@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,42 @@
1
+ import { type RunAddPatternCommandOptions } from "./cli-add-shared.js";
2
+ import type { PatternCatalogScope } from "./pattern-catalog.js";
3
+ /**
4
+ * Add one PHP block pattern shell to an official workspace project.
5
+ *
6
+ * @param options Command options for the pattern scaffold workflow.
7
+ * @param options.catalogTitle Optional human-readable title. Defaults to the
8
+ * title-cased form of the normalized pattern slug.
9
+ * @param options.contentFile Optional safe relative project path directly
10
+ * under `src/patterns/` or one nested directory under `src/patterns/` for the
11
+ * generated PHP file. Defaults to `src/patterns/full/<slug>.php` or
12
+ * `src/patterns/sections/<slug>.php`.
13
+ * @param options.cwd Working directory used to resolve the nearest official workspace.
14
+ * Defaults to `process.cwd()`.
15
+ * @param options.patternName Human-entered pattern name that will be normalized
16
+ * and validated before files are written.
17
+ * @param options.patternScope Catalog scope (`full` or `section`). Defaults to `full`.
18
+ * @param options.sectionRole Section role slug. Required only when
19
+ * `patternScope` is `section`.
20
+ * @param options.tags Optional pattern tags as a comma-separated string or
21
+ * array. Tags are normalized, deduplicated, and sorted.
22
+ * @param options.thumbnailUrl Optional thumbnail URL or relative asset path
23
+ * recorded in the inventory entry.
24
+ * @returns A promise that resolves with the normalized `patternSlug`, owning
25
+ * `projectDir`, resolved `contentFile`, `patternScope`, `tags`, `title`, and
26
+ * optional `sectionRole` and `thumbnailUrl` after the pattern file and
27
+ * inventory entry have been written successfully.
28
+ * @throws {Error} When the command is run outside an official workspace, when
29
+ * the pattern slug, scope, section-role coupling, tag values, or content file
30
+ * path are invalid, or when a conflicting target file or inventory entry
31
+ * already exists.
32
+ */
33
+ export declare function runAddPatternCommand({ catalogTitle, contentFile, cwd, patternName, patternScope, sectionRole, tags, thumbnailUrl, }: RunAddPatternCommandOptions): Promise<{
34
+ contentFile: string;
35
+ patternSlug: string;
36
+ patternScope: PatternCatalogScope;
37
+ projectDir: string;
38
+ sectionRole?: string;
39
+ tags: string[];
40
+ title: string;
41
+ thumbnailUrl?: string;
42
+ }>;
@@ -0,0 +1,99 @@
1
+ import { promises as fsp } from "node:fs";
2
+ import path from "node:path";
3
+ import { assertPatternDoesNotExist, assertValidGeneratedSlug, getWorkspaceBootstrapPath, normalizeBlockSlug, rollbackWorkspaceMutation, snapshotWorkspaceFiles, } from "./cli-add-shared.js";
4
+ import { ensurePatternBootstrapAnchors } from "./cli-add-workspace-pattern-anchors.js";
5
+ import { resolvePatternCatalogOptions } from "./cli-add-workspace-pattern-options.js";
6
+ import { buildPatternConfigEntry, buildPatternSource, } from "./cli-add-workspace-pattern-source-emitters.js";
7
+ import { appendWorkspaceInventoryEntries, readWorkspaceInventoryAsync, } from "./workspace-inventory.js";
8
+ import { resolveWorkspaceProject } from "./workspace-project.js";
9
+ /**
10
+ * Add one PHP block pattern shell to an official workspace project.
11
+ *
12
+ * @param options Command options for the pattern scaffold workflow.
13
+ * @param options.catalogTitle Optional human-readable title. Defaults to the
14
+ * title-cased form of the normalized pattern slug.
15
+ * @param options.contentFile Optional safe relative project path directly
16
+ * under `src/patterns/` or one nested directory under `src/patterns/` for the
17
+ * generated PHP file. Defaults to `src/patterns/full/<slug>.php` or
18
+ * `src/patterns/sections/<slug>.php`.
19
+ * @param options.cwd Working directory used to resolve the nearest official workspace.
20
+ * Defaults to `process.cwd()`.
21
+ * @param options.patternName Human-entered pattern name that will be normalized
22
+ * and validated before files are written.
23
+ * @param options.patternScope Catalog scope (`full` or `section`). Defaults to `full`.
24
+ * @param options.sectionRole Section role slug. Required only when
25
+ * `patternScope` is `section`.
26
+ * @param options.tags Optional pattern tags as a comma-separated string or
27
+ * array. Tags are normalized, deduplicated, and sorted.
28
+ * @param options.thumbnailUrl Optional thumbnail URL or relative asset path
29
+ * recorded in the inventory entry.
30
+ * @returns A promise that resolves with the normalized `patternSlug`, owning
31
+ * `projectDir`, resolved `contentFile`, `patternScope`, `tags`, `title`, and
32
+ * optional `sectionRole` and `thumbnailUrl` after the pattern file and
33
+ * inventory entry have been written successfully.
34
+ * @throws {Error} When the command is run outside an official workspace, when
35
+ * the pattern slug, scope, section-role coupling, tag values, or content file
36
+ * path are invalid, or when a conflicting target file or inventory entry
37
+ * already exists.
38
+ */
39
+ export async function runAddPatternCommand({ catalogTitle, contentFile, cwd = process.cwd(), patternName, patternScope, sectionRole, tags, thumbnailUrl, }) {
40
+ const workspace = resolveWorkspaceProject(cwd);
41
+ const patternSlug = assertValidGeneratedSlug("Pattern name", normalizeBlockSlug(patternName), "wp-typia add pattern <name>");
42
+ const patternCatalogOptions = resolvePatternCatalogOptions(patternSlug, {
43
+ catalogTitle,
44
+ contentFile,
45
+ cwd,
46
+ patternName,
47
+ patternScope,
48
+ sectionRole,
49
+ tags,
50
+ thumbnailUrl,
51
+ });
52
+ const inventory = await readWorkspaceInventoryAsync(workspace.projectDir);
53
+ assertPatternDoesNotExist(workspace.projectDir, patternSlug, inventory);
54
+ const contentFilePath = path.join(workspace.projectDir, patternCatalogOptions.contentFile);
55
+ if (await fsp.stat(contentFilePath).then(() => true, (error) => {
56
+ if (error.code === "ENOENT") {
57
+ return false;
58
+ }
59
+ throw error;
60
+ })) {
61
+ throw new Error(`A pattern already exists at ${patternCatalogOptions.contentFile}. Choose a different name.`);
62
+ }
63
+ const blockConfigPath = path.join(workspace.projectDir, "scripts", "block-config.ts");
64
+ const bootstrapPath = getWorkspaceBootstrapPath(workspace);
65
+ const patternFilePath = contentFilePath;
66
+ const mutationSnapshot = {
67
+ fileSources: await snapshotWorkspaceFiles([blockConfigPath, bootstrapPath]),
68
+ snapshotDirs: [],
69
+ targetPaths: [patternFilePath],
70
+ };
71
+ try {
72
+ await fsp.mkdir(path.dirname(patternFilePath), { recursive: true });
73
+ await ensurePatternBootstrapAnchors(workspace);
74
+ await fsp.writeFile(patternFilePath, buildPatternSource(patternSlug, workspace.workspace.namespace, patternCatalogOptions.sectionRole, workspace.workspace.textDomain, patternCatalogOptions.title), "utf8");
75
+ await appendWorkspaceInventoryEntries(workspace.projectDir, {
76
+ patternEntries: [
77
+ buildPatternConfigEntry(patternSlug, patternCatalogOptions),
78
+ ],
79
+ });
80
+ return {
81
+ contentFile: patternCatalogOptions.contentFile,
82
+ patternSlug,
83
+ patternScope: patternCatalogOptions.patternScope,
84
+ projectDir: workspace.projectDir,
85
+ ...(patternCatalogOptions.sectionRole
86
+ ? { sectionRole: patternCatalogOptions.sectionRole }
87
+ : {}),
88
+ tags: patternCatalogOptions.tags,
89
+ title: patternCatalogOptions.title,
90
+ ...(patternCatalogOptions.thumbnailUrl
91
+ ? { thumbnailUrl: patternCatalogOptions.thumbnailUrl }
92
+ : {}),
93
+ };
94
+ }
95
+ catch (error) {
96
+ await rollbackWorkspaceMutation(mutationSnapshot);
97
+ throw error;
98
+ }
99
+ }
@@ -2,7 +2,7 @@ import { promises as fsp } from "node:fs";
2
2
  import path from "node:path";
