@lark-apaas/fullstack-cli 1.1.37 → 1.1.38
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 +47 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2438,6 +2438,13 @@ var syncConfig = {
|
|
|
2438
2438
|
to: ".spark_project",
|
|
2439
2439
|
type: "file",
|
|
2440
2440
|
overwrite: true
|
|
2441
|
+
},
|
|
2442
|
+
// 9. 确保 tsconfig.app.json 排除 shared/static 目录(避免 TSC 严格校验 JSON 导致编译失败)
|
|
2443
|
+
{
|
|
2444
|
+
type: "ensure-json-array-item",
|
|
2445
|
+
to: "tsconfig.app.json",
|
|
2446
|
+
jsonPath: "exclude",
|
|
2447
|
+
items: ["shared/static"]
|
|
2441
2448
|
}
|
|
2442
2449
|
],
|
|
2443
2450
|
// 文件权限设置
|
|
@@ -2692,6 +2699,11 @@ async function syncRule(rule, pluginRoot, userProjectRoot) {
|
|
|
2692
2699
|
mergeJsonFile(srcPath2, destPath2, rule.arrayMerge);
|
|
2693
2700
|
return;
|
|
2694
2701
|
}
|
|
2702
|
+
if (rule.type === "ensure-json-array-item") {
|
|
2703
|
+
const destPath2 = path5.join(userProjectRoot, rule.to);
|
|
2704
|
+
ensureJsonArrayItem(destPath2, rule.jsonPath, rule.items);
|
|
2705
|
+
return;
|
|
2706
|
+
}
|
|
2695
2707
|
if (!("from" in rule)) {
|
|
2696
2708
|
return;
|
|
2697
2709
|
}
|
|
@@ -2834,6 +2846,41 @@ function addLineToFile(filePath, line) {
|
|
|
2834
2846
|
fs7.appendFileSync(filePath, appendContent);
|
|
2835
2847
|
console.log(`[fullstack-cli] \u2713 ${fileName} (added: ${line})`);
|
|
2836
2848
|
}
|
|
2849
|
+
function ensureJsonArrayItem(filePath, jsonPath, items) {
|
|
2850
|
+
const fileName = path5.basename(filePath);
|
|
2851
|
+
if (!fs7.existsSync(filePath)) {
|
|
2852
|
+
console.log(`[fullstack-cli] \u25CB ${fileName} (not found, skipped)`);
|
|
2853
|
+
return;
|
|
2854
|
+
}
|
|
2855
|
+
const content = JSON.parse(fs7.readFileSync(filePath, "utf-8"));
|
|
2856
|
+
const parts = jsonPath.split(".");
|
|
2857
|
+
let current = content;
|
|
2858
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
2859
|
+
const part = parts[i];
|
|
2860
|
+
if (current[part] == null || typeof current[part] !== "object") {
|
|
2861
|
+
current[part] = {};
|
|
2862
|
+
}
|
|
2863
|
+
current = current[part];
|
|
2864
|
+
}
|
|
2865
|
+
const lastKey = parts[parts.length - 1];
|
|
2866
|
+
if (!Array.isArray(current[lastKey])) {
|
|
2867
|
+
current[lastKey] = [];
|
|
2868
|
+
}
|
|
2869
|
+
const arr = current[lastKey];
|
|
2870
|
+
const added = [];
|
|
2871
|
+
for (const item of items) {
|
|
2872
|
+
if (!arr.includes(item)) {
|
|
2873
|
+
arr.push(item);
|
|
2874
|
+
added.push(item);
|
|
2875
|
+
}
|
|
2876
|
+
}
|
|
2877
|
+
if (added.length === 0) {
|
|
2878
|
+
console.log(`[fullstack-cli] \u25CB ${fileName} ${jsonPath} (already contains all items)`);
|
|
2879
|
+
return;
|
|
2880
|
+
}
|
|
2881
|
+
fs7.writeFileSync(filePath, JSON.stringify(content, null, 2) + "\n");
|
|
2882
|
+
console.log(`[fullstack-cli] \u2713 ${fileName} ${jsonPath} (added: ${added.join(", ")})`);
|
|
2883
|
+
}
|
|
2837
2884
|
function mergeJsonFile(src, dest, arrayMerge) {
|
|
2838
2885
|
const fileName = path5.basename(dest);
|
|
2839
2886
|
if (!fs7.existsSync(src)) {
|