generator-homebase
Version:
generators for workclout homebase codebase
54 lines (49 loc) • 1.29 kB
JavaScript
"use strict";
const Generator = require("yeoman-generator");
const chalk = require("chalk");
const yosay = require("yosay");
module.exports = class extends Generator {
prompting() {
// Have Yeoman greet the user.
this.log(
yosay(
`Welcome to the funkadelic ${chalk.red(
"generator-homebase"
)} generator!`
)
);
const prompts = [
{
type: "input",
name: "name",
message: "Your modal name (CamelCase)"
}
];
return this.prompt(prompts).then(props => {
// To access props later use this.props.someAnswer;
this.props = {
lowerCaseName: props.name.charAt(0).toLowerCase() + props.name.slice(1),
...props
};
});
}
writing() {
this.fs.copyTpl(
this.templatePath("_test.ejs"),
this.destinationPath(`src/components/${this.props.name}/test.tsx`),
this.props
);
this.fs.copyTpl(
this.templatePath("_Modal.stories.ejs"),
this.destinationPath(
`src/components/${this.props.name}/${this.props.name}.stories.tsx`
),
this.props
);
this.fs.copyTpl(
this.templatePath("_index.ejs"),
this.destinationPath(`src/components/${this.props.name}/index.tsx`),
this.props
);
}
};