@developer_tribe/react-builder 0.1.11 → 0.1.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@developer_tribe/react-builder",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "type": "module",
5
5
  "restricted": true,
6
6
  "main": "dist/index.cjs.js",
@@ -14,15 +14,11 @@ import { createComponentsIndex } from './utils/createComponentsIndex.js';
14
14
  const argv = yargs(hideBin(process.argv)).argv;
15
15
  export const args = argv;
16
16
  const builderPath = args.path || 'node_modules/@developer_tribe/react-builder';
17
- const targetPath = process.cwd();
18
17
  const selectedComponents = args.components || [];
18
+ const name = args.name || 'build-components';
19
19
 
20
20
  function run() {
21
- const builderComponentsPath = Path.join(
22
- builderPath,
23
- 'src',
24
- 'build-components'
25
- );
21
+ const builderComponentsPath = Path.join(builderPath, 'src', name);
26
22
  checkPathExists(builderComponentsPath);
27
23
  const components = getAllComponents(builderComponentsPath);
28
24
  for (const component of selectedComponents) {
@@ -31,14 +27,14 @@ function run() {
31
27
  process.exit(1);
32
28
  }
33
29
  }
34
- checkFolderAndFilesValid(targetPath, selectedComponents);
35
- createMissingFoldersAndFiles(targetPath, selectedComponents);
30
+ checkFolderAndFilesValid(builderComponentsPath, selectedComponents);
31
+ createMissingFoldersAndFiles(builderComponentsPath, selectedComponents);
36
32
  createRenderNodeGenerated(
37
33
  builderComponentsPath,
38
- targetPath,
34
+ builderComponentsPath,
39
35
  selectedComponents
40
36
  );
41
- createComponentsIndex(targetPath, selectedComponents);
37
+ createComponentsIndex(builderComponentsPath, selectedComponents);
42
38
  }
43
39
 
44
40
  run();
@@ -12,6 +12,12 @@
12
12
  "type": "array",
13
13
  "describe": "component names",
14
14
  "demandOption": false
15
+ },
16
+ "name": {
17
+ "alias": "n",
18
+ "type": "string",
19
+ "describe": "name of the structure",
20
+ "demandOption": false
15
21
  }
16
22
  }
17
23
  }
@@ -2,12 +2,7 @@ import fs from 'fs';
2
2
  import Path from 'path';
3
3
 
4
4
  // Ensure target build-components folder contains only folders from components list; create missing ones
5
- export function checkFolderAndFilesValid(targetRootPath, components) {
6
- const buildComponentsTarget = Path.join(
7
- targetRootPath,
8
- 'src',
9
- 'build-components'
10
- );
5
+ export function checkFolderAndFilesValid(buildComponentsTarget, components) {
11
6
  if (!fs.existsSync(buildComponentsTarget)) {
12
7
  fs.mkdirSync(buildComponentsTarget, { recursive: true });
13
8
  }
@@ -1,13 +1,7 @@
1
1
  import fs from 'fs';
2
2
  import Path from 'path';
3
3
 
4
- export function createComponentsIndex(targetRootPath, components) {
5
- const buildComponentsTarget = Path.join(
6
- targetRootPath,
7
- 'src',
8
- 'build-components'
9
- );
10
-
4
+ export function createComponentsIndex(buildComponentsTarget, components) {
11
5
  if (!fs.existsSync(buildComponentsTarget)) {
12
6
  fs.mkdirSync(buildComponentsTarget, { recursive: true });
13
7
  }
@@ -6,12 +6,10 @@ function toPropsName(name) {
6
6
  }
7
7
 
8
8
  // Create folders and base component files if missing
9
- export function createMissingFoldersAndFiles(targetRootPath, components) {
10
- const buildComponentsTarget = Path.join(
11
- targetRootPath,
12
- 'src',
13
- 'build-components'
14
- );
9
+ export function createMissingFoldersAndFiles(
10
+ buildComponentsTarget,
11
+ components
12
+ ) {
15
13
  if (!fs.existsSync(buildComponentsTarget)) {
16
14
  fs.mkdirSync(buildComponentsTarget, { recursive: true });
17
15
  }
@@ -14,14 +14,9 @@ function readPatternType(builderComponentsPath, componentName) {
14
14
 
15
15
  export function createRenderNodeGenerated(
16
16
  builderComponentsPath,
17
- targetRootPath,
17
+ buildComponentsTarget,
18
18
  components
19
19
  ) {
20
- const buildComponentsTarget = Path.join(
21
- targetRootPath,
22
- 'src',
23
- 'build-components'
24
- );
25
20
  if (!fs.existsSync(buildComponentsTarget)) {
26
21
  fs.mkdirSync(buildComponentsTarget, { recursive: true });
27
22
  }