@principles/pd-cli 1.132.0 → 1.134.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/__tests__/intent-flag-wiring.test.js +74 -3
- package/dist/commands/__tests__/intent-flag-wiring.test.js.map +1 -1
- package/dist/commands/__tests__/pain-retry-maxTokens-flag.test.d.ts +2 -0
- package/dist/commands/__tests__/pain-retry-maxTokens-flag.test.d.ts.map +1 -0
- package/dist/commands/__tests__/pain-retry-maxTokens-flag.test.js +60 -0
- package/dist/commands/__tests__/pain-retry-maxTokens-flag.test.js.map +1 -0
- package/dist/commands/__tests__/rulecode-flag-wiring.test.js +11 -4
- package/dist/commands/__tests__/rulecode-flag-wiring.test.js.map +1 -1
- package/dist/commands/__tests__/run-rulehost-flag-wiring.test.js +9 -0
- package/dist/commands/__tests__/run-rulehost-flag-wiring.test.js.map +1 -1
- package/dist/commands/admission-gate.d.ts +24 -0
- package/dist/commands/admission-gate.d.ts.map +1 -0
- package/dist/commands/admission-gate.js +29 -0
- package/dist/commands/admission-gate.js.map +1 -0
- package/dist/commands/candidate.d.ts.map +1 -1
- package/dist/commands/candidate.js +72 -6
- package/dist/commands/candidate.js.map +1 -1
- package/dist/commands/console.d.ts.map +1 -1
- package/dist/commands/console.js +40 -0
- package/dist/commands/console.js.map +1 -1
- package/dist/commands/demo-story-a.d.ts.map +1 -1
- package/dist/commands/demo-story-a.js +4 -2
- package/dist/commands/demo-story-a.js.map +1 -1
- package/dist/commands/diagnose.d.ts.map +1 -1
- package/dist/commands/diagnose.js +155 -8
- package/dist/commands/diagnose.js.map +1 -1
- package/dist/commands/errors-list.d.ts +25 -0
- package/dist/commands/errors-list.d.ts.map +1 -0
- package/dist/commands/errors-list.js +368 -0
- package/dist/commands/errors-list.js.map +1 -0
- package/dist/commands/health-codex.d.ts +7 -0
- package/dist/commands/health-codex.d.ts.map +1 -0
- package/dist/commands/health-codex.js +209 -0
- package/dist/commands/health-codex.js.map +1 -0
- package/dist/commands/health.d.ts +24 -0
- package/dist/commands/health.d.ts.map +1 -1
- package/dist/commands/health.js +48 -0
- package/dist/commands/health.js.map +1 -1
- package/dist/commands/intent.d.ts +21 -4
- package/dist/commands/intent.d.ts.map +1 -1
- package/dist/commands/intent.js +88 -27
- package/dist/commands/intent.js.map +1 -1
- package/dist/commands/pain-evidence.d.ts +6 -0
- package/dist/commands/pain-evidence.d.ts.map +1 -1
- package/dist/commands/pain-evidence.js +6 -0
- package/dist/commands/pain-evidence.js.map +1 -1
- package/dist/commands/pain-record.d.ts.map +1 -1
- package/dist/commands/pain-record.js +21 -0
- package/dist/commands/pain-record.js.map +1 -1
- package/dist/commands/pain-retry.d.ts +4 -0
- package/dist/commands/pain-retry.d.ts.map +1 -1
- package/dist/commands/pain-retry.js +327 -32
- package/dist/commands/pain-retry.js.map +1 -1
- package/dist/commands/proven-channel-baseline.d.ts.map +1 -1
- package/dist/commands/proven-channel-baseline.js +4 -2
- package/dist/commands/proven-channel-baseline.js.map +1 -1
- package/dist/commands/runtime-activation.d.ts +30 -0
- package/dist/commands/runtime-activation.d.ts.map +1 -1
- package/dist/commands/runtime-activation.js +567 -11
- package/dist/commands/runtime-activation.js.map +1 -1
- package/dist/commands/runtime-canary.d.ts.map +1 -1
- package/dist/commands/runtime-canary.js +32 -7
- package/dist/commands/runtime-canary.js.map +1 -1
- package/dist/commands/runtime-health-snapshot.d.ts.map +1 -1
- package/dist/commands/runtime-health-snapshot.js +4 -2
- package/dist/commands/runtime-health-snapshot.js.map +1 -1
- package/dist/commands/runtime-init.d.ts +43 -0
- package/dist/commands/runtime-init.d.ts.map +1 -0
- package/dist/commands/runtime-init.js +264 -0
- package/dist/commands/runtime-init.js.map +1 -0
- package/dist/commands/runtime-internalization-context-trace.d.ts +25 -0
- package/dist/commands/runtime-internalization-context-trace.d.ts.map +1 -0
- package/dist/commands/runtime-internalization-context-trace.js +374 -0
- package/dist/commands/runtime-internalization-context-trace.js.map +1 -0
- package/dist/commands/runtime-internalization-enqueue-successors.d.ts.map +1 -1
- package/dist/commands/runtime-internalization-enqueue-successors.js +3 -1
- package/dist/commands/runtime-internalization-enqueue-successors.js.map +1 -1
- package/dist/commands/runtime-internalization-integrity.d.ts.map +1 -1
- package/dist/commands/runtime-internalization-integrity.js +4 -2
- package/dist/commands/runtime-internalization-integrity.js.map +1 -1
- package/dist/commands/runtime-internalization-run-once.d.ts.map +1 -1
- package/dist/commands/runtime-internalization-run-once.js +20 -5
- package/dist/commands/runtime-internalization-run-once.js.map +1 -1
- package/dist/commands/runtime-internalization-run-rulehost.d.ts +1 -0
- package/dist/commands/runtime-internalization-run-rulehost.d.ts.map +1 -1
- package/dist/commands/runtime-internalization-run-rulehost.js +149 -6
- package/dist/commands/runtime-internalization-run-rulehost.js.map +1 -1
- package/dist/commands/runtime-uat.d.ts.map +1 -1
- package/dist/commands/runtime-uat.guard.test.js +13 -15
- package/dist/commands/runtime-uat.guard.test.js.map +1 -1
- package/dist/commands/runtime-uat.js +4 -3
- package/dist/commands/runtime-uat.js.map +1 -1
- package/dist/config-reader.js +1 -1
- package/dist/config-reader.js.map +1 -1
- package/dist/index.js +54 -78
- package/dist/index.js.map +1 -1
- package/dist/services/__tests__/evaluator-runner-deps.test.d.ts +2 -0
- package/dist/services/__tests__/evaluator-runner-deps.test.d.ts.map +1 -0
- package/dist/services/__tests__/evaluator-runner-deps.test.js +304 -0
- package/dist/services/__tests__/evaluator-runner-deps.test.js.map +1 -0
- package/dist/services/__tests__/rulehost-readiness.test.js.map +1 -1
- package/dist/services/__tests__/runtime-adapter-resolver.test.js.map +1 -1
- package/dist/services/config-doctor.d.ts.map +1 -1
- package/dist/services/config-doctor.js +9 -2
- package/dist/services/config-doctor.js.map +1 -1
- package/dist/services/pain-flood-simulation-runner.d.ts.map +1 -1
- package/dist/services/pain-flood-simulation-runner.js +9 -0
- package/dist/services/pain-flood-simulation-runner.js.map +1 -1
- package/dist/services/pd-config-loader.js +2 -2
- package/dist/services/pd-config-loader.js.map +1 -1
- package/dist/services/proven-channel-baseline-runner.d.ts.map +1 -1
- package/dist/services/proven-channel-baseline-runner.js +10 -2
- package/dist/services/proven-channel-baseline-runner.js.map +1 -1
- package/dist/services/quality-scorecard/data-extractor.js.map +1 -1
- package/dist/services/resolve-runtime-from-pd-config.js.map +1 -1
- package/dist/services/rulehost-pipeline-runner.d.ts +77 -1
- package/dist/services/rulehost-pipeline-runner.d.ts.map +1 -1
- package/dist/services/rulehost-pipeline-runner.js +111 -7
- package/dist/services/rulehost-pipeline-runner.js.map +1 -1
- package/dist/services/rulehost-readiness.js.map +1 -1
- package/dist/services/runtime-adapter-resolver.d.ts +1 -0
- package/dist/services/runtime-adapter-resolver.d.ts.map +1 -1
- package/dist/services/runtime-adapter-resolver.js +3 -0
- package/dist/services/runtime-adapter-resolver.js.map +1 -1
- package/dist/services/synthetic-baseline-runner.d.ts.map +1 -1
- package/dist/services/synthetic-baseline-runner.js +11 -0
- package/dist/services/synthetic-baseline-runner.js.map +1 -1
- package/dist/utils/production-workspace-guard.d.ts +4 -4
- package/dist/utils/production-workspace-guard.d.ts.map +1 -1
- package/dist/utils/production-workspace-guard.js +19 -16
- package/dist/utils/production-workspace-guard.js.map +1 -1
- package/dist/utils/production-workspace-guard.test.js +54 -19
- package/dist/utils/production-workspace-guard.test.js.map +1 -1
- package/package.json +8 -5
- package/scripts/migrate-illegal-expected-decision.ts +252 -0
- package/src/commands/__tests__/intent-flag-wiring.test.ts +88 -3
- package/src/commands/__tests__/pain-retry-maxTokens-flag.test.ts +73 -0
- package/src/commands/__tests__/rulecode-flag-wiring.test.ts +31 -24
- package/src/commands/__tests__/run-rulehost-flag-wiring.test.ts +12 -0
- package/src/commands/admission-gate.ts +30 -0
- package/src/commands/candidate.ts +74 -6
- package/src/commands/console.ts +40 -0
- package/src/commands/demo-story-a.ts +4 -2
- package/src/commands/diagnose.ts +158 -10
- package/src/commands/errors-list.ts +440 -0
- package/src/commands/health-codex.ts +249 -0
- package/src/commands/health.ts +60 -0
- package/src/commands/intent.ts +98 -29
- package/src/commands/pain-evidence.ts +6 -0
- package/src/commands/pain-record.ts +21 -0
- package/src/commands/pain-retry.ts +353 -35
- package/src/commands/proven-channel-baseline.ts +4 -2
- package/src/commands/runtime-activation.ts +657 -12
- package/src/commands/runtime-canary.ts +31 -5
- package/src/commands/runtime-health-snapshot.ts +4 -2
- package/src/commands/runtime-init.ts +305 -0
- package/src/commands/runtime-internalization-context-trace.ts +445 -0
- package/src/commands/runtime-internalization-enqueue-successors.ts +3 -1
- package/src/commands/runtime-internalization-integrity.ts +4 -2
- package/src/commands/runtime-internalization-run-once.ts +20 -5
- package/src/commands/runtime-internalization-run-rulehost.ts +159 -6
- package/src/commands/runtime-uat.guard.test.ts +14 -16
- package/src/commands/runtime-uat.ts +4 -3
- package/src/config-reader.ts +1 -1
- package/src/index.ts +69 -78
- package/src/services/__tests__/evaluator-runner-deps.test.ts +341 -0
- package/src/services/config-doctor.ts +9 -2
- package/src/services/pain-flood-simulation-runner.ts +9 -0
- package/src/services/pd-config-loader.ts +2 -2
- package/src/services/proven-channel-baseline-runner.ts +10 -3
- package/src/services/rulehost-pipeline-runner.ts +157 -6
- package/src/services/runtime-adapter-resolver.ts +4 -0
- package/src/services/synthetic-baseline-runner.ts +11 -0
- package/src/utils/production-workspace-guard.test.ts +62 -20
- package/src/utils/production-workspace-guard.ts +19 -16
- package/tests/bdd/cli-contract.steps.ts +343 -0
- package/tests/bdd/context-trace.steps.ts +229 -0
- package/tests/bdd/support/gherkin-loader.ts +147 -0
- package/tests/bdd/support/repo-root.ts +62 -0
- package/tests/bdd/support/vitest-bdd.ts +179 -0
- package/tests/commands/admission-gate-coverage.test.ts +79 -0
- package/tests/commands/candidate-audit-repair.test.ts +77 -0
- package/tests/commands/candidate-intake.test.ts +155 -10
- package/tests/commands/candidate-internalization-backfill.test.ts +30 -0
- package/tests/commands/cli-help-snapshot.test.ts +15 -1
- package/tests/commands/console-open.test.ts +19 -0
- package/tests/commands/diagnose.test.ts +619 -14
- package/tests/commands/errors-list.test.ts +678 -0
- package/tests/commands/health-codex.test.ts +243 -0
- package/tests/commands/health-host-wiring.test.ts +76 -0
- package/tests/commands/intent.test.ts +4 -4
- package/tests/commands/pain-record.test.ts +80 -0
- package/tests/commands/pain-retry.test.ts +94 -3
- package/tests/commands/run-rulehost-handler.test.ts +133 -0
- package/tests/commands/runtime-activation-approve-flag-wiring.test.ts +227 -0
- package/tests/commands/runtime-activation-deactivate-flag-wiring.test.ts +167 -0
- package/tests/commands/runtime-activation-dispatch-flag-wiring.test.ts +262 -0
- package/tests/commands/runtime-activation-list-flag-wiring.test.ts +193 -0
- package/tests/commands/runtime-activation-promote-flag-wiring.test.ts +222 -0
- package/tests/commands/runtime-activation.test.ts +1090 -5
- package/tests/commands/runtime-canary.test.ts +50 -0
- package/tests/commands/runtime-features.test.ts +2 -0
- package/tests/commands/runtime-init-empty-workspace.test.ts +234 -0
- package/tests/commands/runtime-init.test.ts +346 -0
- package/tests/commands/runtime-internalization-context-trace.test.ts +110 -0
- package/tests/commands/runtime-internalization.test.ts +2 -2
- package/tests/config-reader.test.ts +6 -5
- package/tests/e2e/cross-package-acceptance.test.ts +55 -13
- package/tests/services/mainline-snapshot-assembler.test.ts +6 -3
- package/tests/services/resolve-runtime-from-pd-config.test.ts +2 -0
- package/tests/services/rulehost-pipeline-runner.test.ts +1 -1
- package/vitest.config.ts +1 -1
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parser-level tests for `pd runtime activation dispatch` flags (CLI gate rule 7).
|
|
3
|
+
*
|
|
4
|
+
* Mirrors `runtime-activation-promote-flag-wiring.test.ts`. Exercises the real
|
|
5
|
+
* `registerRuntimeActivationDispatchCommand` helper (single source of truth
|
|
6
|
+
* shared with `index.ts`). Flag typos in production surface here at
|
|
7
|
+
* parseAsync time, not at handler dispatch.
|
|
8
|
+
*
|
|
9
|
+
* Covers:
|
|
10
|
+
* - --dry-run and --confirm are registered
|
|
11
|
+
* - --json is registered
|
|
12
|
+
* - --artifact-id / -a, --workspace / -w, --channel / -c shorthand flags
|
|
13
|
+
* - --channel defaults to 'prompt'
|
|
14
|
+
* - --no-dry-run / --no-confirm are NOT registered (no accidental negation)
|
|
15
|
+
*
|
|
16
|
+
* Handler-level behavior (mutual exclusivity enforcement, missing-artifact
|
|
17
|
+
* refusal, JSON output shape) is covered by runtime-activation.test.ts.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { describe, it, expect } from 'vitest';
|
|
21
|
+
import { Command } from 'commander';
|
|
22
|
+
|
|
23
|
+
import { registerRuntimeActivationDispatchCommand } from '../../src/commands/runtime-activation.js';
|
|
24
|
+
|
|
25
|
+
type ActionOptions = Record<string, unknown>;
|
|
26
|
+
|
|
27
|
+
interface CapturedAction {
|
|
28
|
+
opts: ActionOptions | null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function attachCapture(cmd: Command, state: CapturedAction): void {
|
|
32
|
+
cmd.action(function captureAction(...args: unknown[]): void {
|
|
33
|
+
let optsArg: unknown = null;
|
|
34
|
+
for (let i = args.length - 1; i >= 0; i--) {
|
|
35
|
+
const arg: unknown = args[i];
|
|
36
|
+
if (arg !== null && typeof arg === 'object' && !(arg instanceof Command)) {
|
|
37
|
+
optsArg = arg;
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (optsArg !== null && typeof optsArg === 'object') {
|
|
42
|
+
state.opts = optsArg as ActionOptions;
|
|
43
|
+
} else {
|
|
44
|
+
state.opts = {};
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function freshProgram(): Command {
|
|
50
|
+
const program = new Command();
|
|
51
|
+
program.name('pd').exitOverride();
|
|
52
|
+
return program;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
describe('pd runtime activation dispatch — flag wiring (CLI gate rule 7)', () => {
|
|
56
|
+
// ── Option metadata ──────────────────────────────────────────────────────
|
|
57
|
+
|
|
58
|
+
it('registers --dry-run flag', () => {
|
|
59
|
+
const program = freshProgram();
|
|
60
|
+
const runtimeCmd = program.command('runtime');
|
|
61
|
+
const activationCmd = runtimeCmd.command('activation', { hidden: true });
|
|
62
|
+
const dispatchCmd = registerRuntimeActivationDispatchCommand(activationCmd);
|
|
63
|
+
|
|
64
|
+
const opt = dispatchCmd.options.find((o) => o.long === '--dry-run');
|
|
65
|
+
expect(opt).toBeDefined();
|
|
66
|
+
expect(opt?.long).toBe('--dry-run');
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('registers --confirm flag', () => {
|
|
70
|
+
const program = freshProgram();
|
|
71
|
+
const runtimeCmd = program.command('runtime');
|
|
72
|
+
const activationCmd = runtimeCmd.command('activation', { hidden: true });
|
|
73
|
+
const dispatchCmd = registerRuntimeActivationDispatchCommand(activationCmd);
|
|
74
|
+
|
|
75
|
+
const opt = dispatchCmd.options.find((o) => o.long === '--confirm');
|
|
76
|
+
expect(opt).toBeDefined();
|
|
77
|
+
expect(opt?.long).toBe('--confirm');
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it('registers --json flag', () => {
|
|
81
|
+
const program = freshProgram();
|
|
82
|
+
const runtimeCmd = program.command('runtime');
|
|
83
|
+
const activationCmd = runtimeCmd.command('activation', { hidden: true });
|
|
84
|
+
const dispatchCmd = registerRuntimeActivationDispatchCommand(activationCmd);
|
|
85
|
+
|
|
86
|
+
const opt = dispatchCmd.options.find((o) => o.long === '--json');
|
|
87
|
+
expect(opt).toBeDefined();
|
|
88
|
+
expect(opt?.long).toBe('--json');
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('registers -a shorthand for --artifact-id', () => {
|
|
92
|
+
const program = freshProgram();
|
|
93
|
+
const runtimeCmd = program.command('runtime');
|
|
94
|
+
const activationCmd = runtimeCmd.command('activation', { hidden: true });
|
|
95
|
+
const dispatchCmd = registerRuntimeActivationDispatchCommand(activationCmd);
|
|
96
|
+
|
|
97
|
+
const opt = dispatchCmd.options.find((o) => o.short === '-a');
|
|
98
|
+
expect(opt).toBeDefined();
|
|
99
|
+
expect(opt?.long).toBe('--artifact-id');
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('registers -w shorthand for --workspace', () => {
|
|
103
|
+
const program = freshProgram();
|
|
104
|
+
const runtimeCmd = program.command('runtime');
|
|
105
|
+
const activationCmd = runtimeCmd.command('activation', { hidden: true });
|
|
106
|
+
const dispatchCmd = registerRuntimeActivationDispatchCommand(activationCmd);
|
|
107
|
+
|
|
108
|
+
const opt = dispatchCmd.options.find((o) => o.short === '-w');
|
|
109
|
+
expect(opt).toBeDefined();
|
|
110
|
+
expect(opt?.long).toBe('--workspace');
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it('registers -c shorthand for --channel', () => {
|
|
114
|
+
const program = freshProgram();
|
|
115
|
+
const runtimeCmd = program.command('runtime');
|
|
116
|
+
const activationCmd = runtimeCmd.command('activation', { hidden: true });
|
|
117
|
+
const dispatchCmd = registerRuntimeActivationDispatchCommand(activationCmd);
|
|
118
|
+
|
|
119
|
+
const opt = dispatchCmd.options.find((o) => o.short === '-c');
|
|
120
|
+
expect(opt).toBeDefined();
|
|
121
|
+
expect(opt?.long).toBe('--channel');
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it('does NOT register --no-dry-run (no accidental negation)', () => {
|
|
125
|
+
const program = freshProgram();
|
|
126
|
+
const runtimeCmd = program.command('runtime');
|
|
127
|
+
const activationCmd = runtimeCmd.command('activation', { hidden: true });
|
|
128
|
+
const dispatchCmd = registerRuntimeActivationDispatchCommand(activationCmd);
|
|
129
|
+
|
|
130
|
+
const noForm = dispatchCmd.options.find((o) => o.long === '--no-dry-run');
|
|
131
|
+
expect(noForm).toBeUndefined();
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it('does NOT register --no-confirm (no accidental negation)', () => {
|
|
135
|
+
const program = freshProgram();
|
|
136
|
+
const runtimeCmd = program.command('runtime');
|
|
137
|
+
const activationCmd = runtimeCmd.command('activation', { hidden: true });
|
|
138
|
+
const dispatchCmd = registerRuntimeActivationDispatchCommand(activationCmd);
|
|
139
|
+
|
|
140
|
+
const noForm = dispatchCmd.options.find((o) => o.long === '--no-confirm');
|
|
141
|
+
expect(noForm).toBeUndefined();
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
// ── Parser-level tests (program.parseAsync) ───────────────────────────────
|
|
145
|
+
|
|
146
|
+
it('parses --dry-run as true', async () => {
|
|
147
|
+
const program = freshProgram();
|
|
148
|
+
const runtimeCmd = program.command('runtime');
|
|
149
|
+
const activationCmd = runtimeCmd.command('activation', { hidden: true });
|
|
150
|
+
const dispatchCmd = registerRuntimeActivationDispatchCommand(activationCmd);
|
|
151
|
+
const captured: CapturedAction = { opts: null };
|
|
152
|
+
attachCapture(dispatchCmd, captured);
|
|
153
|
+
|
|
154
|
+
await program.parseAsync(['node', 'pd', 'runtime', 'activation', 'dispatch', '--dry-run']);
|
|
155
|
+
|
|
156
|
+
expect(captured.opts).not.toBeNull();
|
|
157
|
+
expect(captured.opts?.dryRun).toBe(true);
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
it('parses --confirm as true', async () => {
|
|
161
|
+
const program = freshProgram();
|
|
162
|
+
const runtimeCmd = program.command('runtime');
|
|
163
|
+
const activationCmd = runtimeCmd.command('activation', { hidden: true });
|
|
164
|
+
const dispatchCmd = registerRuntimeActivationDispatchCommand(activationCmd);
|
|
165
|
+
const captured: CapturedAction = { opts: null };
|
|
166
|
+
attachCapture(dispatchCmd, captured);
|
|
167
|
+
|
|
168
|
+
await program.parseAsync(['node', 'pd', 'runtime', 'activation', 'dispatch', '--confirm']);
|
|
169
|
+
|
|
170
|
+
expect(captured.opts).not.toBeNull();
|
|
171
|
+
expect(captured.opts?.confirm).toBe(true);
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it('parses both --dry-run and --confirm (handler enforces mutual exclusivity)', async () => {
|
|
175
|
+
// Commander parses both flags; the handler validates mutual exclusivity.
|
|
176
|
+
// This test proves the parser accepts both — the handler test in
|
|
177
|
+
// runtime-activation.test.ts proves the handler rejects the combination.
|
|
178
|
+
const program = freshProgram();
|
|
179
|
+
const runtimeCmd = program.command('runtime');
|
|
180
|
+
const activationCmd = runtimeCmd.command('activation', { hidden: true });
|
|
181
|
+
const dispatchCmd = registerRuntimeActivationDispatchCommand(activationCmd);
|
|
182
|
+
const captured: CapturedAction = { opts: null };
|
|
183
|
+
attachCapture(dispatchCmd, captured);
|
|
184
|
+
|
|
185
|
+
await program.parseAsync(['node', 'pd', 'runtime', 'activation', 'dispatch', '--dry-run', '--confirm']);
|
|
186
|
+
|
|
187
|
+
expect(captured.opts).not.toBeNull();
|
|
188
|
+
expect(captured.opts?.dryRun).toBe(true);
|
|
189
|
+
expect(captured.opts?.confirm).toBe(true);
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
it('defaults --dry-run and --confirm to undefined when neither is passed', async () => {
|
|
193
|
+
const program = freshProgram();
|
|
194
|
+
const runtimeCmd = program.command('runtime');
|
|
195
|
+
const activationCmd = runtimeCmd.command('activation', { hidden: true });
|
|
196
|
+
const dispatchCmd = registerRuntimeActivationDispatchCommand(activationCmd);
|
|
197
|
+
const captured: CapturedAction = { opts: null };
|
|
198
|
+
attachCapture(dispatchCmd, captured);
|
|
199
|
+
|
|
200
|
+
await program.parseAsync(['node', 'pd', 'runtime', 'activation', 'dispatch']);
|
|
201
|
+
|
|
202
|
+
expect(captured.opts).not.toBeNull();
|
|
203
|
+
expect(captured.opts?.dryRun).toBeUndefined();
|
|
204
|
+
expect(captured.opts?.confirm).toBeUndefined();
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
it('parses --json as true', async () => {
|
|
208
|
+
const program = freshProgram();
|
|
209
|
+
const runtimeCmd = program.command('runtime');
|
|
210
|
+
const activationCmd = runtimeCmd.command('activation', { hidden: true });
|
|
211
|
+
const dispatchCmd = registerRuntimeActivationDispatchCommand(activationCmd);
|
|
212
|
+
const captured: CapturedAction = { opts: null };
|
|
213
|
+
attachCapture(dispatchCmd, captured);
|
|
214
|
+
|
|
215
|
+
await program.parseAsync(['node', 'pd', 'runtime', 'activation', 'dispatch', '--json']);
|
|
216
|
+
|
|
217
|
+
expect(captured.opts).not.toBeNull();
|
|
218
|
+
expect(captured.opts?.json).toBe(true);
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
it('parses -a shorthand for --artifact-id', async () => {
|
|
222
|
+
const program = freshProgram();
|
|
223
|
+
const runtimeCmd = program.command('runtime');
|
|
224
|
+
const activationCmd = runtimeCmd.command('activation', { hidden: true });
|
|
225
|
+
const dispatchCmd = registerRuntimeActivationDispatchCommand(activationCmd);
|
|
226
|
+
const captured: CapturedAction = { opts: null };
|
|
227
|
+
attachCapture(dispatchCmd, captured);
|
|
228
|
+
|
|
229
|
+
await program.parseAsync(['node', 'pd', 'runtime', 'activation', 'dispatch', '-a', 'art-1']);
|
|
230
|
+
|
|
231
|
+
expect(captured.opts).not.toBeNull();
|
|
232
|
+
expect(captured.opts?.artifactId).toBe('art-1');
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
it('parses -w shorthand for --workspace', async () => {
|
|
236
|
+
const program = freshProgram();
|
|
237
|
+
const runtimeCmd = program.command('runtime');
|
|
238
|
+
const activationCmd = runtimeCmd.command('activation', { hidden: true });
|
|
239
|
+
const dispatchCmd = registerRuntimeActivationDispatchCommand(activationCmd);
|
|
240
|
+
const captured: CapturedAction = { opts: null };
|
|
241
|
+
attachCapture(dispatchCmd, captured);
|
|
242
|
+
|
|
243
|
+
await program.parseAsync(['node', 'pd', 'runtime', 'activation', 'dispatch', '-w', '/tmp/test']);
|
|
244
|
+
|
|
245
|
+
expect(captured.opts).not.toBeNull();
|
|
246
|
+
expect(captured.opts?.workspace).toBe('/tmp/test');
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
it("channel defaults to 'prompt' when not specified", async () => {
|
|
250
|
+
const program = freshProgram();
|
|
251
|
+
const runtimeCmd = program.command('runtime');
|
|
252
|
+
const activationCmd = runtimeCmd.command('activation', { hidden: true });
|
|
253
|
+
const dispatchCmd = registerRuntimeActivationDispatchCommand(activationCmd);
|
|
254
|
+
const captured: CapturedAction = { opts: null };
|
|
255
|
+
attachCapture(dispatchCmd, captured);
|
|
256
|
+
|
|
257
|
+
await program.parseAsync(['node', 'pd', 'runtime', 'activation', 'dispatch']);
|
|
258
|
+
|
|
259
|
+
expect(captured.opts).not.toBeNull();
|
|
260
|
+
expect(captured.opts?.channel).toBe('prompt');
|
|
261
|
+
});
|
|
262
|
+
});
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parser-level tests for `pd activation list` flags (CLI gate rule 7).
|
|
3
|
+
*
|
|
4
|
+
* Mirrors `runtime-activation-promote-flag-wiring.test.ts`. Exercises the real
|
|
5
|
+
* `registerRuntimeActivationListCommand` helper (single source of truth
|
|
6
|
+
* shared with `index.ts`). Flag typos in production surface here at
|
|
7
|
+
* parseAsync time, not at handler dispatch.
|
|
8
|
+
*
|
|
9
|
+
* Covers:
|
|
10
|
+
* - --json is registered
|
|
11
|
+
* - --workspace / -w and --channel / -c shorthand flags are registered
|
|
12
|
+
* - --include-deactivated is registered
|
|
13
|
+
* - --dry-run / --confirm / --no-json are NOT registered
|
|
14
|
+
*
|
|
15
|
+
* Handler-level behavior (filtering, JSON output shape) is covered by
|
|
16
|
+
* runtime-activation.test.ts.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { describe, it, expect } from 'vitest';
|
|
20
|
+
import { Command } from 'commander';
|
|
21
|
+
|
|
22
|
+
import { registerRuntimeActivationListCommand } from '../../src/commands/runtime-activation.js';
|
|
23
|
+
|
|
24
|
+
type ActionOptions = Record<string, unknown>;
|
|
25
|
+
|
|
26
|
+
interface CapturedAction {
|
|
27
|
+
opts: ActionOptions | null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function attachCapture(cmd: Command, state: CapturedAction): void {
|
|
31
|
+
cmd.action(function captureAction(...args: unknown[]): void {
|
|
32
|
+
let optsArg: unknown = null;
|
|
33
|
+
for (let i = args.length - 1; i >= 0; i--) {
|
|
34
|
+
const arg: unknown = args[i];
|
|
35
|
+
if (arg !== null && typeof arg === 'object' && !(arg instanceof Command)) {
|
|
36
|
+
optsArg = arg;
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (optsArg !== null && typeof optsArg === 'object') {
|
|
41
|
+
state.opts = optsArg as ActionOptions;
|
|
42
|
+
} else {
|
|
43
|
+
state.opts = {};
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function freshProgram(): Command {
|
|
49
|
+
const program = new Command();
|
|
50
|
+
program.name('pd').exitOverride();
|
|
51
|
+
return program;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
describe('pd activation list — flag wiring (CLI gate rule 7)', () => {
|
|
55
|
+
// ── Option metadata ──────────────────────────────────────────────────────
|
|
56
|
+
|
|
57
|
+
it('registers --json flag', () => {
|
|
58
|
+
const program = freshProgram();
|
|
59
|
+
const activationCmd = program.command('activation');
|
|
60
|
+
const listCmd = registerRuntimeActivationListCommand(activationCmd);
|
|
61
|
+
|
|
62
|
+
const opt = listCmd.options.find((o) => o.long === '--json');
|
|
63
|
+
expect(opt).toBeDefined();
|
|
64
|
+
expect(opt?.long).toBe('--json');
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('registers -w shorthand for --workspace', () => {
|
|
68
|
+
const program = freshProgram();
|
|
69
|
+
const activationCmd = program.command('activation');
|
|
70
|
+
const listCmd = registerRuntimeActivationListCommand(activationCmd);
|
|
71
|
+
|
|
72
|
+
const opt = listCmd.options.find((o) => o.short === '-w');
|
|
73
|
+
expect(opt).toBeDefined();
|
|
74
|
+
expect(opt?.long).toBe('--workspace');
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('registers -c shorthand for --channel', () => {
|
|
78
|
+
const program = freshProgram();
|
|
79
|
+
const activationCmd = program.command('activation');
|
|
80
|
+
const listCmd = registerRuntimeActivationListCommand(activationCmd);
|
|
81
|
+
|
|
82
|
+
const opt = listCmd.options.find((o) => o.short === '-c');
|
|
83
|
+
expect(opt).toBeDefined();
|
|
84
|
+
expect(opt?.long).toBe('--channel');
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('registers --include-deactivated', () => {
|
|
88
|
+
const program = freshProgram();
|
|
89
|
+
const activationCmd = program.command('activation');
|
|
90
|
+
const listCmd = registerRuntimeActivationListCommand(activationCmd);
|
|
91
|
+
|
|
92
|
+
const opt = listCmd.options.find((o) => o.long === '--include-deactivated');
|
|
93
|
+
expect(opt).toBeDefined();
|
|
94
|
+
expect(opt?.long).toBe('--include-deactivated');
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('does NOT register --dry-run', () => {
|
|
98
|
+
const program = freshProgram();
|
|
99
|
+
const activationCmd = program.command('activation');
|
|
100
|
+
const listCmd = registerRuntimeActivationListCommand(activationCmd);
|
|
101
|
+
|
|
102
|
+
const opt = listCmd.options.find((o) => o.long === '--dry-run');
|
|
103
|
+
expect(opt).toBeUndefined();
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it('does NOT register --confirm', () => {
|
|
107
|
+
const program = freshProgram();
|
|
108
|
+
const activationCmd = program.command('activation');
|
|
109
|
+
const listCmd = registerRuntimeActivationListCommand(activationCmd);
|
|
110
|
+
|
|
111
|
+
const opt = listCmd.options.find((o) => o.long === '--confirm');
|
|
112
|
+
expect(opt).toBeUndefined();
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it('does NOT register --no-json (no accidental negation)', () => {
|
|
116
|
+
const program = freshProgram();
|
|
117
|
+
const activationCmd = program.command('activation');
|
|
118
|
+
const listCmd = registerRuntimeActivationListCommand(activationCmd);
|
|
119
|
+
|
|
120
|
+
const noForm = listCmd.options.find((o) => o.long === '--no-json');
|
|
121
|
+
expect(noForm).toBeUndefined();
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
// ── Parser-level tests (program.parseAsync) ───────────────────────────────
|
|
125
|
+
|
|
126
|
+
it('parses --json as true', async () => {
|
|
127
|
+
const program = freshProgram();
|
|
128
|
+
const activationCmd = program.command('activation');
|
|
129
|
+
const listCmd = registerRuntimeActivationListCommand(activationCmd);
|
|
130
|
+
const captured: CapturedAction = { opts: null };
|
|
131
|
+
attachCapture(listCmd, captured);
|
|
132
|
+
|
|
133
|
+
await program.parseAsync(['node', 'pd', 'activation', 'list', '--json']);
|
|
134
|
+
|
|
135
|
+
expect(captured.opts).not.toBeNull();
|
|
136
|
+
expect(captured.opts?.json).toBe(true);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it('parses -w shorthand for --workspace', async () => {
|
|
140
|
+
const program = freshProgram();
|
|
141
|
+
const activationCmd = program.command('activation');
|
|
142
|
+
const listCmd = registerRuntimeActivationListCommand(activationCmd);
|
|
143
|
+
const captured: CapturedAction = { opts: null };
|
|
144
|
+
attachCapture(listCmd, captured);
|
|
145
|
+
|
|
146
|
+
await program.parseAsync(['node', 'pd', 'activation', 'list', '-w', '/tmp/test']);
|
|
147
|
+
|
|
148
|
+
expect(captured.opts).not.toBeNull();
|
|
149
|
+
expect(captured.opts?.workspace).toBe('/tmp/test');
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it('parses -c shorthand for --channel', async () => {
|
|
153
|
+
const program = freshProgram();
|
|
154
|
+
const activationCmd = program.command('activation');
|
|
155
|
+
const listCmd = registerRuntimeActivationListCommand(activationCmd);
|
|
156
|
+
const captured: CapturedAction = { opts: null };
|
|
157
|
+
attachCapture(listCmd, captured);
|
|
158
|
+
|
|
159
|
+
await program.parseAsync(['node', 'pd', 'activation', 'list', '-c', 'prompt']);
|
|
160
|
+
|
|
161
|
+
expect(captured.opts).not.toBeNull();
|
|
162
|
+
expect(captured.opts?.channel).toBe('prompt');
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it('parses --include-deactivated as true', async () => {
|
|
166
|
+
const program = freshProgram();
|
|
167
|
+
const activationCmd = program.command('activation');
|
|
168
|
+
const listCmd = registerRuntimeActivationListCommand(activationCmd);
|
|
169
|
+
const captured: CapturedAction = { opts: null };
|
|
170
|
+
attachCapture(listCmd, captured);
|
|
171
|
+
|
|
172
|
+
await program.parseAsync(['node', 'pd', 'activation', 'list', '--include-deactivated']);
|
|
173
|
+
|
|
174
|
+
expect(captured.opts).not.toBeNull();
|
|
175
|
+
expect(captured.opts?.includeDeactivated).toBe(true);
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
it('defaults all flags to undefined when none passed', async () => {
|
|
179
|
+
const program = freshProgram();
|
|
180
|
+
const activationCmd = program.command('activation');
|
|
181
|
+
const listCmd = registerRuntimeActivationListCommand(activationCmd);
|
|
182
|
+
const captured: CapturedAction = { opts: null };
|
|
183
|
+
attachCapture(listCmd, captured);
|
|
184
|
+
|
|
185
|
+
await program.parseAsync(['node', 'pd', 'activation', 'list']);
|
|
186
|
+
|
|
187
|
+
expect(captured.opts).not.toBeNull();
|
|
188
|
+
expect(captured.opts?.json).toBeUndefined();
|
|
189
|
+
expect(captured.opts?.workspace).toBeUndefined();
|
|
190
|
+
expect(captured.opts?.channel).toBeUndefined();
|
|
191
|
+
expect(captured.opts?.includeDeactivated).toBeUndefined();
|
|
192
|
+
});
|
|
193
|
+
});
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parser-level tests for `pd activation promote` flags (CLI gate rule 7).
|
|
3
|
+
*
|
|
4
|
+
* Mirrors `run-rulehost-flag-wiring.test.ts`. Exercises the real
|
|
5
|
+
* `registerRuntimeActivationPromoteCommand` helper (single source of truth
|
|
6
|
+
* shared with `index.ts`). Flag typos in production surface here at
|
|
7
|
+
* parseAsync time, not at handler dispatch.
|
|
8
|
+
*
|
|
9
|
+
* Covers:
|
|
10
|
+
* - --dry-run and --confirm are registered
|
|
11
|
+
* - --json is registered
|
|
12
|
+
* - --activation-id is required (Commander rejects missing required option)
|
|
13
|
+
* - --workspace / -w shorthand is registered
|
|
14
|
+
* - --no-dry-run / --no-confirm are NOT registered (no accidental negation)
|
|
15
|
+
*
|
|
16
|
+
* Handler-level behavior (mutual exclusivity enforcement, JSON output shape,
|
|
17
|
+
* refusal reasons) is covered by runtime-activation.test.ts.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { describe, it, expect } from 'vitest';
|
|
21
|
+
import { Command } from 'commander';
|
|
22
|
+
|
|
23
|
+
import { registerRuntimeActivationPromoteCommand } from '../../src/commands/runtime-activation.js';
|
|
24
|
+
|
|
25
|
+
type ActionOptions = Record<string, unknown>;
|
|
26
|
+
|
|
27
|
+
interface CapturedAction {
|
|
28
|
+
opts: ActionOptions | null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function attachCapture(cmd: Command, state: CapturedAction): void {
|
|
32
|
+
cmd.action(function captureAction(...args: unknown[]): void {
|
|
33
|
+
let optsArg: unknown = null;
|
|
34
|
+
for (let i = args.length - 1; i >= 0; i--) {
|
|
35
|
+
const arg: unknown = args[i];
|
|
36
|
+
if (arg !== null && typeof arg === 'object' && !(arg instanceof Command)) {
|
|
37
|
+
optsArg = arg;
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (optsArg !== null && typeof optsArg === 'object') {
|
|
42
|
+
state.opts = optsArg as ActionOptions;
|
|
43
|
+
} else {
|
|
44
|
+
state.opts = {};
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function freshProgram(): Command {
|
|
50
|
+
const program = new Command();
|
|
51
|
+
program.name('pd').exitOverride();
|
|
52
|
+
return program;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
describe('pd activation promote — flag wiring (CLI gate rule 7)', () => {
|
|
56
|
+
// ── Option metadata ──────────────────────────────────────────────────────
|
|
57
|
+
|
|
58
|
+
it('registers --dry-run flag', () => {
|
|
59
|
+
const program = freshProgram();
|
|
60
|
+
const activationCmd = program.command('activation');
|
|
61
|
+
const promoteCmd = registerRuntimeActivationPromoteCommand(activationCmd);
|
|
62
|
+
|
|
63
|
+
const opt = promoteCmd.options.find((o) => o.long === '--dry-run');
|
|
64
|
+
expect(opt).toBeDefined();
|
|
65
|
+
expect(opt?.long).toBe('--dry-run');
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('registers --confirm flag', () => {
|
|
69
|
+
const program = freshProgram();
|
|
70
|
+
const activationCmd = program.command('activation');
|
|
71
|
+
const promoteCmd = registerRuntimeActivationPromoteCommand(activationCmd);
|
|
72
|
+
|
|
73
|
+
const opt = promoteCmd.options.find((o) => o.long === '--confirm');
|
|
74
|
+
expect(opt).toBeDefined();
|
|
75
|
+
expect(opt?.long).toBe('--confirm');
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('registers --json flag', () => {
|
|
79
|
+
const program = freshProgram();
|
|
80
|
+
const activationCmd = program.command('activation');
|
|
81
|
+
const promoteCmd = registerRuntimeActivationPromoteCommand(activationCmd);
|
|
82
|
+
|
|
83
|
+
const opt = promoteCmd.options.find((o) => o.long === '--json');
|
|
84
|
+
expect(opt).toBeDefined();
|
|
85
|
+
expect(opt?.long).toBe('--json');
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('registers --activation-id as required option', () => {
|
|
89
|
+
const program = freshProgram();
|
|
90
|
+
const activationCmd = program.command('activation');
|
|
91
|
+
const promoteCmd = registerRuntimeActivationPromoteCommand(activationCmd);
|
|
92
|
+
|
|
93
|
+
const opt = promoteCmd.options.find((o) => o.long === '--activation-id');
|
|
94
|
+
expect(opt).toBeDefined();
|
|
95
|
+
expect(opt?.long).toBe('--activation-id');
|
|
96
|
+
expect(opt?.required).toBe(true);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('registers -w shorthand for --workspace', () => {
|
|
100
|
+
const program = freshProgram();
|
|
101
|
+
const activationCmd = program.command('activation');
|
|
102
|
+
const promoteCmd = registerRuntimeActivationPromoteCommand(activationCmd);
|
|
103
|
+
|
|
104
|
+
const opt = promoteCmd.options.find((o) => o.short === '-w');
|
|
105
|
+
expect(opt).toBeDefined();
|
|
106
|
+
expect(opt?.long).toBe('--workspace');
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('does NOT register --no-dry-run (no accidental negation)', () => {
|
|
110
|
+
const program = freshProgram();
|
|
111
|
+
const activationCmd = program.command('activation');
|
|
112
|
+
const promoteCmd = registerRuntimeActivationPromoteCommand(activationCmd);
|
|
113
|
+
|
|
114
|
+
const noForm = promoteCmd.options.find((o) => o.long === '--no-dry-run');
|
|
115
|
+
expect(noForm).toBeUndefined();
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it('does NOT register --no-confirm (no accidental negation)', () => {
|
|
119
|
+
const program = freshProgram();
|
|
120
|
+
const activationCmd = program.command('activation');
|
|
121
|
+
const promoteCmd = registerRuntimeActivationPromoteCommand(activationCmd);
|
|
122
|
+
|
|
123
|
+
const noForm = promoteCmd.options.find((o) => o.long === '--no-confirm');
|
|
124
|
+
expect(noForm).toBeUndefined();
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
// ── Parser-level tests (program.parseAsync) ───────────────────────────────
|
|
128
|
+
|
|
129
|
+
it('parses --dry-run as true', async () => {
|
|
130
|
+
const program = freshProgram();
|
|
131
|
+
const activationCmd = program.command('activation');
|
|
132
|
+
const promoteCmd = registerRuntimeActivationPromoteCommand(activationCmd);
|
|
133
|
+
const captured: CapturedAction = { opts: null };
|
|
134
|
+
attachCapture(promoteCmd, captured);
|
|
135
|
+
|
|
136
|
+
await program.parseAsync(['node', 'pd', 'activation', 'promote', '--activation-id', 'act-1', '--dry-run']);
|
|
137
|
+
|
|
138
|
+
expect(captured.opts).not.toBeNull();
|
|
139
|
+
expect(captured.opts?.dryRun).toBe(true);
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it('parses --confirm as true', async () => {
|
|
143
|
+
const program = freshProgram();
|
|
144
|
+
const activationCmd = program.command('activation');
|
|
145
|
+
const promoteCmd = registerRuntimeActivationPromoteCommand(activationCmd);
|
|
146
|
+
const captured: CapturedAction = { opts: null };
|
|
147
|
+
attachCapture(promoteCmd, captured);
|
|
148
|
+
|
|
149
|
+
await program.parseAsync(['node', 'pd', 'activation', 'promote', '--activation-id', 'act-1', '--confirm']);
|
|
150
|
+
|
|
151
|
+
expect(captured.opts).not.toBeNull();
|
|
152
|
+
expect(captured.opts?.confirm).toBe(true);
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it('parses both --dry-run and --confirm (handler enforces mutual exclusivity)', async () => {
|
|
156
|
+
// Commander parses both flags; the handler validates mutual exclusivity.
|
|
157
|
+
// This test proves the parser accepts both — the handler test in
|
|
158
|
+
// runtime-activation.test.ts proves the handler rejects the combination.
|
|
159
|
+
const program = freshProgram();
|
|
160
|
+
const activationCmd = program.command('activation');
|
|
161
|
+
const promoteCmd = registerRuntimeActivationPromoteCommand(activationCmd);
|
|
162
|
+
const captured: CapturedAction = { opts: null };
|
|
163
|
+
attachCapture(promoteCmd, captured);
|
|
164
|
+
|
|
165
|
+
await program.parseAsync(['node', 'pd', 'activation', 'promote', '--activation-id', 'act-1', '--dry-run', '--confirm']);
|
|
166
|
+
|
|
167
|
+
expect(captured.opts).not.toBeNull();
|
|
168
|
+
expect(captured.opts?.dryRun).toBe(true);
|
|
169
|
+
expect(captured.opts?.confirm).toBe(true);
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it('defaults --dry-run and --confirm to undefined when neither is passed', async () => {
|
|
173
|
+
const program = freshProgram();
|
|
174
|
+
const activationCmd = program.command('activation');
|
|
175
|
+
const promoteCmd = registerRuntimeActivationPromoteCommand(activationCmd);
|
|
176
|
+
const captured: CapturedAction = { opts: null };
|
|
177
|
+
attachCapture(promoteCmd, captured);
|
|
178
|
+
|
|
179
|
+
await program.parseAsync(['node', 'pd', 'activation', 'promote', '--activation-id', 'act-1']);
|
|
180
|
+
|
|
181
|
+
expect(captured.opts).not.toBeNull();
|
|
182
|
+
expect(captured.opts?.dryRun).toBeUndefined();
|
|
183
|
+
expect(captured.opts?.confirm).toBeUndefined();
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
it('parses --json as true', async () => {
|
|
187
|
+
const program = freshProgram();
|
|
188
|
+
const activationCmd = program.command('activation');
|
|
189
|
+
const promoteCmd = registerRuntimeActivationPromoteCommand(activationCmd);
|
|
190
|
+
const captured: CapturedAction = { opts: null };
|
|
191
|
+
attachCapture(promoteCmd, captured);
|
|
192
|
+
|
|
193
|
+
await program.parseAsync(['node', 'pd', 'activation', 'promote', '--activation-id', 'act-1', '--json']);
|
|
194
|
+
|
|
195
|
+
expect(captured.opts).not.toBeNull();
|
|
196
|
+
expect(captured.opts?.json).toBe(true);
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it('parses -w shorthand for --workspace', async () => {
|
|
200
|
+
const program = freshProgram();
|
|
201
|
+
const activationCmd = program.command('activation');
|
|
202
|
+
const promoteCmd = registerRuntimeActivationPromoteCommand(activationCmd);
|
|
203
|
+
const captured: CapturedAction = { opts: null };
|
|
204
|
+
attachCapture(promoteCmd, captured);
|
|
205
|
+
|
|
206
|
+
await program.parseAsync(['node', 'pd', 'activation', 'promote', '--activation-id', 'act-1', '-w', '/tmp/test']);
|
|
207
|
+
|
|
208
|
+
expect(captured.opts).not.toBeNull();
|
|
209
|
+
expect(captured.opts?.workspace).toBe('/tmp/test');
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
it('rejects missing --activation-id (required option)', async () => {
|
|
213
|
+
const program = freshProgram();
|
|
214
|
+
const activationCmd = program.command('activation');
|
|
215
|
+
registerRuntimeActivationPromoteCommand(activationCmd);
|
|
216
|
+
|
|
217
|
+
// Commander should throw on missing required option
|
|
218
|
+
await expect(
|
|
219
|
+
program.parseAsync(['node', 'pd', 'activation', 'promote', '--dry-run']),
|
|
220
|
+
).rejects.toThrow(/activation-id/);
|
|
221
|
+
});
|
|
222
|
+
});
|