wp-typia 0.22.7 → 0.22.9

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.
@@ -6,13 +6,12 @@ import {
6
6
  copyInterpolatedDirectory,
7
7
  createScaffoldCompatibilityConfig,
8
8
  getDefaultAnswers,
9
+ isCompoundPersistenceEnabled,
9
10
  listInterpolatedDirectoryOutputs,
10
11
  normalizeOptionalCliString,
11
12
  parseAlternateRenderTargets,
12
13
  parseCompoundInnerBlocksPreset,
13
- parseTemplateLocator,
14
14
  renderScaffoldCompatibilityConfig,
15
- require_semver,
16
15
  resolveExternalTemplateLayers,
17
16
  resolveLocalCliPathOption,
18
17
  resolveOptionalInteractiveExternalLayerId,
@@ -21,7 +20,7 @@ import {
21
20
  scaffoldProject,
22
21
  syncPersistenceRestArtifacts,
23
22
  updatePluginHeaderCompatibility
24
- } from "./cli-8snabymq.js";
23
+ } from "./cli-2pnk64h0.js";
25
24
  import {
26
25
  DEFAULT_WORDPRESS_ABILITIES_VERSION,
27
26
  DEFAULT_WORDPRESS_CORE_ABILITIES_VERSION,
@@ -31,10 +30,14 @@ import {
31
30
  DEFAULT_WP_TYPIA_DATAVIEWS_VERSION,
32
31
  getPackageVersions,
33
32
  resolveManagedPackageVersionRange
34
- } from "./cli-2hsp17nd.js";
33
+ } from "./cli-arz4rcye.js";
34
+ import {
35
+ parseTemplateLocator,
36
+ require_semver
37
+ } from "./cli-8reep89s.js";
35
38
  import {
36
39
  snapshotProjectVersion
37
- } from "./cli-27v2qpjg.js";
40
+ } from "./cli-ag722tzm.js";
38
41
  import {
39
42
  ensureMigrationDirectories,
40
43
  parseMigrationConfig,
@@ -48,10 +51,10 @@ import {
48
51
  hasUncommentedPattern,
49
52
  maskTypeScriptCommentsAndLiterals
50
53
  } from "./cli-rwjkqjhs.js";
51
- import"./cli-10pe4mf8.js";
54
+ import"./cli-xw1wbxf3.js";
52
55
  import {
53
56
  SHARED_WORKSPACE_TEMPLATE_ROOT
54
- } from "./cli-tke8twkn.js";
57
+ } from "./cli-qse6myha.js";
55
58
  import {
56
59
  ADD_BLOCK_TEMPLATE_IDS,
57
60
  EDITOR_PLUGIN_SLOT_IDS,
@@ -76,7 +79,9 @@ import {
76
79
  findPhpFunctionRange,
77
80
  formatAddHelpText,
78
81
  getMutableBlockHooks,
82
+ getPropertyNameText,
79
83
  getWorkspaceBlockSelectOptions,
84
+ getWorkspaceBlockSelectOptionsAsync,
80
85
  getWorkspaceBootstrapPath,
81
86
  hasPhpFunctionCall,
82
87
  hasPhpFunctionDefinition,
@@ -87,8 +92,9 @@ import {
87
92
  quotePhpString,
88
93
  quoteTsString,
89
94
  readOptionalFile,
95
+ readOptionalUtf8File,
90
96
  readWorkspaceBlockJson,
91
- readWorkspaceInventory,
97
+ readWorkspaceInventoryAsync,
92
98
  replacePhpFunctionDefinition,
93
99
  require_typescript,
94
100
  resolveNonEmptyNormalizedBlockSlug,
@@ -96,12 +102,14 @@ import {
96
102
  resolveWorkspaceBlock,
97
103
  rollbackWorkspaceMutation,
98
104
  snapshotWorkspaceFiles,
105
+ suggestAddBlockTemplateId,
99
106
  toCamelCase,
100
107
  toKebabCase,
101
108
  toPascalCase,
102
109
  toSnakeCase,
103
110
  toTitleCase
104
- } from "./cli-ta3y0hp2.js";
111
+ } from "./cli-regw5384.js";
112
+ import"./cli-cvxvcw7c.js";
105
113
  import {
106
114
  createManagedTempRoot
107
115
  } from "./cli-t73q5aqz.js";
@@ -228,7 +236,7 @@ function buildConfigEntries(templateId, variables) {
228
236
  if (templateId === "persistence") {
229
237
  return [buildPersistenceBlockConfigEntry(variables)];
230
238
  }
231
- if (variables.compoundPersistenceEnabled === "true") {
239
+ if (isCompoundPersistenceEnabled(variables)) {
232
240
  return [
233
241
  buildPersistenceBlockConfigEntry(variables),
234
242
  buildCompoundChildConfigEntry(variables)
@@ -499,12 +507,19 @@ async function assertWorkspaceDependenciesInstalled(workspace) {
499
507
  }
500
508
  throw new Error(`Workspace dependencies have not been installed yet. Run \`${formatInstallCommand(workspace.packageManager)}\` from the workspace root before using \`wp-typia add block ...\`.`);
501
509
  }
510
+ function getMistypedAddBlockTemplateMessage(templateId) {
511
+ const suggestion = suggestAddBlockTemplateId(templateId);
512
+ if (!suggestion) {
513
+ return null;
514
+ }
515
+ return `Unknown add-block template "${templateId}". Did you mean "${suggestion}"? Use \`--template ${suggestion}\`, or run \`wp-typia templates list\` to inspect available templates.`;
516
+ }
502
517
  async function copyScaffoldedBlockSlice(projectDir, templateId, tempProjectDir, variables, legacyValidatorPaths = []) {
503
518
  if (templateId === "compound") {
504
519
  await ensureCompoundWorkspaceSupportFiles(projectDir, tempProjectDir, legacyValidatorPaths);
505
520
  await copyTempDirectory(path3.join(tempProjectDir, "src", "blocks", variables.slugKebabCase), path3.join(projectDir, "src", "blocks", variables.slugKebabCase));
506
521
  await copyTempDirectory(path3.join(tempProjectDir, "src", "blocks", `${variables.slugKebabCase}-item`), path3.join(projectDir, "src", "blocks", `${variables.slugKebabCase}-item`));
507
- if (variables.compoundPersistenceEnabled === "true") {
522
+ if (isCompoundPersistenceEnabled(variables)) {
508
523
  await renderWorkspacePersistenceServerModule(projectDir, variables);
509
524
  }
510
525
  return;
@@ -617,7 +632,7 @@ async function syncWorkspaceAddedBlockArtifacts(projectDir, templateId, variable
617
632
  if (templateId === "compound") {
618
633
  await syncWorkspaceBlockMetadata(projectDir, `${variables.slugKebabCase}-item`, `${variables.pascalCase}ItemAttributes`, path3.join("src", "blocks", `${variables.slugKebabCase}-item`, "types.ts"));
619
634
  }
620
- if (templateId === "persistence" || templateId === "compound" && variables.compoundPersistenceEnabled === "true") {
635
+ if (templateId === "persistence" || templateId === "compound" && isCompoundPersistenceEnabled(variables)) {
621
636
  await syncWorkspacePersistenceArtifacts(projectDir, variables);
622
637
  }
623
638
  }
@@ -676,6 +691,10 @@ async function runAddBlockCommand({
676
691
  throw new Error("`wp-typia add block --template query-loop` is not supported. Query Loop is a create-time `core/query` variation scaffold, so use `wp-typia create <project-dir> --template query-loop` instead.");
677
692
  }
678
693
  if (!isAddBlockTemplateId(templateId)) {
694
+ const mistypedAddBlockTemplateMessage = getMistypedAddBlockTemplateMessage(templateId);
695
+ if (mistypedAddBlockTemplateMessage) {
696
+ throw new Error(mistypedAddBlockTemplateMessage);
697
+ }
679
698
  throw new Error(`Unknown add-block template "${templateId}". Expected one of: ${ADD_BLOCK_TEMPLATE_IDS.join(", ")}. Run \`wp-typia templates list\` to inspect available templates.`);
680
699
  }
681
700
  const resolvedTemplateId = templateId;
@@ -772,7 +791,7 @@ async function runAddBlockCommand({
772
791
  try {
773
792
  await copyScaffoldedBlockSlice(workspace.projectDir, resolvedTemplateId, tempProjectDir, result.variables, legacyCompoundValidatorPaths);
774
793
  await addCollectionImportsForTemplate(workspace.projectDir, resolvedTemplateId, result.variables);
775
- await appendBlockConfigEntries(workspace.projectDir, buildConfigEntries(resolvedTemplateId, result.variables), resolvedTemplateId === "persistence" || resolvedTemplateId === "compound" && result.variables.compoundPersistenceEnabled === "true");
794
+ await appendBlockConfigEntries(workspace.projectDir, buildConfigEntries(resolvedTemplateId, result.variables), resolvedTemplateId === "persistence" || resolvedTemplateId === "compound" && isCompoundPersistenceEnabled(result.variables));
776
795
  await syncWorkspaceAddedBlockArtifacts(workspace.projectDir, resolvedTemplateId, result.variables);
777
796
  await updateWorkspaceMigrationConfigIfPresent(workspace.projectDir, buildMigrationBlocks(resolvedTemplateId, result.variables));
778
797
  return {
@@ -797,6 +816,49 @@ async function runAddBlockCommand({
797
816
  import { promises as fsp9 } from "fs";
798
817
  import path14 from "path";
799
818
 
819
+ // ../wp-typia-project-tools/src/runtime/block-targets.ts
820
+ var FULL_BLOCK_NAME_PATTERN = /^[a-z0-9-]+\/[a-z0-9-]+$/u;
821
+ function assertFullBlockName(blockName, flagName) {
822
+ const trimmed = blockName.trim();
823
+ if (!trimmed) {
824
+ throw new Error(`\`${flagName}\` requires a block name.`);
825
+ }
826
+ if (!FULL_BLOCK_NAME_PATTERN.test(trimmed)) {
827
+ throw new Error(`\`${flagName}\` must use <namespace/block-slug> format.`);
828
+ }
829
+ return trimmed;
830
+ }
831
+ function resolveWorkspaceBlockTargetName(blockName, namespace, diagnostics) {
832
+ const trimmed = blockName.trim();
833
+ if (!trimmed) {
834
+ throw new Error(diagnostics.empty());
835
+ }
836
+ const blockNameSegments = trimmed.split("/");
837
+ if (blockNameSegments.length > 2) {
838
+ throw new Error(diagnostics.invalidFormat(trimmed));
839
+ }
840
+ if (blockNameSegments.some((segment) => segment.trim() === "")) {
841
+ throw new Error(diagnostics.emptySegment(trimmed));
842
+ }
843
+ const [maybeNamespace, maybeSlug] = blockNameSegments.length === 2 ? blockNameSegments : [undefined, blockNameSegments[0]];
844
+ if (maybeNamespace && maybeNamespace !== namespace) {
845
+ throw new Error(diagnostics.namespaceMismatch(trimmed, maybeNamespace, namespace));
846
+ }
847
+ const blockSlug = normalizeBlockSlug(maybeSlug ?? "");
848
+ return {
849
+ blockName: `${namespace}/${blockSlug}`,
850
+ blockSlug
851
+ };
852
+ }
853
+ function resolveWorkspaceTargetBlockName(blockName, namespace, flagName) {
854
+ return resolveWorkspaceBlockTargetName(blockName, namespace, {
855
+ empty: () => `\`${flagName}\` requires <block-slug|namespace/block-slug>.`,
856
+ emptySegment: () => `\`${flagName}\` must use <block-slug|namespace/block-slug> format.`,
857
+ invalidFormat: () => `\`${flagName}\` must use <block-slug|namespace/block-slug> format.`,
858
+ namespaceMismatch: (_input, actualNamespace, expectedNamespace) => `\`${flagName}\` references namespace "${actualNamespace}". Expected "${expectedNamespace}".`
859
+ });
860
+ }
861
+
800
862
  // ../wp-typia-project-tools/src/runtime/cli-add-workspace-admin-view-types.ts
801
863
  var ADMIN_VIEW_REST_SOURCE_KIND = "rest-resource";
802
864
  var ADMIN_VIEW_CORE_DATA_SOURCE_KIND = "core-data";
@@ -904,7 +966,6 @@ function resolveAdminViewCoreDataSource(source) {
904
966
  }
905
967
 
906
968
  // ../wp-typia-project-tools/src/runtime/cli-add-workspace-admin-view-scaffold.ts
907
- import fs2 from "fs";
908
969
  import { promises as fsp3 } from "fs";
909
970
  import path5 from "path";
910
971
 
@@ -2085,26 +2146,31 @@ async function ensureAdminViewWebpackAnchors(workspace) {
2085
2146
  return nextSource;
2086
2147
  });
2087
2148
  }
2088
- function resolveAdminViewRegistryPath(projectDir) {
2149
+ async function resolveAdminViewRegistryPath(projectDir) {
2089
2150
  const adminViewsDir = path5.join(projectDir, "src", "admin-views");
2090
- return [
2151
+ for (const candidatePath of [
2091
2152
  path5.join(adminViewsDir, "index.ts"),
2092
2153
  path5.join(adminViewsDir, "index.js")
2093
- ].find((candidatePath) => fs2.existsSync(candidatePath)) ?? path5.join(adminViewsDir, "index.ts");
2154
+ ]) {
2155
+ if (await pathExists(candidatePath)) {
2156
+ return candidatePath;
2157
+ }
2158
+ }
2159
+ return path5.join(adminViewsDir, "index.ts");
2094
2160
  }
2095
- function readAdminViewRegistrySlugs(registryPath) {
2096
- if (!fs2.existsSync(registryPath)) {
2161
+ async function readAdminViewRegistrySlugs(registryPath) {
2162
+ const source = await readOptionalUtf8File(registryPath);
2163
+ if (source === null) {
2097
2164
  return [];
2098
2165
  }
2099
- const source = fs2.readFileSync(registryPath, "utf8");
2100
2166
  return Array.from(source.matchAll(/^\s*import\s+['"]\.\/([^/'"]+)(?:\/index(?:\.[cm]?[jt]sx?)?)?['"];?\s*$/gmu)).map((match) => match[1]);
2101
2167
  }
2102
2168
  async function writeAdminViewRegistry(projectDir, adminViewSlug) {
2103
2169
  const adminViewsDir = path5.join(projectDir, "src", "admin-views");
2104
- const registryPath = resolveAdminViewRegistryPath(projectDir);
2170
+ const registryPath = await resolveAdminViewRegistryPath(projectDir);
2105
2171
  await fsp3.mkdir(adminViewsDir, { recursive: true });
2106
- const existingAdminViewSlugs = readWorkspaceInventory(projectDir).adminViews.map((entry) => entry.slug);
2107
- const existingRegistrySlugs = readAdminViewRegistrySlugs(registryPath);
2172
+ const existingAdminViewSlugs = (await readWorkspaceInventoryAsync(projectDir)).adminViews.map((entry) => entry.slug);
2173
+ const existingRegistrySlugs = await readAdminViewRegistrySlugs(registryPath);
2108
2174
  const nextAdminViewSlugs = Array.from(new Set([
2109
2175
  ...existingAdminViewSlugs,
2110
2176
  ...existingRegistrySlugs,
@@ -2125,7 +2191,7 @@ async function scaffoldAdminViewWorkspace(options) {
2125
2191
  const buildScriptPath = path5.join(workspace.projectDir, "scripts", "build-workspace.mjs");
2126
2192
  const packageJsonPath = path5.join(workspace.projectDir, "package.json");
2127
2193
  const webpackConfigPath = path5.join(workspace.projectDir, "webpack.config.js");
2128
- const adminViewsIndexPath = resolveAdminViewRegistryPath(workspace.projectDir);
2194
+ const adminViewsIndexPath = await resolveAdminViewRegistryPath(workspace.projectDir);
2129
2195
  const adminViewDir = path5.join(workspace.projectDir, "src", "admin-views", adminViewSlug);
2130
2196
  const adminViewPhpPath = path5.join(workspace.projectDir, "inc", "admin-views", `${adminViewSlug}.php`);
2131
2197
  await executeWorkspaceMutationPlan({
@@ -2173,7 +2239,7 @@ async function runAddAdminViewCommand({
2173
2239
  assertAdminViewPackageAvailability();
2174
2240
  const adminViewSlug = assertValidGeneratedSlug("Admin view name", normalizeBlockSlug(adminViewName), ADD_ADMIN_VIEW_USAGE);
2175
2241
  const parsedSource = parseAdminViewSource(source);
2176
- const inventory = readWorkspaceInventory(workspace.projectDir);
2242
+ const inventory = await readWorkspaceInventoryAsync(workspace.projectDir);
2177
2243
  const restResource = resolveRestResourceSource(inventory.restResources, parsedSource);
2178
2244
  const coreDataSource = resolveAdminViewCoreDataSource(parsedSource);
2179
2245
  assertAdminViewDoesNotExist(workspace.projectDir, adminViewSlug, inventory);
@@ -2192,7 +2258,6 @@ async function runAddAdminViewCommand({
2192
2258
  }
2193
2259
  // ../wp-typia-project-tools/src/runtime/cli-add-workspace-assets.ts
2194
2260
  var import_typescript = __toESM(require_typescript(), 1);
2195
- import fs3 from "fs";
2196
2261
  import { promises as fsp4 } from "fs";
2197
2262
  import path6 from "path";
2198
2263
  import {
@@ -2238,24 +2303,6 @@ function assertValidBindingAttributeName(attributeName) {
2238
2303
  }
2239
2304
  return trimmed;
2240
2305
  }
2241
- function resolveBindingTargetBlockSlug(blockName, namespace) {
2242
- const trimmed = blockName.trim();
2243
- if (!trimmed) {
2244
- throw new Error("`wp-typia add binding-source` requires --block <block-slug|namespace/block-slug> to include a value when --attribute is provided.");
2245
- }
2246
- const blockNameSegments = trimmed.split("/");
2247
- if (blockNameSegments.length > 2) {
2248
- throw new Error(`Binding target block "${trimmed}" must use <block-slug> or <namespace/block-slug> format.`);
2249
- }
2250
- if (blockNameSegments.some((segment) => segment.trim() === "")) {
2251
- throw new Error(`Binding target block "${trimmed}" must use <block-slug> or <namespace/block-slug> format without empty path segments.`);
2252
- }
2253
- const [maybeNamespace, maybeSlug] = blockNameSegments.length === 2 ? blockNameSegments : [undefined, blockNameSegments[0]];
2254
- if (maybeNamespace && maybeNamespace !== namespace) {
2255
- throw new Error(`Binding target block "${trimmed}" uses namespace "${maybeNamespace}". Expected "${namespace}".`);
2256
- }
2257
- return normalizeBlockSlug(maybeSlug ?? "");
2258
- }
2259
2306
  function buildEditorPluginConfigEntry(editorPluginSlug, slot) {
2260
2307
  return [
2261
2308
  "\t{",
@@ -2420,9 +2467,15 @@ function resolveBindingTarget(options, namespace) {
2420
2467
  if (!hasBlock || !hasAttribute) {
2421
2468
  throw new Error("`wp-typia add binding-source` requires --block and --attribute to be provided together.");
2422
2469
  }
2470
+ const targetBlock = resolveWorkspaceBlockTargetName(blockName ?? "", namespace, {
2471
+ empty: () => "`wp-typia add binding-source` requires --block <block-slug|namespace/block-slug> to include a value when --attribute is provided.",
2472
+ emptySegment: (input) => `Binding target block "${input}" must use <block-slug> or <namespace/block-slug> format without empty path segments.`,
2473
+ invalidFormat: (input) => `Binding target block "${input}" must use <block-slug> or <namespace/block-slug> format.`,
2474
+ namespaceMismatch: (input, actualNamespace, expectedNamespace) => `Binding target block "${input}" uses namespace "${actualNamespace}". Expected "${expectedNamespace}".`
2475
+ });
2423
2476
  return {
2424
2477
  attributeName: assertValidBindingAttributeName(attributeName ?? ""),
2425
- blockSlug: resolveBindingTargetBlockSlug(blockName ?? "", namespace)
2478
+ blockSlug: targetBlock.blockSlug
2426
2479
  };
2427
2480
  }
2428
2481
  function formatBindingAttributeTypeMember(attributeName) {
@@ -2448,12 +2501,6 @@ function getInterfaceDeclaration(source, interfaceName) {
2448
2501
  visit(sourceFile);
2449
2502
  return declaration ? { declaration, sourceFile } : undefined;
2450
2503
  }
2451
- function getPropertyNameText(name) {
2452
- if (import_typescript.default.isIdentifier(name) || import_typescript.default.isStringLiteral(name) || import_typescript.default.isNumericLiteral(name)) {
2453
- return name.text;
2454
- }
2455
- return;
2456
- }
2457
2504
  function interfaceHasAttributeMember(declaration, attributeName) {
2458
2505
  return declaration.members.some((member) => import_typescript.default.isPropertySignature(member) && member.name !== undefined && getPropertyNameText(member.name) === attributeName);
2459
2506
  }
@@ -2930,38 +2977,51 @@ async function ensureEditorPluginWebpackAnchors(workspace) {
2930
2977
  return nextSource;
2931
2978
  });
2932
2979
  }
2933
- function resolveBindingSourceRegistryPath(projectDir) {
2980
+ async function resolveBindingSourceRegistryPath(projectDir) {
2934
2981
  const bindingsDir = path6.join(projectDir, "src", "bindings");
2935
- return [path6.join(bindingsDir, "index.ts"), path6.join(bindingsDir, "index.js")].find((candidatePath) => fs3.existsSync(candidatePath)) ?? path6.join(bindingsDir, "index.ts");
2982
+ for (const candidatePath of [
2983
+ path6.join(bindingsDir, "index.ts"),
2984
+ path6.join(bindingsDir, "index.js")
2985
+ ]) {
2986
+ if (await pathExists(candidatePath)) {
2987
+ return candidatePath;
2988
+ }
2989
+ }
2990
+ return path6.join(bindingsDir, "index.ts");
2936
2991
  }
2937
2992
  async function writeBindingSourceRegistry(projectDir, bindingSourceSlug) {
2938
2993
  const bindingsDir = path6.join(projectDir, "src", "bindings");
2939
- const bindingsIndexPath = resolveBindingSourceRegistryPath(projectDir);
2994
+ const bindingsIndexPath = await resolveBindingSourceRegistryPath(projectDir);
2940
2995
  await fsp4.mkdir(bindingsDir, { recursive: true });
2941
- const existingBindingSourceSlugs = fs3.readdirSync(bindingsDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
2996
+ const existingBindingSourceSlugs = (await fsp4.readdir(bindingsDir, { withFileTypes: true })).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
2942
2997
  const nextBindingSourceSlugs = Array.from(new Set([...existingBindingSourceSlugs, bindingSourceSlug])).sort();
2943
2998
  await fsp4.writeFile(bindingsIndexPath, buildBindingSourceIndexSource(nextBindingSourceSlugs), "utf8");
2944
2999
  }
2945
- function resolveEditorPluginRegistryPath(projectDir) {
3000
+ async function resolveEditorPluginRegistryPath(projectDir) {
2946
3001
  const editorPluginsDir = path6.join(projectDir, "src", "editor-plugins");
2947
- return [
3002
+ for (const candidatePath of [
2948
3003
  path6.join(editorPluginsDir, "index.ts"),
2949
3004
  path6.join(editorPluginsDir, "index.js")
2950
- ].find((candidatePath) => fs3.existsSync(candidatePath)) ?? path6.join(editorPluginsDir, "index.ts");
3005
+ ]) {
3006
+ if (await pathExists(candidatePath)) {
3007
+ return candidatePath;
3008
+ }
3009
+ }
3010
+ return path6.join(editorPluginsDir, "index.ts");
2951
3011
  }
2952
- function readEditorPluginRegistrySlugs(registryPath) {
2953
- if (!fs3.existsSync(registryPath)) {
3012
+ async function readEditorPluginRegistrySlugs(registryPath) {
3013
+ const source = await readOptionalUtf8File(registryPath);
3014
+ if (source === null) {
2954
3015
  return [];
2955
3016
  }
2956
- const source = fs3.readFileSync(registryPath, "utf8");
2957
3017
  return Array.from(source.matchAll(/^\s*import\s+['"]\.\/([^/'"]+)(?:\/index(?:\.[cm]?[jt]sx?)?)?['"];?\s*$/gmu)).map((match) => match[1]);
2958
3018
  }
2959
3019
  async function writeEditorPluginRegistry(projectDir, editorPluginSlug) {
2960
3020
  const editorPluginsDir = path6.join(projectDir, "src", "editor-plugins");
2961
- const registryPath = resolveEditorPluginRegistryPath(projectDir);
3021
+ const registryPath = await resolveEditorPluginRegistryPath(projectDir);
2962
3022
  await fsp4.mkdir(editorPluginsDir, { recursive: true });
2963
- const existingEditorPluginSlugs = readWorkspaceInventory(projectDir).editorPlugins.map((entry) => entry.slug);
2964
- const existingRegistrySlugs = readEditorPluginRegistrySlugs(registryPath);
3023
+ const existingEditorPluginSlugs = (await readWorkspaceInventoryAsync(projectDir)).editorPlugins.map((entry) => entry.slug);
3024
+ const existingRegistrySlugs = await readEditorPluginRegistrySlugs(registryPath);
2965
3025
  const nextEditorPluginSlugs = Array.from(new Set([...existingEditorPluginSlugs, ...existingRegistrySlugs, editorPluginSlug])).sort();
2966
3026
  await fsp4.writeFile(registryPath, buildEditorPluginRegistrySource(nextEditorPluginSlugs), "utf8");
2967
3027
  }
@@ -2973,12 +3033,12 @@ async function runAddEditorPluginCommand({
2973
3033
  const workspace = resolveWorkspaceProject(cwd);
2974
3034
  const editorPluginSlug = assertValidGeneratedSlug("Editor plugin name", normalizeBlockSlug(editorPluginName), "wp-typia add editor-plugin <name> [--slot <sidebar|document-setting-panel>]");
2975
3035
  const resolvedSlot = assertValidEditorPluginSlot(slot);
2976
- const inventory = readWorkspaceInventory(workspace.projectDir);
3036
+ const inventory = await readWorkspaceInventoryAsync(workspace.projectDir);
2977
3037
  assertEditorPluginDoesNotExist(workspace.projectDir, editorPluginSlug, inventory);
2978
3038
  const blockConfigPath = path6.join(workspace.projectDir, "scripts", "block-config.ts");
2979
3039
  const bootstrapPath = getWorkspaceBootstrapPath(workspace);
2980
3040
  const buildScriptPath = path6.join(workspace.projectDir, "scripts", "build-workspace.mjs");
2981
- const editorPluginsIndexPath = resolveEditorPluginRegistryPath(workspace.projectDir);
3041
+ const editorPluginsIndexPath = await resolveEditorPluginRegistryPath(workspace.projectDir);
2982
3042
  const webpackConfigPath = path6.join(workspace.projectDir, "webpack.config.js");
2983
3043
  const editorPluginDir = path6.join(workspace.projectDir, "src", "editor-plugins", editorPluginSlug);
2984
3044
  const entryFilePath = path6.join(editorPluginDir, "index.tsx");
@@ -3029,7 +3089,7 @@ async function runAddPatternCommand({
3029
3089
  }) {
3030
3090
  const workspace = resolveWorkspaceProject(cwd);
3031
3091
  const patternSlug = assertValidGeneratedSlug("Pattern name", normalizeBlockSlug(patternName), "wp-typia add pattern <name>");
3032
- const inventory = readWorkspaceInventory(workspace.projectDir);
3092
+ const inventory = await readWorkspaceInventoryAsync(workspace.projectDir);
3033
3093
  assertPatternDoesNotExist(workspace.projectDir, patternSlug, inventory);
3034
3094
  const blockConfigPath = path6.join(workspace.projectDir, "scripts", "block-config.ts");
3035
3095
  const bootstrapPath = getWorkspaceBootstrapPath(workspace);
@@ -3063,7 +3123,7 @@ async function runAddBindingSourceCommand({
3063
3123
  }) {
3064
3124
  const workspace = resolveWorkspaceProject(cwd);
3065
3125
  const bindingSourceSlug = assertValidGeneratedSlug("Binding source name", normalizeBlockSlug(bindingSourceName), "wp-typia add binding-source <name> [--block <block-slug|namespace/block-slug> --attribute <attribute>]");
3066
- const inventory = readWorkspaceInventory(workspace.projectDir);
3126
+ const inventory = await readWorkspaceInventoryAsync(workspace.projectDir);
3067
3127
  assertBindingSourceDoesNotExist(workspace.projectDir, bindingSourceSlug, inventory);
3068
3128
  const target = resolveBindingTarget({
3069
3129
  attributeName,
@@ -3072,7 +3132,7 @@ async function runAddBindingSourceCommand({
3072
3132
  const targetBlock = target ? resolveWorkspaceBlock(inventory, target.blockSlug) : undefined;
3073
3133
  const blockConfigPath = path6.join(workspace.projectDir, "scripts", "block-config.ts");
3074
3134
  const bootstrapPath = getWorkspaceBootstrapPath(workspace);
3075
- const bindingsIndexPath = resolveBindingSourceRegistryPath(workspace.projectDir);
3135
+ const bindingsIndexPath = await resolveBindingSourceRegistryPath(workspace.projectDir);
3076
3136
  const bindingSourceDir = path6.join(workspace.projectDir, "src", "bindings", bindingSourceSlug);
3077
3137
  const serverFilePath = path6.join(bindingSourceDir, "server.php");
3078
3138
  const editorFilePath = path6.join(bindingSourceDir, "editor.ts");
@@ -4257,7 +4317,7 @@ async function runAddRestResourceCommand({
4257
4317
  const restResourceSlug = assertValidGeneratedSlug("REST resource name", normalizeBlockSlug(restResourceName), "wp-typia add rest-resource <name> [--namespace <vendor/v1>] [--methods <list,read,create>]");
4258
4318
  const resolvedMethods = assertValidRestResourceMethods(methods);
4259
4319
  const resolvedNamespace = resolveRestResourceNamespace(workspace.workspace.namespace, namespace);
4260
- const inventory = readWorkspaceInventory(workspace.projectDir);
4320
+ const inventory = await readWorkspaceInventoryAsync(workspace.projectDir);
4261
4321
  assertRestResourceDoesNotExist(workspace.projectDir, restResourceSlug, inventory);
4262
4322
  const blockConfigPath = path9.join(workspace.projectDir, "scripts", "block-config.ts");
4263
4323
  const bootstrapPath = getWorkspaceBootstrapPath(workspace);
@@ -4320,7 +4380,6 @@ async function runAddRestResourceCommand({
4320
4380
  }
4321
4381
  // ../wp-typia-project-tools/src/runtime/cli-add-workspace-ability-scaffold.ts
4322
4382
  var import_semver = __toESM(require_semver(), 1);
4323
- import fs4 from "fs";
4324
4383
  import { promises as fsp6 } from "fs";
4325
4384
  import path10 from "path";
4326
4385
  import { syncTypeSchemas as syncTypeSchemas2 } from "@wp-typia/block-runtime/metadata-core";
@@ -4812,26 +4871,34 @@ function resolveManagedDependencyVersion(existingVersion, requiredVersion) {
4812
4871
  }
4813
4872
  return import_semver.default.gte(existingMinimum, requiredMinimum) ? existingVersion : requiredVersion;
4814
4873
  }
4815
- function resolveAbilityRegistryPath(projectDir) {
4874
+ async function resolveAbilityRegistryPath(projectDir) {
4816
4875
  const abilitiesDir = path10.join(projectDir, "src", "abilities");
4817
- return [path10.join(abilitiesDir, "index.ts"), path10.join(abilitiesDir, "index.js")].find((candidatePath) => fs4.existsSync(candidatePath)) ?? path10.join(abilitiesDir, "index.ts");
4876
+ for (const candidatePath of [
4877
+ path10.join(abilitiesDir, "index.ts"),
4878
+ path10.join(abilitiesDir, "index.js")
4879
+ ]) {
4880
+ if (await pathExists(candidatePath)) {
4881
+ return candidatePath;
4882
+ }
4883
+ }
4884
+ return path10.join(abilitiesDir, "index.ts");
4818
4885
  }
4819
- function readAbilityRegistrySlugs(registryPath) {
4820
- if (!fs4.existsSync(registryPath)) {
4886
+ async function readAbilityRegistrySlugs(registryPath) {
4887
+ const source = await readOptionalUtf8File(registryPath);
4888
+ if (source === null) {
4821
4889
  return [];
4822
4890
  }
4823
- const source = fs4.readFileSync(registryPath, "utf8");
4824
- return Array.from(source.matchAll(/^\s*export\s+\*\s+from\s+['"]\.\/([^/'"]+)\/client['"];?\s*$/gmu)).map((match) => match[1]);
4891
+ return Array.from(source.matchAll(/^\s*export\s+\*\s+from\s+['"]\.\/([^/'"]+)\/client(?:\.[cm]?[jt]sx?)?['"];?\s*$/gmu)).map((match) => match[1]);
4825
4892
  }
4826
4893
  async function writeAbilityRegistry(projectDir, abilitySlug) {
4827
4894
  const abilitiesDir = path10.join(projectDir, "src", "abilities");
4828
- const registryPath = resolveAbilityRegistryPath(projectDir);
4895
+ const registryPath = await resolveAbilityRegistryPath(projectDir);
4829
4896
  await fsp6.mkdir(abilitiesDir, { recursive: true });
4830
- const existingAbilitySlugs = readWorkspaceInventory(projectDir).abilities.map((entry) => entry.slug);
4831
- const existingRegistrySlugs = readAbilityRegistrySlugs(registryPath);
4897
+ const existingAbilitySlugs = (await readWorkspaceInventoryAsync(projectDir)).abilities.map((entry) => entry.slug);
4898
+ const existingRegistrySlugs = await readAbilityRegistrySlugs(registryPath);
4832
4899
  const nextAbilitySlugs = Array.from(new Set([...existingAbilitySlugs, ...existingRegistrySlugs, abilitySlug])).sort();
4833
4900
  const generatedSection = buildAbilityRegistrySource(nextAbilitySlugs);
4834
- const existingSource = fs4.existsSync(registryPath) ? fs4.readFileSync(registryPath, "utf8") : "";
4901
+ const existingSource = await readOptionalUtf8File(registryPath) ?? "";
4835
4902
  const generatedSectionPattern = new RegExp(`${escapeRegex(ABILITY_REGISTRY_START_MARKER)}[\\s\\S]*?${escapeRegex(ABILITY_REGISTRY_END_MARKER)}\\n?`, "u");
4836
4903
  const nextSource = existingSource ? generatedSectionPattern.test(existingSource) ? existingSource.replace(generatedSectionPattern, generatedSection) : `${existingSource.trimEnd()}
4837
4904
 
@@ -5100,7 +5167,7 @@ async function scaffoldAbilityWorkspace({
5100
5167
  const syncAbilitiesScriptPath = path10.join(workspace.projectDir, "scripts", "sync-abilities.ts");
5101
5168
  const syncProjectScriptPath = path10.join(workspace.projectDir, "scripts", "sync-project.ts");
5102
5169
  const webpackConfigPath = path10.join(workspace.projectDir, "webpack.config.js");
5103
- const abilitiesIndexPath = resolveAbilityRegistryPath(workspace.projectDir);
5170
+ const abilitiesIndexPath = await resolveAbilityRegistryPath(workspace.projectDir);
5104
5171
  const abilityDir = path10.join(workspace.projectDir, "src", "abilities", abilitySlug);
5105
5172
  const configFilePath = path10.join(abilityDir, "ability.config.json");
5106
5173
  const typesFilePath = path10.join(abilityDir, "types.ts");
@@ -5171,7 +5238,7 @@ async function runAddAbilityCommand({
5171
5238
  }) {
5172
5239
  const workspace = resolveWorkspaceProject(cwd);
5173
5240
  const abilitySlug = assertValidGeneratedSlug("Ability name", normalizeBlockSlug(abilityName), "wp-typia add ability <name>");
5174
- const inventory = readWorkspaceInventory(workspace.projectDir);
5241
+ const inventory = await readWorkspaceInventoryAsync(workspace.projectDir);
5175
5242
  assertAbilityDoesNotExist(workspace.projectDir, abilitySlug, inventory);
5176
5243
  const compatibilityPolicy = resolveScaffoldCompatibilityPolicy(REQUIRED_WORKSPACE_ABILITY_COMPATIBILITY);
5177
5244
  const scaffoldResult = await scaffoldAbilityWorkspace({
@@ -6713,7 +6780,7 @@ async function runAddAiFeatureCommand({
6713
6780
  const aiFeatureSlug = assertValidGeneratedSlug("AI feature name", normalizeBlockSlug(aiFeatureName), "wp-typia add ai-feature <name> [--namespace <vendor/v1>]");
6714
6781
  const resolvedNamespace = resolveRestResourceNamespace(workspace.workspace.namespace, namespace);
6715
6782
  const compatibilityPolicy = resolveScaffoldCompatibilityPolicy(OPTIONAL_WORDPRESS_AI_CLIENT_COMPATIBILITY);
6716
- const inventory = readWorkspaceInventory(workspace.projectDir);
6783
+ const inventory = await readWorkspaceInventoryAsync(workspace.projectDir);
6717
6784
  assertAiFeatureDoesNotExist(workspace.projectDir, aiFeatureSlug, inventory);
6718
6785
  const scaffoldResult = await scaffoldAiFeatureWorkspace({
6719
6786
  aiFeatureSlug,
@@ -6743,7 +6810,6 @@ var BLOCK_TRANSFORMS_IMPORT_PATTERN = /^\s*import\s*\{\s*applyWorkspaceBlockTran
6743
6810
  var BLOCK_TRANSFORMS_CALL_LINE = "applyWorkspaceBlockTransforms(registration.settings);";
6744
6811
  var BLOCK_TRANSFORMS_CALL_PATTERN = /applyWorkspaceBlockTransforms\s*\(\s*registration\s*\.\s*settings\s*\)\s*;?/u;
6745
6812
  var SCAFFOLD_REGISTRATION_SETTINGS_CALL_PATTERN = /registerScaffoldBlockType\s*\(\s*registration\s*\.\s*name\s*,\s*registration\s*\.\s*settings\s*\)\s*;?/u;
6746
- var FULL_BLOCK_NAME_PATTERN = /^[a-z0-9-]+\/[a-z0-9-]+$/u;
6747
6813
  function isIdentifierBoundary(source, index) {
6748
6814
  if (index < 0 || index >= source.length) {
6749
6815
  return true;
@@ -7136,35 +7202,6 @@ async function writeBlockTransformRegistry(projectDir, blockSlug, transformSlug)
7136
7202
  const nextTransformSlugs = Array.from(new Set([...existingTransformSlugs, transformSlug])).sort();
7137
7203
  await fsp9.writeFile(transformsIndexPath, buildBlockTransformIndexSource(nextTransformSlugs), "utf8");
7138
7204
  }
7139
- function assertFullBlockName(blockName, flagName) {
7140
- const trimmed = blockName.trim();
7141
- if (!trimmed) {
7142
- throw new Error(`\`${flagName}\` requires a block name.`);
7143
- }
7144
- if (!FULL_BLOCK_NAME_PATTERN.test(trimmed)) {
7145
- throw new Error(`\`${flagName}\` must use <namespace/block-slug> format.`);
7146
- }
7147
- return trimmed;
7148
- }
7149
- function resolveWorkspaceTargetBlockName(blockName, namespace, flagName) {
7150
- const trimmed = blockName.trim();
7151
- if (!trimmed) {
7152
- throw new Error(`\`${flagName}\` requires <block-slug|namespace/block-slug>.`);
7153
- }
7154
- const blockNameSegments = trimmed.split("/");
7155
- if (blockNameSegments.length > 2 || blockNameSegments.some((segment) => segment.trim() === "")) {
7156
- throw new Error(`\`${flagName}\` must use <block-slug|namespace/block-slug> format.`);
7157
- }
7158
- const [maybeNamespace, maybeSlug] = blockNameSegments.length === 2 ? blockNameSegments : [undefined, blockNameSegments[0]];
7159
- if (maybeNamespace && maybeNamespace !== namespace) {
7160
- throw new Error(`\`${flagName}\` references namespace "${maybeNamespace}". Expected "${namespace}".`);
7161
- }
7162
- const blockSlug = normalizeBlockSlug(maybeSlug ?? "");
7163
- return {
7164
- blockName: `${namespace}/${blockSlug}`,
7165
- blockSlug
7166
- };
7167
- }
7168
7205
  async function runAddVariationCommand({
7169
7206
  blockName,
7170
7207
  cwd = process.cwd(),
@@ -7173,7 +7210,7 @@ async function runAddVariationCommand({
7173
7210
  const workspace = resolveWorkspaceProject(cwd);
7174
7211
  const blockSlug = normalizeBlockSlug(blockName);
7175
7212
  const variationSlug = assertValidGeneratedSlug("Variation name", normalizeBlockSlug(variationName), "wp-typia add variation <name> --block <block-slug>");
7176
- const inventory = readWorkspaceInventory(workspace.projectDir);
7213
+ const inventory = await readWorkspaceInventoryAsync(workspace.projectDir);
7177
7214
  resolveWorkspaceBlock(inventory, blockSlug);
7178
7215
  assertVariationDoesNotExist(workspace.projectDir, blockSlug, variationSlug, inventory);
7179
7216
  const blockConfigPath = path14.join(workspace.projectDir, "scripts", "block-config.ts");
@@ -7220,7 +7257,7 @@ async function runAddBlockStyleCommand({
7220
7257
  const workspace = resolveWorkspaceProject(cwd);
7221
7258
  const blockSlug = normalizeBlockSlug(blockName);
7222
7259
  const styleSlug = assertValidGeneratedSlug("Style name", normalizeBlockSlug(styleName), "wp-typia add style <name> --block <block-slug>");
7223
- const inventory = readWorkspaceInventory(workspace.projectDir);
7260
+ const inventory = await readWorkspaceInventoryAsync(workspace.projectDir);
7224
7261
  resolveWorkspaceBlock(inventory, blockSlug);
7225
7262
  assertBlockStyleDoesNotExist(workspace.projectDir, blockSlug, styleSlug, inventory);
7226
7263
  const blockConfigPath = path14.join(workspace.projectDir, "scripts", "block-config.ts");
@@ -7269,7 +7306,7 @@ async function runAddBlockTransformCommand({
7269
7306
  const transformSlug = assertValidGeneratedSlug("Transform name", normalizeBlockSlug(transformName), "wp-typia add transform <name> --from <namespace/block> --to <block-slug|namespace/block-slug>");
7270
7307
  const resolvedFromBlockName = assertFullBlockName(fromBlockName, "--from");
7271
7308
  const target = resolveWorkspaceTargetBlockName(toBlockName, workspace.workspace.namespace, "--to");
7272
- const inventory = readWorkspaceInventory(workspace.projectDir);
7309
+ const inventory = await readWorkspaceInventoryAsync(workspace.projectDir);
7273
7310
  resolveWorkspaceBlock(inventory, target.blockSlug);
7274
7311
  assertBlockTransformDoesNotExist(workspace.projectDir, target.blockSlug, transformSlug, inventory);
7275
7312
  const blockConfigPath = path14.join(workspace.projectDir, "scripts", "block-config.ts");
@@ -7329,7 +7366,7 @@ async function runAddHookedBlockCommand({
7329
7366
  }) {
7330
7367
  const workspace = resolveWorkspaceProject(cwd);
7331
7368
  const blockSlug = normalizeBlockSlug(blockName);
7332
- const inventory = readWorkspaceInventory(workspace.projectDir);
7369
+ const inventory = await readWorkspaceInventoryAsync(workspace.projectDir);
7333
7370
  resolveWorkspaceBlock(inventory, blockSlug);
7334
7371
  const resolvedAnchorBlockName = assertValidHookAnchor(anchorBlockName);
7335
7372
  const resolvedPosition = assertValidHookedBlockPosition(position);
@@ -7363,6 +7400,7 @@ async function runAddHookedBlockCommand({
7363
7400
  }
7364
7401
  }
7365
7402
  export {
7403
+ suggestAddBlockTemplateId,
7366
7404
  seedWorkspaceMigrationProject,
7367
7405
  runAddVariationCommand,
7368
7406
  runAddRestResourceCommand,
@@ -7377,6 +7415,7 @@ export {
7377
7415
  runAddAdminViewCommand,
7378
7416
  runAddAbilityCommand,
7379
7417
  isAddBlockTemplateId,
7418
+ getWorkspaceBlockSelectOptionsAsync,
7380
7419
  getWorkspaceBlockSelectOptions,
7381
7420
  formatAddHelpText,
7382
7421
  EDITOR_PLUGIN_SLOT_IDS,
@@ -7384,4 +7423,4 @@ export {
7384
7423
  ADD_BLOCK_TEMPLATE_IDS
7385
7424
  };
7386
7425
 
7387
- //# debugId=DA912BE06859998764756E2164756E21
7426
+ //# debugId=31F5DCD7996BF38964756E2164756E21
@@ -51,7 +51,7 @@ import {
51
51
  } from "./cli-bq2v559b.js";
52
52
  import {
53
53
  readWorkspaceInventory
54
- } from "./cli-ta3y0hp2.js";
54
+ } from "./cli-regw5384.js";
55
55
  import {
56
56
  getInvalidWorkspaceProjectReason,
57
57
  tryResolveWorkspaceProject