@wp-typia/project-tools 0.20.2 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/runtime/ai-feature-capability.js +2 -33
- package/dist/runtime/built-in-block-artifact-types.js +11 -0
- package/dist/runtime/built-in-block-code-artifacts.js +5 -1
- package/dist/runtime/built-in-block-code-templates/interactivity.d.ts +4 -3
- package/dist/runtime/built-in-block-code-templates/interactivity.js +259 -100
- package/dist/runtime/built-in-block-code-templates.d.ts +1 -1
- package/dist/runtime/built-in-block-code-templates.js +1 -1
- package/dist/runtime/cli-add-shared.d.ts +74 -5
- package/dist/runtime/cli-add-shared.js +61 -11
- package/dist/runtime/cli-add-workspace-ability.js +14 -61
- package/dist/runtime/cli-add-workspace-admin-view.d.ts +25 -0
- package/dist/runtime/cli-add-workspace-admin-view.js +1401 -0
- package/dist/runtime/cli-add-workspace-ai-anchors.js +2 -5
- package/dist/runtime/cli-add-workspace-ai-source-emitters.d.ts +0 -4
- package/dist/runtime/cli-add-workspace-ai-source-emitters.js +7 -17
- package/dist/runtime/cli-add-workspace-ai.js +4 -6
- package/dist/runtime/cli-add-workspace-assets.d.ts +13 -5
- package/dist/runtime/cli-add-workspace-assets.js +290 -106
- package/dist/runtime/cli-add-workspace-rest-anchors.js +2 -5
- package/dist/runtime/cli-add-workspace-rest-source-emitters.d.ts +0 -1
- package/dist/runtime/cli-add-workspace-rest-source-emitters.js +7 -14
- package/dist/runtime/cli-add-workspace-rest.js +4 -6
- package/dist/runtime/cli-add-workspace.d.ts +58 -1
- package/dist/runtime/cli-add-workspace.js +588 -18
- package/dist/runtime/cli-add.d.ts +1 -1
- package/dist/runtime/cli-add.js +1 -1
- package/dist/runtime/cli-core.d.ts +8 -5
- package/dist/runtime/cli-core.js +7 -4
- package/dist/runtime/cli-diagnostics.d.ts +83 -1
- package/dist/runtime/cli-diagnostics.js +85 -2
- package/dist/runtime/cli-doctor-workspace.js +553 -13
- package/dist/runtime/cli-doctor.d.ts +4 -2
- package/dist/runtime/cli-doctor.js +2 -1
- package/dist/runtime/cli-help.js +22 -9
- package/dist/runtime/cli-init.d.ts +67 -3
- package/dist/runtime/cli-init.js +603 -64
- package/dist/runtime/cli-validation.js +4 -3
- package/dist/runtime/external-layer-selection.d.ts +8 -2
- package/dist/runtime/external-layer-selection.js +3 -4
- package/dist/runtime/index.d.ts +9 -4
- package/dist/runtime/index.js +7 -3
- package/dist/runtime/package-json-types.d.ts +12 -0
- package/dist/runtime/package-json-types.js +1 -0
- package/dist/runtime/package-versions.d.ts +30 -2
- package/dist/runtime/package-versions.js +59 -1
- package/dist/runtime/php-utils.d.ts +16 -0
- package/dist/runtime/php-utils.js +59 -0
- package/dist/runtime/scaffold-answer-resolution.js +7 -6
- package/dist/runtime/scaffold-apply-utils.d.ts +2 -3
- package/dist/runtime/scaffold-apply-utils.js +3 -43
- package/dist/runtime/scaffold-compatibility.d.ts +2 -2
- package/dist/runtime/scaffold-compatibility.js +22 -48
- package/dist/runtime/template-source-cache.d.ts +112 -0
- package/dist/runtime/template-source-cache.js +434 -0
- package/dist/runtime/template-source-seeds.js +319 -53
- package/dist/runtime/version-floor.d.ts +26 -0
- package/dist/runtime/version-floor.js +56 -0
- package/dist/runtime/workspace-inventory.d.ts +44 -2
- package/dist/runtime/workspace-inventory.js +138 -5
- package/package.json +4 -3
|
@@ -10,8 +10,11 @@ export { normalizeBlockSlug, } from "./scaffold-identifiers.js";
|
|
|
10
10
|
* Supported top-level `wp-typia add` kinds exposed by the canonical CLI.
|
|
11
11
|
*/
|
|
12
12
|
export const ADD_KIND_IDS = [
|
|
13
|
+
"admin-view",
|
|
13
14
|
"block",
|
|
14
15
|
"variation",
|
|
16
|
+
"style",
|
|
17
|
+
"transform",
|
|
15
18
|
"pattern",
|
|
16
19
|
"binding-source",
|
|
17
20
|
"rest-resource",
|
|
@@ -32,9 +35,23 @@ export const REST_RESOURCE_METHOD_IDS = [
|
|
|
32
35
|
"delete",
|
|
33
36
|
];
|
|
34
37
|
/**
|
|
35
|
-
* Supported editor-plugin shell
|
|
38
|
+
* Supported editor-plugin shell surfaces accepted by
|
|
39
|
+
* `wp-typia add editor-plugin --slot`.
|
|
36
40
|
*/
|
|
37
|
-
export const EDITOR_PLUGIN_SLOT_IDS = ["
|
|
41
|
+
export const EDITOR_PLUGIN_SLOT_IDS = ["sidebar", "document-setting-panel"];
|
|
42
|
+
export const EDITOR_PLUGIN_SLOT_ALIASES = {
|
|
43
|
+
PluginDocumentSettingPanel: "document-setting-panel",
|
|
44
|
+
PluginSidebar: "sidebar",
|
|
45
|
+
"document-setting-panel": "document-setting-panel",
|
|
46
|
+
sidebar: "sidebar",
|
|
47
|
+
};
|
|
48
|
+
export function resolveEditorPluginSlotAlias(slot) {
|
|
49
|
+
const trimmed = slot.trim();
|
|
50
|
+
if (!Object.prototype.hasOwnProperty.call(EDITOR_PLUGIN_SLOT_ALIASES, trimmed)) {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
return EDITOR_PLUGIN_SLOT_ALIASES[trimmed];
|
|
54
|
+
}
|
|
38
55
|
/**
|
|
39
56
|
* Supported built-in block families accepted by `wp-typia add block --template`.
|
|
40
57
|
*/
|
|
@@ -175,15 +192,16 @@ export function assertValidHookAnchor(anchorBlockName) {
|
|
|
175
192
|
/**
|
|
176
193
|
* Validate and normalize the editor plugin shell slot.
|
|
177
194
|
*
|
|
178
|
-
* @param slot Optional shell slot. Defaults to `
|
|
195
|
+
* @param slot Optional shell slot. Defaults to `sidebar`.
|
|
179
196
|
* @returns The canonical editor plugin slot id.
|
|
180
197
|
* @throws {Error} When the slot is not supported by the workspace scaffold.
|
|
181
198
|
*/
|
|
182
|
-
export function assertValidEditorPluginSlot(slot = "
|
|
183
|
-
|
|
184
|
-
|
|
199
|
+
export function assertValidEditorPluginSlot(slot = "sidebar") {
|
|
200
|
+
const alias = resolveEditorPluginSlotAlias(slot);
|
|
201
|
+
if (alias) {
|
|
202
|
+
return alias;
|
|
185
203
|
}
|
|
186
|
-
throw new Error(`Editor plugin slot must be one of: ${EDITOR_PLUGIN_SLOT_IDS.join(", ")}.`);
|
|
204
|
+
throw new Error(`Editor plugin slot must be one of: ${EDITOR_PLUGIN_SLOT_IDS.join(", ")}. Legacy aliases: PluginSidebar, PluginDocumentSettingPanel.`);
|
|
187
205
|
}
|
|
188
206
|
export function readWorkspaceBlockJson(projectDir, blockSlug) {
|
|
189
207
|
const blockJsonPath = path.join(projectDir, "src", "blocks", blockSlug, "block.json");
|
|
@@ -256,6 +274,28 @@ export function assertRestResourceDoesNotExist(projectDir, restResourceSlug, inv
|
|
|
256
274
|
throw new Error(`A REST resource inventory entry already exists for ${restResourceSlug}. Choose a different name.`);
|
|
257
275
|
}
|
|
258
276
|
}
|
|
277
|
+
/**
|
|
278
|
+
* Ensure a DataViews admin screen scaffold does not already exist on disk or in
|
|
279
|
+
* the workspace inventory.
|
|
280
|
+
*
|
|
281
|
+
* @param projectDir Workspace root directory.
|
|
282
|
+
* @param adminViewSlug Normalized admin screen slug.
|
|
283
|
+
* @param inventory Parsed workspace inventory.
|
|
284
|
+
* @throws {Error} When the directory, PHP bootstrap, or inventory entry already exists.
|
|
285
|
+
*/
|
|
286
|
+
export function assertAdminViewDoesNotExist(projectDir, adminViewSlug, inventory) {
|
|
287
|
+
const adminViewDir = path.join(projectDir, "src", "admin-views", adminViewSlug);
|
|
288
|
+
const adminViewPhpPath = path.join(projectDir, "inc", "admin-views", `${adminViewSlug}.php`);
|
|
289
|
+
if (fs.existsSync(adminViewDir)) {
|
|
290
|
+
throw new Error(`An admin view already exists at ${path.relative(projectDir, adminViewDir)}. Choose a different name.`);
|
|
291
|
+
}
|
|
292
|
+
if (fs.existsSync(adminViewPhpPath)) {
|
|
293
|
+
throw new Error(`An admin view bootstrap already exists at ${path.relative(projectDir, adminViewPhpPath)}. Choose a different name.`);
|
|
294
|
+
}
|
|
295
|
+
if (inventory.adminViews.some((entry) => entry.slug === adminViewSlug)) {
|
|
296
|
+
throw new Error(`An admin view inventory entry already exists for ${adminViewSlug}. Choose a different name.`);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
259
299
|
/**
|
|
260
300
|
* Ensure a workflow ability scaffold does not already exist on disk or in the
|
|
261
301
|
* workspace inventory.
|
|
@@ -317,10 +357,13 @@ export function assertEditorPluginDoesNotExist(projectDir, editorPluginSlug, inv
|
|
|
317
357
|
*/
|
|
318
358
|
export function formatAddHelpText() {
|
|
319
359
|
return `Usage:
|
|
320
|
-
wp-typia add
|
|
360
|
+
wp-typia add admin-view <name> [--source <rest-resource:slug|core-data:kind/name>] [--dry-run]
|
|
361
|
+
wp-typia add block <name> [--template <${ADD_BLOCK_TEMPLATE_IDS.join("|")}>] [--external-layer-source <./path|github:owner/repo/path[#ref]|npm-package>] [--external-layer-id <layer-id>] [--inner-blocks-preset <freeform|ordered|horizontal|locked-structure>] [--alternate-render-targets <email,mjml,plain-text>] [--data-storage <post-meta|custom-table>] [--persistence-policy <authenticated|public>] [--dry-run]
|
|
321
362
|
wp-typia add variation <name> --block <block-slug> [--dry-run]
|
|
363
|
+
wp-typia add style <name> --block <block-slug> [--dry-run]
|
|
364
|
+
wp-typia add transform <name> --from <namespace/block> --to <block-slug|namespace/block-slug> [--dry-run]
|
|
322
365
|
wp-typia add pattern <name> [--dry-run]
|
|
323
|
-
wp-typia add binding-source <name> [--dry-run]
|
|
366
|
+
wp-typia add binding-source <name> [--block <block-slug|namespace/block-slug> --attribute <attribute>] [--dry-run]
|
|
324
367
|
wp-typia add rest-resource <name> [--namespace <vendor/v1>] [--methods <list,read,create,update,delete>] [--dry-run]
|
|
325
368
|
wp-typia add ability <name> [--dry-run]
|
|
326
369
|
wp-typia add ai-feature <name> [--namespace <vendor/v1>] [--dry-run]
|
|
@@ -330,13 +373,20 @@ export function formatAddHelpText() {
|
|
|
330
373
|
Notes:
|
|
331
374
|
\`wp-typia add\` runs only inside official ${WORKSPACE_TEMPLATE_PACKAGE} workspaces scaffolded via \`wp-typia create <project-dir> --template workspace\`.
|
|
332
375
|
Pass \`--dry-run\` to preview the workspace files that would change without writing them.
|
|
376
|
+
Interactive add flows let you choose a template when \`--template\` is omitted; non-interactive runs default to \`basic\`.
|
|
377
|
+
\`add admin-view\` scaffolds an opt-in DataViews-powered WordPress admin screen under \`src/admin-views/\`.
|
|
378
|
+
Pass \`--source rest-resource:<slug>\` to reuse a list-capable REST resource.
|
|
379
|
+
Pass \`--source core-data:postType/post\` or \`--source core-data:taxonomy/category\` to bind a WordPress-owned entity collection.
|
|
380
|
+
Public installs currently gate this workflow until \`@wp-typia/dataviews\` is published to npm.
|
|
333
381
|
\`query-loop\` is a create-time scaffold family. Use \`wp-typia create <project-dir> --template query-loop\` instead of \`wp-typia add block\`.
|
|
334
382
|
\`add variation\` targets an existing block slug from \`scripts/block-config.ts\`.
|
|
383
|
+
\`add style\` registers a Block Styles option for an existing generated block.
|
|
384
|
+
\`add transform\` adds a block-to-block transform into an existing generated block.
|
|
335
385
|
\`add pattern\` scaffolds a namespaced PHP pattern shell under \`src/patterns/\`.
|
|
336
|
-
\`add binding-source\` scaffolds shared PHP and editor registration under \`src/bindings
|
|
386
|
+
\`add binding-source\` scaffolds shared PHP and editor registration under \`src/bindings/\`; pass \`--block\` and \`--attribute\` together to declare an end-to-end bindable attribute on an existing generated block.
|
|
337
387
|
\`add rest-resource\` scaffolds plugin-level TypeScript REST contracts under \`src/rest/\` and PHP route glue under \`inc/rest/\`.
|
|
338
388
|
\`add ability\` scaffolds typed workflow abilities under \`src/abilities/\` and server registration under \`inc/abilities/\`.
|
|
339
389
|
\`add ai-feature\` scaffolds server-owned AI feature endpoints under \`src/ai-features/\` and PHP route glue under \`inc/ai-features/\`.
|
|
340
390
|
\`add hooked-block\` patches an existing workspace block's \`block.json\` \`blockHooks\` metadata.
|
|
341
|
-
\`add editor-plugin\` scaffolds a document-level editor extension under \`src/editor-plugins
|
|
391
|
+
\`add editor-plugin\` scaffolds a document-level editor extension under \`src/editor-plugins/\`; legacy aliases \`PluginSidebar\` and \`PluginDocumentSettingPanel\` resolve to \`sidebar\` and \`document-setting-panel\`.`;
|
|
342
392
|
}
|
|
@@ -5,58 +5,18 @@ import { syncTypeSchemas } from "@wp-typia/block-runtime/metadata-core";
|
|
|
5
5
|
import semver from "semver";
|
|
6
6
|
import { appendWorkspaceInventoryEntries, readWorkspaceInventory, } from "./workspace-inventory.js";
|
|
7
7
|
import { resolveWorkspaceProject } from "./workspace-project.js";
|
|
8
|
-
import { toTitleCase } from "./string-case.js";
|
|
8
|
+
import { toPascalCase, toTitleCase } from "./string-case.js";
|
|
9
|
+
import { escapeRegex, findPhpFunctionRange, hasPhpFunctionDefinition, quotePhpString, replacePhpFunctionDefinition, } from "./php-utils.js";
|
|
9
10
|
import { assertAbilityDoesNotExist, assertValidGeneratedSlug, getWorkspaceBootstrapPath, normalizeBlockSlug, patchFile, quoteTsString, rollbackWorkspaceMutation, snapshotWorkspaceFiles, } from "./cli-add-shared.js";
|
|
10
11
|
import { REQUIRED_WORKSPACE_ABILITY_COMPATIBILITY, renderScaffoldCompatibilityConfig, resolveScaffoldCompatibilityPolicy, updatePluginHeaderCompatibility, } from "./scaffold-compatibility.js";
|
|
12
|
+
import { DEFAULT_WORDPRESS_ABILITIES_VERSION, DEFAULT_WORDPRESS_CORE_ABILITIES_VERSION, } from "./package-versions.js";
|
|
11
13
|
const ABILITY_SERVER_GLOB = "/inc/abilities/*.php";
|
|
12
14
|
const ABILITY_EDITOR_SCRIPT = "build/abilities/index.js";
|
|
13
15
|
const ABILITY_EDITOR_ASSET = "build/abilities/index.asset.php";
|
|
14
16
|
const ABILITY_REGISTRY_END_MARKER = "// wp-typia add ability entries end";
|
|
15
17
|
const ABILITY_REGISTRY_START_MARKER = "// wp-typia add ability entries start";
|
|
16
|
-
const WP_ABILITIES_PACKAGE_VERSION = "^0.10.0";
|
|
17
|
-
const WP_CORE_ABILITIES_PACKAGE_VERSION = "^0.9.0";
|
|
18
18
|
const WP_ABILITIES_SCRIPT_MODULE_ID = "@wordpress/abilities";
|
|
19
19
|
const WP_CORE_ABILITIES_SCRIPT_MODULE_ID = "@wordpress/core-abilities";
|
|
20
|
-
function escapeRegex(value) {
|
|
21
|
-
return value.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
|
|
22
|
-
}
|
|
23
|
-
function quotePhpString(value) {
|
|
24
|
-
return `'${value.replace(/\\/gu, "\\\\").replace(/'/gu, "\\'")}'`;
|
|
25
|
-
}
|
|
26
|
-
function findPhpFunctionRange(source, functionName) {
|
|
27
|
-
const functionPattern = new RegExp(`function\\s+${escapeRegex(functionName)}\\s*\\([^)]*\\)\\s*\\{`, "u");
|
|
28
|
-
const match = functionPattern.exec(source);
|
|
29
|
-
if (!match) {
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
const openingBraceIndex = match.index + match[0].length - 1;
|
|
33
|
-
let depth = 0;
|
|
34
|
-
for (let index = openingBraceIndex; index < source.length; index += 1) {
|
|
35
|
-
const character = source[index];
|
|
36
|
-
if (character === "{") {
|
|
37
|
-
depth += 1;
|
|
38
|
-
}
|
|
39
|
-
else if (character === "}") {
|
|
40
|
-
depth -= 1;
|
|
41
|
-
if (depth === 0) {
|
|
42
|
-
const end = index + 1;
|
|
43
|
-
return {
|
|
44
|
-
end,
|
|
45
|
-
source: source.slice(match.index, end),
|
|
46
|
-
start: match.index,
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
function replacePhpFunctionDefinition(source, functionName, replacement) {
|
|
54
|
-
const functionRange = findPhpFunctionRange(source, functionName);
|
|
55
|
-
if (!functionRange) {
|
|
56
|
-
return source;
|
|
57
|
-
}
|
|
58
|
-
return `${source.slice(0, functionRange.start)}${replacement.trimStart()}${source.slice(functionRange.end)}`;
|
|
59
|
-
}
|
|
60
20
|
function resolveManagedDependencyVersion(existingVersion, requiredVersion) {
|
|
61
21
|
if (!existingVersion) {
|
|
62
22
|
return requiredVersion;
|
|
@@ -70,13 +30,6 @@ function resolveManagedDependencyVersion(existingVersion, requiredVersion) {
|
|
|
70
30
|
? existingVersion
|
|
71
31
|
: requiredVersion;
|
|
72
32
|
}
|
|
73
|
-
function toPascalCaseFromAbilitySlug(abilitySlug) {
|
|
74
|
-
return normalizeBlockSlug(abilitySlug)
|
|
75
|
-
.split("-")
|
|
76
|
-
.filter(Boolean)
|
|
77
|
-
.map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1))
|
|
78
|
-
.join("");
|
|
79
|
-
}
|
|
80
33
|
function toAbilityCategorySlug(workspaceNamespace) {
|
|
81
34
|
const normalizedNamespace = workspaceNamespace
|
|
82
35
|
.replace(/[^a-z0-9-]+/gu, "-")
|
|
@@ -85,7 +38,7 @@ function toAbilityCategorySlug(workspaceNamespace) {
|
|
|
85
38
|
return `${normalizedNamespace || "workspace"}-workflows`;
|
|
86
39
|
}
|
|
87
40
|
function buildAbilityConfigEntry(abilitySlug, compatibilityPolicy) {
|
|
88
|
-
const pascalCase =
|
|
41
|
+
const pascalCase = toPascalCase(abilitySlug);
|
|
89
42
|
return [
|
|
90
43
|
"\t{",
|
|
91
44
|
`\t\tclientFile: ${quoteTsString(`src/abilities/${abilitySlug}/client.ts`)},`,
|
|
@@ -127,7 +80,7 @@ function buildAbilityConfigSource(abilitySlug, workspaceNamespace) {
|
|
|
127
80
|
}, null, 2)}\n`;
|
|
128
81
|
}
|
|
129
82
|
function buildAbilityTypesSource(abilitySlug) {
|
|
130
|
-
const pascalCase =
|
|
83
|
+
const pascalCase = toPascalCase(abilitySlug);
|
|
131
84
|
return `export interface ${pascalCase}AbilityInput {
|
|
132
85
|
\tcontextId: number;
|
|
133
86
|
\tnote?: string;
|
|
@@ -142,7 +95,7 @@ export interface ${pascalCase}AbilityOutput {
|
|
|
142
95
|
`;
|
|
143
96
|
}
|
|
144
97
|
function buildAbilityDataSource(abilitySlug) {
|
|
145
|
-
const pascalCase =
|
|
98
|
+
const pascalCase = toPascalCase(abilitySlug);
|
|
146
99
|
const abilityConstBase = abilitySlug
|
|
147
100
|
.toUpperCase()
|
|
148
101
|
.replace(/[^A-Z0-9]+/gu, "_")
|
|
@@ -242,7 +195,7 @@ export async function run${pascalCase}Ability(
|
|
|
242
195
|
`;
|
|
243
196
|
}
|
|
244
197
|
function buildAbilityClientSource(abilitySlug) {
|
|
245
|
-
const pascalCase =
|
|
198
|
+
const pascalCase = toPascalCase(abilitySlug);
|
|
246
199
|
return `/**
|
|
247
200
|
* Re-export the typed ${pascalCase} ability client helpers.
|
|
248
201
|
*
|
|
@@ -651,7 +604,6 @@ function ${enqueueFunctionName}() {
|
|
|
651
604
|
/add_action\(\s*["']init["']\s*,\s*["'][^"']+_load_textdomain["']\s*\);\s*\n/u,
|
|
652
605
|
/\?>\s*$/u,
|
|
653
606
|
];
|
|
654
|
-
const hasPhpFunctionDefinition = (functionName) => new RegExp(`function\\s+${escapeRegex(functionName)}\\s*\\(`, "u").test(nextSource);
|
|
655
607
|
const insertPhpSnippet = (snippet) => {
|
|
656
608
|
for (const anchor of insertionAnchors) {
|
|
657
609
|
const candidate = nextSource.replace(anchor, (match) => `${snippet}\n${match}`);
|
|
@@ -670,14 +622,15 @@ function ${enqueueFunctionName}() {
|
|
|
670
622
|
}
|
|
671
623
|
nextSource = `${nextSource.trimEnd()}\n${snippet}\n`;
|
|
672
624
|
};
|
|
673
|
-
if (!hasPhpFunctionDefinition(loadFunctionName)) {
|
|
625
|
+
if (!hasPhpFunctionDefinition(nextSource, loadFunctionName)) {
|
|
674
626
|
insertPhpSnippet(loadFunction);
|
|
675
627
|
}
|
|
676
|
-
if (!hasPhpFunctionDefinition(enqueueFunctionName)) {
|
|
628
|
+
if (!hasPhpFunctionDefinition(nextSource, enqueueFunctionName)) {
|
|
677
629
|
insertPhpSnippet(enqueueFunction);
|
|
678
630
|
}
|
|
679
631
|
else if (!findPhpFunctionRange(nextSource, enqueueFunctionName)?.source.includes("wp_enqueue_script_module")) {
|
|
680
|
-
nextSource =
|
|
632
|
+
nextSource =
|
|
633
|
+
replacePhpFunctionDefinition(nextSource, enqueueFunctionName, enqueueFunction, { trimReplacementStart: true }) ?? nextSource;
|
|
681
634
|
}
|
|
682
635
|
if (!nextSource.includes(loadHook)) {
|
|
683
636
|
appendPhpSnippet(loadHook);
|
|
@@ -700,8 +653,8 @@ async function ensureAbilityPackageScripts(workspace) {
|
|
|
700
653
|
};
|
|
701
654
|
const nextDependencies = {
|
|
702
655
|
...(packageJson.dependencies ?? {}),
|
|
703
|
-
[WP_ABILITIES_SCRIPT_MODULE_ID]: resolveManagedDependencyVersion(packageJson.dependencies?.[WP_ABILITIES_SCRIPT_MODULE_ID],
|
|
704
|
-
[WP_CORE_ABILITIES_SCRIPT_MODULE_ID]: resolveManagedDependencyVersion(packageJson.dependencies?.[WP_CORE_ABILITIES_SCRIPT_MODULE_ID],
|
|
656
|
+
[WP_ABILITIES_SCRIPT_MODULE_ID]: resolveManagedDependencyVersion(packageJson.dependencies?.[WP_ABILITIES_SCRIPT_MODULE_ID], DEFAULT_WORDPRESS_ABILITIES_VERSION),
|
|
657
|
+
[WP_CORE_ABILITIES_SCRIPT_MODULE_ID]: resolveManagedDependencyVersion(packageJson.dependencies?.[WP_CORE_ABILITIES_SCRIPT_MODULE_ID], DEFAULT_WORDPRESS_CORE_ABILITIES_VERSION),
|
|
705
658
|
};
|
|
706
659
|
if (JSON.stringify(nextScripts) === JSON.stringify(packageJson.scripts ?? {}) &&
|
|
707
660
|
JSON.stringify(nextDependencies) === JSON.stringify(packageJson.dependencies ?? {})) {
|
|
@@ -882,7 +835,7 @@ export async function runAddAbilityCommand({ abilityName, cwd = process.cwd(), }
|
|
|
882
835
|
await fsp.writeFile(dataFilePath, buildAbilityDataSource(abilitySlug), "utf8");
|
|
883
836
|
await fsp.writeFile(clientFilePath, buildAbilityClientSource(abilitySlug), "utf8");
|
|
884
837
|
await fsp.writeFile(phpFilePath, buildAbilityPhpSource(abilitySlug, workspace), "utf8");
|
|
885
|
-
const pascalCase =
|
|
838
|
+
const pascalCase = toPascalCase(abilitySlug);
|
|
886
839
|
await syncTypeSchemas({
|
|
887
840
|
jsonSchemaFile: `src/abilities/${abilitySlug}/input.schema.json`,
|
|
888
841
|
projectRoot: workspace.projectDir,
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type RunAddAdminViewCommandOptions } from "./cli-add-shared.js";
|
|
2
|
+
/**
|
|
3
|
+
* Add one DataViews-powered WordPress admin screen scaffold to an official
|
|
4
|
+
* workspace project.
|
|
5
|
+
*
|
|
6
|
+
* @param options Command options for the admin-view scaffold workflow.
|
|
7
|
+
* @param options.adminViewName Human-entered admin screen name that will be
|
|
8
|
+
* normalized and validated before files are written.
|
|
9
|
+
* @param options.cwd Working directory used to resolve the nearest official workspace.
|
|
10
|
+
* Defaults to `process.cwd()`.
|
|
11
|
+
* @param options.source Optional data source locator. `rest-resource:<slug>`
|
|
12
|
+
* wires the screen to an existing list-capable REST resource.
|
|
13
|
+
* `core-data:<kind>/<name>` binds the screen to a supported WordPress-owned
|
|
14
|
+
* core-data entity collection.
|
|
15
|
+
* @returns A promise that resolves with the normalized `adminViewSlug`, optional
|
|
16
|
+
* `source`, and owning `projectDir` after scaffold files and inventory entries
|
|
17
|
+
* are written successfully.
|
|
18
|
+
* @throws {Error} When the command is run outside an official workspace, when
|
|
19
|
+
* the slug/source is invalid, or when a conflicting file or inventory entry exists.
|
|
20
|
+
*/
|
|
21
|
+
export declare function runAddAdminViewCommand({ adminViewName, cwd, source, }: RunAddAdminViewCommandOptions): Promise<{
|
|
22
|
+
adminViewSlug: string;
|
|
23
|
+
projectDir: string;
|
|
24
|
+
source?: string;
|
|
25
|
+
}>;
|