wp-typia 0.22.3 → 0.22.4

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.
@@ -21,7 +21,7 @@ import {
21
21
  scaffoldProject,
22
22
  syncPersistenceRestArtifacts,
23
23
  updatePluginHeaderCompatibility
24
- } from "./cli-tbd9x8b6.js";
24
+ } from "./cli-6ymn63t4.js";
25
25
  import {
26
26
  DEFAULT_WORDPRESS_ABILITIES_VERSION,
27
27
  DEFAULT_WORDPRESS_CORE_ABILITIES_VERSION,
@@ -34,17 +34,20 @@ import {
34
34
  } from "./cli-1sm60g1z.js";
35
35
  import {
36
36
  snapshotProjectVersion
37
- } from "./cli-prc42zqd.js";
37
+ } from "./cli-2mt6bvcj.js";
38
38
  import {
39
39
  ensureMigrationDirectories,
40
40
  parseMigrationConfig,
41
41
  writeInitialMigrationScaffold,
42
42
  writeMigrationConfig
43
- } from "./cli-gcbre1zs.js";
43
+ } from "./cli-hb9vpsev.js";
44
44
  import"./cli-bq2v559b.js";
45
45
  import {
46
- formatInstallCommand
47
- } from "./cli-sj5mtyzj.js";
46
+ findExecutablePatternMatch,
47
+ hasExecutablePattern,
48
+ hasUncommentedPattern,
49
+ maskTypeScriptCommentsAndLiterals
50
+ } from "./cli-rwjkqjhs.js";
48
51
  import"./cli-10pe4mf8.js";
49
52
  import {
50
53
  SHARED_WORKSPACE_TEMPLATE_ROOT
@@ -97,7 +100,7 @@ import {
97
100
  toPascalCase,
98
101
  toSnakeCase,
99
102
  toTitleCase
100
- } from "./cli-x0h03qqe.js";
103
+ } from "./cli-qr2ek735.js";
101
104
  import {
102
105
  createManagedTempRoot
103
106
  } from "./cli-t73q5aqz.js";
@@ -107,7 +110,10 @@ import {
107
110
  } from "./cli-p95wr1q8.js";
