@developer_tribe/react-builder 0.1.2 → 0.1.7

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.
Files changed (91) hide show
  1. package/dist/build-components/Button/Button.d.ts +2 -2
  2. package/dist/build-components/Carousel/Carousel.d.ts +2 -2
  3. package/dist/build-components/CarouselButtons/CarouselButtons.d.ts +2 -2
  4. package/dist/build-components/CarouselDots/CarouselDots.d.ts +2 -2
  5. package/dist/build-components/CarouselItem/CarouselItem.d.ts +2 -2
  6. package/dist/build-components/CarouselProvider/CarouselProvider.d.ts +2 -2
  7. package/dist/build-components/Image/Image.d.ts +2 -2
  8. package/dist/build-components/Onboard/Onboard.d.ts +2 -2
  9. package/dist/build-components/OnboardBoardTitle/OnboardBoardTitle.d.ts +2 -2
  10. package/dist/build-components/OnboardButton/OnboardButton.d.ts +2 -2
  11. package/dist/build-components/OnboardButtons/OnboardButtons.d.ts +2 -2
  12. package/dist/build-components/OnboardExpandingDot/OnboardExpandingDot.d.ts +2 -2
  13. package/dist/build-components/OnboardFooter/OnboardFooter.d.ts +2 -2
  14. package/dist/build-components/OnboardImage/OnboardImage.d.ts +2 -2
  15. package/dist/build-components/OnboardItem/OnboardItem.d.ts +2 -2
  16. package/dist/build-components/OnboardProvider/OnboardProvider.d.ts +2 -2
  17. package/dist/build-components/OnboardSubtitle/OnboardSubtitle.d.ts +2 -2
  18. package/dist/build-components/RenderNode.generated.d.ts +1 -1
  19. package/dist/build-components/Text/Text.d.ts +2 -2
  20. package/dist/build-components/View/View.d.ts +2 -2
  21. package/dist/build-components/other.d.ts +3 -0
  22. package/dist/utils/generateRandomKeyForNode.d.ts +1 -0
  23. package/package.json +9 -4
  24. package/scripts/{build-components.js → prebuild/build-components.js} +8 -30
  25. package/scripts/public/bin.js +57 -0
  26. package/scripts/public/scripts/build/index.js +42 -0
  27. package/scripts/public/scripts/build/info.json +17 -0
  28. package/scripts/public/scripts/build/utils/checkFolderAndFilesValid.js +41 -0
  29. package/scripts/public/scripts/build/utils/checkPathExists.js +9 -0
  30. package/scripts/public/scripts/build/utils/createMissingFoldersAndFiles.js +54 -0
  31. package/scripts/public/scripts/build/utils/createRenderNodeGenerated.js +82 -0
  32. package/scripts/public/scripts/build/utils/getAllComponents.js +11 -0
  33. package/src/build-components/Button/Button.tsx +2 -2
  34. package/src/build-components/Carousel/Carousel.tsx +2 -2
  35. package/src/build-components/CarouselButtons/CarouselButtons.tsx +2 -2
  36. package/src/build-components/CarouselDots/CarouselDots.tsx +2 -2
  37. package/src/build-components/CarouselItem/CarouselItem.tsx +2 -2
  38. package/src/build-components/CarouselProvider/CarouselProvider.tsx +2 -2
  39. package/src/build-components/Image/Image.tsx +2 -2
  40. package/src/build-components/Onboard/Onboard.tsx +2 -2
  41. package/src/build-components/OnboardBoardTitle/OnboardBoardTitle.tsx +2 -2
  42. package/src/build-components/OnboardButton/OnboardButton.tsx +2 -2
  43. package/src/build-components/OnboardButtons/OnboardButtons.tsx +2 -2
  44. package/src/build-components/OnboardExpandingDot/OnboardExpandingDot.tsx +2 -2
  45. package/src/build-components/OnboardFooter/OnboardFooter.tsx +2 -2
  46. package/src/build-components/OnboardImage/OnboardImage.tsx +2 -2
  47. package/src/build-components/OnboardItem/OnboardItem.tsx +2 -2
  48. package/src/build-components/OnboardProvider/OnboardProvider.tsx +2 -2
  49. package/src/build-components/OnboardSubtitle/OnboardSubtitle.tsx +2 -2
  50. package/src/build-components/Text/Text.tsx +2 -2
  51. package/src/build-components/View/View.tsx +3 -3
  52. package/src/utils/novaToJson.ts +0 -1
  53. package/dist/build-components/Button/ButtonProps.d.ts +0 -3
  54. package/dist/build-components/Carousel/CarouselProps.d.ts +0 -3
  55. package/dist/build-components/CarouselButtons/CarouselButtonsProps.d.ts +0 -3
  56. package/dist/build-components/CarouselDots/CarouselDotsProps.d.ts +0 -3
  57. package/dist/build-components/CarouselItem/CarouselItemProps.d.ts +0 -3
  58. package/dist/build-components/CarouselProvider/CarouselProviderProps.d.ts +0 -3
  59. package/dist/build-components/Image/ImageProps.d.ts +0 -3
  60. package/dist/build-components/Onboard/OnboardProps.d.ts +0 -3
  61. package/dist/build-components/OnboardBoardTitle/OnboardBoardTitleProps.d.ts +0 -3
  62. package/dist/build-components/OnboardButton/OnboardButtonProps.d.ts +0 -3
  63. package/dist/build-components/OnboardButtons/OnboardButtonsProps.d.ts +0 -3
  64. package/dist/build-components/OnboardExpandingDot/OnboardExpandingDotProps.d.ts +0 -3
  65. package/dist/build-components/OnboardFooter/OnboardFooterProps.d.ts +0 -3
  66. package/dist/build-components/OnboardImage/OnboardImageProps.d.ts +0 -3
  67. package/dist/build-components/OnboardItem/OnboardItemProps.d.ts +0 -3
  68. package/dist/build-components/OnboardProvider/OnboardProviderProps.d.ts +0 -3
  69. package/dist/build-components/OnboardSubtitle/OnboardSubtitleProps.d.ts +0 -3
  70. package/dist/build-components/Text/TextProps.d.ts +0 -3
  71. package/dist/build-components/View/ViewProps.d.ts +0 -3
  72. package/src/build-components/Button/ButtonProps.ts +0 -3
  73. package/src/build-components/Carousel/CarouselProps.ts +0 -3
  74. package/src/build-components/CarouselButtons/CarouselButtonsProps.ts +0 -3
  75. package/src/build-components/CarouselDots/CarouselDotsProps.ts +0 -3
  76. package/src/build-components/CarouselItem/CarouselItemProps.ts +0 -3
  77. package/src/build-components/CarouselProvider/CarouselProviderProps.ts +0 -3
  78. package/src/build-components/Image/ImageProps.ts +0 -3
  79. package/src/build-components/Onboard/OnboardProps.ts +0 -3
  80. package/src/build-components/OnboardBoardTitle/OnboardBoardTitleProps.ts +0 -4
  81. package/src/build-components/OnboardButton/OnboardButtonProps.ts +0 -3
  82. package/src/build-components/OnboardButtons/OnboardButtonsProps.ts +0 -3
  83. package/src/build-components/OnboardExpandingDot/OnboardExpandingDotProps.ts +0 -4
  84. package/src/build-components/OnboardFooter/OnboardFooterProps.ts +0 -3
  85. package/src/build-components/OnboardImage/OnboardImageProps.ts +0 -3
  86. package/src/build-components/OnboardItem/OnboardItemProps.ts +0 -3
  87. package/src/build-components/OnboardProvider/OnboardProviderProps.ts +0 -3
  88. package/src/build-components/OnboardSubtitle/OnboardSubtitleProps.ts +0 -3
  89. package/src/build-components/Text/TextProps.ts +0 -3
  90. package/src/build-components/View/ViewProps.ts +0 -3
  91. /package/scripts/{prebuild.js → prebuild/prebuild.js} +0 -0
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  import type { NodeData } from '../../types/Node';
3
- import type { ButtonProps } from './ButtonProps';
3
+ import type { ButtonPropsGenerated } from './ButtonProps.generated';
4
4
  type ButtonComponentProps = {
5
- node: NodeData<ButtonProps['attributes']>;
5
+ node: NodeData<ButtonPropsGenerated['attributes']>;
6
6
  };
