generate-react-cli 7.0.4 → 7.1.0
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
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
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.1.0](https://github.com/arminbro/generate-react-cli/compare/v7.0.6...v7.1.0) (2022-03-15)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* adds dry-run flag to preview generated paths without writing files ([483aef2](https://github.com/arminbro/generate-react-cli/commit/483aef285a356bb02727d3c512d2e03e22b6493a))
|
|
11
|
+
|
|
12
|
+
### [7.0.6](https://github.com/arminbro/generate-react-cli/compare/v7.0.5...v7.0.6) (2022-02-21)
|
|
13
|
+
|
|
14
|
+
### [7.0.5](https://github.com/arminbro/generate-react-cli/compare/v7.0.4...v7.0.5) (2022-01-17)
|
|
15
|
+
|
|
5
16
|
### [7.0.4](https://github.com/arminbro/generate-react-cli/compare/v7.0.3...v7.0.4) (2021-08-07)
|
|
6
17
|
|
|
7
18
|
|
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.1.0",
|
|
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",
|
|
@@ -48,11 +48,11 @@
|
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"cz-conventional-changelog": "^3.3.0",
|
|
51
|
-
"eslint": "^7.
|
|
52
|
-
"eslint-config-airbnb-base": "^
|
|
51
|
+
"eslint": "^8.7.0",
|
|
52
|
+
"eslint-config-airbnb-base": "^15.0.0",
|
|
53
53
|
"eslint-config-prettier": "^8.3.0",
|
|
54
|
-
"eslint-plugin-prettier": "^
|
|
55
|
-
"prettier": "2.
|
|
54
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
55
|
+
"prettier": "2.5.1",
|
|
56
56
|
"rimraf": "^3.0.2",
|
|
57
57
|
"standard-version": "^9.3.1"
|
|
58
58
|
},
|
package/readme.md
CHANGED
|
@@ -13,6 +13,8 @@ To help speed up productivity in React projects and stop copying, pasting, and r
|
|
|
13
13
|
|
|
14
14
|
A short [article](https://dev.to/arminbro/generate-react-cli-1ooh) that goes a little deeper into why we created GRC if you have the time.
|
|
15
15
|
|
|
16
|
+
Suppose you enjoy learning by watching tutorial videos. Here's an excellent [video](https://www.youtube.com/watch?v=NEvnt3MWttY) on how to use GRC by [Eric Murphy](https://www.youtube.com/channel/UC5KDiSAFxrDWhmysBcNqtMA).
|
|
17
|
+
|
|
16
18
|
**_A few notes:_**
|
|
17
19
|
|
|
18
20
|
- Now supports custom component types ([read more](#custom-component-types)). 🎉
|
|
@@ -149,6 +151,14 @@ Otherwise, if you don't pass any options, it will just use the default values th
|
|
|
149
151
|
<td width="20%">Boolean</td>
|
|
150
152
|
<td width="20%"><code>component.default.withTest<code></td>
|
|
151
153
|
</tr>
|
|
154
|
+
<tr>
|
|
155
|
+
<td width="20%"><b>--dry-run</b></td>
|
|
156
|
+
<td width="60%">
|
|
157
|
+
Show what will be generated without writing to disk
|
|
158
|
+
</td>
|
|
159
|
+
<td width="20%">Boolean</td>
|
|
160
|
+
<td width="20%"><code>false<code></td>
|
|
161
|
+
</tr>
|
|
152
162
|
</table>
|
|
153
163
|
|
|
154
164
|
### Custom component types:
|
|
@@ -221,7 +231,15 @@ There is an optional `customTemplates` object that you can pass to the `componen
|
|
|
221
231
|
},
|
|
222
232
|
```
|
|
223
233
|
|
|
224
|
-
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.
|
|
234
|
+
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.
|
|
235
|
+
|
|
236
|
+
You can also use the following keywords, which will be replaced with their corresponding formatted component name:
|
|
237
|
+
|
|
238
|
+
| Keyword | Replacement |
|
|
239
|
+
|-----------------|------------------------------|
|
|
240
|
+
| `templateName` | component name in camelCase |
|
|
241
|
+
| `template-name` | component name in kebab-case |
|
|
242
|
+
| `template_name` | component name in snake_case |
|
|
225
243
|
|
|
226
244
|
#### Example of using the `customTemplates` object within your generate-react-cli.json config file:
|
|
227
245
|
|
|
@@ -34,6 +34,8 @@ function initGenerateComponentCommand(args, cliConfigFile, program) {
|
|
|
34
34
|
);
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
+
componentCommand.option('--dry-run', 'Show what will be generated without writing to disk')
|
|
38
|
+
|
|
37
39
|
// Component command action.
|
|
38
40
|
|
|
39
41
|
componentCommand.action((componentNames, cmd) =>
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
module.exports = `import React from 'react';
|
|
1
|
+
module.exports = `import React, { FC } from 'react';
|
|
2
2
|
import styles from './TemplateName.module.css';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
interface TemplateNameProps {}
|
|
5
|
+
|
|
6
|
+
const TemplateName: FC<TemplateNameProps> = () => (
|
|
5
7
|
<div className={styles.TemplateName} data-testid="TemplateName">
|
|
6
8
|
TemplateName Component
|
|
7
9
|
</div>
|
|
@@ -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');
|
|
@@ -355,23 +355,41 @@ function generateComponent(componentName, cmd, cliConfigFile) {
|
|
|
355
355
|
console.error(chalk.red(`${filename} already exists in this path "${componentPath}".`));
|
|
356
356
|
} else {
|
|
357
357
|
try {
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
358
|
+
if (!cmd.dryRun) {
|
|
359
|
+
outputFileSync(componentPath, template);
|
|
360
|
+
|
|
361
|
+
replace({
|
|
362
|
+
regex: 'TemplateName',
|
|
363
|
+
replacement: componentName,
|
|
364
|
+
paths: [componentPath],
|
|
365
|
+
recursive: false,
|
|
366
|
+
silent: true,
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
replace({
|
|
370
|
+
regex: 'templateName',
|
|
371
|
+
replacement: camelCase(componentName),
|
|
372
|
+
paths: [componentPath],
|
|
373
|
+
recursive: false,
|
|
374
|
+
silent: true,
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
replace({
|
|
378
|
+
regex: 'template-name',
|
|
379
|
+
replacement: kebabCase(componentName),
|
|
380
|
+
paths: [componentPath],
|
|
381
|
+
recursive: false,
|
|
382
|
+
silent: true,
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
replace({
|
|
386
|
+
regex: 'template_name',
|
|
387
|
+
replacement: snakeCase(componentName),
|
|
388
|
+
paths: [componentPath],
|
|
389
|
+
recursive: false,
|
|
390
|
+
silent: true,
|
|
391
|
+
});
|
|
392
|
+
}
|
|
375
393
|
|
|
376
394
|
console.log(chalk.green(`${filename} was successfully created at ${componentPath}`));
|
|
377
395
|
} catch (error) {
|
|
@@ -381,6 +399,11 @@ function generateComponent(componentName, cmd, cliConfigFile) {
|
|
|
381
399
|
}
|
|
382
400
|
}
|
|
383
401
|
});
|
|
402
|
+
|
|
403
|
+
if (cmd.dryRun) {
|
|
404
|
+
console.log()
|
|
405
|
+
console.log(chalk.yellow(`NOTE: The "dry-run" flag means no changes were made.`))
|
|
406
|
+
}
|
|
384
407
|
}
|
|
385
408
|
|
|
386
409
|
module.exports = {
|