diff --git a/src/core/index.ts b/src/core/index.ts index 740930d..995bd7b 100644 --- a/src/core/index.ts +++ b/src/core/index.ts @@ -6,7 +6,7 @@ // Core authentication and state management export { Auth } from "./auth"; export { state, setState, resetState, primeFromEnv, getState, getUIMode } from "./state"; -export { systemArgs, type SystemArgsType } from "./system-args"; +export { systemArgs, workflowArgs, type SystemArgsType } from "./system-args"; export { normalizeProcessArgs, normalizeArgv } from "./arg-normalizer"; // Main operation services diff --git a/src/core/system-args.ts b/src/core/system-args.ts index 4451847..d484d97 100644 --- a/src/core/system-args.ts +++ b/src/core/system-args.ts @@ -88,24 +88,6 @@ export const systemArgs = { default: false, }, - // **Explicit ID Override for Workflow Operations** - contentIDs: { - describe: - "Comma-separated list of target content IDs to process. Bypasses mappings lookup when provided (e.g., --contentIDs=121,1221,345).", - demandOption: false, - alias: ["content-ids", "contentIds", "ContentIDs", "CONTENTIDS"], - type: "string" as const, - default: "", - }, - pageIDs: { - describe: - "Comma-separated list of target page IDs to process. Bypasses mappings lookup when provided (e.g., --pageIDs=12,11,45).", - demandOption: false, - alias: ["page-ids", "pageIds", "PageIDs", "PAGEIDS"], - type: "string" as const, - default: "", - }, - // Instance identification args sourceGuid: { describe: @@ -149,6 +131,34 @@ export const systemArgs = { }, }; +/** + * Args exclusive to the `workflows` command (PROD-2230). + * + * These bypass the mappings lookup for workflow operations (publish/unpublish/ + * approve/decline). They must NOT be spread into pull/push/sync's builders — + * those commands never read state.explicitContentIDs/explicitPageIDs (only + * lib/workflows/workflow-operation.ts does), so showing them there previously + * advertised a filter that silently did nothing. + */ +export const workflowArgs = { + contentIDs: { + describe: + "Comma-separated list of target content IDs to process. Bypasses mappings lookup when provided (e.g., --contentIDs=121,1221,345).", + demandOption: false, + alias: ["content-ids", "contentIds", "ContentIDs", "CONTENTIDS"], + type: "string" as const, + default: "", + }, + pageIDs: { + describe: + "Comma-separated list of target page IDs to process. Bypasses mappings lookup when provided (e.g., --pageIDs=12,11,45).", + demandOption: false, + alias: ["page-ids", "pageIds", "PageIDs", "PAGEIDS"], + type: "string" as const, + default: "", + }, +}; + /** * Type helper for command arguments that include system args */ diff --git a/src/core/tests/system-args.test.ts b/src/core/tests/system-args.test.ts index a3123fd..7feb0ae 100644 --- a/src/core/tests/system-args.test.ts +++ b/src/core/tests/system-args.test.ts @@ -1,4 +1,4 @@ -import { systemArgs } from "../system-args"; +import { systemArgs, workflowArgs } from "../system-args"; // ─── Structure ───────────────────────────────────────────────────────────────── @@ -13,8 +13,6 @@ describe("systemArgs – required keys exist", () => { "elements", "models", "modelsWithDeps", - "contentIDs", - "pageIDs", "sourceGuid", "targetGuid", "overwrite", @@ -41,6 +39,12 @@ describe("systemArgs – removed keys do not exist", () => { "force", "update", "reset", + // PROD-2230: contentIDs/pageIDs only have an effect for `workflows` (which + // reads state.explicitContentIDs/explicitPageIDs) — pull/push/sync never + // consumed them, so showing them in those commands' --help was misleading. + // They now live in workflowArgs, scoped to the `workflows` builder only. + "contentIDs", + "pageIDs", ]; it.each(removedKeys)('no longer exposes "%s"', (key) => { @@ -48,6 +52,21 @@ describe("systemArgs – removed keys do not exist", () => { }); }); +describe("workflowArgs – contentIDs/pageIDs scoped to `workflows` only (PROD-2230)", () => { + it.each(["contentIDs", "pageIDs"])('has key "%s"', (key) => { + expect(workflowArgs).toHaveProperty(key); + }); + + it.each(["contentIDs", "pageIDs"])('"%s" declares type "string"', (key) => { + expect((workflowArgs as any)[key].type).toBe("string"); + }); + + it.each(["contentIDs", "pageIDs"])('"%s" has a non-empty describe (shown in --help)', (key) => { + expect(typeof (workflowArgs as any)[key].describe).toBe("string"); + expect((workflowArgs as any)[key].describe.length).toBeGreaterThan(0); + }); +}); + describe("systemArgs – types", () => { it('boolean args declare type "boolean"', () => { const boolArgs = ["dev", "headless", "verbose", "overwrite"]; @@ -64,8 +83,6 @@ describe("systemArgs – types", () => { "elements", "models", "modelsWithDeps", - "contentIDs", - "pageIDs", "sourceGuid", "targetGuid", ]; diff --git a/src/index.ts b/src/index.ts index 43722af..d3fb33c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -26,6 +26,7 @@ import { resetState, primeFromEnv, systemArgs, + workflowArgs, normalizeProcessArgs, normalizeArgv, } from "./core"; @@ -290,6 +291,8 @@ yargs.command({ }, // System args (commonly repeated across commands) ...systemArgs, + // Explicit content/page ID overrides — only meaningful for workflow operations (PROD-2230) + ...workflowArgs, }, handler: async function (argv) { resetState(); // Clear any previous command state