-
-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(sub-generators): tests question added to function sub-generator * feat(sub-generators): function event type query added to function sub-generator * feat(sub-generators): function trigger type can now be passed as a flag * feat(sub-generators): sub-generators now accept basePath parameter to run generator from a nested path * feat(generator): babel-plugin-module-resolver added to `functions` template
- Loading branch information
1 parent
9ca6ac3
commit c3d6ded
Showing
30 changed files
with
688 additions
and
3,375 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,5 +8,8 @@ | |
], | ||
"plugins": [ | ||
"transform-object-rest-spread", | ||
["module-resolver", { | ||
"root": ["./src"] | ||
}] | ||
] | ||
} |
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
'use strict' | ||
const Generator = require('yeoman-generator') | ||
const chalk = require('chalk') | ||
const camelCase = require('lodash/camelCase') | ||
const capitalize = require('lodash/capitalize') | ||
|
||
module.exports = class extends Generator { | ||
constructor (args, opts) { | ||
super(args, opts) | ||
|
||
// Get first cli argument, and set it as this.options.name | ||
this.argument('name', { | ||
required: true, | ||
type: String, | ||
desc: 'The form name' | ||
}) | ||
this.argument('basePath', { | ||
type: String, | ||
required: false, | ||
desc: 'The base path of the components folder (starts at "src")' | ||
}) | ||
} | ||
|
||
prompting () { | ||
this.log( | ||
`${chalk.blue('Generating')} -> Redux-Form Form: ${chalk.green(this.options.name)}` | ||
) | ||
|
||
// return this.prompt(prompts).then((props) => { | ||
// this.answers = props | ||
// }) | ||
} | ||
|
||
writing () { | ||
const cleanedName = this.options.name.replace('Form', '').replace('form', '') | ||
const name = `${capitalize(camelCase(cleanedName))}Form` | ||
const basePathOption = this.options.basePath ? `${this.options.basePath}/` : '' | ||
const basePath = `src/${basePathOption}components/${name}` | ||
const filesArray = [ | ||
{ src: '_index.js', dest: `${basePath}/index.js` }, | ||
{ src: '_main.js', dest: `${basePath}/${name}.js` }, | ||
{ | ||
src: '_main.scss', | ||
dest: `${basePath}/${name}.scss` | ||
}, | ||
{ | ||
src: '_main.enhancer.js', | ||
dest: `${basePath}/${name}.enhancer.js` | ||
} | ||
] | ||
|
||
filesArray.forEach(file => { | ||
this.fs.copyTpl( | ||
this.templatePath(file.src), | ||
this.destinationPath(file.dest), | ||
Object.assign({}, { | ||
name, | ||
lowerName: name.toLowerCase() | ||
}) | ||
) | ||
}) | ||
} | ||
} |
Oops, something went wrong.