@tiangong-lca/cli 0.0.4 → 0.0.6
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/README.md +31 -23
- package/bin/tiangong.js +15 -2
- package/dist/src/cli.js +256 -7
- package/dist/src/cli.js.map +1 -1
- package/dist/src/lib/dataset-command.js +115 -96
- package/dist/src/lib/dataset-command.js.map +1 -1
- package/dist/src/lib/flow-publish-version.js +13 -13
- package/dist/src/lib/flow-publish-version.js.map +1 -1
- package/dist/src/lib/http.js +19 -0
- package/dist/src/lib/http.js.map +1 -1
- package/dist/src/lib/lifecyclemodel-bundle-save.js +468 -0
- package/dist/src/lib/lifecyclemodel-bundle-save.js.map +1 -0
- package/dist/src/lib/lifecyclemodel-publish-build.js +3 -1
- package/dist/src/lib/lifecyclemodel-publish-build.js.map +1 -1
- package/dist/src/lib/package-version.js +23 -0
- package/dist/src/lib/package-version.js.map +1 -0
- package/dist/src/lib/process-list.js +337 -0
- package/dist/src/lib/process-list.js.map +1 -0
- package/dist/src/lib/process-save-draft-run.js +325 -0
- package/dist/src/lib/process-save-draft-run.js.map +1 -0
- package/dist/src/lib/process-save-draft.js +165 -0
- package/dist/src/lib/process-save-draft.js.map +1 -0
- package/dist/src/lib/publish.js +81 -13
- package/dist/src/lib/publish.js.map +1 -1
- package/dist/src/lib/review-process.js +180 -9
- package/dist/src/lib/review-process.js.map +1 -1
- package/dist/src/lib/supabase-json-ordered-write.js +14 -32
- package/dist/src/lib/supabase-json-ordered-write.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,19 +4,21 @@ Package: `@tiangong-lca/cli` Executable: `tiangong` Node: `24.x`
|
|
|
4
4
|
|
|
5
5
|
## Run
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
One-off published run:
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
npm exec --yes --package=@tiangong-lca/cli@latest -- tiangong --help
|
|
11
|
+
npm exec --yes --package=@tiangong-lca/cli@latest -- tiangong doctor
|
|
12
|
+
npm exec --yes --package=@tiangong-lca/cli@latest -- tiangong flow --help
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
Install the published CLI:
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
18
|
npm install --global @tiangong-lca/cli
|
|
19
19
|
tiangong --help
|
|
20
|
+
tiangong doctor
|
|
21
|
+
tiangong flow --help
|
|
20
22
|
```
|
|
21
23
|
|
|
22
24
|
Run from this repository:
|
|
@@ -76,9 +78,9 @@ Minimal `search flow` request:
|
|
|
76
78
|
Run:
|
|
77
79
|
|
|
78
80
|
```bash
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
81
|
+
tiangong search flow --input ./search-flow.request.json --json
|
|
82
|
+
tiangong search process --input ./search-process.request.json --json
|
|
83
|
+
tiangong search lifecyclemodel --input ./search-lifecyclemodel.request.json --json
|
|
82
84
|
```
|
|
83
85
|
|
|
84
86
|
Empty search results should be treated as empty whether the response is `[]` or `{"data":[]}`.
|
|
@@ -86,9 +88,10 @@ Empty search results should be treated as empty whether the response is `[]` or
|
|
|
86
88
|
## Read
|
|
87
89
|
|
|
88
90
|
```bash
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
91
|
+
tiangong flow get --id <flow-id> --version <version> --json
|
|
92
|
+
tiangong flow list --id <flow-id> --state-code 100 --limit 20 --json
|
|
93
|
+
tiangong process get --id <process-id> --version <version> --json
|
|
94
|
+
tiangong process list --state-code 100 --limit 20 --json
|
|
92
95
|
```
|
|
93
96
|
|
|
94
97
|
## Real DB Flow Review
|
|
@@ -135,15 +138,15 @@ npx -y @tiangong-lca/cli@latest process get --id <process-id> --version <version
|
|
|
135
138
|
Run:
|
|
136
139
|
|
|
137
140
|
```bash
|
|
138
|
-
|
|
141
|
+
tiangong flow fetch-rows \
|
|
139
142
|
--refs-file ./flow-refs.json \
|
|
140
143
|
--out-dir ./flow-fetch
|
|
141
144
|
|
|
142
|
-
|
|
145
|
+
tiangong review flow \
|
|
143
146
|
--rows-file ./flow-fetch/review-input-rows.jsonl \
|
|
144
147
|
--out-dir ./flow-review
|
|
145
148
|
|
|
146
|
-
|
|
149
|
+
tiangong flow materialize-decisions \
|
|
147
150
|
--decision-file ./approved-decisions.json \
|
|
148
151
|
--flow-rows-file ./flow-fetch/review-input-rows.jsonl \
|
|
149
152
|
--out-dir ./flow-decisions
|
|
@@ -167,11 +170,16 @@ Key `flow materialize-decisions` outputs:
|
|
|
167
170
|
## Other Common Commands
|
|
168
171
|
|
|
169
172
|
```bash
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
+
tiangong review process --rows-file ./process-list-report.json --out-dir ./review
|
|
174
|
+
tiangong review process --run-root ./artifacts/process_from_flow/<run_id> --run-id <run_id> --out-dir ./review
|
|
175
|
+
tiangong publish run --input ./publish-request.json --dry-run
|
|
176
|
+
tiangong doctor --json
|
|
173
177
|
```
|
|
174
178
|
|
|
179
|
+
For `publish run`, relative `out_dir` values from either the request body or `--out-dir` are resolved against the request file directory, not the shell `cwd`. Use an absolute path when you want a fixed destination independent of the request file location.
|
|
180
|
+
|
|
181
|
+
For `review process`, `--rows-file` accepts either raw process rows as JSON/JSONL or the full JSON report emitted by `tiangong process list --json`, as long as it contains a `rows` array.
|
|
182
|
+
|
|
175
183
|
## More Docs
|
|
176
184
|
|
|
177
185
|
- `docs/IMPLEMENTATION_GUIDE_CN.md`: maintainer-facing command contract and implementation notes
|
|
@@ -181,10 +189,10 @@ npx -y @tiangong-lca/cli@latest doctor --json
|
|
|
181
189
|
## Help
|
|
182
190
|
|
|
183
191
|
```bash
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
192
|
+
tiangong --help
|
|
193
|
+
tiangong flow --help
|
|
194
|
+
tiangong review --help
|
|
195
|
+
tiangong process --help
|
|
196
|
+
tiangong lifecyclemodel --help
|
|
197
|
+
tiangong publish --help
|
|
190
198
|
```
|
package/bin/tiangong.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import { existsSync } from 'node:fs';
|
|
3
|
+
import { existsSync, realpathSync } from 'node:fs';
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import process from 'node:process';
|
|
6
6
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
@@ -8,6 +8,19 @@ import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
|
8
8
|
const rootDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
9
9
|
const entryPath = path.join(rootDir, 'dist', 'src', 'main.js');
|
|
10
10
|
|
|
11
|
+
export function resolveInvokedUrl(argv1 = process.argv[1]) {
|
|
12
|
+
if (!argv1) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const resolvedPath = path.resolve(argv1);
|
|
17
|
+
try {
|
|
18
|
+
return pathToFileURL(realpathSync(resolvedPath)).href;
|
|
19
|
+
} catch {
|
|
20
|
+
return pathToFileURL(resolvedPath).href;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
11
24
|
export async function runFromBin(argv = process.argv.slice(2), env = process.env) {
|
|
12
25
|
if (!existsSync(entryPath)) {
|
|
13
26
|
throw new Error(
|
|
@@ -20,7 +33,7 @@ export async function runFromBin(argv = process.argv.slice(2), env = process.env
|
|
|
20
33
|
return main(argv, env);
|
|
21
34
|
}
|
|
22
35
|
|
|
23
|
-
const invokedUrl =
|
|
36
|
+
const invokedUrl = resolveInvokedUrl(process.argv[1]);
|
|
24
37
|
|
|
25
38
|
if (invokedUrl && import.meta.url === invokedUrl) {
|
|
26
39
|
try {
|
package/dist/src/cli.js
CHANGED
|
@@ -2,6 +2,7 @@ import { parseArgs } from 'node:util';
|
|
|
2
2
|
import { buildDoctorReport, readRuntimeEnv } from './lib/env.js';
|
|
3
3
|
import { CliError, toErrorPayload } from './lib/errors.js';
|
|
4
4
|
import { stringifyJson } from './lib/io.js';
|
|
5
|
+
import { loadCliPackageVersion } from './lib/package-version.js';
|
|
5
6
|
import { runLifecyclemodelAutoBuild, } from './lib/lifecyclemodel-auto-build.js';
|
|
6
7
|
import { runLifecyclemodelBuildResultingProcess, } from './lib/lifecyclemodel-resulting-process.js';
|
|
7
8
|
import { runLifecyclemodelPublishResultingProcess, } from './lib/lifecyclemodel-publish-resulting-process.js';
|
|
@@ -10,9 +11,11 @@ import { runLifecyclemodelPublishBuild, } from './lib/lifecyclemodel-publish-bui
|
|
|
10
11
|
import { runLifecyclemodelOrchestrate, } from './lib/lifecyclemodel-orchestrate.js';
|
|
11
12
|
import { runProcessAutoBuild, } from './lib/process-auto-build.js';
|
|
12
13
|
import { runProcessGet, } from './lib/process-get.js';
|
|
14
|
+
import { runProcessList, } from './lib/process-list.js';
|
|
13
15
|
import { runProcessBatchBuild, } from './lib/process-batch-build.js';
|
|
14
16
|
import { runProcessResumeBuild, } from './lib/process-resume-build.js';
|
|
15
17
|
import { runProcessPublishBuild, } from './lib/process-publish-build.js';
|
|
18
|
+
import { runProcessSaveDraft, } from './lib/process-save-draft-run.js';
|
|
16
19
|
import { runPublish } from './lib/publish.js';
|
|
17
20
|
import { runProcessReview, } from './lib/review-process.js';
|
|
18
21
|
import { runFlowReview, } from './lib/review-flow.js';
|
|
@@ -46,7 +49,7 @@ Commands:
|
|
|
46
49
|
Implemented Commands:
|
|
47
50
|
doctor show environment diagnostics
|
|
48
51
|
search flow | process | lifecyclemodel
|
|
49
|
-
process get | auto-build | resume-build | publish-build | batch-build
|
|
52
|
+
process get | list | auto-build | resume-build | publish-build | save-draft | batch-build
|
|
50
53
|
flow get | list | fetch-rows | materialize-decisions | remediate | publish-version | publish-reviewed-data | build-alias-map | scan-process-flow-refs | plan-process-flow-repairs | apply-process-flow-repairs | regen-product | validate-processes
|
|
51
54
|
lifecyclemodel auto-build | validate-build | publish-build | build-resulting-process | publish-resulting-process | orchestrate
|
|
52
55
|
review process | flow | lifecyclemodel
|
|
@@ -65,9 +68,11 @@ Examples:
|
|
|
65
68
|
tiangong search flow --input ./request.json
|
|
66
69
|
tiangong search process --input ./request.json --dry-run
|
|
67
70
|
tiangong process get --id <process-id>
|
|
71
|
+
tiangong process list --state-code 100 --limit 20
|
|
68
72
|
tiangong process auto-build --input ./pff-request.json
|
|
69
73
|
tiangong process resume-build --run-id <id>
|
|
70
74
|
tiangong process publish-build --run-id <id>
|
|
75
|
+
tiangong process save-draft --input ./patched-processes.jsonl --dry-run
|
|
71
76
|
tiangong process batch-build --input ./batch-request.json
|
|
72
77
|
tiangong lifecyclemodel auto-build --input ./lifecyclemodel-auto-build.request.json
|
|
73
78
|
tiangong lifecyclemodel validate-build --run-dir ./artifacts/lifecyclemodel_auto_build/<run_id>
|
|
@@ -86,6 +91,7 @@ Examples:
|
|
|
86
91
|
tiangong flow apply-process-flow-repairs --processes-file ./processes.jsonl --scope-flow-file ./flows.jsonl --out-dir ./flow-repair-apply
|
|
87
92
|
tiangong flow regen-product --processes-file ./processes.jsonl --scope-flow-file ./flows.jsonl --out-dir ./flow-regeneration --apply
|
|
88
93
|
tiangong flow validate-processes --original-processes-file ./before.jsonl --patched-processes-file ./after.jsonl --scope-flow-file ./flows.jsonl --out-dir ./flow-validation
|
|
94
|
+
tiangong review process --rows-file ./processes.jsonl --out-dir ./review
|
|
89
95
|
tiangong review process --run-root ./artifacts/process_from_flow/<run_id> --run-id <run_id> --out-dir ./review
|
|
90
96
|
tiangong review flow --rows-file ./flows.json --out-dir ./review
|
|
91
97
|
tiangong review lifecyclemodel --run-dir ./artifacts/lifecyclemodel_auto_build/<run_id> --out-dir ./lifecyclemodel-review
|
|
@@ -165,6 +171,9 @@ Options:
|
|
|
165
171
|
--dry-run Force publish.commit=false
|
|
166
172
|
--json Print compact JSON
|
|
167
173
|
-h, --help
|
|
174
|
+
|
|
175
|
+
Path rule:
|
|
176
|
+
Relative out_dir values from the request body or --out-dir resolve from the request file directory.
|
|
168
177
|
`.trim();
|
|
169
178
|
}
|
|
170
179
|
function renderValidationHelp() {
|
|
@@ -524,7 +533,7 @@ function renderReviewHelp() {
|
|
|
524
533
|
tiangong review <subcommand> [options]
|
|
525
534
|
|
|
526
535
|
Implemented Subcommands:
|
|
527
|
-
process Review
|
|
536
|
+
process Review process build runs or rows-file snapshots and emit artifact-first findings
|
|
528
537
|
flow Review local flow governance snapshots and emit artifact-first findings
|
|
529
538
|
lifecyclemodel Review one local lifecyclemodel build run and emit artifact-first findings
|
|
530
539
|
|
|
@@ -537,11 +546,12 @@ Examples:
|
|
|
537
546
|
}
|
|
538
547
|
function renderReviewProcessHelp() {
|
|
539
548
|
return `Usage:
|
|
540
|
-
tiangong review process --
|
|
549
|
+
tiangong review process (--rows-file <file> | --run-root <dir>) --out-dir <dir> [options]
|
|
541
550
|
|
|
542
551
|
Options:
|
|
552
|
+
--rows-file <file> Process rows JSON/JSONL file; full process list reports with rows[] are also accepted
|
|
543
553
|
--run-root <dir> Process build run root containing exports/processes
|
|
544
|
-
--run-id <id>
|
|
554
|
+
--run-id <id> Optional review run identifier; defaults to the rows-file name or run-root basename
|
|
545
555
|
--out-dir <dir> Review artifact output directory
|
|
546
556
|
--start-ts <iso> Optional run start timestamp
|
|
547
557
|
--end-ts <iso> Optional run end timestamp
|
|
@@ -721,6 +731,7 @@ This command:
|
|
|
721
731
|
- collects native lifecyclemodel json_ordered payloads from one local build run
|
|
722
732
|
- writes publish-bundle.json, publish-request.json, and publish-intent.json
|
|
723
733
|
- keeps actual dry-run / commit execution in tiangong publish run
|
|
734
|
+
- routes lifecyclemodel commit through save_lifecycle_model_bundle internally
|
|
724
735
|
`.trim();
|
|
725
736
|
}
|
|
726
737
|
function renderProcessAutoBuildHelp() {
|
|
@@ -749,6 +760,33 @@ Required env:
|
|
|
749
760
|
TIANGONG_LCA_API_KEY
|
|
750
761
|
TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY
|
|
751
762
|
|
|
763
|
+
Runtime note:
|
|
764
|
+
The CLI derives a native @supabase/supabase-js client and deterministic read target from TIANGONG_LCA_API_BASE_URL,
|
|
765
|
+
and authenticates that client with the resolved user access token.
|
|
766
|
+
`.trim();
|
|
767
|
+
}
|
|
768
|
+
function renderProcessListHelp() {
|
|
769
|
+
return `Usage:
|
|
770
|
+
tiangong process list [options]
|
|
771
|
+
|
|
772
|
+
Options:
|
|
773
|
+
--id <process-id> Repeatable exact process UUID filter
|
|
774
|
+
--version <version> Optional dataset version filter
|
|
775
|
+
--user-id <user-id> Optional owner filter for private rows
|
|
776
|
+
--state-code <code> Repeatable visibility filter such as 0 or 100
|
|
777
|
+
--order <expr> Deterministic PostgREST order expression (default: id.asc,version.asc)
|
|
778
|
+
--limit <n> Page size for one request (default: 100)
|
|
779
|
+
--offset <n> Row offset for one request (default: 0)
|
|
780
|
+
--all Fetch all matching rows via offset pagination
|
|
781
|
+
--page-size <n> Page size when --all is used (default: 100)
|
|
782
|
+
--json Print compact JSON
|
|
783
|
+
-h, --help
|
|
784
|
+
|
|
785
|
+
Required env:
|
|
786
|
+
TIANGONG_LCA_API_BASE_URL
|
|
787
|
+
TIANGONG_LCA_API_KEY
|
|
788
|
+
TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY
|
|
789
|
+
|
|
752
790
|
Runtime note:
|
|
753
791
|
The CLI derives a native @supabase/supabase-js client and deterministic read target from TIANGONG_LCA_API_BASE_URL,
|
|
754
792
|
and authenticates that client with the resolved user access token.
|
|
@@ -776,6 +814,31 @@ Options:
|
|
|
776
814
|
-h, --help
|
|
777
815
|
`.trim();
|
|
778
816
|
}
|
|
817
|
+
function renderProcessSaveDraftHelp() {
|
|
818
|
+
return `Usage:
|
|
819
|
+
tiangong process save-draft --input <file> [options]
|
|
820
|
+
|
|
821
|
+
Options:
|
|
822
|
+
--input <file> Process rows JSON/JSONL file or publish-request.json
|
|
823
|
+
--out-dir <dir> Run root written relative to cwd when a relative path is passed
|
|
824
|
+
--commit Execute remote save-draft writes
|
|
825
|
+
--dry-run Keep the command local-only (default)
|
|
826
|
+
--json Print compact JSON
|
|
827
|
+
-h, --help
|
|
828
|
+
|
|
829
|
+
Environment:
|
|
830
|
+
none for local dry-run
|
|
831
|
+
TIANGONG_LCA_API_BASE_URL, TIANGONG_LCA_API_KEY, and TIANGONG_LCA_SUPABASE_PUBLISHABLE_KEY
|
|
832
|
+
when --commit executes remote writes
|
|
833
|
+
|
|
834
|
+
Outputs written under --out-dir:
|
|
835
|
+
- inputs/normalized-input.json
|
|
836
|
+
- outputs/save-draft-rpc/selected-processes.jsonl
|
|
837
|
+
- outputs/save-draft-rpc/progress.jsonl
|
|
838
|
+
- outputs/save-draft-rpc/failures.jsonl
|
|
839
|
+
- outputs/save-draft-rpc/summary.json
|
|
840
|
+
`.trim();
|
|
841
|
+
}
|
|
779
842
|
function renderProcessBatchBuildHelp() {
|
|
780
843
|
return `Usage:
|
|
781
844
|
tiangong process batch-build --input <file> [options]
|
|
@@ -793,17 +856,21 @@ function renderProcessHelp() {
|
|
|
793
856
|
|
|
794
857
|
Implemented Subcommands:
|
|
795
858
|
get Load one process dataset by identifier through direct Supabase access
|
|
859
|
+
list List visible process rows through direct Supabase access
|
|
796
860
|
auto-build Prepare a local process-from-flow run scaffold and artifact workspace
|
|
797
861
|
resume-build Prepare a local resume handoff from one existing process build run
|
|
798
862
|
publish-build Prepare publish handoff artifacts from one existing process build run
|
|
863
|
+
save-draft Save canonical process datasets through the state-aware draft-maintenance path
|
|
799
864
|
batch-build Run multiple process auto-build requests through one batch-oriented CLI surface
|
|
800
865
|
|
|
801
866
|
Examples:
|
|
802
867
|
tiangong process --help
|
|
803
868
|
tiangong process get --id <process-id>
|
|
869
|
+
tiangong process list --state-code 100 --limit 20 --help
|
|
804
870
|
tiangong process auto-build --help
|
|
805
871
|
tiangong process resume-build --run-id <id> --help
|
|
806
872
|
tiangong process publish-build --run-id <id> --help
|
|
873
|
+
tiangong process save-draft --input ./patched-processes.jsonl --help
|
|
807
874
|
tiangong process batch-build --input ./batch-request.json --help
|
|
808
875
|
`.trim();
|
|
809
876
|
}
|
|
@@ -1694,6 +1761,7 @@ function parseReviewProcessFlags(args) {
|
|
|
1694
1761
|
options: {
|
|
1695
1762
|
help: { type: 'boolean', short: 'h' },
|
|
1696
1763
|
json: { type: 'boolean' },
|
|
1764
|
+
'rows-file': { type: 'string' },
|
|
1697
1765
|
'run-root': { type: 'string' },
|
|
1698
1766
|
'run-id': { type: 'string' },
|
|
1699
1767
|
'out-dir': { type: 'string' },
|
|
@@ -1725,8 +1793,9 @@ function parseReviewProcessFlags(args) {
|
|
|
1725
1793
|
return {
|
|
1726
1794
|
help: Boolean(values.help),
|
|
1727
1795
|
json: Boolean(values.json),
|
|
1728
|
-
|
|
1729
|
-
|
|
1796
|
+
rowsFile: typeof values['rows-file'] === 'string' ? values['rows-file'] : undefined,
|
|
1797
|
+
runRoot: typeof values['run-root'] === 'string' ? values['run-root'] : undefined,
|
|
1798
|
+
runId: typeof values['run-id'] === 'string' ? values['run-id'] : undefined,
|
|
1730
1799
|
outDir: typeof values['out-dir'] === 'string' ? values['out-dir'] : '',
|
|
1731
1800
|
startTs: typeof values['start-ts'] === 'string' ? values['start-ts'] : undefined,
|
|
1732
1801
|
endTs: typeof values['end-ts'] === 'string' ? values['end-ts'] : undefined,
|
|
@@ -2055,6 +2124,96 @@ function parseProcessGetFlags(args) {
|
|
|
2055
2124
|
version: typeof values.version === 'string' ? values.version : null,
|
|
2056
2125
|
};
|
|
2057
2126
|
}
|
|
2127
|
+
function parseProcessListFlags(args) {
|
|
2128
|
+
let values;
|
|
2129
|
+
try {
|
|
2130
|
+
({ values } = parseArgs({
|
|
2131
|
+
args,
|
|
2132
|
+
allowPositionals: false,
|
|
2133
|
+
strict: true,
|
|
2134
|
+
options: {
|
|
2135
|
+
help: { type: 'boolean', short: 'h' },
|
|
2136
|
+
json: { type: 'boolean' },
|
|
2137
|
+
id: { type: 'string', multiple: true },
|
|
2138
|
+
version: { type: 'string' },
|
|
2139
|
+
'user-id': { type: 'string' },
|
|
2140
|
+
'state-code': { type: 'string', multiple: true },
|
|
2141
|
+
limit: { type: 'string' },
|
|
2142
|
+
offset: { type: 'string' },
|
|
2143
|
+
all: { type: 'boolean' },
|
|
2144
|
+
'page-size': { type: 'string' },
|
|
2145
|
+
order: { type: 'string' },
|
|
2146
|
+
},
|
|
2147
|
+
}));
|
|
2148
|
+
}
|
|
2149
|
+
catch (error) {
|
|
2150
|
+
throw new CliError(String(error), {
|
|
2151
|
+
code: 'INVALID_ARGS',
|
|
2152
|
+
exitCode: 2,
|
|
2153
|
+
});
|
|
2154
|
+
}
|
|
2155
|
+
const parseOptionalPositiveIntegerFlag = (value, label, code) => {
|
|
2156
|
+
if (typeof value !== 'string') {
|
|
2157
|
+
return null;
|
|
2158
|
+
}
|
|
2159
|
+
const parsed = Number.parseInt(value, 10);
|
|
2160
|
+
if (!Number.isInteger(parsed) || parsed <= 0) {
|
|
2161
|
+
throw new CliError(`Expected ${label} to be a positive integer.`, {
|
|
2162
|
+
code,
|
|
2163
|
+
exitCode: 2,
|
|
2164
|
+
});
|
|
2165
|
+
}
|
|
2166
|
+
return parsed;
|
|
2167
|
+
};
|
|
2168
|
+
const parseOptionalNonNegativeIntegerFlag = (value, label, code) => {
|
|
2169
|
+
if (typeof value !== 'string') {
|
|
2170
|
+
return null;
|
|
2171
|
+
}
|
|
2172
|
+
const parsed = Number.parseInt(value, 10);
|
|
2173
|
+
if (!Number.isInteger(parsed) || parsed < 0) {
|
|
2174
|
+
throw new CliError(`Expected ${label} to be a non-negative integer.`, {
|
|
2175
|
+
code,
|
|
2176
|
+
exitCode: 2,
|
|
2177
|
+
});
|
|
2178
|
+
}
|
|
2179
|
+
return parsed;
|
|
2180
|
+
};
|
|
2181
|
+
const parseStateCodeValues = (value) => {
|
|
2182
|
+
if (!Array.isArray(value)) {
|
|
2183
|
+
return [];
|
|
2184
|
+
}
|
|
2185
|
+
return value.map((entry) => {
|
|
2186
|
+
const parsed = Number.parseInt(String(entry), 10);
|
|
2187
|
+
if (!Number.isInteger(parsed) || parsed < 0) {
|
|
2188
|
+
throw new CliError('Expected --state-code to be a non-negative integer.', {
|
|
2189
|
+
code: 'INVALID_PROCESS_LIST_STATE_CODE',
|
|
2190
|
+
exitCode: 2,
|
|
2191
|
+
});
|
|
2192
|
+
}
|
|
2193
|
+
return parsed;
|
|
2194
|
+
});
|
|
2195
|
+
};
|
|
2196
|
+
const toStringArray = (value) => Array.isArray(value) ? value.filter((entry) => typeof entry === 'string') : [];
|
|
2197
|
+
if (values['page-size'] !== undefined && !values.all) {
|
|
2198
|
+
throw new CliError('Use --page-size only with --all.', {
|
|
2199
|
+
code: 'PROCESS_LIST_PAGE_SIZE_REQUIRES_ALL',
|
|
2200
|
+
exitCode: 2,
|
|
2201
|
+
});
|
|
2202
|
+
}
|
|
2203
|
+
return {
|
|
2204
|
+
help: Boolean(values.help),
|
|
2205
|
+
json: Boolean(values.json),
|
|
2206
|
+
ids: toStringArray(values.id),
|
|
2207
|
+
version: typeof values.version === 'string' ? values.version : null,
|
|
2208
|
+
userId: typeof values['user-id'] === 'string' ? values['user-id'] : null,
|
|
2209
|
+
stateCodes: parseStateCodeValues(values['state-code']),
|
|
2210
|
+
limit: parseOptionalPositiveIntegerFlag(values.limit, '--limit', 'INVALID_PROCESS_LIST_LIMIT'),
|
|
2211
|
+
offset: parseOptionalNonNegativeIntegerFlag(values.offset, '--offset', 'INVALID_PROCESS_LIST_OFFSET'),
|
|
2212
|
+
all: Boolean(values.all),
|
|
2213
|
+
pageSize: parseOptionalPositiveIntegerFlag(values['page-size'], '--page-size', 'INVALID_PROCESS_LIST_PAGE_SIZE'),
|
|
2214
|
+
order: typeof values.order === 'string' ? values.order : null,
|
|
2215
|
+
};
|
|
2216
|
+
}
|
|
2058
2217
|
function parseProcessResumeBuildFlags(args) {
|
|
2059
2218
|
let values;
|
|
2060
2219
|
try {
|
|
@@ -2111,6 +2270,43 @@ function parseProcessPublishBuildFlags(args) {
|
|
|
2111
2270
|
runDir: typeof values['run-dir'] === 'string' ? values['run-dir'] : null,
|
|
2112
2271
|
};
|
|
2113
2272
|
}
|
|
2273
|
+
function parseProcessSaveDraftFlags(args) {
|
|
2274
|
+
let values;
|
|
2275
|
+
try {
|
|
2276
|
+
({ values } = parseArgs({
|
|
2277
|
+
args,
|
|
2278
|
+
allowPositionals: false,
|
|
2279
|
+
strict: true,
|
|
2280
|
+
options: {
|
|
2281
|
+
help: { type: 'boolean', short: 'h' },
|
|
2282
|
+
json: { type: 'boolean' },
|
|
2283
|
+
input: { type: 'string' },
|
|
2284
|
+
'out-dir': { type: 'string' },
|
|
2285
|
+
commit: { type: 'boolean' },
|
|
2286
|
+
'dry-run': { type: 'boolean' },
|
|
2287
|
+
},
|
|
2288
|
+
}));
|
|
2289
|
+
}
|
|
2290
|
+
catch (error) {
|
|
2291
|
+
throw new CliError(String(error), {
|
|
2292
|
+
code: 'INVALID_ARGS',
|
|
2293
|
+
exitCode: 2,
|
|
2294
|
+
});
|
|
2295
|
+
}
|
|
2296
|
+
if (values.commit && values['dry-run']) {
|
|
2297
|
+
throw new CliError('Cannot pass both --commit and --dry-run.', {
|
|
2298
|
+
code: 'INVALID_PROCESS_SAVE_DRAFT_MODE',
|
|
2299
|
+
exitCode: 2,
|
|
2300
|
+
});
|
|
2301
|
+
}
|
|
2302
|
+
return {
|
|
2303
|
+
help: Boolean(values.help),
|
|
2304
|
+
json: Boolean(values.json),
|
|
2305
|
+
inputPath: typeof values.input === 'string' ? values.input : '',
|
|
2306
|
+
outDir: typeof values['out-dir'] === 'string' ? values['out-dir'] : null,
|
|
2307
|
+
commit: Boolean(values.commit),
|
|
2308
|
+
};
|
|
2309
|
+
}
|
|
2114
2310
|
function parseProcessBatchBuildFlags(args) {
|
|
2115
2311
|
let values;
|
|
2116
2312
|
try {
|
|
@@ -2168,10 +2364,12 @@ export async function executeCli(argv, deps) {
|
|
|
2168
2364
|
const lifecyclemodelPublishBuildImpl = deps.runLifecyclemodelPublishBuildImpl ?? runLifecyclemodelPublishBuild;
|
|
2169
2365
|
const lifecyclemodelOrchestrateImpl = deps.runLifecyclemodelOrchestrateImpl ?? runLifecyclemodelOrchestrate;
|
|
2170
2366
|
const processGetImpl = deps.runProcessGetImpl ?? runProcessGet;
|
|
2367
|
+
const processListImpl = deps.runProcessListImpl ?? runProcessList;
|
|
2171
2368
|
const processAutoBuildImpl = deps.runProcessAutoBuildImpl ?? runProcessAutoBuild;
|
|
2172
2369
|
const processBatchBuildImpl = deps.runProcessBatchBuildImpl ?? runProcessBatchBuild;
|
|
2173
2370
|
const processResumeBuildImpl = deps.runProcessResumeBuildImpl ?? runProcessResumeBuild;
|
|
2174
2371
|
const processPublishBuildImpl = deps.runProcessPublishBuildImpl ?? runProcessPublishBuild;
|
|
2372
|
+
const processSaveDraftImpl = deps.runProcessSaveDraftImpl ?? runProcessSaveDraft;
|
|
2175
2373
|
const processReviewImpl = deps.runProcessReviewImpl ?? runProcessReview;
|
|
2176
2374
|
const flowReviewImpl = deps.runFlowReviewImpl ?? runFlowReview;
|
|
2177
2375
|
const lifecyclemodelReviewImpl = deps.runLifecyclemodelReviewImpl ?? runLifecyclemodelReview;
|
|
@@ -2189,7 +2387,7 @@ export async function executeCli(argv, deps) {
|
|
|
2189
2387
|
const flowRegenProductImpl = deps.runFlowRegenProductImpl ?? runFlowRegenProduct;
|
|
2190
2388
|
const flowValidateProcessesImpl = deps.runFlowValidateProcessesImpl ?? runFlowValidateProcesses;
|
|
2191
2389
|
if (flags.version) {
|
|
2192
|
-
return { exitCode: 0, stdout:
|
|
2390
|
+
return { exitCode: 0, stdout: `${loadCliPackageVersion(import.meta.url)}\n`, stderr: '' };
|
|
2193
2391
|
}
|
|
2194
2392
|
if (!command || command === 'help' || flags.help) {
|
|
2195
2393
|
return { exitCode: 0, stdout: `${renderMainHelp(deps.dotEnvStatus)}\n`, stderr: '' };
|
|
@@ -2392,6 +2590,34 @@ export async function executeCli(argv, deps) {
|
|
|
2392
2590
|
stderr: '',
|
|
2393
2591
|
};
|
|
2394
2592
|
}
|
|
2593
|
+
if (command === 'process' && subcommand === 'list') {
|
|
2594
|
+
const processFlags = parseProcessListFlags(commandArgs);
|
|
2595
|
+
if (processFlags.help) {
|
|
2596
|
+
return {
|
|
2597
|
+
exitCode: 0,
|
|
2598
|
+
stdout: `${renderProcessListHelp()}\n`,
|
|
2599
|
+
stderr: '',
|
|
2600
|
+
};
|
|
2601
|
+
}
|
|
2602
|
+
const report = await processListImpl({
|
|
2603
|
+
ids: processFlags.ids,
|
|
2604
|
+
version: processFlags.version,
|
|
2605
|
+
userId: processFlags.userId,
|
|
2606
|
+
stateCodes: processFlags.stateCodes,
|
|
2607
|
+
limit: processFlags.limit,
|
|
2608
|
+
offset: processFlags.offset,
|
|
2609
|
+
all: processFlags.all,
|
|
2610
|
+
pageSize: processFlags.pageSize,
|
|
2611
|
+
order: processFlags.order,
|
|
2612
|
+
env: deps.env,
|
|
2613
|
+
fetchImpl: deps.fetchImpl,
|
|
2614
|
+
});
|
|
2615
|
+
return {
|
|
2616
|
+
exitCode: 0,
|
|
2617
|
+
stdout: stringifyJson(report, processFlags.json),
|
|
2618
|
+
stderr: '',
|
|
2619
|
+
};
|
|
2620
|
+
}
|
|
2395
2621
|
if (command === 'process' && subcommand === 'auto-build') {
|
|
2396
2622
|
const processFlags = parseProcessAutoBuildFlags(commandArgs);
|
|
2397
2623
|
if (processFlags.help) {
|
|
@@ -2449,6 +2675,28 @@ export async function executeCli(argv, deps) {
|
|
|
2449
2675
|
stderr: '',
|
|
2450
2676
|
};
|
|
2451
2677
|
}
|
|
2678
|
+
if (command === 'process' && subcommand === 'save-draft') {
|
|
2679
|
+
const processFlags = parseProcessSaveDraftFlags(commandArgs);
|
|
2680
|
+
if (processFlags.help) {
|
|
2681
|
+
return {
|
|
2682
|
+
exitCode: 0,
|
|
2683
|
+
stdout: `${renderProcessSaveDraftHelp()}\n`,
|
|
2684
|
+
stderr: '',
|
|
2685
|
+
};
|
|
2686
|
+
}
|
|
2687
|
+
const report = await processSaveDraftImpl({
|
|
2688
|
+
inputPath: processFlags.inputPath,
|
|
2689
|
+
outDir: processFlags.outDir,
|
|
2690
|
+
commit: processFlags.commit,
|
|
2691
|
+
env: deps.env,
|
|
2692
|
+
fetchImpl: deps.fetchImpl,
|
|
2693
|
+
});
|
|
2694
|
+
return {
|
|
2695
|
+
exitCode: report.status === 'completed_with_failures' ? 1 : 0,
|
|
2696
|
+
stdout: stringifyJson(report, processFlags.json),
|
|
2697
|
+
stderr: '',
|
|
2698
|
+
};
|
|
2699
|
+
}
|
|
2452
2700
|
if (command === 'process' && subcommand === 'batch-build') {
|
|
2453
2701
|
const processFlags = parseProcessBatchBuildFlags(commandArgs);
|
|
2454
2702
|
if (processFlags.help) {
|
|
@@ -2817,6 +3065,7 @@ export async function executeCli(argv, deps) {
|
|
|
2817
3065
|
return { exitCode: 0, stdout: `${renderReviewProcessHelp()}\n`, stderr: '' };
|
|
2818
3066
|
}
|
|
2819
3067
|
const report = await processReviewImpl({
|
|
3068
|
+
rowsFile: reviewFlags.rowsFile,
|
|
2820
3069
|
runRoot: reviewFlags.runRoot,
|
|
2821
3070
|
runId: reviewFlags.runId,
|
|
2822
3071
|
outDir: reviewFlags.outDir,
|