@ikas/component-cli 2.3.0 → 2.4.0
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/commands/add-sections-to-page.d.ts +3 -0
- package/dist/commands/add-sections-to-page.d.ts.map +1 -0
- package/dist/commands/add-sections-to-page.js +39 -0
- package/dist/commands/add-sections-to-page.js.map +1 -0
- package/dist/commands/build.d.ts.map +1 -1
- package/dist/commands/build.js +5 -165
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/create-design-tokens.d.ts +7 -0
- package/dist/commands/create-design-tokens.d.ts.map +1 -0
- package/dist/commands/create-design-tokens.js +127 -0
- package/dist/commands/create-design-tokens.js.map +1 -0
- package/dist/commands/create-global-variable.d.ts +3 -0
- package/dist/commands/create-global-variable.d.ts.map +1 -0
- package/dist/commands/create-global-variable.js +53 -0
- package/dist/commands/create-global-variable.js.map +1 -0
- package/dist/commands/create-page.d.ts +3 -0
- package/dist/commands/create-page.d.ts.map +1 -0
- package/dist/commands/create-page.js +31 -0
- package/dist/commands/create-page.js.map +1 -0
- package/dist/commands/delete-theme-globals.d.ts +4 -0
- package/dist/commands/delete-theme-globals.d.ts.map +1 -0
- package/dist/commands/delete-theme-globals.js +48 -0
- package/dist/commands/delete-theme-globals.js.map +1 -0
- package/dist/commands/get-component-props.d.ts +3 -0
- package/dist/commands/get-component-props.d.ts.map +1 -0
- package/dist/commands/get-component-props.js +32 -0
- package/dist/commands/get-component-props.js.map +1 -0
- package/dist/commands/get-page-by-type.d.ts +3 -0
- package/dist/commands/get-page-by-type.d.ts.map +1 -0
- package/dist/commands/get-page-by-type.js +25 -0
- package/dist/commands/get-page-by-type.js.map +1 -0
- package/dist/commands/get-section-values.d.ts +3 -0
- package/dist/commands/get-section-values.d.ts.map +1 -0
- package/dist/commands/get-section-values.js +39 -0
- package/dist/commands/get-section-values.js.map +1 -0
- package/dist/commands/list-entities.d.ts +3 -0
- package/dist/commands/list-entities.d.ts.map +1 -0
- package/dist/commands/list-entities.js +32 -0
- package/dist/commands/list-entities.js.map +1 -0
- package/dist/commands/list-page-sections.d.ts +3 -0
- package/dist/commands/list-page-sections.d.ts.map +1 -0
- package/dist/commands/list-page-sections.js +25 -0
- package/dist/commands/list-page-sections.js.map +1 -0
- package/dist/commands/list-theme-globals.d.ts +3 -0
- package/dist/commands/list-theme-globals.d.ts.map +1 -0
- package/dist/commands/list-theme-globals.js +22 -0
- package/dist/commands/list-theme-globals.js.map +1 -0
- package/dist/commands/publish-theme.d.ts +3 -0
- package/dist/commands/publish-theme.d.ts.map +1 -0
- package/dist/commands/publish-theme.js +29 -0
- package/dist/commands/publish-theme.js.map +1 -0
- package/dist/commands/search-products.d.ts +3 -0
- package/dist/commands/search-products.d.ts.map +1 -0
- package/dist/commands/search-products.js +40 -0
- package/dist/commands/search-products.js.map +1 -0
- package/dist/commands/update-global-variable.d.ts +3 -0
- package/dist/commands/update-global-variable.d.ts.map +1 -0
- package/dist/commands/update-global-variable.js +47 -0
- package/dist/commands/update-global-variable.js.map +1 -0
- package/dist/commands/update-page-sections.d.ts +3 -0
- package/dist/commands/update-page-sections.d.ts.map +1 -0
- package/dist/commands/update-page-sections.js +39 -0
- package/dist/commands/update-page-sections.js.map +1 -0
- package/dist/commands/update-section-prop.d.ts +3 -0
- package/dist/commands/update-section-prop.d.ts.map +1 -0
- package/dist/commands/update-section-prop.js +59 -0
- package/dist/commands/update-section-prop.js.map +1 -0
- package/dist/commands/upload-image.d.ts +3 -0
- package/dist/commands/upload-image.d.ts.map +1 -0
- package/dist/commands/upload-image.js +38 -0
- package/dist/commands/upload-image.js.map +1 -0
- package/dist/commands/upload-images.d.ts +3 -0
- package/dist/commands/upload-images.d.ts.map +1 -0
- package/dist/commands/upload-images.js +48 -0
- package/dist/commands/upload-images.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/compile.d.ts +4 -1
- package/dist/utils/compile.d.ts.map +1 -1
- package/dist/utils/compile.js +517 -48
- package/dist/utils/compile.js.map +1 -1
- package/dist/utils/component-helpers.d.ts +1 -1
- package/dist/utils/component-helpers.d.ts.map +1 -1
- package/dist/utils/component-helpers.js +4 -0
- package/dist/utils/component-helpers.js.map +1 -1
- package/dist/utils/editor-action-client.d.ts +1 -1
- package/dist/utils/editor-action-client.d.ts.map +1 -1
- package/dist/utils/editor-action-client.js +23 -8
- package/dist/utils/editor-action-client.js.map +1 -1
- package/dist/utils/load-image.d.ts +16 -0
- package/dist/utils/load-image.d.ts.map +1 -0
- package/dist/utils/load-image.js +50 -0
- package/dist/utils/load-image.js.map +1 -0
- package/dist/utils/websocket-server.d.ts +2 -2
- package/dist/utils/websocket-server.d.ts.map +1 -1
- package/dist/utils/websocket-server.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { printErrorAndExit, printResultAndExit, runEditorAction, } from "../utils/editor-action-client.js";
|
|
3
|
+
async function runGetComponentProps(options) {
|
|
4
|
+
const componentIds = options.componentIds
|
|
5
|
+
? options.componentIds
|
|
6
|
+
.split(",")
|
|
7
|
+
.map(s => s.trim())
|
|
8
|
+
.filter(Boolean)
|
|
9
|
+
: undefined;
|
|
10
|
+
if (!componentIds?.length && !options.componentId) {
|
|
11
|
+
printErrorAndExit(new Error("--component-id or --component-ids is required"));
|
|
12
|
+
}
|
|
13
|
+
const port = options.port ? parseInt(options.port, 10) : undefined;
|
|
14
|
+
try {
|
|
15
|
+
const result = await runEditorAction("get-component-props", componentIds?.length ? { componentIds } : { componentId: options.componentId }, port ? { port } : {});
|
|
16
|
+
printResultAndExit(result);
|
|
17
|
+
}
|
|
18
|
+
catch (e) {
|
|
19
|
+
printErrorAndExit(e);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export function createGetComponentPropsCommand() {
|
|
23
|
+
const cmd = new Command("get-component-props");
|
|
24
|
+
cmd
|
|
25
|
+
.description("Get prop blueprints from the editor (the source of truth) for one or many components: each prop's id, name, type, required, default, ENUM `options` (valid values), and for COMPONENT/COMPONENT_LIST the `allowedComponentIds` (which children it permits). Works for any section OR child code component id — use it to learn a COMPONENT_LIST child's props and valid enum values instead of grepping ikas.config.json. Returns { components: [...] }.")
|
|
26
|
+
.option("--component-id <id>", "A single code component id (section or child) — or a section id")
|
|
27
|
+
.option("--component-ids <ids>", "Comma-separated component ids (batch — resolve many schemas in one call)")
|
|
28
|
+
.option("--port <port>", "Dev server WebSocket port", "5201")
|
|
29
|
+
.action(runGetComponentProps);
|
|
30
|
+
return cmd;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=get-component-props.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-component-props.js","sourceRoot":"","sources":["../../src/commands/get-component-props.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,GAChB,MAAM,kCAAkC,CAAC;AAQ1C,KAAK,UAAU,oBAAoB,CAAC,OAAiC;IACnE,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY;QACvC,CAAC,CAAC,OAAO,CAAC,YAAY;aACjB,KAAK,CAAC,GAAG,CAAC;aACV,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;aAClB,MAAM,CAAC,OAAO,CAAC;QACpB,CAAC,CAAC,SAAS,CAAC;IACd,IAAI,CAAC,YAAY,EAAE,MAAM,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;QAClD,iBAAiB,CAAC,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC,CAAC;IAChF,CAAC;IACD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACnE,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,eAAe,CAClC,qBAAqB,EACrB,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,EAC9E,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CACrB,CAAC;QACF,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,iBAAiB,CAAC,CAAC,CAAC,CAAC;IACvB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,8BAA8B;IAC5C,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAC/C,GAAG;SACA,WAAW,CACV,0bAA0b,CAC3b;SACA,MAAM,CAAC,qBAAqB,EAAE,iEAAiE,CAAC;SAChG,MAAM,CAAC,uBAAuB,EAAE,0EAA0E,CAAC;SAC3G,MAAM,CAAC,eAAe,EAAE,2BAA2B,EAAE,MAAM,CAAC;SAC5D,MAAM,CAAC,oBAAoB,CAAC,CAAC;IAChC,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-page-by-type.d.ts","sourceRoot":"","sources":["../../src/commands/get-page-by-type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA6BpC,wBAAgB,0BAA0B,IAAI,OAAO,CAUpD"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { printErrorAndExit, printResultAndExit, runEditorAction, } from "../utils/editor-action-client.js";
|
|
3
|
+
async function runGetPageByType(options) {
|
|
4
|
+
if (!options.pageType || typeof options.pageType !== "string") {
|
|
5
|
+
printErrorAndExit(new Error("--page-type is required (e.g. CATEGORY, PRODUCT, BRAND, BLOG, BLOG_CATEGORY, INDEX)"));
|
|
6
|
+
}
|
|
7
|
+
const port = options.port ? parseInt(options.port, 10) : undefined;
|
|
8
|
+
try {
|
|
9
|
+
const result = await runEditorAction("get-page-by-type", { pageType: options.pageType }, port ? { port } : {});
|
|
10
|
+
printResultAndExit(result);
|
|
11
|
+
}
|
|
12
|
+
catch (e) {
|
|
13
|
+
printErrorAndExit(e);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export function createGetPageByTypeCommand() {
|
|
17
|
+
const cmd = new Command("get-page-by-type");
|
|
18
|
+
cmd
|
|
19
|
+
.description("Resolve a theme page id from its pageType (CATEGORY, PRODUCT, BRAND, BLOG, BLOG_CATEGORY, INDEX, …). Use the returned pageId together with an entity id (from list-entities) to build a PAGE link to that entity. Returns pageId: null with a note if no page of that type exists yet.")
|
|
20
|
+
.requiredOption("--page-type <type>", "Page type to resolve (e.g. CATEGORY)")
|
|
21
|
+
.option("--port <port>", "Dev server WebSocket port", "5201")
|
|
22
|
+
.action(runGetPageByType);
|
|
23
|
+
return cmd;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=get-page-by-type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-page-by-type.js","sourceRoot":"","sources":["../../src/commands/get-page-by-type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,GAChB,MAAM,kCAAkC,CAAC;AAO1C,KAAK,UAAU,gBAAgB,CAAC,OAA6B;IAC3D,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,OAAO,OAAO,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAC9D,iBAAiB,CAAC,IAAI,KAAK,CAAC,qFAAqF,CAAC,CAAC,CAAC;IACtH,CAAC;IACD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACnE,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,eAAe,CAClC,kBAAkB,EAClB,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,EAC9B,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CACrB,CAAC;QACF,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,iBAAiB,CAAC,CAAC,CAAC,CAAC;IACvB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,0BAA0B;IACxC,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAC5C,GAAG;SACA,WAAW,CACV,wRAAwR,CACzR;SACA,cAAc,CAAC,oBAAoB,EAAE,sCAAsC,CAAC;SAC5E,MAAM,CAAC,eAAe,EAAE,2BAA2B,EAAE,MAAM,CAAC;SAC5D,MAAM,CAAC,gBAAgB,CAAC,CAAC;IAC5B,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-section-values.d.ts","sourceRoot":"","sources":["../../src/commands/get-section-values.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA2CpC,wBAAgB,6BAA6B,IAAI,OAAO,CAYvD"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { printErrorAndExit, printResultAndExit, runEditorAction, } from "../utils/editor-action-client.js";
|
|
3
|
+
async function runGetSectionValues(options) {
|
|
4
|
+
if (!options.pageId || typeof options.pageId !== "string") {
|
|
5
|
+
printErrorAndExit(new Error("--page-id is required (use `ikas-component list-pages`)"));
|
|
6
|
+
}
|
|
7
|
+
const elementIds = options.elementIds
|
|
8
|
+
? options.elementIds
|
|
9
|
+
.split(",")
|
|
10
|
+
.map(s => s.trim())
|
|
11
|
+
.filter(Boolean)
|
|
12
|
+
: undefined;
|
|
13
|
+
if (!elementIds?.length && !options.elementId) {
|
|
14
|
+
printErrorAndExit(new Error("--element-id or --element-ids is required (use `ikas-component list-page-sections`)"));
|
|
15
|
+
}
|
|
16
|
+
const port = options.port ? parseInt(options.port, 10) : undefined;
|
|
17
|
+
try {
|
|
18
|
+
const result = await runEditorAction("get-section-values", {
|
|
19
|
+
pageId: options.pageId,
|
|
20
|
+
...(elementIds?.length ? { elementIds } : { elementId: options.elementId }),
|
|
21
|
+
}, port ? { port } : {});
|
|
22
|
+
printResultAndExit(result);
|
|
23
|
+
}
|
|
24
|
+
catch (e) {
|
|
25
|
+
printErrorAndExit(e);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export function createGetSectionValuesCommand() {
|
|
29
|
+
const cmd = new Command("get-section-values");
|
|
30
|
+
cmd
|
|
31
|
+
.description("Get the current prop values of placed section(s) (full propValues + blueprint props). Use for read-modify-write of a COMPONENT_LIST or to inspect an existing value's shape. `list-page-sections` is lean and omits values; this fetches them. Returns { sections: [...] }.")
|
|
32
|
+
.requiredOption("--page-id <id>", "Page id (from `ikas-component list-pages`)")
|
|
33
|
+
.option("--element-id <id>", "A single placed-section elementId (from `ikas-component list-page-sections`)")
|
|
34
|
+
.option("--element-ids <ids>", "Comma-separated elementIds (batch)")
|
|
35
|
+
.option("--port <port>", "Dev server WebSocket port", "5201")
|
|
36
|
+
.action(runGetSectionValues);
|
|
37
|
+
return cmd;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=get-section-values.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-section-values.js","sourceRoot":"","sources":["../../src/commands/get-section-values.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAA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C;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,iBAAiB,CAAC,CAAC,CAAC,CAAC;IACvB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,6BAA6B;IAC3C,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAC9C,GAAG;SACA,WAAW,CACV,6QAA6Q,CAC9Q;SACA,cAAc,CAAC,gBAAgB,EAAE,4CAA4C,CAAC;SAC9E,MAAM,CAAC,mBAAmB,EAAE,8EAA8E,CAAC;SAC3G,MAAM,CAAC,qBAAqB,EAAE,oCAAoC,CAAC;SACnE,MAAM,CAAC,eAAe,EAAE,2BAA2B,EAAE,MAAM,CAAC;SAC5D,MAAM,CAAC,mBAAmB,CAAC,CAAC;IAC/B,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-entities.d.ts","sourceRoot":"","sources":["../../src/commands/list-entities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAoCpC,wBAAgB,yBAAyB,IAAI,OAAO,CAWnD"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { printErrorAndExit, printResultAndExit, runEditorAction, } from "../utils/editor-action-client.js";
|
|
3
|
+
const VALID_KINDS = ["category", "brand", "blog", "blog-category"];
|
|
4
|
+
async function runListEntities(options) {
|
|
5
|
+
if (!options.kind || !VALID_KINDS.includes(options.kind)) {
|
|
6
|
+
printErrorAndExit(new Error(`--kind must be one of: ${VALID_KINDS.join(", ")}`));
|
|
7
|
+
}
|
|
8
|
+
const port = options.port ? parseInt(options.port, 10) : undefined;
|
|
9
|
+
try {
|
|
10
|
+
const result = await runEditorAction("list-entities", {
|
|
11
|
+
kind: options.kind,
|
|
12
|
+
...(options.query ? { query: options.query } : {}),
|
|
13
|
+
},
|
|
14
|
+
// The host fetches from the store API, so allow more than the default 10s.
|
|
15
|
+
{ ...(port ? { port } : {}), timeoutMs: 20_000 });
|
|
16
|
+
printResultAndExit(result);
|
|
17
|
+
}
|
|
18
|
+
catch (e) {
|
|
19
|
+
printErrorAndExit(e);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export function createListEntitiesCommand() {
|
|
23
|
+
const cmd = new Command("list-entities");
|
|
24
|
+
cmd
|
|
25
|
+
.description("List store entities (category, brand, blog, blog-category) and their ids, for filling the corresponding entity prop value via `ikas-component update-section-prop`. Requires the editor embedded in the ikas admin panel (the host runs the lookup). Note: category and brand return all entries (no query); blog and blog-category accept --query.")
|
|
26
|
+
.requiredOption("--kind <kind>", `Entity kind: ${VALID_KINDS.join(" | ")}`)
|
|
27
|
+
.option("--query <text>", "Free-text search (blog / blog-category only)")
|
|
28
|
+
.option("--port <port>", "Dev server WebSocket port", "5201")
|
|
29
|
+
.action(runListEntities);
|
|
30
|
+
return cmd;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=list-entities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-entities.js","sourceRoot":"","sources":["../../src/commands/list-entities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,GAChB,MAAM,kCAAkC,CAAC;AAE1C,MAAM,WAAW,GAAG,CAAC,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,eAAe,CAAC,CAAC;AAQnE,KAAK,UAAU,eAAe,CAAC,OAA4B;IACzD,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACzD,iBAAiB,CAAC,IAAI,KAAK,CAAC,0BAA0B,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IACnF,CAAC;IACD,MAAM,IAAI,GAAG,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OAAO,CAUvD"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { printErrorAndExit, printResultAndExit, runEditorAction, } from "../utils/editor-action-client.js";
|
|
3
|
+
async function runListPageSections(options) {
|
|
4
|
+
if (!options.pageId || typeof options.pageId !== "string") {
|
|
5
|
+
printErrorAndExit(new Error("--page-id is required (use `ikas-component list-pages` to discover ids)"));
|
|
6
|
+
}
|
|
7
|
+
const port = options.port ? parseInt(options.port, 10) : undefined;
|
|
8
|
+
try {
|
|
9
|
+
const result = await runEditorAction("list-page-sections", { pageId: options.pageId }, port ? { port } : {});
|
|
10
|
+
printResultAndExit(result);
|
|
11
|
+
}
|
|
12
|
+
catch (e) {
|
|
13
|
+
printErrorAndExit(e);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export function createListPageSectionsCommand() {
|
|
17
|
+
const cmd = new Command("list-page-sections");
|
|
18
|
+
cmd
|
|
19
|
+
.description("List the sections placed on a page, each with its per-placement elementId, sectionId, current prop values, and blueprint props. Use the elementId with `ikas-component update-section-prop`.")
|
|
20
|
+
.requiredOption("--page-id <id>", "Page id (from `ikas-component list-pages`)")
|
|
21
|
+
.option("--port <port>", "Dev server WebSocket port", "5201")
|
|
22
|
+
.action(runListPageSections);
|
|
23
|
+
return cmd;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=list-page-sections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-page-sections.js","sourceRoot":"","sources":["../../src/commands/list-page-sections.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,GAChB,MAAM,kCAAkC,CAAC;AAO1C,KAAK,UAAU,mBAAmB,CAAC,OAAgC;IACjE,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,OAAO,OAAO,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC1D,iBAAiB,CAAC,IAAI,KAAK,CAAC,yEAAyE,CAAC,CAAC,CAAC;IAC1G,CAAC;IACD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACnE,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,eAAe,CAClC,oBAAoB,EACpB,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,EAC1B,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CACrB,CAAC;QACF,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,iBAAiB,CAAC,CAAC,CAAC,CAAC;IACvB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,6BAA6B;IAC3C,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAC9C,GAAG;SACA,WAAW,CACV,8LAA8L,CAC/L;SACA,cAAc,CAAC,gBAAgB,EAAE,4CAA4C,CAAC;SAC9E,MAAM,CAAC,eAAe,EAAE,2BAA2B,EAAE,MAAM,CAAC;SAC5D,MAAM,CAAC,mBAAmB,CAAC,CAAC;IAC/B,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-theme-globals.d.ts","sourceRoot":"","sources":["../../src/commands/list-theme-globals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAkBpC,wBAAgB,6BAA6B,IAAI,OAAO,CAUvD"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { printErrorAndExit, printResultAndExit, runEditorAction } from "../utils/editor-action-client.js";
|
|
3
|
+
async function runListThemeGlobals(options) {
|
|
4
|
+
const port = options.port ? parseInt(options.port, 10) : undefined;
|
|
5
|
+
try {
|
|
6
|
+
const result = await runEditorAction("list-theme-globals", {}, port ? { port } : {});
|
|
7
|
+
printResultAndExit(result);
|
|
8
|
+
}
|
|
9
|
+
catch (e) {
|
|
10
|
+
printErrorAndExit(e);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export function createListThemeGlobalsCommand() {
|
|
14
|
+
const cmd = new Command("list-theme-globals");
|
|
15
|
+
cmd
|
|
16
|
+
.description("List the theme's global settings — global variables and design tokens (colors, typography, " +
|
|
17
|
+
"breakpoints, keyframes, color schemes). Requires a running dev server with the editor connected.")
|
|
18
|
+
.option("--port <port>", "Dev server WebSocket port", "5201")
|
|
19
|
+
.action(runListThemeGlobals);
|
|
20
|
+
return cmd;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=list-theme-globals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-theme-globals.js","sourceRoot":"","sources":["../../src/commands/list-theme-globals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAM1G,KAAK,UAAU,mBAAmB,CAAC,OAAgC;IACjE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACnE,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,oBAAoB,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACrF,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,iBAAiB,CAAC,CAAC,CAAC,CAAC;IACvB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,6BAA6B;IAC3C,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAC9C,GAAG;SACA,WAAW,CACV,6FAA6F;QAC3F,kGAAkG,CACrG;SACA,MAAM,CAAC,eAAe,EAAE,2BAA2B,EAAE,MAAM,CAAC;SAC5D,MAAM,CAAC,mBAAmB,CAAC,CAAC;IAC/B,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publish-theme.d.ts","sourceRoot":"","sources":["../../src/commands/publish-theme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAgCpC,wBAAgB,yBAAyB,IAAI,OAAO,CAWnD"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { printErrorAndExit, printResultAndExit, runEditorAction, } from "../utils/editor-action-client.js";
|
|
3
|
+
async function runPublishTheme(options) {
|
|
4
|
+
const port = options.port ? parseInt(options.port, 10) : undefined;
|
|
5
|
+
try {
|
|
6
|
+
const result = await runEditorAction("publish-theme", {
|
|
7
|
+
confirm: !!options.confirm,
|
|
8
|
+
confirmProduction: !!options.confirmProduction,
|
|
9
|
+
},
|
|
10
|
+
// Publishing optimizes images + uploads the whole project to the host, so
|
|
11
|
+
// give it more headroom than the default action timeout.
|
|
12
|
+
{ ...(port ? { port } : {}), timeoutMs: 120_000 });
|
|
13
|
+
printResultAndExit(result);
|
|
14
|
+
}
|
|
15
|
+
catch (e) {
|
|
16
|
+
printErrorAndExit(e);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export function createPublishThemeCommand() {
|
|
20
|
+
const cmd = new Command("publish-theme");
|
|
21
|
+
cmd
|
|
22
|
+
.description("Publish the current theme LIVE (same as the editor's Publish button — saves the whole project to the storefront). This is a real, customer-facing publish: it does nothing unless you pass --confirm, and the MAIN/production theme additionally requires --confirm-production. Without the flags it returns a dry-run describing what would happen and the previewUrl. On success returns { published: true, previewUrl, isMainTheme }.")
|
|
23
|
+
.option("--confirm", "Actually publish (required). Without it, returns a dry-run.")
|
|
24
|
+
.option("--confirm-production", "Required IN ADDITION to --confirm when publishing the MAIN/production theme (live customer-facing site).")
|
|
25
|
+
.option("--port <port>", "Dev server WebSocket port", "5201")
|
|
26
|
+
.action(runPublishTheme);
|
|
27
|
+
return cmd;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=publish-theme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publish-theme.js","sourceRoot":"","sources":["../../src/commands/publish-theme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,GAChB,MAAM,kCAAkC,CAAC;AAQ1C,KAAK,UAAU,eAAe,CAAC,OAA4B;IACzD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACnE,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,eAAe,CAClC,eAAe,EACf;YACE,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO;YAC1B,iBAAiB,EAAE,CAAC,CAAC,OAAO,CAAC,iBAAiB;SAC/C;QACD,0EAA0E;QAC1E,yDAAyD;QACzD,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,CAClD,CAAC;QACF,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,iBAAiB,CAAC,CAAC,CAAC,CAAC;IACvB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,yBAAyB;IACvC,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,eAAe,CAAC,CAAC;IACzC,GAAG;SACA,WAAW,CACV,0aAA0a,CAC3a;SACA,MAAM,CAAC,WAAW,EAAE,6DAA6D,CAAC;SAClF,MAAM,CAAC,sBAAsB,EAAE,0GAA0G,CAAC;SAC1I,MAAM,CAAC,eAAe,EAAE,2BAA2B,EAAE,MAAM,CAAC;SAC5D,MAAM,CAAC,eAAe,CAAC,CAAC;IAC3B,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-products.d.ts","sourceRoot":"","sources":["../../src/commands/search-products.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA2CpC,wBAAgB,2BAA2B,IAAI,OAAO,CAarD"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { printErrorAndExit, printResultAndExit, runEditorAction, } from "../utils/editor-action-client.js";
|
|
3
|
+
async function runSearchProducts(options) {
|
|
4
|
+
const port = options.port ? parseInt(options.port, 10) : undefined;
|
|
5
|
+
const productIds = options.ids
|
|
6
|
+
? options.ids
|
|
7
|
+
.split(",")
|
|
8
|
+
.map(s => s.trim())
|
|
9
|
+
.filter(Boolean)
|
|
10
|
+
: undefined;
|
|
11
|
+
const perPage = options.perPage ? parseInt(options.perPage, 10) : undefined;
|
|
12
|
+
const page = options.page ? parseInt(options.page, 10) : undefined;
|
|
13
|
+
try {
|
|
14
|
+
const result = await runEditorAction("search-products", {
|
|
15
|
+
...(options.query ? { query: options.query } : {}),
|
|
16
|
+
...(productIds && productIds.length ? { productIds } : {}),
|
|
17
|
+
...(typeof perPage === "number" && !Number.isNaN(perPage) ? { perPage } : {}),
|
|
18
|
+
...(typeof page === "number" && !Number.isNaN(page) ? { page } : {}),
|
|
19
|
+
},
|
|
20
|
+
// The host fetches from the store API, so allow more than the default 10s.
|
|
21
|
+
{ ...(port ? { port } : {}), timeoutMs: 20_000 });
|
|
22
|
+
printResultAndExit(result);
|
|
23
|
+
}
|
|
24
|
+
catch (e) {
|
|
25
|
+
printErrorAndExit(e);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export function createSearchProductsCommand() {
|
|
29
|
+
const cmd = new Command("search-products");
|
|
30
|
+
cmd
|
|
31
|
+
.description("Search the connected store's products and return each product's id (productId) + first variantId, name, slug, and variant count. Use the productId/variantId to fill a PRODUCT prop value via `ikas-component update-section-prop`. Requires the editor embedded in the ikas admin panel (the host runs the search).")
|
|
32
|
+
.option("--query <text>", "Free-text search query (name, sku, barcode)")
|
|
33
|
+
.option("--ids <ids>", "Comma-separated product ids to look up directly")
|
|
34
|
+
.option("--per-page <n>", "Results per page")
|
|
35
|
+
.option("--page <n>", "Page number")
|
|
36
|
+
.option("--port <port>", "Dev server WebSocket port", "5201")
|
|
37
|
+
.action(runSearchProducts);
|
|
38
|
+
return cmd;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=search-products.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-products.js","sourceRoot":"","sources":["../../src/commands/search-products.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,GAChB,MAAM,kCAAkC,CAAC;AAU1C,KAAK,UAAU,iBAAiB,CAAC,OAA8B;IAC7D,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACnE,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG;QAC5B,CAAC,CAAC,OAAO,CAAC,GAAG;aACR,K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kB,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,iBAAiB,CAAC,CAAC,CAAC,CAAC;IACvB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,2BAA2B;IACzC,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAC3C,GAAG;SACA,WAAW,CACV,sTAAsT,CACvT;SACA,MAAM,CAAC,gBAAgB,EAAE,6CAA6C,CAAC;SACvE,MAAM,CAAC,aAAa,EAAE,iDAAiD,CAAC;SACxE,MAAM,CAAC,gBAAgB,EAAE,kBAAkB,CAAC;SAC5C,MAAM,CAAC,YAAY,EAAE,aAAa,CAAC;SACnC,MAAM,CAAC,eAAe,EAAE,2BAA2B,EAAE,MAAM,CAAC;SAC5D,MAAM,CAAC,iBAAiB,CAAC,CAAC;IAC7B,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-global-variable.d.ts","sourceRoot":"","sources":["../../src/commands/update-global-variable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAiDpC,wBAAgB,iCAAiC,IAAI,OAAO,CAW3D"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { printErrorAndExit, printResultAndExit, runEditorAction } from "../utils/editor-action-client.js";
|
|
3
|
+
const VALID_TYPES = ["TEXT", "RICH_TEXT", "IMAGE", "COLOR", "NUMBER", "BOOLEAN", "BORDER", "SHADOW"];
|
|
4
|
+
function parseValue(raw) {
|
|
5
|
+
if (raw == null)
|
|
6
|
+
return undefined;
|
|
7
|
+
try {
|
|
8
|
+
return JSON.parse(raw);
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
return raw;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
async function runUpdateGlobalVariable(options) {
|
|
15
|
+
if (!options.name) {
|
|
16
|
+
printErrorAndExit(new Error("--name is required (the variable's runtime key, from list-theme-globals)"));
|
|
17
|
+
}
|
|
18
|
+
if (options.type && !VALID_TYPES.includes(options.type)) {
|
|
19
|
+
printErrorAndExit(new Error(`--type must be one of: ${VALID_TYPES.join(", ")}`));
|
|
20
|
+
}
|
|
21
|
+
const port = options.port ? parseInt(options.port, 10) : undefined;
|
|
22
|
+
try {
|
|
23
|
+
const result = await runEditorAction("update-global-variable", {
|
|
24
|
+
name: options.name,
|
|
25
|
+
...(options.displayName !== undefined ? { displayName: options.displayName } : {}),
|
|
26
|
+
...(options.type !== undefined ? { type: options.type } : {}),
|
|
27
|
+
...(options.value !== undefined ? { value: parseValue(options.value) } : {}),
|
|
28
|
+
}, port ? { port } : {});
|
|
29
|
+
printResultAndExit(result);
|
|
30
|
+
}
|
|
31
|
+
catch (e) {
|
|
32
|
+
printErrorAndExit(e);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export function createUpdateGlobalVariableCommand() {
|
|
36
|
+
const cmd = new Command("update-global-variable");
|
|
37
|
+
cmd
|
|
38
|
+
.description("Update a global variable's value, display name, and/or type in the connected editor")
|
|
39
|
+
.requiredOption("--name <key>", "The variable's runtime key (from `list-theme-globals`)")
|
|
40
|
+
.option("--display-name <name>", "New human-facing label")
|
|
41
|
+
.option("--type <type>", `New value type: ${VALID_TYPES.join(" | ")}`)
|
|
42
|
+
.option("--value <json>", "New value (JSON for objects/null; plain string also accepted)")
|
|
43
|
+
.option("--port <port>", "Dev server WebSocket port", "5201")
|
|
44
|
+
.action(runUpdateGlobalVariable);
|
|
45
|
+
return cmd;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=update-global-variable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-global-variable.js","sourceRoot":"","sources":["../../src/commands/update-global-variable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE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@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { printErrorAndExit, printResultAndExit, runEditorAction, } from "../utils/editor-action-client.js";
|
|
3
|
+
async function runUpdatePageSections(options) {
|
|
4
|
+
if (!options.pageId || typeof options.pageId !== "string") {
|
|
5
|
+
printErrorAndExit(new Error("--page-id is required (use `ikas-component list-pages`)"));
|
|
6
|
+
}
|
|
7
|
+
if (options.sections === undefined) {
|
|
8
|
+
printErrorAndExit(new Error('--sections is required: a JSON array, e.g. \'[{"elementId":"<id>","updates":[{"propName":"heading","value":{"value":"Hi"}}]}]\''));
|
|
9
|
+
}
|
|
10
|
+
let sections;
|
|
11
|
+
try {
|
|
12
|
+
sections = JSON.parse(options.sections);
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
printErrorAndExit(new Error(`--sections must be valid JSON. Received: ${options.sections}`));
|
|
16
|
+
}
|
|
17
|
+
if (!Array.isArray(sections) || sections.length === 0) {
|
|
18
|
+
printErrorAndExit(new Error('--sections must be a non-empty JSON array of { elementId, updates: [...] } objects.'));
|
|
19
|
+
}
|
|
20
|
+
const port = options.port ? parseInt(options.port, 10) : undefined;
|
|
21
|
+
try {
|
|
22
|
+
const result = await runEditorAction("update-page-sections", { pageId: options.pageId, sections }, { ...(port ? { port } : {}), timeoutMs: 30_000 });
|
|
23
|
+
printResultAndExit(result);
|
|
24
|
+
}
|
|
25
|
+
catch (e) {
|
|
26
|
+
printErrorAndExit(e);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export function createUpdatePageSectionsCommand() {
|
|
30
|
+
const cmd = new Command("update-page-sections");
|
|
31
|
+
cmd
|
|
32
|
+
.description("Fill MANY placed sections of a page in one call. --sections is a JSON array of { elementId, updates: [{ propId|propName, value }] }, each value using the same per-type shape as update-section-prop. All-or-nothing across the whole page: every value is resolved and validated before any is written.")
|
|
33
|
+
.requiredOption("--page-id <id>", "Page id (from `ikas-component list-pages`)")
|
|
34
|
+
.requiredOption("--sections <json>", 'JSON array, e.g. \'[{"elementId":"<id>","updates":[{"propName":"heading","value":{"value":"Hi"}}]}]\'')
|
|
35
|
+
.option("--port <port>", "Dev server WebSocket port", "5201")
|
|
36
|
+
.action(runUpdatePageSections);
|
|
37
|
+
return cmd;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=update-page-sections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-page-sections.js","sourceRoot":"","sources":["../../src/commands/update-page-sections.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,GAChB,MAAM,kCAAkC,CAAC;AAQ1C,KAAK,UAAU,qBAAqB,CAAC,OAAkC;IACrE,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,OAAO,OAAO,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC1D,iBAAiB,CAAC,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC,CAAC;IAC1F,CAAC;IACD,IAAI,OAAO,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;QACnC,iBAAiB,CACf,IAAI,KAAK,CACP,iIAAiI,CAClI,CACF,CAAC;IACJ,CAAC;IACD,IAAI,QAAiB,CAAC;IACtB,IAAI,CAAC;QACH,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC1C,CAAC;IAAC,MAAM,CAAC;QACP,iBAAiB,CAAC,IAAI,KAAK,CAAC,4CAA4C,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;IAC/F,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtD,iBAAiB,CACf,IAAI,KAAK,CAAC,qFAAqF,CAAC,CACjG,CAAC;IACJ,CAAC;IAED,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACnE,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,eAAe,CAClC,sBAAsB,EACtB,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE,EACpC,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,CACjD,CAAC;QACF,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,iBAAiB,CAAC,CAAC,CAAC,CAAC;IACvB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,+BAA+B;IAC7C,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,sBAAsB,CAAC,CAAC;IAChD,GAAG;SACA,WAAW,CACV,0SAA0S,CAC3S;SACA,cAAc,CAAC,gBAAgB,EAAE,4CAA4C,CAAC;SAC9E,cAAc,CACb,mBAAmB,EACnB,uGAAuG,CACxG;SACA,MAAM,CAAC,eAAe,EAAE,2BAA2B,EAAE,MAAM,CAAC;SAC5D,MAAM,CAAC,qBAAqB,CAAC,CAAC;IACjC,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-section-prop.d.ts","sourceRoot":"","sources":["../../src/commands/update-section-prop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA4DpC,wBAAgB,8BAA8B,IAAI,OAAO,CAsBxD"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { printErrorAndExit, printResultAndExit, runEditorAction, } from "../utils/editor-action-client.js";
|
|
3
|
+
async function runUpdateSectionProp(options) {
|
|
4
|
+
if (!options.pageId || typeof options.pageId !== "string") {
|
|
5
|
+
printErrorAndExit(new Error("--page-id is required (use `ikas-component list-pages` to discover ids)"));
|
|
6
|
+
}
|
|
7
|
+
if (!options.elementId || typeof options.elementId !== "string") {
|
|
8
|
+
printErrorAndExit(new Error("--element-id is required (use `ikas-component list-page-sections` to discover ids)"));
|
|
9
|
+
}
|
|
10
|
+
if (!options.propId && !options.propName) {
|
|
11
|
+
printErrorAndExit(new Error("Provide --prop-id or --prop-name (see `ikas-component list-page-sections`)"));
|
|
12
|
+
}
|
|
13
|
+
if (options.value === undefined) {
|
|
14
|
+
printErrorAndExit(new Error("--value is required (JSON, e.g. '{\"value\":\"Hello\"}')"));
|
|
15
|
+
}
|
|
16
|
+
let value;
|
|
17
|
+
try {
|
|
18
|
+
value = JSON.parse(options.value);
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
printErrorAndExit(new Error(`--value must be valid JSON (e.g. '{"value":"Hello"}'). Received: ${options.value}`));
|
|
22
|
+
}
|
|
23
|
+
const port = options.port ? parseInt(options.port, 10) : undefined;
|
|
24
|
+
try {
|
|
25
|
+
const result = await runEditorAction("update-section-prop", {
|
|
26
|
+
pageId: options.pageId,
|
|
27
|
+
elementId: options.elementId,
|
|
28
|
+
...(options.propId ? { propId: options.propId } : {}),
|
|
29
|
+
...(options.propName ? { propName: options.propName } : {}),
|
|
30
|
+
value,
|
|
31
|
+
}, port ? { port } : {});
|
|
32
|
+
printResultAndExit(result);
|
|
33
|
+
}
|
|
34
|
+
catch (e) {
|
|
35
|
+
printErrorAndExit(e);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export function createUpdateSectionPropCommand() {
|
|
39
|
+
const cmd = new Command("update-section-prop");
|
|
40
|
+
cmd
|
|
41
|
+
.description([
|
|
42
|
+
"Change a single prop value of a section placed on a page. Target the placement by its elementId (from `ikas-component list-page-sections`) and the prop by --prop-id or --prop-name.",
|
|
43
|
+
"--value is the JSON-encoded prop value. Shape depends on the prop type:",
|
|
44
|
+
" Scalars (TEXT/RICH_TEXT/BOOLEAN/NUMBER/COLOR/ENUM/DATE) are { \"value\": <scalar> } — e.g. '{\"value\":\"Hello\"}', '{\"value\":true}', '{\"value\":\"#FF0000\"}'.",
|
|
45
|
+
" Object props are NOT wrapped: IMAGE/VIDEO/SVG = '{\"id\":\"<asset-id>\",\"altText\":\"...\"}' (get id via `ikas-component upload-image`); PRODUCT = '{\"productId\":\"...\"}'.",
|
|
46
|
+
" LINK = a single link object needing id + linkType + label + subLinks: PAGE = '{\"id\":\"<unique>\",\"linkType\":\"PAGE\",\"label\":\"Home\",\"pageId\":\"<id>\",\"pageType\":\"INDEX\",\"subLinks\":[]}'; EXTERNAL = '{\"id\":\"<unique>\",\"linkType\":\"EXTERNAL\",\"label\":\"Docs\",\"externalLink\":\"https://...\",\"subLinks\":[]}'. (pageId/pageType from `list-pages`.) LIST_OF_LINK = '{\"links\":[<link>,...]}'.",
|
|
47
|
+
" COMPONENT_LIST = '{\"components\":[{\"id\":\"<unique>\",\"codeComponentId\":\"<child-id>\",\"propValues\":{\"<childProp>\":<value>}}]}' (single COMPONENT = one such entry). Each entry needs a unique id and codeComponentId (or componentId); child propValues use the same per-type shapes recursively.",
|
|
48
|
+
" The value REPLACES the whole prop — to edit a COMPONENT_LIST, read the current value from `list-page-sections` and resend the entire array. Wrong shapes are rejected with an error, not stored silently.",
|
|
49
|
+
].join("\n"))
|
|
50
|
+
.requiredOption("--page-id <id>", "Page id (from `ikas-component list-pages`)")
|
|
51
|
+
.requiredOption("--element-id <id>", "Placed section elementId (from `ikas-component list-page-sections`)")
|
|
52
|
+
.option("--prop-id <id>", "Blueprint prop id to update")
|
|
53
|
+
.option("--prop-name <name>", "Blueprint prop name to update (alternative to --prop-id)")
|
|
54
|
+
.requiredOption("--value <json>", 'JSON-encoded prop value, e.g. \'{"value":"Hello"}\'')
|
|
55
|
+
.option("--port <port>", "Dev server WebSocket port", "5201")
|
|
56
|
+
.action(runUpdateSectionProp);
|
|
57
|
+
return cmd;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=update-section-prop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-section-prop.js","sourceRoot":"","sources":["../../src/commands/update-section-prop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,GAChB,MAAM,kCAAkC,CAAC;AAW1C,KAAK,UAAU,oBAAoB,CAAC,OAAiC;IACnE,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,OAAO,OAAO,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC1D,iBAAiB,CAAC,IAAI,KAAK,CAAC,yEAAyE,CAAC,CAAC,CAAC;IAC1G,CAAC;IACD,IAAI,CAAC,OAAO,CAAC,SAAS,IAAI,OAAO,OAAO,CAAC,SAAS,KAAK,QAAQ,EAAE,CAAC;QAChE,iBAAiB,CACf,IAAI,KAAK,CAAC,oFAAoF,CAAC,CAChG,CAAC;IACJ,CAAC;IACD,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;QACzC,iBAAiB,CAAC,IAAI,KAAK,CAAC,4EAA4E,CAAC,CAAC,CAAC;IAC7G,CAAC;IACD,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QAChC,iBAAiB,CAAC,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC,CAAC;IAC3F,CAAC;IAED,IAAI,KAAc,CAAC;IACnB,IAAI,CAAC;QACH,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;IAAC,MAAM,CAAC;QACP,iBAAiB,CACf,IAAI,KAAK,CAAC,oEAAoE,OAAO,CAAC,KAAK,EAAE,CAAC,CAC/F,CA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EAAE,0DAA0D,CAAC;SACxF,cAAc,CAAC,gBAAgB,EAAE,qDAAqD,CAAC;SACvF,MAAM,CAAC,eAAe,EAAE,2BAA2B,EAAE,MAAM,CAAC;SAC5D,MAAM,CAAC,oBAAoB,CAAC,CAAC;IAChC,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload-image.d.ts","sourceRoot":"","sources":["../../src/commands/upload-image.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAyCpC,wBAAgB,wBAAwB,IAAI,OAAO,CAYlD"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { printErrorAndExit, printResultAndExit, runEditorAction, } from "../utils/editor-action-client.js";
|
|
3
|
+
import { loadImageSource } from "../utils/load-image.js";
|
|
4
|
+
async function runUploadImage(options) {
|
|
5
|
+
const port = options.port ? parseInt(options.port, 10) : undefined;
|
|
6
|
+
if (!options.file && !options.url) {
|
|
7
|
+
printErrorAndExit(new Error("Provide --file <path> or --url <url>"));
|
|
8
|
+
}
|
|
9
|
+
try {
|
|
10
|
+
const { base64, mimeType, fileName } = await loadImageSource({ file: options.file, url: options.url });
|
|
11
|
+
const result = await runEditorAction("upload-image", {
|
|
12
|
+
base64,
|
|
13
|
+
mimeType,
|
|
14
|
+
fileName,
|
|
15
|
+
...(options.alt ? { altText: options.alt } : {}),
|
|
16
|
+
isVideo: false,
|
|
17
|
+
},
|
|
18
|
+
// Uploads carry the full image payload and round-trip to the host, so give
|
|
19
|
+
// them a far more generous timeout than the default 10s.
|
|
20
|
+
{ ...(port ? { port } : {}), timeoutMs: 60_000 });
|
|
21
|
+
printResultAndExit(result);
|
|
22
|
+
}
|
|
23
|
+
catch (e) {
|
|
24
|
+
printErrorAndExit(e);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export function createUploadImageCommand() {
|
|
28
|
+
const cmd = new Command("upload-image");
|
|
29
|
+
cmd
|
|
30
|
+
.description("Upload an image to the connected editor's project and return its image id. Supply the image with --file (local path) or --url. The returned id can be used as the `id` of an IMAGE prop value via `ikas-component update-section-prop`. Requires the editor to be embedded in the ikas admin panel (the host performs the actual upload).")
|
|
31
|
+
.option("--file <path>", "Local image file path (.png, .jpg, .jpeg, .webp, .gif)")
|
|
32
|
+
.option("--url <url>", "Image URL to fetch and upload")
|
|
33
|
+
.option("--alt <text>", "Alt text for the image")
|
|
34
|
+
.option("--port <port>", "Dev server WebSocket port", "5201")
|
|
35
|
+
.action(runUploadImage);
|
|
36
|
+
return cmd;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=upload-image.js.map
|