@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@developer_tribe/react-builder",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "type": "module",
5
5
  "restricted": true,
6
6
  "main": "dist/index.cjs.js",
@@ -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.ts' &&
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.ts exists
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.ts');
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(targetPath, selectedComponents);
35
- createMissingFoldersAndFiles(targetPath, selectedComponents);
35
+ checkFolderAndFilesValid(targetComponentsPath, selectedComponents);
36
+ createMissingFoldersAndFiles(targetComponentsPath, selectedComponents);
36
37
  createRenderNodeGenerated(
37
38
  builderComponentsPath,
38
- targetPath,
39
+ targetComponentsPath,
39
40
  selectedComponents
40
41
  );
41
- createComponentsIndex(targetPath, selectedComponents);
42
+ createComponentsIndex(builderComponentsPath, selectedComponents);
42
43
  }
43
44
 
44
45
  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
  }
@@ -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.ts'
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(targetRootPath, components) {
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(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
  }
18
16
 
19
17
  // Ensure fallback helper exists
20
- const otherPath = Path.join(buildComponentsTarget, 'other.ts');
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
- 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
  }
File without changes