generate-react-cli 7.0.6 → 7.2.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,13 @@
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
+
5
12
  ### [7.0.6](https://github.com/arminbro/generate-react-cli/compare/v7.0.5...v7.0.6) (2022-02-21)
6
13
 
7
14
  ### [7.0.5](https://github.com/arminbro/generate-react-cli/compare/v7.0.4...v7.0.5) (2022-01-17)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "generate-react-cli",
3
- "version": "7.0.6",
3
+ "version": "7.2.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",
@@ -34,8 +34,7 @@
34
34
  "maintained node versions"
35
35
  ],
36
36
  "scripts": {
37
- "commit": "npx git-cz",
38
- "release": "standard-version"
37
+ "prepare": "husky install"
39
38
  },
40
39
  "dependencies": {
41
40
  "chalk": "^4.1.2",
@@ -47,18 +46,65 @@
47
46
  "replace": "^1.2.0"
48
47
  },
49
48
  "devDependencies": {
50
- "cz-conventional-changelog": "^3.3.0",
49
+ "@commitlint/cli": "^13.2.1",
50
+ "@commitlint/config-conventional": "^13.2.0",
51
+ "@semantic-release/commit-analyzer": "^9.0.1",
52
+ "@semantic-release/git": "^10.0.0",
53
+ "@semantic-release/github": "^8.0.1",
54
+ "@semantic-release/npm": "^8.0.0",
55
+ "@semantic-release/release-notes-generator": "^10.0.2",
51
56
  "eslint": "^8.7.0",
52
57
  "eslint-config-airbnb-base": "^15.0.0",
53
58
  "eslint-config-prettier": "^8.3.0",
54
59
  "eslint-plugin-prettier": "^4.0.0",
60
+ "husky": "^7.0.4",
55
61
  "prettier": "2.5.1",
56
- "rimraf": "^3.0.2",
57
- "standard-version": "^9.3.1"
62
+ "pretty-quick": "^3.1.3",
63
+ "semantic-release": "^18.0.0"
58
64
  },
59
- "config": {
60
- "commitizen": {
61
- "path": "./node_modules/cz-conventional-changelog"
62
- }
65
+ "prettier": {
66
+ "singleQuote": true,
67
+ "trailingComma": "es5",
68
+ "printWidth": 120
69
+ },
70
+ "release": {
71
+ "branches": [
72
+ "main"
73
+ ],
74
+ "plugins": [
75
+ "@semantic-release/commit-analyzer",
76
+ "@semantic-release/release-notes-generator",
77
+ "@semantic-release/npm",
78
+ [
79
+ "@semantic-release/git",
80
+ {
81
+ "assets": [
82
+ "package.json"
83
+ ],
84
+ "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
85
+ }
86
+ ],
87
+ "@semantic-release/github"
88
+ ]
89
+ },
90
+ "commitlint": {
91
+ "extends": [
92
+ "@commitlint/config-conventional"
93
+ ]
94
+ },
95
+ "eslintConfig": {
96
+ "extends": [
97
+ "airbnb-base",
98
+ "plugin:prettier/recommended"
99
+ ],
100
+ "env": {
101
+ "commonjs": true,
102
+ "es2021": true,
103
+ "node": true
104
+ },
105
+ "parserOptions": {
106
+ "ecmaVersion": 12
107
+ },
108
+ "rules": {}
63
109
  }
64
110
  }
package/readme.md CHANGED
@@ -151,6 +151,14 @@ Otherwise, if you don't pass any options, it will just use the default values th
151
151
  <td width="20%">Boolean</td>
152
152
  <td width="20%"><code>component.default.withTest<code></td>
153
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>
154
162
  </table>
155
163
 
156
164
  ### Custom component types:
@@ -227,11 +235,12 @@ The keys represent the type of file, and the values are the paths that point to
227
235
 
228
236
  You can also use the following keywords, which will be replaced with their corresponding formatted component name:
229
237
 
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 |
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 |
243
+ | `TEMPLATE_NAME` | component name in uppercase SNAKE_CASE |
235
244
 
236
245
  #### Example of using the `customTemplates` object within your generate-react-cli.json config file:
237
246
 
@@ -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) =>
@@ -355,39 +355,49 @@ 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
- outputFileSync(componentPath, template);
359
-
360
- replace({
361
- regex: 'TemplateName',
362
- replacement: componentName,
363
- paths: [componentPath],
364
- recursive: false,
365
- silent: true,
366
- });
367
-
368
- replace({
369
- regex: 'templateName',
370
- replacement: camelCase(componentName),
371
- paths: [componentPath],
372
- recursive: false,
373
- silent: true,
374
- });
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
- });
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
+
393
+ replace({
394
+ regex: 'TEMPLATE_NAME',
395
+ replacement: snakeCase(componentName).toUpperCase(),
396
+ paths: [componentPath],
397
+ recursive: false,
398
+ silent: true,
399
+ });
400
+ }
391
401
 
392
402
  console.log(chalk.green(`${filename} was successfully created at ${componentPath}`));
393
403
  } catch (error) {
@@ -397,6 +407,11 @@ function generateComponent(componentName, cmd, cliConfigFile) {
397
407
  }
398
408
  }
399
409
  });
410
+
411
+ if (cmd.dryRun) {
412
+ console.log()
413
+ console.log(chalk.yellow(`NOTE: The "dry-run" flag means no changes were made.`))
414
+ }
400
415
  }
401
416
 
402
417
  module.exports = {