wp-typia 0.22.10 → 0.23.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 +5 -0
- package/bin/routing-metadata.generated.js +16 -0
- package/dist-bunli/.bunli/commands.gen.js +4630 -1298
- package/dist-bunli/{cli-2x49egkd.js → cli-1meywwsy.js} +134 -108
- package/dist-bunli/{cli-fys8vm2t.js → cli-43mx1vfb.js} +4 -1
- package/dist-bunli/{cli-tjf0070f.js → cli-9npd9was.js} +1 -1
- package/dist-bunli/{cli-add-8rvmezy0.js → cli-add-21bvpfgw.js} +4545 -2273
- package/dist-bunli/{cli-2mswafd6.js → cli-agywa5n6.js} +1 -1
- package/dist-bunli/{cli-1k61xyn2.js → cli-c2acv5dv.js} +1 -1
- package/dist-bunli/{cli-doctor-5m6xyx9q.js → cli-doctor-wy2yjsge.js} +241 -142
- package/dist-bunli/{cli-init-qv3zxmvc.js → cli-init-xnsbxncv.js} +15 -5
- package/dist-bunli/{cli-rwjkqjhs.js → cli-j8et6jvr.js} +37 -2
- package/dist-bunli/{cli-scaffold-b1ex2y80.js → cli-scaffold-zhp2ym8z.js} +6 -6
- package/dist-bunli/{cli-3fzqhpx9.js → cli-ts9thts5.js} +541 -14
- package/dist-bunli/{cli-spdrcg8k.js → cli-z5qkx2pn.js} +83 -4
- package/dist-bunli/cli.js +3 -3
- package/dist-bunli/{command-list-h96cft88.js → command-list-aqrkx021.js} +326 -57
- package/dist-bunli/{migrations-7g9rag5d.js → migrations-bx0yvc2v.js} +3 -3
- package/dist-bunli/node-cli.js +384 -44
- package/package.json +2 -2
package/dist-bunli/node-cli.js
CHANGED
|
@@ -3,7 +3,7 @@ var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
|
3
3
|
// package.json
|
|
4
4
|
var package_default = {
|
|
5
5
|
name: "wp-typia",
|
|
6
|
-
version: "0.
|
|
6
|
+
version: "0.23.0",
|
|
7
7
|
description: "Canonical CLI package for wp-typia scaffolding and project workflows",
|
|
8
8
|
packageManager: "bun@1.3.11",
|
|
9
9
|
type: "module",
|
|
@@ -73,7 +73,7 @@ var package_default = {
|
|
|
73
73
|
"@bunli/tui": "0.6.0",
|
|
74
74
|
"@bunli/utils": "0.6.0",
|
|
75
75
|
"@wp-typia/api-client": "^0.4.5",
|
|
76
|
-
"@wp-typia/project-tools": "0.
|
|
76
|
+
"@wp-typia/project-tools": "0.23.0",
|
|
77
77
|
"better-result": "^2.7.0",
|
|
78
78
|
react: "^19.2.5",
|
|
79
79
|
"react-dom": "^19.2.5",
|
|
@@ -100,6 +100,7 @@ import {
|
|
|
100
100
|
CLI_DIAGNOSTIC_CODES as CLI_DIAGNOSTIC_CODES13,
|
|
101
101
|
createCliCommandError as createCliCommandError5,
|
|
102
102
|
formatCliDiagnosticError,
|
|
103
|
+
isCliDiagnosticError,
|
|
103
104
|
serializeCliDiagnosticError as serializeCliDiagnosticError2
|
|
104
105
|
} from "@wp-typia/project-tools/cli-diagnostics";
|
|
105
106
|
|
|
@@ -124,10 +125,22 @@ var ADD_OPTION_METADATA = {
|
|
|
124
125
|
description: "Target block attribute for end-to-end binding-source workflows.",
|
|
125
126
|
type: "string"
|
|
126
127
|
},
|
|
128
|
+
auth: {
|
|
129
|
+
description: "Auth intent for manual REST contract workflows (public, authenticated, or public-write-protected).",
|
|
130
|
+
type: "string"
|
|
131
|
+
},
|
|
127
132
|
block: {
|
|
128
133
|
description: "Target block slug for variation, style, and end-to-end binding-source workflows.",
|
|
129
134
|
type: "string"
|
|
130
135
|
},
|
|
136
|
+
"controller-class": {
|
|
137
|
+
description: "Generated REST resource controller class used for route callbacks.",
|
|
138
|
+
type: "string"
|
|
139
|
+
},
|
|
140
|
+
"controller-extends": {
|
|
141
|
+
description: "Optional base class for generated REST resource controller wrappers.",
|
|
142
|
+
type: "string"
|
|
143
|
+
},
|
|
131
144
|
"data-storage": {
|
|
132
145
|
description: "Persistence storage mode for persistence-capable templates.",
|
|
133
146
|
type: "string"
|
|
@@ -153,6 +166,24 @@ var ADD_OPTION_METADATA = {
|
|
|
153
166
|
description: "Compound-only InnerBlocks preset (freeform, ordered, horizontal, locked-structure).",
|
|
154
167
|
type: "string"
|
|
155
168
|
},
|
|
169
|
+
manual: {
|
|
170
|
+
argumentKind: "flag",
|
|
171
|
+
description: "Create a type-only manual REST contract without PHP route/controller files.",
|
|
172
|
+
type: "boolean"
|
|
173
|
+
},
|
|
174
|
+
"hide-from-rest": {
|
|
175
|
+
argumentKind: "flag",
|
|
176
|
+
description: "Keep a generated post-meta contract out of WordPress REST/editor responses.",
|
|
177
|
+
type: "boolean"
|
|
178
|
+
},
|
|
179
|
+
"meta-key": {
|
|
180
|
+
description: "WordPress meta key for post-meta workflows; defaults to _<phpPrefix>_<name>.",
|
|
181
|
+
type: "string"
|
|
182
|
+
},
|
|
183
|
+
method: {
|
|
184
|
+
description: "HTTP method for manual REST contract workflows (GET, POST, PUT, PATCH, or DELETE).",
|
|
185
|
+
type: "string"
|
|
186
|
+
},
|
|
156
187
|
methods: {
|
|
157
188
|
description: "Comma-separated REST resource methods for rest-resource workflows.",
|
|
158
189
|
type: "string"
|
|
@@ -161,14 +192,50 @@ var ADD_OPTION_METADATA = {
|
|
|
161
192
|
description: "REST namespace for rest-resource and ai-feature workflows.",
|
|
162
193
|
type: "string"
|
|
163
194
|
},
|
|
195
|
+
"permission-callback": {
|
|
196
|
+
description: "PHP permission callback for generated REST resource route registrations.",
|
|
197
|
+
type: "string"
|
|
198
|
+
},
|
|
199
|
+
"post-type": {
|
|
200
|
+
description: "WordPress post type key for post-meta workflows.",
|
|
201
|
+
type: "string"
|
|
202
|
+
},
|
|
164
203
|
"persistence-policy": {
|
|
165
204
|
description: "Persistence write policy for persistence-capable templates.",
|
|
166
205
|
type: "string"
|
|
167
206
|
},
|
|
207
|
+
path: {
|
|
208
|
+
description: "Route path pattern for manual REST contract workflows, relative to the REST namespace.",
|
|
209
|
+
type: "string"
|
|
210
|
+
},
|
|
168
211
|
position: {
|
|
169
212
|
description: "Hook position for hooked-block workflows.",
|
|
170
213
|
type: "string"
|
|
171
214
|
},
|
|
215
|
+
"query-type": {
|
|
216
|
+
description: "Exported TypeScript query type for manual REST contract workflows.",
|
|
217
|
+
type: "string"
|
|
218
|
+
},
|
|
219
|
+
"response-type": {
|
|
220
|
+
description: "Exported TypeScript response type for manual REST contract workflows.",
|
|
221
|
+
type: "string"
|
|
222
|
+
},
|
|
223
|
+
"route-pattern": {
|
|
224
|
+
description: "Generated REST resource item route pattern relative to the REST namespace.",
|
|
225
|
+
type: "string"
|
|
226
|
+
},
|
|
227
|
+
"secret-field": {
|
|
228
|
+
description: "Write-only request body field for manual settings REST contracts.",
|
|
229
|
+
type: "string"
|
|
230
|
+
},
|
|
231
|
+
"secret-state-field": {
|
|
232
|
+
description: "Masked response boolean field for --secret-field; defaults to has<SecretField>.",
|
|
233
|
+
type: "string"
|
|
234
|
+
},
|
|
235
|
+
service: {
|
|
236
|
+
description: "Optional local service starter for integration-env workflows (none or docker-compose).",
|
|
237
|
+
type: "string"
|
|
238
|
+
},
|
|
172
239
|
slot: {
|
|
173
240
|
description: "Document editor shell slot for editor-plugin workflows (sidebar or document-setting-panel).",
|
|
174
241
|
type: "string"
|
|
@@ -181,9 +248,22 @@ var ADD_OPTION_METADATA = {
|
|
|
181
248
|
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.",
|
|
182
249
|
type: "string"
|
|
183
250
|
},
|
|
251
|
+
type: {
|
|
252
|
+
description: "Exported TypeScript type or interface name for standalone contract workflows.",
|
|
253
|
+
type: "string"
|
|
254
|
+
},
|
|
255
|
+
"body-type": {
|
|
256
|
+
description: "Exported TypeScript body type for manual REST contract workflows.",
|
|
257
|
+
type: "string"
|
|
258
|
+
},
|
|
184
259
|
to: {
|
|
185
260
|
description: "Target workspace block slug or full block name for transform workflows.",
|
|
186
261
|
type: "string"
|
|
262
|
+
},
|
|
263
|
+
"wp-env": {
|
|
264
|
+
argumentKind: "flag",
|
|
265
|
+
description: "Add a local @wordpress/env preset for integration-env workflows.",
|
|
266
|
+
type: "boolean"
|
|
187
267
|
}
|
|
188
268
|
};
|
|
189
269
|
// src/command-options/create.ts
|
|
@@ -977,6 +1057,11 @@ var NAME_SOURCE_VISIBLE_FIELDS = [
|
|
|
977
1057
|
"name",
|
|
978
1058
|
"source"
|
|
979
1059
|
];
|
|
1060
|
+
var NAME_TYPE_VISIBLE_FIELDS = [
|
|
1061
|
+
"kind",
|
|
1062
|
+
"name",
|
|
1063
|
+
"type"
|
|
1064
|
+
];
|
|
980
1065
|
var NAME_BLOCK_ATTRIBUTE_VISIBLE_FIELDS = [
|
|
981
1066
|
"kind",
|
|
982
1067
|
"name",
|
|
@@ -1016,6 +1101,12 @@ var NAME_NAMESPACE_VISIBLE_FIELDS = [
|
|
|
1016
1101
|
"name",
|
|
1017
1102
|
"namespace"
|
|
1018
1103
|
];
|
|
1104
|
+
var NAME_POST_TYPE_TYPE_VISIBLE_FIELDS = [
|
|
1105
|
+
"kind",
|
|
1106
|
+
"name",
|
|
1107
|
+
"post-type",
|
|
1108
|
+
"type"
|
|
1109
|
+
];
|
|
1019
1110
|
function requireAddKindName(context, message) {
|
|
1020
1111
|
if (!context.name) {
|
|
1021
1112
|
throw createCliDiagnosticCodeError3(CLI_DIAGNOSTIC_CODES4.MISSING_ARGUMENT, message);
|
|
@@ -1125,6 +1216,9 @@ function readOptionalLooseStringFlag(flags, name) {
|
|
|
1125
1216
|
function readOptionalStrictStringFlag(flags, name) {
|
|
1126
1217
|
return readOptionalCliStringFlagValue(flags, name, "strict");
|
|
1127
1218
|
}
|
|
1219
|
+
function readOptionalDashedOrCamelStringFlag(flags, dashedName, camelName) {
|
|
1220
|
+
return readOptionalStrictStringFlag(flags, dashedName) ?? readOptionalStrictStringFlag(flags, camelName);
|
|
1221
|
+
}
|
|
1128
1222
|
function requireStrictStringFlag(flags, name, message) {
|
|
1129
1223
|
const value = readOptionalStrictStringFlag(flags, name);
|
|
1130
1224
|
if (!value) {
|
|
@@ -1172,7 +1266,8 @@ var adminViewAddKindEntry = defineAddKindRegistryEntry({
|
|
|
1172
1266
|
...result.source ? { source: result.source } : {}
|
|
1173
1267
|
}),
|
|
1174
1268
|
missingNameMessage: ADMIN_VIEW_MISSING_NAME_MESSAGE,
|
|
1175
|
-
name
|
|
1269
|
+
name,
|
|
1270
|
+
warnLine: context.warnLine
|
|
1176
1271
|
});
|
|
1177
1272
|
},
|
|
1178
1273
|
sortOrder: 10,
|
|
@@ -1259,7 +1354,8 @@ var bindingSourceAddKindEntry = defineAddKindRegistryEntry({
|
|
|
1259
1354
|
bindingSourceSlug: result.bindingSourceSlug
|
|
1260
1355
|
}),
|
|
1261
1356
|
missingNameMessage: BINDING_SOURCE_MISSING_NAME_MESSAGE,
|
|
1262
|
-
name
|
|
1357
|
+
name,
|
|
1358
|
+
warnLine: context.warnLine
|
|
1263
1359
|
});
|
|
1264
1360
|
},
|
|
1265
1361
|
sortOrder: 70,
|
|
@@ -1363,6 +1459,50 @@ var blockAddKindEntry = defineAddKindRegistryEntry({
|
|
|
1363
1459
|
})
|
|
1364
1460
|
});
|
|
1365
1461
|
|
|
1462
|
+
// src/add-kinds/contract.ts
|
|
1463
|
+
var CONTRACT_MISSING_NAME_MESSAGE = "`wp-typia add contract` requires <name>. Usage: wp-typia add contract <name> [--type <ExportedTypeName>].";
|
|
1464
|
+
var contractAddKindEntry = defineAddKindRegistryEntry({
|
|
1465
|
+
completion: {
|
|
1466
|
+
nextSteps: (values) => [
|
|
1467
|
+
`Edit ${values.typesFile} when the standalone wire shape changes.`,
|
|
1468
|
+
"Run `wp-typia sync-rest` or `wp-typia sync` to refresh the generated schema artifact."
|
|
1469
|
+
],
|
|
1470
|
+
summaryLines: (values, projectDir) => [
|
|
1471
|
+
`Contract: ${values.contractSlug}`,
|
|
1472
|
+
`Source type: ${values.sourceTypeName}`,
|
|
1473
|
+
`Schema: ${values.schemaFile}`,
|
|
1474
|
+
`Project directory: ${projectDir}`
|
|
1475
|
+
],
|
|
1476
|
+
title: "Added standalone contract"
|
|
1477
|
+
},
|
|
1478
|
+
description: "Add a standalone TypeScript schema contract",
|
|
1479
|
+
nameLabel: "Contract name",
|
|
1480
|
+
async prepareExecution(context) {
|
|
1481
|
+
const name = requireAddKindName(context, CONTRACT_MISSING_NAME_MESSAGE);
|
|
1482
|
+
const typeName = readOptionalStrictStringFlag(context.flags, "type");
|
|
1483
|
+
return createNamedExecutionPlan(context, {
|
|
1484
|
+
execute: ({ cwd, name: name2 }) => context.addRuntime.runAddContractCommand({
|
|
1485
|
+
contractName: name2,
|
|
1486
|
+
cwd,
|
|
1487
|
+
typeName
|
|
1488
|
+
}),
|
|
1489
|
+
getValues: (result) => ({
|
|
1490
|
+
contractSlug: result.contractSlug,
|
|
1491
|
+
schemaFile: result.schemaFile,
|
|
1492
|
+
sourceTypeName: result.sourceTypeName,
|
|
1493
|
+
typesFile: result.typesFile
|
|
1494
|
+
}),
|
|
1495
|
+
missingNameMessage: CONTRACT_MISSING_NAME_MESSAGE,
|
|
1496
|
+
name,
|
|
1497
|
+
warnLine: context.warnLine
|
|
1498
|
+
});
|
|
1499
|
+
},
|
|
1500
|
+
sortOrder: 75,
|
|
1501
|
+
supportsDryRun: true,
|
|
1502
|
+
usage: "wp-typia add contract <name> [--type <ExportedTypeName>] [--dry-run]",
|
|
1503
|
+
visibleFieldNames: () => NAME_TYPE_VISIBLE_FIELDS
|
|
1504
|
+
});
|
|
1505
|
+
|
|
1366
1506
|
// src/add-kinds/editor-plugin.ts
|
|
1367
1507
|
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>].";
|
|
1368
1508
|
var editorPluginAddKindEntry = defineAddKindRegistryEntry({
|
|
@@ -1394,7 +1534,8 @@ var editorPluginAddKindEntry = defineAddKindRegistryEntry({
|
|
|
1394
1534
|
slot: result.slot
|
|
1395
1535
|
}),
|
|
1396
1536
|
missingNameMessage: EDITOR_PLUGIN_MISSING_NAME_MESSAGE,
|
|
1397
|
-
name
|
|
1537
|
+
name,
|
|
1538
|
+
warnLine: context.warnLine
|
|
1398
1539
|
});
|
|
1399
1540
|
},
|
|
1400
1541
|
sortOrder: 120,
|
|
@@ -1438,7 +1579,8 @@ var hookedBlockAddKindEntry = defineAddKindRegistryEntry({
|
|
|
1438
1579
|
position: result.position
|
|
1439
1580
|
}),
|
|
1440
1581
|
missingNameMessage: HOOKED_BLOCK_MISSING_NAME_MESSAGE,
|
|
1441
|
-
name
|
|
1582
|
+
name,
|
|
1583
|
+
warnLine: context.warnLine
|
|
1442
1584
|
});
|
|
1443
1585
|
},
|
|
1444
1586
|
sortOrder: 110,
|
|
@@ -1447,6 +1589,51 @@ var hookedBlockAddKindEntry = defineAddKindRegistryEntry({
|
|
|
1447
1589
|
visibleFieldNames: () => NAME_ANCHOR_POSITION_VISIBLE_FIELDS
|
|
1448
1590
|
});
|
|
1449
1591
|
|
|
1592
|
+
// 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>].";
|
|
1594
|
+
var integrationEnvAddKindEntry = defineAddKindRegistryEntry({
|
|
1595
|
+
completion: {
|
|
1596
|
+
nextSteps: (values) => [
|
|
1597
|
+
`Review scripts/integration-smoke/${values.integrationEnvSlug}.mjs and docs/integration-env/${values.integrationEnvSlug}.md.`,
|
|
1598
|
+
"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."] : []
|
|
1600
|
+
],
|
|
1601
|
+
summaryLines: (values, projectDir) => [
|
|
1602
|
+
`Integration env: ${values.integrationEnvSlug}`,
|
|
1603
|
+
`wp-env preset: ${values.withWpEnv}`,
|
|
1604
|
+
`Service starter: ${values.service}`,
|
|
1605
|
+
`Project directory: ${projectDir}`
|
|
1606
|
+
],
|
|
1607
|
+
title: "Added integration environment starter"
|
|
1608
|
+
},
|
|
1609
|
+
description: "Add an opt-in local WordPress integration smoke environment starter",
|
|
1610
|
+
nameLabel: "Integration env name",
|
|
1611
|
+
async prepareExecution(context) {
|
|
1612
|
+
const service = readOptionalStrictStringFlag(context.flags, "service");
|
|
1613
|
+
const withWpEnv = Boolean(context.flags["wp-env"]);
|
|
1614
|
+
return createNamedExecutionPlan(context, {
|
|
1615
|
+
execute: ({ cwd, name }) => context.addRuntime.runAddIntegrationEnvCommand({
|
|
1616
|
+
cwd,
|
|
1617
|
+
integrationEnvName: name,
|
|
1618
|
+
service,
|
|
1619
|
+
withWpEnv
|
|
1620
|
+
}),
|
|
1621
|
+
getValues: (result) => ({
|
|
1622
|
+
integrationEnvSlug: result.integrationEnvSlug,
|
|
1623
|
+
service: result.service,
|
|
1624
|
+
withWpEnv: String(result.withWpEnv)
|
|
1625
|
+
}),
|
|
1626
|
+
getWarnings: (result) => result.warnings,
|
|
1627
|
+
missingNameMessage: INTEGRATION_ENV_MISSING_NAME_MESSAGE,
|
|
1628
|
+
warnLine: context.warnLine
|
|
1629
|
+
});
|
|
1630
|
+
},
|
|
1631
|
+
sortOrder: 25,
|
|
1632
|
+
supportsDryRun: true,
|
|
1633
|
+
usage: "wp-typia add integration-env <name> [--wp-env] [--service <none|docker-compose>] [--dry-run]",
|
|
1634
|
+
visibleFieldNames: () => NAME_ONLY_VISIBLE_FIELDS
|
|
1635
|
+
});
|
|
1636
|
+
|
|
1450
1637
|
// src/add-kinds/pattern.ts
|
|
1451
1638
|
var PATTERN_MISSING_NAME_MESSAGE = "`wp-typia add pattern` requires <name>. Usage: wp-typia add pattern <name>.";
|
|
1452
1639
|
var patternAddKindEntry = defineAddKindRegistryEntry({
|
|
@@ -1482,47 +1669,177 @@ var patternAddKindEntry = defineAddKindRegistryEntry({
|
|
|
1482
1669
|
visibleFieldNames: () => NAME_ONLY_VISIBLE_FIELDS
|
|
1483
1670
|
});
|
|
1484
1671
|
|
|
1672
|
+
// src/add-kinds/post-meta.ts
|
|
1673
|
+
var POST_META_MISSING_NAME_MESSAGE = "`wp-typia add post-meta` requires <name>. Usage: wp-typia add post-meta <name> --post-type <post-type> [--type <ExportedTypeName>] [--meta-key <meta-key>].";
|
|
1674
|
+
var POST_META_MISSING_POST_TYPE_MESSAGE = "`wp-typia add post-meta` requires --post-type <post-type>. Usage: wp-typia add post-meta <name> --post-type <post-type>.";
|
|
1675
|
+
var postMetaAddKindEntry = defineAddKindRegistryEntry({
|
|
1676
|
+
completion: {
|
|
1677
|
+
nextSteps: (values) => [
|
|
1678
|
+
`Edit ${values.typesFile} when the post meta shape changes.`,
|
|
1679
|
+
"Run `wp-typia sync-rest --check` to verify the generated meta schema is current.",
|
|
1680
|
+
`Smoke test ${values.metaKey} on the ${values.postType} post type in WordPress.`
|
|
1681
|
+
],
|
|
1682
|
+
summaryLines: (values, projectDir) => [
|
|
1683
|
+
`Post meta contract: ${values.postMetaSlug}`,
|
|
1684
|
+
`Post type: ${values.postType}`,
|
|
1685
|
+
`Meta key: ${values.metaKey}`,
|
|
1686
|
+
`REST/editor exposure: ${values.showInRest}`,
|
|
1687
|
+
`Schema: ${values.schemaFile}`,
|
|
1688
|
+
`PHP: ${values.phpFile}`,
|
|
1689
|
+
`Project directory: ${projectDir}`
|
|
1690
|
+
],
|
|
1691
|
+
title: "Added post meta contract"
|
|
1692
|
+
},
|
|
1693
|
+
description: "Add a typed WordPress post meta contract",
|
|
1694
|
+
hiddenBooleanSubmitFields: ["hide-from-rest"],
|
|
1695
|
+
hiddenStringSubmitFields: ["meta-key"],
|
|
1696
|
+
nameLabel: "Post meta name",
|
|
1697
|
+
async prepareExecution(context) {
|
|
1698
|
+
const name = requireAddKindName(context, POST_META_MISSING_NAME_MESSAGE);
|
|
1699
|
+
const hideFromRest = Boolean(context.flags["hide-from-rest"] ?? context.flags.hideFromRest);
|
|
1700
|
+
const metaKey = readOptionalDashedOrCamelStringFlag(context.flags, "meta-key", "metaKey");
|
|
1701
|
+
const postType = readOptionalDashedOrCamelStringFlag(context.flags, "post-type", "postType") ?? requireStrictStringFlag(context.flags, "post-type", POST_META_MISSING_POST_TYPE_MESSAGE);
|
|
1702
|
+
const typeName = readOptionalStrictStringFlag(context.flags, "type");
|
|
1703
|
+
return createNamedExecutionPlan(context, {
|
|
1704
|
+
execute: ({ cwd, name: name2 }) => context.addRuntime.runAddPostMetaCommand({
|
|
1705
|
+
cwd,
|
|
1706
|
+
hideFromRest,
|
|
1707
|
+
metaKey,
|
|
1708
|
+
postMetaName: name2,
|
|
1709
|
+
postType,
|
|
1710
|
+
typeName
|
|
1711
|
+
}),
|
|
1712
|
+
getValues: (result) => ({
|
|
1713
|
+
metaKey: result.metaKey,
|
|
1714
|
+
phpFile: result.phpFile,
|
|
1715
|
+
postMetaSlug: result.postMetaSlug,
|
|
1716
|
+
postType: result.postType,
|
|
1717
|
+
schemaFile: result.schemaFile,
|
|
1718
|
+
showInRest: result.showInRest ? "enabled" : "disabled",
|
|
1719
|
+
sourceTypeName: result.sourceTypeName,
|
|
1720
|
+
typesFile: result.typesFile
|
|
1721
|
+
}),
|
|
1722
|
+
missingNameMessage: POST_META_MISSING_NAME_MESSAGE,
|
|
1723
|
+
name,
|
|
1724
|
+
warnLine: context.warnLine
|
|
1725
|
+
});
|
|
1726
|
+
},
|
|
1727
|
+
sortOrder: 85,
|
|
1728
|
+
supportsDryRun: true,
|
|
1729
|
+
usage: "wp-typia add post-meta <name> --post-type <post-type> [--type <ExportedTypeName>] [--meta-key <meta-key>] [--hide-from-rest] [--dry-run]",
|
|
1730
|
+
visibleFieldNames: () => NAME_POST_TYPE_TYPE_VISIBLE_FIELDS
|
|
1731
|
+
});
|
|
1732
|
+
|
|
1485
1733
|
// src/add-kinds/rest-resource.ts
|
|
1486
|
-
var REST_RESOURCE_MISSING_NAME_MESSAGE = "`wp-typia add rest-resource` requires <name>. Usage: wp-typia add rest-resource <name> [--namespace <vendor/v1>] [--methods <list,read,create,update,delete>].";
|
|
1734
|
+
var REST_RESOURCE_MISSING_NAME_MESSAGE = "`wp-typia add rest-resource` requires <name>. Usage: wp-typia add rest-resource <name> [--namespace <vendor/v1>] [--methods <list,read,create,update,delete>] or wp-typia add rest-resource <name> --manual [--method GET] [--path /external].";
|
|
1735
|
+
function readOptionalDashedOrCamelStringFlag2(flags, dashedName, camelName) {
|
|
1736
|
+
return readOptionalStrictStringFlag(flags, dashedName) ?? readOptionalStrictStringFlag(flags, camelName);
|
|
1737
|
+
}
|
|
1487
1738
|
var restResourceAddKindEntry = defineAddKindRegistryEntry({
|
|
1488
1739
|
completion: {
|
|
1489
|
-
nextSteps: (values) => [
|
|
1740
|
+
nextSteps: (values) => values.mode === "manual" ? [
|
|
1741
|
+
`Review src/rest/${values.restResourceSlug}/ and edit the manual contract types to match the external route owner.`,
|
|
1742
|
+
"Run sync-rest --check after changing the contract types to verify schemas, OpenAPI, and client artifacts."
|
|
1743
|
+
] : [
|
|
1490
1744
|
`Review src/rest/${values.restResourceSlug}/ and inc/rest/${values.restResourceSlug}.php.`,
|
|
1491
1745
|
"Run your workspace build or dev command to verify the generated REST resource contract."
|
|
1492
1746
|
],
|
|
1493
1747
|
summaryLines: (values, projectDir) => [
|
|
1494
1748
|
`REST resource: ${values.restResourceSlug}`,
|
|
1749
|
+
`Mode: ${values.mode}`,
|
|
1495
1750
|
`Namespace: ${values.namespace}`,
|
|
1496
|
-
|
|
1751
|
+
...values.mode === "manual" ? [
|
|
1752
|
+
`Route: ${values.method} /${values.namespace}${values.pathPattern}`,
|
|
1753
|
+
`Auth: ${values.auth}`,
|
|
1754
|
+
...values.secretFieldName ? [
|
|
1755
|
+
`Secret field: ${values.secretFieldName} -> ${values.secretStateFieldName}`
|
|
1756
|
+
] : []
|
|
1757
|
+
] : [
|
|
1758
|
+
`Methods: ${values.methods}`,
|
|
1759
|
+
...values.routePattern ? [`Item route: /${values.namespace}${values.routePattern}`] : [],
|
|
1760
|
+
...values.permissionCallback ? [`Permission callback: ${values.permissionCallback}`] : [],
|
|
1761
|
+
...values.controllerClass ? [`Controller class: ${values.controllerClass}`] : []
|
|
1762
|
+
],
|
|
1497
1763
|
`Project directory: ${projectDir}`
|
|
1498
1764
|
],
|
|
1499
|
-
title: "Added
|
|
1500
|
-
},
|
|
1501
|
-
description: "Add a
|
|
1765
|
+
title: "Added REST resource contract"
|
|
1766
|
+
},
|
|
1767
|
+
description: "Add a generated or type-only REST resource contract",
|
|
1768
|
+
hiddenBooleanSubmitFields: ["manual"],
|
|
1769
|
+
hiddenStringSubmitFields: [
|
|
1770
|
+
"auth",
|
|
1771
|
+
"body-type",
|
|
1772
|
+
"controller-class",
|
|
1773
|
+
"controller-extends",
|
|
1774
|
+
"method",
|
|
1775
|
+
"path",
|
|
1776
|
+
"permission-callback",
|
|
1777
|
+
"query-type",
|
|
1778
|
+
"response-type",
|
|
1779
|
+
"route-pattern",
|
|
1780
|
+
"secret-field",
|
|
1781
|
+
"secret-state-field"
|
|
1782
|
+
],
|
|
1502
1783
|
nameLabel: "REST resource name",
|
|
1503
1784
|
async prepareExecution(context) {
|
|
1504
1785
|
const name = requireAddKindName(context, REST_RESOURCE_MISSING_NAME_MESSAGE);
|
|
1786
|
+
const auth = readOptionalStrictStringFlag(context.flags, "auth");
|
|
1787
|
+
const bodyTypeName = readOptionalStrictStringFlag(context.flags, "body-type");
|
|
1788
|
+
const controllerClass = readOptionalDashedOrCamelStringFlag2(context.flags, "controller-class", "controllerClass");
|
|
1789
|
+
const controllerExtends = readOptionalDashedOrCamelStringFlag2(context.flags, "controller-extends", "controllerExtends");
|
|
1790
|
+
const manual = Boolean(context.flags.manual);
|
|
1791
|
+
const method = readOptionalStrictStringFlag(context.flags, "method");
|
|
1505
1792
|
const methods = readOptionalStrictStringFlag(context.flags, "methods");
|
|
1506
1793
|
const namespace = readOptionalStrictStringFlag(context.flags, "namespace");
|
|
1794
|
+
const permissionCallback = readOptionalDashedOrCamelStringFlag2(context.flags, "permission-callback", "permissionCallback");
|
|
1795
|
+
const pathPattern = readOptionalStrictStringFlag(context.flags, "path");
|
|
1796
|
+
const queryTypeName = readOptionalStrictStringFlag(context.flags, "query-type");
|
|
1797
|
+
const responseTypeName = readOptionalStrictStringFlag(context.flags, "response-type");
|
|
1798
|
+
const routePattern = readOptionalDashedOrCamelStringFlag2(context.flags, "route-pattern", "routePattern");
|
|
1799
|
+
const secretFieldName = readOptionalDashedOrCamelStringFlag2(context.flags, "secret-field", "secretField");
|
|
1800
|
+
const secretStateFieldName = readOptionalDashedOrCamelStringFlag2(context.flags, "secret-state-field", "secretStateField");
|
|
1507
1801
|
return createNamedExecutionPlan(context, {
|
|
1508
1802
|
execute: ({ cwd, name: name2 }) => context.addRuntime.runAddRestResourceCommand({
|
|
1803
|
+
auth,
|
|
1804
|
+
bodyTypeName,
|
|
1805
|
+
controllerClass,
|
|
1806
|
+
controllerExtends,
|
|
1509
1807
|
cwd,
|
|
1808
|
+
manual,
|
|
1809
|
+
method,
|
|
1510
1810
|
methods,
|
|
1511
1811
|
namespace,
|
|
1512
|
-
|
|
1812
|
+
permissionCallback,
|
|
1813
|
+
pathPattern,
|
|
1814
|
+
queryTypeName,
|
|
1815
|
+
restResourceName: name2,
|
|
1816
|
+
responseTypeName,
|
|
1817
|
+
routePattern,
|
|
1818
|
+
secretFieldName,
|
|
1819
|
+
secretStateFieldName
|
|
1513
1820
|
}),
|
|
1514
1821
|
getValues: (result) => ({
|
|
1822
|
+
auth: result.auth ?? "",
|
|
1823
|
+
controllerClass: result.controllerClass ?? "",
|
|
1824
|
+
method: result.method ?? "",
|
|
1515
1825
|
methods: result.methods.join(", "),
|
|
1826
|
+
mode: result.mode,
|
|
1516
1827
|
namespace: result.namespace,
|
|
1517
|
-
|
|
1828
|
+
pathPattern: result.pathPattern ?? "",
|
|
1829
|
+
permissionCallback: result.permissionCallback ?? "",
|
|
1830
|
+
restResourceSlug: result.restResourceSlug,
|
|
1831
|
+
routePattern: result.routePattern ?? "",
|
|
1832
|
+
secretFieldName: result.secretFieldName ?? "",
|
|
1833
|
+
secretStateFieldName: result.secretStateFieldName ?? ""
|
|
1518
1834
|
}),
|
|
1519
1835
|
missingNameMessage: REST_RESOURCE_MISSING_NAME_MESSAGE,
|
|
1520
|
-
name
|
|
1836
|
+
name,
|
|
1837
|
+
warnLine: context.warnLine
|
|
1521
1838
|
});
|
|
1522
1839
|
},
|
|
1523
1840
|
sortOrder: 80,
|
|
1524
1841
|
supportsDryRun: true,
|
|
1525
|
-
usage: "wp-typia add rest-resource <name> [--namespace <vendor/v1>] [--methods <list,read,create,update,delete>] [--dry-run]",
|
|
1842
|
+
usage: "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>] [--manual --method <GET|POST|PUT|PATCH|DELETE> --auth <public|authenticated|public-write-protected> --path <route-pattern> --query-type <Type> --body-type <Type> --response-type <Type> --secret-field <field> --secret-state-field <field>] [--dry-run]",
|
|
1526
1843
|
visibleFieldNames: () => NAME_NAMESPACE_METHODS_VISIBLE_FIELDS
|
|
1527
1844
|
});
|
|
1528
1845
|
|
|
@@ -1557,7 +1874,8 @@ var styleAddKindEntry = defineAddKindRegistryEntry({
|
|
|
1557
1874
|
styleSlug: result.styleSlug
|
|
1558
1875
|
}),
|
|
1559
1876
|
missingNameMessage: STYLE_MISSING_NAME_MESSAGE,
|
|
1560
|
-
name
|
|
1877
|
+
name,
|
|
1878
|
+
warnLine: context.warnLine
|
|
1561
1879
|
});
|
|
1562
1880
|
},
|
|
1563
1881
|
sortOrder: 40,
|
|
@@ -1602,7 +1920,8 @@ var transformAddKindEntry = defineAddKindRegistryEntry({
|
|
|
1602
1920
|
transformSlug: result.transformSlug
|
|
1603
1921
|
}),
|
|
1604
1922
|
missingNameMessage: TRANSFORM_MISSING_NAME_MESSAGE,
|
|
1605
|
-
name
|
|
1923
|
+
name,
|
|
1924
|
+
warnLine: context.warnLine
|
|
1606
1925
|
});
|
|
1607
1926
|
},
|
|
1608
1927
|
sortOrder: 50,
|
|
@@ -1642,7 +1961,8 @@ var variationAddKindEntry = defineAddKindRegistryEntry({
|
|
|
1642
1961
|
variationSlug: result.variationSlug
|
|
1643
1962
|
}),
|
|
1644
1963
|
missingNameMessage: VARIATION_MISSING_NAME_MESSAGE,
|
|
1645
|
-
name
|
|
1964
|
+
name,
|
|
1965
|
+
warnLine: context.warnLine
|
|
1646
1966
|
});
|
|
1647
1967
|
},
|
|
1648
1968
|
sortOrder: 30,
|
|
@@ -1655,12 +1975,15 @@ var variationAddKindEntry = defineAddKindRegistryEntry({
|
|
|
1655
1975
|
var ADD_KIND_REGISTRY = {
|
|
1656
1976
|
"admin-view": adminViewAddKindEntry,
|
|
1657
1977
|
block: blockAddKindEntry,
|
|
1978
|
+
"integration-env": integrationEnvAddKindEntry,
|
|
1658
1979
|
variation: variationAddKindEntry,
|
|
1659
1980
|
style: styleAddKindEntry,
|
|
1660
1981
|
transform: transformAddKindEntry,
|
|
1661
1982
|
pattern: patternAddKindEntry,
|
|
1662
1983
|
"binding-source": bindingSourceAddKindEntry,
|
|
1984
|
+
contract: contractAddKindEntry,
|
|
1663
1985
|
"rest-resource": restResourceAddKindEntry,
|
|
1986
|
+
"post-meta": postMetaAddKindEntry,
|
|
1664
1987
|
ability: abilityAddKindEntry,
|
|
1665
1988
|
"ai-feature": aiFeatureAddKindEntry,
|
|
1666
1989
|
"hooked-block": hookedBlockAddKindEntry,
|
|
@@ -1873,6 +2196,11 @@ async function simulateWorkspaceAddDryRun({
|
|
|
1873
2196
|
}
|
|
1874
2197
|
}
|
|
1875
2198
|
|
|
2199
|
+
// src/string-utils.ts
|
|
2200
|
+
function escapeRegExp(source) {
|
|
2201
|
+
return source.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
|
|
2202
|
+
}
|
|
2203
|
+
|
|
1876
2204
|
// src/output-markers.ts
|
|
1877
2205
|
var UNICODE_OUTPUT_MARKERS = {
|
|
1878
2206
|
dryRun: "\uD83E\uDDEA",
|
|
@@ -1888,9 +2216,6 @@ var ASCII_OUTPUT_MARKERS = {
|
|
|
1888
2216
|
};
|
|
1889
2217
|
var ASCII_ENV_TRUTHY_VALUES = new Set(["1", "on", "true", "yes"]);
|
|
1890
2218
|
var ASCII_ENV_FALSY_VALUES = new Set(["0", "off", "false", "no"]);
|
|
1891
|
-
function escapeRegExp(source) {
|
|
1892
|
-
return source.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1893
|
-
}
|
|
1894
2219
|
function readAsciiPreferenceFromEnv(env) {
|
|
1895
2220
|
const rawValue = env.WP_TYPIA_ASCII;
|
|
1896
2221
|
if (typeof rawValue !== "string") {
|
|
@@ -2053,10 +2378,7 @@ import {
|
|
|
2053
2378
|
CLI_DIAGNOSTIC_CODES as CLI_DIAGNOSTIC_CODES6,
|
|
2054
2379
|
createCliDiagnosticCodeError as createCliDiagnosticCodeError5
|
|
2055
2380
|
} from "@wp-typia/project-tools/cli-diagnostics";
|
|
2056
|
-
|
|
2057
|
-
return source.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
|
|
2058
|
-
}
|
|
2059
|
-
var LOOSE_CREATE_COMPLETION_PACKAGE_MANAGER_PATTERN = new RegExp(`^(?:corepack\\s+)?(${PACKAGE_MANAGER_IDS.map(escapeRegExp2).join("|")})(?=$|[@:/+\\s])`, "iu");
|
|
2381
|
+
var LOOSE_CREATE_COMPLETION_PACKAGE_MANAGER_PATTERN = new RegExp(`^(?:corepack\\s+)?(${PACKAGE_MANAGER_IDS.map(escapeRegExp).join("|")})(?=$|[@:/+\\s])`, "iu");
|
|
2060
2382
|
function parseCreateCompletionPackageManager(packageManager) {
|
|
2061
2383
|
const normalizedPackageManager = packageManager.trim();
|
|
2062
2384
|
const parsedPackageManager = parsePackageManagerField(normalizedPackageManager);
|
|
@@ -2532,22 +2854,24 @@ async function executeInitCommand({ apply, cwd, packageManager, projectDir }, op
|
|
|
2532
2854
|
}
|
|
2533
2855
|
// src/runtime-bridge-migrate.ts
|
|
2534
2856
|
var loadMigrationsRuntime = () => import("@wp-typia/project-tools/migrations");
|
|
2857
|
+
var defaultPrintLine = (line) => {
|
|
2858
|
+
process.stdout.write(`${line}
|
|
2859
|
+
`);
|
|
2860
|
+
};
|
|
2535
2861
|
async function executeMigrateCommand({
|
|
2536
2862
|
command,
|
|
2537
2863
|
cwd,
|
|
2538
2864
|
flags,
|
|
2865
|
+
printLine = defaultPrintLine,
|
|
2539
2866
|
prompt,
|
|
2540
2867
|
renderLine
|
|
2541
2868
|
}) {
|
|
2542
2869
|
try {
|
|
2543
2870
|
const { formatMigrationHelpText, parseMigrationArgs, runMigrationCommand } = await loadMigrationsRuntime();
|
|
2871
|
+
const outputLine = renderLine ?? printLine;
|
|
2544
2872
|
if (!command) {
|
|
2545
2873
|
const helpText = formatMigrationHelpText();
|
|
2546
|
-
|
|
2547
|
-
renderLine(helpText);
|
|
2548
|
-
} else {
|
|
2549
|
-
console.log(helpText);
|
|
2550
|
-
}
|
|
2874
|
+
outputLine(helpText);
|
|
2551
2875
|
return;
|
|
2552
2876
|
}
|
|
2553
2877
|
const argv = [command];
|
|
@@ -2563,11 +2887,7 @@ async function executeMigrateCommand({
|
|
|
2563
2887
|
const lines = renderLine ? [] : null;
|
|
2564
2888
|
const captureLine = (line) => {
|
|
2565
2889
|
lines?.push(line);
|
|
2566
|
-
|
|
2567
|
-
renderLine(line);
|
|
2568
|
-
return;
|
|
2569
|
-
}
|
|
2570
|
-
console.log(line);
|
|
2890
|
+
outputLine(line);
|
|
2571
2891
|
};
|
|
2572
2892
|
const result = await runMigrationCommand(parsed, cwd, {
|
|
2573
2893
|
prompt,
|
|
@@ -3350,6 +3670,17 @@ var printLine = (line) => {
|
|
|
3350
3670
|
var warnLine = (line) => {
|
|
3351
3671
|
console.warn(line);
|
|
3352
3672
|
};
|
|
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
|
+
}
|
|
3353
3684
|
function hasFlagBeforeTerminator(argv, flag) {
|
|
3354
3685
|
for (const arg of argv) {
|
|
3355
3686
|
if (arg === "--") {
|
|
@@ -3516,12 +3847,14 @@ var NODE_FALLBACK_COMMAND_DISPATCHERS = {
|
|
|
3516
3847
|
migrate: async ({
|
|
3517
3848
|
cwd,
|
|
3518
3849
|
mergedFlags,
|
|
3519
|
-
positionals
|
|
3850
|
+
positionals,
|
|
3851
|
+
printLine: printLine2
|
|
3520
3852
|
}) => {
|
|
3521
3853
|
await executeMigrateCommand({
|
|
3522
3854
|
command: positionals[1],
|
|
3523
3855
|
cwd,
|
|
3524
|
-
flags: mergedFlags
|
|
3856
|
+
flags: mergedFlags,
|
|
3857
|
+
printLine: printLine2
|
|
3525
3858
|
});
|
|
3526
3859
|
},
|
|
3527
3860
|
sync: async ({
|
|
@@ -3567,7 +3900,8 @@ var NODE_FALLBACK_COMMAND_DISPATCHERS = {
|
|
|
3567
3900
|
},
|
|
3568
3901
|
templates: async ({
|
|
3569
3902
|
mergedFlags,
|
|
3570
|
-
positionals
|
|
3903
|
+
positionals,
|
|
3904
|
+
printLine: printLine2
|
|
3571
3905
|
}) => {
|
|
3572
3906
|
const subcommand = positionals[1];
|
|
3573
3907
|
const templateId = typeof mergedFlags.id === "string" ? mergedFlags.id : positionals[2];
|
|
@@ -3593,7 +3927,7 @@ var NODE_FALLBACK_COMMAND_DISPATCHERS = {
|
|
|
3593
3927
|
id: templateId,
|
|
3594
3928
|
subcommand: resolvedSubcommand
|
|
3595
3929
|
}
|
|
3596
|
-
});
|
|
3930
|
+
}, printLine2);
|
|
3597
3931
|
}
|
|
3598
3932
|
};
|
|
3599
3933
|
async function runNodeCli(argv = process.argv.slice(2)) {
|
|
@@ -3612,9 +3946,11 @@ async function runNodeCli(argv = process.argv.slice(2)) {
|
|
|
3612
3946
|
const helpTarget = command === "help" ? subcommand : command;
|
|
3613
3947
|
const versionRequested = hasFlagBeforeTerminator(cliArgv, "--version") || command === "version";
|
|
3614
3948
|
if (cliArgv.length === 0) {
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3949
|
+
const noCommandError = createNoCommandCliError();
|
|
3950
|
+
if (rawMergedFlags.format !== "json") {
|
|
3951
|
+
renderNoCommandHelp(printLine);
|
|
3952
|
+
}
|
|
3953
|
+
throw noCommandError;
|
|
3618
3954
|
}
|
|
3619
3955
|
if (helpRequested) {
|
|
3620
3956
|
if (helpTarget) {
|
|
@@ -3672,6 +4008,10 @@ async function runNodeCliEntrypoint(argv = process.argv.slice(2)) {
|
|
|
3672
4008
|
process.exitCode = 1;
|
|
3673
4009
|
return;
|
|
3674
4010
|
}
|
|
4011
|
+
if (isNoCommandCliDiagnostic(error)) {
|
|
4012
|
+
process.exitCode = 1;
|
|
4013
|
+
return;
|
|
4014
|
+
}
|
|
3675
4015
|
console.error(`Error: ${await formatCliDiagnosticError(error)}`);
|
|
3676
4016
|
process.exitCode = 1;
|
|
3677
4017
|
}
|
|
@@ -3683,4 +4023,4 @@ export {
|
|
|
3683
4023
|
hasFlagBeforeTerminator
|
|
3684
4024
|
};
|
|
3685
4025
|
|
|
3686
|
-
//# debugId=
|
|
4026
|
+
//# debugId=CA11CB4ECD0D26E464756E2164756E21
|