integrated initial feature choice into prompts modules

This commit is contained in:
jash
2018-10-06 21:06:38 +02:00
committed by kexkey
parent 54f1d0461e
commit 90d9a8944c
6 changed files with 39 additions and 12 deletions

View File

@@ -0,0 +1,32 @@
const name = 'cyphernode';
module.exports = {
name: function() {
return name;
},
prompts: function( utils ) {
return [{
// https://github.com/SBoudrias/Inquirer.js#question
// input, confirm, list, rawlist, expand, checkbox, password, editor
type: 'checkbox',
name: 'features',
message: 'What features do you want to add to your cyphernode?'+'\n',
choices: utils._featureChoices()
},
{
type: 'confirm',
name: 'cyphernode_rocks0',
default: utils._getDefault( 'cyphernode_rocks0' ),
message: 'Does cyphernode rock?'+'\n',
},
{
type: 'confirm',
name: 'cyphernode_rocks1',
default: utils._getDefault( 'cyphernode_rocks1' ),
message: 'Does cyphernode rock?'+'\n',
}];
},
env: function( props ) {
return 'VAR0=VALUE0\nVAR1=VALUE1'
}
};

View File

@@ -34,16 +34,9 @@ module.exports = class extends Generator {
prompting() {
const splash = fs.readFileSync(this.templatePath('splash.txt'));
this.log(splash.toString());
var prompts = [{
// https://github.com/SBoudrias/Inquirer.js#question
// input, confirm, list, rawlist, expand, checkbox, password, editor
type: 'checkbox',
name: 'features',
message: wrap('What features do you want to add to your cyphernode?')+'\n',
choices: this.featureChoices
}];
let prompts = [];
for( let m of featurePromptModules ) {
prompts = prompts.concat(m.prompts(this));
}
@@ -57,9 +50,7 @@ module.exports = class extends Generator {
fs.writeFileSync('/data/props.json', JSON.stringify(this.props, null, 2));
for( let m of featurePromptModules ) {
const name = m.name();
const env = m.env();
fs.writeFileSync('/data/'+name+'.sh', env);
fs.writeFileSync('/data/'+m.name(), m.env());
}
/*
this.fs.copy(
@@ -93,4 +84,8 @@ module.exports = class extends Generator {
return wrap(text);
}
_featureChoices() {
return this.featureChoices;
}
};