@lark-apaas/fullstack-cli 1.1.28-alpha.15 → 1.1.28-alpha.16
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/index.js +7 -88
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1414,14 +1414,15 @@ async function fetchSyncedTables(appId, workspace) {
|
|
|
1414
1414
|
DEFAULT_TIMEOUT_MS2
|
|
1415
1415
|
);
|
|
1416
1416
|
});
|
|
1417
|
+
const dbBranch = process.env.FORCE_DB_BRANCH || "main";
|
|
1417
1418
|
const start = Date.now();
|
|
1418
1419
|
console.log(
|
|
1419
|
-
`[fetchSyncedTables] \u2192 GET listTableView (dbBranch
|
|
1420
|
+
`[fetchSyncedTables] \u2192 GET listTableView (dbBranch=${dbBranch}) appId=${appId ? "set" : "unset"} workspace=${workspace ? "set" : "unset"}`
|
|
1420
1421
|
);
|
|
1421
1422
|
const response = await Promise.race([
|
|
1422
1423
|
client.get(
|
|
1423
1424
|
`/api/v1/dataloom/inner/app/${appId}/workspaces/${workspace}/listTableView`,
|
|
1424
|
-
{ params: { dbBranch
|
|
1425
|
+
{ params: { dbBranch }, headers: { "x-supaas-bizsource": "miaoda" } }
|
|
1425
1426
|
),
|
|
1426
1427
|
timeoutPromise
|
|
1427
1428
|
]);
|
|
@@ -2377,15 +2378,12 @@ var syncConfig = {
|
|
|
2377
2378
|
type: "directory",
|
|
2378
2379
|
overwrite: true
|
|
2379
2380
|
},
|
|
2380
|
-
// 2.
|
|
2381
|
+
// 2. 覆写 nest-cli.json 配置,禁止用户修改
|
|
2381
2382
|
{
|
|
2382
2383
|
from: "templates/nest-cli.json",
|
|
2383
2384
|
to: "nest-cli.json",
|
|
2384
|
-
type: "
|
|
2385
|
-
|
|
2386
|
-
"compilerOptions.assets": { key: "include" },
|
|
2387
|
-
"compilerOptions.plugins": { key: "name" }
|
|
2388
|
-
}
|
|
2385
|
+
type: "file",
|
|
2386
|
+
overwrite: true
|
|
2389
2387
|
},
|
|
2390
2388
|
// // 2. 追加内容到 .gitignore
|
|
2391
2389
|
// {
|
|
@@ -2478,52 +2476,6 @@ function removeLineFromFile(filePath, pattern) {
|
|
|
2478
2476
|
return true;
|
|
2479
2477
|
}
|
|
2480
2478
|
|
|
2481
|
-
// src/utils/merge-json.ts
|
|
2482
|
-
function isPlainObject(value) {
|
|
2483
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
2484
|
-
}
|
|
2485
|
-
function mergeArrayByKey(userArr, templateArr, key) {
|
|
2486
|
-
const result = [...userArr];
|
|
2487
|
-
for (const templateItem of templateArr) {
|
|
2488
|
-
if (!isPlainObject(templateItem)) continue;
|
|
2489
|
-
const templateKey = templateItem[key];
|
|
2490
|
-
const existingIndex = result.findIndex(
|
|
2491
|
-
(item) => isPlainObject(item) && item[key] === templateKey
|
|
2492
|
-
);
|
|
2493
|
-
if (existingIndex >= 0) {
|
|
2494
|
-
result[existingIndex] = templateItem;
|
|
2495
|
-
} else {
|
|
2496
|
-
result.push(templateItem);
|
|
2497
|
-
}
|
|
2498
|
-
}
|
|
2499
|
-
return result;
|
|
2500
|
-
}
|
|
2501
|
-
function deepMergeJson(user, template, arrayMerge = {}, currentPath = "") {
|
|
2502
|
-
const result = { ...user };
|
|
2503
|
-
for (const key of Object.keys(template)) {
|
|
2504
|
-
const fullPath = currentPath ? `${currentPath}.${key}` : key;
|
|
2505
|
-
const templateValue = template[key];
|
|
2506
|
-
const userValue = user[key];
|
|
2507
|
-
if (Array.isArray(templateValue)) {
|
|
2508
|
-
const mergeConfig = arrayMerge[fullPath];
|
|
2509
|
-
if (mergeConfig && Array.isArray(userValue)) {
|
|
2510
|
-
result[key] = mergeArrayByKey(userValue, templateValue, mergeConfig.key);
|
|
2511
|
-
} else {
|
|
2512
|
-
result[key] = templateValue;
|
|
2513
|
-
}
|
|
2514
|
-
} else if (isPlainObject(templateValue)) {
|
|
2515
|
-
if (isPlainObject(userValue)) {
|
|
2516
|
-
result[key] = deepMergeJson(userValue, templateValue, arrayMerge, fullPath);
|
|
2517
|
-
} else {
|
|
2518
|
-
result[key] = templateValue;
|
|
2519
|
-
}
|
|
2520
|
-
} else {
|
|
2521
|
-
result[key] = templateValue;
|
|
2522
|
-
}
|
|
2523
|
-
}
|
|
2524
|
-
return result;
|
|
2525
|
-
}
|
|
2526
|
-
|
|
2527
2479
|
// src/commands/sync/run.handler.ts
|
|
2528
2480
|
async function run2(options) {
|
|
2529
2481
|
const userProjectRoot = process.env.INIT_CWD || process.cwd();
|
|
@@ -2586,12 +2538,6 @@ async function syncRule(rule, pluginRoot, userProjectRoot) {
|
|
|
2586
2538
|
addLineToFile(destPath2, rule.line);
|
|
2587
2539
|
return;
|
|
2588
2540
|
}
|
|
2589
|
-
if (rule.type === "merge-json") {
|
|
2590
|
-
const srcPath2 = path4.join(pluginRoot, rule.from);
|
|
2591
|
-
const destPath2 = path4.join(userProjectRoot, rule.to);
|
|
2592
|
-
mergeJsonFile(srcPath2, destPath2, rule.arrayMerge);
|
|
2593
|
-
return;
|
|
2594
|
-
}
|
|
2595
2541
|
if (!("from" in rule)) {
|
|
2596
2542
|
return;
|
|
2597
2543
|
}
|
|
@@ -2734,33 +2680,6 @@ function addLineToFile(filePath, line) {
|
|
|
2734
2680
|
fs6.appendFileSync(filePath, appendContent);
|
|
2735
2681
|
console.log(`[fullstack-cli] \u2713 ${fileName} (added: ${line})`);
|
|
2736
2682
|
}
|
|
2737
|
-
function mergeJsonFile(src, dest, arrayMerge) {
|
|
2738
|
-
const fileName = path4.basename(dest);
|
|
2739
|
-
if (!fs6.existsSync(src)) {
|
|
2740
|
-
console.warn(`[fullstack-cli] Source not found: ${src}`);
|
|
2741
|
-
return;
|
|
2742
|
-
}
|
|
2743
|
-
const templateContent = JSON.parse(fs6.readFileSync(src, "utf-8"));
|
|
2744
|
-
if (!fs6.existsSync(dest)) {
|
|
2745
|
-
const destDir = path4.dirname(dest);
|
|
2746
|
-
if (!fs6.existsSync(destDir)) {
|
|
2747
|
-
fs6.mkdirSync(destDir, { recursive: true });
|
|
2748
|
-
}
|
|
2749
|
-
fs6.writeFileSync(dest, JSON.stringify(templateContent, null, 2) + "\n");
|
|
2750
|
-
console.log(`[fullstack-cli] \u2713 ${fileName} (created)`);
|
|
2751
|
-
return;
|
|
2752
|
-
}
|
|
2753
|
-
const userContent = JSON.parse(fs6.readFileSync(dest, "utf-8"));
|
|
2754
|
-
const merged = deepMergeJson(userContent, templateContent, arrayMerge ?? {});
|
|
2755
|
-
const userStr = JSON.stringify(userContent, null, 2);
|
|
2756
|
-
const mergedStr = JSON.stringify(merged, null, 2);
|
|
2757
|
-
if (userStr === mergedStr) {
|
|
2758
|
-
console.log(`[fullstack-cli] \u25CB ${fileName} (already up to date)`);
|
|
2759
|
-
return;
|
|
2760
|
-
}
|
|
2761
|
-
fs6.writeFileSync(dest, mergedStr + "\n");
|
|
2762
|
-
console.log(`[fullstack-cli] \u2713 ${fileName} (merged)`);
|
|
2763
|
-
}
|
|
2764
2683
|
|
|
2765
2684
|
// src/commands/sync/index.ts
|
|
2766
2685
|
var syncCommand = {
|
|
@@ -3017,7 +2936,7 @@ function getUpgradeFilesToStage(disableGenOpenapi = true) {
|
|
|
3017
2936
|
const syncConfig2 = genSyncConfig({ disableGenOpenapi });
|
|
3018
2937
|
const filesToStage = /* @__PURE__ */ new Set();
|
|
3019
2938
|
syncConfig2.sync.forEach((rule) => {
|
|
3020
|
-
if (rule.type === "file" || rule.type === "directory"
|
|
2939
|
+
if (rule.type === "file" || rule.type === "directory") {
|
|
3021
2940
|
filesToStage.add(rule.to);
|
|
3022
2941
|
} else if (rule.type === "remove-line" || rule.type === "add-line") {
|
|
3023
2942
|
filesToStage.add(rule.to);
|