7
7
  declare function Button({ node }: ButtonComponentProps): string;
8
8
  declare const _default: React.MemoExoticComponent<typeof Button>;
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  import type { NodeData } from '../../types/Node';
3
- import type { CarouselProps } from './CarouselProps';
3
+ import type { CarouselPropsGenerated } from './CarouselProps.generated';
4
4
  type CarouselComponentProps = {
5
- node: NodeData<CarouselProps['attributes']>;
5
+ node: NodeData<CarouselPropsGenerated['attributes']>;
6
6
  };
7
7
  declare function Carousel({ node }: CarouselComponentProps): import("react/jsx-runtime").JSX.Element;
8
8
  declare const _default: React.MemoExoticComponent<typeof Carousel>;
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  import type { NodeData } from '../../types/Node';
3
- import type { CarouselButtonsProps } from './CarouselButtonsProps';
3
+ import type { CarouselButtonsPropsGenerated } from './CarouselButtonsProps.generated';
4
4
  type CarouselButtonsComponentProps = {
5
- node: NodeData<CarouselButtonsProps['attributes']>;
5
+ node: NodeData<CarouselButtonsPropsGenerated['attributes']>;
6
6
  };
7
7
  declare function CarouselButtons({ node }: CarouselButtonsComponentProps): import("react/jsx-runtime").JSX.Element;
