@ldsg/cli 0.3.38 → 0.3.41
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/.rush/temp/package-deps_build.json +36 -33
- package/.rush/temp/shrinkwrap-deps.json +4 -1
- package/.tsbuildinfo +1 -1
- package/CHANGELOG.json +69 -0
- package/CHANGELOG.md +22 -1
- package/README.md +87 -4
- package/dist/__tests__/commands.test.js +68 -12
- package/dist/__tests__/commands.test.js.map +1 -1
- package/dist/__tests__/formatter.test.js +18 -3
- package/dist/__tests__/formatter.test.js.map +1 -1
- package/dist/__tests__/generate-app-index-ts.test.d.ts +1 -0
- package/dist/__tests__/generate-app-index-ts.test.js +109 -0
- package/dist/__tests__/generate-app-index-ts.test.js.map +1 -0
- package/dist/__tests__/get-extend-app-data-params-using-workspace-ldsg-module.test.d.ts +1 -0
- package/dist/__tests__/get-extend-app-data-params-using-workspace-ldsg-module.test.js +81 -0
- package/dist/__tests__/get-extend-app-data-params-using-workspace-ldsg-module.test.js.map +1 -0
- package/dist/__tests__/json-file-mutator.test.js +54 -9
- package/dist/__tests__/json-file-mutator.test.js.map +1 -1
- package/dist/__tests__/mutate.test.d.ts +1 -0
- package/dist/__tests__/mutate.test.js +334 -0
- package/dist/__tests__/mutate.test.js.map +1 -0
- package/dist/cli.js +131 -50
- package/dist/cli.js.map +1 -1
- package/dist/commands/resource/create.js +1 -1
- package/dist/commands/resource/create.js.map +1 -1
- package/dist/commands/resource/list.js +1 -1
- package/dist/commands/resource/list.js.map +1 -1
- package/dist/commands/resource/mutate.d.ts +80 -0
- package/dist/commands/resource/mutate.js +311 -0
- package/dist/commands/resource/mutate.js.map +1 -0
- package/dist/constants.d.ts +3 -0
- package/dist/constants.js +4 -1
- package/dist/constants.js.map +1 -1
- package/dist/types/get-extend-app-data-params.d.ts +4 -1
- package/dist/utils/get-extend-app-data-params-using-workspace-ldsg-module/index.js +22 -6
- package/dist/utils/get-extend-app-data-params-using-workspace-ldsg-module/index.js.map +1 -1
- package/jest.config.js +3 -4
- package/package.json +4 -5
- package/src/__tests__/commands.test.ts +68 -12
- package/src/__tests__/formatter.test.ts +18 -3
- package/src/__tests__/generate-app-index-ts.test.ts +141 -0
- package/src/__tests__/get-extend-app-data-params-using-workspace-ldsg-module.test.ts +109 -0
- package/src/__tests__/json-file-mutator.test.ts +54 -9
- package/src/__tests__/mutate.test.ts +392 -0
- package/src/cli.ts +179 -54
- package/src/commands/resource/create.ts +3 -3
- package/src/commands/resource/list.ts +1 -1
- package/src/commands/resource/mutate.ts +542 -0
- package/src/constants.ts +4 -0
- package/src/types/get-extend-app-data-params.ts +4 -1
- package/src/utils/get-extend-app-data-params-using-workspace-ldsg-module/index.ts +43 -7
- package/.rush/temp/chunked-rush-logs/cli.format.chunks.jsonl +0 -2
- package/.rush/temp/package-deps_format.json +0 -38
- package/dist/commands/resource/convert.d.ts +0 -11
- package/dist/commands/resource/convert.js +0 -44
- package/dist/commands/resource/convert.js.map +0 -1
- package/rush-logs/cli.format.log +0 -2
- package/src/commands/resource/convert.ts +0 -54
- package/tsconfig.build.tsbuildinfo +0 -1
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.purifyResourceRecord = purifyResourceRecord;
|
|
7
|
+
exports.buildMutatePlan = buildMutatePlan;
|
|
8
|
+
exports.replaceIdsDeep = replaceIdsDeep;
|
|
9
|
+
exports.applyIdMapToRecords = applyIdMapToRecords;
|
|
10
|
+
exports.fetchRemoteResourceRecords = fetchRemoteResourceRecords;
|
|
11
|
+
exports.mutateResourceRecords = mutateResourceRecords;
|
|
12
|
+
exports.buildIdMap = buildIdMap;
|
|
13
|
+
exports.mutateResources = mutateResources;
|
|
14
|
+
exports.mutateRecordsDirect = mutateRecordsDirect;
|
|
15
|
+
exports.pullRemoteResourceRecords = pullRemoteResourceRecords;
|
|
16
|
+
const axios_1 = __importDefault(require("axios"));
|
|
17
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
18
|
+
const constants_1 = require("../../constants");
|
|
19
|
+
function purifyResourceRecord(record) {
|
|
20
|
+
return {
|
|
21
|
+
id: record.id,
|
|
22
|
+
kind: record.kind,
|
|
23
|
+
parentId: record.parentId ?? null,
|
|
24
|
+
settings: (record.settings ?? {}),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function buildMutatePlan(localRecords, remoteRecords, options = {}) {
|
|
28
|
+
const { deleteMissing = true } = options;
|
|
29
|
+
const remoteIdSet = new Set(remoteRecords.map((r) => r.id));
|
|
30
|
+
const localIdSet = new Set(localRecords.map((r) => r.id));
|
|
31
|
+
const createResourceRecords = localRecords
|
|
32
|
+
.filter((r) => !remoteIdSet.has(r.id))
|
|
33
|
+
.map(purifyResourceRecord);
|
|
34
|
+
const updateResourceRecords = localRecords
|
|
35
|
+
.filter((r) => remoteIdSet.has(r.id))
|
|
36
|
+
.map(purifyResourceRecord);
|
|
37
|
+
const deleteResourceRecords = deleteMissing
|
|
38
|
+
? remoteRecords
|
|
39
|
+
.filter((r) => !localIdSet.has(r.id))
|
|
40
|
+
.map((r) => {
|
|
41
|
+
const purified = purifyResourceRecord(r);
|
|
42
|
+
return {
|
|
43
|
+
...purified,
|
|
44
|
+
settings: { ...purified.settings, isDeleted: true },
|
|
45
|
+
};
|
|
46
|
+
})
|
|
47
|
+
: [];
|
|
48
|
+
return {
|
|
49
|
+
createResourceRecords,
|
|
50
|
+
updateResourceRecords,
|
|
51
|
+
deleteResourceRecords,
|
|
52
|
+
remoteCount: remoteRecords.length,
|
|
53
|
+
localCount: localRecords.length,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function replaceIdsDeep(value, idMap) {
|
|
57
|
+
if (typeof value === "string") {
|
|
58
|
+
return idMap[value] ?? value;
|
|
59
|
+
}
|
|
60
|
+
if (Array.isArray(value)) {
|
|
61
|
+
return value.map((item) => replaceIdsDeep(item, idMap));
|
|
62
|
+
}
|
|
63
|
+
if (value && typeof value === "object") {
|
|
64
|
+
const result = {};
|
|
65
|
+
for (const [key, item] of Object.entries(value)) {
|
|
66
|
+
result[key] = replaceIdsDeep(item, idMap);
|
|
67
|
+
}
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
70
|
+
return value;
|
|
71
|
+
}
|
|
72
|
+
function applyIdMapToRecords(records, idMap) {
|
|
73
|
+
return records.map((record) => replaceIdsDeep(record, idMap));
|
|
74
|
+
}
|
|
75
|
+
function buildRemoteFilter(path) {
|
|
76
|
+
const filter = {
|
|
77
|
+
settings: { isDeleted: { $ne: true } },
|
|
78
|
+
};
|
|
79
|
+
if (path) {
|
|
80
|
+
filter._operators = { path: { regex: path } };
|
|
81
|
+
}
|
|
82
|
+
return filter;
|
|
83
|
+
}
|
|
84
|
+
async function fetchRemoteResourceRecords(options) {
|
|
85
|
+
const { endpoint, token, path } = options;
|
|
86
|
+
const query = `
|
|
87
|
+
query ResourceRecordConnectionQuery(
|
|
88
|
+
$filter: FilterFindManyResourceRecordInput
|
|
89
|
+
$first: Int
|
|
90
|
+
$after: String
|
|
91
|
+
) {
|
|
92
|
+
resourceRecordConnection(filter: $filter, first: $first, after: $after) {
|
|
93
|
+
pageInfo {
|
|
94
|
+
hasNextPage
|
|
95
|
+
endCursor
|
|
96
|
+
}
|
|
97
|
+
edges {
|
|
98
|
+
node {
|
|
99
|
+
id: _id
|
|
100
|
+
kind
|
|
101
|
+
parentId
|
|
102
|
+
settings
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
`;
|
|
108
|
+
const records = [];
|
|
109
|
+
let after;
|
|
110
|
+
while (true) {
|
|
111
|
+
const res = await axios_1.default.post(endpoint, {
|
|
112
|
+
query,
|
|
113
|
+
variables: {
|
|
114
|
+
filter: buildRemoteFilter(path),
|
|
115
|
+
first: constants_1.RRM_FETCH_PAGE_SIZE,
|
|
116
|
+
...(after ? { after } : {}),
|
|
117
|
+
},
|
|
118
|
+
}, {
|
|
119
|
+
headers: {
|
|
120
|
+
"Content-Type": "application/json",
|
|
121
|
+
...(token ? { authorization: `Bearer ${token}` } : {}),
|
|
122
|
+
},
|
|
123
|
+
timeout: 60000,
|
|
124
|
+
});
|
|
125
|
+
if (res.data?.errors?.length > 0) {
|
|
126
|
+
throw new Error(`RRM query failed: ${res.data.errors.map((e) => e.message).join("; ")}`);
|
|
127
|
+
}
|
|
128
|
+
const page = res.data?.data?.resourceRecordConnection;
|
|
129
|
+
if (!page) {
|
|
130
|
+
throw new Error("RRM query returned no resourceRecordConnection");
|
|
131
|
+
}
|
|
132
|
+
for (const edge of page.edges ?? []) {
|
|
133
|
+
records.push({
|
|
134
|
+
id: edge.node.id,
|
|
135
|
+
kind: edge.node.kind,
|
|
136
|
+
parentId: edge.node.parentId ?? null,
|
|
137
|
+
settings: (edge.node.settings ?? {}),
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
if (!page.pageInfo?.hasNextPage)
|
|
141
|
+
break;
|
|
142
|
+
after = page.pageInfo.endCursor ?? undefined;
|
|
143
|
+
}
|
|
144
|
+
return records;
|
|
145
|
+
}
|
|
146
|
+
async function mutateResourceRecords(options) {
|
|
147
|
+
const { endpoint, token, createResourceRecords, updateResourceRecords } = options;
|
|
148
|
+
const mutation = `
|
|
149
|
+
mutation MutateResourceRecordsMutation(
|
|
150
|
+
$createResourceRecords: JSON
|
|
151
|
+
$updateResourceRecords: JSON
|
|
152
|
+
) {
|
|
153
|
+
mutateResourceRecords(
|
|
154
|
+
createResourceRecords: $createResourceRecords
|
|
155
|
+
updateResourceRecords: $updateResourceRecords
|
|
156
|
+
) {
|
|
157
|
+
updatedResourceRecords
|
|
158
|
+
createdResourceRecords
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
`;
|
|
162
|
+
const res = await axios_1.default.post(endpoint, {
|
|
163
|
+
query: mutation,
|
|
164
|
+
variables: {
|
|
165
|
+
createResourceRecords,
|
|
166
|
+
updateResourceRecords,
|
|
167
|
+
},
|
|
168
|
+
}, {
|
|
169
|
+
headers: {
|
|
170
|
+
"Content-Type": "application/json",
|
|
171
|
+
...(token ? { authorization: `Bearer ${token}` } : {}),
|
|
172
|
+
},
|
|
173
|
+
timeout: 120000,
|
|
174
|
+
});
|
|
175
|
+
if (res.data?.errors?.length > 0) {
|
|
176
|
+
throw new Error(`RRM mutateResourceRecords failed: ${res.data.errors
|
|
177
|
+
.map((e) => e.message)
|
|
178
|
+
.join("; ")}`);
|
|
179
|
+
}
|
|
180
|
+
const data = res.data?.data?.mutateResourceRecords ?? {};
|
|
181
|
+
return {
|
|
182
|
+
createdResourceRecords: (data.createdResourceRecords ?? []),
|
|
183
|
+
updatedResourceRecords: (data.updatedResourceRecords ?? []),
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
function buildIdMap(localCreateRecords, createdResourceRecords) {
|
|
187
|
+
if (createdResourceRecords.length !== localCreateRecords.length) {
|
|
188
|
+
return {};
|
|
189
|
+
}
|
|
190
|
+
const idMap = {};
|
|
191
|
+
for (let i = 0; i < localCreateRecords.length; i++) {
|
|
192
|
+
const localId = localCreateRecords[i].id;
|
|
193
|
+
const remoteId = createdResourceRecords[i].id;
|
|
194
|
+
if (localId !== remoteId) {
|
|
195
|
+
idMap[localId] = remoteId;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return idMap;
|
|
199
|
+
}
|
|
200
|
+
async function writeBackLocalFile(sourceData, idMap) {
|
|
201
|
+
if (sourceData.filePath === "-stdin-") {
|
|
202
|
+
return undefined;
|
|
203
|
+
}
|
|
204
|
+
if (Object.keys(idMap).length === 0) {
|
|
205
|
+
return undefined;
|
|
206
|
+
}
|
|
207
|
+
const updatedRecords = applyIdMapToRecords(sourceData.resourceRecords, idMap);
|
|
208
|
+
const output = sourceData.format === "array" ? updatedRecords : { resourceRecords: updatedRecords };
|
|
209
|
+
await fs_extra_1.default.writeJson(sourceData.filePath, output, { spaces: 2 });
|
|
210
|
+
return sourceData.filePath;
|
|
211
|
+
}
|
|
212
|
+
async function mutateResources(options) {
|
|
213
|
+
const { sourceData, endpoint = constants_1.DEFAULT_RRM_GRAPHQL_ENDPOINT, token, path, deleteMissing = true, writeBack = true, yes = false, dryRun = false, } = options;
|
|
214
|
+
const remoteRecords = await fetchRemoteResourceRecords({ endpoint, token, path });
|
|
215
|
+
const plan = buildMutatePlan(sourceData.resourceRecords, remoteRecords, { deleteMissing });
|
|
216
|
+
if (dryRun) {
|
|
217
|
+
return {
|
|
218
|
+
plan,
|
|
219
|
+
dryRun: true,
|
|
220
|
+
createdResourceRecords: [],
|
|
221
|
+
updatedResourceRecords: [],
|
|
222
|
+
idMap: {},
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
const hasWrites = plan.createResourceRecords.length > 0 ||
|
|
226
|
+
plan.updateResourceRecords.length > 0 ||
|
|
227
|
+
plan.deleteResourceRecords.length > 0;
|
|
228
|
+
if (!hasWrites) {
|
|
229
|
+
return {
|
|
230
|
+
plan,
|
|
231
|
+
dryRun: false,
|
|
232
|
+
createdResourceRecords: [],
|
|
233
|
+
updatedResourceRecords: [],
|
|
234
|
+
idMap: {},
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
const effectiveToken = token || process.env.RRM_ACCESS_TOKEN;
|
|
238
|
+
if (!effectiveToken) {
|
|
239
|
+
throw new Error("RRM 写操作需要鉴权:请通过 --token 或环境变量 RRM_ACCESS_TOKEN 提供 Bearer token(console 登录后 localStorage 的 ACCESS_TOKEN)");
|
|
240
|
+
}
|
|
241
|
+
if (plan.deleteResourceRecords.length > 0 && !yes) {
|
|
242
|
+
throw new Error(`本次将软删除 ${plan.deleteResourceRecords.length} 条远端记录(settings.isDeleted=true)。` +
|
|
243
|
+
"请先用 --dry-run 查看,确认后加 --yes 执行;或加 --no-delete-missing 关闭软删除。");
|
|
244
|
+
}
|
|
245
|
+
const updateResourceRecords = [...plan.updateResourceRecords, ...plan.deleteResourceRecords];
|
|
246
|
+
const { createdResourceRecords, updatedResourceRecords: returnedUpdated } = await mutateResourceRecords({
|
|
247
|
+
endpoint,
|
|
248
|
+
token: effectiveToken,
|
|
249
|
+
createResourceRecords: plan.createResourceRecords,
|
|
250
|
+
updateResourceRecords,
|
|
251
|
+
});
|
|
252
|
+
const idMap = buildIdMap(plan.createResourceRecords, createdResourceRecords);
|
|
253
|
+
let writeBackPath;
|
|
254
|
+
if (writeBack) {
|
|
255
|
+
writeBackPath = await writeBackLocalFile(sourceData, idMap);
|
|
256
|
+
}
|
|
257
|
+
return {
|
|
258
|
+
plan,
|
|
259
|
+
dryRun: false,
|
|
260
|
+
createdResourceRecords,
|
|
261
|
+
updatedResourceRecords: returnedUpdated,
|
|
262
|
+
idMap,
|
|
263
|
+
writeBackPath,
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
async function mutateRecordsDirect(options) {
|
|
267
|
+
const { endpoint = constants_1.DEFAULT_RRM_GRAPHQL_ENDPOINT, token, createResourceRecords, updateResourceRecords, dryRun = false, } = options;
|
|
268
|
+
const hasWrites = createResourceRecords.length > 0 || updateResourceRecords.length > 0;
|
|
269
|
+
if (!hasWrites) {
|
|
270
|
+
return {
|
|
271
|
+
dryRun,
|
|
272
|
+
createCount: 0,
|
|
273
|
+
updateCount: 0,
|
|
274
|
+
createdResourceRecords: [],
|
|
275
|
+
updatedResourceRecords: [],
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
if (dryRun) {
|
|
279
|
+
return {
|
|
280
|
+
dryRun: true,
|
|
281
|
+
createCount: createResourceRecords.length,
|
|
282
|
+
updateCount: updateResourceRecords.length,
|
|
283
|
+
createdResourceRecords: [],
|
|
284
|
+
updatedResourceRecords: [],
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
const effectiveToken = token || process.env.RRM_ACCESS_TOKEN;
|
|
288
|
+
if (!effectiveToken) {
|
|
289
|
+
throw new Error("RRM 写操作需要鉴权:请通过 --token 或环境变量 RRM_ACCESS_TOKEN 提供 Bearer token(console 登录后 localStorage 的 ACCESS_TOKEN)");
|
|
290
|
+
}
|
|
291
|
+
const { createdResourceRecords: created, updatedResourceRecords: updated } = await mutateResourceRecords({
|
|
292
|
+
endpoint,
|
|
293
|
+
token: effectiveToken,
|
|
294
|
+
createResourceRecords,
|
|
295
|
+
updateResourceRecords,
|
|
296
|
+
});
|
|
297
|
+
return {
|
|
298
|
+
dryRun: false,
|
|
299
|
+
createCount: createResourceRecords.length,
|
|
300
|
+
updateCount: updateResourceRecords.length,
|
|
301
|
+
createdResourceRecords: created,
|
|
302
|
+
updatedResourceRecords: updated,
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
async function pullRemoteResourceRecords(options) {
|
|
306
|
+
const { endpoint = constants_1.DEFAULT_RRM_GRAPHQL_ENDPOINT, token, path, output = constants_1.DEFAULT_SOURCE_PATH, } = options;
|
|
307
|
+
const records = await fetchRemoteResourceRecords({ endpoint, token, path });
|
|
308
|
+
await fs_extra_1.default.writeJson(output, records, { spaces: 2 });
|
|
309
|
+
return { count: records.length, outputPath: output };
|
|
310
|
+
}
|
|
311
|
+
//# sourceMappingURL=mutate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutate.js","sourceRoot":"","sources":["../../../src/commands/resource/mutate.ts"],"names":[],"mappings":";;;;;AAmEA,oDAOC;AASD,0CAqCC;AAOD,wCAeC;AAKD,kDAKC;AAeD,gEA8EC;AAKD,sDA0DC;AAOD,gCAiBC;AA2BD,0CAiFC;AAcD,kDA4DC;AAYD,8DAeC;AA7hBD,kDAA0B;AAC1B,wDAA0B;AAE1B,+CAIyB;AA4DzB,SAAgB,oBAAoB,CAAC,MAAsB;IACzD,OAAO;QACL,EAAE,EAAE,MAAM,CAAC,EAAE;QACb,IAAI,EAAE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AC,MAAM;QACzC,sBAAsB,EAAE,OAAO;QAC/B,sBAAsB,EAAE,OAAO;KAChC,CAAC;AACJ,CAAC;AAYM,KAAK,UAAU,yBAAyB,CAC7C,OAAyC;IAEzC,MAAM,EACJ,QAAQ,GAAG,wCAA4B,EACvC,KAAK,EACL,IAAI,EACJ,MAAM,GAAG,+BAAmB,GAC7B,GAAG,OAAO,CAAC;IAEZ,MAAM,OAAO,GAAG,MAAM,0BAA0B,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAE5E,MAAM,kBAAE,CAAC,SAAS,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;IAEnD,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC;AACvD,CAAC"}
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
export declare const DEFAULT_OUTPUT_PATH = ".";
|
|
2
2
|
export declare const DEFAULT_SOURCE_FILE = "resource-records.json";
|
|
3
3
|
export declare const DEFAULT_SOURCE_PATH = "./resource-records.json";
|
|
4
|
+
export declare const DEFAULT_RRM_GRAPHQL_ENDPOINT = "https://api.rrm.ldsgy.com/graphql";
|
|
5
|
+
export declare const RRM_ACCESS_TOKEN_ENV = "RRM_ACCESS_TOKEN";
|
|
6
|
+
export declare const RRM_FETCH_PAGE_SIZE = 100;
|
package/dist/constants.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEFAULT_SOURCE_PATH = exports.DEFAULT_SOURCE_FILE = exports.DEFAULT_OUTPUT_PATH = void 0;
|
|
3
|
+
exports.RRM_FETCH_PAGE_SIZE = exports.RRM_ACCESS_TOKEN_ENV = exports.DEFAULT_RRM_GRAPHQL_ENDPOINT = exports.DEFAULT_SOURCE_PATH = exports.DEFAULT_SOURCE_FILE = exports.DEFAULT_OUTPUT_PATH = void 0;
|
|
4
4
|
exports.DEFAULT_OUTPUT_PATH = ".";
|
|
5
5
|
exports.DEFAULT_SOURCE_FILE = "resource-records.json";
|
|
6
6
|
exports.DEFAULT_SOURCE_PATH = `./${exports.DEFAULT_SOURCE_FILE}`;
|
|
7
|
+
exports.DEFAULT_RRM_GRAPHQL_ENDPOINT = "https://api.rrm.ldsgy.com/graphql";
|
|
8
|
+
exports.RRM_ACCESS_TOKEN_ENV = "RRM_ACCESS_TOKEN";
|
|
9
|
+
exports.RRM_FETCH_PAGE_SIZE = 100;
|
|
7
10
|
//# sourceMappingURL=constants.js.map
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,mBAAmB,GAAG,GAAG,CAAC;AAE1B,QAAA,mBAAmB,GAAG,uBAAuB,CAAC;AAC9C,QAAA,mBAAmB,GAAG,KAAK,2BAAmB,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,mBAAmB,GAAG,GAAG,CAAC;AAE1B,QAAA,mBAAmB,GAAG,uBAAuB,CAAC;AAC9C,QAAA,mBAAmB,GAAG,KAAK,2BAAmB,EAAE,CAAC;AAEjD,QAAA,4BAA4B,GAAG,mCAAmC,CAAC;AACnE,QAAA,oBAAoB,GAAG,kBAAkB,CAAC;AAC1C,QAAA,mBAAmB,GAAG,GAAG,CAAC"}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { AppData } from "@ldsg/types";
|
|
2
|
-
import { ExtendAppDataParams } from "@ldsg/utils";
|
|
2
|
+
import { ExtendAppDataParams, ZipAppDataLayout } from "@ldsg/utils";
|
|
3
3
|
interface GetExtendAppDataParamsParams {
|
|
4
4
|
appData: AppData;
|
|
5
|
+
layout?: ZipAppDataLayout;
|
|
6
|
+
appPackageName?: string;
|
|
7
|
+
outputPath?: string;
|
|
5
8
|
}
|
|
6
9
|
export type GetExtendAppDataParams = (params: GetExtendAppDataParamsParams) => Promise<ExtendAppDataParams>;
|
|
7
10
|
export {};
|
|
@@ -7,24 +7,35 @@ exports.getExtendAppDataParamsUsingWorkspaceLdsgModule = void 0;
|
|
|
7
7
|
const constants_1 = require("@ldsg/constants");
|
|
8
8
|
const utils_1 = require("@ldsg/utils");
|
|
9
9
|
const lodash_1 = __importDefault(require("lodash"));
|
|
10
|
-
const
|
|
10
|
+
const path_1 = __importDefault(require("path"));
|
|
11
|
+
const DEFAULT_APP_PACKAGE_NAME = "@ldsg/app";
|
|
12
|
+
const DEFAULT_OUTPUT_PATH = "../../generated";
|
|
11
13
|
const getExtendAppDataParamsUsingWorkspaceLdsgModule = async (params) => {
|
|
12
|
-
const { appData: paramsAppData } = params;
|
|
14
|
+
const { appData: paramsAppData, layout = utils_1.ZipAppDataLayout.FLAT, appPackageName = DEFAULT_APP_PACKAGE_NAME, outputPath = DEFAULT_OUTPUT_PATH, } = params;
|
|
13
15
|
let appData = paramsAppData;
|
|
16
|
+
const handlerResourceIds = [];
|
|
14
17
|
{
|
|
15
18
|
const { resourceRecords: appDataResourceRecords } = appData;
|
|
19
|
+
const repoRoot = path_1.default.resolve(process.cwd(), "../..");
|
|
20
|
+
const outputAbs = path_1.default.resolve(process.cwd(), outputPath);
|
|
21
|
+
const outputRel = path_1.default.relative(repoRoot, outputAbs);
|
|
22
|
+
const appProjectFolder = layout === utils_1.ZipAppDataLayout.NESTED ? outputRel : path_1.default.join(outputRel, "app");
|
|
23
|
+
const getHandlerProjectFolder = (id) => layout === utils_1.ZipAppDataLayout.NESTED
|
|
24
|
+
? path_1.default.join(outputRel, "handlers", id)
|
|
25
|
+
: path_1.default.join(outputRel, id);
|
|
16
26
|
const subspaceProjects = [
|
|
17
27
|
{
|
|
18
|
-
packageName:
|
|
19
|
-
projectFolder:
|
|
28
|
+
packageName: appPackageName,
|
|
29
|
+
projectFolder: appProjectFolder,
|
|
20
30
|
},
|
|
21
31
|
];
|
|
22
32
|
const resourceRecords = appDataResourceRecords.map((resourceRecord) => {
|
|
23
33
|
const { id, kind } = resourceRecord;
|
|
24
34
|
if (kind === "handler") {
|
|
35
|
+
handlerResourceIds.push(id);
|
|
25
36
|
subspaceProjects.push({
|
|
26
37
|
packageName: `${id}`,
|
|
27
|
-
projectFolder:
|
|
38
|
+
projectFolder: getHandlerProjectFolder(id),
|
|
28
39
|
});
|
|
29
40
|
let dependencies = resourceRecord.settings.dependencies.map((dependency) => {
|
|
30
41
|
const res = dependency;
|
|
@@ -69,7 +80,12 @@ const getExtendAppDataParamsUsingWorkspaceLdsgModule = async (params) => {
|
|
|
69
80
|
(0, utils_1.syncRushProjects)(utils_1.RUSH_JSON_PATH, debugProjects);
|
|
70
81
|
}
|
|
71
82
|
const packageJsonFile = constants_1.FILES_IN_APP_TEMPLATE_MODULE.find((file) => file.path === "package.json");
|
|
72
|
-
lodash_1.default.set(packageJsonFile, "data.name",
|
|
83
|
+
lodash_1.default.set(packageJsonFile, "data.name", appPackageName);
|
|
84
|
+
const dependencies = {
|
|
85
|
+
...lodash_1.default.get(packageJsonFile, "data.dependencies"),
|
|
86
|
+
...lodash_1.default.mapValues(lodash_1.default.keyBy(handlerResourceIds), () => "workspace:*"),
|
|
87
|
+
};
|
|
88
|
+
lodash_1.default.set(packageJsonFile, "data.dependencies", dependencies);
|
|
73
89
|
const res = {
|
|
74
90
|
appData,
|
|
75
91
|
extraAppData: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/get-extend-app-data-params-using-workspace-ldsg-module/index.ts"],"names":[],"mappings":";;;;;;AAAA,+CAA+D;AAC/D,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/get-extend-app-data-params-using-workspace-lds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M,aAAa,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;YAClD,MAAM,GAAG,GAAG;gBACV,GAAG,IAAI;aACR,CAAC;YAEF,OAAO,GAAG,CAAC;QACb,CAAC,CAAC,CAAC;QAEH,IAAA,wBAAgB,EAAC,sBAAc,EAAE,aAAa,CAAC,CAAC;IAClD,CAAC;IAED,MAAM,eAAe,GAAG,wCAA4B,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,cAAc,CAAC,CAAC;IAElG,gBAAC,CAAC,GAAG,CAAC,eAAe,EAAE,WAAW,EAAE,cAAc,CAAC,CAAC;IAEpD,MAAM,YAAY,GAAG;QACnB,GAAG,gBAAC,CAAC,GAAG,CAAC,eAAe,EAAE,mBAAmB,CAAC;QAC9C,GAAG,gBAAC,CAAC,SAAS,CAAC,gBAAC,CAAC,KAAK,CAAC,kBAAkB,CAAC,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC;KACjE,CAAC;IAEF,gBAAC,CAAC,GAAG,CAAC,eAAe,EAAE,mBAAmB,EAAE,YAAY,CAAC,CAAC;IAE1D,MAAM,GAAG,GAAwB;QAC/B,OAAO;QACP,YAAY,EAAE;YACZ,gBAAgB,EAAE,CAAC,GAAG,wCAA4B,EAAE,eAAe,CAAC;SACrE;KACF,CAAC;IAEF,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAjIW,QAAA,8CAA8C,kDAiIzD"}
|
package/jest.config.js
CHANGED
|
@@ -4,9 +4,8 @@ module.exports = {
|
|
|
4
4
|
testEnvironment: "node",
|
|
5
5
|
testMatch: ["**/__tests__/**/*.test.ts"],
|
|
6
6
|
moduleNameMapper: {
|
|
7
|
-
"^@ldsg/types$": "<rootDir
|
|
8
|
-
"^@ldsg/constants$": "<rootDir
|
|
9
|
-
"^@ldsg/
|
|
10
|
-
"^@ldsg/utils$": "<rootDir>/../utils/src",
|
|
7
|
+
"^@ldsg/types$": "<rootDir>/../../libs/types/src",
|
|
8
|
+
"^@ldsg/constants$": "<rootDir>/../../libs/constants/src",
|
|
9
|
+
"^@ldsg/utils$": "<rootDir>/../../libs/utils/src",
|
|
11
10
|
},
|
|
12
11
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ldsg/cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.41",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "ISC",
|
|
@@ -17,10 +17,9 @@
|
|
|
17
17
|
"commander": "^12.0.0",
|
|
18
18
|
"fs-extra": "^11.3.0",
|
|
19
19
|
"js-yaml": "^4.1.0",
|
|
20
|
-
"@ldsg/
|
|
21
|
-
"@ldsg/
|
|
22
|
-
"@ldsg/utils": "0.3.
|
|
23
|
-
"@ldsg/constants": "0.3.38"
|
|
20
|
+
"@ldsg/types": "0.3.41",
|
|
21
|
+
"@ldsg/constants": "0.3.41",
|
|
22
|
+
"@ldsg/utils": "0.3.41"
|
|
24
23
|
},
|
|
25
24
|
"devDependencies": {
|
|
26
25
|
"@types/fs-extra": "^11.0.4",
|
|
@@ -12,12 +12,42 @@ jest.mock("fs-extra");
|
|
|
12
12
|
const mockedFs = fs as jest.Mocked<typeof fs>;
|
|
13
13
|
|
|
14
14
|
const sampleRecords: ResourceRecords = [
|
|
15
|
-
{
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
{
|
|
16
|
+
id: "app1",
|
|
17
|
+
kind: "application",
|
|
18
|
+
parentId: null,
|
|
19
|
+
settings: { slug: "app1", title: "My App", description: "" },
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
id: "form1",
|
|
23
|
+
kind: "form",
|
|
24
|
+
parentId: "app1",
|
|
25
|
+
settings: { slug: "form1", title: "Login Form", description: "" },
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
id: "form2",
|
|
29
|
+
kind: "form",
|
|
30
|
+
parentId: "app1",
|
|
31
|
+
settings: { slug: "form2", title: "Register Form", description: "" },
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
id: "table1",
|
|
35
|
+
kind: "table",
|
|
36
|
+
parentId: "app1",
|
|
37
|
+
settings: { slug: "table1", title: "Users", description: "" },
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
id: "field1",
|
|
41
|
+
kind: "field",
|
|
42
|
+
parentId: "table1",
|
|
43
|
+
settings: { slug: "field1", title: "Name", description: "" },
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
id: "field2",
|
|
47
|
+
kind: "field",
|
|
48
|
+
parentId: "table1",
|
|
49
|
+
settings: { slug: "field2", title: "Email", description: "" },
|
|
50
|
+
},
|
|
21
51
|
];
|
|
22
52
|
|
|
23
53
|
const sourceData: SourceData = {
|
|
@@ -97,8 +127,18 @@ describe("commands", () => {
|
|
|
97
127
|
|
|
98
128
|
it("should auto-detect root when only one", async () => {
|
|
99
129
|
const singleRoot: ResourceRecords = [
|
|
100
|
-
{
|
|
101
|
-
|
|
130
|
+
{
|
|
131
|
+
id: "app1",
|
|
132
|
+
kind: "application",
|
|
133
|
+
parentId: null,
|
|
134
|
+
settings: { slug: "app1", title: "App1", description: "" },
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
id: "form1",
|
|
138
|
+
kind: "form",
|
|
139
|
+
parentId: "app1",
|
|
140
|
+
settings: { slug: "form1", title: "Form1", description: "" },
|
|
141
|
+
},
|
|
102
142
|
];
|
|
103
143
|
const result = await getTree(singleRoot, undefined);
|
|
104
144
|
expect(result.rootId).toBe("app1");
|
|
@@ -156,7 +196,11 @@ describe("commands", () => {
|
|
|
156
196
|
});
|
|
157
197
|
|
|
158
198
|
expect(result.record.id).toBe("form1");
|
|
159
|
-
expect(result.record.settings).toEqual({
|
|
199
|
+
expect(result.record.settings).toEqual({
|
|
200
|
+
slug: "form1",
|
|
201
|
+
title: "Updated Form",
|
|
202
|
+
description: "",
|
|
203
|
+
});
|
|
160
204
|
expect(mockedFs.writeJson).toHaveBeenCalled();
|
|
161
205
|
});
|
|
162
206
|
|
|
@@ -196,14 +240,19 @@ describe("commands", () => {
|
|
|
196
240
|
|
|
197
241
|
describe("diffResource", () => {
|
|
198
242
|
const recordsA: ResourceRecords = [
|
|
199
|
-
{
|
|
243
|
+
{
|
|
244
|
+
id: "1",
|
|
245
|
+
kind: "application",
|
|
246
|
+
parentId: null,
|
|
247
|
+
settings: { slug: "app-a", title: "App A", description: "", version: 1 },
|
|
248
|
+
},
|
|
200
249
|
];
|
|
201
250
|
const recordsB: ResourceRecords = [
|
|
202
251
|
{
|
|
203
252
|
id: "1",
|
|
204
253
|
kind: "application",
|
|
205
254
|
parentId: null,
|
|
206
|
-
settings: { title: "App B", version: 1, newField: "new" },
|
|
255
|
+
settings: { slug: "app-b", title: "App B", description: "", version: 1, newField: "new" },
|
|
207
256
|
},
|
|
208
257
|
];
|
|
209
258
|
|
|
@@ -238,7 +287,14 @@ describe("commands", () => {
|
|
|
238
287
|
sourceB: "b.json",
|
|
239
288
|
id: "2",
|
|
240
289
|
recordsA: [],
|
|
241
|
-
recordsB: [
|
|
290
|
+
recordsB: [
|
|
291
|
+
{
|
|
292
|
+
id: "2",
|
|
293
|
+
kind: "application",
|
|
294
|
+
parentId: null,
|
|
295
|
+
settings: { slug: "app2", title: "App2", description: "" },
|
|
296
|
+
},
|
|
297
|
+
],
|
|
242
298
|
});
|
|
243
299
|
|
|
244
300
|
expect(result.sideA).toBeNull();
|
|
@@ -53,10 +53,20 @@ describe("formatter", () => {
|
|
|
53
53
|
describe("formatPrettyTree", () => {
|
|
54
54
|
it("should format a tree with root and children", () => {
|
|
55
55
|
const tree = {
|
|
56
|
-
resource: {
|
|
56
|
+
resource: {
|
|
57
|
+
id: "1",
|
|
58
|
+
kind: "application",
|
|
59
|
+
parentId: null,
|
|
60
|
+
settings: { slug: "app1", title: "App1", description: "" },
|
|
61
|
+
},
|
|
57
62
|
children: [
|
|
58
63
|
{
|
|
59
|
-
resource: {
|
|
64
|
+
resource: {
|
|
65
|
+
id: "2",
|
|
66
|
+
kind: "form",
|
|
67
|
+
parentId: "1",
|
|
68
|
+
settings: { slug: "form1", title: "Form1", description: "" },
|
|
69
|
+
},
|
|
60
70
|
children: [],
|
|
61
71
|
},
|
|
62
72
|
],
|
|
@@ -70,7 +80,12 @@ describe("formatter", () => {
|
|
|
70
80
|
|
|
71
81
|
it("should show kind prefix with showKind option", () => {
|
|
72
82
|
const tree = {
|
|
73
|
-
resource: {
|
|
83
|
+
resource: {
|
|
84
|
+
id: "1",
|
|
85
|
+
kind: "application",
|
|
86
|
+
parentId: null,
|
|
87
|
+
settings: { slug: "app1", title: "App1", description: "" },
|
|
88
|
+
},
|
|
74
89
|
children: [],
|
|
75
90
|
};
|
|
76
91
|
|