@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.
Files changed (228) hide show
  1. package/dist/runtime/ai-feature-artifacts.js +4 -1
  2. package/dist/runtime/block-generator-service-spec.js +2 -1
  3. package/dist/runtime/built-in-block-non-ts-basic-artifacts.d.ts +9 -0
  4. package/dist/runtime/built-in-block-non-ts-basic-artifacts.js +84 -0
  5. package/dist/runtime/built-in-block-non-ts-compound-artifacts.d.ts +9 -0
  6. package/dist/runtime/built-in-block-non-ts-compound-artifacts.js +36 -0
  7. package/dist/runtime/built-in-block-non-ts-compound-templates.d.ts +23 -0
  8. package/dist/runtime/built-in-block-non-ts-compound-templates.js +453 -0
  9. package/dist/runtime/built-in-block-non-ts-family-artifacts.d.ts +8 -26
  10. package/dist/runtime/built-in-block-non-ts-family-artifacts.js +8 -1034
  11. package/dist/runtime/built-in-block-non-ts-interactivity-artifacts.d.ts +9 -0
  12. package/dist/runtime/built-in-block-non-ts-interactivity-artifacts.js +83 -0
  13. package/dist/runtime/built-in-block-non-ts-persistence-artifacts.d.ts +9 -0
  14. package/dist/runtime/built-in-block-non-ts-persistence-artifacts.js +33 -0
  15. package/dist/runtime/built-in-block-non-ts-persistence-templates.d.ts +23 -0
  16. package/dist/runtime/built-in-block-non-ts-persistence-templates.js +395 -0
  17. package/dist/runtime/cli-add-block-json.js +5 -1
  18. package/dist/runtime/cli-add-collision.js +8 -0
  19. package/dist/runtime/cli-add-help.js +14 -10
  20. package/dist/runtime/cli-add-kind-ids.d.ts +1 -1
  21. package/dist/runtime/cli-add-kind-ids.js +1 -0
  22. package/dist/runtime/cli-add-types.d.ts +45 -6
  23. package/dist/runtime/cli-add-types.js +2 -0
  24. package/dist/runtime/cli-add-validation.d.ts +7 -0
  25. package/dist/runtime/cli-add-validation.js +9 -0
  26. package/dist/runtime/cli-add-workspace-ability-anchors.d.ts +24 -0
  27. package/dist/runtime/cli-add-workspace-ability-anchors.js +294 -0
  28. package/dist/runtime/cli-add-workspace-ability-registry.d.ts +10 -0
  29. package/dist/runtime/cli-add-workspace-ability-registry.js +51 -0
  30. package/dist/runtime/cli-add-workspace-ability-scaffold.d.ts +1 -1
  31. package/dist/runtime/cli-add-workspace-ability-scaffold.js +5 -308
  32. package/dist/runtime/cli-add-workspace-admin-view-scaffold.js +6 -2
  33. package/dist/runtime/cli-add-workspace-admin-view-templates-core-data.d.ts +34 -0
  34. package/dist/runtime/cli-add-workspace-admin-view-templates-core-data.js +483 -0
  35. package/dist/runtime/cli-add-workspace-admin-view-templates-default.d.ts +30 -0
  36. package/dist/runtime/cli-add-workspace-admin-view-templates-default.js +310 -0
  37. package/dist/runtime/cli-add-workspace-admin-view-templates-rest.d.ts +25 -0
  38. package/dist/runtime/cli-add-workspace-admin-view-templates-rest.js +124 -0
  39. package/dist/runtime/cli-add-workspace-admin-view-templates-settings.d.ts +34 -0
  40. package/dist/runtime/cli-add-workspace-admin-view-templates-settings.js +370 -0
  41. package/dist/runtime/cli-add-workspace-admin-view-templates-shared.d.ts +49 -0
  42. package/dist/runtime/cli-add-workspace-admin-view-templates-shared.js +259 -0
  43. package/dist/runtime/cli-add-workspace-admin-view-templates.d.ts +18 -27
  44. package/dist/runtime/cli-add-workspace-admin-view-templates.js +30 -1326
  45. package/dist/runtime/cli-add-workspace-ai-anchors.d.ts +4 -4
  46. package/dist/runtime/cli-add-workspace-ai-anchors.js +8 -233
  47. package/dist/runtime/cli-add-workspace-ai-scaffold.js +4 -2
  48. package/dist/runtime/cli-add-workspace-ai-source-emitters.d.ts +1 -4
  49. package/dist/runtime/cli-add-workspace-ai-source-emitters.js +1 -129
  50. package/dist/runtime/cli-add-workspace-ai-sync-rest-anchors.d.ts +5 -0
  51. package/dist/runtime/cli-add-workspace-ai-sync-rest-anchors.js +236 -0
  52. package/dist/runtime/cli-add-workspace-ai-sync-script-source.d.ts +4 -0
  53. package/dist/runtime/cli-add-workspace-ai-sync-script-source.js +145 -0
  54. package/dist/runtime/cli-add-workspace-assets.d.ts +6 -63
  55. package/dist/runtime/cli-add-workspace-assets.js +6 -950
  56. package/dist/runtime/cli-add-workspace-binding-source-anchors.d.ts +23 -0
  57. package/dist/runtime/cli-add-workspace-binding-source-anchors.js +112 -0
  58. package/dist/runtime/cli-add-workspace-binding-source-source-emitters.d.ts +33 -0
  59. package/dist/runtime/cli-add-workspace-binding-source-source-emitters.js +436 -0
  60. package/dist/runtime/cli-add-workspace-binding-source-types.d.ts +20 -0
  61. package/dist/runtime/cli-add-workspace-binding-source-types.js +1 -0
  62. package/dist/runtime/cli-add-workspace-binding-source.d.ts +40 -0
  63. package/dist/runtime/cli-add-workspace-binding-source.js +275 -0
  64. package/dist/runtime/cli-add-workspace-block-style.d.ts +22 -0
  65. package/dist/runtime/cli-add-workspace-block-style.js +148 -0
  66. package/dist/runtime/cli-add-workspace-block-transform.d.ts +32 -0
  67. package/dist/runtime/cli-add-workspace-block-transform.js +197 -0
  68. package/dist/runtime/cli-add-workspace-contract.js +1 -1
  69. package/dist/runtime/cli-add-workspace-core-variation.d.ts +20 -0
  70. package/dist/runtime/cli-add-workspace-core-variation.js +322 -0
  71. package/dist/runtime/cli-add-workspace-editor-plugin-anchors.d.ts +37 -0
  72. package/dist/runtime/cli-add-workspace-editor-plugin-anchors.js +206 -0
  73. package/dist/runtime/cli-add-workspace-editor-plugin-source-emitters.d.ts +47 -0
  74. package/dist/runtime/cli-add-workspace-editor-plugin-source-emitters.js +219 -0
  75. package/dist/runtime/cli-add-workspace-editor-plugin.d.ts +22 -0
  76. package/dist/runtime/cli-add-workspace-editor-plugin.js +78 -0
  77. package/dist/runtime/cli-add-workspace-hooked-block.d.ts +23 -0
  78. package/dist/runtime/cli-add-workspace-hooked-block.js +57 -0
  79. package/dist/runtime/cli-add-workspace-integration-env-files.d.ts +33 -0
  80. package/dist/runtime/cli-add-workspace-integration-env-files.js +65 -0
  81. package/dist/runtime/cli-add-workspace-integration-env-package-json.d.ts +38 -0
  82. package/dist/runtime/cli-add-workspace-integration-env-package-json.js +122 -0
  83. package/dist/runtime/cli-add-workspace-integration-env-source-emitters.d.ts +44 -0
  84. package/dist/runtime/cli-add-workspace-integration-env-source-emitters.js +262 -0
  85. package/dist/runtime/cli-add-workspace-integration-env.d.ts +3 -1
  86. package/dist/runtime/cli-add-workspace-integration-env.js +10 -313
  87. package/dist/runtime/cli-add-workspace-pattern-anchors.d.ts +10 -0
  88. package/dist/runtime/cli-add-workspace-pattern-anchors.js +95 -0
  89. package/dist/runtime/cli-add-workspace-pattern-options.d.ts +20 -0
  90. package/dist/runtime/cli-add-workspace-pattern-options.js +113 -0
  91. package/dist/runtime/cli-add-workspace-pattern-source-emitters.d.ts +20 -0
  92. package/dist/runtime/cli-add-workspace-pattern-source-emitters.js +57 -0
  93. package/dist/runtime/cli-add-workspace-pattern.d.ts +42 -0
  94. package/dist/runtime/cli-add-workspace-pattern.js +99 -0
  95. package/dist/runtime/cli-add-workspace-post-meta.js +1 -1
  96. package/dist/runtime/cli-add-workspace-registration-hooks.d.ts +50 -0
  97. package/dist/runtime/cli-add-workspace-registration-hooks.js +162 -0
  98. package/dist/runtime/cli-add-workspace-rest-anchors.d.ts +9 -4
  99. package/dist/runtime/cli-add-workspace-rest-anchors.js +9 -428
  100. package/dist/runtime/cli-add-workspace-rest-bootstrap-anchors.d.ts +17 -0
  101. package/dist/runtime/cli-add-workspace-rest-bootstrap-anchors.js +108 -0
  102. package/dist/runtime/cli-add-workspace-rest-contract-sync-anchors.d.ts +9 -0
  103. package/dist/runtime/cli-add-workspace-rest-contract-sync-anchors.js +142 -0
  104. package/dist/runtime/cli-add-workspace-rest-generated-source-emitters.d.ts +51 -0
  105. package/dist/runtime/cli-add-workspace-rest-generated-source-emitters.js +415 -0
  106. package/dist/runtime/cli-add-workspace-rest-generated.d.ts +9 -0
  107. package/dist/runtime/cli-add-workspace-rest-generated.js +160 -0
  108. package/dist/runtime/cli-add-workspace-rest-manual-source-emitters.d.ts +80 -0
  109. package/dist/runtime/cli-add-workspace-rest-manual-source-emitters.js +238 -0
  110. package/dist/runtime/cli-add-workspace-rest-manual.d.ts +8 -0
  111. package/dist/runtime/cli-add-workspace-rest-manual.js +266 -0
  112. package/dist/runtime/cli-add-workspace-rest-php-templates.d.ts +18 -0
  113. package/dist/runtime/cli-add-workspace-rest-php-templates.js +359 -0
  114. package/dist/runtime/cli-add-workspace-rest-resource-php-routing-template.d.ts +33 -0
  115. package/dist/runtime/cli-add-workspace-rest-resource-php-routing-template.js +145 -0
  116. package/dist/runtime/cli-add-workspace-rest-resource-sync-anchors.d.ts +9 -0
  117. package/dist/runtime/cli-add-workspace-rest-resource-sync-anchors.js +162 -0
  118. package/dist/runtime/cli-add-workspace-rest-schema-helper-php-template.d.ts +7 -0
  119. package/dist/runtime/cli-add-workspace-rest-schema-helper-php-template.js +193 -0
  120. package/dist/runtime/cli-add-workspace-rest-source-emitters.d.ts +5 -91
  121. package/dist/runtime/cli-add-workspace-rest-source-emitters.js +5 -642
  122. package/dist/runtime/cli-add-workspace-rest-source-utils.d.ts +17 -0
  123. package/dist/runtime/cli-add-workspace-rest-source-utils.js +50 -0
  124. package/dist/runtime/cli-add-workspace-rest-sync-script-shared.d.ts +56 -0
  125. package/dist/runtime/cli-add-workspace-rest-sync-script-shared.js +122 -0
  126. package/dist/runtime/cli-add-workspace-rest-types.d.ts +108 -0
  127. package/dist/runtime/cli-add-workspace-rest-types.js +1 -0
  128. package/dist/runtime/cli-add-workspace-rest.d.ts +3 -20
  129. package/dist/runtime/cli-add-workspace-rest.js +33 -788
  130. package/dist/runtime/cli-add-workspace-variation.d.ts +22 -0
  131. package/dist/runtime/cli-add-workspace-variation.js +162 -0
  132. package/dist/runtime/cli-add-workspace.d.ts +42 -107
  133. package/dist/runtime/cli-add-workspace.js +42 -674
  134. package/dist/runtime/cli-add.d.ts +3 -3
  135. package/dist/runtime/cli-add.js +2 -2
  136. package/dist/runtime/cli-core.d.ts +3 -2
  137. package/dist/runtime/cli-core.js +2 -2
  138. package/dist/runtime/cli-diagnostics.d.ts +3 -1
  139. package/dist/runtime/cli-diagnostics.js +17 -5
  140. package/dist/runtime/cli-doctor-workspace-bindings.js +63 -1
  141. package/dist/runtime/cli-doctor-workspace-block-addons.d.ts +12 -0
  142. package/dist/runtime/cli-doctor-workspace-block-addons.js +162 -0
  143. package/dist/runtime/cli-doctor-workspace-block-iframe.d.ts +9 -0
  144. package/dist/runtime/cli-doctor-workspace-block-iframe.js +228 -0
  145. package/dist/runtime/cli-doctor-workspace-block-metadata.d.ts +11 -0
  146. package/dist/runtime/cli-doctor-workspace-block-metadata.js +111 -0
  147. package/dist/runtime/cli-doctor-workspace-blocks.js +6 -424
  148. package/dist/runtime/cli-doctor-workspace-features-abilities.d.ts +11 -0
  149. package/dist/runtime/cli-doctor-workspace-features-abilities.js +112 -0
  150. package/dist/runtime/cli-doctor-workspace-features-admin-views.d.ts +11 -0
  151. package/dist/runtime/cli-doctor-workspace-features-admin-views.js +128 -0
  152. package/dist/runtime/cli-doctor-workspace-features-ai.d.ts +11 -0
  153. package/dist/runtime/cli-doctor-workspace-features-ai.js +57 -0
  154. package/dist/runtime/cli-doctor-workspace-features-editor-plugins.d.ts +11 -0
  155. package/dist/runtime/cli-doctor-workspace-features-editor-plugins.js +80 -0
  156. package/dist/runtime/cli-doctor-workspace-features-post-meta.d.ts +11 -0
  157. package/dist/runtime/cli-doctor-workspace-features-post-meta.js +77 -0
  158. package/dist/runtime/cli-doctor-workspace-features-rest.d.ts +11 -0
  159. package/dist/runtime/cli-doctor-workspace-features-rest.js +120 -0
  160. package/dist/runtime/cli-doctor-workspace-features.js +14 -487
  161. package/dist/runtime/cli-doctor.d.ts +54 -3
  162. package/dist/runtime/cli-doctor.js +92 -10
  163. package/dist/runtime/cli-help.js +12 -7
  164. package/dist/runtime/cli-init-package-json.js +4 -2
  165. package/dist/runtime/cli-prompt.d.ts +16 -2
  166. package/dist/runtime/cli-prompt.js +29 -12
  167. package/dist/runtime/cli-scaffold.d.ts +2 -1
  168. package/dist/runtime/cli-scaffold.js +19 -10
  169. package/dist/runtime/external-template-guards.js +4 -6
  170. package/dist/runtime/index.d.ts +6 -3
  171. package/dist/runtime/index.js +4 -2
  172. package/dist/runtime/json-utils.d.ts +62 -4
  173. package/dist/runtime/json-utils.js +78 -4
  174. package/dist/runtime/local-dev-presets.js +6 -2
  175. package/dist/runtime/migration-ui-capability.js +4 -1
  176. package/dist/runtime/migration-utils.js +4 -1
  177. package/dist/runtime/package-managers.js +6 -1
  178. package/dist/runtime/package-versions.d.ts +1 -0
  179. package/dist/runtime/package-versions.js +16 -3
  180. package/dist/runtime/pattern-catalog.d.ts +122 -0
  181. package/dist/runtime/pattern-catalog.js +471 -0
  182. package/dist/runtime/post-meta-binding-fields.d.ts +46 -0
  183. package/dist/runtime/post-meta-binding-fields.js +135 -0
  184. package/dist/runtime/scaffold-bootstrap.js +7 -2
  185. package/dist/runtime/scaffold-package-manager-files.js +5 -1
  186. package/dist/runtime/scaffold-repository-reference.js +4 -2
  187. package/dist/runtime/scaffold-template-variables.js +2 -1
  188. package/dist/runtime/scaffold.d.ts +18 -1
  189. package/dist/runtime/scaffold.js +55 -2
  190. package/dist/runtime/temp-roots.js +4 -1
  191. package/dist/runtime/template-layers.js +4 -1
  192. package/dist/runtime/template-registry.js +9 -3
  193. package/dist/runtime/template-source-contracts.d.ts +2 -0
  194. package/dist/runtime/template-source-normalization.js +2 -1
  195. package/dist/runtime/template-source-remote.js +18 -5
  196. package/dist/runtime/template-source-seeds.js +10 -3
  197. package/dist/runtime/typia-llm-json-schema.d.ts +24 -0
  198. package/dist/runtime/typia-llm-json-schema.js +33 -0
  199. package/dist/runtime/typia-llm-openapi-constraints.d.ts +20 -0
  200. package/dist/runtime/typia-llm-openapi-constraints.js +254 -0
  201. package/dist/runtime/typia-llm-projection.d.ts +25 -0
  202. package/dist/runtime/typia-llm-projection.js +58 -0
  203. package/dist/runtime/typia-llm-render.d.ts +21 -0
  204. package/dist/runtime/typia-llm-render.js +252 -0
  205. package/dist/runtime/typia-llm-sync.d.ts +10 -0
  206. package/dist/runtime/typia-llm-sync.js +63 -0
  207. package/dist/runtime/typia-llm-types.d.ts +197 -0
  208. package/dist/runtime/typia-llm-types.js +1 -0
  209. package/dist/runtime/typia-llm.d.ts +9 -255
  210. package/dist/runtime/typia-llm.js +5 -634
  211. package/dist/runtime/workspace-inventory-mutations.js +15 -1
  212. package/dist/runtime/workspace-inventory-parser-entries.d.ts +17 -0
  213. package/dist/runtime/workspace-inventory-parser-entries.js +157 -0
  214. package/dist/runtime/workspace-inventory-parser-validation.d.ts +104 -0
  215. package/dist/runtime/workspace-inventory-parser-validation.js +34 -0
  216. package/dist/runtime/workspace-inventory-parser.d.ts +3 -45
  217. package/dist/runtime/workspace-inventory-parser.js +3 -581
  218. package/dist/runtime/workspace-inventory-section-descriptors.d.ts +19 -0
  219. package/dist/runtime/workspace-inventory-section-descriptors.js +443 -0
  220. package/dist/runtime/workspace-inventory-templates.d.ts +3 -3
  221. package/dist/runtime/workspace-inventory-templates.js +10 -1
  222. package/dist/runtime/workspace-inventory-types.d.ts +10 -1
  223. package/dist/runtime/workspace-project.js +4 -6
  224. package/package.json +8 -3
  225. package/templates/_shared/compound/core/scripts/block-config.ts.mustache +22 -0
  226. package/templates/_shared/compound/core/scripts/sync-types-to-block-json.ts.mustache +103 -2
  227. package/templates/_shared/compound/core/src/inner-blocks-templates.ts.mustache +13 -0
  228. package/templates/_shared/compound/persistence/scripts/block-config.ts.mustache +22 -1
