@rainbow-robotics/muscat-plugin-kit 0.1.2-dev.17 → 0.1.2-dev.19
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/cli/src/update.mjs +29 -10
- package/package.json +1 -1
package/cli/src/update.mjs
CHANGED
|
@@ -90,7 +90,8 @@ async function updateBinary(tag) {
|
|
|
90
90
|
stdio: "ignore",
|
|
91
91
|
}).unref();
|
|
92
92
|
|
|
93
|
-
log.ok(`v${version}
|
|
93
|
+
log.ok(`v${version} installed. Run muscat-pk update again to complete.`);
|
|
94
|
+
process.exit(0);
|
|
94
95
|
} else {
|
|
95
96
|
// macOS / Linux: can replace the file while it's mapped into memory
|
|
96
97
|
const tmp = join(tmpdir(), `muscat-pk-${version}`);
|
|
@@ -113,9 +114,19 @@ function updateNpmGlobal(tag) {
|
|
|
113
114
|
|
|
114
115
|
function detectOldStructure(root) {
|
|
115
116
|
const issues = [];
|
|
116
|
-
|
|
117
|
-
|
|
117
|
+
|
|
118
|
+
// src/ exists (old UI dir) or vite.config references src/content.tsx
|
|
119
|
+
const hasSrcDir = existsSync(resolve(root, "src"));
|
|
120
|
+
const hasUiDir = existsSync(resolve(root, "ui"));
|
|
121
|
+
const viteRef = (() => {
|
|
122
|
+
try {
|
|
123
|
+
return readFileSync(resolve(root, "vite.config.ts"), "utf8").includes("src/content.tsx");
|
|
124
|
+
} catch { return false; }
|
|
125
|
+
})();
|
|
126
|
+
if ((hasSrcDir || viteRef) && !hasUiDir) {
|
|
127
|
+
issues.push({ kind: "src→ui", desc: "src/ → ui/ (+ vite.config.ts, tsconfig.json)" });
|
|
118
128
|
}
|
|
129
|
+
|
|
119
130
|
if (existsSync(resolve(root, "main.py")) && !existsSync(resolve(root, "py"))) {
|
|
120
131
|
issues.push({ kind: "main→py", desc: "main.py → py/main.py" });
|
|
121
132
|
}
|
|
@@ -145,8 +156,10 @@ async function migrateStructure(root, issues) {
|
|
|
145
156
|
|
|
146
157
|
for (const issue of issues) {
|
|
147
158
|
if (issue.kind === "src→ui") {
|
|
148
|
-
|
|
149
|
-
|
|
159
|
+
if (existsSync(resolve(root, "src"))) {
|
|
160
|
+
renameSync(resolve(root, "src"), resolve(root, "ui"));
|
|
161
|
+
log.ok("src/ → ui/");
|
|
162
|
+
}
|
|
150
163
|
|
|
151
164
|
const vitePath = resolve(root, "vite.config.ts");
|
|
152
165
|
if (existsSync(vitePath)) {
|
|
@@ -252,16 +265,22 @@ export async function runUpdate(args = []) {
|
|
|
252
265
|
}
|
|
253
266
|
|
|
254
267
|
// 2. Plugin project: structure migration + local deps
|
|
268
|
+
let root;
|
|
255
269
|
try {
|
|
256
|
-
|
|
270
|
+
root = findPluginRoot();
|
|
271
|
+
} catch {
|
|
272
|
+
// Not inside a plugin project — skip
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
257
275
|
|
|
276
|
+
try {
|
|
258
277
|
const structureIssues = detectOldStructure(root);
|
|
259
278
|
if (structureIssues.length > 0) {
|
|
260
279
|
await migrateStructure(root, structureIssues);
|
|
261
280
|
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
} catch {
|
|
265
|
-
// Not inside a plugin project — skip silently
|
|
281
|
+
} catch (err) {
|
|
282
|
+
log.warn(`Structure check failed: ${err.message}`);
|
|
266
283
|
}
|
|
284
|
+
|
|
285
|
+
updateLocalDeps(root, tag);
|
|
267
286
|
}
|