Files
js-generator-openstack/generators/app/index.js
Michael Krotscheck 07cb1d455d Fixed build dependencies
This patch accomplishes the following:
- It updates node security, as this depended on a version
  of ansi-styles that was unpublished.
- It updates deprecated uses of yeoman Base and yeoman test.
- It adds mem-fs and mem-fs-editor to dependencies, as those are
  only transiently available in later versions of node/npm.
2016-04-04 11:39:51 -07:00

104 lines
2.9 KiB
JavaScript

(function() {
'use strict';
var yeoman = require('yeoman-generator');
var projectBuilder = require('./lib/project_builder');
var Q = require('q');
var gerrit = require('./lib/component/gerrit');
var editorconfig = require('./lib/component/editorconfig');
var license = require('./lib/component/license');
var eslint = require('./lib/component/eslint');
var gitignore = require('./lib/component/gitignore');
module.exports = yeoman.Base.extend({
constructor: function() {
yeoman.Base.apply(this, arguments);
// Add support for a `--non-interactive` flag
this.option('non-interactive');
},
initializing: function() {
var done = this.async();
// Set our own defaults.
this.config.defaults({
projectName: this.appname
});
// Initialize components.
Q(this)
.then(gerrit.init) // Gerrit
.then(editorconfig.init) // Editorconfig
.then(license.init) // Licensing
.then(eslint.init) // Linting
.then(gitignore.init) // Gitignore
.then(function() {
done();
});
},
prompting: function() {
if (!this.options['non-interactive']) {
var done = this.async();
// Prompt components.
Q(this)
.then(gerrit.prompt) // Gerrit
.then(editorconfig.prompt) // Editorconfig
.then(license.prompt) // Licensing
.then(eslint.prompt) // Linting
.then(gitignore.prompt) // Gitignore
.then(function() {
done();
});
}
},
configuring: function() {
var done = this.async();
// Configure components.
Q(this)
.then(gerrit.configure) // Gerrit
.then(editorconfig.configure) // Editorconfig
.then(license.configure) // Licensing
.then(eslint.configure) // Linting
.then(gitignore.configure) // Gitignore
.then(function() {
done();
});
},
writing: function() {
var self = this;
var config = self.config.getAll();
var included = projectBuilder.getIncludedFiles();
var excluded = projectBuilder.getExcludedFiles();
// Write out all files included in the project builder.
included.forEach(function(fileRef) {
if (fileRef.hasOwnProperty('content')) {
var content = typeof fileRef.content === 'function'
? "" + fileRef.content()
: "" + fileRef.content;
self.fs.write(fileRef.to, content);
} else {
self.fs.copyTpl(
self.templatePath(fileRef.from),
self.destinationPath(fileRef.to),
config
);
}
});
// Delete all files explicitly excluded in the project builder.
excluded.forEach(function(path) {
self.fs.delete(self.destinationPath(path));
});
}
});
})();