108
111
  import {
109
112
  resolveWorkspaceProject
110
- } from "./cli-pd5pqgre.js";
113
+ } from "./cli-btbpt84c.js";
114
+ import {
115
+ formatInstallCommand
116
+ } from "./cli-6bhfzq5e.js";
111
117
  import {
112
118
  __reExport,
113
119
  __toESM
@@ -1865,6 +1871,67 @@ add_action( 'admin_enqueue_scripts', '${enqueueFunctionName}' );
1865
1871
  `;
1866
1872
  }
1867
1873
 
1874
+ // ../wp-typia-project-tools/src/runtime/cli-add-workspace-mutation.ts
1875
+ var DEFAULT_PHP_SNIPPET_INSERTION_ANCHORS = [
1876
+ /add_action\(\s*["']init["']\s*,\s*["'][^"']+_load_textdomain["']\s*\);\s*\n/u,
1877
+ /\?>\s*$/u
1878
+ ];
1879
+
1880
+ class WorkspaceMutationRollbackError extends Error {
1881
+ mutationError;
1882
+ rollbackError;
1883
+ constructor(mutationError, rollbackError) {
1884
+ super("Workspace mutation failed and rollback also failed.");
1885
+ this.name = "WorkspaceMutationRollbackError";
1886
+ this.mutationError = mutationError;
1887
+ this.rollbackError = rollbackError;
1888
+ }
1889
+ }
1890
+ async function executeWorkspaceMutationPlan({
1891
+ filePaths,
1892
+ run,
1893
+ snapshotDirs = [],
1894
+ targetPaths = []
1895
+ }) {
1896
+ const mutationSnapshot = {
1897
+ fileSources: await snapshotWorkspaceFiles(filePaths),
1898
+ snapshotDirs: [...snapshotDirs],
1899
+ targetPaths: [...targetPaths]
1900
+ };
1901
+ try {
1902
+ return await run();
1903
+ } catch (error) {
1904
+ try {
1905
+ await rollbackWorkspaceMutation(mutationSnapshot);
1906
+ } catch (rollbackError) {
1907
+ throw new WorkspaceMutationRollbackError(error, rollbackError);
1908
+ }
1909
+ throw error;
1910
+ }
1911
+ }
1912
+ function insertPhpSnippetBeforeWorkspaceAnchors(source, snippet) {
1913
+ for (const anchor of DEFAULT_PHP_SNIPPET_INSERTION_ANCHORS) {
1914
+ const candidate = source.replace(anchor, (match) => `${snippet}
1915
+ ${match}`);
1916
+ if (candidate !== source) {
1917
+ return candidate;
1918
+ }
1919
+ }
1920
+ return `${source.trimEnd()}
1921
+ ${snippet}
1922
+ `;
1923
+ }
1924
+ function appendPhpSnippetBeforeClosingTag(source, snippet) {
1925
+ const closingTagPattern = /\?>\s*$/u;
1926
+ if (closingTagPattern.test(source)) {
1927
+ return source.replace(closingTagPattern, `${snippet}
1928
+ ?>`);
1929
+ }
1930
+ return `${source.trimEnd()}
1931
+ ${snippet}
1932
+ `;
1933
+ }
1934
+
1868
1935
  // ../wp-typia-project-tools/src/runtime/cli-add-workspace-admin-view-scaffold.ts
1869
1936
  function detectJsonIndent(source) {
1870
1937
  const indentMatch = /\n([ \t]+)"/u.exec(source);
@@ -1928,36 +1995,8 @@ function ${loadFunctionName}() {
1928
1995
  }
1929
1996
  }
1930
1997
  `;
1931
- const insertionAnchors = [
1932
- /add_action\(\s*["']init["']\s*,\s*["'][^"']+_load_textdomain["']\s*\);\s*\n/u,
1933
- /\?>\s*$/u
1934
- ];
1935
- const insertPhpSnippet = (snippet) => {
1936
- for (const anchor of insertionAnchors) {
1937
- const candidate = nextSource.replace(anchor, (match) => `${snippet}
1938
- ${match}`);
1939
- if (candidate !== nextSource) {
1940
- nextSource = candidate;
1941
- return;
1942
- }
1943
- }
1944
- nextSource = `${nextSource.trimEnd()}
1945
- ${snippet}
1946
- `;
1947
- };
1948
- const appendPhpSnippet = (snippet) => {
1949
- const closingTagPattern = /\?>\s*$/u;
1950
- if (closingTagPattern.test(nextSource)) {
1951
- nextSource = nextSource.replace(closingTagPattern, `${snippet}
1952
- ?>`);
1953
- return;
1954
- }
1955
- nextSource = `${nextSource.trimEnd()}
1956
- ${snippet}
1957
- `;
1958
- };
1959
1998
  if (!hasPhpFunctionDefinition(nextSource, loadFunctionName)) {
1960
- insertPhpSnippet(loadFunction);
1999
+ nextSource = insertPhpSnippetBeforeWorkspaceAnchors(nextSource, loadFunction);
1961
2000
  } else {
1962
2001
  const functionRange = findPhpFunctionRange(nextSource, loadFunctionName);
1963
2002
  const functionSource = functionRange ? nextSource.slice(functionRange.start, functionRange.end) : "";
@@ -1970,7 +2009,7 @@ ${snippet}
1970
2009
  }
1971
2010
  }
1972
2011
  if (!loadHookPattern.test(nextSource)) {
1973
- appendPhpSnippet(loadHook);
2012
+ nextSource = appendPhpSnippetBeforeClosingTag(nextSource, loadHook);
1974
2013
  }
1975
2014
  return nextSource;
1976
2015
  });
