aiteam-x 0.14.6 → 0.14.9
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 +1 -1
- package/scripts/cli.mjs +34 -3
package/package.json
CHANGED
package/scripts/cli.mjs
CHANGED
|
@@ -65,6 +65,31 @@ function mergePackageJson(templatePath, targetPath) {
|
|
|
65
65
|
console.log(C.dim(" package.json mesclado (deps + scripts adicionados)"));
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
function isPlainObject(v) {
|
|
69
|
+
return v !== null && typeof v === "object" && !Array.isArray(v);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Preenche chaves e sub-objetos em falta a partir do template (preserva strings do projeto). */
|
|
73
|
+
function deepMergeMessages(target, template) {
|
|
74
|
+
const out = { ...target };
|
|
75
|
+
for (const key of Object.keys(template)) {
|
|
76
|
+
if (!(key in out)) {
|
|
77
|
+
out[key] = template[key];
|
|
78
|
+
} else if (isPlainObject(out[key]) && isPlainObject(template[key])) {
|
|
79
|
+
out[key] = deepMergeMessages(out[key], template[key]);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return out;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function mergeMessagesJson(templatePath, targetPath) {
|
|
86
|
+
const tpl = JSON.parse(fs.readFileSync(templatePath, "utf-8"));
|
|
87
|
+
const cur = JSON.parse(fs.readFileSync(targetPath, "utf-8"));
|
|
88
|
+
const merged = deepMergeMessages(cur, tpl);
|
|
89
|
+
fs.writeFileSync(targetPath, JSON.stringify(merged, null, 2) + "\n", "utf-8");
|
|
90
|
+
console.log(C.dim(` messages/${path.basename(targetPath)} mesclado (namespaces AITEAM-X)`));
|
|
91
|
+
}
|
|
92
|
+
|
|
68
93
|
const ALWAYS_UPDATE_DIRS = new Set(["lib", "app", "scripts", "components"]);
|
|
69
94
|
|
|
70
95
|
function copyMerge(src, dest, forceOverwrite = false) {
|
|
@@ -88,6 +113,12 @@ function copyMerge(src, dest, forceOverwrite = false) {
|
|
|
88
113
|
} else if (entry.name === ".gitignore" && fs.existsSync(destPath)) {
|
|
89
114
|
fs.copyFileSync(srcPath, destPath);
|
|
90
115
|
console.log(C.dim(" .gitignore atualizado"));
|
|
116
|
+
} else if (
|
|
117
|
+
path.basename(path.dirname(srcPath)) === "messages" &&
|
|
118
|
+
entry.name.endsWith(".json") &&
|
|
119
|
+
fs.existsSync(destPath)
|
|
120
|
+
) {
|
|
121
|
+
mergeMessagesJson(srcPath, destPath);
|
|
91
122
|
} else if (forceOverwrite || !fs.existsSync(destPath)) {
|
|
92
123
|
fs.copyFileSync(srcPath, destPath);
|
|
93
124
|
}
|
|
@@ -212,11 +243,11 @@ async function main() {
|
|
|
212
243
|
console.log(C.bold(`${n + 1}. Abrindo wizard de configuração no navegador...`));
|
|
213
244
|
console.log(C.dim(" O setup será feito no browser. O servidor será iniciado automaticamente.\n"));
|
|
214
245
|
|
|
215
|
-
//
|
|
216
|
-
const
|
|
246
|
+
// node scripts/setup.mjs — evita spawn(npm) no Windows (EINVAL) e shell:true (DEP0190)
|
|
247
|
+
const setupScript = path.join(absTarget, "scripts", "setup.mjs");
|
|
248
|
+
const child = spawn(process.execPath, [setupScript], {
|
|
217
249
|
stdio: "inherit",
|
|
218
250
|
cwd: absTarget,
|
|
219
|
-
shell: true,
|
|
220
251
|
});
|
|
221
252
|
child.on("error", (err) => {
|
|
222
253
|
console.error(C.yellow("Erro ao iniciar setup:"), err.message);
|