8
8
  declare const _default: React.MemoExoticComponent<typeof CarouselButtons>;
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  import type { NodeData } from '../../types/Node';
3
- import type { CarouselDotsProps } from './CarouselDotsProps';
3
+ import type { CarouselDotsPropsGenerated } from './CarouselDotsProps.generated';
4
4
  type CarouselDotsComponentProps = {
5
- node: NodeData<CarouselDotsProps['attributes']>;
5
+ node: NodeData<CarouselDotsPropsGenerated['attributes']>;
6
6
  };
7
7
  declare function CarouselDots({ node }: CarouselDotsComponentProps): import("react/jsx-runtime").JSX.Element;
8
8
  declare const _default: React.MemoExoticComponent<typeof CarouselDots>;
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  import type { NodeData } from '../../types/Node';
3
- import type { CarouselItemProps } from './CarouselItemProps';
3
+ import type { CarouselItemPropsGenerated } from './CarouselItemProps.generated';
4
4
  type CarouselItemComponentProps = {
5
- node: NodeData<CarouselItemProps['attributes']>;
5
+ node: NodeData<CarouselItemPropsGenerated['attributes']>;
6
6
  };
7
7
  export declare function CarouselItem({ node }: CarouselItemComponentProps): import("react/jsx-runtime").JSX.Element;
8
8
  declare const _default: React.MemoExoticComponent<typeof CarouselItem>;
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  import type { NodeData } from '../../types/Node';
3
- import type { CarouselProviderProps } from './CarouselProviderProps';
3
+ import type { CarouselProviderPropsGenerated } from './CarouselProviderProps.generated';
4
4
  type CarouselProviderComponentProps = {
5
- node: NodeData<CarouselProviderProps['attributes']>;
5
+ node: NodeData<CarouselProviderPropsGenerated['attributes']>;
6
6
  };
7
7
  export declare const carouselContext: React.Context<any>;
8
8
  declare function CarouselProvider({ node }: CarouselProviderComponentProps): import("react/jsx-runtime").JSX.Element;
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  import type { NodeData } from '../../types/Node';
3
- import type { ImageProps } from './ImageProps';
3
+ import type { ImagePropsGenerated } from './ImageProps.generated';
4
4
  type ImageComponentProps = {
5
- node: NodeData<ImageProps['attributes']>;
5
+ node: NodeData<ImagePropsGenerated['attributes']>;
6
6
  };
7
7
  declare function Image({ node }: ImageComponentProps): import("react/jsx-runtime").JSX.Element;
8
8
  declare const _default: React.MemoExoticComponent<typeof Image>;
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  import type { NodeData } from '../../types/Node';
3
- import type { OnboardProps } from './OnboardProps';
3
+ import type { OnboardPropsGenerated } from './OnboardProps.generated';
4
4
  type OnboardComponentProps = {
5
- node: NodeData<OnboardProps['attributes']>;
5
+ node: NodeData<OnboardPropsGenerated['attributes']>;
6
6
  };
