generate-react-cli 7.0.5 → 7.1.1

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,15 @@
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
+
5
14
  ### [7.0.5](https://github.com/arminbro/generate-react-cli/compare/v7.0.4...v7.0.5) (2022-01-17)
6
15
 
7
16
  ### [7.0.4](https://github.com/arminbro/generate-react-cli/compare/v7.0.3...v7.0.4) (2021-08-07)
@@ -19,7 +19,7 @@ const isNotValidNodeVersion = () => {
19
19
  return false;
20
20
  };
21
21
 
22
- // --- Check if user is running Node 10 or higher.
22
+ // --- Check if user is running Node 12 or higher.
23
23
 
24
24
  if (isNotValidNodeVersion()) {
25
25
  process.exit(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "generate-react-cli",
3
- "version": "7.0.5",
3
+ "version": "7.1.1",
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,12 +34,11 @@
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",
42
- "commander": "^8.1.0",
41
+ "commander": "^9.0.0",
43
42
  "deep-keys": "^0.5.0",
44
43
  "fs-extra": "^10.0.0",
45
44
  "inquirer": "^8.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:
@@ -223,7 +231,15 @@ There is an optional `customTemplates` object that you can pass to the `componen
223
231
  },
224
232
  ```
225
233
 
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. You can also use the keyword `templateName`, which will be replaced with your component name in camelCase.
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 |
227
243
 
228
244
  #### Example of using the `customTemplates` object within your generate-react-cli.json config file:
229
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,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
- 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
- });
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 = {