@@ -2093,42 +2132,38 @@ async function scaffoldAdminViewWorkspace(options) {
2093
2132
  const adminViewsIndexPath = resolveAdminViewRegistryPath(workspace.projectDir);
2094
2133
  const adminViewDir = path5.join(workspace.projectDir, "src", "admin-views", adminViewSlug);
2095
2134
  const adminViewPhpPath = path5.join(workspace.projectDir, "inc", "admin-views", `${adminViewSlug}.php`);
2096
- const mutationSnapshot = {
2097
- fileSources: await snapshotWorkspaceFiles([
2135
+ await executeWorkspaceMutationPlan({
2136
+ filePaths: [
2098
2137
  adminViewsIndexPath,
2099
2138
  blockConfigPath,
2100
2139
  bootstrapPath,
2101
2140
  buildScriptPath,
2102
2141
  packageJsonPath,
2103
2142
  webpackConfigPath
2104
- ]),
2105
- snapshotDirs: [],
2106
- targetPaths: [adminViewDir, adminViewPhpPath]
2107
- };
2108
- try {
2109
- await fsp3.mkdir(adminViewDir, { recursive: true });
2110
- await fsp3.mkdir(path5.dirname(adminViewPhpPath), { recursive: true });
2111
- await ensureAdminViewPackageDependencies(workspace, parsedSource);
2112
- await ensureAdminViewBootstrapAnchors(workspace);
2113
- await ensureAdminViewBuildScriptAnchors(workspace);
2114
- await ensureAdminViewWebpackAnchors(workspace);
2115
- await fsp3.writeFile(path5.join(adminViewDir, "types.ts"), buildAdminViewTypesSource(adminViewSlug, restResource, coreDataSource), "utf8");
2116
- await fsp3.writeFile(path5.join(adminViewDir, "config.ts"), buildAdminViewConfigSource(adminViewSlug, workspace.workspace.textDomain, parsedSource, restResource), "utf8");
2117
- await fsp3.writeFile(path5.join(adminViewDir, "data.ts"), coreDataSource ? buildCoreDataAdminViewDataSource(adminViewSlug, coreDataSource) : restResource ? buildRestAdminViewDataSource(adminViewSlug, restResource) : buildDefaultAdminViewDataSource(adminViewSlug), "utf8");
2118
- await fsp3.writeFile(path5.join(adminViewDir, "Screen.tsx"), coreDataSource ? buildCoreDataAdminViewScreenSource(adminViewSlug, workspace.workspace.textDomain) : buildAdminViewScreenSource(adminViewSlug, workspace.workspace.textDomain), "utf8");
2119
- await fsp3.writeFile(path5.join(adminViewDir, "index.tsx"), buildAdminViewEntrySource(adminViewSlug), "utf8");
2120
- await fsp3.writeFile(path5.join(adminViewDir, "style.scss"), buildAdminViewStyleSource(), "utf8");
2121
- await fsp3.writeFile(adminViewPhpPath, buildAdminViewPhpSource(adminViewSlug, workspace), "utf8");
2122
- await writeAdminViewRegistry(workspace.projectDir, adminViewSlug);
2123
- await appendWorkspaceInventoryEntries(workspace.projectDir, {
2124
- adminViewEntries: [
2125
- buildAdminViewConfigEntry(adminViewSlug, parsedSource)
2126
- ]
2127
- });
2128
- } catch (error) {
2129
- await rollbackWorkspaceMutation(mutationSnapshot);
2130
- throw error;
2131
- }
2143
+ ],
2144
+ targetPaths: [adminViewDir, adminViewPhpPath],
2145
+ run: async () => {
2146
+ await fsp3.mkdir(adminViewDir, { recursive: true });
2147
+ await fsp3.mkdir(path5.dirname(adminViewPhpPath), { recursive: true });
2148
+ await ensureAdminViewPackageDependencies(workspace, parsedSource);
2149
+ await ensureAdminViewBootstrapAnchors(workspace);
2150
+ await ensureAdminViewBuildScriptAnchors(workspace);
2151
+ await ensureAdminViewWebpackAnchors(workspace);
2152
+ await fsp3.writeFile(path5.join(adminViewDir, "types.ts"), buildAdminViewTypesSource(adminViewSlug, restResource, coreDataSource), "utf8");
2153
+ await fsp3.writeFile(path5.join(adminViewDir, "config.ts"), buildAdminViewConfigSource(adminViewSlug, workspace.workspace.textDomain, parsedSource, restResource), "utf8");
2154
+ await fsp3.writeFile(path5.join(adminViewDir, "data.ts"), coreDataSource ? buildCoreDataAdminViewDataSource(adminViewSlug, coreDataSource) : restResource ? buildRestAdminViewDataSource(adminViewSlug, restResource) : buildDefaultAdminViewDataSource(adminViewSlug), "utf8");
2155
+ await fsp3.writeFile(path5.join(adminViewDir, "Screen.tsx"), coreDataSource ? buildCoreDataAdminViewScreenSource(adminViewSlug, workspace.workspace.textDomain) : buildAdminViewScreenSource(adminViewSlug, workspace.workspace.textDomain), "utf8");
2156
+ await fsp3.writeFile(path5.join(adminViewDir, "index.tsx"), buildAdminViewEntrySource(adminViewSlug), "utf8");
2157
+ await fsp3.writeFile(path5.join(adminViewDir, "style.scss"), buildAdminViewStyleSource(), "utf8");
2158
+ await fsp3.writeFile(adminViewPhpPath, buildAdminViewPhpSource(adminViewSlug, workspace), "utf8");
2159
+ await writeAdminViewRegistry(workspace.projectDir, adminViewSlug);
2160
+ await appendWorkspaceInventoryEntries(workspace.projectDir, {
2161
+ adminViewEntries: [
2162
+ buildAdminViewConfigEntry(adminViewSlug, parsedSource)
2163
+ ]
2164
+ });
2165
+ }
2166
+ });
2132
2167
  }
2133
2168
 
2134
2169
  // ../wp-typia-project-tools/src/runtime/cli-add-workspace-admin-view.ts
@@ -4960,50 +4995,22 @@ function ${enqueueFunctionName}() {
4960
4995
  );
4961
4996
  }
