@ldsg/cli 0.3.31 → 0.3.32

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 (70) hide show
  1. package/.rush/temp/package-deps_build.json +27 -27
  2. package/.rush/temp/shrinkwrap-deps.json +58 -3
  3. package/.tsbuildinfo +1 -1
  4. package/CHANGELOG.json +26 -0
  5. package/CHANGELOG.md +16 -2
  6. package/README.md +3 -0
  7. package/dist/__tests__/commands.test.js +104 -104
  8. package/dist/__tests__/formatter.test.js +66 -63
  9. package/dist/__tests__/formatter.test.js.map +1 -1
  10. package/dist/__tests__/json-file-mutator.test.js +48 -45
  11. package/dist/__tests__/json-file-mutator.test.js.map +1 -1
  12. package/dist/__tests__/source-resolver.test.js +39 -39
  13. package/dist/cli.js +89 -89
  14. package/dist/cli.js.map +1 -1
  15. package/dist/commands/resource/convert.d.ts +1 -1
  16. package/dist/commands/resource/convert.js +9 -7
  17. package/dist/commands/resource/convert.js.map +1 -1
  18. package/dist/commands/resource/create.d.ts +2 -2
  19. package/dist/commands/resource/create.js +5 -5
  20. package/dist/commands/resource/delete.d.ts +2 -2
  21. package/dist/commands/resource/delete.js.map +1 -1
  22. package/dist/commands/resource/diff.d.ts +2 -2
  23. package/dist/commands/resource/diff.js +8 -8
  24. package/dist/commands/resource/get.d.ts +1 -1
  25. package/dist/commands/resource/list.d.ts +2 -2
  26. package/dist/commands/resource/list.js +11 -11
  27. package/dist/commands/resource/list.js.map +1 -1
  28. package/dist/commands/resource/tree.d.ts +1 -1
  29. package/dist/commands/resource/update.d.ts +2 -2
  30. package/dist/commands/resource/update.js +1 -1
  31. package/dist/constants.js +2 -2
  32. package/dist/types/get-extend-app-data-params.d.ts +2 -2
  33. package/dist/types/resource-record.d.ts +2 -2
  34. package/dist/utils/formatter.d.ts +1 -1
  35. package/dist/utils/formatter.js +25 -25
  36. package/dist/utils/get-extend-app-data-params-using-npm-ldsg-module.d.ts +1 -1
  37. package/dist/utils/get-extend-app-data-params-using-npm-ldsg-module.js +12 -12
  38. package/dist/utils/get-extend-app-data-params-using-npm-ldsg-module.js.map +1 -1
  39. package/dist/utils/get-extend-app-data-params-using-workspace-ldsg-module/index.d.ts +1 -1
  40. package/dist/utils/get-extend-app-data-params-using-workspace-ldsg-module/index.js +20 -20
  41. package/dist/utils/get-extend-app-data-params-using-workspace-ldsg-module/index.js.map +1 -1
  42. package/dist/utils/json-file-mutator.d.ts +2 -2
  43. package/dist/utils/json-file-mutator.js +4 -4
  44. package/dist/utils/json-file-mutator.js.map +1 -1
  45. package/dist/utils/source-resolver.d.ts +1 -1
  46. package/dist/utils/source-resolver.js +15 -15
  47. package/dist/utils/source-resolver.js.map +1 -1
  48. package/jest.config.js +8 -8
  49. package/package.json +9 -6
  50. package/src/__tests__/commands.test.ts +116 -116
  51. package/src/__tests__/formatter.test.ts +68 -65
  52. package/src/__tests__/json-file-mutator.test.ts +57 -52
  53. package/src/__tests__/source-resolver.test.ts +43 -43
  54. package/src/cli.ts +132 -114
  55. package/src/commands/resource/convert.ts +13 -11
  56. package/src/commands/resource/create.ts +8 -8
  57. package/src/commands/resource/delete.ts +6 -4
  58. package/src/commands/resource/diff.ts +10 -10
  59. package/src/commands/resource/get.ts +2 -2
  60. package/src/commands/resource/list.ts +20 -18
  61. package/src/commands/resource/tree.ts +2 -2
  62. package/src/commands/resource/update.ts +4 -4
  63. package/src/constants.ts +2 -2
  64. package/src/types/get-extend-app-data-params.ts +5 -3
  65. package/src/types/resource-record.ts +2 -2
  66. package/src/utils/formatter.ts +27 -27
  67. package/src/utils/get-extend-app-data-params-using-npm-ldsg-module.ts +20 -16
  68. package/src/utils/get-extend-app-data-params-using-workspace-ldsg-module/index.ts +28 -26
  69. package/src/utils/json-file-mutator.ts +18 -12
  70. package/src/utils/source-resolver.ts +26 -21
