@cmo-so/cli 0.12.9 → 0.12.10
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 +28 -5
- package/package.json +1 -1
package/dist/cmo.mjs
CHANGED
|
@@ -17360,7 +17360,7 @@ var childTools = [
|
|
|
17360
17360
|
}),
|
|
17361
17361
|
tool({
|
|
17362
17362
|
name: "wp_child_theme_update",
|
|
17363
|
-
description: "Change a Maggie child theme's files (default: the active child): brand colours (by name, hex) and fonts (by name, CSS font-family of fonts already in it) in theme.json, extra theme.json styles, plain CSS (replace or append), the header or footer (block markup), templates, and the site's own patterns (shown in the editor's inserter).
|
|
17363
|
+
description: "Change a Maggie child theme's files (default: the active child): brand colours (by name, hex) and fonts (by name, CSS font-family of fonts already in it) in theme.json, extra theme.json styles, plain CSS (replace or append), the site's own JavaScript (assets/js/site.js, replace or append; runs for every visitor), the header or footer (block markup), templates, and the site's own patterns (shown in the editor's inserter). No PHP or server code. Each change keeps a backup (wp_child_theme_restore). Changes made with wp_style_set / wp_header_set are stored in the database and win over the child's files.",
|
|
17364
17364
|
parameters: {
|
|
17365
17365
|
type: "object",
|
|
17366
17366
|
properties: {
|
|
@@ -17381,6 +17381,10 @@ var childTools = [
|
|
|
17381
17381
|
styles: obj('theme.json styles to merge in (e.g. { "elements": { "button": { \u2026 } } }).'),
|
|
17382
17382
|
css: str2("Replace the child's CSS (plain CSS)."),
|
|
17383
17383
|
css_append: str2("Add CSS at the end."),
|
|
17384
|
+
js: str2(
|
|
17385
|
+
`Replace the site's own script (assets/js/site.js, plain JavaScript loaded deferred on every page; "" turns it off). Needs Maggie Core 0.12+ and a login allowed to add scripts. No eval or new Function; addresses only on the site or cdn.jsdelivr.net, unpkg.com, cdnjs.cloudflare.com.`
|
|
17386
|
+
),
|
|
17387
|
+
js_append: str2("Add JavaScript at the end of the site's script."),
|
|
17384
17388
|
header: str2("Header block markup (parts/header.html)."),
|
|
17385
17389
|
footer: str2("Footer block markup (parts/footer.html)."),
|
|
17386
17390
|
templates: obj('Templates by slug \u2192 block markup, e.g. { "page-landing": "\u2026" }.'),
|
|
@@ -17394,8 +17398,8 @@ var childTools = [
|
|
|
17394
17398
|
gates: [...GATES],
|
|
17395
17399
|
confirm: (a, lang) => say(
|
|
17396
17400
|
lang,
|
|
17397
|
-
`Change the child theme ${q2(a.slug, "(the active one)")} on your website
|
|
17398
|
-
`\u4FEE\u6539\u7DB2\u7AD9\u7684\u5B50\u4E3B\u984C ${q2(a.slug, "\uFF08\u76EE\u524D\u4F7F\u7528\u4E2D\u7684\uFF09")}\u3002`
|
|
17401
|
+
`Change the child theme ${q2(a.slug, "(the active one)")} on your website.${typeof a.js === "string" || typeof a.js_append === "string" ? a.js === "" ? " Turns off the site's own script." : " Includes JavaScript that runs in every visitor's browser on every page." : ""}`,
|
|
17402
|
+
`\u4FEE\u6539\u7DB2\u7AD9\u7684\u5B50\u4E3B\u984C ${q2(a.slug, "\uFF08\u76EE\u524D\u4F7F\u7528\u4E2D\u7684\uFF09")}\u3002${typeof a.js === "string" || typeof a.js_append === "string" ? a.js === "" ? "\u95DC\u9589\u7DB2\u7AD9\u81EA\u8A02\u8173\u672C\u3002" : "\u5305\u542B\u6703\u5728\u6BCF\u4F4D\u8A2A\u5BA2\u700F\u89BD\u5668\u3001\u6BCF\u500B\u9801\u9762\u57F7\u884C\u7684 JavaScript\u3002" : ""}`
|
|
17399
17403
|
),
|
|
17400
17404
|
run: async (ctx, a) => {
|
|
17401
17405
|
const site = siteOf(ctx);
|
|
@@ -17493,6 +17497,22 @@ var childTools = [
|
|
|
17493
17497
|
if (typeof a.css_append === "string")
|
|
17494
17498
|
files["style.css"] = `${(files["style.css"] ?? cur["style.css"] ?? "").replace(/\n*$/, "\n")}${a.css_append}
|
|
17495
17499
|
`;
|
|
17500
|
+
if (typeof a.js === "string" || typeof a.js_append === "string") {
|
|
17501
|
+
const parentV = String(info.parent?.version ?? "0");
|
|
17502
|
+
const [maj, min] = parentV.split(".").map(Number);
|
|
17503
|
+
if ((maj ?? 0) === 0 && (min ?? 0) < 12)
|
|
17504
|
+
throw new Error(
|
|
17505
|
+
`The site's script needs Maggie Core 0.12 or later (the site has ${parentV}): update it with wp_theme_update first.`
|
|
17506
|
+
);
|
|
17507
|
+
const js = typeof a.js === "string" ? a.js : `${(cur["assets/js/site.js"] ?? "").replace(/\n*$/, "\n")}${String(a.js_append)}
|
|
17508
|
+
`.trimStart();
|
|
17509
|
+
if (/<\/?script\b/i.test(js)) throw new Error("js: plain JavaScript only, no <script> tags.");
|
|
17510
|
+
if (/<\?(php|=)?/i.test(js)) throw new Error("js: PHP isn't allowed.");
|
|
17511
|
+
files["assets/js/site.js"] = js;
|
|
17512
|
+
notes.push(
|
|
17513
|
+
js.trim() ? "assets/js/site.js runs deferred on every page; undo with wp_child_theme_restore." : "The site's own script is off."
|
|
17514
|
+
);
|
|
17515
|
+
}
|
|
17496
17516
|
const markup = (path3, m) => {
|
|
17497
17517
|
if (typeof m !== "string" || !m.trim()) return;
|
|
17498
17518
|
if (!parse(m).some((b) => b.name)) throw new Error(`${path3}: give block markup (<!-- wp:\u2026 -->).`);
|
|
@@ -21908,7 +21928,7 @@ var program = new Command();
|
|
|
21908
21928
|
// package.json
|
|
21909
21929
|
var package_default = {
|
|
21910
21930
|
name: "@cmo-so/cli",
|
|
21911
|
-
version: "0.12.
|
|
21931
|
+
version: "0.12.10",
|
|
21912
21932
|
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.",
|
|
21913
21933
|
type: "module",
|
|
21914
21934
|
license: "MIT",
|
|
@@ -33156,12 +33176,15 @@ ${table(r.issues, ["severity", "code", "path", "detail"])}`;
|
|
|
33156
33176
|
).option(
|
|
33157
33177
|
"--from <file>",
|
|
33158
33178
|
"JSON: { colors, fonts, styles, css, css_append, header, footer, templates, patterns, remove_patterns }"
|
|
33159
|
-
).option("--color <slug=hex...>").option("--css-file <file>", "replace the CSS with this file").option("--header-file <file>", "header block markup").option("--footer-file <file>", "footer block markup").action(
|
|
33179
|
+
).option("--color <slug=hex...>").option("--css-file <file>", "replace the CSS with this file").option("--js-file <file>", "replace the site's script (assets/js/site.js, runs on every page) with this file").option("--js-append <file>", "add this JavaScript file at the end of the site's script").option("--js-off", "turn the site's script off").option("--header-file <file>", "header block markup").option("--footer-file <file>", "footer block markup").action(
|
|
33160
33180
|
async (slug, o, c) => {
|
|
33161
33181
|
const args = o.from ? await json(o.from) : {};
|
|
33162
33182
|
if (slug) args.slug = slug;
|
|
33163
33183
|
if (o.color) args.colors = Object.fromEntries(pairs(o.color));
|
|
33164
33184
|
if (o.cssFile) args.css = await readFile2(o.cssFile, "utf8");
|
|
33185
|
+
if (o.jsFile) args.js = await readFile2(o.jsFile, "utf8");
|
|
33186
|
+
if (o.jsAppend) args.js_append = await readFile2(o.jsAppend, "utf8");
|
|
33187
|
+
if (o.jsOff) args.js = "";
|
|
33165
33188
|
if (o.headerFile) args.header = await readFile2(o.headerFile, "utf8");
|
|
33166
33189
|
if (o.footerFile) args.footer = await readFile2(o.footerFile, "utf8");
|
|
33167
33190
|
await run(g(c), "wp_child_theme_update", args);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cmo-so/cli",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.10",
|
|
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",
|