4962
4997
  `;
4963
- const insertionAnchors = [
4964
- /add_action\(\s*["']init["']\s*,\s*["'][^"']+_load_textdomain["']\s*\);\s*\n/u,
4965
- /\?>\s*$/u
4966
- ];
4967
- const insertPhpSnippet = (snippet) => {
4968
- for (const anchor of insertionAnchors) {
4969
- const candidate = nextSource.replace(anchor, (match) => `${snippet}
4970
- ${match}`);
4971
- if (candidate !== nextSource) {
4972
- nextSource = candidate;
4973
- return;
4974
- }
4975
- }
4976
- nextSource = `${nextSource.trimEnd()}
4977
- ${snippet}
4978
- `;
4979
- };
4980
- const appendPhpSnippet = (snippet) => {
4981
- const closingTagPattern = /\?>\s*$/u;
4982
- if (closingTagPattern.test(nextSource)) {
4983
- nextSource = nextSource.replace(closingTagPattern, `${snippet}
4984
- ?>`);
4985
- return;
4986
- }
4987
- nextSource = `${nextSource.trimEnd()}
4988
- ${snippet}
4989
- `;
4990
- };
4991
4998
  if (!hasPhpFunctionDefinition(nextSource, loadFunctionName)) {
4992
- insertPhpSnippet(loadFunction);
4999
+ nextSource = insertPhpSnippetBeforeWorkspaceAnchors(nextSource, loadFunction);
4993
5000
  }
4994
5001
  if (!hasPhpFunctionDefinition(nextSource, enqueueFunctionName)) {
4995
- insertPhpSnippet(enqueueFunction);
5002
+ nextSource = insertPhpSnippetBeforeWorkspaceAnchors(nextSource, enqueueFunction);
4996
5003
  } else if (!findPhpFunctionRange(nextSource, enqueueFunctionName)?.source.includes("wp_enqueue_script_module")) {
4997
5004
  nextSource = replacePhpFunctionDefinition(nextSource, enqueueFunctionName, enqueueFunction, { trimReplacementStart: true }) ?? nextSource;
4998
5005
  }
4999
5006
  if (!nextSource.includes(loadHook)) {
5000
- appendPhpSnippet(loadHook);
5007
+ nextSource = appendPhpSnippetBeforeClosingTag(nextSource, loadHook);
5001
5008
  }
5002
5009
  if (!nextSource.includes(adminEnqueueHook)) {
5003
- appendPhpSnippet(adminEnqueueHook);
5010
+ nextSource = appendPhpSnippetBeforeClosingTag(nextSource, adminEnqueueHook);
5004
5011
  }
5005
5012
  if (!nextSource.includes(editorEnqueueHook)) {
5006
- appendPhpSnippet(editorEnqueueHook);
5013
+ nextSource = appendPhpSnippetBeforeClosingTag(nextSource, editorEnqueueHook);
5007
5014
  }
5008
5015
  return nextSource;
5009
5016
  });
@@ -5179,8 +5186,8 @@ async function scaffoldAbilityWorkspace({
5179
5186
  const dataFilePath = path10.join(abilityDir, "data.ts");
5180
5187
  const clientFilePath = path10.join(abilityDir, "client.ts");
5181
5188
  const phpFilePath = path10.join(workspace.projectDir, "inc", "abilities", `${abilitySlug}.php`);
5182
- const mutationSnapshot = {
5183
- fileSources: await snapshotWorkspaceFiles([
5189
+ await executeWorkspaceMutationPlan({
5190
+ filePaths: [
5184
5191
  blockConfigPath,
5185
5192
  bootstrapPath,
5186
5193
  buildScriptPath,
@@ -5189,48 +5196,44 @@ async function scaffoldAbilityWorkspace({
5189
5196
  syncProjectScriptPath,
5190
5197
  webpackConfigPath,
5191
5198
  abilitiesIndexPath
5192
- ]),
5193
- snapshotDirs: [],
5194
- targetPaths: [abilityDir, phpFilePath, syncAbilitiesScriptPath]
5195
- };
5196
- try {
5197
- await fsp6.mkdir(abilityDir, { recursive: true });
5198
- await fsp6.mkdir(path10.dirname(phpFilePath), { recursive: true });
5199
- await ensureAbilityBootstrapAnchors(workspace);
5200
- await patchFile(bootstrapPath, (source) => updatePluginHeaderCompatibility(source, compatibilityPolicy));
5201
- await ensureAbilityPackageScripts(workspace);
5202
- await ensureAbilitySyncProjectAnchors(workspace);
5203
- await ensureAbilityBuildScriptAnchors(workspace);
5204
- await ensureAbilityWebpackAnchors(workspace);
5205
- await fsp6.writeFile(syncAbilitiesScriptPath, buildAbilitySyncScriptSource(), "utf8");
5206
- await fsp6.writeFile(configFilePath, buildAbilityConfigSource(abilitySlug, workspace.workspace.namespace), "utf8");
5207
- await fsp6.writeFile(typesFilePath, buildAbilityTypesSource(abilitySlug), "utf8");
5208
- await fsp6.writeFile(dataFilePath, buildAbilityDataSource(abilitySlug), "utf8");
5209
- await fsp6.writeFile(clientFilePath, buildAbilityClientSource(abilitySlug), "utf8");
5210
- await fsp6.writeFile(phpFilePath, buildAbilityPhpSource(abilitySlug, workspace), "utf8");
5211
- const pascalCase = toPascalCase(abilitySlug);
5212
- await syncTypeSchemas2({
5213
- jsonSchemaFile: `src/abilities/${abilitySlug}/input.schema.json`,
5214
- projectRoot: workspace.projectDir,
5215
- sourceTypeName: `${pascalCase}AbilityInput`,
5216
- typesFile: `src/abilities/${abilitySlug}/types.ts`
5217
- });
5218
- await syncTypeSchemas2({
5219
- jsonSchemaFile: `src/abilities/${abilitySlug}/output.schema.json`,
5220
- projectRoot: workspace.projectDir,
5221
- sourceTypeName: `${pascalCase}AbilityOutput`,
5222
- typesFile: `src/abilities/${abilitySlug}/types.ts`
5223
- });
5224
- await writeAbilityRegistry(workspace.projectDir, abilitySlug);
5225
- await appendWorkspaceInventoryEntries(workspace.projectDir, {
5226
- abilityEntries: [
5227
- buildAbilityConfigEntry(abilitySlug, compatibilityPolicy)
5228
- ]
5229
- });
5230
- } catch (error) {
5231
- await rollbackWorkspaceMutation(mutationSnapshot);
5232
- throw error;
5233
- }
5199
+ ],
5200
+ targetPaths: [abilityDir, phpFilePath, syncAbilitiesScriptPath],
5201
+ run: async () => {
5202
+ await fsp6.mkdir(abilityDir, { recursive: true });
5203
+ await fsp6.mkdir(path10.dirname(phpFilePath), { recursive: true });
5204
+ await ensureAbilityBootstrapAnchors(workspace);
5205
+ await patchFile(bootstrapPath, (source) => updatePluginHeaderCompatibility(source, compatibilityPolicy));
5206
+ await ensureAbilityPackageScripts(workspace);
5207
+ await ensureAbilitySyncProjectAnchors(workspace);
5208
+ await ensureAbilityBuildScriptAnchors(workspace);
5209
+ await ensureAbilityWebpackAnchors(workspace);
5210
+ await fsp6.writeFile(syncAbilitiesScriptPath, buildAbilitySyncScriptSource(), "utf8");
5211
+ await fsp6.writeFile(configFilePath, buildAbilityConfigSource(abilitySlug, workspace.workspace.namespace), "utf8");
5212
+ await fsp6.writeFile(typesFilePath, buildAbilityTypesSource(abilitySlug), "utf8");
5213
+ await fsp6.writeFile(dataFilePath, buildAbilityDataSource(abilitySlug), "utf8");
5214
+ await fsp6.writeFile(clientFilePath, buildAbilityClientSource(abilitySlug), "utf8");
5215
+ await fsp6.writeFile(phpFilePath, buildAbilityPhpSource(abilitySlug, workspace), "utf8");
5216
+ const pascalCase = toPascalCase(abilitySlug);
5217
+ await syncTypeSchemas2({
5218
+ jsonSchemaFile: `src/abilities/${abilitySlug}/input.schema.json`,
5219
+ projectRoot: workspace.projectDir,
5220
+ sourceTypeName: `${pascalCase}AbilityInput`,
5221
+ typesFile: `src/abilities/${abilitySlug}/types.ts`
5222
+ });
5223
+ await syncTypeSchemas2({
5224
+ jsonSchemaFile: `src/abilities/${abilitySlug}/output.schema.json`,
5225
+ projectRoot: workspace.projectDir,
5226
+ sourceTypeName: `${pascalCase}AbilityOutput`,
5227
+ typesFile: `src/abilities/${abilitySlug}/types.ts`
5228
+ });
5229
+ await writeAbilityRegistry(workspace.projectDir, abilitySlug);
5230
+ await appendWorkspaceInventoryEntries(workspace.projectDir, {
5231
+ abilityEntries: [
5232
+ buildAbilityConfigEntry(abilitySlug, compatibilityPolicy)
5233
+ ]
5234
+ });
5235
+ }
5236
+ });
5234
5237
  }
5235
5238
 
5236
5239
  // ../wp-typia-project-tools/src/runtime/cli-add-workspace-ability.ts
@@ -6151,6 +6154,8 @@ if ( ! defined( 'ABSPATH' ) ) {
6151
6154
  * - ${quotePhpString(adminNoticeMessageFilterHook)} filters the wp-admin notice shown when AI support is unavailable.
6152
6155
  * - ${quotePhpString(unavailableMessageFilterHook)} filters REST-facing unavailable messages by reason code.
6153
6156
  * - ${quotePhpString(telemetryFilterHook)} filters the response telemetry array before schema validation. Return a schema-compatible array.
6157
+ *
6158
+ * Compatibility note: this server-only endpoint avoids WordPress script-module enqueue APIs so older sites can load the generated feature file safely.
6154
6159
  */
6155
6160
 
6156
6161
  if ( ! function_exists( '${loadSchemaFunctionName}' ) ) {
@@ -6731,66 +6736,62 @@ async function scaffoldAiFeatureWorkspace({
6731
6736
  const apiFilePath = path13.join(aiFeatureDir, "api.ts");
6732
6737
  const dataFilePath = path13.join(aiFeatureDir, "data.ts");
6733
6738
  const phpFilePath = path13.join(workspace.projectDir, "inc", "ai-features", `${aiFeatureSlug}.php`);
6734
- const mutationSnapshot = {
6735
- fileSources: await snapshotWorkspaceFiles([
6739
+ return executeWorkspaceMutationPlan({
6740
+ filePaths: [
6736
6741
  blockConfigPath,
6737
6742
  bootstrapPath,
6738
6743
  packageJsonPath,
6739
6744
  syncAiScriptPath,
6740
6745
  syncProjectScriptPath,
6741
6746
  syncRestScriptPath
6742
- ]),
6743
- snapshotDirs: [],
6744
- targetPaths: [aiFeatureDir, phpFilePath, syncAiScriptPath]
6745
- };
6746
- try {
6747
- await fsp8.mkdir(aiFeatureDir, { recursive: true });
6748
- await fsp8.mkdir(path13.dirname(phpFilePath), { recursive: true });
6749
- await ensureAiFeatureBootstrapAnchors(workspace);
6750
- await patchFile(bootstrapPath, (source) => updatePluginHeaderCompatibility(source, compatibilityPolicy));
6751
- const packageScriptChanges = await ensureAiFeaturePackageScripts(workspace);
6752
- await ensureAiFeatureSyncProjectAnchors(workspace);
6753
- await ensureAiFeatureSyncRestAnchors(workspace);
6754
- await fsp8.writeFile(syncAiScriptPath, buildAiFeatureSyncScriptSource(), "utf8");
6755
- await fsp8.writeFile(typesFilePath, buildAiFeatureTypesSource(aiFeatureSlug), "utf8");
6756
- await fsp8.writeFile(validatorsFilePath, buildAiFeatureValidatorsSource(aiFeatureSlug), "utf8");
6757
- await fsp8.writeFile(apiFilePath, buildAiFeatureApiSource(aiFeatureSlug), "utf8");
6758
- await fsp8.writeFile(dataFilePath, buildAiFeatureDataSource(aiFeatureSlug), "utf8");
6759
- await fsp8.writeFile(phpFilePath, buildAiFeaturePhpSource(aiFeatureSlug, namespace, workspace.workspace.phpPrefix, workspace.workspace.textDomain), "utf8");
6760
- const pascalCase = toPascalCase(aiFeatureSlug);
6761
- await syncAiFeatureRestArtifacts({
6762
- clientFile: `src/ai-features/${aiFeatureSlug}/api-client.ts`,
6763
- outputDir: path13.join("src", "ai-features", aiFeatureSlug),
6764
- projectDir: workspace.projectDir,
6765
- typesFile: `src/ai-features/${aiFeatureSlug}/api-types.ts`,
6766
- validatorsFile: `src/ai-features/${aiFeatureSlug}/api-validators.ts`,
6767
- variables: {
6768
- namespace,
6769
- pascalCase,
6770
- slugKebabCase: aiFeatureSlug,
6771
- title: toTitleCase(aiFeatureSlug)
6772
- }
6773
- });
6774
- await syncAiFeatureSchemaArtifact({
6775
- aiSchemaFile: `src/ai-features/${aiFeatureSlug}/ai-schemas/feature-result.ai.schema.json`,
6776
- outputDir: path13.join("src", "ai-features", aiFeatureSlug),
6777
- projectDir: workspace.projectDir
6778
- });
6779
- await appendWorkspaceInventoryEntries(workspace.projectDir, {
6780
- aiFeatureEntries: [
6781
- buildAiFeatureConfigEntry(aiFeatureSlug, namespace)
6782
- ],
6783
- transformSource: ensureBlockConfigCanAddRestManifests
6784
- });
6785
- return {
6786
- warnings: packageScriptChanges.addedProjectToolsDependency ? [
6787
- "Added `@wp-typia/project-tools` to devDependencies for `sync-ai`. If this workspace was already installed, rerun your package manager install command before the first `wp-typia sync ai`."
6788
- ] : []
6789
- };
6790
- } catch (error) {
6791
- await rollbackWorkspaceMutation(mutationSnapshot);
6792
- throw error;
6793
- }
6747
+ ],
6748
+ targetPaths: [aiFeatureDir, phpFilePath, syncAiScriptPath],
6749
+ run: async () => {
6750
+ await fsp8.mkdir(aiFeatureDir, { recursive: true });
6751
+ await fsp8.mkdir(path13.dirname(phpFilePath), { recursive: true });
6752
+ await ensureAiFeatureBootstrapAnchors(workspace);
6753
+ await patchFile(bootstrapPath, (source) => updatePluginHeaderCompatibility(source, compatibilityPolicy));
6754
+ const packageScriptChanges = await ensureAiFeaturePackageScripts(workspace);
6755
+ await ensureAiFeatureSyncProjectAnchors(workspace);
6756
+ await ensureAiFeatureSyncRestAnchors(workspace);
6757
+ await fsp8.writeFile(syncAiScriptPath, buildAiFeatureSyncScriptSource(), "utf8");
6758
+ await fsp8.writeFile(typesFilePath, buildAiFeatureTypesSource(aiFeatureSlug), "utf8");
6759
+ await fsp8.writeFile(validatorsFilePath, buildAiFeatureValidatorsSource(aiFeatureSlug), "utf8");
6760
+ await fsp8.writeFile(apiFilePath, buildAiFeatureApiSource(aiFeatureSlug), "utf8");
6761
+ await fsp8.writeFile(dataFilePath, buildAiFeatureDataSource(aiFeatureSlug), "utf8");
6762
+ await fsp8.writeFile(phpFilePath, buildAiFeaturePhpSource(aiFeatureSlug, namespace, workspace.workspace.phpPrefix, workspace.workspace.textDomain), "utf8");
6763
+ const pascalCase = toPascalCase(aiFeatureSlug);
6764
+ await syncAiFeatureRestArtifacts({
6765
+ clientFile: `src/ai-features/${aiFeatureSlug}/api-client.ts`,
6766
+ outputDir: path13.join("src", "ai-features", aiFeatureSlug),
6767
+ projectDir: workspace.projectDir,
6768
+ typesFile: `src/ai-features/${aiFeatureSlug}/api-types.ts`,
6769
+ validatorsFile: `src/ai-features/${aiFeatureSlug}/api-validators.ts`,
6770
+ variables: {
6771
+ namespace,
6772
+ pascalCase,
6773
+ slugKebabCase: aiFeatureSlug,
6774
+ title: toTitleCase(aiFeatureSlug)
6775
+ }
6776
+ });
6777
+ await syncAiFeatureSchemaArtifact({
6778
+ aiSchemaFile: `src/ai-features/${aiFeatureSlug}/ai-schemas/feature-result.ai.schema.json`,
6779
+ outputDir: path13.join("src", "ai-features", aiFeatureSlug),
6780
+ projectDir: workspace.projectDir
6781
+ });
6782
+ await appendWorkspaceInventoryEntries(workspace.projectDir, {
6783
+ aiFeatureEntries: [
6784
+ buildAiFeatureConfigEntry(aiFeatureSlug, namespace)
6785
+ ],
6786
+ transformSource: ensureBlockConfigCanAddRestManifests
6787
+ });
6788
+ return {
6789
+ warnings: packageScriptChanges.addedProjectToolsDependency ? [
6790
+ "Added `@wp-typia/project-tools` to devDependencies for `sync-ai`. If this workspace was already installed, rerun your package manager install command before the first `wp-typia sync ai`."
6791
+ ] : []
6792
+ };
6793
+ }
6794
+ });
6794
6795
  }
6795
6796
 
6796
6797
  // ../wp-typia-project-tools/src/runtime/cli-add-workspace-ai.ts
@@ -6834,80 +6835,6 @@ var BLOCK_TRANSFORMS_CALL_LINE = "applyWorkspaceBlockTransforms(registration.set
6834
6835
  var BLOCK_TRANSFORMS_CALL_PATTERN = /applyWorkspaceBlockTransforms\s*\(\s*registration\s*\.\s*settings\s*\)\s*;?/u;
6835
6836
  var SCAFFOLD_REGISTRATION_SETTINGS_CALL_PATTERN = /registerScaffoldBlockType\s*\(\s*registration\s*\.\s*name\s*,\s*registration\s*\.\s*settings\s*\)\s*;?/u;
6836
6837
  var FULL_BLOCK_NAME_PATTERN = /^[a-z0-9-]+\/[a-z0-9-]+$/u;
6837
- function maskSourceSegment(segment) {
6838
- return segment.replace(/[^\n\r]/gu, " ");
6839
- }
6840
- function maskTypeScriptComments(source) {
6841
- return source.replace(/\/\*[\s\S]*?\*\//gu, maskSourceSegment).replace(/\/\/[^\n\r]*/gu, maskSourceSegment);
6842
- }
6843
- function maskTypeScriptCommentsAndLiterals(source) {
6844
- let maskedSource = "";
6845
- let index = 0;
6846
- while (index < source.length) {
6847
- const current = source[index];
6848
- const next = source[index + 1];
6849
- if (current === "/" && next === "/") {
6850
- const start = index;
6851
- index += 2;
6852
- while (index < source.length && source[index] !== `
6853
- ` && source[index] !== "\r") {
6854
- index += 1;
6855
- }
6856
- maskedSource += maskSourceSegment(source.slice(start, index));
6857
- continue;
6858
- }
6859
- if (current === "/" && next === "*") {
6860
- const start = index;
6861
- index += 2;
6862
- while (index < source.length && !(source[index] === "*" && source[index + 1] === "/")) {
6863
- index += 1;
6864
- }
6865
- index = Math.min(index + 2, source.length);
6866
- maskedSource += maskSourceSegment(source.slice(start, index));
6867
- continue;
6868
- }
6869
- if (current === "'" || current === '"' || current === "`") {
6870
- const start = index;
6871
- const quote = current;
6872
- index += 1;
6873
- while (index < source.length) {
6874
- const char = source[index];
6875
- if (char === "\\") {
6876
- index += 2;
6877
- continue;
6878
- }
6879
- index += 1;
6880
- if (char === quote) {
6881
- break;
6882
- }
6883
- }
6884
- maskedSource += maskSourceSegment(source.slice(start, index));
6885
- continue;
6886
- }
6887
- maskedSource += current;
6888
- index += 1;
6889
- }
6890
- return maskedSource;
6891
- }
6892
- function hasExecutablePattern(source, pattern) {
6893
- return pattern.test(maskTypeScriptCommentsAndLiterals(source));
6894
- }
6895
- function hasUncommentedPattern(source, pattern) {
6896
- return pattern.test(maskTypeScriptComments(source));
6897
- }
6898
- function findExecutablePatternMatch(source, patterns) {
6899
- const maskedSource = maskTypeScriptCommentsAndLiterals(source);
6900
- for (const pattern of patterns) {
6901
- const match = pattern.exec(maskedSource);
6902
- if (match && match.index !== undefined) {
6903
- return {
6904
- end: match.index + match[0].length,
6905
- start: match.index
6906
- };
6907
- }
6908
- }
6909
- return;
6910
- }
6911
6838
  function isIdentifierBoundary(source, index) {
6912
6839
  if (index < 0 || index >= source.length) {
6913
6840
  return true;
@@ -7540,6 +7467,7 @@ export {
7540
7467
  runAddAiFeatureCommand,
7541
7468
  runAddAdminViewCommand,
7542
7469
  runAddAbilityCommand,
7470
+ isAddBlockTemplateId,
7543
7471
  getWorkspaceBlockSelectOptions,
7544
7472
  formatAddHelpText,
7545
7473
  EDITOR_PLUGIN_SLOT_IDS,
@@ -7547,4 +7475,4 @@ export {
7547
7475
  ADD_BLOCK_TEMPLATE_IDS
7548
7476
  };
7549
7477
 
7550
- //# debugId=272EBA8B7C96349F64756E2164756E21
7478
+ //# debugId=851894DA0B69BA4964756E2164756E21
@@ -1,4 +1,8 @@
1
1
  // @bun
2
+ import {
3
+ parsePackageManagerField
4
+ } from "./cli-6bhfzq5e.js";
5
+
2
6
  // ../wp-typia-project-tools/src/runtime/workspace-project.ts
3
7
  import fs from "fs";
4
8
  import path from "path";
@@ -56,16 +60,7 @@ function getInvalidWorkspaceProjectReason(startDir) {
56
60
  return null;
57
61
  }
58
62
  function parseWorkspacePackageManagerId(packageManagerField) {
59
- const packageManagerId = packageManagerField?.split("@", 1)[0];
60
- switch (packageManagerId) {
61
- case "bun":
62
- case "npm":
63
- case "pnpm":
64
- case "yarn":
65
- return packageManagerId;
66
- default:
67
- return "npm";
68
- }
63
+ return parsePackageManagerField(packageManagerField) ?? "npm";
69
64
  }
70
65
  function tryResolveWorkspaceProject(startDir) {
71
66
  let currentDir = path.resolve(startDir);
@@ -107,4 +102,4 @@ function resolveWorkspaceProject(startDir) {
107
102
 
108
103
  export { WORKSPACE_TEMPLATE_PACKAGE, parseWorkspacePackageJson, getInvalidWorkspaceProjectReason, parseWorkspacePackageManagerId, tryResolveWorkspaceProject, resolveWorkspaceProject };
109
104
 
110
- //# debugId=399A269701638C0F64756E2164756E21
105
+ //# debugId=79A99E0E108D7B5E64756E2164756E21