@developer_tribe/react-builder 0.1.10 → 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.
@@ -9,19 +9,16 @@ import { getAllComponents } from './utils/getAllComponents.js';
9
9
  import { checkFolderAndFilesValid } from './utils/checkFolderAndFilesValid.js';
10
10
  import { createMissingFoldersAndFiles } from './utils/createMissingFoldersAndFiles.js';
11
11
  import { createRenderNodeGenerated } from './utils/createRenderNodeGenerated.js';
12
+ import { createComponentsIndex } from './utils/createComponentsIndex.js';
12
13
 
13
14
  const argv = yargs(hideBin(process.argv)).argv;
14
15
  export const args = argv;
15
16
  const builderPath = args.path || 'node_modules/@developer_tribe/react-builder';
16
- const targetPath = process.cwd();
17
17
  const selectedComponents = args.components || [];
18
+ const name = args.name || 'build-components';
18
19
 
19
20
  function run() {
20
- const builderComponentsPath = Path.join(
21
- builderPath,
22
- 'src',
23
- 'build-components'
24
- );
21
+ const builderComponentsPath = Path.join(builderPath, 'src', name);
25
22
  checkPathExists(builderComponentsPath);
26
23
  const components = getAllComponents(builderComponentsPath);
27
24
  for (const component of selectedComponents) {
@@ -30,13 +27,14 @@ function run() {
30
27
  process.exit(1);
31
28
  }
32
29
  }
33
- checkFolderAndFilesValid(targetPath, selectedComponents);
34
- createMissingFoldersAndFiles(targetPath, selectedComponents);
30
+ checkFolderAndFilesValid(builderComponentsPath, selectedComponents);
31
+ createMissingFoldersAndFiles(builderComponentsPath, selectedComponents);
35
32
  createRenderNodeGenerated(
36
33
  builderComponentsPath,
37
- targetPath,
34
+ builderComponentsPath,
38
35
  selectedComponents
39
36
  );
37
+ createComponentsIndex(builderComponentsPath, selectedComponents);
40
38
  }
41
39
 
42
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
  }
@@ -0,0 +1,27 @@
1
+ import fs from 'fs';
2
+ import Path from 'path';
3
+
4
+ export function createComponentsIndex(buildComponentsTarget, components) {
5
+ if (!fs.existsSync(buildComponentsTarget)) {
6
+ fs.mkdirSync(buildComponentsTarget, { recursive: true });
7
+ }
8
+
9
+ const targetPath = Path.join(buildComponentsTarget, 'index.ts');
10
+
11
+ const header = '/* AUTO-GENERATED FILE - DO NOT EDIT */\n\n';
12
+ const renderNodeExport =
13
+ "export { default as RenderNode } from './RenderNode.generated';";
14
+
15
+ const componentExports = components
16
+ .map(name => `export { default as ${name} } from './${name}/${name}';`)
17
+ .join('\n');
18
+
19
+ const content = [header, renderNodeExport, componentExports]
20
+ .filter(Boolean)
21
+ .join('\n\n')
22
+ .concat('\n');
23
+
24
+ fs.writeFileSync(targetPath, content, 'utf8');
25
+ }
26
+
27
+ // no default export
@@ -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
  }
@@ -1,5 +1,7 @@
1
1
  /* AUTO-GENERATED FILE - DO NOT EDIT */
2
2
 
3
+ export { default as RenderNode } from './RenderNode.generated';
4
+
3
5
  export type {
4
6
  ButtonPropsGenerated,
5
7
  ButtonComponentProps,
package/src/index.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import './styles/index.scss';
2
- import RenderNode from './build-components/RenderNode.generated';
3
2
  import AttributesEditor from './AttributesEditor';
4
3
 
5
4
  export { TargetedScreenSize } from './types/TargetedScreenSize';
@@ -18,7 +17,6 @@ export { RenderPage } from './RenderPage';
18
17
  export { RenderMainNode } from './RenderMainNode';
19
18
  export { novaToJson } from './utils/novaToJson';
20
19
  export type { Localication } from './types/PreviewConfig';
21
- export { RenderNode };
22
20
  export { getDevices } from './utils/getDevices';
23
21
  export type { Device } from './types/Device';
24
22
  export { AttributesEditor };