generator-team
Version:
Generates an app with CI/CD in Team Foundation Server or Team Services
45 lines (39 loc) • 1.62 kB
JavaScript
// Project
const path = require(`path`);
const app = require(`./app`);
const util = require(`../app/utility`);
const argUtils = require(`../app/args`);
const prompts = require(`../app/prompt`);
const Generator = require(`yeoman-generator`);
module.exports = class extends Generator {
// The name `constructor` is important here
constructor(args, opts) {
// Calling the super constructor is important so our generator is correctly set up
super(args, opts);
// Order is important
argUtils.applicationName(this);
argUtils.tfs(this);
argUtils.pat(this);
}
// 2. Where you prompt users for options (where you'd call this.prompt())
prompting() {
// Collect any missing data from the user.
// This gives me access to the generator in the
// when callbacks of prompt
let cmdLnInput = this;
return this.prompt([
prompts.tfs(this),
prompts.pat(this),
prompts.applicationName(this)
]).then(function (answers) {
// Transfer answers to local object for use in the rest of the generator
this.pat = util.reconcileValue(cmdLnInput.options.pat, answers.pat);
this.tfs = util.reconcileValue(cmdLnInput.options.tfs, answers.tfs);
this.applicationName = util.reconcileValue(cmdLnInput.options.applicationName, answers.applicationName);
}.bind(this));
}
// 3. Saving configurations and configure the project (creating .editorconfig files and other metadata files)
configuring() {
app.run(this, this.async());
}
};