@@ -1,5 +1,5 @@
1
- import { ResourceRecords } from '@ldsg/types';
2
- import { getResource } from './list';
1
+ import { ResourceRecords } from "@ldsg/types";
2
+ import { getResource } from "./list";
3
3
 
4
4
  export { getResource };
5
5
  export type GetOptions = { children?: boolean; tree?: boolean };
@@ -1,5 +1,5 @@
1
- import { ResourceRecord, ResourceRecords } from '@ldsg/types';
2
- import { ResourceFilter } from '../../types/resource-record';
1
+ import { ResourceRecord, ResourceRecords } from "@ldsg/types";
2
+ import { ResourceFilter } from "../../types/resource-record";
3
3
 
4
4
  function filterByKind(records: ResourceRecords, kind?: string): ResourceRecords {
5
5
  if (!kind) return records;
@@ -14,7 +14,7 @@ function filterByParentId(records: ResourceRecords, parentId?: string): Resource
14
14
  function getDescendantIds(allRecords: ResourceRecords, rootId: string): Set<string> {
15
15
  const childMap = new Map<string, string[]>();
16
16
  for (const r of allRecords) {
17
- const pid = r.parentId || 'null';
17
+ const pid = r.parentId || "null";
18
18
  if (!childMap.has(pid)) childMap.set(pid, []);
19
19
  childMap.get(pid)!.push(r.id);
20
20
  }
@@ -42,7 +42,7 @@ function filterByRootId(records: ResourceRecords, rootId?: string): ResourceReco
42
42
  function buildChildMap(records: ResourceRecords): Map<string, ResourceRecord[]> {
43
43
  const map = new Map<string, ResourceRecord[]>();
44
44
  for (const r of records) {
45
- const pid = r.parentId || 'null';
45
+ const pid = r.parentId || "null";
46
46
  if (!map.has(pid)) map.set(pid, []);
47
47
  map.get(pid)!.push(r);
48
48
  }
@@ -50,7 +50,7 @@ function buildChildMap(records: ResourceRecords): Map<string, ResourceRecord[]>
50
50
  }
51
51
 
52
52
  function findRoots(records: ResourceRecords): ResourceRecord[] {
53
- const roots = records.filter((r) => r.parentId === null || r.parentId === 'root');
53
+ const roots = records.filter((r) => r.parentId === null || r.parentId === "root");
54
54
  if (roots.length > 0) return roots;
55
55
  const allParentIds = new Set(records.map((r) => r.parentId).filter(Boolean));
56
56
  return records.filter((r) => !allParentIds.has(r.id));
@@ -58,7 +58,7 @@ function findRoots(records: ResourceRecords): ResourceRecord[] {
58
58
 
59
59
  function buildTree(
60
60
  records: ResourceRecords,
61
- rootId: string
61
+ rootId: string,
62
62
  ): { resource: ResourceRecord; children: unknown[] } | null {
63
63
  const root = records.find((r) => r.id === rootId);
64
64
  if (!root) return null;
@@ -76,7 +76,7 @@ function buildTree(
76
76
 
77
77
  export async function listResources(
78
78
  records: ResourceRecords,
79
- filter: ResourceFilter
79
+ filter: ResourceFilter,
80
80
  ): Promise<{
81
81
  total: number;
82
82
  resources: ResourceRecords;
@@ -89,15 +89,17 @@ export async function listResources(
89
89
 
90
90
  return {
91
91
  total: result.length,
92
- resources: result
92
+ resources: result,
93
93
  };
94
94
  }
95
95
 
96
96
  export async function getResource(
97
97
  records: ResourceRecords,
98
98
  id: string,
99
- options: { children?: boolean; tree?: boolean }
100
- ): Promise<ResourceRecord | (ResourceRecord & { children?: ResourceRecords; tree?: unknown }) | null> {
99
+ options: { children?: boolean; tree?: boolean },
100
+ ): Promise<
101
+ ResourceRecord | (ResourceRecord & { children?: ResourceRecords; tree?: unknown }) | null
102
+ > {
101
103
  const record = records.find((r) => r.id === id);
102
104
  if (!record) return null;
103
105
 
@@ -117,25 +119,25 @@ export async function getResource(
117
119
  export async function getTree(
118
120
  records: ResourceRecords,
119
121
  rootId?: string,
120
- showKind?: boolean
122
+ showKind?: boolean,
121
123
  ): Promise<{ rootId: string; tree: { resource: ResourceRecord; children: unknown[] } }> {
122
124
  let effectiveRootId = rootId;
123
125
 
124
126
  if (!effectiveRootId) {
125
127
  const roots = findRoots(records);
126
128
  if (roots.length === 0) {
127
- throw new Error('No root resource found. Specify a root-id.');
129
+ throw new Error("No root resource found. Specify a root-id.");
128
130
  }
129
131
 
130
132
  if (roots.length === 1) {
131
133
  effectiveRootId = roots[0].id;
132
134
  } else {
133
- effectiveRootId = '__virtual_root__';
135
+ effectiveRootId = "__virtual_root__";
134
136
  const virtualRoot: ResourceRecord = {
135
- id: '__virtual_root__',
136
- kind: 'virtual',
137
+ id: "__virtual_root__",
138
+ kind: "virtual",
137
139
  parentId: null,
138
- settings: { title: 'Virtual Root' }
140
+ settings: { title: "Virtual Root" },
139
141
  };
140
142
  const childMap = buildChildMap(records);
141
143
  const children = roots.map((r) => buildTree(records, r.id)!).filter(Boolean);
@@ -144,8 +146,8 @@ export async function getTree(
144
146
  rootId: effectiveRootId,
145
147
  tree: {
146
148
  resource: virtualRoot,
147
- children: showKind ? children : children
148
- }
149
+ children: showKind ? children : children,
150
+ },
149
151
  };
150
152
  }
151
153
  }
@@ -1,4 +1,4 @@
1
- import { ResourceRecords } from '@ldsg/types';
2
- import { getTree } from './list';
1
+ import { ResourceRecords } from "@ldsg/types";
2
+ import { getTree } from "./list";
3
3
 
4
4
  export { getTree };
@@ -1,6 +1,6 @@
1
- import { ResourceRecord } from '@ldsg/types';
2
- import { SourceData } from '../../types/resource-record';
3
- import { updateRecord } from '../../utils/json-file-mutator';
1
+ import { ResourceRecord } from "@ldsg/types";
2
+ import { SourceData } from "../../types/resource-record";
3
+ import { updateRecord } from "../../utils/json-file-mutator";
4
4
 
5
5
  export interface UpdateOptions {
6
6
  sourceData: SourceData;
@@ -13,7 +13,7 @@ export async function updateResource(options: UpdateOptions): Promise<{ record:
13
13
  const { sourceData, id, settings, dryRun } = options;
14
14
 
15
15
  if (!settings || Object.keys(settings).length === 0) {
16
- throw new Error('Missing required option: --settings');
16
+ throw new Error("Missing required option: --settings");
17
17
  }
18
18
 
19
19
  const result = await updateRecord(sourceData, id, settings, dryRun);
package/src/constants.ts CHANGED
@@ -1,4 +1,4 @@
1
- export const DEFAULT_OUTPUT_PATH = '.';
1
+ export const DEFAULT_OUTPUT_PATH = ".";
2
2
 
3
- export const DEFAULT_SOURCE_FILE = 'resource-records.json';
3
+ export const DEFAULT_SOURCE_FILE = "resource-records.json";
4
4
  export const DEFAULT_SOURCE_PATH = `./${DEFAULT_SOURCE_FILE}`;
@@ -1,8 +1,10 @@
1
- import { AppData } from '@ldsg/types';
2
- import { ExtendAppDataParams } from '@ldsg/utils';
1
+ import { AppData } from "@ldsg/types";
2
+ import { ExtendAppDataParams } from "@ldsg/utils";
3
3
 
4
4
  interface GetExtendAppDataParamsParams {
5
5
  appData: AppData;
6
6
  }
7
7
 
8
- export type GetExtendAppDataParams = (params: GetExtendAppDataParamsParams) => Promise<ExtendAppDataParams>;
8
+ export type GetExtendAppDataParams = (
9
+ params: GetExtendAppDataParamsParams,
10
+ ) => Promise<ExtendAppDataParams>;
@@ -1,4 +1,4 @@
1
- import { ResourceRecord, ResourceRecords } from '@ldsg/types';
1
+ import { ResourceRecord, ResourceRecords } from "@ldsg/types";
2
2
 
3
3
  export interface CliError {
4
4
  code: string;
@@ -41,7 +41,7 @@ export interface DiffResult {
41
41
  sideB: ResourceRecord | null;
42
42
  }
43
43
 
44
- export type SourceFormat = 'array' | 'object';
44
+ export type SourceFormat = "array" | "object";
45
45
 
46
46
  export interface SourceData {
47
47
  resourceRecords: ResourceRecords;
@@ -1,4 +1,4 @@
1
- import { CliResponse, TreeNode, DiffResult } from '../types/resource-record';
1
+ import { CliResponse, TreeNode, DiffResult } from "../types/resource-record";
2
2
 
3
3
  export function formatSuccess<T>(data: T): CliResponse<T> {
4
4
  return { success: true, data };
@@ -14,61 +14,61 @@ export function formatJson(data: unknown): string {
14
14
 
15
15
  function formatValue(value: unknown): string {
16
16
  if (value === null || value === undefined) {
17
- return 'null';
17
+ return "null";
18
18
  }
19
- if (typeof value === 'string') {
19
+ if (typeof value === "string") {
20
20
  return value;
21
21
  }
22
- if (typeof value === 'object') {
22
+ if (typeof value === "object") {
23
23
  return JSON.stringify(value);
24
24
  }
25
25
  return String(value);
26
26
  }
27
27
 
28
28
  export function formatPrettyList(
29
- resources: { id: string; kind: string; parentId: string | null; title?: string }[]
29
+ resources: { id: string; kind: string; parentId: string | null; title?: string }[],
30
30
  ): string {
31
31
  if (resources.length === 0) {
32
- return 'No resources found.';
32
+ return "No resources found.";
33
33
  }
34
34
 
35
35
  const lines: string[] = [];
36
- lines.push(`${'ID'.padEnd(30)} ${'KIND'.padEnd(20)} PARENT ID`);
37
- lines.push('-'.repeat(70));
36
+ lines.push(`${"ID".padEnd(30)} ${"KIND".padEnd(20)} PARENT ID`);
37
+ lines.push("-".repeat(70));
38
38
 
39
39
  for (const r of resources) {
40
- const title = r.title || '';
40
+ const title = r.title || "";
41
41
  const displayId = title ? `${r.id} (${title})` : r.id;
42
- lines.push(`${displayId.padEnd(30)} ${r.kind.padEnd(20)} ${r.parentId || '-'}`);
42
+ lines.push(`${displayId.padEnd(30)} ${r.kind.padEnd(20)} ${r.parentId || "-"}`);
43
43
  }
44
44
 
45
- lines.push('');
45
+ lines.push("");
46
46
  lines.push(`Total: ${resources.length} resource(s)`);
47
- return lines.join('\n');
47
+ return lines.join("\n");
48
48
  }
49
49
 
50
- export function formatPrettyTree(node: TreeNode, showKind: boolean, indent = ''): string {
51
- const prefix = indent ? indent.slice(0, -4) + (indent.endsWith('└── ') ? ' ' : '│ ') : '';
50
+ export function formatPrettyTree(node: TreeNode, showKind: boolean, indent = ""): string {
51
+ const prefix = indent ? indent.slice(0, -4) + (indent.endsWith("└── ") ? " " : "│ ") : "";
52
52
  const label = showKind ? `[${node.resource.kind}] ${node.resource.id}` : node.resource.id;
53
53
 
54
- if (indent === '') {
54
+ if (indent === "") {
55
55
  const lines: string[] = [label];
56
56
  for (let i = 0; i < node.children.length; i++) {
57
57
  const child = node.children[i];
58
- const connector = i === node.children.length - 1 ? '└── ' : '├── ';
58
+ const connector = i === node.children.length - 1 ? "└── " : "├── ";
59
59
  lines.push(formatPrettyTree(child, showKind, connector));
60
60
  }
61
- return lines.join('\n');
61
+ return lines.join("\n");
62
62
  }
63
63
 
64
64
  const result = `${indent}${label}`;
65
65
  const childLines: string[] = [];
66
66
  for (let i = 0; i < node.children.length; i++) {
67
67
  const child = node.children[i];
68
- const connector = i === node.children.length - 1 ? '└── ' : '├── ';
68
+ const connector = i === node.children.length - 1 ? "└── " : "├── ";
69
69
  childLines.push(formatPrettyTree(child, showKind, `${prefix}${connector}`));
70
70
  }
71
- return [result, ...childLines].join('\n');
71
+ return [result, ...childLines].join("\n");
72
72
  }
73
73
 
74
74
  export function formatPrettyDiff(diff: DiffResult): string {
@@ -76,20 +76,20 @@ export function formatPrettyDiff(diff: DiffResult): string {
76
76
  lines.push(`Resource: ${diff.id} (${diff.kind})`);
77
77
  lines.push(`Source A: ${diff.sourceA}`);
78
78
  lines.push(`Source B: ${diff.sourceB}`);
79
- lines.push('');
79
+ lines.push("");
80
80
 
81
81
  if (diff.sideA === null) {
82
- lines.push('⚠ Resource only exists in source B (new)');
83
- return lines.join('\n');
82
+ lines.push("⚠ Resource only exists in source B (new)");
83
+ return lines.join("\n");
84
84
  }
85
85
  if (diff.sideB === null) {
86
- lines.push('⚠ Resource only exists in source A (removed)');
87
- return lines.join('\n');
86
+ lines.push("⚠ Resource only exists in source A (removed)");
87
+ return lines.join("\n");
88
88
  }
89
89
 
90
90
  if (diff.changed.length === 0 && diff.added.length === 0 && diff.removed.length === 0) {
91
- lines.push('No differences found.');
92
- return lines.join('\n');
91
+ lines.push("No differences found.");
92
+ return lines.join("\n");
93
93
  }
94
94
 
95
95
  for (const field of diff.changed) {
@@ -102,5 +102,5 @@ export function formatPrettyDiff(diff: DiffResult): string {
102
102
  lines.push(` ${field.path}: -"${formatValue(field.from)}"`);
103
103
  }
104
104
 
105
- return lines.join('\n');
105
+ return lines.join("\n");
106
106
  }
@@ -1,32 +1,36 @@
1
- import { FILES_IN_APP_TEMPLATE_MODULE } from '@ldsg/constants';
2
- import { ExtendAppDataParams } from '@ldsg/utils';
3
- import _ from 'lodash';
4
- import { GetExtendAppDataParams } from '../types/get-extend-app-data-params';
1
+ import { FILES_IN_APP_TEMPLATE_MODULE } from "@ldsg/constants";
2
+ import { ExtendAppDataParams } from "@ldsg/utils";
3
+ import _ from "lodash";
4
+ import { GetExtendAppDataParams } from "../types/get-extend-app-data-params";
5
5
 
6
6
  export const getExtendAppDataParamsUsingNpmLdsgModule: GetExtendAppDataParams = async (params) => {
7
7
  const { appData } = params;
8
8
 
9
- const packageJsonFile = FILES_IN_APP_TEMPLATE_MODULE.find((file) => file.path === 'package.json');
9
+ const packageJsonFile = FILES_IN_APP_TEMPLATE_MODULE.find((file) => file.path === "package.json");
10
10
 
11
11
  /**
12
12
  * 替换模块版本
13
13
  */
14
- _.set(packageJsonFile, 'data.dependencies["@ldsg/create-app"]', 'latest');
15
- _.set(packageJsonFile, 'data.dependencies["@ldsg/opentelemetry-node"]', 'latest');
16
- _.set(packageJsonFile, 'data.overrides', {
17
- graphql: '$graphql',
18
- 'graphql-middleware': '$graphql-middleware',
19
- 'graphql-shield': '$graphql-shield'
14
+ _.set(packageJsonFile, 'data.dependencies["@ldsg/create-app"]', "latest");
15
+ _.set(packageJsonFile, 'data.dependencies["@ldsg/opentelemetry-node"]', "latest");
16
+ _.set(packageJsonFile, "data.overrides", {
17
+ graphql: "$graphql",
18
+ "graphql-middleware": "$graphql-middleware",
19
+ "graphql-shield": "$graphql-shield",
20
20
  });
21
- _.set(packageJsonFile, 'data.workspaces', ['handlers/*']);
22
- _.set(packageJsonFile, 'data.scripts.build', 'npm run build --workspaces && tsc --project tsconfig.json');
21
+ _.set(packageJsonFile, "data.workspaces", ["handlers/*"]);
22
+ _.set(
23
+ packageJsonFile,
24
+ "data.scripts.build",
25
+ "npm run build --workspaces && tsc --project tsconfig.json",
26
+ );
23
27
 
24
28
  let res: ExtendAppDataParams = {
25
29
  appData,
26
30
  extraAppData: {
27
- reuseMainAppDependencies: ['graphql', 'graphql-middleware', 'graphql-shield'],
28
- filesInAppModele: [...FILES_IN_APP_TEMPLATE_MODULE, packageJsonFile]
29
- }
31
+ reuseMainAppDependencies: ["graphql", "graphql-middleware", "graphql-shield"],
32
+ filesInAppModele: [...FILES_IN_APP_TEMPLATE_MODULE, packageJsonFile],
33
+ },
30
34
  };
31
35
 
32
36
  return res;
@@ -1,10 +1,10 @@
1
- import { FILES_IN_APP_TEMPLATE_MODULE } from '@ldsg/constants';
2
- import { ExtendAppDataParams, RUSH_JSON_PATH, syncRushProjects } from '@ldsg/utils';
3
- import fs from 'fs-extra';
4
- import _ from 'lodash';
5
- import { GetExtendAppDataParams } from '../../types/get-extend-app-data-params';
1
+ import { FILES_IN_APP_TEMPLATE_MODULE } from "@ldsg/constants";
2
+ import { ExtendAppDataParams, RUSH_JSON_PATH, syncRushProjects } from "@ldsg/utils";
3
+ import fs from "fs-extra";
4
+ import _ from "lodash";
5
+ import { GetExtendAppDataParams } from "../../types/get-extend-app-data-params";
6
6
 
7
- const DEBUG_APP_PACKAGE_NAME = '@ldsg/app';
7
+ const DEBUG_APP_PACKAGE_NAME = "@ldsg/app";
8
8
 
9
9
  /**
10
10
  * 主函数,用于准备调试应用环境
@@ -19,7 +19,9 @@ const DEBUG_APP_PACKAGE_NAME = '@ldsg/app';
19
19
  * @function main
20
20
  * @throws {Error} 当文件读写操作失败时抛出错误
21
21
  */
22
- export const getExtendAppDataParamsUsingWorkspaceLdsgModule: GetExtendAppDataParams = async (params) => {
22
+ export const getExtendAppDataParamsUsingWorkspaceLdsgModule: GetExtendAppDataParams = async (
23
+ params,
24
+ ) => {
23
25
  const { appData: paramsAppData } = params;
24
26
 
25
27
  let appData = paramsAppData;
@@ -38,8 +40,8 @@ export const getExtendAppDataParamsUsingWorkspaceLdsgModule: GetExtendAppDataPar
38
40
  }[] = [
39
41
  {
40
42
  packageName: DEBUG_APP_PACKAGE_NAME,
41
- projectFolder: 'generated/app'
42
- }
43
+ projectFolder: "generated/app",
44
+ },
43
45
  ];
44
46
 
45
47
  /**
@@ -48,19 +50,19 @@ export const getExtendAppDataParamsUsingWorkspaceLdsgModule: GetExtendAppDataPar
48
50
  const resourceRecords = appDataResourceRecords.map((resourceRecord) => {
49
51
  const { id, kind } = resourceRecord;
50
52
 
51
- if (kind === 'handler') {
53
+ if (kind === "handler") {
52
54
  subspaceProjects.push({
53
55
  packageName: `${id}`,
54
- projectFolder: `generated/${id}`
56
+ projectFolder: `generated/${id}`,
55
57
  });
56
58
 
57
59
  let dependencies = resourceRecord.settings.dependencies.map((dependency) => {
58
60
  const res = dependency;
59
61
 
60
- if (_.startsWith(dependency.name, '@ldsg/')) {
62
+ if (_.startsWith(dependency.name, "@ldsg/")) {
61
63
  return {
62
64
  ...dependency,
63
- version: 'workspace:*'
65
+ version: "workspace:*",
64
66
  };
65
67
  }
66
68
 
@@ -69,21 +71,21 @@ export const getExtendAppDataParamsUsingWorkspaceLdsgModule: GetExtendAppDataPar
69
71
 
70
72
  dependencies = dependencies.concat([
71
73
  {
72
- name: '@types/node',
73
- version: '^24.1.0'
74
+ name: "@types/node",
75
+ version: "^24.1.0",
74
76
  },
75
77
  {
76
- name: 'typescript',
77
- version: '^5.3.3'
78
- }
78
+ name: "typescript",
79
+ version: "^5.3.3",
80
+ },
79
81
  ]);
80
82
 
81
83
  return {
82
84
  ...resourceRecord,
83
85
  settings: {
84
86
  ...resourceRecord.settings,
85
- dependencies
86
- }
87
+ dependencies,
88
+ },
87
89
  };
88
90
  }
89
91
 
@@ -92,12 +94,12 @@ export const getExtendAppDataParamsUsingWorkspaceLdsgModule: GetExtendAppDataPar
92
94
 
93
95
  appData = {
94
96
  ...appData,
95
- resourceRecords
97
+ resourceRecords,
96
98
  };
97
99
 
98
100
  const debugProjects = subspaceProjects.map((item) => {
99
101
  const res = {
100
- ...item
102
+ ...item,
101
103
  };
102
104
 
103
105
  return res;
@@ -106,15 +108,15 @@ export const getExtendAppDataParamsUsingWorkspaceLdsgModule: GetExtendAppDataPar
106
108
  syncRushProjects(RUSH_JSON_PATH, debugProjects);
107
109
  }
108
110
 
109
- const packageJsonFile = FILES_IN_APP_TEMPLATE_MODULE.find((file) => file.path === 'package.json');
111
+ const packageJsonFile = FILES_IN_APP_TEMPLATE_MODULE.find((file) => file.path === "package.json");
110
112
 
111
- _.set(packageJsonFile, 'data.name', DEBUG_APP_PACKAGE_NAME);
113
+ _.set(packageJsonFile, "data.name", DEBUG_APP_PACKAGE_NAME);
112
114
 
113
115
  const res: ExtendAppDataParams = {
114
116
  appData,
115
117
  extraAppData: {
116
- filesInAppModele: [...FILES_IN_APP_TEMPLATE_MODULE, packageJsonFile]
117
- }
118
+ filesInAppModele: [...FILES_IN_APP_TEMPLATE_MODULE, packageJsonFile],
119
+ },
118
120
  };
119
121
 
120
122
  return res;
@@ -1,11 +1,11 @@
1
- import fs from 'fs-extra';
2
- import { ResourceRecord, ResourceRecords } from '@ldsg/types';
3
- import { SourceData } from '../types/resource-record';
1
+ import fs from "fs-extra";
2
+ import { ResourceRecord, ResourceRecords } from "@ldsg/types";
3
+ import { SourceData } from "../types/resource-record";
4
4
 
5
5
  function buildChildMap(resourceRecords: ResourceRecords): Map<string, ResourceRecord[]> {
6
6
  const childMap = new Map<string, ResourceRecord[]>();
7
7
  for (const record of resourceRecords) {
8
- const pid = record.parentId || 'null';
8
+ const pid = record.parentId || "null";
9
9
  const children = childMap.get(pid) || [];
10
10
  children.push(record);
11
11
  childMap.set(pid, children);
@@ -32,13 +32,13 @@ function extractSourceData(data: unknown): { records: ResourceRecords; isArray:
32
32
  if (Array.isArray(data)) {
33
33
  return { records: data as ResourceRecords, isArray: true };
34
34
  }
35
- if (data && typeof data === 'object') {
35
+ if (data && typeof data === "object") {
36
36
  const obj = data as Record<string, unknown>;
37
37
  if (Array.isArray(obj.resourceRecords)) {
38
38
  return { records: obj.resourceRecords as ResourceRecords, isArray: false };
39
39
  }
40
40
  }
41
- throw new Error('Invalid resource records format');
41
+ throw new Error("Invalid resource records format");
42
42
  }
43
43
 
44
44
  function buildOutputData(records: ResourceRecords, isArray: boolean): unknown {
@@ -48,12 +48,18 @@ function buildOutputData(records: ResourceRecords, isArray: boolean): unknown {
48
48
  return { resourceRecords: records };
49
49
  }
50
50
 
51
- async function readSourceFile(filePath: string): Promise<{ records: ResourceRecords; isArray: boolean }> {
51
+ async function readSourceFile(
52
+ filePath: string,
53
+ ): Promise<{ records: ResourceRecords; isArray: boolean }> {
52
54
  const data = await fs.readJson(filePath);
53
55
  return extractSourceData(data);
54
56
  }
55
57
 
56
- async function writeSourceFile(filePath: string, records: ResourceRecords, isArray: boolean): Promise<void> {
58
+ async function writeSourceFile(
59
+ filePath: string,
60
+ records: ResourceRecords,
61
+ isArray: boolean,
62
+ ): Promise<void> {
57
63
  const output = buildOutputData(records, isArray);
58
64
  await fs.writeJson(filePath, output, { spaces: 2 });
59
65
  }
@@ -67,7 +73,7 @@ export function generateId(): string {
67
73
  export async function appendRecord(
68
74
  sourceData: SourceData,
69
75
  record: ResourceRecord,
70
- dryRun = false
76
+ dryRun = false,
71
77
  ): Promise<{ record: ResourceRecord; allRecords: ResourceRecords }> {
72
78
  const { records, isArray } = await readSourceFile(sourceData.filePath);
73
79
 
@@ -89,7 +95,7 @@ export async function updateRecord(
89
95
  sourceData: SourceData,
90
96
  id: string,
91
97
  settings: Record<string, unknown>,
92
- dryRun = false
98
+ dryRun = false,
93
99
  ): Promise<{ record: ResourceRecord; allRecords: ResourceRecords }> {
94
100
  const { records, isArray } = await readSourceFile(sourceData.filePath);
95
101
 
@@ -100,7 +106,7 @@ export async function updateRecord(
100
106
 
101
107
  const updatedRecord: ResourceRecord = {
102
108
  ...records[index],
103
- settings: { ...records[index].settings, ...settings }
109
+ settings: { ...records[index].settings, ...settings },
104
110
  };
105
111
 
106
112
  const allRecords = [...records];
@@ -116,7 +122,7 @@ export async function updateRecord(
116
122
  export async function removeRecord(
117
123
  sourceData: SourceData,
118
124
  id: string,
119
- dryRun = false
125
+ dryRun = false,
120
126
  ): Promise<{ removed: ResourceRecord[]; allRecords: ResourceRecords }> {
121
127
  const { records, isArray } = await readSourceFile(sourceData.filePath);
122
128