@cmo-so/cli 0.12.3 → 0.12.4
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/cmo.mjs +81 -1
- package/package.json +1 -1
package/dist/cmo.mjs
CHANGED
|
@@ -17265,6 +17265,81 @@ var childTools = [
|
|
|
17265
17265
|
})
|
|
17266
17266
|
})
|
|
17267
17267
|
];
|
|
17268
|
+
var themeTools = [
|
|
17269
|
+
tool({
|
|
17270
|
+
name: "wp_theme_updates",
|
|
17271
|
+
description: "Is there a newer Maggie Core for this site? The installed and latest versions, release notes link, whether this host lets it update itself, auto-updates on or off, and the earlier versions kept for rollback.",
|
|
17272
|
+
parameters: { type: "object", properties: {} },
|
|
17273
|
+
group: "site",
|
|
17274
|
+
need: READ,
|
|
17275
|
+
risk: "R0",
|
|
17276
|
+
gates: ["WP"],
|
|
17277
|
+
run: (ctx) => call(siteOf(ctx), { path: "/maggie-core/v1/update", query: { fresh: 1 } })
|
|
17278
|
+
}),
|
|
17279
|
+
tool({
|
|
17280
|
+
name: "wp_theme_update",
|
|
17281
|
+
description: "Update Maggie Core on the site to the latest version (checked against its published checksum; the current version is kept for rollback), then compare the homepage before and after (words, fonts, brand colours). If the site breaks (an error page or most of the homepage gone) it rolls back by itself. rollback_to puts an earlier kept version back instead. The site's look lives in the database and its child theme, so an update doesn't change it.",
|
|
17282
|
+
parameters: {
|
|
17283
|
+
type: "object",
|
|
17284
|
+
properties: { rollback_to: str2("Put this kept version back instead (from wp_theme_updates backups).") }
|
|
17285
|
+
},
|
|
17286
|
+
group: "site",
|
|
17287
|
+
need: WRITE,
|
|
17288
|
+
risk: "W3",
|
|
17289
|
+
gates: [...GATES],
|
|
17290
|
+
confirm: (a, lang) => a.rollback_to ? say(
|
|
17291
|
+
lang,
|
|
17292
|
+
`Put Maggie Core ${String(a.rollback_to)} back on your website.`,
|
|
17293
|
+
`\u628A\u7DB2\u7AD9\u7684 Maggie Core \u9084\u539F\u5230 ${String(a.rollback_to)}\u3002`
|
|
17294
|
+
) : say(
|
|
17295
|
+
lang,
|
|
17296
|
+
"Update Maggie Core on your website to the latest version (rolled back by itself if the site breaks).",
|
|
17297
|
+
"\u628A\u7DB2\u7AD9\u7684 Maggie Core \u66F4\u65B0\u5230\u6700\u65B0\u7248\u672C\uFF08\u7DB2\u7AD9\u51FA\u932F\u6703\u81EA\u52D5\u9084\u539F\uFF09\u3002"
|
|
17298
|
+
),
|
|
17299
|
+
run: async (ctx, a) => {
|
|
17300
|
+
const site = siteOf(ctx);
|
|
17301
|
+
const before = await homeShape(site);
|
|
17302
|
+
if (a.rollback_to) {
|
|
17303
|
+
const r2 = await call(site, {
|
|
17304
|
+
method: "POST",
|
|
17305
|
+
path: "/maggie-core/v1/update/rollback",
|
|
17306
|
+
body: { version: a.rollback_to }
|
|
17307
|
+
});
|
|
17308
|
+
return { ...r2, check: compareShapes(before, await homeShape(site)) };
|
|
17309
|
+
}
|
|
17310
|
+
const info = await call(site, { path: "/maggie-core/v1/update", query: { fresh: 1 } });
|
|
17311
|
+
if (!info.available)
|
|
17312
|
+
return {
|
|
17313
|
+
updated: false,
|
|
17314
|
+
current: info.current,
|
|
17315
|
+
latest: info.latest,
|
|
17316
|
+
note: info.check_error ?? "Already the latest Maggie Core."
|
|
17317
|
+
};
|
|
17318
|
+
if (!info.can_update)
|
|
17319
|
+
throw new Error(info.update_issue ?? "This host doesn't let WordPress update themes itself.");
|
|
17320
|
+
const r = await call(site, {
|
|
17321
|
+
method: "POST",
|
|
17322
|
+
path: "/maggie-core/v1/update"
|
|
17323
|
+
});
|
|
17324
|
+
const check2 = compareShapes(before, await homeShape(site));
|
|
17325
|
+
const broken = check2.checked && (check2.problems.some((p) => p.startsWith("the homepage answers")) || (check2.same_text_percent ?? 100) < 60);
|
|
17326
|
+
if (broken) {
|
|
17327
|
+
const back = await call(site, {
|
|
17328
|
+
method: "POST",
|
|
17329
|
+
path: "/maggie-core/v1/update/rollback",
|
|
17330
|
+
body: { version: r.before }
|
|
17331
|
+
}).catch((e) => ({ error: e.message }));
|
|
17332
|
+
return {
|
|
17333
|
+
...r,
|
|
17334
|
+
check: check2,
|
|
17335
|
+
rolled_back: back,
|
|
17336
|
+
note: `The homepage looked broken after the update, so Maggie Core ${r.before} was put back.`
|
|
17337
|
+
};
|
|
17338
|
+
}
|
|
17339
|
+
return { ...r, check: check2, notes: info.notes, undo: `wp_theme_update rollback_to ${r.before}` };
|
|
17340
|
+
}
|
|
17341
|
+
})
|
|
17342
|
+
];
|
|
17268
17343
|
function deepMerge(a, b) {
|
|
17269
17344
|
const out = { ...a };
|
|
17270
17345
|
for (const [k, v] of Object.entries(b)) {
|
|
@@ -17534,6 +17609,7 @@ var wordpressTools = [
|
|
|
17534
17609
|
...sectionTools,
|
|
17535
17610
|
...mediaTools,
|
|
17536
17611
|
...childTools,
|
|
17612
|
+
...themeTools,
|
|
17537
17613
|
...seoTools,
|
|
17538
17614
|
...elementTools
|
|
17539
17615
|
];
|
|
@@ -20946,7 +21022,7 @@ var program = new Command();
|
|
|
20946
21022
|
// package.json
|
|
20947
21023
|
var package_default = {
|
|
20948
21024
|
name: "@cmo-so/cli",
|
|
20949
|
-
version: "0.12.
|
|
21025
|
+
version: "0.12.4",
|
|
20950
21026
|
description: "CMO.so on the command line: your websites, ideas, blog posts, LinkedIn queue and results, plus a local MCP server for Claude Desktop, Cursor and other MCP clients.",
|
|
20951
21027
|
type: "module",
|
|
20952
21028
|
license: "MIT",
|
|
@@ -32095,6 +32171,10 @@ ${table(r.issues, ["severity", "code", "path", "detail"])}`;
|
|
|
32095
32171
|
}
|
|
32096
32172
|
})
|
|
32097
32173
|
);
|
|
32174
|
+
const theme = wp.command("theme").description("Maggie Core updates");
|
|
32175
|
+
theme.command("status", { isDefault: true }).description("installed and latest version, rollback versions").action((_o, c) => run(g(c), "wp_theme_updates", {}));
|
|
32176
|
+
theme.command("update").description("update to the latest (homepage checked; rolled back by itself if it breaks)").action((_o, c) => run(g(c), "wp_theme_update", {}));
|
|
32177
|
+
theme.command("rollback <version>").description("put a kept earlier version back").action((version2, _o, c) => run(g(c), "wp_theme_update", { rollback_to: version2 }));
|
|
32098
32178
|
const child = wp.command("child").description("the site's Maggie child theme, on the site itself (data files only, backups kept)");
|
|
32099
32179
|
child.command("status [slug]", { isDefault: true }).description("child themes, their files and backups; with a slug, its files in full").action((slug, _o, c) => run(g(c), "wp_child_theme_status", { slug }));
|
|
32100
32180
|
child.command("create <slug>").description("create maggie-<name> from the site's current look").requiredOption("--name <name>").option("--empty", "start empty instead of from the site").option("--activate", "switch the site to it (checks the homepage looks the same)").action(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cmo-so/cli",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.4",
|
|
4
4
|
"description": "CMO.so on the command line: your websites, ideas, blog posts, LinkedIn queue and results, plus a local MCP server for Claude Desktop, Cursor and other MCP clients.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|