wp-typia 0.22.2 → 0.22.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/wp-typia.js +15 -1
- package/dist-bunli/.bunli/commands.gen.js +981 -760
- package/dist-bunli/{cli-add-s0p4w1wz.js → cli-add-p3re8act.js} +134 -94
- package/dist-bunli/{cli-doctor-6dchxz12.js → cli-doctor-cjm4rzbk.js} +463 -412
- package/dist-bunli/{cli-init-r6h1xchq.js → cli-init-7gcthyn1.js} +1 -1
- package/dist-bunli/{cli-n6hgvysz.js → cli-mpgt29xc.js} +3 -3
- package/dist-bunli/{cli-6hcbjvym.js → cli-prc42zqd.js} +1 -1
- package/dist-bunli/{cli-scaffold-f023yxc5.js → cli-scaffold-x1dp8sz1.js} +3 -3
- package/dist-bunli/{cli-kww2sraq.js → cli-tbd9x8b6.js} +7 -5
- package/dist-bunli/{cli-smzkbfna.js → cli-x0h03qqe.js} +172 -73
- package/dist-bunli/cli.js +2 -2
- package/dist-bunli/{command-list-d3dcvzg2.js → command-list-wzej5c7v.js} +84 -92
- package/dist-bunli/{migrations-pg5b9fh4.js → migrations-xfb2h7nf.js} +2 -2
- package/dist-bunli/node-cli.js +120 -119
- package/package.json +2 -2
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
scaffoldProject,
|
|
22
22
|
syncPersistenceRestArtifacts,
|
|
23
23
|
updatePluginHeaderCompatibility
|
|
24
|
-
} from "./cli-
|
|
24
|
+
} from "./cli-tbd9x8b6.js";
|
|
25
25
|
import {
|
|
26
26
|
DEFAULT_WORDPRESS_ABILITIES_VERSION,
|
|
27
27
|
DEFAULT_WORDPRESS_CORE_ABILITIES_VERSION,
|
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
} from "./cli-1sm60g1z.js";
|
|
35
35
|
import {
|
|
36
36
|
snapshotProjectVersion
|
|
37
|
-
} from "./cli-
|
|
37
|
+
} from "./cli-prc42zqd.js";
|
|
38
38
|
import {
|
|
39
39
|
ensureMigrationDirectories,
|
|
40
40
|
parseMigrationConfig,
|
|
@@ -58,6 +58,8 @@ import {
|
|
|
58
58
|
assertAdminViewDoesNotExist,
|
|
59
59
|
assertAiFeatureDoesNotExist,
|
|
60
60
|
assertBindingSourceDoesNotExist,
|
|
61
|
+
assertBlockStyleDoesNotExist,
|
|
62
|
+
assertBlockTransformDoesNotExist,
|
|
61
63
|
assertEditorPluginDoesNotExist,
|
|
62
64
|
assertPatternDoesNotExist,
|
|
63
65
|
assertRestResourceDoesNotExist,
|
|
@@ -95,7 +97,7 @@ import {
|
|
|
95
97
|
toPascalCase,
|
|
96
98
|
toSnakeCase,
|
|
97
99
|
toTitleCase
|
|
98
|
-
} from "./cli-
|
|
100
|
+
} from "./cli-x0h03qqe.js";
|
|
99
101
|
import {
|
|
100
102
|
createManagedTempRoot
|
|
101
103
|
} from "./cli-t73q5aqz.js";
|
|
@@ -2377,8 +2379,10 @@ registerBlockBindingsSource( {
|
|
|
2377
2379
|
`;
|
|
2378
2380
|
}
|
|
2379
2381
|
function resolveBindingTarget(options, namespace) {
|
|
2380
|
-
const
|
|
2381
|
-
const
|
|
2382
|
+
const blockName = normalizeOptionalCliString(options.blockName);
|
|
2383
|
+
const attributeName = normalizeOptionalCliString(options.attributeName);
|
|
2384
|
+
const hasBlock = blockName !== undefined;
|
|
2385
|
+
const hasAttribute = attributeName !== undefined;
|
|
2382
2386
|
if (!hasBlock && !hasAttribute) {
|
|
2383
2387
|
return;
|
|
2384
2388
|
}
|
|
@@ -2386,8 +2390,8 @@ function resolveBindingTarget(options, namespace) {
|
|
|
2386
2390
|
throw new Error("`wp-typia add binding-source` requires --block and --attribute to be provided together.");
|
|
2387
2391
|
}
|
|
2388
2392
|
return {
|
|
2389
|
-
attributeName: assertValidBindingAttributeName(
|
|
2390
|
-
blockSlug: resolveBindingTargetBlockSlug(
|
|
2393
|
+
attributeName: assertValidBindingAttributeName(attributeName ?? ""),
|
|
2394
|
+
blockSlug: resolveBindingTargetBlockSlug(blockName ?? "", namespace)
|
|
2391
2395
|
};
|
|
2392
2396
|
}
|
|
2393
2397
|
function formatBindingAttributeTypeMember(attributeName) {
|
|
@@ -4367,12 +4371,14 @@ async function runAddRestResourceCommand({
|
|
|
4367
4371
|
throw error;
|
|
4368
4372
|
}
|
|
4369
4373
|
}
|
|
4370
|
-
// ../wp-typia-project-tools/src/runtime/cli-add-workspace-ability.ts
|
|
4374
|
+
// ../wp-typia-project-tools/src/runtime/cli-add-workspace-ability-scaffold.ts
|
|
4371
4375
|
var import_semver = __toESM(require_semver(), 1);
|
|
4372
4376
|
import fs5 from "fs";
|
|
4373
4377
|
import { promises as fsp6 } from "fs";
|
|
4374
4378
|
import path10 from "path";
|
|
4375
4379
|
import { syncTypeSchemas as syncTypeSchemas2 } from "@wp-typia/block-runtime/metadata-core";
|
|
4380
|
+
|
|
4381
|
+
// ../wp-typia-project-tools/src/runtime/cli-add-workspace-ability-types.ts
|
|
4376
4382
|
var ABILITY_SERVER_GLOB = "/inc/abilities/*.php";
|
|
4377
4383
|
var ABILITY_EDITOR_SCRIPT = "build/abilities/index.js";
|
|
4378
4384
|
var ABILITY_EDITOR_ASSET = "build/abilities/index.asset.php";
|
|
@@ -4380,17 +4386,8 @@ var ABILITY_REGISTRY_END_MARKER = "// wp-typia add ability entries end";
|
|
|
4380
4386
|
var ABILITY_REGISTRY_START_MARKER = "// wp-typia add ability entries start";
|
|
4381
4387
|
var WP_ABILITIES_SCRIPT_MODULE_ID = "@wordpress/abilities";
|
|
4382
4388
|
var WP_CORE_ABILITIES_SCRIPT_MODULE_ID = "@wordpress/core-abilities";
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
return requiredVersion;
|
|
4386
|
-
}
|
|
4387
|
-
const existingMinimum = import_semver.default.minVersion(existingVersion);
|
|
4388
|
-
const requiredMinimum = import_semver.default.minVersion(requiredVersion);
|
|
4389
|
-
if (!existingMinimum || !requiredMinimum) {
|
|
4390
|
-
return requiredVersion;
|
|
4391
|
-
}
|
|
4392
|
-
return import_semver.default.gte(existingMinimum, requiredMinimum) ? existingVersion : requiredVersion;
|
|
4393
|
-
}
|
|
4389
|
+
|
|
4390
|
+
// ../wp-typia-project-tools/src/runtime/cli-add-workspace-ability-templates.ts
|
|
4394
4391
|
function toAbilityCategorySlug(workspaceNamespace) {
|
|
4395
4392
|
const normalizedNamespace = workspaceNamespace.replace(/[^a-z0-9-]+/gu, "-").replace(/-{2,}/gu, "-").replace(/^-|-$/gu, "");
|
|
4396
4393
|
return `${normalizedNamespace || "workspace"}-workflows`;
|
|
@@ -4855,6 +4852,19 @@ function buildAbilityRegistrySource(abilitySlugs) {
|
|
|
4855
4852
|
`).concat(`
|
|
4856
4853
|
`);
|
|
4857
4854
|
}
|
|
4855
|
+
|
|
4856
|
+
// ../wp-typia-project-tools/src/runtime/cli-add-workspace-ability-scaffold.ts
|
|
4857
|
+
function resolveManagedDependencyVersion(existingVersion, requiredVersion) {
|
|
4858
|
+
if (!existingVersion) {
|
|
4859
|
+
return requiredVersion;
|
|
4860
|
+
}
|
|
4861
|
+
const existingMinimum = import_semver.default.minVersion(existingVersion);
|
|
4862
|
+
const requiredMinimum = import_semver.default.minVersion(requiredVersion);
|
|
4863
|
+
if (!existingMinimum || !requiredMinimum) {
|
|
4864
|
+
return requiredVersion;
|
|
4865
|
+
}
|
|
4866
|
+
return import_semver.default.gte(existingMinimum, requiredMinimum) ? existingVersion : requiredVersion;
|
|
4867
|
+
}
|
|
4858
4868
|
function resolveAbilityRegistryPath(projectDir) {
|
|
4859
4869
|
const abilitiesDir = path10.join(projectDir, "src", "abilities");
|
|
4860
4870
|
return [path10.join(abilitiesDir, "index.ts"), path10.join(abilitiesDir, "index.js")].find((candidatePath) => fs5.existsSync(candidatePath)) ?? path10.join(abilitiesDir, "index.ts");
|
|
@@ -5066,21 +5076,29 @@ async function ensureAbilityBuildScriptAnchors(workspace) {
|
|
|
5066
5076
|
}
|
|
5067
5077
|
const sharedEntriesPattern = /(for\s*\(\s*const\s+relativePath\s+of\s+\[)([\s\S]*?)(\]\s*\)\s*\{)/u;
|
|
5068
5078
|
const match = nextSource.match(sharedEntriesPattern);
|
|
5069
|
-
if (!match ||
|
|
5079
|
+
if (!match || !/['"]src\/bindings\/index\.(?:ts|js)['"]/u.test(match[2]) || !/['"]src\/editor-plugins\/index\.(?:tsx|ts|js)['"]/u.test(match[2])) {
|
|
5070
5080
|
throw new Error([
|
|
5071
5081
|
`ensureAbilityBuildScriptAnchors could not patch ${path10.basename(buildScriptPath)}.`,
|
|
5072
5082
|
"Missing the expected shared editor entries array in scripts/build-workspace.mjs.",
|
|
5073
5083
|
"Restore the generated template or wire abilities/index manually before retrying."
|
|
5074
5084
|
].join(" "));
|
|
5075
5085
|
}
|
|
5076
|
-
nextSource = nextSource.replace(sharedEntriesPattern,
|
|
5077
|
-
|
|
5078
|
-
|
|
5079
|
-
|
|
5080
|
-
|
|
5081
|
-
|
|
5082
|
-
|
|
5083
|
-
|
|
5086
|
+
nextSource = nextSource.replace(sharedEntriesPattern, (fullMatch, sharedEntries) => {
|
|
5087
|
+
const missingAbilityEntries = [
|
|
5088
|
+
"'src/abilities/index.ts'",
|
|
5089
|
+
"'src/abilities/index.js'"
|
|
5090
|
+
].filter((entry) => !sharedEntries.includes(entry));
|
|
5091
|
+
if (missingAbilityEntries.length === 0) {
|
|
5092
|
+
return fullMatch;
|
|
5093
|
+
}
|
|
5094
|
+
const itemIndent = sharedEntries.match(/\n([ \t]*)['"]/u)?.[1] ?? "\t\t";
|
|
5095
|
+
const trimmedEntries = sharedEntries.replace(/\s*$/u, "");
|
|
5096
|
+
const trailingWhitespace = sharedEntries.slice(trimmedEntries.length);
|
|
5097
|
+
const separator = trimmedEntries.trimEnd().endsWith(",") ? "" : ",";
|
|
5098
|
+
const nextEntries = `${trimmedEntries}${separator}` + missingAbilityEntries.map((entry) => `
|
|
5099
|
+
${itemIndent}${entry},`).join("") + trailingWhitespace;
|
|
5100
|
+
return fullMatch.replace(sharedEntries, nextEntries);
|
|
5101
|
+
});
|
|
5084
5102
|
return nextSource;
|
|
5085
5103
|
});
|
|
5086
5104
|
}
|
|
@@ -5109,8 +5127,7 @@ async function ensureAbilityWebpackAnchors(workspace) {
|
|
|
5109
5127
|
entries.push( [ entryName, entryPath ] );
|
|
5110
5128
|
break;
|
|
5111
5129
|
}
|
|
5112
|
-
}
|
|
5113
|
-
$2`);
|
|
5130
|
+
}$2`);
|
|
5114
5131
|
}
|
|
5115
5132
|
const sharedEntriesPattern = /for\s*\(\s*const\s+\[\s*entryName\s*,\s*candidates\s*\]\s+of\s+\[([\s\S]*?)\]\s*\)\s*\{/u;
|
|
5116
5133
|
const match = source.match(sharedEntriesPattern);
|
|
@@ -5121,31 +5138,33 @@ $2`);
|
|
|
5121
5138
|
"Restore the generated template or wire abilities/index manually before retrying."
|
|
5122
5139
|
].join(" "));
|
|
5123
5140
|
}
|
|
5124
|
-
return source.replace(sharedEntriesPattern,
|
|
5125
|
-
|
|
5126
|
-
|
|
5127
|
-
|
|
5128
|
-
|
|
5129
|
-
|
|
5130
|
-
|
|
5131
|
-
|
|
5132
|
-
|
|
5133
|
-
|
|
5134
|
-
|
|
5135
|
-
|
|
5136
|
-
|
|
5137
|
-
|
|
5141
|
+
return source.replace(sharedEntriesPattern, (fullMatch, sharedEntries) => {
|
|
5142
|
+
if (/['"]abilities\/index['"]/u.test(sharedEntries)) {
|
|
5143
|
+
return fullMatch;
|
|
5144
|
+
}
|
|
5145
|
+
const tupleIndent = sharedEntries.match(/\n([ \t]*)\[/u)?.[1] ?? "\t\t";
|
|
5146
|
+
const nestedIndent = `${tupleIndent} `;
|
|
5147
|
+
const trimmedEntries = sharedEntries.replace(/\s*$/u, "");
|
|
5148
|
+
const trailingWhitespace = sharedEntries.slice(trimmedEntries.length);
|
|
5149
|
+
const separator = trimmedEntries.trimEnd().endsWith(",") ? "" : ",";
|
|
5150
|
+
const abilityTuple = [
|
|
5151
|
+
`${tupleIndent}[`,
|
|
5152
|
+
`${nestedIndent}'abilities/index',`,
|
|
5153
|
+
`${nestedIndent}[ 'src/abilities/index.ts', 'src/abilities/index.js' ],`,
|
|
5154
|
+
`${tupleIndent}],`
|
|
5155
|
+
].join(`
|
|
5156
|
+
`);
|
|
5157
|
+
const nextEntries = `${trimmedEntries}${separator}
|
|
5158
|
+
${abilityTuple}` + trailingWhitespace;
|
|
5159
|
+
return fullMatch.replace(sharedEntries, nextEntries);
|
|
5160
|
+
});
|
|
5138
5161
|
});
|
|
5139
5162
|
}
|
|
5140
|
-
async function
|
|
5141
|
-
|
|
5142
|
-
|
|
5163
|
+
async function scaffoldAbilityWorkspace({
|
|
5164
|
+
abilitySlug,
|
|
5165
|
+
compatibilityPolicy,
|
|
5166
|
+
workspace
|
|
5143
5167
|
}) {
|
|
5144
|
-
const workspace = resolveWorkspaceProject(cwd);
|
|
5145
|
-
const abilitySlug = assertValidGeneratedSlug("Ability name", normalizeBlockSlug(abilityName), "wp-typia add ability <name>");
|
|
5146
|
-
const inventory = readWorkspaceInventory(workspace.projectDir);
|
|
5147
|
-
assertAbilityDoesNotExist(workspace.projectDir, abilitySlug, inventory);
|
|
5148
|
-
const compatibilityPolicy = resolveScaffoldCompatibilityPolicy(REQUIRED_WORKSPACE_ABILITY_COMPATIBILITY);
|
|
5149
5168
|
const blockConfigPath = path10.join(workspace.projectDir, "scripts", "block-config.ts");
|
|
5150
5169
|
const bootstrapPath = getWorkspaceBootstrapPath(workspace);
|
|
5151
5170
|
const buildScriptPath = path10.join(workspace.projectDir, "scripts", "build-workspace.mjs");
|
|
@@ -5204,18 +5223,37 @@ async function runAddAbilityCommand({
|
|
|
5204
5223
|
});
|
|
5205
5224
|
await writeAbilityRegistry(workspace.projectDir, abilitySlug);
|
|
5206
5225
|
await appendWorkspaceInventoryEntries(workspace.projectDir, {
|
|
5207
|
-
abilityEntries: [
|
|
5226
|
+
abilityEntries: [
|
|
5227
|
+
buildAbilityConfigEntry(abilitySlug, compatibilityPolicy)
|
|
5228
|
+
]
|
|
5208
5229
|
});
|
|
5209
|
-
return {
|
|
5210
|
-
abilitySlug,
|
|
5211
|
-
projectDir: workspace.projectDir
|
|
5212
|
-
};
|
|
5213
5230
|
} catch (error) {
|
|
5214
5231
|
await rollbackWorkspaceMutation(mutationSnapshot);
|
|
5215
5232
|
throw error;
|
|
5216
5233
|
}
|
|
5217
5234
|
}
|
|
5218
|
-
|
|
5235
|
+
|
|
5236
|
+
// ../wp-typia-project-tools/src/runtime/cli-add-workspace-ability.ts
|
|
5237
|
+
async function runAddAbilityCommand({
|
|
5238
|
+
abilityName,
|
|
5239
|
+
cwd = process.cwd()
|
|
5240
|
+
}) {
|
|
5241
|
+
const workspace = resolveWorkspaceProject(cwd);
|
|
5242
|
+
const abilitySlug = assertValidGeneratedSlug("Ability name", normalizeBlockSlug(abilityName), "wp-typia add ability <name>");
|
|
5243
|
+
const inventory = readWorkspaceInventory(workspace.projectDir);
|
|
5244
|
+
assertAbilityDoesNotExist(workspace.projectDir, abilitySlug, inventory);
|
|
5245
|
+
const compatibilityPolicy = resolveScaffoldCompatibilityPolicy(REQUIRED_WORKSPACE_ABILITY_COMPATIBILITY);
|
|
5246
|
+
await scaffoldAbilityWorkspace({
|
|
5247
|
+
abilitySlug,
|
|
5248
|
+
compatibilityPolicy,
|
|
5249
|
+
workspace
|
|
5250
|
+
});
|
|
5251
|
+
return {
|
|
5252
|
+
abilitySlug,
|
|
5253
|
+
projectDir: workspace.projectDir
|
|
5254
|
+
};
|
|
5255
|
+
}
|
|
5256
|
+
// ../wp-typia-project-tools/src/runtime/cli-add-workspace-ai-scaffold.ts
|
|
5219
5257
|
import { promises as fsp8 } from "fs";
|
|
5220
5258
|
import path13 from "path";
|
|
5221
5259
|
|
|
@@ -6072,7 +6110,7 @@ async function ensureAiFeatureSyncRestAnchors(workspace) {
|
|
|
6072
6110
|
});
|
|
6073
6111
|
}
|
|
6074
6112
|
|
|
6075
|
-
// ../wp-typia-project-tools/src/runtime/cli-add-workspace-ai.ts
|
|
6113
|
+
// ../wp-typia-project-tools/src/runtime/cli-add-workspace-ai-templates.ts
|
|
6076
6114
|
function buildAiFeaturePhpSource(aiFeatureSlug, namespace, phpPrefix, textDomain) {
|
|
6077
6115
|
const aiFeatureTitle = toTitleCase(aiFeatureSlug);
|
|
6078
6116
|
const aiFeaturePhpId = aiFeatureSlug.replace(/-/g, "_");
|
|
@@ -6673,17 +6711,14 @@ add_action( 'admin_notices', '${adminNoticeFunctionName}' );
|
|
|
6673
6711
|
add_action( 'rest_api_init', '${registerRoutesFunctionName}' );
|
|
6674
6712
|
`;
|
|
6675
6713
|
}
|
|
6676
|
-
|
|
6677
|
-
|
|
6678
|
-
|
|
6679
|
-
|
|
6714
|
+
|
|
6715
|
+
// ../wp-typia-project-tools/src/runtime/cli-add-workspace-ai-scaffold.ts
|
|
6716
|
+
async function scaffoldAiFeatureWorkspace({
|
|
6717
|
+
aiFeatureSlug,
|
|
6718
|
+
compatibilityPolicy,
|
|
6719
|
+
namespace,
|
|
6720
|
+
workspace
|
|
6680
6721
|
}) {
|
|
6681
|
-
const workspace = resolveWorkspaceProject(cwd);
|
|
6682
|
-
const aiFeatureSlug = assertValidGeneratedSlug("AI feature name", normalizeBlockSlug(aiFeatureName), "wp-typia add ai-feature <name> [--namespace <vendor/v1>]");
|
|
6683
|
-
const resolvedNamespace = resolveRestResourceNamespace(workspace.workspace.namespace, namespace);
|
|
6684
|
-
const compatibilityPolicy = resolveScaffoldCompatibilityPolicy(OPTIONAL_WORDPRESS_AI_CLIENT_COMPATIBILITY);
|
|
6685
|
-
const inventory = readWorkspaceInventory(workspace.projectDir);
|
|
6686
|
-
assertAiFeatureDoesNotExist(workspace.projectDir, aiFeatureSlug, inventory);
|
|
6687
6722
|
const blockConfigPath = path13.join(workspace.projectDir, "scripts", "block-config.ts");
|
|
6688
6723
|
const bootstrapPath = getWorkspaceBootstrapPath(workspace);
|
|
6689
6724
|
const packageJsonPath = path13.join(workspace.projectDir, "package.json");
|
|
@@ -6721,7 +6756,7 @@ async function runAddAiFeatureCommand({
|
|
|
6721
6756
|
await fsp8.writeFile(validatorsFilePath, buildAiFeatureValidatorsSource(aiFeatureSlug), "utf8");
|
|
6722
6757
|
await fsp8.writeFile(apiFilePath, buildAiFeatureApiSource(aiFeatureSlug), "utf8");
|
|
6723
6758
|
await fsp8.writeFile(dataFilePath, buildAiFeatureDataSource(aiFeatureSlug), "utf8");
|
|
6724
|
-
await fsp8.writeFile(phpFilePath, buildAiFeaturePhpSource(aiFeatureSlug,
|
|
6759
|
+
await fsp8.writeFile(phpFilePath, buildAiFeaturePhpSource(aiFeatureSlug, namespace, workspace.workspace.phpPrefix, workspace.workspace.textDomain), "utf8");
|
|
6725
6760
|
const pascalCase = toPascalCase(aiFeatureSlug);
|
|
6726
6761
|
await syncAiFeatureRestArtifacts({
|
|
6727
6762
|
clientFile: `src/ai-features/${aiFeatureSlug}/api-client.ts`,
|
|
@@ -6730,7 +6765,7 @@ async function runAddAiFeatureCommand({
|
|
|
6730
6765
|
typesFile: `src/ai-features/${aiFeatureSlug}/api-types.ts`,
|
|
6731
6766
|
validatorsFile: `src/ai-features/${aiFeatureSlug}/api-validators.ts`,
|
|
6732
6767
|
variables: {
|
|
6733
|
-
namespace
|
|
6768
|
+
namespace,
|
|
6734
6769
|
pascalCase,
|
|
6735
6770
|
slugKebabCase: aiFeatureSlug,
|
|
6736
6771
|
title: toTitleCase(aiFeatureSlug)
|
|
@@ -6743,14 +6778,11 @@ async function runAddAiFeatureCommand({
|
|
|
6743
6778
|
});
|
|
6744
6779
|
await appendWorkspaceInventoryEntries(workspace.projectDir, {
|
|
6745
6780
|
aiFeatureEntries: [
|
|
6746
|
-
buildAiFeatureConfigEntry(aiFeatureSlug,
|
|
6781
|
+
buildAiFeatureConfigEntry(aiFeatureSlug, namespace)
|
|
6747
6782
|
],
|
|
6748
6783
|
transformSource: ensureBlockConfigCanAddRestManifests
|
|
6749
6784
|
});
|
|
6750
6785
|
return {
|
|
6751
|
-
aiFeatureSlug,
|
|
6752
|
-
namespace: resolvedNamespace,
|
|
6753
|
-
projectDir: workspace.projectDir,
|
|
6754
6786
|
warnings: packageScriptChanges.addedProjectToolsDependency ? [
|
|
6755
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`."
|
|
6756
6788
|
] : []
|
|
@@ -6761,6 +6793,32 @@ async function runAddAiFeatureCommand({
|
|
|
6761
6793
|
}
|
|
6762
6794
|
}
|
|
6763
6795
|
|
|
6796
|
+
// ../wp-typia-project-tools/src/runtime/cli-add-workspace-ai.ts
|
|
6797
|
+
async function runAddAiFeatureCommand({
|
|
6798
|
+
aiFeatureName,
|
|
6799
|
+
cwd = process.cwd(),
|
|
6800
|
+
namespace
|
|
6801
|
+
}) {
|
|
6802
|
+
const workspace = resolveWorkspaceProject(cwd);
|
|
6803
|
+
const aiFeatureSlug = assertValidGeneratedSlug("AI feature name", normalizeBlockSlug(aiFeatureName), "wp-typia add ai-feature <name> [--namespace <vendor/v1>]");
|
|
6804
|
+
const resolvedNamespace = resolveRestResourceNamespace(workspace.workspace.namespace, namespace);
|
|
6805
|
+
const compatibilityPolicy = resolveScaffoldCompatibilityPolicy(OPTIONAL_WORDPRESS_AI_CLIENT_COMPATIBILITY);
|
|
6806
|
+
const inventory = readWorkspaceInventory(workspace.projectDir);
|
|
6807
|
+
assertAiFeatureDoesNotExist(workspace.projectDir, aiFeatureSlug, inventory);
|
|
6808
|
+
const scaffoldResult = await scaffoldAiFeatureWorkspace({
|
|
6809
|
+
aiFeatureSlug,
|
|
6810
|
+
compatibilityPolicy,
|
|
6811
|
+
namespace: resolvedNamespace,
|
|
6812
|
+
workspace
|
|
6813
|
+
});
|
|
6814
|
+
return {
|
|
6815
|
+
aiFeatureSlug,
|
|
6816
|
+
namespace: resolvedNamespace,
|
|
6817
|
+
projectDir: workspace.projectDir,
|
|
6818
|
+
warnings: scaffoldResult.warnings
|
|
6819
|
+
};
|
|
6820
|
+
}
|
|
6821
|
+
|
|
6764
6822
|
// ../wp-typia-project-tools/src/runtime/cli-add-workspace.ts
|
|
6765
6823
|
var VARIATIONS_IMPORT_LINE = "import { registerWorkspaceVariations } from './variations';";
|
|
6766
6824
|
var VARIATIONS_IMPORT_PATTERN = /^\s*import\s*\{\s*registerWorkspaceVariations\s*\}\s*from\s*["']\.\/variations["']\s*;?\s*$/mu;
|
|
@@ -7242,24 +7300,6 @@ async function writeBlockTransformRegistry(projectDir, blockSlug, transformSlug)
|
|
|
7242
7300
|
const nextTransformSlugs = Array.from(new Set([...existingTransformSlugs, transformSlug])).sort();
|
|
7243
7301
|
await fsp9.writeFile(transformsIndexPath, buildBlockTransformIndexSource(nextTransformSlugs), "utf8");
|
|
7244
7302
|
}
|
|
7245
|
-
function assertBlockStyleDoesNotExist(projectDir, blockSlug, styleSlug, inventory) {
|
|
7246
|
-
const stylePath = path14.join(projectDir, "src", "blocks", blockSlug, "styles", `${styleSlug}.ts`);
|
|
7247
|
-
if (fs6.existsSync(stylePath)) {
|
|
7248
|
-
throw new Error(`A block style already exists at ${path14.relative(projectDir, stylePath)}. Choose a different name.`);
|
|
7249
|
-
}
|
|
7250
|
-
if (inventory.blockStyles.some((entry) => entry.block === blockSlug && entry.slug === styleSlug)) {
|
|
7251
|
-
throw new Error(`A block style inventory entry already exists for ${blockSlug}/${styleSlug}. Choose a different name.`);
|
|
7252
|
-
}
|
|
7253
|
-
}
|
|
7254
|
-
function assertBlockTransformDoesNotExist(projectDir, blockSlug, transformSlug, inventory) {
|
|
7255
|
-
const transformPath = path14.join(projectDir, "src", "blocks", blockSlug, "transforms", `${transformSlug}.ts`);
|
|
7256
|
-
if (fs6.existsSync(transformPath)) {
|
|
7257
|
-
throw new Error(`A block transform already exists at ${path14.relative(projectDir, transformPath)}. Choose a different name.`);
|
|
7258
|
-
}
|
|
7259
|
-
if (inventory.blockTransforms.some((entry) => entry.block === blockSlug && entry.slug === transformSlug)) {
|
|
7260
|
-
throw new Error(`A block transform inventory entry already exists for ${blockSlug}/${transformSlug}. Choose a different name.`);
|
|
7261
|
-
}
|
|
7262
|
-
}
|
|
7263
7303
|
function assertFullBlockName(blockName, flagName) {
|
|
7264
7304
|
const trimmed = blockName.trim();
|
|
7265
7305
|
if (!trimmed) {
|
|
@@ -7507,4 +7547,4 @@ export {
|
|
|
7507
7547
|
ADD_BLOCK_TEMPLATE_IDS
|
|
7508
7548
|
};
|
|
7509
7549
|
|
|
7510
|
-
//# debugId=
|
|
7550
|
+
//# debugId=272EBA8B7C96349F64756E2164756E21
|