generate-react-cli 7.0.5 → 7.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/bin/generate-react +1 -1
- package/package.json +2 -2
- package/readme.md +9 -1
- package/src/utils/generateComponentUtils.js +17 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [7.0.6](https://github.com/arminbro/generate-react-cli/compare/v7.0.5...v7.0.6) (2022-02-21)
|
|
6
|
+
|
|
5
7
|
### [7.0.5](https://github.com/arminbro/generate-react-cli/compare/v7.0.4...v7.0.5) (2022-01-17)
|
|
6
8
|
|
|
7
9
|
### [7.0.4](https://github.com/arminbro/generate-react-cli/compare/v7.0.3...v7.0.4) (2021-08-07)
|
package/bin/generate-react
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "generate-react-cli",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.6",
|
|
4
4
|
"description": "A simple React CLI to generate components instantly and more.",
|
|
5
5
|
"repository": "https://github.com/arminbro/generate-react-cli",
|
|
6
6
|
"bugs": "https://github.com/arminbro/generate-react-cli/issues",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"chalk": "^4.1.2",
|
|
42
|
-
"commander": "^
|
|
42
|
+
"commander": "^9.0.0",
|
|
43
43
|
"deep-keys": "^0.5.0",
|
|
44
44
|
"fs-extra": "^10.0.0",
|
|
45
45
|
"inquirer": "^8.1.2",
|
package/readme.md
CHANGED
|
@@ -223,7 +223,15 @@ There is an optional `customTemplates` object that you can pass to the `componen
|
|
|
223
223
|
},
|
|
224
224
|
```
|
|
225
225
|
|
|
226
|
-
The keys represent the type of file, and the values are the paths that point to where your custom template lives in your project/system. Please note the `TemplateName` keyword in the template filename. GRC will use this keyword and replace it with your component name as the filename.
|
|
226
|
+
The keys represent the type of file, and the values are the paths that point to where your custom template lives in your project/system. Please note the `TemplateName` keyword in the template filename. GRC will use this keyword and replace it with your component name as the filename.
|
|
227
|
+
|
|
228
|
+
You can also use the following keywords, which will be replaced with their corresponding formatted component name:
|
|
229
|
+
|
|
230
|
+
| Keyword | Replacement |
|
|
231
|
+
|-----------------|------------------------------|
|
|
232
|
+
| `templateName` | component name in camelCase |
|
|
233
|
+
| `template-name` | component name in kebab-case |
|
|
234
|
+
| `template_name` | component name in snake_case |
|
|
227
235
|
|
|
228
236
|
#### Example of using the `customTemplates` object within your generate-react-cli.json config file:
|
|
229
237
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const chalk = require('chalk');
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const replace = require('replace');
|
|
4
|
-
const { camelCase } = require('lodash');
|
|
4
|
+
const { camelCase, kebabCase, snakeCase } = require('lodash');
|
|
5
5
|
const { existsSync, outputFileSync, readFileSync } = require('fs-extra');
|
|
6
6
|
|
|
7
7
|
const componentJsTemplate = require('../templates/component/componentJsTemplate');
|
|
@@ -373,6 +373,22 @@ function generateComponent(componentName, cmd, cliConfigFile) {
|
|
|
373
373
|
silent: true,
|
|
374
374
|
});
|
|
375
375
|
|
|
376
|
+
replace({
|
|
377
|
+
regex: 'template-name',
|
|
378
|
+
replacement: kebabCase(componentName),
|
|
379
|
+
paths: [componentPath],
|
|
380
|
+
recursive: false,
|
|
381
|
+
silent: true,
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
replace({
|
|
385
|
+
regex: 'template_name',
|
|
386
|
+
replacement: snakeCase(componentName),
|
|
387
|
+
paths: [componentPath],
|
|
388
|
+
recursive: false,
|
|
389
|
+
silent: true,
|
|
390
|
+
});
|
|
391
|
+
|
|
376
392
|
console.log(chalk.green(`${filename} was successfully created at ${componentPath}`));
|
|
377
393
|
} catch (error) {
|
|
378
394
|
console.error(chalk.red(`${filename} failed and was not created.`));
|