@developer_tribe/react-builder 0.1.2 → 0.1.4
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/dist/build-components/Button/Button.d.ts +2 -2
- package/dist/build-components/Carousel/Carousel.d.ts +2 -2
- package/dist/build-components/CarouselButtons/CarouselButtons.d.ts +2 -2
- package/dist/build-components/CarouselDots/CarouselDots.d.ts +2 -2
- package/dist/build-components/CarouselItem/CarouselItem.d.ts +2 -2
- package/dist/build-components/CarouselProvider/CarouselProvider.d.ts +2 -2
- package/dist/build-components/Image/Image.d.ts +2 -2
- package/dist/build-components/Onboard/Onboard.d.ts +2 -2
- package/dist/build-components/OnboardBoardTitle/OnboardBoardTitle.d.ts +2 -2
- package/dist/build-components/OnboardButton/OnboardButton.d.ts +2 -2
- package/dist/build-components/OnboardButtons/OnboardButtons.d.ts +2 -2
- package/dist/build-components/OnboardExpandingDot/OnboardExpandingDot.d.ts +2 -2
- package/dist/build-components/OnboardFooter/OnboardFooter.d.ts +2 -2
- package/dist/build-components/OnboardImage/OnboardImage.d.ts +2 -2
- package/dist/build-components/OnboardItem/OnboardItem.d.ts +2 -2
- package/dist/build-components/OnboardProvider/OnboardProvider.d.ts +2 -2
- package/dist/build-components/OnboardSubtitle/OnboardSubtitle.d.ts +2 -2
- package/dist/build-components/RenderNode.generated.d.ts +1 -1
- package/dist/build-components/Text/Text.d.ts +2 -2
- package/dist/build-components/View/View.d.ts +2 -2
- package/dist/build-components/other.d.ts +3 -0
- package/dist/utils/generateRandomKeyForNode.d.ts +1 -0
- package/package.json +9 -4
- package/scripts/{build-components.js → prebuild/build-components.js} +8 -30
- package/scripts/public/bin.js +57 -0
- package/scripts/public/scripts/build/index.js +31 -0
- package/scripts/public/scripts/build/info.json +11 -0
- package/scripts/public/scripts/build/utils/checkFolderAndFilesValid.js +41 -0
- package/scripts/public/scripts/build/utils/checkPathExists.js +9 -0
- package/scripts/public/scripts/build/utils/createMissingFoldersAndFiles.js +54 -0
- package/scripts/public/scripts/build/utils/createRenderNodeGenerated.js +82 -0
- package/scripts/public/scripts/build/utils/getAllComponents.js +11 -0
- package/src/build-components/Button/Button.tsx +2 -2
- package/src/build-components/Carousel/Carousel.tsx +2 -2
- package/src/build-components/CarouselButtons/CarouselButtons.tsx +2 -2
- package/src/build-components/CarouselDots/CarouselDots.tsx +2 -2
- package/src/build-components/CarouselItem/CarouselItem.tsx +2 -2
- package/src/build-components/CarouselProvider/CarouselProvider.tsx +2 -2
- package/src/build-components/Image/Image.tsx +2 -2
- package/src/build-components/Onboard/Onboard.tsx +2 -2
- package/src/build-components/OnboardBoardTitle/OnboardBoardTitle.tsx +2 -2
- package/src/build-components/OnboardButton/OnboardButton.tsx +2 -2
- package/src/build-components/OnboardButtons/OnboardButtons.tsx +2 -2
- package/src/build-components/OnboardExpandingDot/OnboardExpandingDot.tsx +2 -2
- package/src/build-components/OnboardFooter/OnboardFooter.tsx +2 -2
- package/src/build-components/OnboardImage/OnboardImage.tsx +2 -2
- package/src/build-components/OnboardItem/OnboardItem.tsx +2 -2
- package/src/build-components/OnboardProvider/OnboardProvider.tsx +2 -2
- package/src/build-components/OnboardSubtitle/OnboardSubtitle.tsx +2 -2
- package/src/build-components/Text/Text.tsx +2 -2
- package/src/build-components/View/View.tsx +3 -3
- package/src/utils/novaToJson.ts +0 -1
- package/dist/build-components/Button/ButtonProps.d.ts +0 -3
- package/dist/build-components/Carousel/CarouselProps.d.ts +0 -3
- package/dist/build-components/CarouselButtons/CarouselButtonsProps.d.ts +0 -3
- package/dist/build-components/CarouselDots/CarouselDotsProps.d.ts +0 -3
- package/dist/build-components/CarouselItem/CarouselItemProps.d.ts +0 -3
- package/dist/build-components/CarouselProvider/CarouselProviderProps.d.ts +0 -3
- package/dist/build-components/Image/ImageProps.d.ts +0 -3
- package/dist/build-components/Onboard/OnboardProps.d.ts +0 -3
- package/dist/build-components/OnboardBoardTitle/OnboardBoardTitleProps.d.ts +0 -3
- package/dist/build-components/OnboardButton/OnboardButtonProps.d.ts +0 -3
- package/dist/build-components/OnboardButtons/OnboardButtonsProps.d.ts +0 -3
- package/dist/build-components/OnboardExpandingDot/OnboardExpandingDotProps.d.ts +0 -3
- package/dist/build-components/OnboardFooter/OnboardFooterProps.d.ts +0 -3
- package/dist/build-components/OnboardImage/OnboardImageProps.d.ts +0 -3
- package/dist/build-components/OnboardItem/OnboardItemProps.d.ts +0 -3
- package/dist/build-components/OnboardProvider/OnboardProviderProps.d.ts +0 -3
- package/dist/build-components/OnboardSubtitle/OnboardSubtitleProps.d.ts +0 -3
- package/dist/build-components/Text/TextProps.d.ts +0 -3
- package/dist/build-components/View/ViewProps.d.ts +0 -3
- package/src/build-components/Button/ButtonProps.ts +0 -3
- package/src/build-components/Carousel/CarouselProps.ts +0 -3
- package/src/build-components/CarouselButtons/CarouselButtonsProps.ts +0 -3
- package/src/build-components/CarouselDots/CarouselDotsProps.ts +0 -3
- package/src/build-components/CarouselItem/CarouselItemProps.ts +0 -3
- package/src/build-components/CarouselProvider/CarouselProviderProps.ts +0 -3
- package/src/build-components/Image/ImageProps.ts +0 -3
- package/src/build-components/Onboard/OnboardProps.ts +0 -3
- package/src/build-components/OnboardBoardTitle/OnboardBoardTitleProps.ts +0 -4
- package/src/build-components/OnboardButton/OnboardButtonProps.ts +0 -3
- package/src/build-components/OnboardButtons/OnboardButtonsProps.ts +0 -3
- package/src/build-components/OnboardExpandingDot/OnboardExpandingDotProps.ts +0 -4
- package/src/build-components/OnboardFooter/OnboardFooterProps.ts +0 -3
- package/src/build-components/OnboardImage/OnboardImageProps.ts +0 -3
- package/src/build-components/OnboardItem/OnboardItemProps.ts +0 -3
- package/src/build-components/OnboardProvider/OnboardProviderProps.ts +0 -3
- package/src/build-components/OnboardSubtitle/OnboardSubtitleProps.ts +0 -3
- package/src/build-components/Text/TextProps.ts +0 -3
- package/src/build-components/View/ViewProps.ts +0 -3
- /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 {
|
|
3
|
+
import type { ButtonPropsGenerated } from './ButtonProps.generated';
|
|
4
4
|
type ButtonComponentProps = {
|
|
5
|
-
node: NodeData<
|
|
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 {
|
|
3
|
+
import type { CarouselPropsGenerated } from './CarouselProps.generated';
|
|
4
4
|
type CarouselComponentProps = {
|
|
5
|
-
node: NodeData<
|
|
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 {
|
|
3
|
+
import type { CarouselButtonsPropsGenerated } from './CarouselButtonsProps.generated';
|
|
4
4
|
type CarouselButtonsComponentProps = {
|
|
5
|
-
node: NodeData<
|
|
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 {
|
|
3
|
+
import type { CarouselDotsPropsGenerated } from './CarouselDotsProps.generated';
|
|
4
4
|
type CarouselDotsComponentProps = {
|
|
5
|
-
node: NodeData<
|
|
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 {
|
|
3
|
+
import type { CarouselItemPropsGenerated } from './CarouselItemProps.generated';
|
|
4
4
|
type CarouselItemComponentProps = {
|
|
5
|
-
node: NodeData<
|
|
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 {
|
|
3
|
+
import type { CarouselProviderPropsGenerated } from './CarouselProviderProps.generated';
|
|
4
4
|
type CarouselProviderComponentProps = {
|
|
5
|
-
node: NodeData<
|
|
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 {
|
|
3
|
+
import type { ImagePropsGenerated } from './ImageProps.generated';
|
|
4
4
|
type ImageComponentProps = {
|
|
5
|
-
node: NodeData<
|
|
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 {
|
|
3
|
+
import type { OnboardPropsGenerated } from './OnboardProps.generated';
|
|
4
4
|
type OnboardComponentProps = {
|
|
5
|
-
node: NodeData<
|
|
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 {
|
|
3
|
+
import type { OnboardBoardTitlePropsGenerated } from './OnboardBoardTitleProps.generated';
|
|
4
4
|
type OnboardBoardTitleComponentProps = {
|
|
5
|
-
node: NodeData<
|
|
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 {
|
|
3
|
+
import type { OnboardButtonPropsGenerated } from './OnboardButtonProps.generated';
|
|
4
4
|
type OnboardButtonComponentProps = {
|
|
5
|
-
node: NodeData<
|
|
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 {
|
|
3
|
+
import type { OnboardButtonsPropsGenerated } from './OnboardButtonsProps.generated';
|
|
4
4
|
type OnboardButtonsComponentProps = {
|
|
5
|
-
node: NodeData<
|
|
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 {
|
|
3
|
+
import type { OnboardExpandingDotPropsGenerated } from './OnboardExpandingDotProps.generated';
|
|
4
4
|
type OnboardExpandingDotComponentProps = {
|
|
5
|
-
node: NodeData<
|
|
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 {
|
|
3
|
+
import type { OnboardFooterPropsGenerated } from './OnboardFooterProps.generated';
|
|
4
4
|
type OnboardFooterComponentProps = {
|
|
5
|
-
node: NodeData<
|
|
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 {
|
|
3
|
+
import type { OnboardImagePropsGenerated } from './OnboardImageProps.generated';
|
|
4
4
|
type OnboardImageComponentProps = {
|
|
5
|
-
node: NodeData<
|
|
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 {
|
|
3
|
+
import type { OnboardItemPropsGenerated } from './OnboardItemProps.generated';
|
|
4
4
|
type OnboardItemComponentProps = {
|
|
5
|
-
node: NodeData<
|
|
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 {
|
|
3
|
+
import type { OnboardProviderPropsGenerated } from './OnboardProviderProps.generated';
|
|
4
4
|
type OnboardProviderComponentProps = {
|
|
5
|
-
node: NodeData<
|
|
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 {
|
|
3
|
+
import type { OnboardSubtitlePropsGenerated } from './OnboardSubtitleProps.generated';
|
|
4
4
|
type OnboardSubtitleComponentProps = {
|
|
5
|
-
node: NodeData<
|
|
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 {
|
|
3
|
+
import type { TextPropsGenerated } from './TextProps.generated';
|
|
4
4
|
type TextComponentProps = {
|
|
5
|
-
node: NodeData<
|
|
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 {
|
|
2
|
+
import type { ViewPropsGenerated } from './ViewProps.generated';
|
|
3
3
|
import { NodeData } from '../../types/Node';
|
|
4
4
|
type ViewComponentProps = {
|
|
5
|
-
node: NodeData<
|
|
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 @@
|
|
|
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.
|
|
4
|
-
"private": false,
|
|
3
|
+
"version": "0.1.4",
|
|
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(
|
|
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)
|
|
217
|
+
* 6) Custom <Name>Props.ts are deprecated; validation removed.
|
|
216
218
|
*/
|
|
217
|
-
|
|
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
|
-
/**
|
|
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;
|
|
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,31 @@
|
|
|
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
|
+
|
|
18
|
+
function run() {
|
|
19
|
+
const builderComponentsPath = Path.join(
|
|
20
|
+
builderPath,
|
|
21
|
+
'src',
|
|
22
|
+
'build-components'
|
|
23
|
+
);
|
|
24
|
+
checkPathExists(builderComponentsPath);
|
|
25
|
+
const components = getAllComponents(builderComponentsPath);
|
|
26
|
+
checkFolderAndFilesValid(targetPath, components);
|
|
27
|
+
createMissingFoldersAndFiles(targetPath, components);
|
|
28
|
+
createRenderNodeGenerated(builderComponentsPath, targetPath, components);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
run();
|
|
@@ -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,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
|
+
}
|