wp-typia 0.22.6 → 0.22.8
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 +83 -0
- package/dist-bunli/.bunli/commands.gen.js +1376 -1208
- package/dist-bunli/{cli-add-5vmxpgmn.js → cli-add-1xvw17yg.js} +150 -128
- package/dist-bunli/{cli-1sm60g1z.js → cli-arz4rcye.js} +14 -5
- package/dist-bunli/{cli-5kn2p7ee.js → cli-bbj0kn1e.js} +267 -205
- package/dist-bunli/{cli-0q0tz4dq.js → cli-bwwssctv.js} +1 -1
- package/dist-bunli/{cli-doctor-ngzs8kkc.js → cli-doctor-bjv6z74k.js} +3 -3
- package/dist-bunli/{cli-f44sphgv.js → cli-e7n7hbvr.js} +3 -3
- package/dist-bunli/{cli-6a65qfb1.js → cli-fa7g1aqm.js} +368 -4025
- package/dist-bunli/{cli-init-df1wg71p.js → cli-init-zdfrmp3y.js} +74 -73
- package/dist-bunli/cli-mzvzbpnz.js +3702 -0
- package/dist-bunli/{cli-10pe4mf8.js → cli-pnjx2e2h.js} +1 -1
- package/dist-bunli/{cli-tke8twkn.js → cli-qse6myha.js} +4 -6
- package/dist-bunli/{cli-scaffold-btx3wfsn.js → cli-scaffold-pbb67zxg.js} +10 -8
- package/dist-bunli/{cli-templates-9t2a7zqd.js → cli-templates-hc71dfc2.js} +1 -1
- package/dist-bunli/cli.js +11 -8
- package/dist-bunli/{command-list-bqr2tp8w.js → command-list-hbcv3bz6.js} +54 -38
- package/dist-bunli/create-template-validation-7k2752mz.js +14 -0
- package/dist-bunli/{migrations-bnrjw4k1.js → migrations-ads3j14z.js} +4 -3
- package/dist-bunli/node-cli.js +443 -413
- package/package.json +2 -2
|
@@ -6,14 +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
|
-
pathExists,
|
|
15
14
|
renderScaffoldCompatibilityConfig,
|
|
16
|
-
require_semver,
|
|
17
15
|
resolveExternalTemplateLayers,
|
|
18
16
|
resolveLocalCliPathOption,
|
|
19
17
|
resolveOptionalInteractiveExternalLayerId,
|
|
@@ -22,7 +20,7 @@ import {
|
|
|
22
20
|
scaffoldProject,
|
|
23
21
|
syncPersistenceRestArtifacts,
|
|
24
22
|
updatePluginHeaderCompatibility
|
|
25
|
-
} from "./cli-
|
|
23
|
+
} from "./cli-fa7g1aqm.js";
|
|
26
24
|
import {
|
|
27
25
|
DEFAULT_WORDPRESS_ABILITIES_VERSION,
|
|
28
26
|
DEFAULT_WORDPRESS_CORE_ABILITIES_VERSION,
|
|
@@ -32,10 +30,14 @@ import {
|
|
|
32
30
|
DEFAULT_WP_TYPIA_DATAVIEWS_VERSION,
|
|
33
31
|
getPackageVersions,
|
|
34
32
|
resolveManagedPackageVersionRange
|
|
35
|
-
} from "./cli-
|
|
33
|
+
} from "./cli-arz4rcye.js";
|
|
34
|
+
import {
|
|
35
|
+
parseTemplateLocator,
|
|
36
|
+
require_semver
|
|
37
|
+
} from "./cli-mzvzbpnz.js";
|
|
36
38
|
import {
|
|
37
39
|
snapshotProjectVersion
|
|
38
|
-
} from "./cli-
|
|
40
|
+
} from "./cli-bwwssctv.js";
|
|
39
41
|
import {
|
|
40
42
|
ensureMigrationDirectories,
|
|
41
43
|
parseMigrationConfig,
|
|
@@ -49,10 +51,10 @@ import {
|
|
|
49
51
|
hasUncommentedPattern,
|
|
50
52
|
maskTypeScriptCommentsAndLiterals
|
|
51
53
|
} from "./cli-rwjkqjhs.js";
|
|
52
|
-
import"./cli-
|
|
54
|
+
import"./cli-pnjx2e2h.js";
|
|
53
55
|
import {
|
|
54
56
|
SHARED_WORKSPACE_TEMPLATE_ROOT
|
|
55
|
-
} from "./cli-
|
|
57
|
+
} from "./cli-qse6myha.js";
|
|
56
58
|
import {
|
|
57
59
|
ADD_BLOCK_TEMPLATE_IDS,
|
|
58
60
|
EDITOR_PLUGIN_SLOT_IDS,
|
|
@@ -77,6 +79,7 @@ import {
|
|
|
77
79
|
findPhpFunctionRange,
|
|
78
80
|
formatAddHelpText,
|
|
79
81
|
getMutableBlockHooks,
|
|
82
|
+
getPropertyNameText,
|
|
80
83
|
getWorkspaceBlockSelectOptions,
|
|
81
84
|
getWorkspaceBootstrapPath,
|
|
82
85
|
hasPhpFunctionCall,
|
|
@@ -84,11 +87,13 @@ import {
|
|
|
84
87
|
isAddBlockTemplateId,
|
|
85
88
|
normalizeBlockSlug,
|
|
86
89
|
patchFile,
|
|
90
|
+
pathExists,
|
|
87
91
|
quotePhpString,
|
|
88
92
|
quoteTsString,
|
|
89
93
|
readOptionalFile,
|
|
94
|
+
readOptionalUtf8File,
|
|
90
95
|
readWorkspaceBlockJson,
|
|
91
|
-
|
|
96
|
+
readWorkspaceInventoryAsync,
|
|
92
97
|
replacePhpFunctionDefinition,
|
|
93
98
|
require_typescript,
|
|
94
99
|
resolveNonEmptyNormalizedBlockSlug,
|
|
@@ -101,7 +106,7 @@ import {
|
|
|
101
106
|
toPascalCase,
|
|
102
107
|
toSnakeCase,
|
|
103
108
|
toTitleCase
|
|
104
|
-
} from "./cli-
|
|
109
|
+
} from "./cli-bbj0kn1e.js";
|
|
105
110
|
import {
|
|
106
111
|
createManagedTempRoot
|
|
107
112
|
} from "./cli-t73q5aqz.js";
|
|
@@ -228,7 +233,7 @@ function buildConfigEntries(templateId, variables) {
|
|
|
228
233
|
if (templateId === "persistence") {
|
|
229
234
|
return [buildPersistenceBlockConfigEntry(variables)];
|
|
230
235
|
}
|
|
231
|
-
if (variables
|
|
236
|
+
if (isCompoundPersistenceEnabled(variables)) {
|
|
232
237
|
return [
|
|
233
238
|
buildPersistenceBlockConfigEntry(variables),
|
|
234
239
|
buildCompoundChildConfigEntry(variables)
|
|
@@ -504,7 +509,7 @@ async function copyScaffoldedBlockSlice(projectDir, templateId, tempProjectDir,
|
|
|
504
509
|
await ensureCompoundWorkspaceSupportFiles(projectDir, tempProjectDir, legacyValidatorPaths);
|
|
505
510
|
await copyTempDirectory(path3.join(tempProjectDir, "src", "blocks", variables.slugKebabCase), path3.join(projectDir, "src", "blocks", variables.slugKebabCase));
|
|
506
511
|
await copyTempDirectory(path3.join(tempProjectDir, "src", "blocks", `${variables.slugKebabCase}-item`), path3.join(projectDir, "src", "blocks", `${variables.slugKebabCase}-item`));
|
|
507
|
-
if (variables
|
|
512
|
+
if (isCompoundPersistenceEnabled(variables)) {
|
|
508
513
|
await renderWorkspacePersistenceServerModule(projectDir, variables);
|
|
509
514
|
}
|
|
510
515
|
return;
|
|
@@ -617,7 +622,7 @@ async function syncWorkspaceAddedBlockArtifacts(projectDir, templateId, variable
|
|
|
617
622
|
if (templateId === "compound") {
|
|
618
623
|
await syncWorkspaceBlockMetadata(projectDir, `${variables.slugKebabCase}-item`, `${variables.pascalCase}ItemAttributes`, path3.join("src", "blocks", `${variables.slugKebabCase}-item`, "types.ts"));
|
|
619
624
|
}
|
|
620
|
-
if (templateId === "persistence" || templateId === "compound" && variables
|
|
625
|
+
if (templateId === "persistence" || templateId === "compound" && isCompoundPersistenceEnabled(variables)) {
|
|
621
626
|
await syncWorkspacePersistenceArtifacts(projectDir, variables);
|
|
622
627
|
}
|
|
623
628
|
}
|
|
@@ -772,7 +777,7 @@ async function runAddBlockCommand({
|
|
|
772
777
|
try {
|
|
773
778
|
await copyScaffoldedBlockSlice(workspace.projectDir, resolvedTemplateId, tempProjectDir, result.variables, legacyCompoundValidatorPaths);
|
|
774
779
|
await addCollectionImportsForTemplate(workspace.projectDir, resolvedTemplateId, result.variables);
|
|
775
|
-
await appendBlockConfigEntries(workspace.projectDir, buildConfigEntries(resolvedTemplateId, result.variables), resolvedTemplateId === "persistence" || resolvedTemplateId === "compound" && result.variables
|
|
780
|
+
await appendBlockConfigEntries(workspace.projectDir, buildConfigEntries(resolvedTemplateId, result.variables), resolvedTemplateId === "persistence" || resolvedTemplateId === "compound" && isCompoundPersistenceEnabled(result.variables));
|
|
776
781
|
await syncWorkspaceAddedBlockArtifacts(workspace.projectDir, resolvedTemplateId, result.variables);
|
|
777
782
|
await updateWorkspaceMigrationConfigIfPresent(workspace.projectDir, buildMigrationBlocks(resolvedTemplateId, result.variables));
|
|
778
783
|
return {
|
|
@@ -794,10 +799,52 @@ async function runAddBlockCommand({
|
|
|
794
799
|
}
|
|
795
800
|
}
|
|
796
801
|
// ../wp-typia-project-tools/src/runtime/cli-add-workspace.ts
|
|
797
|
-
import fs5 from "fs";
|
|
798
802
|
import { promises as fsp9 } from "fs";
|
|
799
803
|
import path14 from "path";
|
|
800
804
|
|
|
805
|
+
// ../wp-typia-project-tools/src/runtime/block-targets.ts
|
|
806
|
+
var FULL_BLOCK_NAME_PATTERN = /^[a-z0-9-]+\/[a-z0-9-]+$/u;
|
|
807
|
+
function assertFullBlockName(blockName, flagName) {
|
|
808
|
+
const trimmed = blockName.trim();
|
|
809
|
+
if (!trimmed) {
|
|
810
|
+
throw new Error(`\`${flagName}\` requires a block name.`);
|
|
811
|
+
}
|
|
812
|
+
if (!FULL_BLOCK_NAME_PATTERN.test(trimmed)) {
|
|
813
|
+
throw new Error(`\`${flagName}\` must use <namespace/block-slug> format.`);
|
|
814
|
+
}
|
|
815
|
+
return trimmed;
|
|
816
|
+
}
|
|
817
|
+
function resolveWorkspaceBlockTargetName(blockName, namespace, diagnostics) {
|
|
818
|
+
const trimmed = blockName.trim();
|
|
819
|
+
if (!trimmed) {
|
|
820
|
+
throw new Error(diagnostics.empty());
|
|
821
|
+
}
|
|
822
|
+
const blockNameSegments = trimmed.split("/");
|
|
823
|
+
if (blockNameSegments.length > 2) {
|
|
824
|
+
throw new Error(diagnostics.invalidFormat(trimmed));
|
|
825
|
+
}
|
|
826
|
+
if (blockNameSegments.some((segment) => segment.trim() === "")) {
|
|
827
|
+
throw new Error(diagnostics.emptySegment(trimmed));
|
|
828
|
+
}
|
|
829
|
+
const [maybeNamespace, maybeSlug] = blockNameSegments.length === 2 ? blockNameSegments : [undefined, blockNameSegments[0]];
|
|
830
|
+
if (maybeNamespace && maybeNamespace !== namespace) {
|
|
831
|
+
throw new Error(diagnostics.namespaceMismatch(trimmed, maybeNamespace, namespace));
|
|
832
|
+
}
|
|
833
|
+
const blockSlug = normalizeBlockSlug(maybeSlug ?? "");
|
|
834
|
+
return {
|
|
835
|
+
blockName: `${namespace}/${blockSlug}`,
|
|
836
|
+
blockSlug
|
|
837
|
+
};
|
|
838
|
+
}
|
|
839
|
+
function resolveWorkspaceTargetBlockName(blockName, namespace, flagName) {
|
|
840
|
+
return resolveWorkspaceBlockTargetName(blockName, namespace, {
|
|
841
|
+
empty: () => `\`${flagName}\` requires <block-slug|namespace/block-slug>.`,
|
|
842
|
+
emptySegment: () => `\`${flagName}\` must use <block-slug|namespace/block-slug> format.`,
|
|
843
|
+
invalidFormat: () => `\`${flagName}\` must use <block-slug|namespace/block-slug> format.`,
|
|
844
|
+
namespaceMismatch: (_input, actualNamespace, expectedNamespace) => `\`${flagName}\` references namespace "${actualNamespace}". Expected "${expectedNamespace}".`
|
|
845
|
+
});
|
|
846
|
+
}
|
|
847
|
+
|
|
801
848
|
// ../wp-typia-project-tools/src/runtime/cli-add-workspace-admin-view-types.ts
|
|
802
849
|
var ADMIN_VIEW_REST_SOURCE_KIND = "rest-resource";
|
|
803
850
|
var ADMIN_VIEW_CORE_DATA_SOURCE_KIND = "core-data";
|
|
@@ -905,7 +952,6 @@ function resolveAdminViewCoreDataSource(source) {
|
|
|
905
952
|
}
|
|
906
953
|
|
|
907
954
|
// ../wp-typia-project-tools/src/runtime/cli-add-workspace-admin-view-scaffold.ts
|
|
908
|
-
import fs2 from "fs";
|
|
909
955
|
import { promises as fsp3 } from "fs";
|
|
910
956
|
import path5 from "path";
|
|
911
957
|
|
|
@@ -2086,26 +2132,31 @@ async function ensureAdminViewWebpackAnchors(workspace) {
|
|
|
2086
2132
|
return nextSource;
|
|
2087
2133
|
});
|
|
2088
2134
|
}
|
|
2089
|
-
function resolveAdminViewRegistryPath(projectDir) {
|
|
2135
|
+
async function resolveAdminViewRegistryPath(projectDir) {
|
|
2090
2136
|
const adminViewsDir = path5.join(projectDir, "src", "admin-views");
|
|
2091
|
-
|
|
2137
|
+
for (const candidatePath of [
|
|
2092
2138
|
path5.join(adminViewsDir, "index.ts"),
|
|
2093
2139
|
path5.join(adminViewsDir, "index.js")
|
|
2094
|
-
]
|
|
2140
|
+
]) {
|
|
2141
|
+
if (await pathExists(candidatePath)) {
|
|
2142
|
+
return candidatePath;
|
|
2143
|
+
}
|
|
2144
|
+
}
|
|
2145
|
+
return path5.join(adminViewsDir, "index.ts");
|
|
2095
2146
|
}
|
|
2096
|
-
function readAdminViewRegistrySlugs(registryPath) {
|
|
2097
|
-
|
|
2147
|
+
async function readAdminViewRegistrySlugs(registryPath) {
|
|
2148
|
+
const source = await readOptionalUtf8File(registryPath);
|
|
2149
|
+
if (source === null) {
|
|
2098
2150
|
return [];
|
|
2099
2151
|
}
|
|
2100
|
-
const source = fs2.readFileSync(registryPath, "utf8");
|
|
2101
2152
|
return Array.from(source.matchAll(/^\s*import\s+['"]\.\/([^/'"]+)(?:\/index(?:\.[cm]?[jt]sx?)?)?['"];?\s*$/gmu)).map((match) => match[1]);
|
|
2102
2153
|
}
|
|
2103
2154
|
async function writeAdminViewRegistry(projectDir, adminViewSlug) {
|
|
2104
2155
|
const adminViewsDir = path5.join(projectDir, "src", "admin-views");
|
|
2105
|
-
const registryPath = resolveAdminViewRegistryPath(projectDir);
|
|
2156
|
+
const registryPath = await resolveAdminViewRegistryPath(projectDir);
|
|
2106
2157
|
await fsp3.mkdir(adminViewsDir, { recursive: true });
|
|
2107
|
-
const existingAdminViewSlugs =
|
|
2108
|
-
const existingRegistrySlugs = readAdminViewRegistrySlugs(registryPath);
|
|
2158
|
+
const existingAdminViewSlugs = (await readWorkspaceInventoryAsync(projectDir)).adminViews.map((entry) => entry.slug);
|
|
2159
|
+
const existingRegistrySlugs = await readAdminViewRegistrySlugs(registryPath);
|
|
2109
2160
|
const nextAdminViewSlugs = Array.from(new Set([
|
|
2110
2161
|
...existingAdminViewSlugs,
|
|
2111
2162
|
...existingRegistrySlugs,
|
|
@@ -2126,7 +2177,7 @@ async function scaffoldAdminViewWorkspace(options) {
|
|
|
2126
2177
|
const buildScriptPath = path5.join(workspace.projectDir, "scripts", "build-workspace.mjs");
|
|
2127
2178
|
const packageJsonPath = path5.join(workspace.projectDir, "package.json");
|
|
2128
2179
|
const webpackConfigPath = path5.join(workspace.projectDir, "webpack.config.js");
|
|
2129
|
-
const adminViewsIndexPath = resolveAdminViewRegistryPath(workspace.projectDir);
|
|
2180
|
+
const adminViewsIndexPath = await resolveAdminViewRegistryPath(workspace.projectDir);
|
|
2130
2181
|
const adminViewDir = path5.join(workspace.projectDir, "src", "admin-views", adminViewSlug);
|
|
2131
2182
|
const adminViewPhpPath = path5.join(workspace.projectDir, "inc", "admin-views", `${adminViewSlug}.php`);
|
|
2132
2183
|
await executeWorkspaceMutationPlan({
|
|
@@ -2174,7 +2225,7 @@ async function runAddAdminViewCommand({
|
|
|
2174
2225
|
assertAdminViewPackageAvailability();
|
|
2175
2226
|
const adminViewSlug = assertValidGeneratedSlug("Admin view name", normalizeBlockSlug(adminViewName), ADD_ADMIN_VIEW_USAGE);
|
|
2176
2227
|
const parsedSource = parseAdminViewSource(source);
|
|
2177
|
-
const inventory =
|
|
2228
|
+
const inventory = await readWorkspaceInventoryAsync(workspace.projectDir);
|
|
2178
2229
|
const restResource = resolveRestResourceSource(inventory.restResources, parsedSource);
|
|
2179
2230
|
const coreDataSource = resolveAdminViewCoreDataSource(parsedSource);
|
|
2180
2231
|
assertAdminViewDoesNotExist(workspace.projectDir, adminViewSlug, inventory);
|
|
@@ -2193,7 +2244,6 @@ async function runAddAdminViewCommand({
|
|
|
2193
2244
|
}
|
|
2194
2245
|
// ../wp-typia-project-tools/src/runtime/cli-add-workspace-assets.ts
|
|
2195
2246
|
var import_typescript = __toESM(require_typescript(), 1);
|
|
2196
|
-
import fs3 from "fs";
|
|
2197
2247
|
import { promises as fsp4 } from "fs";
|
|
2198
2248
|
import path6 from "path";
|
|
2199
2249
|
import {
|
|
@@ -2239,24 +2289,6 @@ function assertValidBindingAttributeName(attributeName) {
|
|
|
2239
2289
|
}
|
|
2240
2290
|
return trimmed;
|
|
2241
2291
|
}
|
|
2242
|
-
function resolveBindingTargetBlockSlug(blockName, namespace) {
|
|
2243
|
-
const trimmed = blockName.trim();
|
|
2244
|
-
if (!trimmed) {
|
|
2245
|
-
throw new Error("`wp-typia add binding-source` requires --block <block-slug|namespace/block-slug> to include a value when --attribute is provided.");
|
|
2246
|
-
}
|
|
2247
|
-
const blockNameSegments = trimmed.split("/");
|
|
2248
|
-
if (blockNameSegments.length > 2) {
|
|
2249
|
-
throw new Error(`Binding target block "${trimmed}" must use <block-slug> or <namespace/block-slug> format.`);
|
|
2250
|
-
}
|
|
2251
|
-
if (blockNameSegments.some((segment) => segment.trim() === "")) {
|
|
2252
|
-
throw new Error(`Binding target block "${trimmed}" must use <block-slug> or <namespace/block-slug> format without empty path segments.`);
|
|
2253
|
-
}
|
|
2254
|
-
const [maybeNamespace, maybeSlug] = blockNameSegments.length === 2 ? blockNameSegments : [undefined, blockNameSegments[0]];
|
|
2255
|
-
if (maybeNamespace && maybeNamespace !== namespace) {
|
|
2256
|
-
throw new Error(`Binding target block "${trimmed}" uses namespace "${maybeNamespace}". Expected "${namespace}".`);
|
|
2257
|
-
}
|
|
2258
|
-
return normalizeBlockSlug(maybeSlug ?? "");
|
|
2259
|
-
}
|
|
2260
2292
|
function buildEditorPluginConfigEntry(editorPluginSlug, slot) {
|
|
2261
2293
|
return [
|
|
2262
2294
|
"\t{",
|
|
@@ -2421,9 +2453,15 @@ function resolveBindingTarget(options, namespace) {
|
|
|
2421
2453
|
if (!hasBlock || !hasAttribute) {
|
|
2422
2454
|
throw new Error("`wp-typia add binding-source` requires --block and --attribute to be provided together.");
|
|
2423
2455
|
}
|
|
2456
|
+
const targetBlock = resolveWorkspaceBlockTargetName(blockName ?? "", namespace, {
|
|
2457
|
+
empty: () => "`wp-typia add binding-source` requires --block <block-slug|namespace/block-slug> to include a value when --attribute is provided.",
|
|
2458
|
+
emptySegment: (input) => `Binding target block "${input}" must use <block-slug> or <namespace/block-slug> format without empty path segments.`,
|
|
2459
|
+
invalidFormat: (input) => `Binding target block "${input}" must use <block-slug> or <namespace/block-slug> format.`,
|
|
2460
|
+
namespaceMismatch: (input, actualNamespace, expectedNamespace) => `Binding target block "${input}" uses namespace "${actualNamespace}". Expected "${expectedNamespace}".`
|
|
2461
|
+
});
|
|
2424
2462
|
return {
|
|
2425
2463
|
attributeName: assertValidBindingAttributeName(attributeName ?? ""),
|
|
2426
|
-
blockSlug:
|
|
2464
|
+
blockSlug: targetBlock.blockSlug
|
|
2427
2465
|
};
|
|
2428
2466
|
}
|
|
2429
2467
|
function formatBindingAttributeTypeMember(attributeName) {
|
|
@@ -2449,12 +2487,6 @@ function getInterfaceDeclaration(source, interfaceName) {
|
|
|
2449
2487
|
visit(sourceFile);
|
|
2450
2488
|
return declaration ? { declaration, sourceFile } : undefined;
|
|
2451
2489
|
}
|
|
2452
|
-
function getPropertyNameText(name) {
|
|
2453
|
-
if (import_typescript.default.isIdentifier(name) || import_typescript.default.isStringLiteral(name) || import_typescript.default.isNumericLiteral(name)) {
|
|
2454
|
-
return name.text;
|
|
2455
|
-
}
|
|
2456
|
-
return;
|
|
2457
|
-
}
|
|
2458
2490
|
function interfaceHasAttributeMember(declaration, attributeName) {
|
|
2459
2491
|
return declaration.members.some((member) => import_typescript.default.isPropertySignature(member) && member.name !== undefined && getPropertyNameText(member.name) === attributeName);
|
|
2460
2492
|
}
|
|
@@ -2931,38 +2963,51 @@ async function ensureEditorPluginWebpackAnchors(workspace) {
|
|
|
2931
2963
|
return nextSource;
|
|
2932
2964
|
});
|
|
2933
2965
|
}
|
|
2934
|
-
function resolveBindingSourceRegistryPath(projectDir) {
|
|
2966
|
+
async function resolveBindingSourceRegistryPath(projectDir) {
|
|
2935
2967
|
const bindingsDir = path6.join(projectDir, "src", "bindings");
|
|
2936
|
-
|
|
2968
|
+
for (const candidatePath of [
|
|
2969
|
+
path6.join(bindingsDir, "index.ts"),
|
|
2970
|
+
path6.join(bindingsDir, "index.js")
|
|
2971
|
+
]) {
|
|
2972
|
+
if (await pathExists(candidatePath)) {
|
|
2973
|
+
return candidatePath;
|
|
2974
|
+
}
|
|
2975
|
+
}
|
|
2976
|
+
return path6.join(bindingsDir, "index.ts");
|
|
2937
2977
|
}
|
|
2938
2978
|
async function writeBindingSourceRegistry(projectDir, bindingSourceSlug) {
|
|
2939
2979
|
const bindingsDir = path6.join(projectDir, "src", "bindings");
|
|
2940
|
-
const bindingsIndexPath = resolveBindingSourceRegistryPath(projectDir);
|
|
2980
|
+
const bindingsIndexPath = await resolveBindingSourceRegistryPath(projectDir);
|
|
2941
2981
|
await fsp4.mkdir(bindingsDir, { recursive: true });
|
|
2942
|
-
const existingBindingSourceSlugs =
|
|
2982
|
+
const existingBindingSourceSlugs = (await fsp4.readdir(bindingsDir, { withFileTypes: true })).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
2943
2983
|
const nextBindingSourceSlugs = Array.from(new Set([...existingBindingSourceSlugs, bindingSourceSlug])).sort();
|
|
2944
2984
|
await fsp4.writeFile(bindingsIndexPath, buildBindingSourceIndexSource(nextBindingSourceSlugs), "utf8");
|
|
2945
2985
|
}
|
|
2946
|
-
function resolveEditorPluginRegistryPath(projectDir) {
|
|
2986
|
+
async function resolveEditorPluginRegistryPath(projectDir) {
|
|
2947
2987
|
const editorPluginsDir = path6.join(projectDir, "src", "editor-plugins");
|
|
2948
|
-
|
|
2988
|
+
for (const candidatePath of [
|
|
2949
2989
|
path6.join(editorPluginsDir, "index.ts"),
|
|
2950
2990
|
path6.join(editorPluginsDir, "index.js")
|
|
2951
|
-
]
|
|
2991
|
+
]) {
|
|
2992
|
+
if (await pathExists(candidatePath)) {
|
|
2993
|
+
return candidatePath;
|
|
2994
|
+
}
|
|
2995
|
+
}
|
|
2996
|
+
return path6.join(editorPluginsDir, "index.ts");
|
|
2952
2997
|
}
|
|
2953
|
-
function readEditorPluginRegistrySlugs(registryPath) {
|
|
2954
|
-
|
|
2998
|
+
async function readEditorPluginRegistrySlugs(registryPath) {
|
|
2999
|
+
const source = await readOptionalUtf8File(registryPath);
|
|
3000
|
+
if (source === null) {
|
|
2955
3001
|
return [];
|
|
2956
3002
|
}
|
|
2957
|
-
const source = fs3.readFileSync(registryPath, "utf8");
|
|
2958
3003
|
return Array.from(source.matchAll(/^\s*import\s+['"]\.\/([^/'"]+)(?:\/index(?:\.[cm]?[jt]sx?)?)?['"];?\s*$/gmu)).map((match) => match[1]);
|
|
2959
3004
|
}
|
|
2960
3005
|
async function writeEditorPluginRegistry(projectDir, editorPluginSlug) {
|
|
2961
3006
|
const editorPluginsDir = path6.join(projectDir, "src", "editor-plugins");
|
|
2962
|
-
const registryPath = resolveEditorPluginRegistryPath(projectDir);
|
|
3007
|
+
const registryPath = await resolveEditorPluginRegistryPath(projectDir);
|
|
2963
3008
|
await fsp4.mkdir(editorPluginsDir, { recursive: true });
|
|
2964
|
-
const existingEditorPluginSlugs =
|
|
2965
|
-
const existingRegistrySlugs = readEditorPluginRegistrySlugs(registryPath);
|
|
3009
|
+
const existingEditorPluginSlugs = (await readWorkspaceInventoryAsync(projectDir)).editorPlugins.map((entry) => entry.slug);
|
|
3010
|
+
const existingRegistrySlugs = await readEditorPluginRegistrySlugs(registryPath);
|
|
2966
3011
|
const nextEditorPluginSlugs = Array.from(new Set([...existingEditorPluginSlugs, ...existingRegistrySlugs, editorPluginSlug])).sort();
|
|
2967
3012
|
await fsp4.writeFile(registryPath, buildEditorPluginRegistrySource(nextEditorPluginSlugs), "utf8");
|
|
2968
3013
|
}
|
|
@@ -2974,12 +3019,12 @@ async function runAddEditorPluginCommand({
|
|
|
2974
3019
|
const workspace = resolveWorkspaceProject(cwd);
|
|
2975
3020
|
const editorPluginSlug = assertValidGeneratedSlug("Editor plugin name", normalizeBlockSlug(editorPluginName), "wp-typia add editor-plugin <name> [--slot <sidebar|document-setting-panel>]");
|
|
2976
3021
|
const resolvedSlot = assertValidEditorPluginSlot(slot);
|
|
2977
|
-
const inventory =
|
|
3022
|
+
const inventory = await readWorkspaceInventoryAsync(workspace.projectDir);
|
|
2978
3023
|
assertEditorPluginDoesNotExist(workspace.projectDir, editorPluginSlug, inventory);
|
|
2979
3024
|
const blockConfigPath = path6.join(workspace.projectDir, "scripts", "block-config.ts");
|
|
2980
3025
|
const bootstrapPath = getWorkspaceBootstrapPath(workspace);
|
|
2981
3026
|
const buildScriptPath = path6.join(workspace.projectDir, "scripts", "build-workspace.mjs");
|
|
2982
|
-
const editorPluginsIndexPath = resolveEditorPluginRegistryPath(workspace.projectDir);
|
|
3027
|
+
const editorPluginsIndexPath = await resolveEditorPluginRegistryPath(workspace.projectDir);
|
|
2983
3028
|
const webpackConfigPath = path6.join(workspace.projectDir, "webpack.config.js");
|
|
2984
3029
|
const editorPluginDir = path6.join(workspace.projectDir, "src", "editor-plugins", editorPluginSlug);
|
|
2985
3030
|
const entryFilePath = path6.join(editorPluginDir, "index.tsx");
|
|
@@ -3030,7 +3075,7 @@ async function runAddPatternCommand({
|
|
|
3030
3075
|
}) {
|
|
3031
3076
|
const workspace = resolveWorkspaceProject(cwd);
|
|
3032
3077
|
const patternSlug = assertValidGeneratedSlug("Pattern name", normalizeBlockSlug(patternName), "wp-typia add pattern <name>");
|
|
3033
|
-
const inventory =
|
|
3078
|
+
const inventory = await readWorkspaceInventoryAsync(workspace.projectDir);
|
|
3034
3079
|
assertPatternDoesNotExist(workspace.projectDir, patternSlug, inventory);
|
|
3035
3080
|
const blockConfigPath = path6.join(workspace.projectDir, "scripts", "block-config.ts");
|
|
3036
3081
|
const bootstrapPath = getWorkspaceBootstrapPath(workspace);
|
|
@@ -3064,7 +3109,7 @@ async function runAddBindingSourceCommand({
|
|
|
3064
3109
|
}) {
|
|
3065
3110
|
const workspace = resolveWorkspaceProject(cwd);
|
|
3066
3111
|
const bindingSourceSlug = assertValidGeneratedSlug("Binding source name", normalizeBlockSlug(bindingSourceName), "wp-typia add binding-source <name> [--block <block-slug|namespace/block-slug> --attribute <attribute>]");
|
|
3067
|
-
const inventory =
|
|
3112
|
+
const inventory = await readWorkspaceInventoryAsync(workspace.projectDir);
|
|
3068
3113
|
assertBindingSourceDoesNotExist(workspace.projectDir, bindingSourceSlug, inventory);
|
|
3069
3114
|
const target = resolveBindingTarget({
|
|
3070
3115
|
attributeName,
|
|
@@ -3073,7 +3118,7 @@ async function runAddBindingSourceCommand({
|
|
|
3073
3118
|
const targetBlock = target ? resolveWorkspaceBlock(inventory, target.blockSlug) : undefined;
|
|
3074
3119
|
const blockConfigPath = path6.join(workspace.projectDir, "scripts", "block-config.ts");
|
|
3075
3120
|
const bootstrapPath = getWorkspaceBootstrapPath(workspace);
|
|
3076
|
-
const bindingsIndexPath = resolveBindingSourceRegistryPath(workspace.projectDir);
|
|
3121
|
+
const bindingsIndexPath = await resolveBindingSourceRegistryPath(workspace.projectDir);
|
|
3077
3122
|
const bindingSourceDir = path6.join(workspace.projectDir, "src", "bindings", bindingSourceSlug);
|
|
3078
3123
|
const serverFilePath = path6.join(bindingSourceDir, "server.php");
|
|
3079
3124
|
const editorFilePath = path6.join(bindingSourceDir, "editor.ts");
|
|
@@ -4258,7 +4303,7 @@ async function runAddRestResourceCommand({
|
|
|
4258
4303
|
const restResourceSlug = assertValidGeneratedSlug("REST resource name", normalizeBlockSlug(restResourceName), "wp-typia add rest-resource <name> [--namespace <vendor/v1>] [--methods <list,read,create>]");
|
|
4259
4304
|
const resolvedMethods = assertValidRestResourceMethods(methods);
|
|
4260
4305
|
const resolvedNamespace = resolveRestResourceNamespace(workspace.workspace.namespace, namespace);
|
|
4261
|
-
const inventory =
|
|
4306
|
+
const inventory = await readWorkspaceInventoryAsync(workspace.projectDir);
|
|
4262
4307
|
assertRestResourceDoesNotExist(workspace.projectDir, restResourceSlug, inventory);
|
|
4263
4308
|
const blockConfigPath = path9.join(workspace.projectDir, "scripts", "block-config.ts");
|
|
4264
4309
|
const bootstrapPath = getWorkspaceBootstrapPath(workspace);
|
|
@@ -4321,7 +4366,6 @@ async function runAddRestResourceCommand({
|
|
|
4321
4366
|
}
|
|
4322
4367
|
// ../wp-typia-project-tools/src/runtime/cli-add-workspace-ability-scaffold.ts
|
|
4323
4368
|
var import_semver = __toESM(require_semver(), 1);
|
|
4324
|
-
import fs4 from "fs";
|
|
4325
4369
|
import { promises as fsp6 } from "fs";
|
|
4326
4370
|
import path10 from "path";
|
|
4327
4371
|
import { syncTypeSchemas as syncTypeSchemas2 } from "@wp-typia/block-runtime/metadata-core";
|
|
@@ -4813,26 +4857,34 @@ function resolveManagedDependencyVersion(existingVersion, requiredVersion) {
|
|
|
4813
4857
|
}
|
|
4814
4858
|
return import_semver.default.gte(existingMinimum, requiredMinimum) ? existingVersion : requiredVersion;
|
|
4815
4859
|
}
|
|
4816
|
-
function resolveAbilityRegistryPath(projectDir) {
|
|
4860
|
+
async function resolveAbilityRegistryPath(projectDir) {
|
|
4817
4861
|
const abilitiesDir = path10.join(projectDir, "src", "abilities");
|
|
4818
|
-
|
|
4862
|
+
for (const candidatePath of [
|
|
4863
|
+
path10.join(abilitiesDir, "index.ts"),
|
|
4864
|
+
path10.join(abilitiesDir, "index.js")
|
|
4865
|
+
]) {
|
|
4866
|
+
if (await pathExists(candidatePath)) {
|
|
4867
|
+
return candidatePath;
|
|
4868
|
+
}
|
|
4869
|
+
}
|
|
4870
|
+
return path10.join(abilitiesDir, "index.ts");
|
|
4819
4871
|
}
|
|
4820
|
-
function readAbilityRegistrySlugs(registryPath) {
|
|
4821
|
-
|
|
4872
|
+
async function readAbilityRegistrySlugs(registryPath) {
|
|
4873
|
+
const source = await readOptionalUtf8File(registryPath);
|
|
4874
|
+
if (source === null) {
|
|
4822
4875
|
return [];
|
|
4823
4876
|
}
|
|
4824
|
-
|
|
4825
|
-
return Array.from(source.matchAll(/^\s*export\s+\*\s+from\s+['"]\.\/([^/'"]+)\/client['"];?\s*$/gmu)).map((match) => match[1]);
|
|
4877
|
+
return Array.from(source.matchAll(/^\s*export\s+\*\s+from\s+['"]\.\/([^/'"]+)\/client(?:\.[cm]?[jt]sx?)?['"];?\s*$/gmu)).map((match) => match[1]);
|
|
4826
4878
|
}
|
|
4827
4879
|
async function writeAbilityRegistry(projectDir, abilitySlug) {
|
|
4828
4880
|
const abilitiesDir = path10.join(projectDir, "src", "abilities");
|
|
4829
|
-
const registryPath = resolveAbilityRegistryPath(projectDir);
|
|
4881
|
+
const registryPath = await resolveAbilityRegistryPath(projectDir);
|
|
4830
4882
|
await fsp6.mkdir(abilitiesDir, { recursive: true });
|
|
4831
|
-
const existingAbilitySlugs =
|
|
4832
|
-
const existingRegistrySlugs = readAbilityRegistrySlugs(registryPath);
|
|
4883
|
+
const existingAbilitySlugs = (await readWorkspaceInventoryAsync(projectDir)).abilities.map((entry) => entry.slug);
|
|
4884
|
+
const existingRegistrySlugs = await readAbilityRegistrySlugs(registryPath);
|
|
4833
4885
|
const nextAbilitySlugs = Array.from(new Set([...existingAbilitySlugs, ...existingRegistrySlugs, abilitySlug])).sort();
|
|
4834
4886
|
const generatedSection = buildAbilityRegistrySource(nextAbilitySlugs);
|
|
4835
|
-
const existingSource =
|
|
4887
|
+
const existingSource = await readOptionalUtf8File(registryPath) ?? "";
|
|
4836
4888
|
const generatedSectionPattern = new RegExp(`${escapeRegex(ABILITY_REGISTRY_START_MARKER)}[\\s\\S]*?${escapeRegex(ABILITY_REGISTRY_END_MARKER)}\\n?`, "u");
|
|
4837
4889
|
const nextSource = existingSource ? generatedSectionPattern.test(existingSource) ? existingSource.replace(generatedSectionPattern, generatedSection) : `${existingSource.trimEnd()}
|
|
4838
4890
|
|
|
@@ -5101,7 +5153,7 @@ async function scaffoldAbilityWorkspace({
|
|
|
5101
5153
|
const syncAbilitiesScriptPath = path10.join(workspace.projectDir, "scripts", "sync-abilities.ts");
|
|
5102
5154
|
const syncProjectScriptPath = path10.join(workspace.projectDir, "scripts", "sync-project.ts");
|
|
5103
5155
|
const webpackConfigPath = path10.join(workspace.projectDir, "webpack.config.js");
|
|
5104
|
-
const abilitiesIndexPath = resolveAbilityRegistryPath(workspace.projectDir);
|
|
5156
|
+
const abilitiesIndexPath = await resolveAbilityRegistryPath(workspace.projectDir);
|
|
5105
5157
|
const abilityDir = path10.join(workspace.projectDir, "src", "abilities", abilitySlug);
|
|
5106
5158
|
const configFilePath = path10.join(abilityDir, "ability.config.json");
|
|
5107
5159
|
const typesFilePath = path10.join(abilityDir, "types.ts");
|
|
@@ -5172,7 +5224,7 @@ async function runAddAbilityCommand({
|
|
|
5172
5224
|
}) {
|
|
5173
5225
|
const workspace = resolveWorkspaceProject(cwd);
|
|
5174
5226
|
const abilitySlug = assertValidGeneratedSlug("Ability name", normalizeBlockSlug(abilityName), "wp-typia add ability <name>");
|
|
5175
|
-
const inventory =
|
|
5227
|
+
const inventory = await readWorkspaceInventoryAsync(workspace.projectDir);
|
|
5176
5228
|
assertAbilityDoesNotExist(workspace.projectDir, abilitySlug, inventory);
|
|
5177
5229
|
const compatibilityPolicy = resolveScaffoldCompatibilityPolicy(REQUIRED_WORKSPACE_ABILITY_COMPATIBILITY);
|
|
5178
5230
|
const scaffoldResult = await scaffoldAbilityWorkspace({
|
|
@@ -6714,7 +6766,7 @@ async function runAddAiFeatureCommand({
|
|
|
6714
6766
|
const aiFeatureSlug = assertValidGeneratedSlug("AI feature name", normalizeBlockSlug(aiFeatureName), "wp-typia add ai-feature <name> [--namespace <vendor/v1>]");
|
|
6715
6767
|
const resolvedNamespace = resolveRestResourceNamespace(workspace.workspace.namespace, namespace);
|
|
6716
6768
|
const compatibilityPolicy = resolveScaffoldCompatibilityPolicy(OPTIONAL_WORDPRESS_AI_CLIENT_COMPATIBILITY);
|
|
6717
|
-
const inventory =
|
|
6769
|
+
const inventory = await readWorkspaceInventoryAsync(workspace.projectDir);
|
|
6718
6770
|
assertAiFeatureDoesNotExist(workspace.projectDir, aiFeatureSlug, inventory);
|
|
6719
6771
|
const scaffoldResult = await scaffoldAiFeatureWorkspace({
|
|
6720
6772
|
aiFeatureSlug,
|
|
@@ -6744,7 +6796,6 @@ var BLOCK_TRANSFORMS_IMPORT_PATTERN = /^\s*import\s*\{\s*applyWorkspaceBlockTran
|
|
|
6744
6796
|
var BLOCK_TRANSFORMS_CALL_LINE = "applyWorkspaceBlockTransforms(registration.settings);";
|
|
6745
6797
|
var BLOCK_TRANSFORMS_CALL_PATTERN = /applyWorkspaceBlockTransforms\s*\(\s*registration\s*\.\s*settings\s*\)\s*;?/u;
|
|
6746
6798
|
var SCAFFOLD_REGISTRATION_SETTINGS_CALL_PATTERN = /registerScaffoldBlockType\s*\(\s*registration\s*\.\s*name\s*,\s*registration\s*\.\s*settings\s*\)\s*;?/u;
|
|
6747
|
-
var FULL_BLOCK_NAME_PATTERN = /^[a-z0-9-]+\/[a-z0-9-]+$/u;
|
|
6748
6799
|
function isIdentifierBoundary(source, index) {
|
|
6749
6800
|
if (index < 0 || index >= source.length) {
|
|
6750
6801
|
return true;
|
|
@@ -7117,7 +7168,7 @@ async function writeVariationRegistry(projectDir, blockSlug, variationSlug) {
|
|
|
7117
7168
|
const variationsDir = path14.join(projectDir, "src", "blocks", blockSlug, "variations");
|
|
7118
7169
|
const variationsIndexPath = path14.join(variationsDir, "index.ts");
|
|
7119
7170
|
await fsp9.mkdir(variationsDir, { recursive: true });
|
|
7120
|
-
const existingVariationSlugs =
|
|
7171
|
+
const existingVariationSlugs = (await fsp9.readdir(variationsDir)).filter((entry) => entry.endsWith(".ts") && entry !== "index.ts").map((entry) => entry.replace(/\.ts$/u, ""));
|
|
7121
7172
|
const nextVariationSlugs = Array.from(new Set([...existingVariationSlugs, variationSlug])).sort();
|
|
7122
7173
|
await fsp9.writeFile(variationsIndexPath, buildVariationIndexSource(nextVariationSlugs), "utf8");
|
|
7123
7174
|
}
|
|
@@ -7125,7 +7176,7 @@ async function writeBlockStyleRegistry(projectDir, blockSlug, styleSlug) {
|
|
|
7125
7176
|
const stylesDir = path14.join(projectDir, "src", "blocks", blockSlug, "styles");
|
|
7126
7177
|
const stylesIndexPath = path14.join(stylesDir, "index.ts");
|
|
7127
7178
|
await fsp9.mkdir(stylesDir, { recursive: true });
|
|
7128
|
-
const existingStyleSlugs =
|
|
7179
|
+
const existingStyleSlugs = (await fsp9.readdir(stylesDir)).filter((entry) => entry.endsWith(".ts") && entry !== "index.ts").map((entry) => entry.replace(/\.ts$/u, ""));
|
|
7129
7180
|
const nextStyleSlugs = Array.from(new Set([...existingStyleSlugs, styleSlug])).sort();
|
|
7130
7181
|
await fsp9.writeFile(stylesIndexPath, buildBlockStyleIndexSource(nextStyleSlugs), "utf8");
|
|
7131
7182
|
}
|
|
@@ -7133,39 +7184,10 @@ async function writeBlockTransformRegistry(projectDir, blockSlug, transformSlug)
|
|
|
7133
7184
|
const transformsDir = path14.join(projectDir, "src", "blocks", blockSlug, "transforms");
|
|
7134
7185
|
const transformsIndexPath = path14.join(transformsDir, "index.ts");
|
|
7135
7186
|
await fsp9.mkdir(transformsDir, { recursive: true });
|
|
7136
|
-
const existingTransformSlugs =
|
|
7187
|
+
const existingTransformSlugs = (await fsp9.readdir(transformsDir)).filter((entry) => entry.endsWith(".ts") && entry !== "index.ts").map((entry) => entry.replace(/\.ts$/u, ""));
|
|
7137
7188
|
const nextTransformSlugs = Array.from(new Set([...existingTransformSlugs, transformSlug])).sort();
|
|
7138
7189
|
await fsp9.writeFile(transformsIndexPath, buildBlockTransformIndexSource(nextTransformSlugs), "utf8");
|
|
7139
7190
|
}
|
|
7140
|
-
function assertFullBlockName(blockName, flagName) {
|
|
7141
|
-
const trimmed = blockName.trim();
|
|
7142
|
-
if (!trimmed) {
|
|
7143
|
-
throw new Error(`\`${flagName}\` requires a block name.`);
|
|
7144
|
-
}
|
|
7145
|
-
if (!FULL_BLOCK_NAME_PATTERN.test(trimmed)) {
|
|
7146
|
-
throw new Error(`\`${flagName}\` must use <namespace/block-slug> format.`);
|
|
7147
|
-
}
|
|
7148
|
-
return trimmed;
|
|
7149
|
-
}
|
|
7150
|
-
function resolveWorkspaceTargetBlockName(blockName, namespace, flagName) {
|
|
7151
|
-
const trimmed = blockName.trim();
|
|
7152
|
-
if (!trimmed) {
|
|
7153
|
-
throw new Error(`\`${flagName}\` requires <block-slug|namespace/block-slug>.`);
|
|
7154
|
-
}
|
|
7155
|
-
const blockNameSegments = trimmed.split("/");
|
|
7156
|
-
if (blockNameSegments.length > 2 || blockNameSegments.some((segment) => segment.trim() === "")) {
|
|
7157
|
-
throw new Error(`\`${flagName}\` must use <block-slug|namespace/block-slug> format.`);
|
|
7158
|
-
}
|
|
7159
|
-
const [maybeNamespace, maybeSlug] = blockNameSegments.length === 2 ? blockNameSegments : [undefined, blockNameSegments[0]];
|
|
7160
|
-
if (maybeNamespace && maybeNamespace !== namespace) {
|
|
7161
|
-
throw new Error(`\`${flagName}\` references namespace "${maybeNamespace}". Expected "${namespace}".`);
|
|
7162
|
-
}
|
|
7163
|
-
const blockSlug = normalizeBlockSlug(maybeSlug ?? "");
|
|
7164
|
-
return {
|
|
7165
|
-
blockName: `${namespace}/${blockSlug}`,
|
|
7166
|
-
blockSlug
|
|
7167
|
-
};
|
|
7168
|
-
}
|
|
7169
7191
|
async function runAddVariationCommand({
|
|
7170
7192
|
blockName,
|
|
7171
7193
|
cwd = process.cwd(),
|
|
@@ -7174,7 +7196,7 @@ async function runAddVariationCommand({
|
|
|
7174
7196
|
const workspace = resolveWorkspaceProject(cwd);
|
|
7175
7197
|
const blockSlug = normalizeBlockSlug(blockName);
|
|
7176
7198
|
const variationSlug = assertValidGeneratedSlug("Variation name", normalizeBlockSlug(variationName), "wp-typia add variation <name> --block <block-slug>");
|
|
7177
|
-
const inventory =
|
|
7199
|
+
const inventory = await readWorkspaceInventoryAsync(workspace.projectDir);
|
|
7178
7200
|
resolveWorkspaceBlock(inventory, blockSlug);
|
|
7179
7201
|
assertVariationDoesNotExist(workspace.projectDir, blockSlug, variationSlug, inventory);
|
|
7180
7202
|
const blockConfigPath = path14.join(workspace.projectDir, "scripts", "block-config.ts");
|
|
@@ -7182,7 +7204,7 @@ async function runAddVariationCommand({
|
|
|
7182
7204
|
const variationsDir = path14.join(workspace.projectDir, "src", "blocks", blockSlug, "variations");
|
|
7183
7205
|
const variationFilePath = path14.join(variationsDir, `${variationSlug}.ts`);
|
|
7184
7206
|
const variationsIndexPath = path14.join(variationsDir, "index.ts");
|
|
7185
|
-
const shouldRemoveVariationsDirOnRollback = !
|
|
7207
|
+
const shouldRemoveVariationsDirOnRollback = !await pathExists(variationsDir);
|
|
7186
7208
|
const mutationSnapshot = {
|
|
7187
7209
|
fileSources: await snapshotWorkspaceFiles([
|
|
7188
7210
|
blockConfigPath,
|
|
@@ -7221,7 +7243,7 @@ async function runAddBlockStyleCommand({
|
|
|
7221
7243
|
const workspace = resolveWorkspaceProject(cwd);
|
|
7222
7244
|
const blockSlug = normalizeBlockSlug(blockName);
|
|
7223
7245
|
const styleSlug = assertValidGeneratedSlug("Style name", normalizeBlockSlug(styleName), "wp-typia add style <name> --block <block-slug>");
|
|
7224
|
-
const inventory =
|
|
7246
|
+
const inventory = await readWorkspaceInventoryAsync(workspace.projectDir);
|
|
7225
7247
|
resolveWorkspaceBlock(inventory, blockSlug);
|
|
7226
7248
|
assertBlockStyleDoesNotExist(workspace.projectDir, blockSlug, styleSlug, inventory);
|
|
7227
7249
|
const blockConfigPath = path14.join(workspace.projectDir, "scripts", "block-config.ts");
|
|
@@ -7229,7 +7251,7 @@ async function runAddBlockStyleCommand({
|
|
|
7229
7251
|
const stylesDir = path14.join(workspace.projectDir, "src", "blocks", blockSlug, "styles");
|
|
7230
7252
|
const styleFilePath = path14.join(stylesDir, `${styleSlug}.ts`);
|
|
7231
7253
|
const stylesIndexPath = path14.join(stylesDir, "index.ts");
|
|
7232
|
-
const shouldRemoveStylesDirOnRollback = !
|
|
7254
|
+
const shouldRemoveStylesDirOnRollback = !await pathExists(stylesDir);
|
|
7233
7255
|
const mutationSnapshot = {
|
|
7234
7256
|
fileSources: await snapshotWorkspaceFiles([
|
|
7235
7257
|
blockConfigPath,
|
|
@@ -7270,7 +7292,7 @@ async function runAddBlockTransformCommand({
|
|
|
7270
7292
|
const transformSlug = assertValidGeneratedSlug("Transform name", normalizeBlockSlug(transformName), "wp-typia add transform <name> --from <namespace/block> --to <block-slug|namespace/block-slug>");
|
|
7271
7293
|
const resolvedFromBlockName = assertFullBlockName(fromBlockName, "--from");
|
|
7272
7294
|
const target = resolveWorkspaceTargetBlockName(toBlockName, workspace.workspace.namespace, "--to");
|
|
7273
|
-
const inventory =
|
|
7295
|
+
const inventory = await readWorkspaceInventoryAsync(workspace.projectDir);
|
|
7274
7296
|
resolveWorkspaceBlock(inventory, target.blockSlug);
|
|
7275
7297
|
assertBlockTransformDoesNotExist(workspace.projectDir, target.blockSlug, transformSlug, inventory);
|
|
7276
7298
|
const blockConfigPath = path14.join(workspace.projectDir, "scripts", "block-config.ts");
|
|
@@ -7278,7 +7300,7 @@ async function runAddBlockTransformCommand({
|
|
|
7278
7300
|
const transformsDir = path14.join(workspace.projectDir, "src", "blocks", target.blockSlug, "transforms");
|
|
7279
7301
|
const transformFilePath = path14.join(transformsDir, `${transformSlug}.ts`);
|
|
7280
7302
|
const transformsIndexPath = path14.join(transformsDir, "index.ts");
|
|
7281
|
-
const shouldRemoveTransformsDirOnRollback = !
|
|
7303
|
+
const shouldRemoveTransformsDirOnRollback = !await pathExists(transformsDir);
|
|
7282
7304
|
const mutationSnapshot = {
|
|
7283
7305
|
fileSources: await snapshotWorkspaceFiles([
|
|
7284
7306
|
blockConfigPath,
|
|
@@ -7330,7 +7352,7 @@ async function runAddHookedBlockCommand({
|
|
|
7330
7352
|
}) {
|
|
7331
7353
|
const workspace = resolveWorkspaceProject(cwd);
|
|
7332
7354
|
const blockSlug = normalizeBlockSlug(blockName);
|
|
7333
|
-
const inventory =
|
|
7355
|
+
const inventory = await readWorkspaceInventoryAsync(workspace.projectDir);
|
|
7334
7356
|
resolveWorkspaceBlock(inventory, blockSlug);
|
|
7335
7357
|
const resolvedAnchorBlockName = assertValidHookAnchor(anchorBlockName);
|
|
7336
7358
|
const resolvedPosition = assertValidHookedBlockPosition(position);
|
|
@@ -7338,7 +7360,7 @@ async function runAddHookedBlockCommand({
|
|
|
7338
7360
|
if (resolvedAnchorBlockName === selfHookAnchor) {
|
|
7339
7361
|
throw new Error("`wp-typia add hooked-block` cannot hook a block relative to its own block name.");
|
|
7340
7362
|
}
|
|
7341
|
-
const { blockJson, blockJsonPath } = readWorkspaceBlockJson(workspace.projectDir, blockSlug);
|
|
7363
|
+
const { blockJson, blockJsonPath } = await readWorkspaceBlockJson(workspace.projectDir, blockSlug);
|
|
7342
7364
|
const blockJsonRelativePath = path14.relative(workspace.projectDir, blockJsonPath);
|
|
7343
7365
|
const blockHooks = getMutableBlockHooks(blockJson, blockJsonRelativePath);
|
|
7344
7366
|
if (Object.prototype.hasOwnProperty.call(blockHooks, resolvedAnchorBlockName)) {
|
|
@@ -7385,4 +7407,4 @@ export {
|
|
|
7385
7407
|
ADD_BLOCK_TEMPLATE_IDS
|
|
7386
7408
|
};
|
|
7387
7409
|
|
|
7388
|
-
//# debugId=
|
|
7410
|
+
//# debugId=D2A71082E757E7C764756E2164756E21
|