@@ -0,0 +1,22 @@
1
+ import { type RunAddVariationCommandOptions } from "./cli-add-shared.js";
2
+ /**
3
+ * Add one variation entry to an existing workspace block.
4
+ *
5
+ * @param options Command options for the variation scaffold workflow.
6
+ * @param options.blockName Target workspace block slug that will own the variation.
7
+ * @param options.cwd Working directory used to resolve the nearest official workspace.
8
+ * Defaults to `process.cwd()`.
9
+ * @param options.variationName Human-entered variation name that will be normalized
10
+ * and validated before files are written.
11
+ * @returns A promise that resolves with the normalized `blockSlug`,
12
+ * `variationSlug`, and owning `projectDir` after the variation files and
13
+ * inventory entry have been written successfully.
14
+ * @throws {Error} When the command is run outside an official workspace, when
15
+ * the target block is unknown, when the variation slug is invalid, or when a
16
+ * conflicting file or inventory entry already exists.
17
+ */
18
+ export declare function runAddVariationCommand({ blockName, cwd, variationName, }: RunAddVariationCommandOptions): Promise<{
19
+ blockSlug: string;
20
+ projectDir: string;
21
+ variationSlug: string;
22
+ }>;
@@ -0,0 +1,162 @@
1
+ import { promises as fsp } from "node:fs";
2
+ import path from "node:path";
3
+ import { pathExists } from "./fs-async.js";
4
+ import { assertVariationDoesNotExist, assertValidGeneratedSlug, normalizeBlockSlug, quoteTsString, resolveWorkspaceBlock, rollbackWorkspaceMutation, snapshotWorkspaceFiles, } from "./cli-add-shared.js";
5
+ import { ensureWorkspaceEntrypointCall } from "./cli-add-workspace-registration-hooks.js";
6
+ import { appendWorkspaceInventoryEntries, readWorkspaceInventoryAsync, } from "./workspace-inventory.js";
7
+ import { resolveWorkspaceProject } from "./workspace-project.js";
8
+ import { toKebabCase, toTitleCase } from "./string-case.js";
9
+ const VARIATIONS_IMPORT_LINE = "import { registerWorkspaceVariations } from './variations';";
10
+ const VARIATIONS_IMPORT_PATTERN = /^\s*import\s*\{\s*registerWorkspaceVariations\s*\}\s*from\s*["']\.\/variations["']\s*;?\s*$/mu;
11
+ const VARIATIONS_CALL_LINE = "registerWorkspaceVariations();";
12
+ const VARIATIONS_CALL_PATTERN = /registerWorkspaceVariations\s*\(\s*\)\s*;?/u;
13
+ function buildVariationConfigEntry(blockSlug, variationSlug) {
14
+ return [
15
+ "\t{",
16
+ `\t\tblock: ${quoteTsString(blockSlug)},`,
17
+ `\t\tfile: ${quoteTsString(`src/blocks/${blockSlug}/variations/${variationSlug}.ts`)},`,
18
+ `\t\tslug: ${quoteTsString(variationSlug)},`,
19
+ "\t},",
20
+ ].join("\n");
21
+ }
22
+ function buildVariationConstName(variationSlug) {
23
+ const identifierSegments = toKebabCase(variationSlug)
24
+ .split("-")
25
+ .filter(Boolean);
26
+ return `workspaceVariation_${identifierSegments.join("_")}`;
27
+ }
28
+ function getVariationConstBindings(variationSlugs) {
29
+ const seenConstNames = new Map();
30
+ return variationSlugs.map((variationSlug) => {
31
+ const constName = buildVariationConstName(variationSlug);
32
+ const previousSlug = seenConstNames.get(constName);
33
+ if (previousSlug && previousSlug !== variationSlug) {
34
+ throw new Error(`Variation slugs "${previousSlug}" and "${variationSlug}" generate the same registry identifier "${constName}". Rename one of the variations.`);
35
+ }
36
+ seenConstNames.set(constName, variationSlug);
37
+ return { constName, variationSlug };
38
+ });
39
+ }
40
+ function buildVariationSource(variationSlug, textDomain) {
41
+ const variationTitle = toTitleCase(variationSlug);
42
+ const variationConstName = buildVariationConstName(variationSlug);
43
+ return `import type { BlockVariation } from '@wp-typia/block-types/blocks/registration';
44
+ import { __ } from '@wordpress/i18n';
45
+
46
+ export const ${variationConstName} = {
47
+ \tname: ${quoteTsString(variationSlug)},
48
+ \ttitle: __( ${quoteTsString(variationTitle)}, ${quoteTsString(textDomain)} ),
49
+ \tdescription: __(
50
+ \t\t${quoteTsString(`A starter variation for ${variationTitle}.`)},
51
+ \t\t${quoteTsString(textDomain)},
52
+ \t),
53
+ \tattributes: {},
54
+ \tscope: ['inserter'],
55
+ } satisfies BlockVariation;
56
+ `;
57
+ }
58
+ function buildVariationIndexSource(variationSlugs) {
59
+ const variationBindings = getVariationConstBindings(variationSlugs);
60
+ const importLines = variationBindings
61
+ .map(({ constName, variationSlug }) => {
62
+ return `import { ${constName} } from './${variationSlug}';`;
63
+ })
64
+ .join("\n");
65
+ const variationConstNames = variationBindings
66
+ .map(({ constName }) => constName)
67
+ .join(",\n\t\t");
68
+ return `import { registerBlockVariation } from '@wordpress/blocks';
69
+ import metadata from '../block.json';
70
+ ${importLines ? `\n${importLines}` : ""}
71
+
72
+ const WORKSPACE_VARIATIONS = [
73
+ \t${variationConstNames}
74
+ \t// wp-typia add variation entries
75
+ ];
76
+
77
+ export function registerWorkspaceVariations() {
78
+ \tfor (const variation of WORKSPACE_VARIATIONS) {
79
+ \t\tregisterBlockVariation(metadata.name, variation);
80
+ \t}
81
+ }
82
+ `;
83
+ }
84
+ async function ensureVariationRegistrationHook(blockIndexPath) {
85
+ await ensureWorkspaceEntrypointCall({
86
+ blockIndexPath,
87
+ callLine: VARIATIONS_CALL_LINE,
88
+ callPattern: VARIATIONS_CALL_PATTERN,
89
+ importLine: VARIATIONS_IMPORT_LINE,
90
+ importPattern: VARIATIONS_IMPORT_PATTERN,
91
+ });
92
+ }
93
+ async function writeVariationRegistry(projectDir, blockSlug, variationSlug) {
94
+ const variationsDir = path.join(projectDir, "src", "blocks", blockSlug, "variations");
95
+ const variationsIndexPath = path.join(variationsDir, "index.ts");
96
+ await fsp.mkdir(variationsDir, { recursive: true });
97
+ const existingVariationSlugs = (await fsp.readdir(variationsDir))
98
+ .filter((entry) => entry.endsWith(".ts") && entry !== "index.ts")
99
+ .map((entry) => entry.replace(/\.ts$/u, ""));
100
+ const nextVariationSlugs = Array.from(new Set([...existingVariationSlugs, variationSlug])).sort();
101
+ await fsp.writeFile(variationsIndexPath, buildVariationIndexSource(nextVariationSlugs), "utf8");
102
+ }
103
+ /**
104
+ * Add one variation entry to an existing workspace block.
105
+ *
106
+ * @param options Command options for the variation scaffold workflow.
107
+ * @param options.blockName Target workspace block slug that will own the variation.
108
+ * @param options.cwd Working directory used to resolve the nearest official workspace.
109
+ * Defaults to `process.cwd()`.
110
+ * @param options.variationName Human-entered variation name that will be normalized
111
+ * and validated before files are written.
112
+ * @returns A promise that resolves with the normalized `blockSlug`,
113
+ * `variationSlug`, and owning `projectDir` after the variation files and
114
+ * inventory entry have been written successfully.
115
+ * @throws {Error} When the command is run outside an official workspace, when
116
+ * the target block is unknown, when the variation slug is invalid, or when a
117
+ * conflicting file or inventory entry already exists.
118
+ */
119
+ export async function runAddVariationCommand({ blockName, cwd = process.cwd(), variationName, }) {
120
+ const workspace = resolveWorkspaceProject(cwd);
121
+ const blockSlug = normalizeBlockSlug(blockName);
122
+ const variationSlug = assertValidGeneratedSlug("Variation name", normalizeBlockSlug(variationName), "wp-typia add variation <name> --block <block-slug>");
123
+ const inventory = await readWorkspaceInventoryAsync(workspace.projectDir);
124
+ resolveWorkspaceBlock(inventory, blockSlug);
125
+ assertVariationDoesNotExist(workspace.projectDir, blockSlug, variationSlug, inventory);
126
+ const blockConfigPath = path.join(workspace.projectDir, "scripts", "block-config.ts");
127
+ const blockIndexPath = path.join(workspace.projectDir, "src", "blocks", blockSlug, "index.tsx");
128
+ const variationsDir = path.join(workspace.projectDir, "src", "blocks", blockSlug, "variations");
129
+ const variationFilePath = path.join(variationsDir, `${variationSlug}.ts`);
130
+ const variationsIndexPath = path.join(variationsDir, "index.ts");
131
+ const shouldRemoveVariationsDirOnRollback = !(await pathExists(variationsDir));
132
+ const mutationSnapshot = {
133
+ fileSources: await snapshotWorkspaceFiles([
134
+ blockConfigPath,
135
+ blockIndexPath,
136
+ variationsIndexPath,
137
+ ]),
138
+ snapshotDirs: [],
139
+ targetPaths: [
140
+ variationFilePath,
141
+ ...(shouldRemoveVariationsDirOnRollback ? [variationsDir] : []),
142
+ ],
143
+ };
144
+ try {
145
+ await fsp.mkdir(variationsDir, { recursive: true });
146
+ await fsp.writeFile(variationFilePath, buildVariationSource(variationSlug, workspace.workspace.textDomain), "utf8");
147
+ await writeVariationRegistry(workspace.projectDir, blockSlug, variationSlug);
148
+ await ensureVariationRegistrationHook(blockIndexPath);
149
+ await appendWorkspaceInventoryEntries(workspace.projectDir, {
150
+ variationEntries: [buildVariationConfigEntry(blockSlug, variationSlug)],
151
+ });
152
+ return {
153
+ blockSlug,
154
+ projectDir: workspace.projectDir,
155
+ variationSlug,
156
+ };
157
+ }
158
+ catch (error) {
159
+ await rollbackWorkspaceMutation(mutationSnapshot);
160
+ throw error;
161
+ }
162
+ }
@@ -1,136 +1,71 @@
1
- import type { HookedBlockPositionId } from "./hooked-blocks.js";
2
- import { type RunAddBlockStyleCommandOptions, type RunAddBlockTransformCommandOptions, type RunAddHookedBlockCommandOptions, type RunAddVariationCommandOptions } from "./cli-add-shared.js";
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";
3
12
  /**
4
13
  * Re-export the DataViews admin screen scaffold workflow from the focused
5
14
  * admin-view runtime helper module.
6
15
  */
7
- export { runAddAdminViewCommand, } from "./cli-add-workspace-admin-view.js";
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";
8
22
  /**
9
23
  * Re-export focused workspace asset scaffold commands from the companion
10
24
  * `cli-add-workspace-assets` module.
11
25
  */
12
- export { runAddEditorPluginCommand, runAddBindingSourceCommand, runAddPatternCommand, } from "./cli-add-workspace-assets.js";
26
+ export { runAddBindingSourceCommand, runAddEditorPluginCommand, runAddPatternCommand, } from "./cli-add-workspace-assets.js";
13
27
  /**
14
- * Re-export the local integration environment scaffold workflow from the
15
- * focused integration-env runtime helper module.
28
+ * Re-export the block style scaffold workflow from the focused block-style
29
+ * runtime helper module.
16
30
  */
17
- export { runAddIntegrationEnvCommand } from "./cli-add-workspace-integration-env.js";
31
+ export { runAddBlockStyleCommand } from "./cli-add-workspace-block-style.js";
18
32
  /**
19
- * Re-export the plugin-level REST resource scaffold workflow from the focused
20
- * rest-resource runtime helper module.
33
+ * Re-export the block transform scaffold workflow from the focused
34
+ * block-transform runtime helper module.
21
35
  */
22
- export { runAddRestResourceCommand } from "./cli-add-workspace-rest.js";
36
+ export { runAddBlockTransformCommand, } from "./cli-add-workspace-block-transform.js";
23
37
  /**
24
38
  * Re-export the standalone contract scaffold workflow from the focused
25
39
  * contract runtime helper module.
26
40
  */
27
41
  export { runAddContractCommand } from "./cli-add-workspace-contract.js";
28
42
  /**
29
- * Re-export the typed post-meta contract scaffold workflow from the focused
30
- * post-meta runtime helper module.
43
+ * Re-export the generic core/external block variation scaffold workflow from
44
+ * the focused core-variation runtime helper module.
31
45
  */
32
- export { runAddPostMetaCommand } from "./cli-add-workspace-post-meta.js";
46
+ export { runAddCoreVariationCommand } from "./cli-add-workspace-core-variation.js";
33
47
  /**
34
- * Re-export the typed workflow ability scaffold workflow from the focused
35
- * ability runtime helper module.
48
+ * Re-export the hooked-block scaffold workflow from the focused hooked-block
49
+ * runtime helper module.
36
50
  */
37
- export { runAddAbilityCommand } from "./cli-add-workspace-ability.js";
51
+ export { runAddHookedBlockCommand } from "./cli-add-workspace-hooked-block.js";
38
52
  /**
39
- * Re-export the server-only AI feature scaffold workflow from the focused
40
- * AI-feature runtime helper module.
41
- */
42
- export { runAddAiFeatureCommand } from "./cli-add-workspace-ai.js";
43
- /**
44
- * Add one variation entry to an existing workspace block.
45
- *
46
- * @param options Command options for the variation scaffold workflow.
47
- * @param options.blockName Target workspace block slug that will own the variation.
48
- * @param options.cwd Working directory used to resolve the nearest official workspace.
49
- * Defaults to `process.cwd()`.
50
- * @param options.variationName Human-entered variation name that will be normalized
51
- * and validated before files are written.
52
- * @returns A promise that resolves with the normalized `blockSlug`,
53
- * `variationSlug`, and owning `projectDir` after the variation files and
54
- * inventory entry have been written successfully.
55
- * @throws {Error} When the command is run outside an official workspace, when
56
- * the target block is unknown, when the variation slug is invalid, or when a
57
- * 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.
58
55
  */
59
- export declare function runAddVariationCommand({ blockName, cwd, variationName, }: RunAddVariationCommandOptions): Promise<{
60
- blockSlug: string;
61
- projectDir: string;
62
- variationSlug: string;
63
- }>;
56
+ export { runAddIntegrationEnvCommand } from "./cli-add-workspace-integration-env.js";
64
57
  /**
65
- * Add one Block Styles registration to an existing workspace block.
66
- *
67
- * @param options Command options for the Block Styles scaffold workflow.
68
- * @param options.blockName Target workspace block slug that will own the style.
69
- * @param options.cwd Working directory used to resolve the nearest official workspace.
70
- * Defaults to `process.cwd()`.
71
- * @param options.styleName Human-entered style name that will be normalized and
72
- * validated before files are written.
73
- * @returns A promise that resolves with the normalized `blockSlug`, `styleSlug`,
74
- * and owning `projectDir` after the style module, style registry, entrypoint
75
- * hook, and inventory entry have been written successfully.
76
- * @throws {Error} When the command is run outside an official workspace, when
77
- * the target block is unknown, when the style slug is invalid, or when a
78
- * 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.
79
60
  */
80
- export declare function runAddBlockStyleCommand({ blockName, cwd, styleName, }: RunAddBlockStyleCommandOptions): Promise<{
81
- blockSlug: string;
82
- projectDir: string;
83
- styleSlug: string;
84
- }>;
61
+ export { runAddPostMetaCommand } from "./cli-add-workspace-post-meta.js";
85
62
  /**
86
- * Add one block-to-block transform registration to an existing workspace block.
87
- *
88
- * @param options Command options for the block transform scaffold workflow.
89
- * @param options.cwd Working directory used to resolve the nearest official workspace.
90
- * Defaults to `process.cwd()`.
91
- * @param options.fromBlockName Source block name for `--from`. This must be the
92
- * full `namespace/block` form because transforms may originate from WordPress
93
- * core or third-party blocks outside the workspace.
94
- * @param options.toBlockName Target block for `--to`. A workspace block slug is
95
- * resolved against the workspace namespace, while a full `namespace/block` name
96
- * must still point at an existing workspace block.
97
- * @param options.transformName Human-entered transform name that will be
98
- * normalized and validated before files are written.
99
- * @returns A promise that resolves with the normalized target `blockSlug`,
100
- * resolved `fromBlockName`, resolved `toBlockName`, `transformSlug`, and owning
101
- * `projectDir` after the transform module, transform registry, entrypoint hook,
102
- * and inventory entry have been written successfully.
103
- * @throws {Error} When the command is run outside an official workspace, when
104
- * the target block is unknown, when `--from` is not a full block name, when
105
- * `--to` uses a non-workspace namespace, when the target block entrypoint does
106
- * not expose `registration.settings`, when the transform slug is invalid, or
107
- * 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.
108
65
  */
109
- export declare function runAddBlockTransformCommand({ cwd, fromBlockName, toBlockName, transformName, }: RunAddBlockTransformCommandOptions): Promise<{
110
- blockSlug: string;
111
- fromBlockName: string;
112
- projectDir: string;
113
- toBlockName: string;
114
- transformSlug: string;
115
- }>;
66
+ export { runAddRestResourceCommand } from "./cli-add-workspace-rest.js";
116
67
  /**
117
- * Add one `blockHooks` entry to an existing official workspace block.
118
- *
119
- * @param options Command options for the hooked-block workflow.
120
- * @param options.anchorBlockName Full block name that will anchor the insertion.
121
- * @param options.blockName Existing workspace block slug to patch.
122
- * @param options.cwd Working directory used to resolve the nearest official workspace.
123
- * Defaults to `process.cwd()`.
124
- * @param options.position Hook position to store in `block.json`.
125
- * @returns A promise that resolves with the normalized target block slug, anchor
126
- * block name, position, and owning project directory after `block.json` is written.
127
- * @throws {Error} When the command is run outside an official workspace, when
128
- * the target block is unknown, when required flags are missing, or when the
129
- * 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.
130
70
  */
131
- export declare function runAddHookedBlockCommand({ anchorBlockName, blockName, cwd, position, }: RunAddHookedBlockCommandOptions): Promise<{
132
- anchorBlockName: string;
133
- blockSlug: string;
134
- position: HookedBlockPositionId;
135
- projectDir: string;
136
- }>;
71
+ export { runAddVariationCommand } from "./cli-add-workspace-variation.js";