@developer_tribe/react-builder 0.1.9 → 0.1.11

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,6 +9,7 @@ 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;
@@ -37,6 +38,7 @@ function run() {
37
38
  targetPath,
38
39
  selectedComponents
39
40
  );
41
+ createComponentsIndex(targetPath, selectedComponents);
40
42
  }
41
43
 
42
44
  run();
@@ -0,0 +1,33 @@
1
+ import fs from 'fs';
2
+ import Path from 'path';
3
+
4
+ export function createComponentsIndex(targetRootPath, components) {
5
+ const buildComponentsTarget = Path.join(
6
+ targetRootPath,
7
+ 'src',
8
+ 'build-components'
9
+ );
10
+
11
+ if (!fs.existsSync(buildComponentsTarget)) {
12
+ fs.mkdirSync(buildComponentsTarget, { recursive: true });
13
+ }
14
+
15
+ const targetPath = Path.join(buildComponentsTarget, 'index.ts');
16
+
17
+ const header = '/* AUTO-GENERATED FILE - DO NOT EDIT */\n\n';
18
+ const renderNodeExport =
19
+ "export { default as RenderNode } from './RenderNode.generated';";
20
+
21
+ const componentExports = components
22
+ .map(name => `export { default as ${name} } from './${name}/${name}';`)
23
+ .join('\n');
24
+
25
+ const content = [header, renderNodeExport, componentExports]
26
+ .filter(Boolean)
27
+ .join('\n\n')
28
+ .concat('\n');
29
+
30
+ fs.writeFileSync(targetPath, content, 'utf8');
31
+ }
32
+
33
+ // no default export
@@ -42,7 +42,7 @@ export function other(type: string, node: Node): React.ReactNode {
42
42
  const content = `import React from 'react';
43
43
  import type { ${propsName} } from '@developer_tribe/react-builder';
44
44
 
45
- function ${component}(props: { node: any }) {
45
+ function ${component}(props: ${propsName}) {
46
46
  return "hello world";
47
47
  }
48
48
 
@@ -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 };