install() { if (this.options.apply) { common.spawnKubectlCommand(this, this.destinationRoot(), "apply"); } }
// 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) this.argument('duckName', { type: String, required: false }) if (this.options.duckName) { this.duckName = _.camelCase(this.options.duckName) } }
generators.extend({ // The name `constructor` is important here constructor: function () { // Calling the super constructor is important so our generator is correctly set up generators.apply(this, arguments); }, method: function () { console.log('UPDATING JSON File: ', this.options.filePath); var config = Object.assign(require(this.options.filePath), this.options.replace); fs.writeFileSync(this.options.filePath, JSON.stringify(config, null, 2)); this.log(chalk.green('Updating: ', this.options.filePath)); } })
writeProjectConfigFile () { var configJson = { 'projectName': this.options.projectName, 'qtyScreens': this.options.qtyScreens, 'markupLanguage': this.options.markupLanguage, 'frontEndFramework': this.options.frontEndFramework, 'jQuery': this.options.jQuery || this.options.frontEndFramework, 'generatedBy': 'Pixel2HTML', 'generatorVersion': pkg.version, 'generatedAt': new Date(), } this.fs.writeJSON('./.project.conf', configJson) }
// 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) this.argument('viewName', { type: String, required: false }) if (this.options.viewName) { this.viewName = _.upperFirst(_.camelCase(this.options.viewName)) } }
copyHeadFiles () { this.fs.copy( this.templatePath('assets/head/favico.ico'), this.destinationPath(this.paths.src.head + '/favico.ico') ) this.fs.copy( this.templatePath('assets/head/favicon.png'), this.destinationPath(this.paths.src.head + '/favicon.png') ) this.fs.copyTpl( this.templatePath('assets/head/manifest.json.ejs'), this.destinationPath(this.paths.src.head + '/manifest.json'), { projectName: this.options.projectName } ) }
function constructor() { generators.Base.apply(this, arguments); }
for (var i = 1; i < this.options.qtyScreens + 1; i++) { this.fs.copyTpl( this.templatePath('styles/main/screens/_screen.scss'), this.destinationPath(this.paths.src.styles + '/main/screens/_screen_' + i + '.scss'), { screenNumber: i, projectName: this.options.projectName this.destinationPath(`src/assets/${file}`), { screenNumber: i, projectName: this.options.projectName, qtyScreens: this.options.qtyScreens, frontEndFramework: this.options.frontEndFramework
prompting() { const prompts = [] if (!this.options.generatorName) { prompts.push({ type: 'input', name: 'generatorName', message: 'What would like to name this generator?', validate: (input) => { if (input.length <= 0) { return 'You must provide a generator name' } return true } }) } return this.prompt(prompts).then((answers) => { if (answers.generatorName) { this.generatorName = _.kebabCase(answers.generatorName) } }) }
writeBaseScriptsFiles () { this.log(chalk.yellow('Copying js main file.')) this.fs.copyTpl( this.templatePath('scripts/app.js'), this.destinationPath(this.paths.src.scripts + '/app.js'), { projectName: this.options.projectName, frontEndFramework: this.options.frontEndFramework } ) this.fs.copyTpl( this.templatePath('scripts/index.js.ejs'), this.destinationPath(this.paths.src.scripts + '/index.js'), { projectName: this.options.projectName, frontEndFramework: this.options.frontEndFramework, jQuery: this.options.jQuery } ) if (this.options.frontEndFramework) { this.fs.copyTpl( this.templatePath('scripts/framework.js.ejs'), this.destinationPath(this.paths.src.scripts + '/framework.js'), { projectName: this.options.projectName, frontEndFramework: this.options.frontEndFramework, jQuery: this.options.jQuery } ) } }
writeHtmlFiles () { if (this.options.markupLanguage === 'html') { for (var i = 1; i < this.options.qtyScreens + 1; i++) { const filePath = i === 1 ? '/index.html' : '/screen-' + i + '.' + this.options.markupLanguage this.fs.copyTpl( this.templatePath('markup/_screen.' + this.options.markupLanguage + '.ejs'), this.destinationPath(this.paths.src.markup + filePath), { screenNumber: i, projectName: this.options.projectName, frontEndFramework: this.options.frontEndFramework, jQuery: this.options.jQuery } ) } } }
// 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) this.argument('generatorName', { type: String, required: false }) if (this.options.generatorName) { this.generatorName = _.kebabCase(this.options.generatorName) } }
prompting() { const prompts = [] if (!this.options.viewName) { prompts.push({ type: 'input', name: 'viewName', message: 'What would like to name this View?', validate: (input) => { if (input.length <= 0) { return 'You must provide a view name' } return true } }) } return this.prompt(prompts).then((answers) => { if (answers.viewName) { this.viewName = _.upperFirst(_.camelCase(answers.viewName)) } }) }
// 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) this.argument('componentName', { type: String, required: false }) if (this.options.componentName) { this.componentName = _.upperFirst(_.camelCase(this.options.componentName)) } }
function constructor() { generators.Base.apply(this, arguments); }