forked from angular-fullstack/generator-angular-fullstack
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathindex.js
More file actions
77 lines (65 loc) · 2.3 KB
/
index.js
File metadata and controls
77 lines (65 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
'use strict';
var util = require('util');
var ScriptBase = require('../script-base.js');
var exec = require('child_process').exec;
var chalk = require('chalk');
var Generator = module.exports = function Generator() {
ScriptBase.apply(this, arguments);
};
util.inherits(Generator, ScriptBase);
Generator.prototype.checkInstallation = function checkInstallation() {
if(this.name.toLowerCase() != "heroku") return;
var done = this.async();
this.herokuInstalled = false;
exec('heroku --version', function (err) {
if (err) {
this.log.error('You don\'t have the Heroku Toolbelt installed. ' +
'Grab it from https://toolbelt.heroku.com/');
} else {
this.herokuInstalled = true;
}
done();
}.bind(this));
};
Generator.prototype.copyProcfile = function copyProcfile() {
if(this.name.toLowerCase() != "heroku") return;
this.template('../deploy/heroku/Procfile', 'dist/Procfile');
};
Generator.prototype.gruntBuild = function gruntBuild() {
if(this.name.toLowerCase() != "heroku") return;
var done = this.async();
console.log(chalk.bold('Building dist folder, please wait...'));
exec('grunt build', function (err, stdout) {
console.log('stdout: ' + stdout);
if (err) {
this.log.error(err);
}
done();
}.bind(this));
};
Generator.prototype.gitInit = function gitInit() {
if(this.name.toLowerCase() != "heroku") return;
var done = this.async();
exec('git init && git add -A && git commit -m "Initial commit"', { cwd: 'dist' }, function (err) {
if (err) {
this.log.error(err);
}
done();
}.bind(this));
};
Generator.prototype.herokuCreate = function herokuCreate() {
if(this.name.toLowerCase() != "heroku") return;
var done = this.async();
exec('heroku apps:create && heroku config:set NODE_ENV=production', { cwd: 'dist' }, function (err, stdout, stderr) {
if (err) {
this.log.error(err);
} else {
console.log('stdout: ' + stdout);
console.log(chalk.green('You\'re all set! Now push to heroku with\n\t' + chalk.bold('git push heroku master') +
'\nfrom your new ' + chalk.bold('dist') + ' folder'));
console.log(chalk.yellow('After app modification run\n\t' + chalk.bold('grunt build') +
'\nthen commit and push the dist folder'));
}
done();
}.bind(this));
};