7
7
  declare function Onboard({ node }: OnboardComponentProps): import("react/jsx-runtime").JSX.Element;
8
8
  declare const _default: React.MemoExoticComponent<typeof Onboard>;
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  import type { NodeData } from '../../types/Node';
3
- import type { OnboardBoardTitleProps } from './OnboardBoardTitleProps';
3
+ import type { OnboardBoardTitlePropsGenerated } from './OnboardBoardTitleProps.generated';
4
4
  type OnboardBoardTitleComponentProps = {
5
- node: NodeData<OnboardBoardTitleProps['attributes']>;
5
+ node: NodeData<OnboardBoardTitlePropsGenerated['attributes']>;
6
6
  };
7
7
  declare function OnboardBoardTitle({ node }: OnboardBoardTitleComponentProps): import("react/jsx-runtime").JSX.Element;
8
8
  declare const _default: React.MemoExoticComponent<typeof OnboardBoardTitle>;
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  import type { NodeData } from '../../types/Node';
3
- import type { OnboardButtonProps } from './OnboardButtonProps';
3
+ import type { OnboardButtonPropsGenerated } from './OnboardButtonProps.generated';
4
4
  type OnboardButtonComponentProps = {
5
- node: NodeData<OnboardButtonProps['attributes']>;
5
+ node: NodeData<OnboardButtonPropsGenerated['attributes']>;
6
6
  };
7
7
  declare function OnboardButton({ node }: OnboardButtonComponentProps): import("react/jsx-runtime").JSX.Element;
8
8
  declare const _default: React.MemoExoticComponent<typeof OnboardButton>;
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  import type { NodeData } from '../../types/Node';
3
- import type { OnboardButtonsProps } from './OnboardButtonsProps';
3
+ import type { OnboardButtonsPropsGenerated } from './OnboardButtonsProps.generated';
4
4
  type OnboardButtonsComponentProps = {
5
- node: NodeData<OnboardButtonsProps['attributes']>;
5
+ node: NodeData<OnboardButtonsPropsGenerated['attributes']>;
6
6
  };
7
7
  declare function OnboardButtons({ node }: OnboardButtonsComponentProps): import("react/jsx-runtime").JSX.Element | null;
8
8
  declare const _default: React.MemoExoticComponent<typeof OnboardButtons>;
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  import type { NodeData } from '../../types/Node';
3
- import type { OnboardExpandingDotProps } from './OnboardExpandingDotProps';
3
+ import type { OnboardExpandingDotPropsGenerated } from './OnboardExpandingDotProps.generated';
4
4
  type OnboardExpandingDotComponentProps = {
5
- node: NodeData<OnboardExpandingDotProps['attributes']>;
5
+ node: NodeData<OnboardExpandingDotPropsGenerated['attributes']>;
6
6
  };
7
7
  declare function OnboardExpandingDot({ node }: OnboardExpandingDotComponentProps): import("react/jsx-runtime").JSX.Element;
8
8
  declare const _default: React.MemoExoticComponent<typeof OnboardExpandingDot>;
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  import type { NodeData } from '../../types/Node';
3
- import type { OnboardFooterProps } from './OnboardFooterProps';
3
+ import type { OnboardFooterPropsGenerated } from './OnboardFooterProps.generated';
4
4
  type OnboardFooterComponentProps = {
5
- node: NodeData<OnboardFooterProps['attributes']>;
5
+ node: NodeData<OnboardFooterPropsGenerated['attributes']>;
6
6
  };
7
7
  declare function OnboardFooter({ node }: OnboardFooterComponentProps): string;
8
8
  declare const _default: React.MemoExoticComponent<typeof OnboardFooter>;
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  import type { NodeData } from '../../types/Node';
3
- import type { OnboardImageProps } from './OnboardImageProps';
3
+ import type { OnboardImagePropsGenerated } from './OnboardImageProps.generated';
4
4
  type OnboardImageComponentProps = {
5
- node: NodeData<OnboardImageProps['attributes']>;
5
+ node: NodeData<OnboardImagePropsGenerated['attributes']>;
6
6
  };
7
7
  declare function OnboardImage({ node }: OnboardImageComponentProps): import("react/jsx-runtime").JSX.Element;
