@developer_tribe/react-builder 0.1.11 → 0.1.13
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 +1 -1
- package/scripts/prebuild/utils/validateAllComponentsOrThrow.js +3 -3
- package/scripts/public/scripts/build/index.js +7 -6
- package/scripts/public/scripts/build/info.json +6 -0
- package/scripts/public/scripts/build/utils/checkFolderAndFilesValid.js +2 -7
- package/scripts/public/scripts/build/utils/createComponentsIndex.js +1 -7
- package/scripts/public/scripts/build/utils/createMissingFoldersAndFiles.js +5 -7
- package/scripts/public/scripts/build/utils/createRenderNodeGenerated.js +1 -6
- /package/src/build-components/{other.ts → other.tsx} +0 -0
package/package.json
CHANGED
|
@@ -20,7 +20,7 @@ async function getAllEntriesInComponentsRoot(paths) {
|
|
|
20
20
|
return dirents.filter(
|
|
21
21
|
d =>
|
|
22
22
|
d.name !== 'RenderNode.generated.tsx' &&
|
|
23
|
-
d.name !== 'other.
|
|
23
|
+
d.name !== 'other.tsx' &&
|
|
24
24
|
d.name !== 'index.ts'
|
|
25
25
|
);
|
|
26
26
|
});
|
|
@@ -37,10 +37,10 @@ function ensureAllEntriesAreFolders(dirents, paths) {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
// single-use: ensure fallback other.
|
|
40
|
+
// single-use: ensure fallback other.tsx exists
|
|
41
41
|
async function ensureOtherTsExists(paths) {
|
|
42
42
|
const { COMPONENTS_ROOT } = paths;
|
|
43
|
-
const otherPath = path.join(COMPONENTS_ROOT, 'other.
|
|
43
|
+
const otherPath = path.join(COMPONENTS_ROOT, 'other.tsx');
|
|
44
44
|
const exists = await fs
|
|
45
45
|
.stat(otherPath)
|
|
46
46
|
.then(() => true)
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import yargs from 'yargs/yargs';
|
|
4
4
|
import { hideBin } from 'yargs/helpers';
|
|
5
5
|
import Path from 'path';
|
|
6
|
-
import { fileURLToPath } from 'url';
|
|
7
6
|
import { checkPathExists } from './utils/checkPathExists.js';
|
|
8
7
|
import { getAllComponents } from './utils/getAllComponents.js';
|
|
9
8
|
import { checkFolderAndFilesValid } from './utils/checkFolderAndFilesValid.js';
|
|
@@ -14,8 +13,9 @@ import { createComponentsIndex } from './utils/createComponentsIndex.js';
|
|
|
14
13
|
const argv = yargs(hideBin(process.argv)).argv;
|
|
15
14
|
export const args = argv;
|
|
16
15
|
const builderPath = args.path || 'node_modules/@developer_tribe/react-builder';
|
|
17
|
-
const targetPath = process.cwd();
|
|
18
16
|
const selectedComponents = args.components || [];
|
|
17
|
+
const name = args.name || 'build-components';
|
|
18
|
+
const targetPath = process.cwd();
|
|
19
19
|
|
|
20
20
|
function run() {
|
|
21
21
|
const builderComponentsPath = Path.join(
|
|
@@ -23,6 +23,7 @@ function run() {
|
|
|
23
23
|
'src',
|
|
24
24
|
'build-components'
|
|
25
25
|
);
|
|
26
|
+
const targetComponentsPath = Path.join(targetPath, 'src', name);
|
|
26
27
|
checkPathExists(builderComponentsPath);
|
|
27
28
|
const components = getAllComponents(builderComponentsPath);
|
|
28
29
|
for (const component of selectedComponents) {
|
|
@@ -31,14 +32,14 @@ function run() {
|
|
|
31
32
|
process.exit(1);
|
|
32
33
|
}
|
|
33
34
|
}
|
|
34
|
-
checkFolderAndFilesValid(
|
|
35
|
-
createMissingFoldersAndFiles(
|
|
35
|
+
checkFolderAndFilesValid(targetComponentsPath, selectedComponents);
|
|
36
|
+
createMissingFoldersAndFiles(targetComponentsPath, selectedComponents);
|
|
36
37
|
createRenderNodeGenerated(
|
|
37
38
|
builderComponentsPath,
|
|
38
|
-
|
|
39
|
+
targetComponentsPath,
|
|
39
40
|
selectedComponents
|
|
40
41
|
);
|
|
41
|
-
createComponentsIndex(
|
|
42
|
+
createComponentsIndex(builderComponentsPath, selectedComponents);
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
run();
|
|
@@ -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(
|
|
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
|
}
|
|
@@ -24,7 +19,7 @@ export function checkFolderAndFilesValid(targetRootPath, components) {
|
|
|
24
19
|
if (
|
|
25
20
|
!components.includes(name) &&
|
|
26
21
|
name !== 'RenderNode.generated.tsx' &&
|
|
27
|
-
name !== 'other.
|
|
22
|
+
name !== 'other.tsx'
|
|
28
23
|
) {
|
|
29
24
|
const full = Path.join(buildComponentsTarget, name);
|
|
30
25
|
fs.rmSync(full, { recursive: true, force: true });
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import Path from 'path';
|
|
3
3
|
|
|
4
|
-
export function createComponentsIndex(
|
|
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,18 +6,16 @@ function toPropsName(name) {
|
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
// Create folders and base component files if missing
|
|
9
|
-
export function createMissingFoldersAndFiles(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
}
|
|
18
16
|
|
|
19
17
|
// Ensure fallback helper exists
|
|
20
|
-
const otherPath = Path.join(buildComponentsTarget, 'other.
|
|
18
|
+
const otherPath = Path.join(buildComponentsTarget, 'other.tsx');
|
|
21
19
|
if (!fs.existsSync(otherPath)) {
|
|
22
20
|
const otherContent = `import React from 'react';
|
|
23
21
|
import type { Node } from '@developer_tribe/react-builder';
|
|
@@ -14,14 +14,9 @@ function readPatternType(builderComponentsPath, componentName) {
|
|
|
14
14
|
|
|
15
15
|
export function createRenderNodeGenerated(
|
|
16
16
|
builderComponentsPath,
|
|
17
|
-
|
|
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
|
}
|
|
File without changes
|