3
3
  import { pathExists } from "./fs-async.js";
4
4
  import { assertPostMetaDoesNotExist, assertValidGeneratedSlug, assertValidPostMetaPostType, assertValidTypeScriptIdentifier, getWorkspaceBootstrapPath, normalizeBlockSlug, resolvePostMetaKey, } from "./cli-add-shared.js";
5
- import { ensureContractSyncScriptAnchors } from "./cli-add-workspace-rest-anchors.js";
5
+ import { ensureContractSyncScriptAnchors, } from "./cli-add-workspace-rest-contract-sync-anchors.js";
6
6
  import { ensurePostMetaBootstrapAnchors, ensurePostMetaSyncScriptAnchors, } from "./cli-add-workspace-post-meta-anchors.js";
7
7
  import { buildPostMetaConfigEntry, buildPostMetaPhpSource, buildPostMetaReadmeSource, buildPostMetaTypesSource, } from "./cli-add-workspace-post-meta-source-emitters.js";
8
8
  import { executeWorkspaceMutationPlan } from "./cli-add-workspace-mutation.js";
@@ -0,0 +1,50 @@
1
+ import { type SourceRange } from "./ts-source-masking.js";
2
+ /**
3
+ * Find the first executable call expression for a named function in source code.
4
+ *
5
+ * @param source TypeScript or JavaScript source text to scan.
6
+ * @param callName Function identifier to locate.
7
+ * @returns The source range for the first matching executable call, or
8
+ * `undefined` when the identifier is absent, commented, string-literal-only, or
9
+ * not followed by a call expression.
10
+ */
11
+ export declare function findExecutableCallRange(source: string, callName: string): SourceRange | undefined;
12
+ /**
13
+ * Ensure a block entrypoint imports and calls a workspace registration helper.
14
+ *
15
+ * @param options Entrypoint patch options.
16
+ * @param options.blockIndexPath Absolute path to the block entrypoint file.
17
+ * @param options.callLine Call expression line to insert when missing.
18
+ * @param options.callPattern Executable pattern used to detect an existing call.
19
+ * @param options.importLine Import line to prepend when missing.
20
+ * @param options.importPattern Uncommented import pattern used to avoid duplicates.
21
+ * @returns A promise that resolves after the entrypoint has been patched.
22
+ * @throws {Error} When the call cannot be injected or verified.
23
+ */
24
+ export declare function ensureWorkspaceEntrypointCall({ blockIndexPath, callLine, callPattern, importLine, importPattern, }: {
25
+ blockIndexPath: string;
26
+ callLine: string;
27
+ callPattern: RegExp;
28
+ importLine: string;
29
+ importPattern: RegExp;
30
+ }): Promise<void>;
31
+ /**
32
+ * Ensure a scaffold block registration settings hook is imported and called.
33
+ *
34
+ * @param options Registration settings patch options.
35
+ * @param options.blockIndexPath Absolute path to the block entrypoint file.
36
+ * @param options.callLine Settings mutation call to insert before registration.
37
+ * @param options.callPattern Executable pattern used to detect an existing call.
38
+ * @param options.importLine Import line to prepend when missing.
39
+ * @param options.importPattern Uncommented import pattern used to avoid duplicates.
40
+ * @returns A promise that resolves after the entrypoint has been patched.
41
+ * @throws {Error} When the entrypoint does not expose the expected
42
+ * `registerScaffoldBlockType(registration.name, registration.settings)` call.
43
+ */
44
+ export declare function ensureWorkspaceRegistrationSettingsCall({ blockIndexPath, callLine, callPattern, importLine, importPattern, }: {
45
+ blockIndexPath: string;
46
+ callLine: string;
47
+ callPattern: RegExp;
48
+ importLine: string;
49
+ importPattern: RegExp;
50
+ }): Promise<void>;
@@ -0,0 +1,162 @@
1
+ import path from "node:path";
2
+ import { patchFile } from "./cli-add-shared.js";
3
+ import { findExecutablePatternMatch, hasExecutablePattern, hasUncommentedPattern, maskTypeScriptCommentsAndLiterals, } from "./ts-source-masking.js";
4
+ const SCAFFOLD_REGISTRATION_SETTINGS_CALL_PATTERN = /registerScaffoldBlockType\s*\(\s*registration\s*\.\s*name\s*,\s*registration\s*\.\s*settings\s*\)\s*;?/u;
5
+ function isIdentifierBoundary(source, index) {
6
+ if (index < 0 || index >= source.length) {
7
+ return true;
8
+ }
9
+ return !/[A-Za-z0-9_$]/u.test(source[index] ?? "");
10
+ }
11
+ function skipWhitespace(source, index) {
12
+ let cursor = index;
13
+ while (cursor < source.length && /\s/u.test(source[cursor] ?? "")) {
14
+ cursor += 1;
15
+ }
16
+ return cursor;
17
+ }
18
+ function findMatchingDelimiterEnd(source, openIndex, openDelimiter, closeDelimiter) {
19
+ let depth = 0;
20
+ for (let index = openIndex; index < source.length; index += 1) {
21
+ const char = source[index];
22
+ if (char === openDelimiter) {
23
+ depth += 1;
24
+ continue;
25
+ }
26
+ if (char === closeDelimiter) {
27
+ depth -= 1;
28
+ if (depth === 0) {
29
+ return index + 1;
30
+ }
31
+ }
32
+ }
33
+ return undefined;
34
+ }
35
+ /**
36
+ * Find the first executable call expression for a named function in source code.
37
+ *
38
+ * @param source TypeScript or JavaScript source text to scan.
39
+ * @param callName Function identifier to locate.
40
+ * @returns The source range for the first matching executable call, or
41
+ * `undefined` when the identifier is absent, commented, string-literal-only, or
42
+ * not followed by a call expression.
43
+ */
44
+ export function findExecutableCallRange(source, callName) {
45
+ const maskedSource = maskTypeScriptCommentsAndLiterals(source);
46
+ let searchIndex = 0;
47
+ while (searchIndex < maskedSource.length) {
48
+ const callNameIndex = maskedSource.indexOf(callName, searchIndex);
49
+ if (callNameIndex === -1) {
50
+ return undefined;
51
+ }
52
+ const callNameEnd = callNameIndex + callName.length;
53
+ if (!isIdentifierBoundary(maskedSource, callNameIndex - 1) ||
54
+ !isIdentifierBoundary(maskedSource, callNameEnd)) {
55
+ searchIndex = callNameEnd;
56
+ continue;
57
+ }
58
+ let cursor = skipWhitespace(maskedSource, callNameEnd);
59
+ if (maskedSource[cursor] === "<") {
60
+ const genericEnd = findMatchingDelimiterEnd(maskedSource, cursor, "<", ">");
61
+ if (genericEnd === undefined) {
62
+ searchIndex = callNameEnd;
63
+ continue;
64
+ }
65
+ cursor = skipWhitespace(maskedSource, genericEnd);
66
+ }
67
+ if (maskedSource[cursor] !== "(") {
68
+ searchIndex = callNameEnd;
69
+ continue;
70
+ }
71
+ const callEnd = findMatchingDelimiterEnd(maskedSource, cursor, "(", ")");
72
+ if (callEnd === undefined) {
73
+ searchIndex = callNameEnd;
74
+ continue;
75
+ }
76
+ let end = skipWhitespace(maskedSource, callEnd);
77
+ if (maskedSource[end] === ";") {
78
+ end += 1;
79
+ }
80
+ return {
81
+ end,
82
+ start: callNameIndex,
83
+ };
84
+ }
85
+ return undefined;
86
+ }
87
+ function findBlockRegistrationCallRange(source) {
88
+ return (findExecutableCallRange(source, "registerScaffoldBlockType") ??
89
+ findExecutableCallRange(source, "registerBlockType"));
90
+ }
91
+ /**
92
+ * Ensure a block entrypoint imports and calls a workspace registration helper.
93
+ *
94
+ * @param options Entrypoint patch options.
95
+ * @param options.blockIndexPath Absolute path to the block entrypoint file.
96
+ * @param options.callLine Call expression line to insert when missing.
97
+ * @param options.callPattern Executable pattern used to detect an existing call.
98
+ * @param options.importLine Import line to prepend when missing.
99
+ * @param options.importPattern Uncommented import pattern used to avoid duplicates.
100
+ * @returns A promise that resolves after the entrypoint has been patched.
101
+ * @throws {Error} When the call cannot be injected or verified.
102
+ */
103
+ export async function ensureWorkspaceEntrypointCall({ blockIndexPath, callLine, callPattern, importLine, importPattern, }) {
104
+ await patchFile(blockIndexPath, (source) => {
105
+ let nextSource = source;
106
+ if (!hasUncommentedPattern(nextSource, importPattern)) {
107
+ nextSource = `${importLine}\n${nextSource}`;
108
+ }
109
+ if (!hasExecutablePattern(nextSource, callPattern)) {
110
+ const callRange = findBlockRegistrationCallRange(nextSource);
111
+ if (callRange) {
112
+ nextSource = [
113
+ nextSource.slice(0, callRange.end),
114
+ `\n${callLine}\n`,
115
+ nextSource.slice(callRange.end),
116
+ ].join("");
117
+ }
118
+ else {
119
+ nextSource = `${nextSource.trimEnd()}\n\n${callLine}\n`;
120
+ }
121
+ }
122
+ if (!hasExecutablePattern(nextSource, callPattern)) {
123
+ throw new Error(`Unable to inject ${callLine} into ${path.basename(blockIndexPath)}.`);
124
+ }
125
+ return nextSource;
126
+ });
127
+ }
128
+ /**
129
+ * Ensure a scaffold block registration settings hook is imported and called.
130
+ *
131
+ * @param options Registration settings patch options.
132
+ * @param options.blockIndexPath Absolute path to the block entrypoint file.
133
+ * @param options.callLine Settings mutation call to insert before registration.
134
+ * @param options.callPattern Executable pattern used to detect an existing call.
135
+ * @param options.importLine Import line to prepend when missing.
136
+ * @param options.importPattern Uncommented import pattern used to avoid duplicates.
137
+ * @returns A promise that resolves after the entrypoint has been patched.
138
+ * @throws {Error} When the entrypoint does not expose the expected
139
+ * `registerScaffoldBlockType(registration.name, registration.settings)` call.
140
+ */
141
+ export async function ensureWorkspaceRegistrationSettingsCall({ blockIndexPath, callLine, callPattern, importLine, importPattern, }) {
142
+ await patchFile(blockIndexPath, (source) => {
143
+ let nextSource = source;
144
+ if (!hasUncommentedPattern(nextSource, importPattern)) {
145
+ nextSource = `${importLine}\n${nextSource}`;
146
+ }
147
+ if (!hasExecutablePattern(nextSource, callPattern)) {
148
+ const callRange = findExecutablePatternMatch(nextSource, [
149
+ SCAFFOLD_REGISTRATION_SETTINGS_CALL_PATTERN,
150
+ ]);
151
+ if (!callRange) {
152
+ throw new Error(`Unable to inject ${callLine} into ${path.basename(blockIndexPath)} because it does not expose a scaffold registration settings object.`);
153
+ }
154
+ nextSource = [
155
+ nextSource.slice(0, callRange.start),
156
+ `${callLine}\n`,
157
+ nextSource.slice(callRange.start),
158
+ ].join("");
159
+ }
160
+ return nextSource;
161
+ });
162
+ }
@@ -1,4 +1,9 @@
1
- import type { WorkspaceProject } from "./workspace-project.js";
2
- export declare function ensureRestResourceBootstrapAnchors(workspace: WorkspaceProject): Promise<void>;
3
- export declare function ensureContractSyncScriptAnchors(workspace: WorkspaceProject): Promise<void>;
4
- export declare function ensureRestResourceSyncScriptAnchors(workspace: WorkspaceProject): Promise<void>;
1
+ /**
2
+ * Compatibility facade for REST workspace anchor patchers.
3
+ *
4
+ * Keep the public runtime import path stable while bootstrap, contract sync,
5
+ * and REST resource sync patchers live in focused implementation modules.
6
+ */
7
+ export { ensureRestResourceBootstrapAnchors, ensureRestSchemaHelperBootstrapAnchors, } from "./cli-add-workspace-rest-bootstrap-anchors.js";
8
+ export { ensureContractSyncScriptAnchors, } from "./cli-add-workspace-rest-contract-sync-anchors.js";
9
+ export { ensureRestResourceSyncScriptAnchors, } from "./cli-add-workspace-rest-resource-sync-anchors.js";