This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const Generator = require('yeoman-generator'); | |
const chalk = require('chalk'); | |
const yosay = require('yosay'); | |
module.exports = class extends Generator { | |
// Note: arguments and options should be defined in the constructor. | |
constructor(args, opts) { | |
super(args, opts); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
constructor(args, opts) { | |
super(args, opts); | |
// Define argument. | |
this.argument('arg1', { type: String, required: false }); | |
// Define options | |
this.option('coffee', { type: String, required: false }); | |
// And you can then access it later; e.g. | |
// this.log(this.options.arg1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
writing() { | |
this.fs.copyTpl(this.templatePath('_data.json'), this.destinationPath('/data.json'), { | |
name: this.props.name, | |
cool: this.props.cool | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"projectName": "<%= name %>", | |
"coolFeatures": <%= cool %> | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"projectName": "some-name", | |
"coolFeatures": true | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
prompting() { | |
// Have Yeoman greet the user. | |
this.log(yosay(`Welcome from ${chalk.yellow('KIAN')} development team.`)); | |
const prompts = [ | |
{ | |
type: 'input', | |
name: 'name', | |
message: 'project name?' | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const Generator = require('yeoman-generator'); | |
const chalk = require('chalk'); | |
const yosay = require('yosay'); | |
module.exports = class extends Generator {...} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function async someAction() { | |
const response = await someHelperFunctionThatCallAnotherService(); | |
if (!response) { | |
return dispatch({ | |
type: 'FAILURE' | |
}) | |
} | |
// check schema |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function async someAction() { | |
const response = await someHelperFunctionThatCallAnotherService(); | |
if (!response) { | |
return dispatch({ | |
type: 'FAILURE' | |
}) | |
} | |
return dispatch({ | |
type: 'SUCCESS', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ( foo?.bar?.length ) { | |
return foo.bar.map(items => <Component data={items.hey} />) | |
} |