8
8
  declare const _default: React.MemoExoticComponent<typeof OnboardImage>;
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  import type { NodeData } from '../../types/Node';
3
- import type { OnboardItemProps } from './OnboardItemProps';
3
+ import type { OnboardItemPropsGenerated } from './OnboardItemProps.generated';
4
4
  type OnboardItemComponentProps = {
5
- node: NodeData<OnboardItemProps['attributes']>;
5
+ node: NodeData<OnboardItemPropsGenerated['attributes']>;
6
6
  };
7
7
  declare function OnboardItem({ node }: OnboardItemComponentProps): import("react/jsx-runtime").JSX.Element;
8
8
  declare const _default: React.MemoExoticComponent<typeof OnboardItem>;
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  import type { NodeData } from '../../types/Node';
3
- import type { OnboardProviderProps } from './OnboardProviderProps';
3
+ import type { OnboardProviderPropsGenerated } from './OnboardProviderProps.generated';
4
4
  type OnboardProviderComponentProps = {
5
- node: NodeData<OnboardProviderProps['attributes']>;
5
+ node: NodeData<OnboardProviderPropsGenerated['attributes']>;
6
6
  };
7
7
  declare function OnboardProvider({ node }: OnboardProviderComponentProps): import("react/jsx-runtime").JSX.Element;
8
8
  declare const _default: React.MemoExoticComponent<typeof OnboardProvider>;
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  import type { NodeData } from '../../types/Node';
3
- import type { OnboardSubtitleProps } from './OnboardSubtitleProps';
3
+ import type { OnboardSubtitlePropsGenerated } from './OnboardSubtitleProps.generated';
4
4
  type OnboardSubtitleComponentProps = {
5
- node: NodeData<OnboardSubtitleProps['attributes']>;
5
+ node: NodeData<OnboardSubtitlePropsGenerated['attributes']>;
6
6
  };
7
7
  declare function OnboardSubtitle({ node }: OnboardSubtitleComponentProps): import("react/jsx-runtime").JSX.Element;
8
8
  declare const _default: React.MemoExoticComponent<typeof OnboardSubtitle>;
@@ -2,6 +2,6 @@ import React from 'react';
2
2
  import { Node } from '../index';
3
3
  declare function RenderNode({ node }: {
4
4
  node: Node;
5
- }): import("react/jsx-runtime").JSX.Element | null;
5
+ }): string | number | boolean | import("react/jsx-runtime").JSX.Element | Iterable<React.ReactNode> | null | undefined;
6
6
  declare const _default: React.MemoExoticComponent<typeof RenderNode>;
7
7
  export default _default;
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  import type { NodeData } from '../../types/Node';
3
- import type { TextProps } from './TextProps';
3
+ import type { TextPropsGenerated } from './TextProps.generated';
4
4
  type TextComponentProps = {
5
- node: NodeData<TextProps['attributes']>;
5
+ node: NodeData<TextPropsGenerated['attributes']>;
6
6
  };
7
7
  declare function Text({ node }: TextComponentProps): import("react/jsx-runtime").JSX.Element;
8
8
  declare const _default: React.MemoExoticComponent<typeof Text>;
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
- import type { ViewProps } from './ViewProps';
2
+ import type { ViewPropsGenerated } from './ViewProps.generated';
3
3
  import { NodeData } from '../../types/Node';
4
4
  type ViewComponentProps = {
5
- node: NodeData<ViewProps['attributes']>;
5
+ node: NodeData<ViewPropsGenerated['attributes']>;
6
6
  };
7
7
  export declare function View({ node }: ViewComponentProps): import("react/jsx-runtime").JSX.Element;
8
8
  declare const _default: React.MemoExoticComponent<typeof View>;
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import type { Node } from '../types/Node';
3
+ export declare function other(type: string, node: Node): React.ReactNode;
@@ -0,0 +1 @@
1
+ export declare function generateRandomKeyForNode(type: string): string;
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@developer_tribe/react-builder",
3
- "version": "0.1.2",
4
- "private": false,
3
+ "version": "0.1.7",
5
4
  "type": "module",
5
+ "restricted": true,
6
6
  "main": "dist/index.cjs.js",
7
7
  "module": "dist/index.esm.js",
8
8
  "types": "dist/index.d.ts",
@@ -20,7 +20,11 @@
20
20
  "typecheck": "tsc --noEmit",
