@rainbow-robotics/muscat-plugin-kit 0.1.2-dev.16 → 0.1.2-dev.18
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 +46 -10
- package/package.json +1 -1
package/cli/src/update.mjs
CHANGED
|
@@ -113,9 +113,19 @@ function updateNpmGlobal(tag) {
|
|
|
113
113
|
|
|
114
114
|
function detectOldStructure(root) {
|
|
115
115
|
const issues = [];
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
|
|
117
|
+
// src/ exists (old UI dir) or vite.config references src/content.tsx
|
|
118
|
+
const hasSrcDir = existsSync(resolve(root, "src"));
|
|
119
|
+
const hasUiDir = existsSync(resolve(root, "ui"));
|
|
120
|
+
const viteRef = (() => {
|
|
121
|
+
try {
|
|
122
|
+
return readFileSync(resolve(root, "vite.config.ts"), "utf8").includes("src/content.tsx");
|
|
123
|
+
} catch { return false; }
|
|
124
|
+
})();
|
|
125
|
+
if ((hasSrcDir || viteRef) && !hasUiDir) {
|
|
126
|
+
issues.push({ kind: "src→ui", desc: "src/ → ui/ (+ vite.config.ts, tsconfig.json)" });
|
|
118
127
|
}
|
|
128
|
+
|
|
119
129
|
if (existsSync(resolve(root, "main.py")) && !existsSync(resolve(root, "py"))) {
|
|
120
130
|
issues.push({ kind: "main→py", desc: "main.py → py/main.py" });
|
|
121
131
|
}
|
|
@@ -145,8 +155,10 @@ async function migrateStructure(root, issues) {
|
|
|
145
155
|
|
|
146
156
|
for (const issue of issues) {
|
|
147
157
|
if (issue.kind === "src→ui") {
|
|
148
|
-
|
|
149
|
-
|
|
158
|
+
if (existsSync(resolve(root, "src"))) {
|
|
159
|
+
renameSync(resolve(root, "src"), resolve(root, "ui"));
|
|
160
|
+
log.ok("src/ → ui/");
|
|
161
|
+
}
|
|
150
162
|
|
|
151
163
|
const vitePath = resolve(root, "vite.config.ts");
|
|
152
164
|
if (existsSync(vitePath)) {
|
|
@@ -202,9 +214,27 @@ function updateLocalDeps(root, tag) {
|
|
|
202
214
|
|
|
203
215
|
// ── main ─────────────────────────────────────────────────────────────────────
|
|
204
216
|
|
|
217
|
+
async function resolveTag(explicitTag) {
|
|
218
|
+
if (explicitTag) return explicitTag;
|
|
219
|
+
|
|
220
|
+
const current = kitVersion();
|
|
221
|
+
const isDevVersion = current.includes("-dev.");
|
|
222
|
+
|
|
223
|
+
if (!isDevVersion) return "latest";
|
|
224
|
+
|
|
225
|
+
const answer = await prompt(
|
|
226
|
+
`You are on a dev version (v${current}).\n` +
|
|
227
|
+
` [1] Stay on dev — update to latest dev build\n` +
|
|
228
|
+
` [2] Switch to stable — update to latest stable release\n` +
|
|
229
|
+
`Choice [1/2, default: 1]: `
|
|
230
|
+
);
|
|
231
|
+
return answer.trim() === "2" ? "latest" : "dev";
|
|
232
|
+
}
|
|
233
|
+
|
|
205
234
|
export async function runUpdate(args = []) {
|
|
206
235
|
const opts = parseArgs(args);
|
|
207
|
-
const
|
|
236
|
+
const explicitTag = opts._[0] || opts.version || opts.tag || "";
|
|
237
|
+
const tag = await resolveTag(explicitTag);
|
|
208
238
|
|
|
209
239
|
// 1. Update the CLI itself
|
|
210
240
|
if (isBinaryMode) {
|
|
@@ -234,16 +264,22 @@ export async function runUpdate(args = []) {
|
|
|
234
264
|
}
|
|
235
265
|
|
|
236
266
|
// 2. Plugin project: structure migration + local deps
|
|
267
|
+
let root;
|
|
237
268
|
try {
|
|
238
|
-
|
|
269
|
+
root = findPluginRoot();
|
|
270
|
+
} catch {
|
|
271
|
+
// Not inside a plugin project — skip
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
239
274
|
|
|
275
|
+
try {
|
|
240
276
|
const structureIssues = detectOldStructure(root);
|
|
241
277
|
if (structureIssues.length > 0) {
|
|
242
278
|
await migrateStructure(root, structureIssues);
|
|
243
279
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
} catch {
|
|
247
|
-
// Not inside a plugin project — skip silently
|
|
280
|
+
} catch (err) {
|
|
281
|
+
log.warn(`Structure check failed: ${err.message}`);
|
|
248
282
|
}
|
|
283
|
+
|
|
284
|
+
updateLocalDeps(root, tag);
|
|
249
285
|
}
|