@wp-typia/project-tools 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/dist/runtime/ai-feature-artifacts.js +4 -1
- package/dist/runtime/block-generator-service-spec.js +2 -1
- package/dist/runtime/built-in-block-non-ts-basic-artifacts.d.ts +9 -0
- package/dist/runtime/built-in-block-non-ts-basic-artifacts.js +84 -0
- package/dist/runtime/built-in-block-non-ts-compound-artifacts.d.ts +9 -0
- package/dist/runtime/built-in-block-non-ts-compound-artifacts.js +36 -0
- package/dist/runtime/built-in-block-non-ts-compound-templates.d.ts +23 -0
- package/dist/runtime/built-in-block-non-ts-compound-templates.js +453 -0
- package/dist/runtime/built-in-block-non-ts-family-artifacts.d.ts +8 -26
- package/dist/runtime/built-in-block-non-ts-family-artifacts.js +8 -1034
- package/dist/runtime/built-in-block-non-ts-interactivity-artifacts.d.ts +9 -0
- package/dist/runtime/built-in-block-non-ts-interactivity-artifacts.js +83 -0
- package/dist/runtime/built-in-block-non-ts-persistence-artifacts.d.ts +9 -0
- package/dist/runtime/built-in-block-non-ts-persistence-artifacts.js +33 -0
- package/dist/runtime/built-in-block-non-ts-persistence-templates.d.ts +23 -0
- package/dist/runtime/built-in-block-non-ts-persistence-templates.js +395 -0
- package/dist/runtime/cli-add-block-json.js +5 -1
- package/dist/runtime/cli-add-collision.js +8 -0
- package/dist/runtime/cli-add-help.js +14 -10
- package/dist/runtime/cli-add-kind-ids.d.ts +1 -1
- package/dist/runtime/cli-add-kind-ids.js +1 -0
- package/dist/runtime/cli-add-types.d.ts +45 -6
- package/dist/runtime/cli-add-types.js +2 -0
- package/dist/runtime/cli-add-validation.d.ts +7 -0
- package/dist/runtime/cli-add-validation.js +9 -0
- package/dist/runtime/cli-add-workspace-ability-anchors.d.ts +24 -0
- package/dist/runtime/cli-add-workspace-ability-anchors.js +294 -0
- package/dist/runtime/cli-add-workspace-ability-registry.d.ts +10 -0
- package/dist/runtime/cli-add-workspace-ability-registry.js +51 -0
- package/dist/runtime/cli-add-workspace-ability-scaffold.d.ts +1 -1
- package/dist/runtime/cli-add-workspace-ability-scaffold.js +5 -308
- package/dist/runtime/cli-add-workspace-admin-view-scaffold.js +6 -2
- package/dist/runtime/cli-add-workspace-admin-view-templates-core-data.d.ts +34 -0
- package/dist/runtime/cli-add-workspace-admin-view-templates-core-data.js +483 -0
- package/dist/runtime/cli-add-workspace-admin-view-templates-default.d.ts +30 -0
- package/dist/runtime/cli-add-workspace-admin-view-templates-default.js +310 -0
- package/dist/runtime/cli-add-workspace-admin-view-templates-rest.d.ts +25 -0
- package/dist/runtime/cli-add-workspace-admin-view-templates-rest.js +124 -0
- package/dist/runtime/cli-add-workspace-admin-view-templates-settings.d.ts +34 -0
- package/dist/runtime/cli-add-workspace-admin-view-templates-settings.js +370 -0
- package/dist/runtime/cli-add-workspace-admin-view-templates-shared.d.ts +49 -0
- package/dist/runtime/cli-add-workspace-admin-view-templates-shared.js +259 -0
- package/dist/runtime/cli-add-workspace-admin-view-templates.d.ts +18 -27
- package/dist/runtime/cli-add-workspace-admin-view-templates.js +30 -1326
- package/dist/runtime/cli-add-workspace-ai-anchors.d.ts +4 -4
- package/dist/runtime/cli-add-workspace-ai-anchors.js +8 -233
- package/dist/runtime/cli-add-workspace-ai-scaffold.js +4 -2
- package/dist/runtime/cli-add-workspace-ai-source-emitters.d.ts +1 -4
- package/dist/runtime/cli-add-workspace-ai-source-emitters.js +1 -129
- package/dist/runtime/cli-add-workspace-ai-sync-rest-anchors.d.ts +5 -0
- package/dist/runtime/cli-add-workspace-ai-sync-rest-anchors.js +236 -0
- package/dist/runtime/cli-add-workspace-ai-sync-script-source.d.ts +4 -0
- package/dist/runtime/cli-add-workspace-ai-sync-script-source.js +145 -0
- package/dist/runtime/cli-add-workspace-assets.d.ts +6 -63
- package/dist/runtime/cli-add-workspace-assets.js +6 -950
- package/dist/runtime/cli-add-workspace-binding-source-anchors.d.ts +23 -0
- package/dist/runtime/cli-add-workspace-binding-source-anchors.js +112 -0
- package/dist/runtime/cli-add-workspace-binding-source-source-emitters.d.ts +33 -0
- package/dist/runtime/cli-add-workspace-binding-source-source-emitters.js +436 -0
- package/dist/runtime/cli-add-workspace-binding-source-types.d.ts +20 -0
- package/dist/runtime/cli-add-workspace-binding-source-types.js +1 -0
- package/dist/runtime/cli-add-workspace-binding-source.d.ts +40 -0
- package/dist/runtime/cli-add-workspace-binding-source.js +275 -0
- package/dist/runtime/cli-add-workspace-block-style.d.ts +22 -0
- package/dist/runtime/cli-add-workspace-block-style.js +148 -0
- package/dist/runtime/cli-add-workspace-block-transform.d.ts +32 -0
- package/dist/runtime/cli-add-workspace-block-transform.js +197 -0
- package/dist/runtime/cli-add-workspace-contract.js +1 -1
- package/dist/runtime/cli-add-workspace-core-variation.d.ts +20 -0
- package/dist/runtime/cli-add-workspace-core-variation.js +322 -0
- package/dist/runtime/cli-add-workspace-editor-plugin-anchors.d.ts +37 -0
- package/dist/runtime/cli-add-workspace-editor-plugin-anchors.js +206 -0
- package/dist/runtime/cli-add-workspace-editor-plugin-source-emitters.d.ts +47 -0
- package/dist/runtime/cli-add-workspace-editor-plugin-source-emitters.js +219 -0
- package/dist/runtime/cli-add-workspace-editor-plugin.d.ts +22 -0
- package/dist/runtime/cli-add-workspace-editor-plugin.js +78 -0
- package/dist/runtime/cli-add-workspace-hooked-block.d.ts +23 -0
- package/dist/runtime/cli-add-workspace-hooked-block.js +57 -0
- package/dist/runtime/cli-add-workspace-integration-env-files.d.ts +33 -0
- package/dist/runtime/cli-add-workspace-integration-env-files.js +65 -0
- package/dist/runtime/cli-add-workspace-integration-env-package-json.d.ts +38 -0
- package/dist/runtime/cli-add-workspace-integration-env-package-json.js +122 -0
- package/dist/runtime/cli-add-workspace-integration-env-source-emitters.d.ts +44 -0
- package/dist/runtime/cli-add-workspace-integration-env-source-emitters.js +262 -0
- package/dist/runtime/cli-add-workspace-integration-env.d.ts +3 -1
- package/dist/runtime/cli-add-workspace-integration-env.js +10 -313
- package/dist/runtime/cli-add-workspace-pattern-anchors.d.ts +10 -0
- package/dist/runtime/cli-add-workspace-pattern-anchors.js +95 -0
- package/dist/runtime/cli-add-workspace-pattern-options.d.ts +20 -0
- package/dist/runtime/cli-add-workspace-pattern-options.js +113 -0
- package/dist/runtime/cli-add-workspace-pattern-source-emitters.d.ts +20 -0
- package/dist/runtime/cli-add-workspace-pattern-source-emitters.js +57 -0
- package/dist/runtime/cli-add-workspace-pattern.d.ts +42 -0
- package/dist/runtime/cli-add-workspace-pattern.js +99 -0
- package/dist/runtime/cli-add-workspace-post-meta.js +1 -1
- package/dist/runtime/cli-add-workspace-registration-hooks.d.ts +50 -0
- package/dist/runtime/cli-add-workspace-registration-hooks.js +162 -0
- package/dist/runtime/cli-add-workspace-rest-anchors.d.ts +9 -4
- package/dist/runtime/cli-add-workspace-rest-anchors.js +9 -428
- package/dist/runtime/cli-add-workspace-rest-bootstrap-anchors.d.ts +17 -0
- package/dist/runtime/cli-add-workspace-rest-bootstrap-anchors.js +108 -0
- package/dist/runtime/cli-add-workspace-rest-contract-sync-anchors.d.ts +9 -0
- package/dist/runtime/cli-add-workspace-rest-contract-sync-anchors.js +142 -0
- package/dist/runtime/cli-add-workspace-rest-generated-source-emitters.d.ts +51 -0
- package/dist/runtime/cli-add-workspace-rest-generated-source-emitters.js +415 -0
- package/dist/runtime/cli-add-workspace-rest-generated.d.ts +9 -0
- package/dist/runtime/cli-add-workspace-rest-generated.js +160 -0
- package/dist/runtime/cli-add-workspace-rest-manual-source-emitters.d.ts +80 -0
- package/dist/runtime/cli-add-workspace-rest-manual-source-emitters.js +238 -0
- package/dist/runtime/cli-add-workspace-rest-manual.d.ts +8 -0
- package/dist/runtime/cli-add-workspace-rest-manual.js +266 -0
- package/dist/runtime/cli-add-workspace-rest-php-templates.d.ts +18 -0
- package/dist/runtime/cli-add-workspace-rest-php-templates.js +359 -0
- package/dist/runtime/cli-add-workspace-rest-resource-php-routing-template.d.ts +33 -0
- package/dist/runtime/cli-add-workspace-rest-resource-php-routing-template.js +145 -0
- package/dist/runtime/cli-add-workspace-rest-resource-sync-anchors.d.ts +9 -0
- package/dist/runtime/cli-add-workspace-rest-resource-sync-anchors.js +162 -0
- package/dist/runtime/cli-add-workspace-rest-schema-helper-php-template.d.ts +7 -0
- package/dist/runtime/cli-add-workspace-rest-schema-helper-php-template.js +193 -0
- package/dist/runtime/cli-add-workspace-rest-source-emitters.d.ts +5 -91
- package/dist/runtime/cli-add-workspace-rest-source-emitters.js +5 -642
- package/dist/runtime/cli-add-workspace-rest-source-utils.d.ts +17 -0
- package/dist/runtime/cli-add-workspace-rest-source-utils.js +50 -0
- package/dist/runtime/cli-add-workspace-rest-sync-script-shared.d.ts +56 -0
- package/dist/runtime/cli-add-workspace-rest-sync-script-shared.js +122 -0
- package/dist/runtime/cli-add-workspace-rest-types.d.ts +108 -0
- package/dist/runtime/cli-add-workspace-rest-types.js +1 -0
- package/dist/runtime/cli-add-workspace-rest.d.ts +3 -20
- package/dist/runtime/cli-add-workspace-rest.js +33 -788
- package/dist/runtime/cli-add-workspace-variation.d.ts +22 -0
- package/dist/runtime/cli-add-workspace-variation.js +162 -0
- package/dist/runtime/cli-add-workspace.d.ts +42 -107
- package/dist/runtime/cli-add-workspace.js +42 -674
- package/dist/runtime/cli-add.d.ts +3 -3
- package/dist/runtime/cli-add.js +2 -2
- package/dist/runtime/cli-core.d.ts +3 -2
- package/dist/runtime/cli-core.js +2 -2
- package/dist/runtime/cli-diagnostics.d.ts +3 -1
- package/dist/runtime/cli-diagnostics.js +17 -5
- package/dist/runtime/cli-doctor-workspace-bindings.js +63 -1
- package/dist/runtime/cli-doctor-workspace-block-addons.d.ts +12 -0
- package/dist/runtime/cli-doctor-workspace-block-addons.js +162 -0
- package/dist/runtime/cli-doctor-workspace-block-iframe.d.ts +9 -0
- package/dist/runtime/cli-doctor-workspace-block-iframe.js +228 -0
- package/dist/runtime/cli-doctor-workspace-block-metadata.d.ts +11 -0
- package/dist/runtime/cli-doctor-workspace-block-metadata.js +111 -0
- package/dist/runtime/cli-doctor-workspace-blocks.js +6 -424
- package/dist/runtime/cli-doctor-workspace-features-abilities.d.ts +11 -0
- package/dist/runtime/cli-doctor-workspace-features-abilities.js +112 -0
- package/dist/runtime/cli-doctor-workspace-features-admin-views.d.ts +11 -0
- package/dist/runtime/cli-doctor-workspace-features-admin-views.js +128 -0
- package/dist/runtime/cli-doctor-workspace-features-ai.d.ts +11 -0
- package/dist/runtime/cli-doctor-workspace-features-ai.js +57 -0
- package/dist/runtime/cli-doctor-workspace-features-editor-plugins.d.ts +11 -0
- package/dist/runtime/cli-doctor-workspace-features-editor-plugins.js +80 -0
- package/dist/runtime/cli-doctor-workspace-features-post-meta.d.ts +11 -0
- package/dist/runtime/cli-doctor-workspace-features-post-meta.js +77 -0
- package/dist/runtime/cli-doctor-workspace-features-rest.d.ts +11 -0
- package/dist/runtime/cli-doctor-workspace-features-rest.js +120 -0
- package/dist/runtime/cli-doctor-workspace-features.js +14 -487
- package/dist/runtime/cli-doctor.d.ts +54 -3
- package/dist/runtime/cli-doctor.js +92 -10
- package/dist/runtime/cli-help.js +12 -7
- package/dist/runtime/cli-init-package-json.js +4 -2
- package/dist/runtime/cli-prompt.d.ts +16 -2
- package/dist/runtime/cli-prompt.js +29 -12
- package/dist/runtime/cli-scaffold.d.ts +2 -1
- package/dist/runtime/cli-scaffold.js +19 -10
- package/dist/runtime/external-template-guards.js +4 -6
- package/dist/runtime/index.d.ts +6 -3
- package/dist/runtime/index.js +4 -2
- package/dist/runtime/json-utils.d.ts +62 -4
- package/dist/runtime/json-utils.js +78 -4
- package/dist/runtime/local-dev-presets.js +6 -2
- package/dist/runtime/migration-ui-capability.js +4 -1
- package/dist/runtime/migration-utils.js +4 -1
- package/dist/runtime/package-managers.js +6 -1
- package/dist/runtime/package-versions.d.ts +1 -0
- package/dist/runtime/package-versions.js +16 -3
- package/dist/runtime/pattern-catalog.d.ts +122 -0
- package/dist/runtime/pattern-catalog.js +471 -0
- package/dist/runtime/post-meta-binding-fields.d.ts +46 -0
- package/dist/runtime/post-meta-binding-fields.js +135 -0
- package/dist/runtime/scaffold-bootstrap.js +7 -2
- package/dist/runtime/scaffold-package-manager-files.js +5 -1
- package/dist/runtime/scaffold-repository-reference.js +4 -2
- package/dist/runtime/scaffold-template-variables.js +2 -1
- package/dist/runtime/scaffold.d.ts +18 -1
- package/dist/runtime/scaffold.js +55 -2
- package/dist/runtime/temp-roots.js +4 -1
- package/dist/runtime/template-layers.js +4 -1
- package/dist/runtime/template-registry.js +9 -3
- package/dist/runtime/template-source-contracts.d.ts +2 -0
- package/dist/runtime/template-source-normalization.js +2 -1
- package/dist/runtime/template-source-remote.js +18 -5
- package/dist/runtime/template-source-seeds.js +10 -3
- package/dist/runtime/typia-llm-json-schema.d.ts +24 -0
- package/dist/runtime/typia-llm-json-schema.js +33 -0
- package/dist/runtime/typia-llm-openapi-constraints.d.ts +20 -0
- package/dist/runtime/typia-llm-openapi-constraints.js +254 -0
- package/dist/runtime/typia-llm-projection.d.ts +25 -0
- package/dist/runtime/typia-llm-projection.js +58 -0
- package/dist/runtime/typia-llm-render.d.ts +21 -0
- package/dist/runtime/typia-llm-render.js +252 -0
- package/dist/runtime/typia-llm-sync.d.ts +10 -0
- package/dist/runtime/typia-llm-sync.js +63 -0
- package/dist/runtime/typia-llm-types.d.ts +197 -0
- package/dist/runtime/typia-llm-types.js +1 -0
- package/dist/runtime/typia-llm.d.ts +9 -255
- package/dist/runtime/typia-llm.js +5 -634
- package/dist/runtime/workspace-inventory-mutations.js +15 -1
- package/dist/runtime/workspace-inventory-parser-entries.d.ts +17 -0
- package/dist/runtime/workspace-inventory-parser-entries.js +157 -0
- package/dist/runtime/workspace-inventory-parser-validation.d.ts +104 -0
- package/dist/runtime/workspace-inventory-parser-validation.js +34 -0
- package/dist/runtime/workspace-inventory-parser.d.ts +3 -45
- package/dist/runtime/workspace-inventory-parser.js +3 -581
- package/dist/runtime/workspace-inventory-section-descriptors.d.ts +19 -0
- package/dist/runtime/workspace-inventory-section-descriptors.js +443 -0
- package/dist/runtime/workspace-inventory-templates.d.ts +3 -3
- package/dist/runtime/workspace-inventory-templates.js +10 -1
- package/dist/runtime/workspace-inventory-types.d.ts +10 -1
- package/dist/runtime/workspace-project.js +4 -6
- package/package.json +8 -3
- package/templates/_shared/compound/core/scripts/block-config.ts.mustache +22 -0
- package/templates/_shared/compound/core/scripts/sync-types-to-block-json.ts.mustache +103 -2
- package/templates/_shared/compound/core/src/inner-blocks-templates.ts.mustache +13 -0
- package/templates/_shared/compound/persistence/scripts/block-config.ts.mustache +22 -1
|
@@ -1,703 +1,71 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const VARIATIONS_CALL_LINE = "registerWorkspaceVariations();";
|
|
13
|
-
const VARIATIONS_CALL_PATTERN = /registerWorkspaceVariations\s*\(\s*\)\s*;?/u;
|
|
14
|
-
const BLOCK_STYLES_IMPORT_LINE = "import { registerWorkspaceBlockStyles } from './styles';";
|
|
15
|
-
const BLOCK_STYLES_IMPORT_PATTERN = /^\s*import\s*\{\s*registerWorkspaceBlockStyles\s*\}\s*from\s*["']\.\/styles["']\s*;?\s*$/mu;
|
|
16
|
-
const BLOCK_STYLES_CALL_LINE = "registerWorkspaceBlockStyles();";
|
|
17
|
-
const BLOCK_STYLES_CALL_PATTERN = /registerWorkspaceBlockStyles\s*\(\s*\)\s*;?/u;
|
|
18
|
-
const BLOCK_TRANSFORMS_IMPORT_LINE = "import { applyWorkspaceBlockTransforms } from './transforms';";
|
|
19
|
-
const BLOCK_TRANSFORMS_IMPORT_PATTERN = /^\s*import\s*\{\s*applyWorkspaceBlockTransforms\s*\}\s*from\s*["']\.\/transforms["']\s*;?\s*$/mu;
|
|
20
|
-
const BLOCK_TRANSFORMS_CALL_LINE = "applyWorkspaceBlockTransforms(registration.settings);";
|
|
21
|
-
const BLOCK_TRANSFORMS_CALL_PATTERN = /applyWorkspaceBlockTransforms\s*\(\s*registration\s*\.\s*settings\s*\)\s*;?/u;
|
|
22
|
-
const SCAFFOLD_REGISTRATION_SETTINGS_CALL_PATTERN = /registerScaffoldBlockType\s*\(\s*registration\s*\.\s*name\s*,\s*registration\s*\.\s*settings\s*\)\s*;?/u;
|
|
23
|
-
function isIdentifierBoundary(source, index) {
|
|
24
|
-
if (index < 0 || index >= source.length) {
|
|
25
|
-
return true;
|
|
26
|
-
}
|
|
27
|
-
return !/[A-Za-z0-9_$]/u.test(source[index] ?? "");
|
|
28
|
-
}
|
|
29
|
-
function skipWhitespace(source, index) {
|
|
30
|
-
let cursor = index;
|
|
31
|
-
while (cursor < source.length && /\s/u.test(source[cursor] ?? "")) {
|
|
32
|
-
cursor += 1;
|
|
33
|
-
}
|
|
34
|
-
return cursor;
|
|
35
|
-
}
|
|
36
|
-
function findMatchingDelimiterEnd(source, openIndex, openDelimiter, closeDelimiter) {
|
|
37
|
-
let depth = 0;
|
|
38
|
-
for (let index = openIndex; index < source.length; index += 1) {
|
|
39
|
-
const char = source[index];
|
|
40
|
-
if (char === openDelimiter) {
|
|
41
|
-
depth += 1;
|
|
42
|
-
continue;
|
|
43
|
-
}
|
|
44
|
-
if (char === closeDelimiter) {
|
|
45
|
-
depth -= 1;
|
|
46
|
-
if (depth === 0) {
|
|
47
|
-
return index + 1;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return undefined;
|
|
52
|
-
}
|
|
53
|
-
function findExecutableCallRange(source, callName) {
|
|
54
|
-
const maskedSource = maskTypeScriptCommentsAndLiterals(source);
|
|
55
|
-
let searchIndex = 0;
|
|
56
|
-
while (searchIndex < maskedSource.length) {
|
|
57
|
-
const callNameIndex = maskedSource.indexOf(callName, searchIndex);
|
|
58
|
-
if (callNameIndex === -1) {
|
|
59
|
-
return undefined;
|
|
60
|
-
}
|
|
61
|
-
const callNameEnd = callNameIndex + callName.length;
|
|
62
|
-
if (!isIdentifierBoundary(maskedSource, callNameIndex - 1) ||
|
|
63
|
-
!isIdentifierBoundary(maskedSource, callNameEnd)) {
|
|
64
|
-
searchIndex = callNameEnd;
|
|
65
|
-
continue;
|
|
66
|
-
}
|
|
67
|
-
let cursor = skipWhitespace(maskedSource, callNameEnd);
|
|
68
|
-
if (maskedSource[cursor] === "<") {
|
|
69
|
-
const genericEnd = findMatchingDelimiterEnd(maskedSource, cursor, "<", ">");
|
|
70
|
-
if (genericEnd === undefined) {
|
|
71
|
-
searchIndex = callNameEnd;
|
|
72
|
-
continue;
|
|
73
|
-
}
|
|
74
|
-
cursor = skipWhitespace(maskedSource, genericEnd);
|
|
75
|
-
}
|
|
76
|
-
if (maskedSource[cursor] !== "(") {
|
|
77
|
-
searchIndex = callNameEnd;
|
|
78
|
-
continue;
|
|
79
|
-
}
|
|
80
|
-
const callEnd = findMatchingDelimiterEnd(maskedSource, cursor, "(", ")");
|
|
81
|
-
if (callEnd === undefined) {
|
|
82
|
-
searchIndex = callNameEnd;
|
|
83
|
-
continue;
|
|
84
|
-
}
|
|
85
|
-
let end = skipWhitespace(maskedSource, callEnd);
|
|
86
|
-
if (maskedSource[end] === ";") {
|
|
87
|
-
end += 1;
|
|
88
|
-
}
|
|
89
|
-
return {
|
|
90
|
-
end,
|
|
91
|
-
start: callNameIndex,
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
return undefined;
|
|
95
|
-
}
|
|
96
|
-
function findBlockRegistrationCallRange(source) {
|
|
97
|
-
return (findExecutableCallRange(source, "registerScaffoldBlockType") ??
|
|
98
|
-
findExecutableCallRange(source, "registerBlockType"));
|
|
99
|
-
}
|
|
100
|
-
function buildVariationConfigEntry(blockSlug, variationSlug) {
|
|
101
|
-
return [
|
|
102
|
-
"\t{",
|
|
103
|
-
`\t\tblock: ${quoteTsString(blockSlug)},`,
|
|
104
|
-
`\t\tfile: ${quoteTsString(`src/blocks/${blockSlug}/variations/${variationSlug}.ts`)},`,
|
|
105
|
-
`\t\tslug: ${quoteTsString(variationSlug)},`,
|
|
106
|
-
"\t},",
|
|
107
|
-
].join("\n");
|
|
108
|
-
}
|
|
109
|
-
function buildVariationConstName(variationSlug) {
|
|
110
|
-
const identifierSegments = toKebabCase(variationSlug)
|
|
111
|
-
.split("-")
|
|
112
|
-
.filter(Boolean);
|
|
113
|
-
return `workspaceVariation_${identifierSegments.join("_")}`;
|
|
114
|
-
}
|
|
115
|
-
function getVariationConstBindings(variationSlugs) {
|
|
116
|
-
const seenConstNames = new Map();
|
|
117
|
-
return variationSlugs.map((variationSlug) => {
|
|
118
|
-
const constName = buildVariationConstName(variationSlug);
|
|
119
|
-
const previousSlug = seenConstNames.get(constName);
|
|
120
|
-
if (previousSlug && previousSlug !== variationSlug) {
|
|
121
|
-
throw new Error(`Variation slugs "${previousSlug}" and "${variationSlug}" generate the same registry identifier "${constName}". Rename one of the variations.`);
|
|
122
|
-
}
|
|
123
|
-
seenConstNames.set(constName, variationSlug);
|
|
124
|
-
return { constName, variationSlug };
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
function buildVariationSource(variationSlug, textDomain) {
|
|
128
|
-
const variationTitle = toTitleCase(variationSlug);
|
|
129
|
-
const variationConstName = buildVariationConstName(variationSlug);
|
|
130
|
-
return `import type { BlockVariation } from '@wp-typia/block-types/blocks/registration';
|
|
131
|
-
import { __ } from '@wordpress/i18n';
|
|
132
|
-
|
|
133
|
-
export const ${variationConstName} = {
|
|
134
|
-
\tname: ${quoteTsString(variationSlug)},
|
|
135
|
-
\ttitle: __( ${quoteTsString(variationTitle)}, ${quoteTsString(textDomain)} ),
|
|
136
|
-
\tdescription: __(
|
|
137
|
-
\t\t${quoteTsString(`A starter variation for ${variationTitle}.`)},
|
|
138
|
-
\t\t${quoteTsString(textDomain)},
|
|
139
|
-
\t),
|
|
140
|
-
\tattributes: {},
|
|
141
|
-
\tscope: ['inserter'],
|
|
142
|
-
} satisfies BlockVariation;
|
|
143
|
-
`;
|
|
144
|
-
}
|
|
145
|
-
function buildVariationIndexSource(variationSlugs) {
|
|
146
|
-
const variationBindings = getVariationConstBindings(variationSlugs);
|
|
147
|
-
const importLines = variationBindings
|
|
148
|
-
.map(({ constName, variationSlug }) => {
|
|
149
|
-
return `import { ${constName} } from './${variationSlug}';`;
|
|
150
|
-
})
|
|
151
|
-
.join("\n");
|
|
152
|
-
const variationConstNames = variationBindings
|
|
153
|
-
.map(({ constName }) => constName)
|
|
154
|
-
.join(",\n\t\t");
|
|
155
|
-
return `import { registerBlockVariation } from '@wordpress/blocks';
|
|
156
|
-
import metadata from '../block.json';
|
|
157
|
-
${importLines ? `\n${importLines}` : ""}
|
|
158
|
-
|
|
159
|
-
const WORKSPACE_VARIATIONS = [
|
|
160
|
-
\t${variationConstNames}
|
|
161
|
-
\t// wp-typia add variation entries
|
|
162
|
-
];
|
|
163
|
-
|
|
164
|
-
export function registerWorkspaceVariations() {
|
|
165
|
-
\tfor (const variation of WORKSPACE_VARIATIONS) {
|
|
166
|
-
\t\tregisterBlockVariation(metadata.name, variation);
|
|
167
|
-
\t}
|
|
168
|
-
}
|
|
169
|
-
`;
|
|
170
|
-
}
|
|
171
|
-
function buildWorkspaceConstName(prefix, slug) {
|
|
172
|
-
return `workspace${prefix}_${toSnakeCase(slug)}`;
|
|
173
|
-
}
|
|
174
|
-
function buildBlockStyleConfigEntry(blockSlug, styleSlug) {
|
|
175
|
-
return [
|
|
176
|
-
"\t{",
|
|
177
|
-
`\t\tblock: ${quoteTsString(blockSlug)},`,
|
|
178
|
-
`\t\tfile: ${quoteTsString(`src/blocks/${blockSlug}/styles/${styleSlug}.ts`)},`,
|
|
179
|
-
`\t\tslug: ${quoteTsString(styleSlug)},`,
|
|
180
|
-
"\t},",
|
|
181
|
-
].join("\n");
|
|
182
|
-
}
|
|
183
|
-
function buildBlockTransformConfigEntry(options) {
|
|
184
|
-
return [
|
|
185
|
-
"\t{",
|
|
186
|
-
`\t\tblock: ${quoteTsString(options.blockSlug)},`,
|
|
187
|
-
`\t\tfile: ${quoteTsString(`src/blocks/${options.blockSlug}/transforms/${options.transformSlug}.ts`)},`,
|
|
188
|
-
`\t\tfrom: ${quoteTsString(options.fromBlockName)},`,
|
|
189
|
-
`\t\tslug: ${quoteTsString(options.transformSlug)},`,
|
|
190
|
-
`\t\tto: ${quoteTsString(options.toBlockName)},`,
|
|
191
|
-
"\t},",
|
|
192
|
-
].join("\n");
|
|
193
|
-
}
|
|
194
|
-
function getBlockStyleConstBindings(styleSlugs) {
|
|
195
|
-
const seenConstNames = new Map();
|
|
196
|
-
return styleSlugs.map((styleSlug) => {
|
|
197
|
-
const constName = buildWorkspaceConstName("BlockStyle", styleSlug);
|
|
198
|
-
const previousSlug = seenConstNames.get(constName);
|
|
199
|
-
if (previousSlug && previousSlug !== styleSlug) {
|
|
200
|
-
throw new Error(`Style slugs "${previousSlug}" and "${styleSlug}" generate the same registry identifier "${constName}". Rename one of the styles.`);
|
|
201
|
-
}
|
|
202
|
-
seenConstNames.set(constName, styleSlug);
|
|
203
|
-
return { constName, styleSlug };
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
function getBlockTransformConstBindings(transformSlugs) {
|
|
207
|
-
const seenConstNames = new Map();
|
|
208
|
-
return transformSlugs.map((transformSlug) => {
|
|
209
|
-
const constName = buildWorkspaceConstName("BlockTransform", transformSlug);
|
|
210
|
-
const previousSlug = seenConstNames.get(constName);
|
|
211
|
-
if (previousSlug && previousSlug !== transformSlug) {
|
|
212
|
-
throw new Error(`Transform slugs "${previousSlug}" and "${transformSlug}" generate the same registry identifier "${constName}". Rename one of the transforms.`);
|
|
213
|
-
}
|
|
214
|
-
seenConstNames.set(constName, transformSlug);
|
|
215
|
-
return { constName, transformSlug };
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
function buildBlockStyleSource(styleSlug, textDomain) {
|
|
219
|
-
const styleTitle = toTitleCase(styleSlug);
|
|
220
|
-
const styleConstName = buildWorkspaceConstName("BlockStyle", styleSlug);
|
|
221
|
-
return `import { __ } from '@wordpress/i18n';
|
|
222
|
-
|
|
223
|
-
export const ${styleConstName} = {
|
|
224
|
-
\tname: ${quoteTsString(styleSlug)},
|
|
225
|
-
\tlabel: __( ${quoteTsString(styleTitle)}, ${quoteTsString(textDomain)} ),
|
|
226
|
-
} as const;
|
|
227
|
-
`;
|
|
228
|
-
}
|
|
229
|
-
function buildBlockStyleIndexSource(styleSlugs) {
|
|
230
|
-
const styleBindings = getBlockStyleConstBindings(styleSlugs);
|
|
231
|
-
const importLines = styleBindings
|
|
232
|
-
.map(({ constName, styleSlug }) => `import { ${constName} } from './${styleSlug}';`)
|
|
233
|
-
.join("\n");
|
|
234
|
-
const styleConstNames = styleBindings.map(({ constName }) => constName).join(",\n\t");
|
|
235
|
-
return `import { registerBlockStyle } from '@wordpress/blocks';
|
|
236
|
-
import metadata from '../block.json';
|
|
237
|
-
${importLines ? `\n${importLines}` : ""}
|
|
238
|
-
|
|
239
|
-
const WORKSPACE_BLOCK_STYLES = [
|
|
240
|
-
\t${styleConstNames}
|
|
241
|
-
\t// wp-typia add style entries
|
|
242
|
-
] as const;
|
|
243
|
-
|
|
244
|
-
export function registerWorkspaceBlockStyles() {
|
|
245
|
-
\tfor (const style of WORKSPACE_BLOCK_STYLES) {
|
|
246
|
-
\t\tregisterBlockStyle(metadata.name, style);
|
|
247
|
-
\t}
|
|
248
|
-
}
|
|
249
|
-
`;
|
|
250
|
-
}
|
|
251
|
-
function buildBlockTransformSource(options) {
|
|
252
|
-
const transformTitle = toTitleCase(options.transformSlug);
|
|
253
|
-
const transformConstName = buildWorkspaceConstName("BlockTransform", options.transformSlug);
|
|
254
|
-
return `import { createBlock } from '@wordpress/blocks';
|
|
255
|
-
import { __ } from '@wordpress/i18n';
|
|
256
|
-
import metadata from '../block.json';
|
|
257
|
-
|
|
258
|
-
type TransformAttributes = Record<string, unknown>;
|
|
259
|
-
type TransformInnerBlock = ReturnType<typeof createBlock>;
|
|
260
|
-
|
|
261
|
-
function mapTransformAttributes(attributes: TransformAttributes): TransformAttributes {
|
|
262
|
-
\tconst content = attributes.content;
|
|
263
|
-
|
|
264
|
-
\treturn typeof content === 'string' ? { content } : {};
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
export const ${transformConstName} = {
|
|
268
|
-
\ttype: 'block',
|
|
269
|
-
\tblocks: [${quoteTsString(options.fromBlockName)}],
|
|
270
|
-
\ttitle: __( ${quoteTsString(transformTitle)}, ${quoteTsString(options.textDomain)} ),
|
|
271
|
-
\ttransform: (
|
|
272
|
-
\t\tattributes: TransformAttributes,
|
|
273
|
-
\t\tinnerBlocks: TransformInnerBlock[] = [],
|
|
274
|
-
\t) => createBlock(metadata.name, mapTransformAttributes(attributes), innerBlocks),
|
|
275
|
-
} as const;
|
|
276
|
-
`;
|
|
277
|
-
}
|
|
278
|
-
function buildBlockTransformIndexSource(transformSlugs) {
|
|
279
|
-
const transformBindings = getBlockTransformConstBindings(transformSlugs);
|
|
280
|
-
const importLines = transformBindings
|
|
281
|
-
.map(({ constName, transformSlug }) => `import { ${constName} } from './${transformSlug}';`)
|
|
282
|
-
.join("\n");
|
|
283
|
-
const transformConstNames = transformBindings
|
|
284
|
-
.map(({ constName }) => constName)
|
|
285
|
-
.join(",\n\t");
|
|
286
|
-
return `${importLines ? `${importLines}\n\n` : ""}type BlockSettingsWithTransforms = {
|
|
287
|
-
\ttransforms?: {
|
|
288
|
-
\t\tfrom?: unknown[];
|
|
289
|
-
\t\tto?: unknown[];
|
|
290
|
-
\t};
|
|
291
|
-
};
|
|
292
|
-
|
|
293
|
-
const WORKSPACE_BLOCK_TRANSFORMS = [
|
|
294
|
-
\t${transformConstNames}
|
|
295
|
-
\t// wp-typia add transform entries
|
|
296
|
-
] as const;
|
|
297
|
-
|
|
298
|
-
export function applyWorkspaceBlockTransforms(settings: BlockSettingsWithTransforms) {
|
|
299
|
-
\tconst transforms = settings.transforms ?? {};
|
|
300
|
-
|
|
301
|
-
\tsettings.transforms = {
|
|
302
|
-
\t\t...transforms,
|
|
303
|
-
\t\tfrom: [...(transforms.from ?? []), ...WORKSPACE_BLOCK_TRANSFORMS],
|
|
304
|
-
\t};
|
|
305
|
-
}
|
|
306
|
-
`;
|
|
307
|
-
}
|
|
308
|
-
async function ensureVariationRegistrationHook(blockIndexPath) {
|
|
309
|
-
await patchFile(blockIndexPath, (source) => {
|
|
310
|
-
let nextSource = source;
|
|
311
|
-
if (!hasUncommentedPattern(nextSource, VARIATIONS_IMPORT_PATTERN)) {
|
|
312
|
-
nextSource = `${VARIATIONS_IMPORT_LINE}\n${nextSource}`;
|
|
313
|
-
}
|
|
314
|
-
if (!hasExecutablePattern(nextSource, VARIATIONS_CALL_PATTERN)) {
|
|
315
|
-
const callRange = findBlockRegistrationCallRange(nextSource);
|
|
316
|
-
if (callRange) {
|
|
317
|
-
nextSource = [
|
|
318
|
-
nextSource.slice(0, callRange.end),
|
|
319
|
-
`\n${VARIATIONS_CALL_LINE}\n`,
|
|
320
|
-
nextSource.slice(callRange.end),
|
|
321
|
-
].join("");
|
|
322
|
-
}
|
|
323
|
-
else {
|
|
324
|
-
nextSource = `${nextSource.trimEnd()}\n\n${VARIATIONS_CALL_LINE}\n`;
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
if (!hasExecutablePattern(nextSource, VARIATIONS_CALL_PATTERN)) {
|
|
328
|
-
throw new Error(`Unable to inject ${VARIATIONS_CALL_LINE} into ${path.basename(blockIndexPath)}.`);
|
|
329
|
-
}
|
|
330
|
-
return nextSource;
|
|
331
|
-
});
|
|
332
|
-
}
|
|
333
|
-
async function ensureBlockStyleRegistrationHook(blockIndexPath) {
|
|
334
|
-
await patchFile(blockIndexPath, (source) => {
|
|
335
|
-
let nextSource = source;
|
|
336
|
-
if (!hasUncommentedPattern(nextSource, BLOCK_STYLES_IMPORT_PATTERN)) {
|
|
337
|
-
nextSource = `${BLOCK_STYLES_IMPORT_LINE}\n${nextSource}`;
|
|
338
|
-
}
|
|
339
|
-
if (!hasExecutablePattern(nextSource, BLOCK_STYLES_CALL_PATTERN)) {
|
|
340
|
-
const callRange = findBlockRegistrationCallRange(nextSource);
|
|
341
|
-
if (callRange) {
|
|
342
|
-
nextSource = [
|
|
343
|
-
nextSource.slice(0, callRange.end),
|
|
344
|
-
`\n${BLOCK_STYLES_CALL_LINE}\n`,
|
|
345
|
-
nextSource.slice(callRange.end),
|
|
346
|
-
].join("");
|
|
347
|
-
}
|
|
348
|
-
else {
|
|
349
|
-
nextSource = `${nextSource.trimEnd()}\n\n${BLOCK_STYLES_CALL_LINE}\n`;
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
if (!hasExecutablePattern(nextSource, BLOCK_STYLES_CALL_PATTERN)) {
|
|
353
|
-
throw new Error(`Unable to inject ${BLOCK_STYLES_CALL_LINE} into ${path.basename(blockIndexPath)}.`);
|
|
354
|
-
}
|
|
355
|
-
return nextSource;
|
|
356
|
-
});
|
|
357
|
-
}
|
|
358
|
-
async function ensureBlockTransformRegistrationHook(blockIndexPath) {
|
|
359
|
-
await patchFile(blockIndexPath, (source) => {
|
|
360
|
-
let nextSource = source;
|
|
361
|
-
if (!hasUncommentedPattern(nextSource, BLOCK_TRANSFORMS_IMPORT_PATTERN)) {
|
|
362
|
-
nextSource = `${BLOCK_TRANSFORMS_IMPORT_LINE}\n${nextSource}`;
|
|
363
|
-
}
|
|
364
|
-
if (!hasExecutablePattern(nextSource, BLOCK_TRANSFORMS_CALL_PATTERN)) {
|
|
365
|
-
const callRange = findExecutablePatternMatch(nextSource, [
|
|
366
|
-
SCAFFOLD_REGISTRATION_SETTINGS_CALL_PATTERN,
|
|
367
|
-
]);
|
|
368
|
-
if (!callRange) {
|
|
369
|
-
throw new Error(`Unable to inject ${BLOCK_TRANSFORMS_CALL_LINE} into ${path.basename(blockIndexPath)} because it does not expose a scaffold registration settings object.`);
|
|
370
|
-
}
|
|
371
|
-
nextSource = [
|
|
372
|
-
nextSource.slice(0, callRange.start),
|
|
373
|
-
`${BLOCK_TRANSFORMS_CALL_LINE}\n`,
|
|
374
|
-
nextSource.slice(callRange.start),
|
|
375
|
-
].join("");
|
|
376
|
-
}
|
|
377
|
-
return nextSource;
|
|
378
|
-
});
|
|
379
|
-
}
|
|
380
|
-
async function writeVariationRegistry(projectDir, blockSlug, variationSlug) {
|
|
381
|
-
const variationsDir = path.join(projectDir, "src", "blocks", blockSlug, "variations");
|
|
382
|
-
const variationsIndexPath = path.join(variationsDir, "index.ts");
|
|
383
|
-
await fsp.mkdir(variationsDir, { recursive: true });
|
|
384
|
-
const existingVariationSlugs = (await fsp.readdir(variationsDir))
|
|
385
|
-
.filter((entry) => entry.endsWith(".ts") && entry !== "index.ts")
|
|
386
|
-
.map((entry) => entry.replace(/\.ts$/u, ""));
|
|
387
|
-
const nextVariationSlugs = Array.from(new Set([...existingVariationSlugs, variationSlug])).sort();
|
|
388
|
-
await fsp.writeFile(variationsIndexPath, buildVariationIndexSource(nextVariationSlugs), "utf8");
|
|
389
|
-
}
|
|
390
|
-
async function writeBlockStyleRegistry(projectDir, blockSlug, styleSlug) {
|
|
391
|
-
const stylesDir = path.join(projectDir, "src", "blocks", blockSlug, "styles");
|
|
392
|
-
const stylesIndexPath = path.join(stylesDir, "index.ts");
|
|
393
|
-
await fsp.mkdir(stylesDir, { recursive: true });
|
|
394
|
-
const existingStyleSlugs = (await fsp.readdir(stylesDir))
|
|
395
|
-
.filter((entry) => entry.endsWith(".ts") && entry !== "index.ts")
|
|
396
|
-
.map((entry) => entry.replace(/\.ts$/u, ""));
|
|
397
|
-
const nextStyleSlugs = Array.from(new Set([...existingStyleSlugs, styleSlug])).sort();
|
|
398
|
-
await fsp.writeFile(stylesIndexPath, buildBlockStyleIndexSource(nextStyleSlugs), "utf8");
|
|
399
|
-
}
|
|
400
|
-
async function writeBlockTransformRegistry(projectDir, blockSlug, transformSlug) {
|
|
401
|
-
const transformsDir = path.join(projectDir, "src", "blocks", blockSlug, "transforms");
|
|
402
|
-
const transformsIndexPath = path.join(transformsDir, "index.ts");
|
|
403
|
-
await fsp.mkdir(transformsDir, { recursive: true });
|
|
404
|
-
const existingTransformSlugs = (await fsp.readdir(transformsDir))
|
|
405
|
-
.filter((entry) => entry.endsWith(".ts") && entry !== "index.ts")
|
|
406
|
-
.map((entry) => entry.replace(/\.ts$/u, ""));
|
|
407
|
-
const nextTransformSlugs = Array.from(new Set([...existingTransformSlugs, transformSlug])).sort();
|
|
408
|
-
await fsp.writeFile(transformsIndexPath, buildBlockTransformIndexSource(nextTransformSlugs), "utf8");
|
|
409
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Compatibility facade for workspace add commands.
|
|
3
|
+
*
|
|
4
|
+
* Keep the public runtime import path stable while each workflow lives in a
|
|
5
|
+
* focused implementation module.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Re-export the typed workflow ability scaffold workflow from the focused
|
|
9
|
+
* ability runtime helper module.
|
|
10
|
+
*/
|
|
11
|
+
export { runAddAbilityCommand } from "./cli-add-workspace-ability.js";
|
|
410
12
|
/**
|
|
411
13
|
* Re-export the DataViews admin screen scaffold workflow from the focused
|
|
412
14
|
* admin-view runtime helper module.
|
|
413
15
|
*/
|
|
414
|
-
export { runAddAdminViewCommand
|
|
16
|
+
export { runAddAdminViewCommand } from "./cli-add-workspace-admin-view.js";
|
|
17
|
+
/**
|
|
18
|
+
* Re-export the server-only AI feature scaffold workflow from the focused
|
|
19
|
+
* AI-feature runtime helper module.
|
|
20
|
+
*/
|
|
21
|
+
export { runAddAiFeatureCommand } from "./cli-add-workspace-ai.js";
|
|
415
22
|
/**
|
|
416
23
|
* Re-export focused workspace asset scaffold commands from the companion
|
|
417
24
|
* `cli-add-workspace-assets` module.
|
|
418
25
|
*/
|
|
419
|
-
export {
|
|
26
|
+
export { runAddBindingSourceCommand, runAddEditorPluginCommand, runAddPatternCommand, } from "./cli-add-workspace-assets.js";
|
|
420
27
|
/**
|
|
421
|
-
* Re-export the
|
|
422
|
-
*
|
|
28
|
+
* Re-export the block style scaffold workflow from the focused block-style
|
|
29
|
+
* runtime helper module.
|
|
423
30
|
*/
|
|
424
|
-
export {
|
|
31
|
+
export { runAddBlockStyleCommand } from "./cli-add-workspace-block-style.js";
|
|
425
32
|
/**
|
|
426
|
-
* Re-export the
|
|
427
|
-
*
|
|
33
|
+
* Re-export the block transform scaffold workflow from the focused
|
|
34
|
+
* block-transform runtime helper module.
|
|
428
35
|
*/
|
|
429
|
-
export {
|
|
36
|
+
export { runAddBlockTransformCommand, } from "./cli-add-workspace-block-transform.js";
|
|
430
37
|
/**
|
|
431
38
|
* Re-export the standalone contract scaffold workflow from the focused
|
|
432
39
|
* contract runtime helper module.
|
|
433
40
|
*/
|
|
434
41
|
export { runAddContractCommand } from "./cli-add-workspace-contract.js";
|
|
435
42
|
/**
|
|
436
|
-
* Re-export the
|
|
437
|
-
*
|
|
43
|
+
* Re-export the generic core/external block variation scaffold workflow from
|
|
44
|
+
* the focused core-variation runtime helper module.
|
|
438
45
|
*/
|
|
439
|
-
export {
|
|
46
|
+
export { runAddCoreVariationCommand } from "./cli-add-workspace-core-variation.js";
|
|
440
47
|
/**
|
|
441
|
-
* Re-export the
|
|
442
|
-
*
|
|
48
|
+
* Re-export the hooked-block scaffold workflow from the focused hooked-block
|
|
49
|
+
* runtime helper module.
|
|
443
50
|
*/
|
|
444
|
-
export {
|
|
51
|
+
export { runAddHookedBlockCommand } from "./cli-add-workspace-hooked-block.js";
|
|
445
52
|
/**
|
|
446
|
-
* Re-export the
|
|
447
|
-
*
|
|
448
|
-
*/
|
|
449
|
-
export { runAddAiFeatureCommand } from "./cli-add-workspace-ai.js";
|
|
450
|
-
/**
|
|
451
|
-
* Add one variation entry to an existing workspace block.
|
|
452
|
-
*
|
|
453
|
-
* @param options Command options for the variation scaffold workflow.
|
|
454
|
-
* @param options.blockName Target workspace block slug that will own the variation.
|
|
455
|
-
* @param options.cwd Working directory used to resolve the nearest official workspace.
|
|
456
|
-
* Defaults to `process.cwd()`.
|
|
457
|
-
* @param options.variationName Human-entered variation name that will be normalized
|
|
458
|
-
* and validated before files are written.
|
|
459
|
-
* @returns A promise that resolves with the normalized `blockSlug`,
|
|
460
|
-
* `variationSlug`, and owning `projectDir` after the variation files and
|
|
461
|
-
* inventory entry have been written successfully.
|
|
462
|
-
* @throws {Error} When the command is run outside an official workspace, when
|
|
463
|
-
* the target block is unknown, when the variation slug is invalid, or when a
|
|
464
|
-
* conflicting file or inventory entry already exists.
|
|
53
|
+
* Re-export the local integration environment scaffold workflow from the
|
|
54
|
+
* focused integration-env runtime helper module.
|
|
465
55
|
*/
|
|
466
|
-
export
|
|
467
|
-
const workspace = resolveWorkspaceProject(cwd);
|
|
468
|
-
const blockSlug = normalizeBlockSlug(blockName);
|
|
469
|
-
const variationSlug = assertValidGeneratedSlug("Variation name", normalizeBlockSlug(variationName), "wp-typia add variation <name> --block <block-slug>");
|
|
470
|
-
const inventory = await readWorkspaceInventoryAsync(workspace.projectDir);
|
|
471
|
-
resolveWorkspaceBlock(inventory, blockSlug);
|
|
472
|
-
assertVariationDoesNotExist(workspace.projectDir, blockSlug, variationSlug, inventory);
|
|
473
|
-
const blockConfigPath = path.join(workspace.projectDir, "scripts", "block-config.ts");
|
|
474
|
-
const blockIndexPath = path.join(workspace.projectDir, "src", "blocks", blockSlug, "index.tsx");
|
|
475
|
-
const variationsDir = path.join(workspace.projectDir, "src", "blocks", blockSlug, "variations");
|
|
476
|
-
const variationFilePath = path.join(variationsDir, `${variationSlug}.ts`);
|
|
477
|
-
const variationsIndexPath = path.join(variationsDir, "index.ts");
|
|
478
|
-
const shouldRemoveVariationsDirOnRollback = !(await pathExists(variationsDir));
|
|
479
|
-
const mutationSnapshot = {
|
|
480
|
-
fileSources: await snapshotWorkspaceFiles([
|
|
481
|
-
blockConfigPath,
|
|
482
|
-
blockIndexPath,
|
|
483
|
-
variationsIndexPath,
|
|
484
|
-
]),
|
|
485
|
-
snapshotDirs: [],
|
|
486
|
-
targetPaths: [
|
|
487
|
-
variationFilePath,
|
|
488
|
-
...(shouldRemoveVariationsDirOnRollback ? [variationsDir] : []),
|
|
489
|
-
],
|
|
490
|
-
};
|
|
491
|
-
try {
|
|
492
|
-
await fsp.mkdir(variationsDir, { recursive: true });
|
|
493
|
-
await fsp.writeFile(variationFilePath, buildVariationSource(variationSlug, workspace.workspace.textDomain), "utf8");
|
|
494
|
-
await writeVariationRegistry(workspace.projectDir, blockSlug, variationSlug);
|
|
495
|
-
await ensureVariationRegistrationHook(blockIndexPath);
|
|
496
|
-
await appendWorkspaceInventoryEntries(workspace.projectDir, {
|
|
497
|
-
variationEntries: [buildVariationConfigEntry(blockSlug, variationSlug)],
|
|
498
|
-
});
|
|
499
|
-
return {
|
|
500
|
-
blockSlug,
|
|
501
|
-
projectDir: workspace.projectDir,
|
|
502
|
-
variationSlug,
|
|
503
|
-
};
|
|
504
|
-
}
|
|
505
|
-
catch (error) {
|
|
506
|
-
await rollbackWorkspaceMutation(mutationSnapshot);
|
|
507
|
-
throw error;
|
|
508
|
-
}
|
|
509
|
-
}
|
|
56
|
+
export { runAddIntegrationEnvCommand } from "./cli-add-workspace-integration-env.js";
|
|
510
57
|
/**
|
|
511
|
-
*
|
|
512
|
-
*
|
|
513
|
-
* @param options Command options for the Block Styles scaffold workflow.
|
|
514
|
-
* @param options.blockName Target workspace block slug that will own the style.
|
|
515
|
-
* @param options.cwd Working directory used to resolve the nearest official workspace.
|
|
516
|
-
* Defaults to `process.cwd()`.
|
|
517
|
-
* @param options.styleName Human-entered style name that will be normalized and
|
|
518
|
-
* validated before files are written.
|
|
519
|
-
* @returns A promise that resolves with the normalized `blockSlug`, `styleSlug`,
|
|
520
|
-
* and owning `projectDir` after the style module, style registry, entrypoint
|
|
521
|
-
* hook, and inventory entry have been written successfully.
|
|
522
|
-
* @throws {Error} When the command is run outside an official workspace, when
|
|
523
|
-
* the target block is unknown, when the style slug is invalid, or when a
|
|
524
|
-
* conflicting file or inventory entry already exists.
|
|
58
|
+
* Re-export the typed post-meta contract scaffold workflow from the focused
|
|
59
|
+
* post-meta runtime helper module.
|
|
525
60
|
*/
|
|
526
|
-
export
|
|
527
|
-
const workspace = resolveWorkspaceProject(cwd);
|
|
528
|
-
const blockSlug = normalizeBlockSlug(blockName);
|
|
529
|
-
const styleSlug = assertValidGeneratedSlug("Style name", normalizeBlockSlug(styleName), "wp-typia add style <name> --block <block-slug>");
|
|
530
|
-
const inventory = await readWorkspaceInventoryAsync(workspace.projectDir);
|
|
531
|
-
resolveWorkspaceBlock(inventory, blockSlug);
|
|
532
|
-
assertBlockStyleDoesNotExist(workspace.projectDir, blockSlug, styleSlug, inventory);
|
|
533
|
-
const blockConfigPath = path.join(workspace.projectDir, "scripts", "block-config.ts");
|
|
534
|
-
const blockIndexPath = path.join(workspace.projectDir, "src", "blocks", blockSlug, "index.tsx");
|
|
535
|
-
const stylesDir = path.join(workspace.projectDir, "src", "blocks", blockSlug, "styles");
|
|
536
|
-
const styleFilePath = path.join(stylesDir, `${styleSlug}.ts`);
|
|
537
|
-
const stylesIndexPath = path.join(stylesDir, "index.ts");
|
|
538
|
-
const shouldRemoveStylesDirOnRollback = !(await pathExists(stylesDir));
|
|
539
|
-
const mutationSnapshot = {
|
|
540
|
-
fileSources: await snapshotWorkspaceFiles([
|
|
541
|
-
blockConfigPath,
|
|
542
|
-
blockIndexPath,
|
|
543
|
-
stylesIndexPath,
|
|
544
|
-
]),
|
|
545
|
-
snapshotDirs: [],
|
|
546
|
-
targetPaths: [
|
|
547
|
-
styleFilePath,
|
|
548
|
-
...(shouldRemoveStylesDirOnRollback ? [stylesDir] : []),
|
|
549
|
-
],
|
|
550
|
-
};
|
|
551
|
-
try {
|
|
552
|
-
await fsp.mkdir(stylesDir, { recursive: true });
|
|
553
|
-
await fsp.writeFile(styleFilePath, buildBlockStyleSource(styleSlug, workspace.workspace.textDomain), "utf8");
|
|
554
|
-
await writeBlockStyleRegistry(workspace.projectDir, blockSlug, styleSlug);
|
|
555
|
-
await ensureBlockStyleRegistrationHook(blockIndexPath);
|
|
556
|
-
await appendWorkspaceInventoryEntries(workspace.projectDir, {
|
|
557
|
-
blockStyleEntries: [buildBlockStyleConfigEntry(blockSlug, styleSlug)],
|
|
558
|
-
});
|
|
559
|
-
return {
|
|
560
|
-
blockSlug,
|
|
561
|
-
projectDir: workspace.projectDir,
|
|
562
|
-
styleSlug,
|
|
563
|
-
};
|
|
564
|
-
}
|
|
565
|
-
catch (error) {
|
|
566
|
-
await rollbackWorkspaceMutation(mutationSnapshot);
|
|
567
|
-
throw error;
|
|
568
|
-
}
|
|
569
|
-
}
|
|
61
|
+
export { runAddPostMetaCommand } from "./cli-add-workspace-post-meta.js";
|
|
570
62
|
/**
|
|
571
|
-
*
|
|
572
|
-
*
|
|
573
|
-
* @param options Command options for the block transform scaffold workflow.
|
|
574
|
-
* @param options.cwd Working directory used to resolve the nearest official workspace.
|
|
575
|
-
* Defaults to `process.cwd()`.
|
|
576
|
-
* @param options.fromBlockName Source block name for `--from`. This must be the
|
|
577
|
-
* full `namespace/block` form because transforms may originate from WordPress
|
|
578
|
-
* core or third-party blocks outside the workspace.
|
|
579
|
-
* @param options.toBlockName Target block for `--to`. A workspace block slug is
|
|
580
|
-
* resolved against the workspace namespace, while a full `namespace/block` name
|
|
581
|
-
* must still point at an existing workspace block.
|
|
582
|
-
* @param options.transformName Human-entered transform name that will be
|
|
583
|
-
* normalized and validated before files are written.
|
|
584
|
-
* @returns A promise that resolves with the normalized target `blockSlug`,
|
|
585
|
-
* resolved `fromBlockName`, resolved `toBlockName`, `transformSlug`, and owning
|
|
586
|
-
* `projectDir` after the transform module, transform registry, entrypoint hook,
|
|
587
|
-
* and inventory entry have been written successfully.
|
|
588
|
-
* @throws {Error} When the command is run outside an official workspace, when
|
|
589
|
-
* the target block is unknown, when `--from` is not a full block name, when
|
|
590
|
-
* `--to` uses a non-workspace namespace, when the target block entrypoint does
|
|
591
|
-
* not expose `registration.settings`, when the transform slug is invalid, or
|
|
592
|
-
* when a conflicting file or inventory entry already exists.
|
|
63
|
+
* Re-export the plugin-level REST resource scaffold workflow from the focused
|
|
64
|
+
* rest-resource runtime helper module.
|
|
593
65
|
*/
|
|
594
|
-
export
|
|
595
|
-
const workspace = resolveWorkspaceProject(cwd);
|
|
596
|
-
const transformSlug = assertValidGeneratedSlug("Transform name", normalizeBlockSlug(transformName), "wp-typia add transform <name> --from <namespace/block> --to <block-slug|namespace/block-slug>");
|
|
597
|
-
const resolvedFromBlockName = assertFullBlockName(fromBlockName, "--from");
|
|
598
|
-
const target = resolveWorkspaceTargetBlockName(toBlockName, workspace.workspace.namespace, "--to");
|
|
599
|
-
const inventory = await readWorkspaceInventoryAsync(workspace.projectDir);
|
|
600
|
-
resolveWorkspaceBlock(inventory, target.blockSlug);
|
|
601
|
-
assertBlockTransformDoesNotExist(workspace.projectDir, target.blockSlug, transformSlug, inventory);
|
|
602
|
-
const blockConfigPath = path.join(workspace.projectDir, "scripts", "block-config.ts");
|
|
603
|
-
const blockIndexPath = path.join(workspace.projectDir, "src", "blocks", target.blockSlug, "index.tsx");
|
|
604
|
-
const transformsDir = path.join(workspace.projectDir, "src", "blocks", target.blockSlug, "transforms");
|
|
605
|
-
const transformFilePath = path.join(transformsDir, `${transformSlug}.ts`);
|
|
606
|
-
const transformsIndexPath = path.join(transformsDir, "index.ts");
|
|
607
|
-
const shouldRemoveTransformsDirOnRollback = !(await pathExists(transformsDir));
|
|
608
|
-
const mutationSnapshot = {
|
|
609
|
-
fileSources: await snapshotWorkspaceFiles([
|
|
610
|
-
blockConfigPath,
|
|
611
|
-
blockIndexPath,
|
|
612
|
-
transformsIndexPath,
|
|
613
|
-
]),
|
|
614
|
-
snapshotDirs: [],
|
|
615
|
-
targetPaths: [
|
|
616
|
-
transformFilePath,
|
|
617
|
-
...(shouldRemoveTransformsDirOnRollback ? [transformsDir] : []),
|
|
618
|
-
],
|
|
619
|
-
};
|
|
620
|
-
try {
|
|
621
|
-
await fsp.mkdir(transformsDir, { recursive: true });
|
|
622
|
-
await fsp.writeFile(transformFilePath, buildBlockTransformSource({
|
|
623
|
-
fromBlockName: resolvedFromBlockName,
|
|
624
|
-
textDomain: workspace.workspace.textDomain,
|
|
625
|
-
transformSlug,
|
|
626
|
-
}), "utf8");
|
|
627
|
-
await writeBlockTransformRegistry(workspace.projectDir, target.blockSlug, transformSlug);
|
|
628
|
-
await ensureBlockTransformRegistrationHook(blockIndexPath);
|
|
629
|
-
await appendWorkspaceInventoryEntries(workspace.projectDir, {
|
|
630
|
-
blockTransformEntries: [
|
|
631
|
-
buildBlockTransformConfigEntry({
|
|
632
|
-
blockSlug: target.blockSlug,
|
|
633
|
-
fromBlockName: resolvedFromBlockName,
|
|
634
|
-
toBlockName: target.blockName,
|
|
635
|
-
transformSlug,
|
|
636
|
-
}),
|
|
637
|
-
],
|
|
638
|
-
});
|
|
639
|
-
return {
|
|
640
|
-
blockSlug: target.blockSlug,
|
|
641
|
-
fromBlockName: resolvedFromBlockName,
|
|
642
|
-
projectDir: workspace.projectDir,
|
|
643
|
-
toBlockName: target.blockName,
|
|
644
|
-
transformSlug,
|
|
645
|
-
};
|
|
646
|
-
}
|
|
647
|
-
catch (error) {
|
|
648
|
-
await rollbackWorkspaceMutation(mutationSnapshot);
|
|
649
|
-
throw error;
|
|
650
|
-
}
|
|
651
|
-
}
|
|
66
|
+
export { runAddRestResourceCommand } from "./cli-add-workspace-rest.js";
|
|
652
67
|
/**
|
|
653
|
-
*
|
|
654
|
-
*
|
|
655
|
-
* @param options Command options for the hooked-block workflow.
|
|
656
|
-
* @param options.anchorBlockName Full block name that will anchor the insertion.
|
|
657
|
-
* @param options.blockName Existing workspace block slug to patch.
|
|
658
|
-
* @param options.cwd Working directory used to resolve the nearest official workspace.
|
|
659
|
-
* Defaults to `process.cwd()`.
|
|
660
|
-
* @param options.position Hook position to store in `block.json`.
|
|
661
|
-
* @returns A promise that resolves with the normalized target block slug, anchor
|
|
662
|
-
* block name, position, and owning project directory after `block.json` is written.
|
|
663
|
-
* @throws {Error} When the command is run outside an official workspace, when
|
|
664
|
-
* the target block is unknown, when required flags are missing, or when the
|
|
665
|
-
* block already defines a hook for the requested anchor.
|
|
68
|
+
* Re-export the block variation scaffold workflow from the focused variation
|
|
69
|
+
* runtime helper module.
|
|
666
70
|
*/
|
|
667
|
-
export
|
|
668
|
-
const workspace = resolveWorkspaceProject(cwd);
|
|
669
|
-
const blockSlug = normalizeBlockSlug(blockName);
|
|
670
|
-
const inventory = await readWorkspaceInventoryAsync(workspace.projectDir);
|
|
671
|
-
resolveWorkspaceBlock(inventory, blockSlug);
|
|
672
|
-
const resolvedAnchorBlockName = assertValidHookAnchor(anchorBlockName);
|
|
673
|
-
const resolvedPosition = assertValidHookedBlockPosition(position);
|
|
674
|
-
const selfHookAnchor = `${workspace.workspace.namespace}/${blockSlug}`;
|
|
675
|
-
if (resolvedAnchorBlockName === selfHookAnchor) {
|
|
676
|
-
throw new Error("`wp-typia add hooked-block` cannot hook a block relative to its own block name.");
|
|
677
|
-
}
|
|
678
|
-
const { blockJson, blockJsonPath } = await readWorkspaceBlockJson(workspace.projectDir, blockSlug);
|
|
679
|
-
const blockJsonRelativePath = path.relative(workspace.projectDir, blockJsonPath);
|
|
680
|
-
const blockHooks = getMutableBlockHooks(blockJson, blockJsonRelativePath);
|
|
681
|
-
if (Object.prototype.hasOwnProperty.call(blockHooks, resolvedAnchorBlockName)) {
|
|
682
|
-
throw new Error(`${blockJsonRelativePath} already defines a blockHooks entry for "${resolvedAnchorBlockName}".`);
|
|
683
|
-
}
|
|
684
|
-
const mutationSnapshot = {
|
|
685
|
-
fileSources: await snapshotWorkspaceFiles([blockJsonPath]),
|
|
686
|
-
snapshotDirs: [],
|
|
687
|
-
targetPaths: [],
|
|
688
|
-
};
|
|
689
|
-
try {
|
|
690
|
-
blockHooks[resolvedAnchorBlockName] = resolvedPosition;
|
|
691
|
-
await fsp.writeFile(blockJsonPath, JSON.stringify(blockJson, null, "\t"), "utf8");
|
|
692
|
-
return {
|
|
693
|
-
anchorBlockName: resolvedAnchorBlockName,
|
|
694
|
-
blockSlug,
|
|
695
|
-
position: resolvedPosition,
|
|
696
|
-
projectDir: workspace.projectDir,
|
|
697
|
-
};
|
|
698
|
-
}
|
|
699
|
-
catch (error) {
|
|
700
|
-
await rollbackWorkspaceMutation(mutationSnapshot);
|
|
701
|
-
throw error;
|
|
702
|
-
}
|
|
703
|
-
}
|
|
71
|
+
export { runAddVariationCommand } from "./cli-add-workspace-variation.js";
|