21
21
  "example:dev": "npm --prefix example run dev",
22
22
  "example:build": "npm --prefix example run build",
23
- "example:preview": "npm --prefix example run preview"
23
+ "example:preview": "npm --prefix example run preview",
24
+ "builder": "node ./scripts/public/bin.js"
25
+ },
26
+ "bin": {
27
+ "builder": "./scripts/public/bin.js"
24
28
  },
25
29
  "peerDependencies": {
26
30
  "react": ">=17",
@@ -50,7 +54,8 @@
50
54
  "rollup-plugin-typescript2": "^0.36.0",
51
55
  "sass": "^1.93.2",
52
56
  "typescript": "^5.9.2",
53
- "typescript-eslint": "^8.44.1"
57
+ "typescript-eslint": "^8.44.1",
58
+ "yargs": "^18.0.0"
54
59
  },
55
60
  "engines": {
56
61
  "node": ">=18"
@@ -105,7 +105,9 @@ async function getAllEntriesInComponentsRoot() {
105
105
  return await fs
106
106
  .readdir(COMPONENTS_ROOT, { withFileTypes: true })
107
107
  .then(dirents => {
108
- return dirents.filter(d => d.name !== 'RenderNode.generated.tsx');
108
+ return dirents.filter(
109
+ d => d.name !== 'RenderNode.generated.tsx' && d.name !== 'other.ts'
110
+ );
109
111
  });
110
112
  }
111
113
 
@@ -212,26 +214,9 @@ async function validatePatternJson(componentDir, componentName) {
212
214
  // (Moved to Actions section) ensurePropsTs
213
215
 
214
216
  /**
215
- * 6) Check <Name>Props.ts is valid if it already exists (in the component folder)
217
+ * 6) Custom <Name>Props.ts are deprecated; validation removed.
216
218
  */
217
- async function validateExistingPropsTs(componentDir, componentName) {
218
- const filePath = path.join(componentDir, `${componentName}Props.ts`);
219
- const exists = await fs
220
- .stat(filePath)
221
- .then(() => true)
222
- .catch(() => false);
223
- if (!exists) return; // Created in step 5 if missing
224
-
225
- const content = await fs.readFile(filePath, 'utf8');
226
- const hasExportedInterface = new RegExp(
227
- `export\\s+interface\\s+${componentName}Props\\s+extends\\s+${componentName}PropsGenerated`
228
- ).test(content);
229
- if (!hasExportedInterface) {
230
- throw new Error(
231
- `${filePath} must export interface '${componentName}Props' extending '${componentName}PropsGenerated'`
232
- );
233
- }
234
- }
219
+ // (intentionally left blank)
235
220
 
236
221
  /**
237
222
  * 7) Create <Name>.tsx inside its component folder
@@ -282,7 +267,6 @@ async function validateExistingComponentTsx(componentDir, componentName) {
282
267
  */
283
268
  async function validateComponent(componentDir, componentName) {
284
269
  const patternJson = await validatePatternJson(componentDir, componentName);
285
- await validateExistingPropsTs(componentDir, componentName);
286
270
  await validateExistingComponentTsx(componentDir, componentName);
287
271
  return { componentDir, componentName, patternJson };
288
272
  }
@@ -382,7 +366,7 @@ async function createGeneratedProps(componentDir, componentName, patternJson) {
382
366
  await fs.writeFile(filePath, formatted, 'utf8');
383
367
  }
384
368
 
385
- /** Create <Name>Props.ts if it doesn't exist inside the component folder */
369
+ /** Delete <Name>Props.ts if it exists inside the component folder */
386
370
  async function ensurePropsTs(componentDir, componentName) {
387
371
  await ensureDir(componentDir);
388
372
  const fileName = `${componentName}Props.ts`;
@@ -391,13 +375,8 @@ async function ensurePropsTs(componentDir, componentName) {
391
375
  .stat(filePath)
392
376
  .then(() => true)
393
377
  .catch(() => false);
394
- if (exists) return; // Will be validated in step 6
395
-
396
- const content =
397
- `import type { ${componentName}PropsGenerated } from './${componentName}Props.generated';\n\n` +
398
- `export interface ${componentName}Props extends ${componentName}PropsGenerated {\n}\n`;
399
- const formatted = await formatWithPrettier(content);
400
- await fs.writeFile(filePath, formatted, 'utf8');
378
+ if (!exists) return;
379
+ await fs.unlink(filePath);
401
380
  }
402
381
 
403
382
  /** Create <Name>.tsx inside its component folder */
@@ -536,7 +515,6 @@ async function run() {
536
515
  await createComponentTsx(componentDir, componentName);
537
516
 
538
517
  // Final sanity validations
539
- await validateExistingPropsTs(componentDir, componentName);
540
518
  await validateExistingComponentTsx(componentDir, componentName);
541
519
  }
542
520
 
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env node
2
+ import { execSync } from 'child_process';
3
+ import fs from 'fs';
4
+ import yargs from 'yargs/yargs';
5
+ import { hideBin } from 'yargs/helpers';
6
+ import Path from 'path';
7
+ import { fileURLToPath } from 'url';
8
+
9
+ const cli = yargs(hideBin(process.argv));
10
+
11
+ const __dirname = Path.dirname(fileURLToPath(import.meta.url));
12
+ const directoryPath = Path.join(__dirname, 'scripts');
13
+
14
+ const getFolderNames = dirPath => {
15
+ try {
16
+ const items = fs.readdirSync(dirPath, { withFileTypes: true });
17
+
18
+ const folderNames = items
19
+ .filter(item => item.isDirectory()) // Keep only directories
20
+ .map(folder => folder.name); // Extract folder names
21
+
22
+ return folderNames;
23
+ } catch (err) {
24
+ console.error(`Error reading directory: ${err.message}`);
25
+ return [];
26
+ }
27
+ };
28
+ const folderNames = getFolderNames(directoryPath);
29
+
30
+ folderNames.forEach(folderName => {
31
+ const infoPath = Path.join(directoryPath, folderName, 'info.json');
32
+ const res = fs.readFileSync(infoPath, 'utf8');
33
+ const json = JSON.parse(res.toString('utf8'));
34
+ cli.command(
35
+ folderName,
36
+ json.description,
37
+ y => {
38
+ Object.entries(json.options ?? {}).forEach(([key, value]) => {
39
+ y.option(key, value);
40
+ });
41
+ },
42
+ args => {
43
+ const keys = Object.keys(json.options ?? {});
44
+ const dynamicArgs = Object.entries(args ?? {})
45
+ .filter(([key]) => keys.includes(key)) // Only accept specified keys
46
+ .map(([key, value]) => `--${key} "${value}"`)
47
+ .join(' ');
48
+ execSync(
49
+ `node ${Path.join(directoryPath, folderName, 'index.js')} ${dynamicArgs}`,
50
+ {
51
+ stdio: 'inherit',
52
+ }
53
+ );
54
+ }
55
+ );
56
+ });
57
+ cli.demandCommand(1, 'You need to specify a command').help().strict().parse();
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env node
2
+
3
+ import yargs from 'yargs/yargs';
4
+ import { hideBin } from 'yargs/helpers';
5
+ import Path from 'path';
6
+ import { fileURLToPath } from 'url';
7
+ import { checkPathExists } from './utils/checkPathExists.js';
8
+ import { getAllComponents } from './utils/getAllComponents.js';
9
+ import { checkFolderAndFilesValid } from './utils/checkFolderAndFilesValid.js';
10
+ import { createMissingFoldersAndFiles } from './utils/createMissingFoldersAndFiles.js';
11
+ import { createRenderNodeGenerated } from './utils/createRenderNodeGenerated.js';
12
+
13
+ const argv = yargs(hideBin(process.argv)).argv;
14
+ export const args = argv;
15
+ const builderPath = args.path || '/node_modules/@developer_tribe/react-builder';
16
+ const targetPath = process.cwd();
17
+ const selectedComponents = args.components || [];
18
+
19
+ function run() {
20
+ const builderComponentsPath = Path.join(
21
+ builderPath,
22
+ 'src',
23
+ 'build-components'
24
+ );
25
+ checkPathExists(builderComponentsPath);
26
+ const components = getAllComponents(builderComponentsPath);
27
+ for (const component of components) {
28
+ if (!selectedComponents.includes(component)) {
29
+ console.error(`Component ${component} not found`);
30
+ process.exit(1);
31
+ }
32
+ }
33
+ checkFolderAndFilesValid(targetPath, selectedComponents);
34
+ createMissingFoldersAndFiles(targetPath, selectedComponents);
35
+ createRenderNodeGenerated(
36
+ builderComponentsPath,
37
+ targetPath,
38
+ selectedComponents
39
+ );
40
+ }
41
+
42
+ run();
@@ -0,0 +1,17 @@
1
+ {
2
+ "description": "command for build",
3
+ "options": {
4
+ "path": {
5
+ "alias": "p",
6
+ "type": "string",
7
+ "describe": "path of project",
8
+ "demandOption": false
9
+ },
10
+ "components": {
11
+ "alias": "c",
12
+ "type": "array",
13
+ "describe": "component names",
14
+ "demandOption": false
15
+ }
16
+ }
17
+ }
@@ -0,0 +1,41 @@
1
+ import fs from 'fs';
2
+ import Path from 'path';
3
+
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
+ );
11
+ if (!fs.existsSync(buildComponentsTarget)) {
12
+ fs.mkdirSync(buildComponentsTarget, { recursive: true });
13
+ }
14
+
15
+ const entries = fs.readdirSync(buildComponentsTarget, {
16
+ withFileTypes: true,
17
+ });
18
+ const entryNames = new Set(
19
+ entries.filter(e => e.isDirectory()).map(e => e.name)
20
+ );
21
+
22
+ // Remove folders not in components
23
+ for (const name of Array.from(entryNames)) {
24
+ if (
25
+ !components.includes(name) &&
26
+ name !== 'RenderNode.generated.tsx' &&
27
+ name !== 'other.ts'
28
+ ) {
29
+ const full = Path.join(buildComponentsTarget, name);
30
+ fs.rmSync(full, { recursive: true, force: true });
31
+ }
32
+ }
33
+
34
+ // Create missing component folders
35
+ for (const component of components) {
36
+ const dir = Path.join(buildComponentsTarget, component);
37
+ if (!fs.existsSync(dir)) {
38
+ fs.mkdirSync(dir, { recursive: true });
39
+ }
40
+ }
41
+ }
@@ -0,0 +1,9 @@
1
+ import fs from 'fs';
2
+
3
+ export function checkPathExists(path) {
4
+ if (!fs.existsSync(path)) {
5
+ throw new Error(`Path does not exist: ${path}`);
6
+ }
7
+ }
8
+
9
+ // no default export
@@ -0,0 +1,54 @@
1
+ import fs from 'fs';
2
+ import Path from 'path';
3
+
4
+ function toPropsName(name) {
5
+ return `${name}Props`;
6
+ }
7
+
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
+ );
15
+ if (!fs.existsSync(buildComponentsTarget)) {
16
+ fs.mkdirSync(buildComponentsTarget, { recursive: true });
17
+ }
18
+
19
+ // Ensure fallback helper exists
20
+ const otherPath = Path.join(buildComponentsTarget, 'other.ts');
21
+ if (!fs.existsSync(otherPath)) {
22
+ const otherContent = `import React from 'react';
23
+ import type { Node } from '@developer_tribe/react-builder';
24
+
25
+ export function other(type: string, node: Node): React.ReactNode {
26
+ return null;
27
+ }
28
+ `;
29
+ fs.writeFileSync(otherPath, otherContent, 'utf8');
30
+ }
31
+
32
+ for (const component of components) {
33
+ const dir = Path.join(buildComponentsTarget, component);
34
+ if (!fs.existsSync(dir)) {
35
+ fs.mkdirSync(dir, { recursive: true });
36
+ }
37
+
38
+ // component tsx
39
+ const tsxPath = Path.join(dir, `${component}.tsx`);
40
+ if (!fs.existsSync(tsxPath)) {
41
+ const propsName = toPropsName(component);
42
+ const content = `import React from 'react';
43
+ import type { ${propsName} } from '@developer_tribe/react-builder';
44
+
45
+ function ${component}(props: { node: any }) {
46
+ return "hello world";
47
+ }
48
+
49
+ export default React.memo(${component});
50
+ `;
51
+ fs.writeFileSync(tsxPath, content, 'utf8');
52
+ }
53
+ }
54
+ }