wp-typia 0.23.0 → 0.24.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/README.md +3 -1
- package/bin/routing-metadata.generated.js +11 -0
- package/dist-bunli/.bunli/commands.gen.js +11884 -9017
- package/dist-bunli/{cli-9npd9was.js → cli-0v407aag.js} +12 -10
- package/dist-bunli/{cli-hhp1d348.js → cli-1170yyve.js} +8 -7
- package/dist-bunli/{cli-1meywwsy.js → cli-74y6z3yx.js} +1455 -819
- package/dist-bunli/{cli-qse6myha.js → cli-8hxf9qw6.js} +11 -3
- package/dist-bunli/{cli-8reep89s.js → cli-9fx0qgb7.js} +2 -2
- package/dist-bunli/{cli-add-21bvpfgw.js → cli-add-nmdraf20.js} +8542 -7667
- package/dist-bunli/{cli-52ke0ptp.js → cli-am5x7tb4.js} +8 -2
- package/dist-bunli/{cli-43mx1vfb.js → cli-bajwv85z.js} +2 -1
- package/dist-bunli/cli-ccax7s0s.js +34 -0
- package/dist-bunli/{cli-z5qkx2pn.js → cli-cwjdzq6n.js} +79 -13
- package/dist-bunli/{cli-diagnostics-5dvztm7q.js → cli-diagnostics-10drxh34.js} +1 -1
- package/dist-bunli/{cli-doctor-wy2yjsge.js → cli-doctor-pcss6ecx.js} +688 -459
- package/dist-bunli/{cli-2rqf6t0b.js → cli-e4bwd81c.js} +8 -11
- package/dist-bunli/{cli-init-xnsbxncv.js → cli-init-he7vm7kc.js} +15 -11
- package/dist-bunli/{cli-prompt-614tq57c.js → cli-prompt-ncyg68rn.js} +1 -1
- package/dist-bunli/{cli-bq2v559b.js → cli-rdcga1bd.js} +31 -13
- package/dist-bunli/{cli-scaffold-zhp2ym8z.js → cli-scaffold-an2k0fnm.js} +28 -16
- package/dist-bunli/{cli-c2acv5dv.js → cli-sw06c521.js} +2 -2
- package/dist-bunli/{cli-templates-hc71dfc2.js → cli-templates-g8t4fm11.js} +3 -2
- package/dist-bunli/{cli-p95wr1q8.js → cli-tq730sqt.js} +6 -3
- package/dist-bunli/{cli-ts9thts5.js → cli-v0nnagb3.js} +1513 -1053
- package/dist-bunli/{cli-agywa5n6.js → cli-y0a8nztv.js} +15 -6
- package/dist-bunli/cli-z48frc8t.js +229 -0
- package/dist-bunli/cli.js +5 -5
- package/dist-bunli/{command-list-aqrkx021.js → command-list-xaw5agks.js} +241 -64
- package/dist-bunli/{create-template-validation-rtec5sng.js → create-template-validation-4fr851vg.js} +5 -4
- package/dist-bunli/{migrations-bx0yvc2v.js → migrations-z7f4kxba.js} +10 -9
- package/dist-bunli/node-cli.js +661 -389
- package/dist-bunli/{workspace-project-csnnggz6.js → workspace-project-gmv2a71z.js} +4 -3
- package/package.json +2 -2
- package/dist-bunli/cli-j8et6jvr.js +0 -123
package/dist-bunli/node-cli.js
CHANGED
|
@@ -1,108 +1,8 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
3
|
-
// package.json
|
|
4
|
-
var package_default = {
|
|
5
|
-
name: "wp-typia",
|
|
6
|
-
version: "0.23.0",
|
|
7
|
-
description: "Canonical CLI package for wp-typia scaffolding and project workflows",
|
|
8
|
-
packageManager: "bun@1.3.11",
|
|
9
|
-
type: "module",
|
|
10
|
-
bin: {
|
|
11
|
-
"wp-typia": "bin/wp-typia.js"
|
|
12
|
-
},
|
|
13
|
-
files: [
|
|
14
|
-
"bin/",
|
|
15
|
-
"dist-bunli/",
|
|
16
|
-
"README.md",
|
|
17
|
-
"package.json"
|
|
18
|
-
],
|
|
19
|
-
scripts: {
|
|
20
|
-
"generate:routing": "node scripts/generate-routing-metadata.mjs",
|
|
21
|
-
"validate:routing": "node scripts/generate-routing-metadata.mjs --check",
|
|
22
|
-
generate: "node scripts/generate-routing-metadata.mjs && bun scripts/generate-bunli-metadata.ts",
|
|
23
|
-
build: "bun run generate && bun scripts/build-bunli-runtime.ts",
|
|
24
|
-
"build:standalone": "bun scripts/build-standalone-runtime.ts --targets native --outdir ./dist-standalone",
|
|
25
|
-
"build:standalone:release": "bun scripts/build-standalone-runtime.ts --targets darwin-arm64,darwin-x64,linux-arm64,linux-x64,windows-x64 --outdir ./.cache/standalone/raw",
|
|
26
|
-
"bunli:generate": "bun run generate",
|
|
27
|
-
"bunli:build": "bun run build",
|
|
28
|
-
"bunli:dev": "bun src/cli.ts",
|
|
29
|
-
"bunli:test": "bun test tests/*.test.ts",
|
|
30
|
-
dev: "bun run build && node bin/wp-typia.js",
|
|
31
|
-
"standalone:prepare-release-assets": "bun scripts/prepare-standalone-release-assets.ts --input-dir ./.cache/standalone/raw --outdir ./.cache/standalone/release-assets",
|
|
32
|
-
test: "cd ../wp-typia-project-tools && bun run build && cd ../wp-typia && bun run build && bun test tests/*.test.ts",
|
|
33
|
-
"test:coverage": "cd ../wp-typia-project-tools && bun run build && cd ../wp-typia && bun run build && bun test tests/*.test.ts --coverage --coverage-reporter=lcov --coverage-dir=coverage",
|
|
34
|
-
clean: "rm -rf .bunli .cache/standalone .pack-backup dist-bunli dist-standalone",
|
|
35
|
-
prepack: "bun run build && node ./scripts/publish-runtime-maps.mjs prepare",
|
|
36
|
-
postpack: "node ./scripts/publish-runtime-maps.mjs restore"
|
|
37
|
-
},
|
|
38
|
-
keywords: [
|
|
39
|
-
"wordpress",
|
|
40
|
-
"gutenberg",
|
|
41
|
-
"typia",
|
|
42
|
-
"cli",
|
|
43
|
-
"scaffold",
|
|
44
|
-
"templates"
|
|
45
|
-
],
|
|
46
|
-
author: "imjlk",
|
|
47
|
-
license: "GPL-2.0-or-later",
|
|
48
|
-
repository: {
|
|
49
|
-
type: "git",
|
|
50
|
-
url: "git+https://github.com/imjlk/wp-typia.git",
|
|
51
|
-
directory: "packages/wp-typia"
|
|
52
|
-
},
|
|
53
|
-
bugs: {
|
|
54
|
-
url: "https://github.com/imjlk/wp-typia/issues"
|
|
55
|
-
},
|
|
56
|
-
homepage: "https://github.com/imjlk/wp-typia/tree/main/packages/wp-typia#readme",
|
|
57
|
-
publishConfig: {
|
|
58
|
-
access: "public"
|
|
59
|
-
},
|
|
60
|
-
engines: {
|
|
61
|
-
bun: ">=1.3.11",
|
|
62
|
-
node: ">=20.0.0",
|
|
63
|
-
npm: ">=10.0.0"
|
|
64
|
-
},
|
|
65
|
-
dependencies: {
|
|
66
|
-
"@bunli/core": "0.9.0",
|
|
67
|
-
"@bunli/plugin-ai-detect": "0.6.4",
|
|
68
|
-
"@bunli/plugin-completions": "0.3.5",
|
|
69
|
-
"@bunli/plugin-config": "0.4.4",
|
|
70
|
-
"@bunli/plugin-mcp": "0.2.5",
|
|
71
|
-
"@bunli/plugin-skills": "0.1.0",
|
|
72
|
-
"@bunli/runtime": "0.3.1",
|
|
73
|
-
"@bunli/tui": "0.6.0",
|
|
74
|
-
"@bunli/utils": "0.6.0",
|
|
75
|
-
"@wp-typia/api-client": "^0.4.5",
|
|
76
|
-
"@wp-typia/project-tools": "0.23.0",
|
|
77
|
-
"better-result": "^2.7.0",
|
|
78
|
-
react: "^19.2.5",
|
|
79
|
-
"react-dom": "^19.2.5",
|
|
80
|
-
zod: "4.3.6"
|
|
81
|
-
},
|
|
82
|
-
devDependencies: {
|
|
83
|
-
"@bunli/generator": "0.6.5",
|
|
84
|
-
"@bunli/test": "0.6.0",
|
|
85
|
-
bunli: "0.9.0",
|
|
86
|
-
typescript: "^5.9.2"
|
|
87
|
-
},
|
|
88
|
-
optionalDependencies: {
|
|
89
|
-
"@opentui/core-darwin-arm64": "0.1.97",
|
|
90
|
-
"@opentui/core-darwin-x64": "0.1.97",
|
|
91
|
-
"@opentui/core-linux-arm64": "0.1.97",
|
|
92
|
-
"@opentui/core-linux-x64": "0.1.97",
|
|
93
|
-
"@opentui/core-win32-arm64": "0.1.97",
|
|
94
|
-
"@opentui/core-win32-x64": "0.1.97"
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
3
|
|
|
98
4
|
// src/node-cli.ts
|
|
99
|
-
import {
|
|
100
|
-
CLI_DIAGNOSTIC_CODES as CLI_DIAGNOSTIC_CODES13,
|
|
101
|
-
createCliCommandError as createCliCommandError5,
|
|
102
|
-
formatCliDiagnosticError,
|
|
103
|
-
isCliDiagnosticError,
|
|
104
|
-
serializeCliDiagnosticError as serializeCliDiagnosticError2
|
|
105
|
-
} from "@wp-typia/project-tools/cli-diagnostics";
|
|
5
|
+
import { createCliCommandError as createCliCommandError8 } from "@wp-typia/project-tools/cli-diagnostics";
|
|
106
6
|
|
|
107
7
|
// src/command-option-metadata.ts
|
|
108
8
|
import { z } from "zod";
|
|
@@ -130,15 +30,15 @@ var ADD_OPTION_METADATA = {
|
|
|
130
30
|
type: "string"
|
|
131
31
|
},
|
|
132
32
|
block: {
|
|
133
|
-
description: "Target block slug for variation, style, and end-to-end binding-source workflows.",
|
|
33
|
+
description: "Target block slug/name for variation, core-variation, style, and end-to-end binding-source workflows.",
|
|
134
34
|
type: "string"
|
|
135
35
|
},
|
|
136
36
|
"controller-class": {
|
|
137
|
-
description: "
|
|
37
|
+
description: "REST resource controller class used for generated route callbacks or declared manual/provider route ownership.",
|
|
138
38
|
type: "string"
|
|
139
39
|
},
|
|
140
40
|
"controller-extends": {
|
|
141
|
-
description: "Optional base class for generated REST resource controller wrappers.",
|
|
41
|
+
description: "Optional base class for generated REST resource controller wrappers or declared manual/provider controller ownership.",
|
|
142
42
|
type: "string"
|
|
143
43
|
},
|
|
144
44
|
"data-storage": {
|
|
@@ -162,6 +62,10 @@ var ADD_OPTION_METADATA = {
|
|
|
162
62
|
description: "Source full block name (namespace/block) for transform workflows.",
|
|
163
63
|
type: "string"
|
|
164
64
|
},
|
|
65
|
+
"from-post-meta": {
|
|
66
|
+
description: "Alias for --post-meta when backing a binding-source scaffold from a typed post-meta contract.",
|
|
67
|
+
type: "string"
|
|
68
|
+
},
|
|
165
69
|
"inner-blocks-preset": {
|
|
166
70
|
description: "Compound-only InnerBlocks preset (freeform, ordered, horizontal, locked-structure).",
|
|
167
71
|
type: "string"
|
|
@@ -180,6 +84,10 @@ var ADD_OPTION_METADATA = {
|
|
|
180
84
|
description: "WordPress meta key for post-meta workflows; defaults to _<phpPrefix>_<name>.",
|
|
181
85
|
type: "string"
|
|
182
86
|
},
|
|
87
|
+
"meta-path": {
|
|
88
|
+
description: "Top-level post-meta field used as the default binding-source field when --post-meta or --from-post-meta is provided.",
|
|
89
|
+
type: "string"
|
|
90
|
+
},
|
|
183
91
|
method: {
|
|
184
92
|
description: "HTTP method for manual REST contract workflows (GET, POST, PUT, PATCH, or DELETE).",
|
|
185
93
|
type: "string"
|
|
@@ -193,13 +101,17 @@ var ADD_OPTION_METADATA = {
|
|
|
193
101
|
type: "string"
|
|
194
102
|
},
|
|
195
103
|
"permission-callback": {
|
|
196
|
-
description: "PHP permission callback for generated
|
|
104
|
+
description: "PHP permission callback for generated route registrations or declared manual/provider route ownership.",
|
|
197
105
|
type: "string"
|
|
198
106
|
},
|
|
199
107
|
"post-type": {
|
|
200
108
|
description: "WordPress post type key for post-meta workflows.",
|
|
201
109
|
type: "string"
|
|
202
110
|
},
|
|
111
|
+
"post-meta": {
|
|
112
|
+
description: "Typed post-meta contract slug used to back a binding-source scaffold.",
|
|
113
|
+
type: "string"
|
|
114
|
+
},
|
|
203
115
|
"persistence-policy": {
|
|
204
116
|
description: "Persistence write policy for persistence-capable templates.",
|
|
205
117
|
type: "string"
|
|
@@ -220,16 +132,41 @@ var ADD_OPTION_METADATA = {
|
|
|
220
132
|
description: "Exported TypeScript response type for manual REST contract workflows.",
|
|
221
133
|
type: "string"
|
|
222
134
|
},
|
|
135
|
+
"release-zip": {
|
|
136
|
+
argumentKind: "flag",
|
|
137
|
+
description: "Add release zip packaging scripts for integration-env plugin QA workflows.",
|
|
138
|
+
type: "boolean"
|
|
139
|
+
},
|
|
223
140
|
"route-pattern": {
|
|
224
|
-
description: "
|
|
141
|
+
description: "REST route pattern relative to the namespace; generated resources use it for item routes and manual/provider contracts may use it as an alias for --path.",
|
|
142
|
+
type: "string"
|
|
143
|
+
},
|
|
144
|
+
scope: {
|
|
145
|
+
description: "Pattern catalog scope for pattern workflows (full or section).",
|
|
146
|
+
type: "string"
|
|
147
|
+
},
|
|
148
|
+
"section-role": {
|
|
149
|
+
description: "Typed section role for section-scoped pattern catalog entries.",
|
|
225
150
|
type: "string"
|
|
226
151
|
},
|
|
227
152
|
"secret-field": {
|
|
228
|
-
description: "Write-only request body field for manual settings REST contracts.",
|
|
153
|
+
description: "Write-only request body field for manual settings REST contracts; requires --manual and a request body, typically generated by POST, PUT, or PATCH.",
|
|
154
|
+
type: "string"
|
|
155
|
+
},
|
|
156
|
+
"secret-has-value-field": {
|
|
157
|
+
description: "Alias for --secret-state-field when the manual settings response exposes a safe has-value indicator.",
|
|
158
|
+
type: "string"
|
|
159
|
+
},
|
|
160
|
+
"secret-masked-response-field": {
|
|
161
|
+
description: "Alias for --secret-state-field when the manual settings response exposes masked secret state.",
|
|
162
|
+
type: "string"
|
|
163
|
+
},
|
|
164
|
+
"secret-preserve-on-empty": {
|
|
165
|
+
description: "Whether blank manual settings secret submissions should preserve the stored secret (true by default).",
|
|
229
166
|
type: "string"
|
|
230
167
|
},
|
|
231
168
|
"secret-state-field": {
|
|
232
|
-
description: "Masked response boolean field for --secret-field; defaults to has<SecretField
|
|
169
|
+
description: "Masked response boolean field for --secret-field; defaults to has<SecretField> and may also be provided as --secret-has-value-field.",
|
|
233
170
|
type: "string"
|
|
234
171
|
},
|
|
235
172
|
service: {
|
|
@@ -248,6 +185,14 @@ var ADD_OPTION_METADATA = {
|
|
|
248
185
|
description: "Optional built-in block family for the new block; interactive flows let you choose it when omitted and non-interactive runs default to basic.",
|
|
249
186
|
type: "string"
|
|
250
187
|
},
|
|
188
|
+
"thumbnail-url": {
|
|
189
|
+
description: "Optional thumbnail URL or relative path for typed pattern catalog entries.",
|
|
190
|
+
type: "string"
|
|
191
|
+
},
|
|
192
|
+
tags: {
|
|
193
|
+
description: "Comma-separated tags for typed pattern catalog entries.",
|
|
194
|
+
type: "string"
|
|
195
|
+
},
|
|
251
196
|
type: {
|
|
252
197
|
description: "Exported TypeScript type or interface name for standalone contract workflows.",
|
|
253
198
|
type: "string"
|
|
@@ -315,6 +260,10 @@ var CREATE_OPTION_METADATA = {
|
|
|
315
260
|
description: "Custom PHP symbol prefix.",
|
|
316
261
|
type: "string"
|
|
317
262
|
},
|
|
263
|
+
profile: {
|
|
264
|
+
description: "Opt-in scaffold profile; use plugin-qa with --template workspace for wp-env, smoke, and release zip starters.",
|
|
265
|
+
type: "string"
|
|
266
|
+
},
|
|
318
267
|
"query-post-type": {
|
|
319
268
|
description: "Default post type assigned to Query Loop variation scaffolds.",
|
|
320
269
|
type: "string"
|
|
@@ -359,6 +308,11 @@ var DOCTOR_OPTION_METADATA = {
|
|
|
359
308
|
format: {
|
|
360
309
|
description: "Use `json` for machine-readable doctor check output or `text` for human-readable output.",
|
|
361
310
|
type: "string"
|
|
311
|
+
},
|
|
312
|
+
"workspace-only": {
|
|
313
|
+
argumentKind: "flag",
|
|
314
|
+
description: "Fail only on workspace-scoped doctor checks; environment/runtime failures remain advisory in JSON summaries.",
|
|
315
|
+
type: "boolean"
|
|
362
316
|
}
|
|
363
317
|
};
|
|
364
318
|
// src/command-options/global.ts
|
|
@@ -678,10 +632,10 @@ function resolveCommandOptionValues(metadata, options) {
|
|
|
678
632
|
return resolved;
|
|
679
633
|
}
|
|
680
634
|
|
|
681
|
-
// src/cli-
|
|
635
|
+
// src/cli-output-format.ts
|
|
682
636
|
import {
|
|
683
|
-
|
|
684
|
-
|
|
637
|
+
CLI_DIAGNOSTIC_CODES as CLI_DIAGNOSTIC_CODES2,
|
|
638
|
+
createCliCommandError
|
|
685
639
|
} from "@wp-typia/project-tools/cli-diagnostics";
|
|
686
640
|
|
|
687
641
|
// bin/argv-walker.js
|
|
@@ -735,10 +689,6 @@ function resolveEntrypointCliCommand(argv) {
|
|
|
735
689
|
}
|
|
736
690
|
|
|
737
691
|
// src/cli-output-format.ts
|
|
738
|
-
import {
|
|
739
|
-
CLI_DIAGNOSTIC_CODES as CLI_DIAGNOSTIC_CODES2,
|
|
740
|
-
createCliCommandError
|
|
741
|
-
} from "@wp-typia/project-tools/cli-diagnostics";
|
|
742
692
|
var PUBLIC_CLI_OUTPUT_FORMATS = ["json", "text"];
|
|
743
693
|
var LEGACY_CLI_OUTPUT_FORMAT_ALIASES = ["toon"];
|
|
744
694
|
var SUPPORTED_CLI_OUTPUT_FORMATS = [
|
|
@@ -819,32 +769,6 @@ function validateCliOutputFormatArgv(argv) {
|
|
|
819
769
|
}
|
|
820
770
|
}
|
|
821
771
|
|
|
822
|
-
// src/cli-diagnostic-output.ts
|
|
823
|
-
function prefersStructuredCliArgv(argv) {
|
|
824
|
-
for (let index = 0;index < argv.length; index += 1) {
|
|
825
|
-
const arg = argv[index];
|
|
826
|
-
if (!arg) {
|
|
827
|
-
continue;
|
|
828
|
-
}
|
|
829
|
-
if (arg === "--") {
|
|
830
|
-
return false;
|
|
831
|
-
}
|
|
832
|
-
if (arg === "--format") {
|
|
833
|
-
return argv[index + 1] === "json";
|
|
834
|
-
}
|
|
835
|
-
if (arg.startsWith("--format=")) {
|
|
836
|
-
return arg.slice("--format=".length) === "json";
|
|
837
|
-
}
|
|
838
|
-
}
|
|
839
|
-
return false;
|
|
840
|
-
}
|
|
841
|
-
|
|
842
|
-
// src/node-cli.ts
|
|
843
|
-
import {
|
|
844
|
-
getTemplateById,
|
|
845
|
-
listTemplates
|
|
846
|
-
} from "@wp-typia/project-tools/cli-templates";
|
|
847
|
-
|
|
848
772
|
// src/config.ts
|
|
849
773
|
import fs from "node:fs/promises";
|
|
850
774
|
import os from "node:os";
|
|
@@ -860,10 +784,19 @@ var WP_TYPIA_CONFIG_SOURCES = [
|
|
|
860
784
|
".wp-typiarc",
|
|
861
785
|
".wp-typiarc.json"
|
|
862
786
|
];
|
|
787
|
+
var wordpressVersionSchema = z2.string().regex(/^\d+\.\d+(?:\.\d+)?$/u, 'expected dotted numeric WordPress version such as "6.7" or "6.7.1"');
|
|
863
788
|
var wpTypiaSchemaSourceSchema = z2.object({
|
|
864
789
|
namespace: z2.string(),
|
|
865
790
|
path: z2.string()
|
|
866
791
|
}).strict();
|
|
792
|
+
var wordpressCompatibilityConfigSchema = z2.object({
|
|
793
|
+
minVersion: wordpressVersionSchema.optional(),
|
|
794
|
+
testedVersions: z2.array(wordpressVersionSchema).optional()
|
|
795
|
+
}).strict();
|
|
796
|
+
var blockApiCompatibilityConfigSchema = z2.object({
|
|
797
|
+
allowUnknownFutureKeys: z2.boolean().optional(),
|
|
798
|
+
strict: z2.boolean().optional()
|
|
799
|
+
}).strict();
|
|
867
800
|
var createConfigSchema = z2.object({
|
|
868
801
|
"alternate-render-targets": z2.string().optional(),
|
|
869
802
|
"inner-blocks-preset": z2.string().optional(),
|
|
@@ -876,6 +809,7 @@ var createConfigSchema = z2.object({
|
|
|
876
809
|
"package-manager": z2.string().optional(),
|
|
877
810
|
"persistence-policy": z2.string().optional(),
|
|
878
811
|
"php-prefix": z2.string().optional(),
|
|
812
|
+
profile: z2.string().optional(),
|
|
879
813
|
"query-post-type": z2.string().optional(),
|
|
880
814
|
template: z2.string().optional(),
|
|
881
815
|
"text-domain": z2.string().optional(),
|
|
@@ -902,8 +836,10 @@ var mcpConfigSchema = z2.object({
|
|
|
902
836
|
}).strict();
|
|
903
837
|
var wpTypiaUserConfigSchema = z2.object({
|
|
904
838
|
add: addConfigSchema.optional(),
|
|
839
|
+
compatibility: blockApiCompatibilityConfigSchema.optional(),
|
|
905
840
|
create: createConfigSchema.optional(),
|
|
906
|
-
mcp: mcpConfigSchema.optional()
|
|
841
|
+
mcp: mcpConfigSchema.optional(),
|
|
842
|
+
wordpress: wordpressCompatibilityConfigSchema.optional()
|
|
907
843
|
}).strict();
|
|
908
844
|
function formatIssuePath(issuePath) {
|
|
909
845
|
if (issuePath.length === 0) {
|
|
@@ -1020,8 +956,8 @@ function extractWpTypiaConfigOverride(argv) {
|
|
|
1020
956
|
|
|
1021
957
|
// src/runtime-bridge-add.ts
|
|
1022
958
|
import {
|
|
1023
|
-
CLI_DIAGNOSTIC_CODES as
|
|
1024
|
-
createCliDiagnosticCodeError as
|
|
959
|
+
CLI_DIAGNOSTIC_CODES as CLI_DIAGNOSTIC_CODES9,
|
|
960
|
+
createCliDiagnosticCodeError as createCliDiagnosticCodeError8
|
|
1025
961
|
} from "@wp-typia/project-tools/cli-diagnostics";
|
|
1026
962
|
|
|
1027
963
|
// src/add-kind-ids.ts
|
|
@@ -1062,11 +998,13 @@ var NAME_TYPE_VISIBLE_FIELDS = [
|
|
|
1062
998
|
"name",
|
|
1063
999
|
"type"
|
|
1064
1000
|
];
|
|
1065
|
-
var
|
|
1001
|
+
var NAME_BLOCK_ATTRIBUTE_POST_META_VISIBLE_FIELDS = [
|
|
1066
1002
|
"kind",
|
|
1067
1003
|
"name",
|
|
1068
1004
|
"block",
|
|
1069
|
-
"attribute"
|
|
1005
|
+
"attribute",
|
|
1006
|
+
"post-meta",
|
|
1007
|
+
"meta-path"
|
|
1070
1008
|
];
|
|
1071
1009
|
var NAME_BLOCK_VISIBLE_FIELDS = [
|
|
1072
1010
|
"kind",
|
|
@@ -1319,7 +1257,7 @@ var aiFeatureAddKindEntry = defineAddKindRegistryEntry({
|
|
|
1319
1257
|
});
|
|
1320
1258
|
|
|
1321
1259
|
// src/add-kinds/binding-source.ts
|
|
1322
|
-
var BINDING_SOURCE_MISSING_NAME_MESSAGE = "`wp-typia add binding-source` requires <name>. Usage: wp-typia add binding-source <name> [--block <block-slug|namespace/block-slug> --attribute <attribute>].";
|
|
1260
|
+
var BINDING_SOURCE_MISSING_NAME_MESSAGE = "`wp-typia add binding-source` requires <name>. Usage: wp-typia add binding-source <name> [--block <block-slug|namespace/block-slug> --attribute <attribute>] [--from-post-meta <post-meta> --meta-path <field>].";
|
|
1323
1261
|
var bindingSourceAddKindEntry = defineAddKindRegistryEntry({
|
|
1324
1262
|
completion: {
|
|
1325
1263
|
nextSteps: (values) => [
|
|
@@ -1327,11 +1265,18 @@ var bindingSourceAddKindEntry = defineAddKindRegistryEntry({
|
|
|
1327
1265
|
...values.blockSlug && values.attributeName ? [
|
|
1328
1266
|
`Review src/blocks/${values.blockSlug}/block.json for the ${values.attributeName} bindable attribute.`
|
|
1329
1267
|
] : [],
|
|
1268
|
+
...values.postMetaSlug ? [
|
|
1269
|
+
`Run wp-typia sync-rest --check after editing ${values.schemaFile}.`
|
|
1270
|
+
] : [],
|
|
1330
1271
|
"Run your workspace build or dev command to verify the binding source hooks and editor registration."
|
|
1331
1272
|
],
|
|
1332
1273
|
summaryLines: (values, projectDir) => [
|
|
1333
1274
|
`Binding source: ${values.bindingSourceSlug}`,
|
|
1334
1275
|
...values.blockSlug && values.attributeName ? [`Target: ${values.blockSlug}.${values.attributeName}`] : [],
|
|
1276
|
+
...values.postMetaSlug ? [
|
|
1277
|
+
`Post meta: ${values.postMetaSlug}`,
|
|
1278
|
+
`Meta field: ${values.metaPath}`
|
|
1279
|
+
] : [],
|
|
1335
1280
|
`Project directory: ${projectDir}`
|
|
1336
1281
|
],
|
|
1337
1282
|
title: "Added binding source"
|
|
@@ -1341,17 +1286,26 @@ var bindingSourceAddKindEntry = defineAddKindRegistryEntry({
|
|
|
1341
1286
|
async prepareExecution(context) {
|
|
1342
1287
|
const name = requireAddKindName(context, BINDING_SOURCE_MISSING_NAME_MESSAGE);
|
|
1343
1288
|
const [blockName, attributeName] = readOptionalPairedStrictStringFlags(context.flags, "block", "attribute", "`wp-typia add binding-source` requires --block and --attribute to be provided together.");
|
|
1289
|
+
const postMetaName = readOptionalDashedOrCamelStringFlag(context.flags, "from-post-meta", "fromPostMeta") ?? readOptionalDashedOrCamelStringFlag(context.flags, "post-meta", "postMeta");
|
|
1290
|
+
const metaPath = readOptionalDashedOrCamelStringFlag(context.flags, "meta-path", "metaPath");
|
|
1344
1291
|
return createNamedExecutionPlan(context, {
|
|
1345
1292
|
execute: ({ cwd, name: name2 }) => context.addRuntime.runAddBindingSourceCommand({
|
|
1346
1293
|
attributeName,
|
|
1347
1294
|
bindingSourceName: name2,
|
|
1348
1295
|
blockName,
|
|
1349
|
-
cwd
|
|
1296
|
+
cwd,
|
|
1297
|
+
metaPath,
|
|
1298
|
+
postMetaName
|
|
1350
1299
|
}),
|
|
1351
1300
|
getValues: (result) => ({
|
|
1352
1301
|
...result.attributeName ? { attributeName: result.attributeName } : {},
|
|
1353
1302
|
...result.blockSlug ? { blockSlug: result.blockSlug } : {},
|
|
1354
|
-
bindingSourceSlug: result.bindingSourceSlug
|
|
1303
|
+
bindingSourceSlug: result.bindingSourceSlug,
|
|
1304
|
+
...result.metaKey ? { metaKey: result.metaKey } : {},
|
|
1305
|
+
...result.metaPath ? { metaPath: result.metaPath } : {},
|
|
1306
|
+
...result.postMetaSlug ? { postMetaSlug: result.postMetaSlug } : {},
|
|
1307
|
+
...result.postType ? { postType: result.postType } : {},
|
|
1308
|
+
...result.schemaFile ? { schemaFile: result.schemaFile } : {}
|
|
1355
1309
|
}),
|
|
1356
1310
|
missingNameMessage: BINDING_SOURCE_MISSING_NAME_MESSAGE,
|
|
1357
1311
|
name,
|
|
@@ -1360,8 +1314,8 @@ var bindingSourceAddKindEntry = defineAddKindRegistryEntry({
|
|
|
1360
1314
|
},
|
|
1361
1315
|
sortOrder: 70,
|
|
1362
1316
|
supportsDryRun: true,
|
|
1363
|
-
usage: "wp-typia add binding-source <name> [--block <block-slug|namespace/block-slug> --attribute <attribute>] [--dry-run]",
|
|
1364
|
-
visibleFieldNames: () =>
|
|
1317
|
+
usage: "wp-typia add binding-source <name> [--block <block-slug|namespace/block-slug> --attribute <attribute>] [--from-post-meta|--post-meta <post-meta> [--meta-path <field>]] [--dry-run]",
|
|
1318
|
+
visibleFieldNames: () => NAME_BLOCK_ATTRIBUTE_POST_META_VISIBLE_FIELDS
|
|
1365
1319
|
});
|
|
1366
1320
|
|
|
1367
1321
|
// src/external-layer-prompt-options.ts
|
|
@@ -1503,6 +1457,78 @@ var contractAddKindEntry = defineAddKindRegistryEntry({
|
|
|
1503
1457
|
visibleFieldNames: () => NAME_TYPE_VISIBLE_FIELDS
|
|
1504
1458
|
});
|
|
1505
1459
|
|
|
1460
|
+
// src/add-kinds/core-variation.ts
|
|
1461
|
+
import {
|
|
1462
|
+
CLI_DIAGNOSTIC_CODES as CLI_DIAGNOSTIC_CODES6,
|
|
1463
|
+
createCliDiagnosticCodeError as createCliDiagnosticCodeError5
|
|
1464
|
+
} from "@wp-typia/project-tools/cli-diagnostics";
|
|
1465
|
+
var CORE_VARIATION_MISSING_NAME_MESSAGE = "`wp-typia add core-variation` requires <name>. Usage: wp-typia add core-variation <block-name> <name> or wp-typia add core-variation <name> --block <namespace/block>.";
|
|
1466
|
+
var CORE_VARIATION_MISSING_BLOCK_MESSAGE = "`wp-typia add core-variation` requires <block-name>. Usage: wp-typia add core-variation <block-name> <name> or wp-typia add core-variation <name> --block <namespace/block>.";
|
|
1467
|
+
function resolveCoreVariationInputs(context) {
|
|
1468
|
+
const positionalTargetBlockName = context.positionalArgs?.[1];
|
|
1469
|
+
const positionalVariationName = context.positionalArgs?.[2];
|
|
1470
|
+
if (positionalVariationName) {
|
|
1471
|
+
if (!positionalTargetBlockName) {
|
|
1472
|
+
throw createCliDiagnosticCodeError5(CLI_DIAGNOSTIC_CODES6.MISSING_ARGUMENT, CORE_VARIATION_MISSING_BLOCK_MESSAGE);
|
|
1473
|
+
}
|
|
1474
|
+
return {
|
|
1475
|
+
targetBlockName: positionalTargetBlockName,
|
|
1476
|
+
variationName: positionalVariationName
|
|
1477
|
+
};
|
|
1478
|
+
}
|
|
1479
|
+
if (context.name?.includes("/") && !readOptionalStrictStringFlag(context.flags, "block")) {
|
|
1480
|
+
throw createCliDiagnosticCodeError5(CLI_DIAGNOSTIC_CODES6.MISSING_ARGUMENT, CORE_VARIATION_MISSING_NAME_MESSAGE);
|
|
1481
|
+
}
|
|
1482
|
+
const variationName = requireAddKindName(context, CORE_VARIATION_MISSING_NAME_MESSAGE);
|
|
1483
|
+
const targetBlockName = readOptionalStrictStringFlag(context.flags, "block");
|
|
1484
|
+
if (!targetBlockName) {
|
|
1485
|
+
throw createCliDiagnosticCodeError5(CLI_DIAGNOSTIC_CODES6.MISSING_ARGUMENT, CORE_VARIATION_MISSING_BLOCK_MESSAGE);
|
|
1486
|
+
}
|
|
1487
|
+
return {
|
|
1488
|
+
targetBlockName,
|
|
1489
|
+
variationName
|
|
1490
|
+
};
|
|
1491
|
+
}
|
|
1492
|
+
var coreVariationAddKindEntry = defineAddKindRegistryEntry({
|
|
1493
|
+
completion: {
|
|
1494
|
+
nextSteps: (values) => [
|
|
1495
|
+
`Review ${values.variationFile}.`,
|
|
1496
|
+
"Run your workspace build or dev command to verify the editor-side variation registration."
|
|
1497
|
+
],
|
|
1498
|
+
summaryLines: (values, projectDir) => [
|
|
1499
|
+
`Core variation: ${values.variationSlug}`,
|
|
1500
|
+
`Target block: ${values.targetBlockName}`,
|
|
1501
|
+
`Project directory: ${projectDir}`
|
|
1502
|
+
],
|
|
1503
|
+
title: "Added core block variation"
|
|
1504
|
+
},
|
|
1505
|
+
description: "Add an editor-side variation for an existing core or external block",
|
|
1506
|
+
nameLabel: "Variation name",
|
|
1507
|
+
async prepareExecution(context) {
|
|
1508
|
+
const { targetBlockName, variationName } = resolveCoreVariationInputs(context);
|
|
1509
|
+
return createNamedExecutionPlan(context, {
|
|
1510
|
+
execute: ({ cwd, name }) => context.addRuntime.runAddCoreVariationCommand({
|
|
1511
|
+
cwd,
|
|
1512
|
+
targetBlockName,
|
|
1513
|
+
variationName: name
|
|
1514
|
+
}),
|
|
1515
|
+
getValues: (result) => ({
|
|
1516
|
+
targetBlockName: result.targetBlockName,
|
|
1517
|
+
variationFile: result.variationFile,
|
|
1518
|
+
variationSlug: result.variationSlug
|
|
1519
|
+
}),
|
|
1520
|
+
missingNameMessage: CORE_VARIATION_MISSING_NAME_MESSAGE,
|
|
1521
|
+
name: variationName,
|
|
1522
|
+
warnLine: context.warnLine
|
|
1523
|
+
});
|
|
1524
|
+
},
|
|
1525
|
+
sortOrder: 25,
|
|
1526
|
+
supportsDryRun: true,
|
|
1527
|
+
usage: `wp-typia add core-variation <block-name> <name> [--dry-run]
|
|
1528
|
+
Alias: wp-typia add core-variation <name> --block <namespace/block> [--dry-run]`,
|
|
1529
|
+
visibleFieldNames: () => NAME_BLOCK_VISIBLE_FIELDS
|
|
1530
|
+
});
|
|
1531
|
+
|
|
1506
1532
|
// src/add-kinds/editor-plugin.ts
|
|
1507
1533
|
var EDITOR_PLUGIN_MISSING_NAME_MESSAGE = "`wp-typia add editor-plugin` requires <name>. Usage: wp-typia add editor-plugin <name> [--slot <sidebar|document-setting-panel>].";
|
|
1508
1534
|
var editorPluginAddKindEntry = defineAddKindRegistryEntry({
|
|
@@ -1590,17 +1616,19 @@ var hookedBlockAddKindEntry = defineAddKindRegistryEntry({
|
|
|
1590
1616
|
});
|
|
1591
1617
|
|
|
1592
1618
|
// src/add-kinds/integration-env.ts
|
|
1593
|
-
var INTEGRATION_ENV_MISSING_NAME_MESSAGE = "`wp-typia add integration-env` requires <name>. Usage: wp-typia add integration-env <name> [--wp-env] [--service <none|docker-compose>].";
|
|
1619
|
+
var INTEGRATION_ENV_MISSING_NAME_MESSAGE = "`wp-typia add integration-env` requires <name>. Usage: wp-typia add integration-env <name> [--wp-env] [--release-zip] [--service <none|docker-compose>].";
|
|
1594
1620
|
var integrationEnvAddKindEntry = defineAddKindRegistryEntry({
|
|
1595
1621
|
completion: {
|
|
1596
1622
|
nextSteps: (values) => [
|
|
1597
1623
|
`Review scripts/integration-smoke/${values.integrationEnvSlug}.mjs and docs/integration-env/${values.integrationEnvSlug}.md.`,
|
|
1598
1624
|
"Copy `.env.example` to `.env`, adjust local URLs or credentials, then run the generated smoke script.",
|
|
1599
|
-
...values.withWpEnv === "true" ? ["Run `npm run wp-env:start` before the smoke check when using the generated wp-env preset."] : []
|
|
1625
|
+
...values.withWpEnv === "true" ? ["Run `npm run wp-env:start` before the smoke check when using the generated wp-env preset."] : [],
|
|
1626
|
+
...values.withReleaseZip === "true" ? ["Run `npm run release:zip` after smoke checks pass to build a distributable plugin zip."] : []
|
|
1600
1627
|
],
|
|
1601
1628
|
summaryLines: (values, projectDir) => [
|
|
1602
1629
|
`Integration env: ${values.integrationEnvSlug}`,
|
|
1603
1630
|
`wp-env preset: ${values.withWpEnv}`,
|
|
1631
|
+
`Release zip scripts: ${values.withReleaseZip}`,
|
|
1604
1632
|
`Service starter: ${values.service}`,
|
|
1605
1633
|
`Project directory: ${projectDir}`
|
|
1606
1634
|
],
|
|
@@ -1610,17 +1638,20 @@ var integrationEnvAddKindEntry = defineAddKindRegistryEntry({
|
|
|
1610
1638
|
nameLabel: "Integration env name",
|
|
1611
1639
|
async prepareExecution(context) {
|
|
1612
1640
|
const service = readOptionalStrictStringFlag(context.flags, "service");
|
|
1641
|
+
const withReleaseZip = Boolean(context.flags["release-zip"]);
|
|
1613
1642
|
const withWpEnv = Boolean(context.flags["wp-env"]);
|
|
1614
1643
|
return createNamedExecutionPlan(context, {
|
|
1615
1644
|
execute: ({ cwd, name }) => context.addRuntime.runAddIntegrationEnvCommand({
|
|
1616
1645
|
cwd,
|
|
1617
1646
|
integrationEnvName: name,
|
|
1618
1647
|
service,
|
|
1648
|
+
withReleaseZip,
|
|
1619
1649
|
withWpEnv
|
|
1620
1650
|
}),
|
|
1621
1651
|
getValues: (result) => ({
|
|
1622
1652
|
integrationEnvSlug: result.integrationEnvSlug,
|
|
1623
1653
|
service: result.service,
|
|
1654
|
+
withReleaseZip: String(result.withReleaseZip),
|
|
1624
1655
|
withWpEnv: String(result.withWpEnv)
|
|
1625
1656
|
}),
|
|
1626
1657
|
getWarnings: (result) => result.warnings,
|
|
@@ -1630,8 +1661,9 @@ var integrationEnvAddKindEntry = defineAddKindRegistryEntry({
|
|
|
1630
1661
|
},
|
|
1631
1662
|
sortOrder: 25,
|
|
1632
1663
|
supportsDryRun: true,
|
|
1633
|
-
usage: "wp-typia add integration-env <name> [--wp-env] [--service <none|docker-compose>] [--dry-run]",
|
|
1634
|
-
visibleFieldNames: () => NAME_ONLY_VISIBLE_FIELDS
|
|
1664
|
+
usage: "wp-typia add integration-env <name> [--wp-env] [--release-zip] [--service <none|docker-compose>] [--dry-run]",
|
|
1665
|
+
visibleFieldNames: () => NAME_ONLY_VISIBLE_FIELDS,
|
|
1666
|
+
hiddenBooleanSubmitFields: ["wp-env", "release-zip"]
|
|
1635
1667
|
});
|
|
1636
1668
|
|
|
1637
1669
|
// src/add-kinds/pattern.ts
|
|
@@ -1639,33 +1671,51 @@ var PATTERN_MISSING_NAME_MESSAGE = "`wp-typia add pattern` requires <name>. Usag
|
|
|
1639
1671
|
var patternAddKindEntry = defineAddKindRegistryEntry({
|
|
1640
1672
|
completion: {
|
|
1641
1673
|
nextSteps: (values) => [
|
|
1642
|
-
`Review
|
|
1674
|
+
`Review ${values.contentFile}.`,
|
|
1643
1675
|
"Run your workspace build or dev command to verify the new pattern registration."
|
|
1644
1676
|
],
|
|
1645
1677
|
summaryLines: (values, projectDir) => [
|
|
1646
1678
|
`Pattern: ${values.patternSlug}`,
|
|
1679
|
+
`Content file: ${values.contentFile}`,
|
|
1647
1680
|
`Project directory: ${projectDir}`
|
|
1648
1681
|
],
|
|
1649
1682
|
title: "Added workspace pattern"
|
|
1650
1683
|
},
|
|
1651
1684
|
description: "Add a PHP block pattern shell",
|
|
1685
|
+
hiddenStringSubmitFields: [
|
|
1686
|
+
"scope",
|
|
1687
|
+
"section-role",
|
|
1688
|
+
"tags",
|
|
1689
|
+
"thumbnail-url"
|
|
1690
|
+
],
|
|
1652
1691
|
nameLabel: "Pattern name",
|
|
1653
1692
|
async prepareExecution(context) {
|
|
1654
|
-
|
|
1655
|
-
|
|
1693
|
+
const name = requireAddKindName(context, PATTERN_MISSING_NAME_MESSAGE);
|
|
1694
|
+
const scope = typeof context.flags.scope === "string" ? context.flags.scope : undefined;
|
|
1695
|
+
const sectionRole = typeof context.flags["section-role"] === "string" ? context.flags["section-role"] : undefined;
|
|
1696
|
+
const tags = typeof context.flags.tags === "string" ? context.flags.tags : undefined;
|
|
1697
|
+
const thumbnailUrl = typeof context.flags["thumbnail-url"] === "string" ? context.flags["thumbnail-url"] : undefined;
|
|
1698
|
+
return {
|
|
1699
|
+
execute: (cwd) => context.addRuntime.runAddPatternCommand({
|
|
1656
1700
|
cwd,
|
|
1657
|
-
|
|
1701
|
+
patternScope: scope,
|
|
1702
|
+
patternName: name,
|
|
1703
|
+
sectionRole,
|
|
1704
|
+
tags,
|
|
1705
|
+
thumbnailUrl
|
|
1658
1706
|
}),
|
|
1659
1707
|
getValues: (result) => ({
|
|
1660
|
-
|
|
1708
|
+
contentFile: result.contentFile,
|
|
1709
|
+
patternSlug: result.patternSlug,
|
|
1710
|
+
patternScope: result.patternScope,
|
|
1711
|
+
...result.sectionRole ? { sectionRole: result.sectionRole } : {}
|
|
1661
1712
|
}),
|
|
1662
|
-
missingNameMessage: PATTERN_MISSING_NAME_MESSAGE,
|
|
1663
1713
|
warnLine: context.warnLine
|
|
1664
|
-
}
|
|
1714
|
+
};
|
|
1665
1715
|
},
|
|
1666
1716
|
sortOrder: 60,
|
|
1667
1717
|
supportsDryRun: true,
|
|
1668
|
-
usage: "wp-typia add pattern <name> [--dry-run]",
|
|
1718
|
+
usage: "wp-typia add pattern <name> [--scope <full|section>] [--section-role <role>] [--tags <tag,...>] [--thumbnail-url <url>] [--dry-run]",
|
|
1669
1719
|
visibleFieldNames: () => NAME_ONLY_VISIBLE_FIELDS
|
|
1670
1720
|
});
|
|
1671
1721
|
|
|
@@ -1731,9 +1781,44 @@ var postMetaAddKindEntry = defineAddKindRegistryEntry({
|
|
|
1731
1781
|
});
|
|
1732
1782
|
|
|
1733
1783
|
// src/add-kinds/rest-resource.ts
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1784
|
+
import {
|
|
1785
|
+
CLI_DIAGNOSTIC_CODES as CLI_DIAGNOSTIC_CODES7,
|
|
1786
|
+
createCliDiagnosticCodeError as createCliDiagnosticCodeError6
|
|
1787
|
+
} from "@wp-typia/project-tools/cli-diagnostics";
|
|
1788
|
+
var REST_RESOURCE_GENERATED_USAGE = "Generated: wp-typia add rest-resource <name> [--namespace <vendor/v1>] [--methods <list,read,create,update,delete>] [--route-pattern <route-pattern>] [--permission-callback <callback>] [--controller-class <ClassName>] [--controller-extends <BaseClass>] [--dry-run]";
|
|
1789
|
+
var REST_RESOURCE_MANUAL_USAGE = "Manual: wp-typia add rest-resource <name> --manual [--namespace <vendor/v1>] [--method <GET|POST|PUT|PATCH|DELETE>] [--auth <public|authenticated|public-write-protected>] [--path <route-pattern>|--route-pattern <route-pattern>] [--permission-callback <callback>] [--controller-class <ClassName>] [--controller-extends <BaseClass>] [--query-type <Type>] [--body-type <Type>] [--response-type <Type>] [--secret-field <field>] [--secret-state-field|--secret-has-value-field <field>] [--secret-preserve-on-empty <true|false>] [--dry-run]";
|
|
1790
|
+
var REST_RESOURCE_USAGE = `${REST_RESOURCE_GENERATED_USAGE}
|
|
1791
|
+
${REST_RESOURCE_MANUAL_USAGE}`;
|
|
1792
|
+
var REST_RESOURCE_MISSING_NAME_MESSAGE = [
|
|
1793
|
+
"`wp-typia add rest-resource` requires <name>. Usage:",
|
|
1794
|
+
` ${REST_RESOURCE_GENERATED_USAGE}`,
|
|
1795
|
+
` ${REST_RESOURCE_MANUAL_USAGE}`
|
|
1796
|
+
].join(`
|
|
1797
|
+
`);
|
|
1798
|
+
var SECRET_PRESERVE_ON_EMPTY_TRUE_VALUES = new Set(["1", "true", "yes"]);
|
|
1799
|
+
var SECRET_PRESERVE_ON_EMPTY_FALSE_VALUES = new Set(["0", "false", "no"]);
|
|
1800
|
+
function readOptionalSecretPreserveOnEmptyFlag(flags) {
|
|
1801
|
+
const value = flags["secret-preserve-on-empty"] ?? flags.secretPreserveOnEmpty;
|
|
1802
|
+
if (value === undefined || value === null) {
|
|
1803
|
+
return;
|
|
1804
|
+
}
|
|
1805
|
+
if (typeof value === "boolean") {
|
|
1806
|
+
return value;
|
|
1807
|
+
}
|
|
1808
|
+
if (typeof value !== "string") {
|
|
1809
|
+
throw createCliDiagnosticCodeError6(CLI_DIAGNOSTIC_CODES7.MISSING_ARGUMENT, "`--secret-preserve-on-empty` requires a value.");
|
|
1810
|
+
}
|
|
1811
|
+
const normalized = value.trim().toLowerCase();
|
|
1812
|
+
if (normalized.length === 0) {
|
|
1813
|
+
throw createCliDiagnosticCodeError6(CLI_DIAGNOSTIC_CODES7.MISSING_ARGUMENT, "`--secret-preserve-on-empty` requires a value.");
|
|
1814
|
+
}
|
|
1815
|
+
if (SECRET_PRESERVE_ON_EMPTY_TRUE_VALUES.has(normalized)) {
|
|
1816
|
+
return true;
|
|
1817
|
+
}
|
|
1818
|
+
if (SECRET_PRESERVE_ON_EMPTY_FALSE_VALUES.has(normalized)) {
|
|
1819
|
+
return false;
|
|
1820
|
+
}
|
|
1821
|
+
throw createCliDiagnosticCodeError6(CLI_DIAGNOSTIC_CODES7.INVALID_ARGUMENT, "Manual REST contract --secret-preserve-on-empty must be true or false.");
|
|
1737
1822
|
}
|
|
1738
1823
|
var restResourceAddKindEntry = defineAddKindRegistryEntry({
|
|
1739
1824
|
completion: {
|
|
@@ -1752,8 +1837,12 @@ var restResourceAddKindEntry = defineAddKindRegistryEntry({
|
|
|
1752
1837
|
`Route: ${values.method} /${values.namespace}${values.pathPattern}`,
|
|
1753
1838
|
`Auth: ${values.auth}`,
|
|
1754
1839
|
...values.secretFieldName ? [
|
|
1755
|
-
`Secret field: ${values.secretFieldName} -> ${values.secretStateFieldName}
|
|
1756
|
-
|
|
1840
|
+
`Secret field: ${values.secretFieldName} -> ${values.secretStateFieldName}`,
|
|
1841
|
+
`Secret preserve on empty: ${values.secretPreserveOnEmpty}`
|
|
1842
|
+
] : [],
|
|
1843
|
+
...values.permissionCallback ? [`Declared permission callback: ${values.permissionCallback}`] : [],
|
|
1844
|
+
...values.controllerClass ? [`Declared controller class: ${values.controllerClass}`] : [],
|
|
1845
|
+
...values.controllerExtends ? [`Declared controller base: ${values.controllerExtends}`] : []
|
|
1757
1846
|
] : [
|
|
1758
1847
|
`Methods: ${values.methods}`,
|
|
1759
1848
|
...values.routePattern ? [`Item route: /${values.namespace}${values.routePattern}`] : [],
|
|
@@ -1778,6 +1867,9 @@ var restResourceAddKindEntry = defineAddKindRegistryEntry({
|
|
|
1778
1867
|
"response-type",
|
|
1779
1868
|
"route-pattern",
|
|
1780
1869
|
"secret-field",
|
|
1870
|
+
"secret-has-value-field",
|
|
1871
|
+
"secret-masked-response-field",
|
|
1872
|
+
"secret-preserve-on-empty",
|
|
1781
1873
|
"secret-state-field"
|
|
1782
1874
|
],
|
|
1783
1875
|
nameLabel: "REST resource name",
|
|
@@ -1785,19 +1877,22 @@ var restResourceAddKindEntry = defineAddKindRegistryEntry({
|
|
|
1785
1877
|
const name = requireAddKindName(context, REST_RESOURCE_MISSING_NAME_MESSAGE);
|
|
1786
1878
|
const auth = readOptionalStrictStringFlag(context.flags, "auth");
|
|
1787
1879
|
const bodyTypeName = readOptionalStrictStringFlag(context.flags, "body-type");
|
|
1788
|
-
const controllerClass =
|
|
1789
|
-
const controllerExtends =
|
|
1880
|
+
const controllerClass = readOptionalDashedOrCamelStringFlag(context.flags, "controller-class", "controllerClass");
|
|
1881
|
+
const controllerExtends = readOptionalDashedOrCamelStringFlag(context.flags, "controller-extends", "controllerExtends");
|
|
1790
1882
|
const manual = Boolean(context.flags.manual);
|
|
1791
1883
|
const method = readOptionalStrictStringFlag(context.flags, "method");
|
|
1792
1884
|
const methods = readOptionalStrictStringFlag(context.flags, "methods");
|
|
1793
1885
|
const namespace = readOptionalStrictStringFlag(context.flags, "namespace");
|
|
1794
|
-
const permissionCallback =
|
|
1886
|
+
const permissionCallback = readOptionalDashedOrCamelStringFlag(context.flags, "permission-callback", "permissionCallback");
|
|
1795
1887
|
const pathPattern = readOptionalStrictStringFlag(context.flags, "path");
|
|
1796
1888
|
const queryTypeName = readOptionalStrictStringFlag(context.flags, "query-type");
|
|
1797
1889
|
const responseTypeName = readOptionalStrictStringFlag(context.flags, "response-type");
|
|
1798
|
-
const routePattern =
|
|
1799
|
-
const secretFieldName =
|
|
1800
|
-
const
|
|
1890
|
+
const routePattern = readOptionalDashedOrCamelStringFlag(context.flags, "route-pattern", "routePattern");
|
|
1891
|
+
const secretFieldName = readOptionalDashedOrCamelStringFlag(context.flags, "secret-field", "secretField");
|
|
1892
|
+
const secretHasValueFieldName = readOptionalDashedOrCamelStringFlag(context.flags, "secret-has-value-field", "secretHasValueField");
|
|
1893
|
+
const secretMaskedResponseFieldName = readOptionalDashedOrCamelStringFlag(context.flags, "secret-masked-response-field", "secretMaskedResponseField");
|
|
1894
|
+
const secretPreserveOnEmpty = readOptionalSecretPreserveOnEmptyFlag(context.flags);
|
|
1895
|
+
const secretStateFieldName = readOptionalDashedOrCamelStringFlag(context.flags, "secret-state-field", "secretStateField");
|
|
1801
1896
|
return createNamedExecutionPlan(context, {
|
|
1802
1897
|
execute: ({ cwd, name: name2 }) => context.addRuntime.runAddRestResourceCommand({
|
|
1803
1898
|
auth,
|
|
@@ -1816,11 +1911,15 @@ var restResourceAddKindEntry = defineAddKindRegistryEntry({
|
|
|
1816
1911
|
responseTypeName,
|
|
1817
1912
|
routePattern,
|
|
1818
1913
|
secretFieldName,
|
|
1914
|
+
secretHasValueFieldName,
|
|
1915
|
+
secretMaskedResponseFieldName,
|
|
1916
|
+
secretPreserveOnEmpty,
|
|
1819
1917
|
secretStateFieldName
|
|
1820
1918
|
}),
|
|
1821
1919
|
getValues: (result) => ({
|
|
1822
1920
|
auth: result.auth ?? "",
|
|
1823
1921
|
controllerClass: result.controllerClass ?? "",
|
|
1922
|
+
controllerExtends: result.controllerExtends ?? "",
|
|
1824
1923
|
method: result.method ?? "",
|
|
1825
1924
|
methods: result.methods.join(", "),
|
|
1826
1925
|
mode: result.mode,
|
|
@@ -1830,6 +1929,7 @@ var restResourceAddKindEntry = defineAddKindRegistryEntry({
|
|
|
1830
1929
|
restResourceSlug: result.restResourceSlug,
|
|
1831
1930
|
routePattern: result.routePattern ?? "",
|
|
1832
1931
|
secretFieldName: result.secretFieldName ?? "",
|
|
1932
|
+
secretPreserveOnEmpty: result.secretPreserveOnEmpty === undefined ? "" : String(result.secretPreserveOnEmpty),
|
|
1833
1933
|
secretStateFieldName: result.secretStateFieldName ?? ""
|
|
1834
1934
|
}),
|
|
1835
1935
|
missingNameMessage: REST_RESOURCE_MISSING_NAME_MESSAGE,
|
|
@@ -1839,7 +1939,7 @@ var restResourceAddKindEntry = defineAddKindRegistryEntry({
|
|
|
1839
1939
|
},
|
|
1840
1940
|
sortOrder: 80,
|
|
1841
1941
|
supportsDryRun: true,
|
|
1842
|
-
usage:
|
|
1942
|
+
usage: REST_RESOURCE_USAGE,
|
|
1843
1943
|
visibleFieldNames: () => NAME_NAMESPACE_METHODS_VISIBLE_FIELDS
|
|
1844
1944
|
});
|
|
1845
1945
|
|
|
@@ -1976,6 +2076,7 @@ var ADD_KIND_REGISTRY = {
|
|
|
1976
2076
|
"admin-view": adminViewAddKindEntry,
|
|
1977
2077
|
block: blockAddKindEntry,
|
|
1978
2078
|
"integration-env": integrationEnvAddKindEntry,
|
|
2079
|
+
"core-variation": coreVariationAddKindEntry,
|
|
1979
2080
|
variation: variationAddKindEntry,
|
|
1980
2081
|
style: styleAddKindEntry,
|
|
1981
2082
|
transform: transformAddKindEntry,
|
|
@@ -2368,33 +2469,128 @@ function buildStructuredInitSuccessPayload(plan) {
|
|
|
2368
2469
|
}
|
|
2369
2470
|
};
|
|
2370
2471
|
}
|
|
2371
|
-
//
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
}
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2472
|
+
// package.json
|
|
2473
|
+
var package_default = {
|
|
2474
|
+
name: "wp-typia",
|
|
2475
|
+
version: "0.24.0",
|
|
2476
|
+
description: "Canonical CLI package for wp-typia scaffolding and project workflows",
|
|
2477
|
+
packageManager: "bun@1.3.11",
|
|
2478
|
+
type: "module",
|
|
2479
|
+
bin: {
|
|
2480
|
+
"wp-typia": "bin/wp-typia.js"
|
|
2481
|
+
},
|
|
2482
|
+
files: [
|
|
2483
|
+
"bin/",
|
|
2484
|
+
"dist-bunli/",
|
|
2485
|
+
"README.md",
|
|
2486
|
+
"package.json"
|
|
2487
|
+
],
|
|
2488
|
+
scripts: {
|
|
2489
|
+
"generate:routing": "node scripts/generate-routing-metadata.mjs",
|
|
2490
|
+
"validate:routing": "node scripts/generate-routing-metadata.mjs --check",
|
|
2491
|
+
generate: "node scripts/generate-routing-metadata.mjs && bun scripts/generate-bunli-metadata.ts",
|
|
2492
|
+
build: "bun run generate && bun scripts/build-bunli-runtime.ts",
|
|
2493
|
+
"build:standalone": "bun scripts/build-standalone-runtime.ts --targets native --outdir ./dist-standalone",
|
|
2494
|
+
"build:standalone:release": "bun scripts/build-standalone-runtime.ts --targets darwin-arm64,darwin-x64,linux-arm64,linux-x64,windows-x64 --outdir ./.cache/standalone/raw",
|
|
2495
|
+
"bunli:generate": "bun run generate",
|
|
2496
|
+
"bunli:build": "bun run build",
|
|
2497
|
+
"bunli:dev": "bun src/cli.ts",
|
|
2498
|
+
"bunli:test": "bun test tests/*.test.ts",
|
|
2499
|
+
dev: "bun run build && node bin/wp-typia.js",
|
|
2500
|
+
"standalone:prepare-release-assets": "bun scripts/prepare-standalone-release-assets.ts --input-dir ./.cache/standalone/raw --outdir ./.cache/standalone/release-assets",
|
|
2501
|
+
test: "cd ../wp-typia-project-tools && bun run build && cd ../wp-typia && bun run build && bun test tests/*.test.ts",
|
|
2502
|
+
"test:coverage": "cd ../wp-typia-project-tools && bun run build && cd ../wp-typia && bun run build && bun test tests/*.test.ts --coverage --coverage-reporter=lcov --coverage-dir=coverage",
|
|
2503
|
+
clean: "rm -rf .bunli .cache/standalone .pack-backup dist-bunli dist-standalone",
|
|
2504
|
+
prepack: "bun run build && node ./scripts/publish-runtime-maps.mjs prepare",
|
|
2505
|
+
postpack: "node ./scripts/publish-runtime-maps.mjs restore"
|
|
2506
|
+
},
|
|
2507
|
+
keywords: [
|
|
2508
|
+
"wordpress",
|
|
2509
|
+
"gutenberg",
|
|
2510
|
+
"typia",
|
|
2511
|
+
"cli",
|
|
2512
|
+
"scaffold",
|
|
2513
|
+
"templates"
|
|
2514
|
+
],
|
|
2515
|
+
author: "imjlk",
|
|
2516
|
+
license: "GPL-2.0-or-later",
|
|
2517
|
+
repository: {
|
|
2518
|
+
type: "git",
|
|
2519
|
+
url: "git+https://github.com/imjlk/wp-typia.git",
|
|
2520
|
+
directory: "packages/wp-typia"
|
|
2521
|
+
},
|
|
2522
|
+
bugs: {
|
|
2523
|
+
url: "https://github.com/imjlk/wp-typia/issues"
|
|
2524
|
+
},
|
|
2525
|
+
homepage: "https://github.com/imjlk/wp-typia/tree/main/packages/wp-typia#readme",
|
|
2526
|
+
publishConfig: {
|
|
2527
|
+
access: "public"
|
|
2528
|
+
},
|
|
2529
|
+
engines: {
|
|
2530
|
+
bun: ">=1.3.11",
|
|
2531
|
+
node: ">=20.0.0",
|
|
2532
|
+
npm: ">=10.0.0"
|
|
2533
|
+
},
|
|
2534
|
+
dependencies: {
|
|
2535
|
+
"@bunli/core": "0.9.0",
|
|
2536
|
+
"@bunli/plugin-ai-detect": "0.6.4",
|
|
2537
|
+
"@bunli/plugin-completions": "0.3.5",
|
|
2538
|
+
"@bunli/plugin-config": "0.4.4",
|
|
2539
|
+
"@bunli/plugin-mcp": "0.2.5",
|
|
2540
|
+
"@bunli/plugin-skills": "0.1.0",
|
|
2541
|
+
"@bunli/runtime": "0.3.1",
|
|
2542
|
+
"@bunli/tui": "0.6.0",
|
|
2543
|
+
"@bunli/utils": "0.6.0",
|
|
2544
|
+
"@wp-typia/api-client": "^0.4.5",
|
|
2545
|
+
"@wp-typia/project-tools": "0.24.0",
|
|
2546
|
+
"better-result": "^2.7.0",
|
|
2547
|
+
react: "^19.2.5",
|
|
2548
|
+
"react-dom": "^19.2.5",
|
|
2549
|
+
zod: "4.3.6"
|
|
2550
|
+
},
|
|
2551
|
+
devDependencies: {
|
|
2552
|
+
"@bunli/generator": "0.6.5",
|
|
2553
|
+
"@bunli/test": "0.6.0",
|
|
2554
|
+
bunli: "0.9.0",
|
|
2555
|
+
typescript: "^5.9.2"
|
|
2556
|
+
},
|
|
2557
|
+
optionalDependencies: {
|
|
2558
|
+
"@opentui/core-darwin-arm64": "0.1.97",
|
|
2559
|
+
"@opentui/core-darwin-x64": "0.1.97",
|
|
2560
|
+
"@opentui/core-linux-arm64": "0.1.97",
|
|
2561
|
+
"@opentui/core-linux-x64": "0.1.97",
|
|
2562
|
+
"@opentui/core-win32-arm64": "0.1.97",
|
|
2563
|
+
"@opentui/core-win32-x64": "0.1.97"
|
|
2564
|
+
}
|
|
2565
|
+
};
|
|
2566
|
+
|
|
2567
|
+
// src/runtime-output/create.ts
|
|
2568
|
+
import {
|
|
2569
|
+
PACKAGE_MANAGER_IDS,
|
|
2570
|
+
formatPackageExecCommand,
|
|
2571
|
+
parsePackageManagerField
|
|
2572
|
+
} from "@wp-typia/project-tools/package-managers";
|
|
2573
|
+
import {
|
|
2574
|
+
CLI_DIAGNOSTIC_CODES as CLI_DIAGNOSTIC_CODES8,
|
|
2575
|
+
createCliDiagnosticCodeError as createCliDiagnosticCodeError7
|
|
2576
|
+
} from "@wp-typia/project-tools/cli-diagnostics";
|
|
2577
|
+
var LOOSE_CREATE_COMPLETION_PACKAGE_MANAGER_PATTERN = new RegExp(`^(?:corepack\\s+)?(${PACKAGE_MANAGER_IDS.map(escapeRegExp).join("|")})(?=$|[@:/+\\s])`, "iu");
|
|
2578
|
+
function parseCreateCompletionPackageManager(packageManager) {
|
|
2579
|
+
const normalizedPackageManager = packageManager.trim();
|
|
2580
|
+
const parsedPackageManager = parsePackageManagerField(normalizedPackageManager);
|
|
2581
|
+
if (parsedPackageManager) {
|
|
2582
|
+
return parsedPackageManager;
|
|
2583
|
+
}
|
|
2584
|
+
const looseMatch = LOOSE_CREATE_COMPLETION_PACKAGE_MANAGER_PATTERN.exec(normalizedPackageManager);
|
|
2585
|
+
const loosePackageManager = looseMatch?.[1]?.toLowerCase();
|
|
2586
|
+
return PACKAGE_MANAGER_IDS.includes(loosePackageManager) ? loosePackageManager : null;
|
|
2587
|
+
}
|
|
2588
|
+
function resolveCreateCompletionPackageManager(packageManager) {
|
|
2589
|
+
const parsedPackageManager = parseCreateCompletionPackageManager(packageManager);
|
|
2590
|
+
if (parsedPackageManager) {
|
|
2395
2591
|
return parsedPackageManager;
|
|
2396
2592
|
}
|
|
2397
|
-
throw
|
|
2593
|
+
throw createCliDiagnosticCodeError7(CLI_DIAGNOSTIC_CODES8.INVALID_ARGUMENT, `Unsupported package manager "${packageManager}" in create completion payload. Expected one of: ${PACKAGE_MANAGER_IDS.join(", ")}.`);
|
|
2398
2594
|
}
|
|
2399
2595
|
function formatCreateProgressLine(payload, markerOptions) {
|
|
2400
2596
|
return formatOutputMarker("progress", `${payload.title}: ${payload.detail}`, markerOptions);
|
|
@@ -2555,8 +2751,8 @@ function isInteractiveTerminal({
|
|
|
2555
2751
|
// src/runtime-bridge-shared.ts
|
|
2556
2752
|
var loadCliDiagnosticsRuntime = () => import("@wp-typia/project-tools/cli-diagnostics");
|
|
2557
2753
|
async function wrapCliCommandError(command, error) {
|
|
2558
|
-
const { createCliCommandError:
|
|
2559
|
-
return
|
|
2754
|
+
const { createCliCommandError: createCliCommandError2 } = await loadCliDiagnosticsRuntime();
|
|
2755
|
+
return createCliCommandError2({ command, error });
|
|
2560
2756
|
}
|
|
2561
2757
|
function shouldWrapCliCommandError(options) {
|
|
2562
2758
|
if (options.emitOutput === false) {
|
|
@@ -2640,6 +2836,7 @@ async function executeAddCommand({
|
|
|
2640
2836
|
interactive,
|
|
2641
2837
|
kind,
|
|
2642
2838
|
name,
|
|
2839
|
+
positionalArgs,
|
|
2643
2840
|
printLine = console.log,
|
|
2644
2841
|
prompt,
|
|
2645
2842
|
warnLine = console.warn
|
|
@@ -2653,13 +2850,13 @@ async function executeAddCommand({
|
|
|
2653
2850
|
if (shouldPrintMissingAddKindHelp({ emitOutput })) {
|
|
2654
2851
|
printLine(addRuntime.formatAddHelpText());
|
|
2655
2852
|
}
|
|
2656
|
-
throw
|
|
2853
|
+
throw createCliDiagnosticCodeError8(CLI_DIAGNOSTIC_CODES9.MISSING_ARGUMENT, formatMissingAddKindDetailLine());
|
|
2657
2854
|
}
|
|
2658
2855
|
if (!isAddKindId(kind)) {
|
|
2659
|
-
throw
|
|
2856
|
+
throw createCliDiagnosticCodeError8(CLI_DIAGNOSTIC_CODES9.INVALID_COMMAND, `Unknown add kind "${kind}". Expected one of: ${formatAddKindList()}.`);
|
|
2660
2857
|
}
|
|
2661
2858
|
if (dryRun && !supportsAddKindDryRun(kind)) {
|
|
2662
|
-
throw
|
|
2859
|
+
throw createCliDiagnosticCodeError8(CLI_DIAGNOSTIC_CODES9.INVALID_ARGUMENT, `\`wp-typia add ${kind}\` does not support \`--dry-run\` yet.`);
|
|
2663
2860
|
}
|
|
2664
2861
|
const executionContext = {
|
|
2665
2862
|
addRuntime,
|
|
@@ -2675,6 +2872,7 @@ async function executeAddCommand({
|
|
|
2675
2872
|
},
|
|
2676
2873
|
isInteractiveSession,
|
|
2677
2874
|
name,
|
|
2875
|
+
positionalArgs,
|
|
2678
2876
|
warnLine
|
|
2679
2877
|
};
|
|
2680
2878
|
return await executePlannedAddKind(kind, executionContext, {
|
|
@@ -2768,6 +2966,7 @@ async function executeCreateCommand({
|
|
|
2768
2966
|
packageManager: readOptionalLooseStringFlag(flags, "package-manager"),
|
|
2769
2967
|
persistencePolicy: readOptionalLooseStringFlag(flags, "persistence-policy"),
|
|
2770
2968
|
phpPrefix: readOptionalLooseStringFlag(flags, "php-prefix"),
|
|
2969
|
+
profile: readOptionalLooseStringFlag(flags, "profile"),
|
|
2771
2970
|
projectInput: projectDir,
|
|
2772
2971
|
onProgress: async (progress) => {
|
|
2773
2972
|
const payload2 = {
|
|
@@ -2817,10 +3016,10 @@ async function executeCreateCommand({
|
|
|
2817
3016
|
}
|
|
2818
3017
|
// src/runtime-bridge-doctor.ts
|
|
2819
3018
|
var loadCliDoctorRuntime = () => import("@wp-typia/project-tools/cli-doctor");
|
|
2820
|
-
async function executeDoctorCommand(cwd) {
|
|
3019
|
+
async function executeDoctorCommand(cwd, options = {}) {
|
|
2821
3020
|
try {
|
|
2822
3021
|
const { runDoctor } = await loadCliDoctorRuntime();
|
|
2823
|
-
await runDoctor(cwd);
|
|
3022
|
+
await runDoctor(cwd, { exitPolicy: options.exitPolicy });
|
|
2824
3023
|
} catch (error) {
|
|
2825
3024
|
throw await wrapCliCommandError("doctor", error);
|
|
2826
3025
|
}
|
|
@@ -2911,8 +3110,8 @@ async function executeMigrateCommand({
|
|
|
2911
3110
|
}
|
|
2912
3111
|
// src/runtime-bridge-templates.ts
|
|
2913
3112
|
import {
|
|
2914
|
-
CLI_DIAGNOSTIC_CODES as
|
|
2915
|
-
createCliDiagnosticCodeError as
|
|
3113
|
+
CLI_DIAGNOSTIC_CODES as CLI_DIAGNOSTIC_CODES10,
|
|
3114
|
+
createCliDiagnosticCodeError as createCliDiagnosticCodeError9
|
|
2916
3115
|
} from "@wp-typia/project-tools/cli-diagnostics";
|
|
2917
3116
|
var loadCliTemplatesRuntime2 = () => import("@wp-typia/project-tools/cli-templates");
|
|
2918
3117
|
async function executeTemplatesCommand({ flags }, printLine = console.log) {
|
|
@@ -2932,24 +3131,24 @@ async function executeTemplatesCommand({ flags }, printLine = console.log) {
|
|
|
2932
3131
|
}
|
|
2933
3132
|
if (subcommand === "inspect") {
|
|
2934
3133
|
if (!flags.id) {
|
|
2935
|
-
throw
|
|
3134
|
+
throw createCliDiagnosticCodeError9(CLI_DIAGNOSTIC_CODES10.MISSING_ARGUMENT, "`wp-typia templates inspect` requires <template-id>.");
|
|
2936
3135
|
}
|
|
2937
3136
|
const template = getTemplateById(flags.id);
|
|
2938
3137
|
if (!template) {
|
|
2939
|
-
throw
|
|
3138
|
+
throw createCliDiagnosticCodeError9(CLI_DIAGNOSTIC_CODES10.INVALID_ARGUMENT, `Unknown template "${flags.id}".`);
|
|
2940
3139
|
}
|
|
2941
3140
|
printBlock(printLine, [formatTemplateDetails(template)]);
|
|
2942
3141
|
return;
|
|
2943
3142
|
}
|
|
2944
|
-
throw
|
|
3143
|
+
throw createCliDiagnosticCodeError9(CLI_DIAGNOSTIC_CODES10.INVALID_COMMAND, `Unknown templates subcommand "${subcommand}". Expected list or inspect.`);
|
|
2945
3144
|
}
|
|
2946
3145
|
// src/runtime-bridge-sync.ts
|
|
2947
3146
|
import { spawnSync } from "node:child_process";
|
|
2948
3147
|
import fs3 from "node:fs";
|
|
2949
3148
|
import path4 from "node:path";
|
|
2950
3149
|
import {
|
|
2951
|
-
CLI_DIAGNOSTIC_CODES as
|
|
2952
|
-
createCliDiagnosticCodeError as
|
|
3150
|
+
CLI_DIAGNOSTIC_CODES as CLI_DIAGNOSTIC_CODES11,
|
|
3151
|
+
createCliDiagnosticCodeError as createCliDiagnosticCodeError10
|
|
2953
3152
|
} from "@wp-typia/project-tools/cli-diagnostics";
|
|
2954
3153
|
import {
|
|
2955
3154
|
formatInstallCommand,
|
|
@@ -2970,10 +3169,10 @@ function resolveSyncExecutionTarget(subcommand) {
|
|
|
2970
3169
|
if (subcommand === "ai") {
|
|
2971
3170
|
return "ai";
|
|
2972
3171
|
}
|
|
2973
|
-
throw
|
|
3172
|
+
throw createCliDiagnosticCodeError10(CLI_DIAGNOSTIC_CODES11.INVALID_COMMAND, `Unknown sync subcommand "${subcommand}". Expected one of: "ai".`);
|
|
2974
3173
|
}
|
|
2975
3174
|
function getSyncRootError(cwd) {
|
|
2976
|
-
return
|
|
3175
|
+
return createCliDiagnosticCodeError10(CLI_DIAGNOSTIC_CODES11.OUTSIDE_PROJECT_ROOT, `No generated wp-typia project root was found at ${cwd}. Run \`wp-typia sync\` from a scaffolded project or official workspace root that already contains generated sync scripts. If you expected this directory to work, cd into the scaffold root first or rerun the scaffold before syncing.`);
|
|
2977
3176
|
}
|
|
2978
3177
|
function readSyncPackageJson(packageJsonPath) {
|
|
2979
3178
|
const source = fs3.readFileSync(packageJsonPath, "utf8");
|
|
@@ -2981,7 +3180,7 @@ function readSyncPackageJson(packageJsonPath) {
|
|
|
2981
3180
|
return JSON.parse(source);
|
|
2982
3181
|
} catch (error) {
|
|
2983
3182
|
const message = error instanceof Error ? error.message : String(error);
|
|
2984
|
-
throw
|
|
3183
|
+
throw createCliDiagnosticCodeError10(CLI_DIAGNOSTIC_CODES11.INVALID_ARGUMENT, `Unable to parse ${packageJsonPath}: ${message}`, error instanceof Error ? { cause: error } : undefined);
|
|
2985
3184
|
}
|
|
2986
3185
|
}
|
|
2987
3186
|
function resolveSyncProjectContext(cwd) {
|
|
@@ -3048,7 +3247,7 @@ function assertSyncDependenciesInstalled(project, target) {
|
|
|
3048
3247
|
if (markerDir) {
|
|
3049
3248
|
return;
|
|
3050
3249
|
}
|
|
3051
|
-
throw
|
|
3250
|
+
throw createCliDiagnosticCodeError10(CLI_DIAGNOSTIC_CODES11.DEPENDENCIES_NOT_INSTALLED, `Project dependencies have not been installed yet. Run \`${formatInstallCommand(project.packageManager)}\` from the project root before \`wp-typia sync\`. The generated sync scripts rely on local tools such as \`tsx\`.`);
|
|
3052
3251
|
}
|
|
3053
3252
|
function getPackageManagerRunInvocation(packageManager, scriptName, extraArgs) {
|
|
3054
3253
|
switch (packageManager) {
|
|
@@ -3086,7 +3285,7 @@ function buildSyncPlannedCommands(project, extraArgs, target) {
|
|
|
3086
3285
|
if (target === "ai") {
|
|
3087
3286
|
const syncAiCommand2 = createSyncPlannedCommand(project, "sync-ai", extraArgs);
|
|
3088
3287
|
if (!syncAiCommand2) {
|
|
3089
|
-
throw
|
|
3288
|
+
throw createCliDiagnosticCodeError10(CLI_DIAGNOSTIC_CODES11.CONFIGURATION_MISSING, `Expected ${project.packageJsonPath} to define a \`sync-ai\` script for \`wp-typia sync ai\`.`);
|
|
3090
3289
|
}
|
|
3091
3290
|
return [syncAiCommand2];
|
|
3092
3291
|
}
|
|
@@ -3095,7 +3294,7 @@ function buildSyncPlannedCommands(project, extraArgs, target) {
|
|
|
3095
3294
|
}
|
|
3096
3295
|
const syncTypesCommand = createSyncPlannedCommand(project, "sync-types", extraArgs);
|
|
3097
3296
|
if (!syncTypesCommand) {
|
|
3098
|
-
throw
|
|
3297
|
+
throw createCliDiagnosticCodeError10(CLI_DIAGNOSTIC_CODES11.CONFIGURATION_MISSING, `Expected ${project.packageJsonPath} to define either a \`sync\` or \`sync-types\` script.`);
|
|
3099
3298
|
}
|
|
3100
3299
|
const plannedCommands = [syncTypesCommand];
|
|
3101
3300
|
const syncRestCommand = createSyncPlannedCommand(project, "sync-rest", extraArgs);
|
|
@@ -3119,7 +3318,7 @@ function runProjectScript(project, plannedCommand, options) {
|
|
|
3119
3318
|
const stderr = options.captureOutput && typeof result.stderr === "string" ? result.stderr : undefined;
|
|
3120
3319
|
const stdout = options.captureOutput && typeof result.stdout === "string" ? result.stdout : undefined;
|
|
3121
3320
|
if (result.error || result.status !== 0) {
|
|
3122
|
-
throw
|
|
3321
|
+
throw createCliDiagnosticCodeError10(CLI_DIAGNOSTIC_CODES11.COMMAND_EXECUTION, `\`${plannedCommand.displayCommand}\` failed.`, {
|
|
3123
3322
|
cause: result.error ?? (stderr ? new Error(stderr.trim()) : undefined)
|
|
3124
3323
|
});
|
|
3125
3324
|
}
|
|
@@ -3161,8 +3360,8 @@ async function executeSyncCommand({
|
|
|
3161
3360
|
// src/command-contract.ts
|
|
3162
3361
|
import path5 from "node:path";
|
|
3163
3362
|
import {
|
|
3164
|
-
CLI_DIAGNOSTIC_CODES as
|
|
3165
|
-
createCliDiagnosticCodeError as
|
|
3363
|
+
CLI_DIAGNOSTIC_CODES as CLI_DIAGNOSTIC_CODES12,
|
|
3364
|
+
createCliDiagnosticCodeError as createCliDiagnosticCodeError11
|
|
3166
3365
|
} from "@wp-typia/project-tools/cli-diagnostics";
|
|
3167
3366
|
|
|
3168
3367
|
// src/command-registry.ts
|
|
@@ -3433,10 +3632,10 @@ function looksLikeStructuredProjectInput(value) {
|
|
|
3433
3632
|
function assertPositionalAliasProjectDir(projectDir) {
|
|
3434
3633
|
const normalizedProjectDir = path5.normalize(projectDir).replace(/[\\/]+$/u, "") || path5.normalize(projectDir);
|
|
3435
3634
|
if (normalizedProjectDir === "." || normalizedProjectDir === "..") {
|
|
3436
|
-
throw
|
|
3635
|
+
throw createCliDiagnosticCodeError11(CLI_DIAGNOSTIC_CODES12.INVALID_ARGUMENT, `The positional alias does not scaffold into \`${projectDir}\`. Use \`${WP_TYPIA_CANONICAL_CREATE_USAGE}\` with an explicit child directory instead.`);
|
|
3437
3636
|
}
|
|
3438
3637
|
if (looksLikeStructuredProjectInput(projectDir)) {
|
|
3439
|
-
throw
|
|
3638
|
+
throw createCliDiagnosticCodeError11(CLI_DIAGNOSTIC_CODES12.INVALID_ARGUMENT, `The positional alias only accepts unambiguous local project directories. Use \`${WP_TYPIA_CANONICAL_CREATE_USAGE}\` for \`${projectDir}\`.`);
|
|
3440
3639
|
}
|
|
3441
3640
|
}
|
|
3442
3641
|
function normalizeWpTypiaArgv(argv) {
|
|
@@ -3450,7 +3649,7 @@ function normalizeWpTypiaArgv(argv) {
|
|
|
3450
3649
|
return argv;
|
|
3451
3650
|
}
|
|
3452
3651
|
if (firstPositional === "migrations") {
|
|
3453
|
-
throw
|
|
3652
|
+
throw createCliDiagnosticCodeError11(CLI_DIAGNOSTIC_CODES12.INVALID_ARGUMENT, "`wp-typia migrations` was removed in favor of `wp-typia migrate`. Use `wp-typia migrate <subcommand>` instead.");
|
|
3454
3653
|
}
|
|
3455
3654
|
if (isReservedTopLevelCommandName(firstPositional)) {
|
|
3456
3655
|
assertStringOptionValues(argv);
|
|
@@ -3458,7 +3657,7 @@ function normalizeWpTypiaArgv(argv) {
|
|
|
3458
3657
|
}
|
|
3459
3658
|
if (positionalIndexes.length > 1) {
|
|
3460
3659
|
const extraPositionals = positionalIndexes.slice(1).map((index) => argv[index]).filter((value) => typeof value === "string" && value.length > 0);
|
|
3461
|
-
throw
|
|
3660
|
+
throw createCliDiagnosticCodeError11(CLI_DIAGNOSTIC_CODES12.INVALID_ARGUMENT, `The positional alias only accepts a single project directory. Use \`${WP_TYPIA_CANONICAL_CREATE_USAGE}\` for scaffold invocations with additional positional arguments, or check the command spelling if you meant another top-level command. Extra positional arguments: ${extraPositionals.map((value) => `\`${value}\``).join(", ")}.`);
|
|
3462
3661
|
}
|
|
3463
3662
|
assertPositionalAliasProjectDir(firstPositional);
|
|
3464
3663
|
const normalizedArgv = [
|
|
@@ -3470,11 +3669,56 @@ function normalizeWpTypiaArgv(argv) {
|
|
|
3470
3669
|
return normalizedArgv;
|
|
3471
3670
|
}
|
|
3472
3671
|
|
|
3672
|
+
// src/node-fallback/doctor.ts
|
|
3673
|
+
import {
|
|
3674
|
+
CLI_DIAGNOSTIC_CODES as CLI_DIAGNOSTIC_CODES13,
|
|
3675
|
+
createCliCommandError as createCliCommandError2
|
|
3676
|
+
} from "@wp-typia/project-tools/cli-diagnostics";
|
|
3677
|
+
async function renderNodeFallbackDoctorJson(cwd, exitPolicy, printLine) {
|
|
3678
|
+
const {
|
|
3679
|
+
createDoctorRunSummary,
|
|
3680
|
+
getDoctorChecks,
|
|
3681
|
+
getDoctorExitFailureDetailLines
|
|
3682
|
+
} = await import("@wp-typia/project-tools/cli-doctor");
|
|
3683
|
+
const checks = await getDoctorChecks(cwd);
|
|
3684
|
+
const summary = createDoctorRunSummary(checks, { exitPolicy });
|
|
3685
|
+
printLine(JSON.stringify({
|
|
3686
|
+
checks,
|
|
3687
|
+
summary
|
|
3688
|
+
}, null, 2));
|
|
3689
|
+
if (summary.exitCode === 1) {
|
|
3690
|
+
throw createCliCommandError2({
|
|
3691
|
+
code: CLI_DIAGNOSTIC_CODES13.DOCTOR_CHECK_FAILED,
|
|
3692
|
+
command: "doctor",
|
|
3693
|
+
detailLines: getDoctorExitFailureDetailLines(checks, { exitPolicy }),
|
|
3694
|
+
summary: "One or more doctor checks failed."
|
|
3695
|
+
});
|
|
3696
|
+
}
|
|
3697
|
+
}
|
|
3698
|
+
async function dispatchNodeFallbackDoctor({
|
|
3699
|
+
cwd,
|
|
3700
|
+
mergedFlags,
|
|
3701
|
+
printLine
|
|
3702
|
+
}) {
|
|
3703
|
+
const exitPolicy = mergedFlags["workspace-only"] ? "workspace-only" : "strict";
|
|
3704
|
+
if (mergedFlags.format === "json") {
|
|
3705
|
+
await renderNodeFallbackDoctorJson(cwd, exitPolicy, printLine);
|
|
3706
|
+
return;
|
|
3707
|
+
}
|
|
3708
|
+
await executeDoctorCommand(cwd, { exitPolicy });
|
|
3709
|
+
}
|
|
3710
|
+
|
|
3473
3711
|
// src/node-fallback/dispatchers/add.ts
|
|
3474
3712
|
import {
|
|
3475
|
-
CLI_DIAGNOSTIC_CODES as
|
|
3713
|
+
CLI_DIAGNOSTIC_CODES as CLI_DIAGNOSTIC_CODES14,
|
|
3476
3714
|
createCliCommandError as createCliCommandError3
|
|
3477
3715
|
} from "@wp-typia/project-tools/cli-diagnostics";
|
|
3716
|
+
function resolveNodeFallbackAddName(positionals) {
|
|
3717
|
+
if (positionals[1] === "core-variation" && positionals[3]) {
|
|
3718
|
+
return positionals[3];
|
|
3719
|
+
}
|
|
3720
|
+
return positionals[2];
|
|
3721
|
+
}
|
|
3478
3722
|
async function dispatchNodeFallbackAdd({
|
|
3479
3723
|
cwd,
|
|
3480
3724
|
mergedFlags,
|
|
@@ -3488,11 +3732,14 @@ async function dispatchNodeFallbackAdd({
|
|
|
3488
3732
|
printLine(formatAddHelpText());
|
|
3489
3733
|
}
|
|
3490
3734
|
throw createCliCommandError3({
|
|
3491
|
-
code:
|
|
3735
|
+
code: CLI_DIAGNOSTIC_CODES14.MISSING_ARGUMENT,
|
|
3492
3736
|
command: "add",
|
|
3493
3737
|
detailLines: buildMissingAddKindDetailLines()
|
|
3494
3738
|
});
|
|
3495
3739
|
}
|
|
3740
|
+
const kind = positionals[1];
|
|
3741
|
+
const name = resolveNodeFallbackAddName(positionals);
|
|
3742
|
+
const positionalArgs = positionals.slice(1);
|
|
3496
3743
|
if (mergedFlags.format === "json") {
|
|
3497
3744
|
let completion;
|
|
3498
3745
|
try {
|
|
@@ -3501,8 +3748,9 @@ async function dispatchNodeFallbackAdd({
|
|
|
3501
3748
|
emitOutput: false,
|
|
3502
3749
|
flags: mergedFlags,
|
|
3503
3750
|
interactive: false,
|
|
3504
|
-
kind
|
|
3505
|
-
name
|
|
3751
|
+
kind,
|
|
3752
|
+
name,
|
|
3753
|
+
positionalArgs,
|
|
3506
3754
|
printLine,
|
|
3507
3755
|
warnLine
|
|
3508
3756
|
});
|
|
@@ -3514,8 +3762,8 @@ async function dispatchNodeFallbackAdd({
|
|
|
3514
3762
|
}
|
|
3515
3763
|
printLine(JSON.stringify(buildStructuredCompletionSuccessPayload("add", completion, {
|
|
3516
3764
|
dryRun: Boolean(mergedFlags["dry-run"]),
|
|
3517
|
-
kind
|
|
3518
|
-
name
|
|
3765
|
+
kind,
|
|
3766
|
+
name,
|
|
3519
3767
|
projectDir: extractCompletionProjectDir(completion) ?? cwd
|
|
3520
3768
|
}), null, 2));
|
|
3521
3769
|
return;
|
|
@@ -3524,8 +3772,9 @@ async function dispatchNodeFallbackAdd({
|
|
|
3524
3772
|
cwd,
|
|
3525
3773
|
flags: mergedFlags,
|
|
3526
3774
|
interactive: undefined,
|
|
3527
|
-
kind
|
|
3528
|
-
name
|
|
3775
|
+
kind,
|
|
3776
|
+
name,
|
|
3777
|
+
positionalArgs,
|
|
3529
3778
|
printLine,
|
|
3530
3779
|
warnLine
|
|
3531
3780
|
});
|
|
@@ -3533,7 +3782,7 @@ async function dispatchNodeFallbackAdd({
|
|
|
3533
3782
|
|
|
3534
3783
|
// src/node-fallback/dispatchers/create.ts
|
|
3535
3784
|
import {
|
|
3536
|
-
CLI_DIAGNOSTIC_CODES as
|
|
3785
|
+
CLI_DIAGNOSTIC_CODES as CLI_DIAGNOSTIC_CODES15,
|
|
3537
3786
|
createCliCommandError as createCliCommandError4
|
|
3538
3787
|
} from "@wp-typia/project-tools/cli-diagnostics";
|
|
3539
3788
|
async function dispatchNodeFallbackCreate({
|
|
@@ -3546,7 +3795,7 @@ async function dispatchNodeFallbackCreate({
|
|
|
3546
3795
|
const projectDir = positionals[1];
|
|
3547
3796
|
if (!projectDir) {
|
|
3548
3797
|
throw createCliCommandError4({
|
|
3549
|
-
code:
|
|
3798
|
+
code: CLI_DIAGNOSTIC_CODES15.MISSING_ARGUMENT,
|
|
3550
3799
|
command: "create",
|
|
3551
3800
|
detailLines: buildMissingCreateProjectDirDetailLines()
|
|
3552
3801
|
});
|
|
@@ -3577,6 +3826,39 @@ async function dispatchNodeFallbackCreate({
|
|
|
3577
3826
|
}
|
|
3578
3827
|
}
|
|
3579
3828
|
|
|
3829
|
+
// src/node-fallback/errors.ts
|
|
3830
|
+
import {
|
|
3831
|
+
CLI_DIAGNOSTIC_CODES as CLI_DIAGNOSTIC_CODES16,
|
|
3832
|
+
createCliCommandError as createCliCommandError6,
|
|
3833
|
+
formatCliDiagnosticError,
|
|
3834
|
+
isCliDiagnosticError,
|
|
3835
|
+
serializeCliDiagnosticError as serializeCliDiagnosticError2
|
|
3836
|
+
} from "@wp-typia/project-tools/cli-diagnostics";
|
|
3837
|
+
|
|
3838
|
+
// src/cli-diagnostic-output.ts
|
|
3839
|
+
import {
|
|
3840
|
+
createCliCommandError as createCliCommandError5,
|
|
3841
|
+
serializeCliDiagnosticError
|
|
3842
|
+
} from "@wp-typia/project-tools/cli-diagnostics";
|
|
3843
|
+
function prefersStructuredCliArgv(argv) {
|
|
3844
|
+
for (let index = 0;index < argv.length; index += 1) {
|
|
3845
|
+
const arg = argv[index];
|
|
3846
|
+
if (!arg) {
|
|
3847
|
+
continue;
|
|
3848
|
+
}
|
|
3849
|
+
if (arg === "--") {
|
|
3850
|
+
return false;
|
|
3851
|
+
}
|
|
3852
|
+
if (arg === "--format") {
|
|
3853
|
+
return argv[index + 1] === "json";
|
|
3854
|
+
}
|
|
3855
|
+
if (arg.startsWith("--format=")) {
|
|
3856
|
+
return arg.slice("--format=".length) === "json";
|
|
3857
|
+
}
|
|
3858
|
+
}
|
|
3859
|
+
return false;
|
|
3860
|
+
}
|
|
3861
|
+
|
|
3580
3862
|
// src/node-fallback/help.ts
|
|
3581
3863
|
var STANDALONE_GUIDANCE_LINE = "Prefer not to install Bun? Use the standalone wp-typia binary from the GitHub release assets.";
|
|
3582
3864
|
var NODE_FALLBACK_RUNTIME_SUMMARY_LINES = [
|
|
@@ -3631,9 +3913,9 @@ var NODE_FALLBACK_COMMAND_HELP_CONFIG = {
|
|
|
3631
3913
|
},
|
|
3632
3914
|
doctor: {
|
|
3633
3915
|
bodyLines: [
|
|
3634
|
-
"Runs read-only environment readiness checks. Official wp-typia workspace roots also get inventory, source-tree drift, iframe/API v3 compatibility, and shared convention checks."
|
|
3916
|
+
"Runs read-only environment readiness checks. Official wp-typia workspace roots also get inventory, source-tree drift, iframe/API v3 compatibility, and shared convention checks. Use --workspace-only for CI gates that should fail only on workspace-scoped checks while keeping environment failures advisory."
|
|
3635
3917
|
],
|
|
3636
|
-
heading: "Usage: wp-typia doctor [--format json]",
|
|
3918
|
+
heading: "Usage: wp-typia doctor [--format json] [--workspace-only]",
|
|
3637
3919
|
optionMetadata: DOCTOR_OPTION_METADATA
|
|
3638
3920
|
},
|
|
3639
3921
|
init: {
|
|
@@ -3661,6 +3943,138 @@ var NODE_FALLBACK_HELP_RENDERERS = Object.fromEntries(Object.entries(NODE_FALLBA
|
|
|
3661
3943
|
(printLine) => renderNodeFallbackCommandHelp(printLine, config)
|
|
3662
3944
|
]));
|
|
3663
3945
|
|
|
3946
|
+
// src/node-fallback/errors.ts
|
|
3947
|
+
function createNodeFallbackNoCommandCliError() {
|
|
3948
|
+
return createCliCommandError6({
|
|
3949
|
+
code: CLI_DIAGNOSTIC_CODES16.INVALID_COMMAND,
|
|
3950
|
+
command: "wp-typia",
|
|
3951
|
+
detailLines: [NODE_FALLBACK_NO_COMMAND_REASON_LINE],
|
|
3952
|
+
summary: "No command was provided."
|
|
3953
|
+
});
|
|
3954
|
+
}
|
|
3955
|
+
function isNodeFallbackNoCommandCliDiagnostic(error) {
|
|
3956
|
+
return isCliDiagnosticError(error) && error.code === CLI_DIAGNOSTIC_CODES16.INVALID_COMMAND && error.command === "wp-typia" && error.detailLines.includes(NODE_FALLBACK_NO_COMMAND_REASON_LINE);
|
|
3957
|
+
}
|
|
3958
|
+
function throwUnsupportedNodeFallbackCommand(command) {
|
|
3959
|
+
throw createCliCommandError6({
|
|
3960
|
+
code: CLI_DIAGNOSTIC_CODES16.UNSUPPORTED_COMMAND,
|
|
3961
|
+
command,
|
|
3962
|
+
detailLines: [
|
|
3963
|
+
[
|
|
3964
|
+
`The Bun-free fallback runtime does not support \`${command}\` yet.`,
|
|
3965
|
+
"Supported without Bun: `--version`, `--help`, non-interactive `create`/`init`/`add`/`migrate`, `doctor`, `sync`, `templates list`, and `templates inspect`.",
|
|
3966
|
+
`Install Bun 1.3.11+ or use \`bunx wp-typia ...\` for the full Bunli-powered runtime. ${STANDALONE_GUIDANCE_LINE}`
|
|
3967
|
+
].join(" ")
|
|
3968
|
+
],
|
|
3969
|
+
summary: "This command requires the Bun-powered runtime."
|
|
3970
|
+
});
|
|
3971
|
+
}
|
|
3972
|
+
async function handleNodeFallbackEntrypointError(error, argv) {
|
|
3973
|
+
if (prefersStructuredCliArgv(argv)) {
|
|
3974
|
+
const diagnostic = createCliCommandError6({
|
|
3975
|
+
command: resolveCanonicalCommandContext(argv),
|
|
3976
|
+
error
|
|
3977
|
+
});
|
|
3978
|
+
process.stderr.write(`${JSON.stringify({
|
|
3979
|
+
ok: false,
|
|
3980
|
+
error: serializeCliDiagnosticError2(diagnostic)
|
|
3981
|
+
}, null, 2)}
|
|
3982
|
+
`);
|
|
3983
|
+
process.exitCode = 1;
|
|
3984
|
+
return;
|
|
3985
|
+
}
|
|
3986
|
+
if (isNodeFallbackNoCommandCliDiagnostic(error)) {
|
|
3987
|
+
process.exitCode = 1;
|
|
3988
|
+
return;
|
|
3989
|
+
}
|
|
3990
|
+
console.error(`Error: ${await formatCliDiagnosticError(error)}`);
|
|
3991
|
+
process.exitCode = 1;
|
|
3992
|
+
}
|
|
3993
|
+
|
|
3994
|
+
// src/node-fallback/templates.ts
|
|
3995
|
+
import {
|
|
3996
|
+
CLI_DIAGNOSTIC_CODES as CLI_DIAGNOSTIC_CODES17,
|
|
3997
|
+
createCliCommandError as createCliCommandError7
|
|
3998
|
+
} from "@wp-typia/project-tools/cli-diagnostics";
|
|
3999
|
+
import {
|
|
4000
|
+
getTemplateById,
|
|
4001
|
+
listTemplates
|
|
4002
|
+
} from "@wp-typia/project-tools/cli-templates";
|
|
4003
|
+
function renderNodeFallbackTemplatesJson(printLine, flags, subcommand) {
|
|
4004
|
+
if (subcommand === "list") {
|
|
4005
|
+
printLine(JSON.stringify({
|
|
4006
|
+
templates: listTemplates()
|
|
4007
|
+
}, null, 2));
|
|
4008
|
+
return;
|
|
4009
|
+
}
|
|
4010
|
+
const templateId = flags.id;
|
|
4011
|
+
if (!templateId) {
|
|
4012
|
+
throw createCliCommandError7({
|
|
4013
|
+
code: CLI_DIAGNOSTIC_CODES17.MISSING_ARGUMENT,
|
|
4014
|
+
command: "templates",
|
|
4015
|
+
detailLines: ["`wp-typia templates inspect` requires <template-id>."]
|
|
4016
|
+
});
|
|
4017
|
+
}
|
|
4018
|
+
const template = getTemplateById(templateId);
|
|
4019
|
+
if (!template) {
|
|
4020
|
+
throw createCliCommandError7({
|
|
4021
|
+
code: CLI_DIAGNOSTIC_CODES17.INVALID_ARGUMENT,
|
|
4022
|
+
command: "templates",
|
|
4023
|
+
detailLines: [`Unknown template "${templateId}".`]
|
|
4024
|
+
});
|
|
4025
|
+
}
|
|
4026
|
+
printLine(JSON.stringify({
|
|
4027
|
+
template
|
|
4028
|
+
}, null, 2));
|
|
4029
|
+
}
|
|
4030
|
+
async function dispatchNodeFallbackTemplates({
|
|
4031
|
+
mergedFlags,
|
|
4032
|
+
positionals,
|
|
4033
|
+
printLine
|
|
4034
|
+
}) {
|
|
4035
|
+
const subcommand = positionals[1];
|
|
4036
|
+
const templateId = typeof mergedFlags.id === "string" ? mergedFlags.id : positionals[2];
|
|
4037
|
+
const resolvedSubcommand = subcommand ?? (templateId ? "inspect" : "list");
|
|
4038
|
+
if (resolvedSubcommand !== "list" && resolvedSubcommand !== "inspect") {
|
|
4039
|
+
throw createCliCommandError7({
|
|
4040
|
+
code: CLI_DIAGNOSTIC_CODES17.INVALID_COMMAND,
|
|
4041
|
+
command: "templates",
|
|
4042
|
+
detailLines: [
|
|
4043
|
+
`Unknown templates subcommand "${resolvedSubcommand}". Expected list or inspect.`
|
|
4044
|
+
]
|
|
4045
|
+
});
|
|
4046
|
+
}
|
|
4047
|
+
if (mergedFlags.format === "json") {
|
|
4048
|
+
renderNodeFallbackTemplatesJson(printLine, {
|
|
4049
|
+
format: mergedFlags.format,
|
|
4050
|
+
id: templateId
|
|
4051
|
+
}, resolvedSubcommand);
|
|
4052
|
+
return;
|
|
4053
|
+
}
|
|
4054
|
+
await executeTemplatesCommand({
|
|
4055
|
+
flags: {
|
|
4056
|
+
id: templateId,
|
|
4057
|
+
subcommand: resolvedSubcommand
|
|
4058
|
+
}
|
|
4059
|
+
}, printLine);
|
|
4060
|
+
}
|
|
4061
|
+
|
|
4062
|
+
// src/node-fallback/version.ts
|
|
4063
|
+
function renderNodeFallbackVersion(printLine, options = {}) {
|
|
4064
|
+
if (options.format === "json") {
|
|
4065
|
+
printLine(JSON.stringify({
|
|
4066
|
+
ok: true,
|
|
4067
|
+
data: {
|
|
4068
|
+
type: "version",
|
|
4069
|
+
name: package_default.name,
|
|
4070
|
+
version: package_default.version
|
|
4071
|
+
}
|
|
4072
|
+
}, null, 2));
|
|
4073
|
+
return;
|
|
4074
|
+
}
|
|
4075
|
+
printLine(`wp-typia ${package_default.version}`);
|
|
4076
|
+
}
|
|
4077
|
+
|
|
3664
4078
|
// src/node-cli.ts
|
|
3665
4079
|
var NODE_FALLBACK_OPTION_PARSER = buildCommandOptionParser(ALL_COMMAND_OPTION_METADATA);
|
|
3666
4080
|
var NODE_FALLBACK_BOOLEAN_OPTION_NAMES = ["help", "version"];
|
|
@@ -3670,17 +4084,6 @@ var printLine = (line) => {
|
|
|
3670
4084
|
var warnLine = (line) => {
|
|
3671
4085
|
console.warn(line);
|
|
3672
4086
|
};
|
|
3673
|
-
function createNoCommandCliError() {
|
|
3674
|
-
return createCliCommandError5({
|
|
3675
|
-
code: CLI_DIAGNOSTIC_CODES13.INVALID_COMMAND,
|
|
3676
|
-
command: "wp-typia",
|
|
3677
|
-
detailLines: [NODE_FALLBACK_NO_COMMAND_REASON_LINE],
|
|
3678
|
-
summary: "No command was provided."
|
|
3679
|
-
});
|
|
3680
|
-
}
|
|
3681
|
-
function isNoCommandCliDiagnostic(error) {
|
|
3682
|
-
return isCliDiagnosticError(error) && error.code === CLI_DIAGNOSTIC_CODES13.INVALID_COMMAND && error.command === "wp-typia" && error.detailLines.includes(NODE_FALLBACK_NO_COMMAND_REASON_LINE);
|
|
3683
|
-
}
|
|
3684
4087
|
function hasFlagBeforeTerminator(argv, flag) {
|
|
3685
4088
|
for (const arg of argv) {
|
|
3686
4089
|
if (arg === "--") {
|
|
@@ -3737,92 +4140,10 @@ function parseArgv(argv) {
|
|
|
3737
4140
|
parser: NODE_FALLBACK_OPTION_PARSER
|
|
3738
4141
|
});
|
|
3739
4142
|
}
|
|
3740
|
-
function renderVersion(options = {}) {
|
|
3741
|
-
if (options.format === "json") {
|
|
3742
|
-
printLine(JSON.stringify({
|
|
3743
|
-
ok: true,
|
|
3744
|
-
data: {
|
|
3745
|
-
type: "version",
|
|
3746
|
-
name: package_default.name,
|
|
3747
|
-
version: package_default.version
|
|
3748
|
-
}
|
|
3749
|
-
}, null, 2));
|
|
3750
|
-
return;
|
|
3751
|
-
}
|
|
3752
|
-
printLine(`wp-typia ${package_default.version}`);
|
|
3753
|
-
}
|
|
3754
|
-
function renderTemplatesJson(flags, subcommand) {
|
|
3755
|
-
if (subcommand === "list") {
|
|
3756
|
-
printLine(JSON.stringify({
|
|
3757
|
-
templates: listTemplates()
|
|
3758
|
-
}, null, 2));
|
|
3759
|
-
return;
|
|
3760
|
-
}
|
|
3761
|
-
const templateId = flags.id;
|
|
3762
|
-
if (!templateId) {
|
|
3763
|
-
throw createCliCommandError5({
|
|
3764
|
-
code: CLI_DIAGNOSTIC_CODES13.MISSING_ARGUMENT,
|
|
3765
|
-
command: "templates",
|
|
3766
|
-
detailLines: ["`wp-typia templates inspect` requires <template-id>."]
|
|
3767
|
-
});
|
|
3768
|
-
}
|
|
3769
|
-
const template = getTemplateById(templateId);
|
|
3770
|
-
if (!template) {
|
|
3771
|
-
throw createCliCommandError5({
|
|
3772
|
-
code: CLI_DIAGNOSTIC_CODES13.INVALID_ARGUMENT,
|
|
3773
|
-
command: "templates",
|
|
3774
|
-
detailLines: [`Unknown template "${templateId}".`]
|
|
3775
|
-
});
|
|
3776
|
-
}
|
|
3777
|
-
printLine(JSON.stringify({
|
|
3778
|
-
template
|
|
3779
|
-
}, null, 2));
|
|
3780
|
-
}
|
|
3781
|
-
function renderUnsupportedCommand(command) {
|
|
3782
|
-
throw createCliCommandError5({
|
|
3783
|
-
code: CLI_DIAGNOSTIC_CODES13.UNSUPPORTED_COMMAND,
|
|
3784
|
-
command,
|
|
3785
|
-
detailLines: [
|
|
3786
|
-
[
|
|
3787
|
-
`The Bun-free fallback runtime does not support \`${command}\` yet.`,
|
|
3788
|
-
"Supported without Bun: `--version`, `--help`, non-interactive `create`/`init`/`add`/`migrate`, `doctor`, `sync`, `templates list`, and `templates inspect`.",
|
|
3789
|
-
`Install Bun 1.3.11+ or use \`bunx wp-typia ...\` for the full Bunli-powered runtime. ${STANDALONE_GUIDANCE_LINE}`
|
|
3790
|
-
].join(" ")
|
|
3791
|
-
],
|
|
3792
|
-
summary: "This command requires the Bun-powered runtime."
|
|
3793
|
-
});
|
|
3794
|
-
}
|
|
3795
|
-
async function renderDoctorJson() {
|
|
3796
|
-
const [
|
|
3797
|
-
{ getDoctorChecks },
|
|
3798
|
-
{ createCliCommandError: createCliCommandError6, getDoctorFailureDetailLines }
|
|
3799
|
-
] = await Promise.all([
|
|
3800
|
-
import("@wp-typia/project-tools/cli-doctor"),
|
|
3801
|
-
import("@wp-typia/project-tools/cli-diagnostics")
|
|
3802
|
-
]);
|
|
3803
|
-
const checks = await getDoctorChecks(process.cwd());
|
|
3804
|
-
printLine(JSON.stringify({
|
|
3805
|
-
checks
|
|
3806
|
-
}, null, 2));
|
|
3807
|
-
if (checks.some((check) => check.status === "fail")) {
|
|
3808
|
-
throw createCliCommandError6({
|
|
3809
|
-
code: CLI_DIAGNOSTIC_CODES13.DOCTOR_CHECK_FAILED,
|
|
3810
|
-
command: "doctor",
|
|
3811
|
-
detailLines: getDoctorFailureDetailLines(checks),
|
|
3812
|
-
summary: "One or more doctor checks failed."
|
|
3813
|
-
});
|
|
3814
|
-
}
|
|
3815
|
-
}
|
|
3816
4143
|
var NODE_FALLBACK_COMMAND_DISPATCHERS = {
|
|
3817
4144
|
add: dispatchNodeFallbackAdd,
|
|
3818
4145
|
create: dispatchNodeFallbackCreate,
|
|
3819
|
-
doctor:
|
|
3820
|
-
if (mergedFlags.format === "json") {
|
|
3821
|
-
await renderDoctorJson();
|
|
3822
|
-
return;
|
|
3823
|
-
}
|
|
3824
|
-
await executeDoctorCommand(cwd);
|
|
3825
|
-
},
|
|
4146
|
+
doctor: dispatchNodeFallbackDoctor,
|
|
3826
4147
|
init: async ({
|
|
3827
4148
|
cwd,
|
|
3828
4149
|
mergedFlags,
|
|
@@ -3892,43 +4213,13 @@ var NODE_FALLBACK_COMMAND_DISPATCHERS = {
|
|
|
3892
4213
|
});
|
|
3893
4214
|
}
|
|
3894
4215
|
} catch (error) {
|
|
3895
|
-
throw
|
|
4216
|
+
throw createCliCommandError8({
|
|
3896
4217
|
command: "sync",
|
|
3897
4218
|
error
|
|
3898
4219
|
});
|
|
3899
4220
|
}
|
|
3900
4221
|
},
|
|
3901
|
-
templates:
|
|
3902
|
-
mergedFlags,
|
|
3903
|
-
positionals,
|
|
3904
|
-
printLine: printLine2
|
|
3905
|
-
}) => {
|
|
3906
|
-
const subcommand = positionals[1];
|
|
3907
|
-
const templateId = typeof mergedFlags.id === "string" ? mergedFlags.id : positionals[2];
|
|
3908
|
-
const resolvedSubcommand = templateId ? "inspect" : subcommand ?? "list";
|
|
3909
|
-
if (resolvedSubcommand !== "list" && resolvedSubcommand !== "inspect") {
|
|
3910
|
-
throw createCliCommandError5({
|
|
3911
|
-
code: CLI_DIAGNOSTIC_CODES13.INVALID_COMMAND,
|
|
3912
|
-
command: "templates",
|
|
3913
|
-
detailLines: [
|
|
3914
|
-
`Unknown templates subcommand "${resolvedSubcommand}". Expected list or inspect.`
|
|
3915
|
-
]
|
|
3916
|
-
});
|
|
3917
|
-
}
|
|
3918
|
-
if (mergedFlags.format === "json") {
|
|
3919
|
-
renderTemplatesJson({
|
|
3920
|
-
format: mergedFlags.format,
|
|
3921
|
-
id: templateId
|
|
3922
|
-
}, resolvedSubcommand);
|
|
3923
|
-
return;
|
|
3924
|
-
}
|
|
3925
|
-
await executeTemplatesCommand({
|
|
3926
|
-
flags: {
|
|
3927
|
-
id: templateId,
|
|
3928
|
-
subcommand: resolvedSubcommand
|
|
3929
|
-
}
|
|
3930
|
-
}, printLine2);
|
|
3931
|
-
}
|
|
4222
|
+
templates: dispatchNodeFallbackTemplates
|
|
3932
4223
|
};
|
|
3933
4224
|
async function runNodeCli(argv = process.argv.slice(2)) {
|
|
3934
4225
|
const normalizedArgv = normalizeWpTypiaArgv(argv);
|
|
@@ -3946,7 +4237,7 @@ async function runNodeCli(argv = process.argv.slice(2)) {
|
|
|
3946
4237
|
const helpTarget = command === "help" ? subcommand : command;
|
|
3947
4238
|
const versionRequested = hasFlagBeforeTerminator(cliArgv, "--version") || command === "version";
|
|
3948
4239
|
if (cliArgv.length === 0) {
|
|
3949
|
-
const noCommandError =
|
|
4240
|
+
const noCommandError = createNodeFallbackNoCommandCliError();
|
|
3950
4241
|
if (rawMergedFlags.format !== "json") {
|
|
3951
4242
|
renderNoCommandHelp(printLine);
|
|
3952
4243
|
}
|
|
@@ -3971,7 +4262,7 @@ async function runNodeCli(argv = process.argv.slice(2)) {
|
|
|
3971
4262
|
return;
|
|
3972
4263
|
}
|
|
3973
4264
|
if (versionRequested) {
|
|
3974
|
-
|
|
4265
|
+
renderNodeFallbackVersion(printLine, {
|
|
3975
4266
|
format: typeof rawMergedFlags.format === "string" ? rawMergedFlags.format : undefined
|
|
3976
4267
|
});
|
|
3977
4268
|
return;
|
|
@@ -3988,32 +4279,13 @@ async function runNodeCli(argv = process.argv.slice(2)) {
|
|
|
3988
4279
|
});
|
|
3989
4280
|
return;
|
|
3990
4281
|
}
|
|
3991
|
-
|
|
4282
|
+
throwUnsupportedNodeFallbackCommand(command ?? "(missing)");
|
|
3992
4283
|
}
|
|
3993
4284
|
async function runNodeCliEntrypoint(argv = process.argv.slice(2)) {
|
|
3994
|
-
const prefersStructuredErrorOutput = prefersStructuredCliArgv(argv);
|
|
3995
4285
|
try {
|
|
3996
4286
|
await runNodeCli(argv);
|
|
3997
4287
|
} catch (error) {
|
|
3998
|
-
|
|
3999
|
-
const diagnostic = createCliCommandError5({
|
|
4000
|
-
command: resolveCanonicalCommandContext(argv),
|
|
4001
|
-
error
|
|
4002
|
-
});
|
|
4003
|
-
process.stderr.write(`${JSON.stringify({
|
|
4004
|
-
ok: false,
|
|
4005
|
-
error: serializeCliDiagnosticError2(diagnostic)
|
|
4006
|
-
}, null, 2)}
|
|
4007
|
-
`);
|
|
4008
|
-
process.exitCode = 1;
|
|
4009
|
-
return;
|
|
4010
|
-
}
|
|
4011
|
-
if (isNoCommandCliDiagnostic(error)) {
|
|
4012
|
-
process.exitCode = 1;
|
|
4013
|
-
return;
|
|
4014
|
-
}
|
|
4015
|
-
console.error(`Error: ${await formatCliDiagnosticError(error)}`);
|
|
4016
|
-
process.exitCode = 1;
|
|
4288
|
+
await handleNodeFallbackEntrypointError(error, argv);
|
|
4017
4289
|
}
|
|
4018
4290
|
}
|
|
4019
4291
|
export {
|
|
@@ -4023,4 +4295,4 @@ export {
|
|
|
4023
4295
|
hasFlagBeforeTerminator
|
|
4024
4296
|
};
|
|
4025
4297
|
|
|
4026
|
-
//# debugId=
|
|
4298
|
+
//# debugId=89977F6E4F67703D64756E2164756E21
|