generate-react-cli 7.0.6 → 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,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.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",
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:
@@ -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,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
- });
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
+ }
391
393
 
392
394
  console.log(chalk.green(`${filename} was successfully created at ${componentPath}`));
393
395
  } catch (error) {
@@ -397,6 +399,11 @@ function generateComponent(componentName, cmd, cliConfigFile) {
397
399
  }
398
400
  }
399
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
+ }
400
407
  }
401
408
 
402
409
  module.exports = {