wp-typia 0.20.4 → 0.20.5
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/dist-bunli/.bunli/commands.gen.js +286 -246
- package/dist-bunli/{cli-add-a27wjrk4.js → cli-add-6byyahb8.js} +3 -3
- package/dist-bunli/{cli-diagnostics-db6kxv83.js → cli-diagnostics-zecc6w1f.js} +1 -1
- package/dist-bunli/{cli-doctor-31djnnxs.js → cli-doctor-2bc4sq7v.js} +1 -1
- package/dist-bunli/{cli-c5021kqy.js → cli-j1tyw390.js} +249 -212
- package/dist-bunli/{cli-scaffold-r0yxfhbq.js → cli-scaffold-19gyvxxt.js} +1 -1
- package/dist-bunli/{cli-68145vb5.js → cli-xnh2s5kz.js} +4 -4
- package/dist-bunli/{cli-jcd4wgam.js → cli-xxzpb58s.js} +6 -2
- package/dist-bunli/cli.js +4 -4
- package/dist-bunli/{command-list-kx7q3f18.js → command-list-pztcgga5.js} +8 -8
- package/dist-bunli/node-cli.js +3 -3
- package/package.json +2 -2
|
@@ -35481,7 +35481,10 @@ function inferCliDiagnosticCode(options) {
|
|
|
35481
35481
|
if (/requires <|requires --|requires a value/u.test(haystack)) {
|
|
35482
35482
|
return CLI_DIAGNOSTIC_CODES.MISSING_ARGUMENT;
|
|
35483
35483
|
}
|
|
35484
|
-
if (/Unknown
|
|
35484
|
+
if (/Unknown (?:add-block )?template\s+(?:"|\\")/u.test(haystack)) {
|
|
35485
|
+
return CLI_DIAGNOSTIC_CODES.UNKNOWN_TEMPLATE;
|
|
35486
|
+
}
|
|
35487
|
+
if (/Unknown .*subcommand|Unknown add kind|removed in favor|does not support|The Bun-free fallback runtime does not support|The positional alias only accepts/u.test(haystack)) {
|
|
35485
35488
|
return haystack.includes("does not support") || haystack.includes("The Bun-free fallback runtime does not support") ? CLI_DIAGNOSTIC_CODES.UNSUPPORTED_COMMAND : CLI_DIAGNOSTIC_CODES.INVALID_COMMAND;
|
|
35486
35489
|
}
|
|
35487
35490
|
if (/Invalid |must start with|cannot hook|cannot nest|cannot use|cannot be|already defines|already exists|Expected one of/u.test(haystack)) {
|
|
@@ -35577,6 +35580,7 @@ var init_cli_diagnostics = __esm(() => {
|
|
|
35577
35580
|
OUTSIDE_PROJECT_ROOT: "outside-project-root",
|
|
35578
35581
|
TEMPLATE_SOURCE_TIMEOUT: "template-source-timeout",
|
|
35579
35582
|
TEMPLATE_SOURCE_TOO_LARGE: "template-source-too-large",
|
|
35583
|
+
UNKNOWN_TEMPLATE: "unknown-template",
|
|
35580
35584
|
UNSUPPORTED_COMMAND: "unsupported-command"
|
|
35581
35585
|
};
|
|
35582
35586
|
DEFAULT_CLI_FAILURE_SUMMARIES = {
|
|
@@ -223023,6 +223027,13 @@ import { promises as fsp13 } from "fs";
|
|
|
223023
223027
|
import { createRequire as createRequire3 } from "module";
|
|
223024
223028
|
import path43 from "path";
|
|
223025
223029
|
import { spawnSync as spawnSync3 } from "child_process";
|
|
223030
|
+
function getUnknownNpmTemplateMessage(templateId) {
|
|
223031
|
+
return [
|
|
223032
|
+
`Unknown template "${templateId}". Expected one of: ${USER_FACING_TEMPLATE_IDS.join(", ")}.`,
|
|
223033
|
+
"Run `wp-typia templates list` to inspect available templates.",
|
|
223034
|
+
"If you meant an npm template package, verify the package name and configured npm registry."
|
|
223035
|
+
].join(" ");
|
|
223036
|
+
}
|
|
223026
223037
|
function selectRegistryVersion(metadata2, locator) {
|
|
223027
223038
|
const distTags = isPlainObject3(metadata2["dist-tags"]) ? metadata2["dist-tags"] : {};
|
|
223028
223039
|
const versions2 = isPlainObject3(metadata2.versions) ? metadata2.versions : {};
|
|
@@ -223061,6 +223072,9 @@ async function fetchNpmTemplateSource(locator) {
|
|
|
223061
223072
|
label: metadataLabel
|
|
223062
223073
|
});
|
|
223063
223074
|
if (!metadataResponse.ok) {
|
|
223075
|
+
if (metadataResponse.status === 404) {
|
|
223076
|
+
throw new Error(getUnknownNpmTemplateMessage(locator.raw));
|
|
223077
|
+
}
|
|
223064
223078
|
throw new Error(`Failed to fetch npm template metadata for ${locator.raw}: ${metadataResponse.status}`);
|
|
223065
223079
|
}
|
|
223066
223080
|
const metadata2 = await readJsonResponseWithLimit(metadataResponse, {
|
|
@@ -223253,7 +223267,7 @@ async function resolveTemplateSeed(locator, cwd) {
|
|
|
223253
223267
|
}
|
|
223254
223268
|
return fetchNpmTemplateSource(locator.locator);
|
|
223255
223269
|
}
|
|
223256
|
-
var import_semver;
|
|
223270
|
+
var import_semver, USER_FACING_TEMPLATE_IDS;
|
|
223257
223271
|
var init_template_source_seeds = __esm(() => {
|
|
223258
223272
|
init_index_min();
|
|
223259
223273
|
init_external_template_guards();
|
|
@@ -223261,6 +223275,10 @@ var init_template_source_seeds = __esm(() => {
|
|
|
223261
223275
|
init_object_utils();
|
|
223262
223276
|
init_temp_roots();
|
|
223263
223277
|
import_semver = __toESM(require_semver2(), 1);
|
|
223278
|
+
USER_FACING_TEMPLATE_IDS = [
|
|
223279
|
+
...TEMPLATE_IDS,
|
|
223280
|
+
OFFICIAL_WORKSPACE_TEMPLATE_ALIAS
|
|
223281
|
+
];
|
|
223264
223282
|
});
|
|
223265
223283
|
|
|
223266
223284
|
// ../wp-typia-project-tools/src/runtime/cli-validation.ts
|
|
@@ -228275,6 +228293,7 @@ var init_block_generator_service = __esm(() => {
|
|
|
228275
228293
|
|
|
228276
228294
|
// ../wp-typia-project-tools/src/runtime/scaffold-answer-resolution.ts
|
|
228277
228295
|
import { execSync as execSync4 } from "child_process";
|
|
228296
|
+
import path45 from "path";
|
|
228278
228297
|
function detectAuthor() {
|
|
228279
228298
|
try {
|
|
228280
228299
|
return execSync4("git config user.name", {
|
|
@@ -228325,8 +228344,14 @@ function normalizeQueryPostType(value2) {
|
|
|
228325
228344
|
function normalizeTemplateSelection(templateId) {
|
|
228326
228345
|
return templateId === WORKSPACE_TEMPLATE_ALIAS ? OFFICIAL_WORKSPACE_TEMPLATE_PACKAGE : templateId;
|
|
228327
228346
|
}
|
|
228347
|
+
function looksLikeWindowsAbsoluteTemplatePath(templateId) {
|
|
228348
|
+
return /^[a-z]:[\\/]/iu.test(templateId) || /^\\\\[^\\]+\\[^\\]+/u.test(templateId);
|
|
228349
|
+
}
|
|
228350
|
+
function looksLikeExplicitNonNpmExternalTemplateLocator(templateId) {
|
|
228351
|
+
return path45.isAbsolute(templateId) || looksLikeWindowsAbsoluteTemplatePath(templateId) || templateId.startsWith("./") || templateId.startsWith("../") || templateId.startsWith("@") || templateId.startsWith("github:") || templateId.includes("/");
|
|
228352
|
+
}
|
|
228328
228353
|
function looksLikeExplicitExternalTemplateLocator(templateId) {
|
|
228329
|
-
return
|
|
228354
|
+
return looksLikeExplicitNonNpmExternalTemplateLocator(templateId) || parseNpmTemplateLocator(templateId) !== null;
|
|
228330
228355
|
}
|
|
228331
228356
|
function getEditDistance(left, right) {
|
|
228332
228357
|
const previous = Array.from({ length: right.length + 1 }, (_3, index) => index);
|
|
@@ -228345,7 +228370,7 @@ function getEditDistance(left, right) {
|
|
|
228345
228370
|
}
|
|
228346
228371
|
function findMistypedBuiltInTemplateSuggestion(templateId) {
|
|
228347
228372
|
const normalizedTemplateId = templateId.trim().toLowerCase();
|
|
228348
|
-
if (normalizedTemplateId.length === 0 ||
|
|
228373
|
+
if (normalizedTemplateId.length === 0 || looksLikeExplicitNonNpmExternalTemplateLocator(normalizedTemplateId)) {
|
|
228349
228374
|
return null;
|
|
228350
228375
|
}
|
|
228351
228376
|
let bestCandidate = null;
|
|
@@ -228368,6 +228393,13 @@ function getMistypedBuiltInTemplateMessage(templateId) {
|
|
|
228368
228393
|
const suggestionDescription = suggestion === WORKSPACE_TEMPLATE_ALIAS ? "official workspace scaffold" : "built-in scaffold";
|
|
228369
228394
|
return `Unknown template "${templateId}". Did you mean "${suggestion}"? Use \`--template ${suggestion}\` for the ${suggestionDescription}, or pass a local path, \`github:owner/repo/path[#ref]\`, or an npm package spec for an external template.`;
|
|
228370
228395
|
}
|
|
228396
|
+
function getUnknownTemplateMessage(templateId) {
|
|
228397
|
+
return [
|
|
228398
|
+
`Unknown template "${templateId}". Expected one of: ${USER_FACING_TEMPLATE_IDS2.join(", ")}.`,
|
|
228399
|
+
"Run `wp-typia templates list` to inspect available templates.",
|
|
228400
|
+
"Pass an explicit external template locator such as `./path`, `github:owner/repo/path[#ref]`, or `@scope/template` for custom templates."
|
|
228401
|
+
].join(" ");
|
|
228402
|
+
}
|
|
228371
228403
|
async function resolveTemplateId({
|
|
228372
228404
|
templateId,
|
|
228373
228405
|
yes = false,
|
|
@@ -228389,6 +228421,9 @@ async function resolveTemplateId({
|
|
|
228389
228421
|
if (mistypedBuiltInTemplateMessage) {
|
|
228390
228422
|
throw new Error(mistypedBuiltInTemplateMessage);
|
|
228391
228423
|
}
|
|
228424
|
+
if (!looksLikeExplicitExternalTemplateLocator(normalizedTemplateId)) {
|
|
228425
|
+
throw new Error(getUnknownTemplateMessage(templateId));
|
|
228426
|
+
}
|
|
228392
228427
|
return normalizedTemplateId;
|
|
228393
228428
|
}
|
|
228394
228429
|
if (yes) {
|
|
@@ -228429,7 +228464,7 @@ async function collectScaffoldAnswers({
|
|
|
228429
228464
|
textDomain
|
|
228430
228465
|
}) {
|
|
228431
228466
|
const defaults = getDefaultAnswers(projectName, templateId);
|
|
228432
|
-
if (yes) {
|
|
228467
|
+
if (yes || !isBuiltInTemplateId(templateId) && !promptText) {
|
|
228433
228468
|
const identifiers2 = resolveScaffoldIdentifiers({
|
|
228434
228469
|
namespace: namespace ?? defaults.namespace,
|
|
228435
228470
|
phpPrefix,
|
|
@@ -228468,17 +228503,22 @@ async function collectScaffoldAnswers({
|
|
|
228468
228503
|
title: await promptText("Block title", toTitleCase(identifiers.slug))
|
|
228469
228504
|
};
|
|
228470
228505
|
}
|
|
228471
|
-
var WORKSPACE_TEMPLATE_ALIAS = "workspace", TEMPLATE_SELECTION_HINT, TEMPLATE_SUGGESTION_IDS, QUERY_POST_TYPE_RULE = 'Use lowercase, 1-20 chars, and only a-z, 0-9, "_" or "-".';
|
|
228506
|
+
var WORKSPACE_TEMPLATE_ALIAS = "workspace", TEMPLATE_SELECTION_HINT, TEMPLATE_SUGGESTION_IDS, QUERY_POST_TYPE_RULE = 'Use lowercase, 1-20 chars, and only a-z, 0-9, "_" or "-".', USER_FACING_TEMPLATE_IDS2;
|
|
228472
228507
|
var init_scaffold_answer_resolution = __esm(() => {
|
|
228473
228508
|
init_package_managers();
|
|
228474
228509
|
init_scaffold_identifiers();
|
|
228475
228510
|
init_template_registry();
|
|
228476
228511
|
init_template_defaults();
|
|
228512
|
+
init_template_source_locators();
|
|
228477
228513
|
TEMPLATE_SELECTION_HINT = `--template <${[
|
|
228478
228514
|
...TEMPLATE_IDS,
|
|
228479
228515
|
WORKSPACE_TEMPLATE_ALIAS
|
|
228480
228516
|
].join("|")}|./path|github:owner/repo/path[#ref]|npm-package>`;
|
|
228481
228517
|
TEMPLATE_SUGGESTION_IDS = [...TEMPLATE_IDS, WORKSPACE_TEMPLATE_ALIAS];
|
|
228518
|
+
USER_FACING_TEMPLATE_IDS2 = [
|
|
228519
|
+
...TEMPLATE_IDS,
|
|
228520
|
+
WORKSPACE_TEMPLATE_ALIAS
|
|
228521
|
+
];
|
|
228482
228522
|
});
|
|
228483
228523
|
|
|
228484
228524
|
// ../wp-typia-project-tools/src/runtime/scaffold-template-variables.ts
|
|
@@ -228665,7 +228705,7 @@ var init_scaffold_template_variables = __esm(() => {
|
|
|
228665
228705
|
// ../wp-typia-project-tools/src/runtime/scaffold.ts
|
|
228666
228706
|
import fs38 from "fs";
|
|
228667
228707
|
import { promises as fsp14 } from "fs";
|
|
228668
|
-
import
|
|
228708
|
+
import path46 from "path";
|
|
228669
228709
|
function isDataStorageMode(value2) {
|
|
228670
228710
|
return DATA_STORAGE_MODES.includes(value2);
|
|
228671
228711
|
}
|
|
@@ -228811,7 +228851,7 @@ async function scaffoldProject({
|
|
|
228811
228851
|
phase: "finalize-project",
|
|
228812
228852
|
title: "Finalizing scaffold output"
|
|
228813
228853
|
});
|
|
228814
|
-
const readmePath =
|
|
228854
|
+
const readmePath = path46.join(projectDir, "README.md");
|
|
228815
228855
|
if (!fs38.existsSync(readmePath)) {
|
|
228816
228856
|
await fsp14.writeFile(readmePath, buildReadme(resolvedTemplateId, variables, resolvedPackageManager, {
|
|
228817
228857
|
withMigrationUi: isBuiltInTemplate || isWorkspace ? withMigrationUi : false,
|
|
@@ -228819,7 +228859,7 @@ async function scaffoldProject({
|
|
|
228819
228859
|
withWpEnv: isBuiltInTemplate ? withWpEnv : false
|
|
228820
228860
|
}), "utf8");
|
|
228821
228861
|
}
|
|
228822
|
-
const gitignorePath =
|
|
228862
|
+
const gitignorePath = path46.join(projectDir, ".gitignore");
|
|
228823
228863
|
const existingGitignore = fs38.existsSync(gitignorePath) ? await fsp14.readFile(gitignorePath, "utf8") : "";
|
|
228824
228864
|
await fsp14.writeFile(gitignorePath, mergeTextLines(buildGitignore(), existingGitignore), "utf8");
|
|
228825
228865
|
await normalizePackageJson(projectDir, resolvedPackageManager);
|
|
@@ -228885,9 +228925,9 @@ var init_scaffold = __esm(() => {
|
|
|
228885
228925
|
});
|
|
228886
228926
|
|
|
228887
228927
|
// ../wp-typia-project-tools/src/runtime/cli-add-block-config.ts
|
|
228888
|
-
import
|
|
228928
|
+
import path47 from "path";
|
|
228889
228929
|
function buildServerTemplateRoot(persistencePolicy) {
|
|
228890
|
-
return
|
|
228930
|
+
return path47.join(SHARED_WORKSPACE_TEMPLATE_ROOT, persistencePolicy === "public" ? "persistence-public" : "persistence-auth");
|
|
228891
228931
|
}
|
|
228892
228932
|
function buildSingleBlockConfigEntry(variables) {
|
|
228893
228933
|
return [
|
|
@@ -229037,7 +229077,7 @@ var init_cli_add_block_config = __esm(() => {
|
|
|
229037
229077
|
// ../wp-typia-project-tools/src/runtime/cli-add-block-legacy-validator.ts
|
|
229038
229078
|
import fs39 from "fs";
|
|
229039
229079
|
import { promises as fsp15 } from "fs";
|
|
229040
|
-
import
|
|
229080
|
+
import path48 from "path";
|
|
229041
229081
|
function ensureBlockConfigCanAddRestManifests(source) {
|
|
229042
229082
|
const importLine = "import { defineEndpointManifest } from '@wp-typia/block-runtime/metadata-core';";
|
|
229043
229083
|
if (REST_MANIFEST_IMPORT_PATTERN.test(source)) {
|
|
@@ -229139,22 +229179,22 @@ function renderLegacyManifestDefaultsWrapperSource() {
|
|
|
229139
229179
|
`);
|
|
229140
229180
|
}
|
|
229141
229181
|
async function ensureLegacyCompoundValidatorManifestDefaultsWrapper(validatorPath) {
|
|
229142
|
-
const validatorDir =
|
|
229143
|
-
const wrapperPath =
|
|
229144
|
-
const manifestPath =
|
|
229182
|
+
const validatorDir = path48.dirname(validatorPath);
|
|
229183
|
+
const wrapperPath = path48.join(validatorDir, "manifest-defaults-document.ts");
|
|
229184
|
+
const manifestPath = path48.join(validatorDir, "typia.manifest.json");
|
|
229145
229185
|
if (fs39.existsSync(wrapperPath) || !fs39.existsSync(manifestPath)) {
|
|
229146
229186
|
return;
|
|
229147
229187
|
}
|
|
229148
229188
|
await fsp15.writeFile(wrapperPath, renderLegacyManifestDefaultsWrapperSource(), "utf8");
|
|
229149
229189
|
}
|
|
229150
229190
|
async function collectLegacyCompoundValidatorPaths(projectDir) {
|
|
229151
|
-
const blocksDir =
|
|
229191
|
+
const blocksDir = path48.join(projectDir, "src", "blocks");
|
|
229152
229192
|
if (!fs39.existsSync(blocksDir)) {
|
|
229153
229193
|
return [];
|
|
229154
229194
|
}
|
|
229155
229195
|
const blockEntries = await fsp15.readdir(blocksDir, { withFileTypes: true });
|
|
229156
229196
|
const validatorPaths = await Promise.all(blockEntries.filter((entry) => entry.isDirectory()).map(async (entry) => {
|
|
229157
|
-
const validatorPath =
|
|
229197
|
+
const validatorPath = path48.join(blocksDir, entry.name, "validators.ts");
|
|
229158
229198
|
const validatorSource = await readOptionalFile(validatorPath);
|
|
229159
229199
|
return isLegacyCompoundValidatorSource(validatorSource) ? validatorPath : null;
|
|
229160
229200
|
}));
|
|
@@ -229162,14 +229202,14 @@ async function collectLegacyCompoundValidatorPaths(projectDir) {
|
|
|
229162
229202
|
}
|
|
229163
229203
|
async function ensureCompoundWorkspaceSupportFiles(projectDir, tempProjectDir, legacyValidatorPaths) {
|
|
229164
229204
|
for (const fileName of COMPOUND_SHARED_SUPPORT_FILES) {
|
|
229165
|
-
const sourcePath =
|
|
229205
|
+
const sourcePath = path48.join(tempProjectDir, "src", fileName);
|
|
229166
229206
|
if (!fs39.existsSync(sourcePath)) {
|
|
229167
229207
|
continue;
|
|
229168
229208
|
}
|
|
229169
|
-
const targetPath =
|
|
229209
|
+
const targetPath = path48.join(projectDir, "src", fileName);
|
|
229170
229210
|
const currentSource = await readOptionalFile(targetPath);
|
|
229171
229211
|
if (fileName === "validator-toolkit.ts" ? shouldRefreshCompoundValidatorToolkit(currentSource) : currentSource === null) {
|
|
229172
|
-
await fsp15.mkdir(
|
|
229212
|
+
await fsp15.mkdir(path48.dirname(targetPath), { recursive: true });
|
|
229173
229213
|
await fsp15.copyFile(sourcePath, targetPath);
|
|
229174
229214
|
}
|
|
229175
229215
|
}
|
|
@@ -229254,7 +229294,7 @@ var init_external_layer_selection = __esm(() => {
|
|
|
229254
229294
|
// ../wp-typia-project-tools/src/runtime/cli-add-block.ts
|
|
229255
229295
|
import fs40 from "fs";
|
|
229256
229296
|
import { promises as fsp16 } from "fs";
|
|
229257
|
-
import
|
|
229297
|
+
import path49 from "path";
|
|
229258
229298
|
import {
|
|
229259
229299
|
syncBlockMetadata
|
|
229260
229300
|
} from "@wp-typia/block-runtime/metadata-core";
|
|
@@ -229276,16 +229316,16 @@ ${source}`;
|
|
|
229276
229316
|
});
|
|
229277
229317
|
}
|
|
229278
229318
|
async function copyTempDirectory(sourceDir, targetDir) {
|
|
229279
|
-
await fsp16.mkdir(
|
|
229319
|
+
await fsp16.mkdir(path49.dirname(targetDir), { recursive: true });
|
|
229280
229320
|
await fsp16.cp(sourceDir, targetDir, { recursive: true });
|
|
229281
229321
|
}
|
|
229282
229322
|
async function addCollectionImportsForTemplate(projectDir, templateId, variables) {
|
|
229283
229323
|
if (templateId === "compound") {
|
|
229284
|
-
await ensureCollectionImport(
|
|
229285
|
-
await ensureCollectionImport(
|
|
229324
|
+
await ensureCollectionImport(path49.join(projectDir, "src", "blocks", variables.slugKebabCase, "index.tsx"));
|
|
229325
|
+
await ensureCollectionImport(path49.join(projectDir, "src", "blocks", `${variables.slugKebabCase}-item`, "index.tsx"));
|
|
229286
229326
|
return;
|
|
229287
229327
|
}
|
|
229288
|
-
await ensureCollectionImport(
|
|
229328
|
+
await ensureCollectionImport(path49.join(projectDir, "src", "blocks", variables.slugKebabCase, "index.tsx"));
|
|
229289
229329
|
}
|
|
229290
229330
|
async function appendBlockConfigEntries(projectDir, entries, needsRestManifestImport) {
|
|
229291
229331
|
await appendWorkspaceInventoryEntries(projectDir, {
|
|
@@ -229294,12 +229334,12 @@ async function appendBlockConfigEntries(projectDir, entries, needsRestManifestIm
|
|
|
229294
229334
|
});
|
|
229295
229335
|
}
|
|
229296
229336
|
async function renderWorkspacePersistenceServerModule(projectDir, variables) {
|
|
229297
|
-
const targetDir =
|
|
229337
|
+
const targetDir = path49.join(projectDir, "src", "blocks", variables.slugKebabCase);
|
|
229298
229338
|
const templateDir = buildServerTemplateRoot(variables.persistencePolicy);
|
|
229299
229339
|
await copyInterpolatedDirectory(templateDir, targetDir, variables);
|
|
229300
229340
|
}
|
|
229301
229341
|
function hasInstalledWorkspaceDependencies(projectDir) {
|
|
229302
|
-
return WORKSPACE_INSTALL_MARKERS.some((marker) => fs40.existsSync(
|
|
229342
|
+
return WORKSPACE_INSTALL_MARKERS.some((marker) => fs40.existsSync(path49.join(projectDir, marker)));
|
|
229303
229343
|
}
|
|
229304
229344
|
function assertWorkspaceDependenciesInstalled(workspace) {
|
|
229305
229345
|
if (hasInstalledWorkspaceDependencies(workspace.projectDir)) {
|
|
@@ -229310,14 +229350,14 @@ function assertWorkspaceDependenciesInstalled(workspace) {
|
|
|
229310
229350
|
async function copyScaffoldedBlockSlice(projectDir, templateId, tempProjectDir, variables, legacyValidatorPaths = []) {
|
|
229311
229351
|
if (templateId === "compound") {
|
|
229312
229352
|
await ensureCompoundWorkspaceSupportFiles(projectDir, tempProjectDir, legacyValidatorPaths);
|
|
229313
|
-
await copyTempDirectory(
|
|
229314
|
-
await copyTempDirectory(
|
|
229353
|
+
await copyTempDirectory(path49.join(tempProjectDir, "src", "blocks", variables.slugKebabCase), path49.join(projectDir, "src", "blocks", variables.slugKebabCase));
|
|
229354
|
+
await copyTempDirectory(path49.join(tempProjectDir, "src", "blocks", `${variables.slugKebabCase}-item`), path49.join(projectDir, "src", "blocks", `${variables.slugKebabCase}-item`));
|
|
229315
229355
|
if (variables.compoundPersistenceEnabled === "true") {
|
|
229316
229356
|
await renderWorkspacePersistenceServerModule(projectDir, variables);
|
|
229317
229357
|
}
|
|
229318
229358
|
return;
|
|
229319
229359
|
}
|
|
229320
|
-
await copyTempDirectory(
|
|
229360
|
+
await copyTempDirectory(path49.join(tempProjectDir, "src"), path49.join(projectDir, "src", "blocks", variables.slugKebabCase));
|
|
229321
229361
|
if (templateId === "persistence") {
|
|
229322
229362
|
await renderWorkspacePersistenceServerModule(projectDir, variables);
|
|
229323
229363
|
}
|
|
@@ -229368,21 +229408,21 @@ async function assertAddBlockSupportsExternalLayerOutputs(options) {
|
|
|
229368
229408
|
function collectWorkspaceBlockPaths(projectDir, templateId, variables) {
|
|
229369
229409
|
if (templateId === "compound") {
|
|
229370
229410
|
return [
|
|
229371
|
-
|
|
229372
|
-
|
|
229411
|
+
path49.join(projectDir, "src", "blocks", variables.slugKebabCase),
|
|
229412
|
+
path49.join(projectDir, "src", "blocks", `${variables.slugKebabCase}-item`)
|
|
229373
229413
|
];
|
|
229374
229414
|
}
|
|
229375
|
-
return [
|
|
229415
|
+
return [path49.join(projectDir, "src", "blocks", variables.slugKebabCase)];
|
|
229376
229416
|
}
|
|
229377
229417
|
function assertBlockTargetsDoNotExist(projectDir, templateId, variables) {
|
|
229378
229418
|
for (const targetPath of collectWorkspaceBlockPaths(projectDir, templateId, variables)) {
|
|
229379
229419
|
if (fs40.existsSync(targetPath)) {
|
|
229380
|
-
throw new Error(`A block already exists at ${
|
|
229420
|
+
throw new Error(`A block already exists at ${path49.relative(projectDir, targetPath)}. Choose a different name.`);
|
|
229381
229421
|
}
|
|
229382
229422
|
}
|
|
229383
229423
|
}
|
|
229384
229424
|
async function updateWorkspaceMigrationConfigIfPresent(projectDir, newBlocks) {
|
|
229385
|
-
const configPath =
|
|
229425
|
+
const configPath = path49.join(projectDir, "src", "migrations", "config.ts");
|
|
229386
229426
|
if (!fs40.existsSync(configPath)) {
|
|
229387
229427
|
return;
|
|
229388
229428
|
}
|
|
@@ -229403,10 +229443,10 @@ async function updateWorkspaceMigrationConfigIfPresent(projectDir, newBlocks) {
|
|
|
229403
229443
|
}
|
|
229404
229444
|
async function syncWorkspaceBlockMetadata(projectDir, slug, sourceTypeName, typesFile) {
|
|
229405
229445
|
await syncBlockMetadata({
|
|
229406
|
-
blockJsonFile:
|
|
229407
|
-
jsonSchemaFile:
|
|
229408
|
-
manifestFile:
|
|
229409
|
-
openApiFile:
|
|
229446
|
+
blockJsonFile: path49.join("src", "blocks", slug, "block.json"),
|
|
229447
|
+
jsonSchemaFile: path49.join("src", "blocks", slug, "typia.schema.json"),
|
|
229448
|
+
manifestFile: path49.join("src", "blocks", slug, "typia.manifest.json"),
|
|
229449
|
+
openApiFile: path49.join("src", "blocks", slug, "typia.openapi.json"),
|
|
229410
229450
|
projectRoot: projectDir,
|
|
229411
229451
|
sourceTypeName,
|
|
229412
229452
|
typesFile
|
|
@@ -229414,16 +229454,16 @@ async function syncWorkspaceBlockMetadata(projectDir, slug, sourceTypeName, type
|
|
|
229414
229454
|
}
|
|
229415
229455
|
async function syncWorkspacePersistenceArtifacts(projectDir, variables) {
|
|
229416
229456
|
await syncPersistenceRestArtifacts({
|
|
229417
|
-
apiTypesFile:
|
|
229418
|
-
outputDir:
|
|
229457
|
+
apiTypesFile: path49.join("src", "blocks", variables.slugKebabCase, "api-types.ts"),
|
|
229458
|
+
outputDir: path49.join("src", "blocks", variables.slugKebabCase),
|
|
229419
229459
|
projectDir,
|
|
229420
229460
|
variables
|
|
229421
229461
|
});
|
|
229422
229462
|
}
|
|
229423
229463
|
async function syncWorkspaceAddedBlockArtifacts(projectDir, templateId, variables) {
|
|
229424
|
-
await syncWorkspaceBlockMetadata(projectDir, variables.slugKebabCase, `${variables.pascalCase}Attributes`,
|
|
229464
|
+
await syncWorkspaceBlockMetadata(projectDir, variables.slugKebabCase, `${variables.pascalCase}Attributes`, path49.join("src", "blocks", variables.slugKebabCase, "types.ts"));
|
|
229425
229465
|
if (templateId === "compound") {
|
|
229426
|
-
await syncWorkspaceBlockMetadata(projectDir, `${variables.slugKebabCase}-item`, `${variables.pascalCase}ItemAttributes`,
|
|
229466
|
+
await syncWorkspaceBlockMetadata(projectDir, `${variables.slugKebabCase}-item`, `${variables.pascalCase}ItemAttributes`, path49.join("src", "blocks", `${variables.slugKebabCase}-item`, "types.ts"));
|
|
229427
229467
|
}
|
|
229428
229468
|
if (templateId === "persistence" || templateId === "compound" && variables.compoundPersistenceEnabled === "true") {
|
|
229429
229469
|
await syncWorkspacePersistenceArtifacts(projectDir, variables);
|
|
@@ -229484,7 +229524,7 @@ async function runAddBlockCommand({
|
|
|
229484
229524
|
throw new Error("`wp-typia add block --template query-loop` is not supported. Query Loop is a create-time `core/query` variation scaffold, so use `wp-typia create <project-dir> --template query-loop` instead.");
|
|
229485
229525
|
}
|
|
229486
229526
|
if (!isAddBlockTemplateId(templateId)) {
|
|
229487
|
-
throw new Error(`Unknown add-block template "${templateId}". Expected one of: ${ADD_BLOCK_TEMPLATE_IDS.join(", ")}
|
|
229527
|
+
throw new Error(`Unknown add-block template "${templateId}". Expected one of: ${ADD_BLOCK_TEMPLATE_IDS.join(", ")}. Run \`wp-typia templates list\` to inspect available templates.`);
|
|
229488
229528
|
}
|
|
229489
229529
|
const resolvedTemplateId = templateId;
|
|
229490
229530
|
assertPersistenceFlagsAllowed(resolvedTemplateId, {
|
|
@@ -229525,13 +229565,13 @@ async function runAddBlockCommand({
|
|
|
229525
229565
|
path: tempRoot,
|
|
229526
229566
|
cleanup: cleanupTempRoot
|
|
229527
229567
|
} = await createManagedTempRoot("wp-typia-add-block-"));
|
|
229528
|
-
const tempProjectDir =
|
|
229529
|
-
const blockConfigPath =
|
|
229530
|
-
const migrationConfigPath =
|
|
229568
|
+
const tempProjectDir = path49.join(tempRoot, normalizedSlug);
|
|
229569
|
+
const blockConfigPath = path49.join(workspace.projectDir, "scripts", "block-config.ts");
|
|
229570
|
+
const migrationConfigPath = path49.join(workspace.projectDir, "src", "migrations", "config.ts");
|
|
229531
229571
|
const blockPhpPrefix = buildWorkspacePhpPrefix(workspace.workspace.phpPrefix, normalizedSlug);
|
|
229532
229572
|
const migrationConfigSource = await readOptionalFile(migrationConfigPath);
|
|
229533
229573
|
const migrationConfig = migrationConfigSource === null ? null : parseMigrationConfig(migrationConfigSource);
|
|
229534
|
-
const compoundSupportPaths = resolvedTemplateId === "compound" ? COMPOUND_SHARED_SUPPORT_FILES.map((fileName) =>
|
|
229574
|
+
const compoundSupportPaths = resolvedTemplateId === "compound" ? COMPOUND_SHARED_SUPPORT_FILES.map((fileName) => path49.join(workspace.projectDir, "src", fileName)) : [];
|
|
229535
229575
|
const legacyCompoundValidatorPaths = resolvedTemplateId === "compound" ? await collectLegacyCompoundValidatorPaths(workspace.projectDir) : [];
|
|
229536
229576
|
const result = await (async () => {
|
|
229537
229577
|
const scaffoldResult = await scaffoldProject({
|
|
@@ -229574,7 +229614,7 @@ async function runAddBlockCommand({
|
|
|
229574
229614
|
...compoundSupportPaths,
|
|
229575
229615
|
...legacyCompoundValidatorPaths
|
|
229576
229616
|
]),
|
|
229577
|
-
snapshotDirs: migrationConfig === null ? [] : buildMigrationBlocks2(resolvedTemplateId, result.variables).map((block) =>
|
|
229617
|
+
snapshotDirs: migrationConfig === null ? [] : buildMigrationBlocks2(resolvedTemplateId, result.variables).map((block) => path49.join(workspace.projectDir, ...migrationConfig.snapshotDir.split("/"), migrationConfig.currentMigrationVersion, block.key)),
|
|
229578
229618
|
targetPaths: collectWorkspaceBlockPaths(workspace.projectDir, resolvedTemplateId, result.variables)
|
|
229579
229619
|
};
|
|
229580
229620
|
try {
|
|
@@ -229584,7 +229624,7 @@ async function runAddBlockCommand({
|
|
|
229584
229624
|
await syncWorkspaceAddedBlockArtifacts(workspace.projectDir, resolvedTemplateId, result.variables);
|
|
229585
229625
|
await updateWorkspaceMigrationConfigIfPresent(workspace.projectDir, buildMigrationBlocks2(resolvedTemplateId, result.variables));
|
|
229586
229626
|
return {
|
|
229587
|
-
blockSlugs: collectWorkspaceBlockPaths(workspace.projectDir, resolvedTemplateId, result.variables).map((targetPath) =>
|
|
229627
|
+
blockSlugs: collectWorkspaceBlockPaths(workspace.projectDir, resolvedTemplateId, result.variables).map((targetPath) => path49.basename(targetPath)),
|
|
229588
229628
|
projectDir: workspace.projectDir,
|
|
229589
229629
|
templateId: resolvedTemplateId,
|
|
229590
229630
|
warnings: result.warnings
|
|
@@ -229628,7 +229668,7 @@ var init_cli_add_block = __esm(() => {
|
|
|
229628
229668
|
// ../wp-typia-project-tools/src/runtime/cli-add-workspace-assets.ts
|
|
229629
229669
|
import fs41 from "fs";
|
|
229630
229670
|
import { promises as fsp17 } from "fs";
|
|
229631
|
-
import
|
|
229671
|
+
import path50 from "path";
|
|
229632
229672
|
function escapeRegex3(value2) {
|
|
229633
229673
|
return value2.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
|
|
229634
229674
|
}
|
|
@@ -230010,7 +230050,7 @@ ${patternFunctions}
|
|
|
230010
230050
|
}
|
|
230011
230051
|
}
|
|
230012
230052
|
if (!nextSource.includes(patternCategoryFunctionName) || !nextSource.includes(patternRegistrationFunctionName)) {
|
|
230013
|
-
throw new Error(`Unable to inject pattern bootstrap functions into ${
|
|
230053
|
+
throw new Error(`Unable to inject pattern bootstrap functions into ${path50.basename(bootstrapPath)}.`);
|
|
230014
230054
|
}
|
|
230015
230055
|
if (!nextSource.includes(patternCategoryHook)) {
|
|
230016
230056
|
nextSource = `${nextSource.trimEnd()}
|
|
@@ -230200,7 +230240,7 @@ ${snippet}
|
|
|
230200
230240
|
if (missingReferences.length > 0) {
|
|
230201
230241
|
const replacedSource = replacePhpFunctionDefinition(nextSource, enqueueFunctionName, enqueueFunction);
|
|
230202
230242
|
if (!replacedSource) {
|
|
230203
|
-
throw new Error(`Unable to repair ${
|
|
230243
|
+
throw new Error(`Unable to repair ${path50.basename(bootstrapPath)} for ${enqueueFunctionName}.`);
|
|
230204
230244
|
}
|
|
230205
230245
|
nextSource = replacedSource;
|
|
230206
230246
|
}
|
|
@@ -230212,7 +230252,7 @@ ${snippet}
|
|
|
230212
230252
|
});
|
|
230213
230253
|
}
|
|
230214
230254
|
async function ensureEditorPluginBuildScriptAnchors(workspace) {
|
|
230215
|
-
const buildScriptPath =
|
|
230255
|
+
const buildScriptPath = path50.join(workspace.projectDir, "scripts", "build-workspace.mjs");
|
|
230216
230256
|
await patchFile(buildScriptPath, (source) => {
|
|
230217
230257
|
if (/['"]src\/editor-plugins\/index\.(?:ts|js)['"]/u.test(source)) {
|
|
230218
230258
|
return source;
|
|
@@ -230225,13 +230265,13 @@ async function ensureEditorPluginBuildScriptAnchors(workspace) {
|
|
|
230225
230265
|
'src/editor-plugins/index.js',
|
|
230226
230266
|
]`);
|
|
230227
230267
|
if (nextSource === source) {
|
|
230228
|
-
throw new Error(`Unable to update ${
|
|
230268
|
+
throw new Error(`Unable to update ${path50.relative(workspace.projectDir, buildScriptPath)} for editor plugin shared entries.`);
|
|
230229
230269
|
}
|
|
230230
230270
|
return nextSource;
|
|
230231
230271
|
});
|
|
230232
230272
|
}
|
|
230233
230273
|
async function ensureEditorPluginWebpackAnchors(workspace) {
|
|
230234
|
-
const webpackConfigPath =
|
|
230274
|
+
const webpackConfigPath = path50.join(workspace.projectDir, "webpack.config.js");
|
|
230235
230275
|
await patchFile(webpackConfigPath, (source) => {
|
|
230236
230276
|
if (/['"]editor-plugins\/index['"]/u.test(source)) {
|
|
230237
230277
|
return source;
|
|
@@ -230259,17 +230299,17 @@ async function ensureEditorPluginWebpackAnchors(workspace) {
|
|
|
230259
230299
|
}`;
|
|
230260
230300
|
const nextSource = source.replace(legacySharedEntriesBlockPattern, nextSharedEntriesBlock);
|
|
230261
230301
|
if (nextSource === source) {
|
|
230262
|
-
throw new Error(`Unable to update ${
|
|
230302
|
+
throw new Error(`Unable to update ${path50.relative(workspace.projectDir, webpackConfigPath)} for editor plugin shared entries.`);
|
|
230263
230303
|
}
|
|
230264
230304
|
return nextSource;
|
|
230265
230305
|
});
|
|
230266
230306
|
}
|
|
230267
230307
|
function resolveBindingSourceRegistryPath(projectDir) {
|
|
230268
|
-
const bindingsDir =
|
|
230269
|
-
return [
|
|
230308
|
+
const bindingsDir = path50.join(projectDir, "src", "bindings");
|
|
230309
|
+
return [path50.join(bindingsDir, "index.ts"), path50.join(bindingsDir, "index.js")].find((candidatePath) => fs41.existsSync(candidatePath)) ?? path50.join(bindingsDir, "index.ts");
|
|
230270
230310
|
}
|
|
230271
230311
|
async function writeBindingSourceRegistry(projectDir, bindingSourceSlug) {
|
|
230272
|
-
const bindingsDir =
|
|
230312
|
+
const bindingsDir = path50.join(projectDir, "src", "bindings");
|
|
230273
230313
|
const bindingsIndexPath = resolveBindingSourceRegistryPath(projectDir);
|
|
230274
230314
|
await fsp17.mkdir(bindingsDir, { recursive: true });
|
|
230275
230315
|
const existingBindingSourceSlugs = fs41.readdirSync(bindingsDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
@@ -230277,11 +230317,11 @@ async function writeBindingSourceRegistry(projectDir, bindingSourceSlug) {
|
|
|
230277
230317
|
await fsp17.writeFile(bindingsIndexPath, buildBindingSourceIndexSource(nextBindingSourceSlugs), "utf8");
|
|
230278
230318
|
}
|
|
230279
230319
|
function resolveEditorPluginRegistryPath(projectDir) {
|
|
230280
|
-
const editorPluginsDir =
|
|
230320
|
+
const editorPluginsDir = path50.join(projectDir, "src", "editor-plugins");
|
|
230281
230321
|
return [
|
|
230282
|
-
|
|
230283
|
-
|
|
230284
|
-
].find((candidatePath) => fs41.existsSync(candidatePath)) ??
|
|
230322
|
+
path50.join(editorPluginsDir, "index.ts"),
|
|
230323
|
+
path50.join(editorPluginsDir, "index.js")
|
|
230324
|
+
].find((candidatePath) => fs41.existsSync(candidatePath)) ?? path50.join(editorPluginsDir, "index.ts");
|
|
230285
230325
|
}
|
|
230286
230326
|
function readEditorPluginRegistrySlugs(registryPath) {
|
|
230287
230327
|
if (!fs41.existsSync(registryPath)) {
|
|
@@ -230291,7 +230331,7 @@ function readEditorPluginRegistrySlugs(registryPath) {
|
|
|
230291
230331
|
return Array.from(source.matchAll(/^\s*import\s+['"]\.\/([^/'"]+)(?:\/index(?:\.[cm]?[jt]sx?)?)?['"];?\s*$/gmu)).map((match3) => match3[1]);
|
|
230292
230332
|
}
|
|
230293
230333
|
async function writeEditorPluginRegistry(projectDir, editorPluginSlug) {
|
|
230294
|
-
const editorPluginsDir =
|
|
230334
|
+
const editorPluginsDir = path50.join(projectDir, "src", "editor-plugins");
|
|
230295
230335
|
const registryPath = resolveEditorPluginRegistryPath(projectDir);
|
|
230296
230336
|
await fsp17.mkdir(editorPluginsDir, { recursive: true });
|
|
230297
230337
|
const existingEditorPluginSlugs = readWorkspaceInventory(projectDir).editorPlugins.map((entry) => entry.slug);
|
|
@@ -230309,17 +230349,17 @@ async function runAddEditorPluginCommand({
|
|
|
230309
230349
|
const resolvedSlot = assertValidEditorPluginSlot(slot);
|
|
230310
230350
|
const inventory = readWorkspaceInventory(workspace.projectDir);
|
|
230311
230351
|
assertEditorPluginDoesNotExist(workspace.projectDir, editorPluginSlug, inventory);
|
|
230312
|
-
const blockConfigPath =
|
|
230352
|
+
const blockConfigPath = path50.join(workspace.projectDir, "scripts", "block-config.ts");
|
|
230313
230353
|
const bootstrapPath = getWorkspaceBootstrapPath(workspace);
|
|
230314
|
-
const buildScriptPath =
|
|
230354
|
+
const buildScriptPath = path50.join(workspace.projectDir, "scripts", "build-workspace.mjs");
|
|
230315
230355
|
const editorPluginsIndexPath = resolveEditorPluginRegistryPath(workspace.projectDir);
|
|
230316
|
-
const webpackConfigPath =
|
|
230317
|
-
const editorPluginDir =
|
|
230318
|
-
const entryFilePath =
|
|
230319
|
-
const sidebarFilePath =
|
|
230320
|
-
const dataFilePath =
|
|
230321
|
-
const typesFilePath =
|
|
230322
|
-
const styleFilePath =
|
|
230356
|
+
const webpackConfigPath = path50.join(workspace.projectDir, "webpack.config.js");
|
|
230357
|
+
const editorPluginDir = path50.join(workspace.projectDir, "src", "editor-plugins", editorPluginSlug);
|
|
230358
|
+
const entryFilePath = path50.join(editorPluginDir, "index.tsx");
|
|
230359
|
+
const sidebarFilePath = path50.join(editorPluginDir, "Sidebar.tsx");
|
|
230360
|
+
const dataFilePath = path50.join(editorPluginDir, "data.ts");
|
|
230361
|
+
const typesFilePath = path50.join(editorPluginDir, "types.ts");
|
|
230362
|
+
const styleFilePath = path50.join(editorPluginDir, "style.scss");
|
|
230323
230363
|
const mutationSnapshot = {
|
|
230324
230364
|
fileSources: await snapshotWorkspaceFiles([
|
|
230325
230365
|
blockConfigPath,
|
|
@@ -230365,16 +230405,16 @@ async function runAddPatternCommand({
|
|
|
230365
230405
|
const patternSlug = assertValidGeneratedSlug("Pattern name", normalizeBlockSlug(patternName), "wp-typia add pattern <name>");
|
|
230366
230406
|
const inventory = readWorkspaceInventory(workspace.projectDir);
|
|
230367
230407
|
assertPatternDoesNotExist(workspace.projectDir, patternSlug, inventory);
|
|
230368
|
-
const blockConfigPath =
|
|
230408
|
+
const blockConfigPath = path50.join(workspace.projectDir, "scripts", "block-config.ts");
|
|
230369
230409
|
const bootstrapPath = getWorkspaceBootstrapPath(workspace);
|
|
230370
|
-
const patternFilePath =
|
|
230410
|
+
const patternFilePath = path50.join(workspace.projectDir, "src", "patterns", `${patternSlug}.php`);
|
|
230371
230411
|
const mutationSnapshot = {
|
|
230372
230412
|
fileSources: await snapshotWorkspaceFiles([blockConfigPath, bootstrapPath]),
|
|
230373
230413
|
snapshotDirs: [],
|
|
230374
230414
|
targetPaths: [patternFilePath]
|
|
230375
230415
|
};
|
|
230376
230416
|
try {
|
|
230377
|
-
await fsp17.mkdir(
|
|
230417
|
+
await fsp17.mkdir(path50.dirname(patternFilePath), { recursive: true });
|
|
230378
230418
|
await ensurePatternBootstrapAnchors(workspace);
|
|
230379
230419
|
await fsp17.writeFile(patternFilePath, buildPatternSource(patternSlug, workspace.workspace.namespace, workspace.workspace.textDomain), "utf8");
|
|
230380
230420
|
await appendWorkspaceInventoryEntries(workspace.projectDir, {
|
|
@@ -230397,12 +230437,12 @@ async function runAddBindingSourceCommand({
|
|
|
230397
230437
|
const bindingSourceSlug = assertValidGeneratedSlug("Binding source name", normalizeBlockSlug(bindingSourceName), "wp-typia add binding-source <name>");
|
|
230398
230438
|
const inventory = readWorkspaceInventory(workspace.projectDir);
|
|
230399
230439
|
assertBindingSourceDoesNotExist(workspace.projectDir, bindingSourceSlug, inventory);
|
|
230400
|
-
const blockConfigPath =
|
|
230440
|
+
const blockConfigPath = path50.join(workspace.projectDir, "scripts", "block-config.ts");
|
|
230401
230441
|
const bootstrapPath = getWorkspaceBootstrapPath(workspace);
|
|
230402
230442
|
const bindingsIndexPath = resolveBindingSourceRegistryPath(workspace.projectDir);
|
|
230403
|
-
const bindingSourceDir =
|
|
230404
|
-
const serverFilePath =
|
|
230405
|
-
const editorFilePath =
|
|
230443
|
+
const bindingSourceDir = path50.join(workspace.projectDir, "src", "bindings", bindingSourceSlug);
|
|
230444
|
+
const serverFilePath = path50.join(bindingSourceDir, "server.php");
|
|
230445
|
+
const editorFilePath = path50.join(bindingSourceDir, "editor.ts");
|
|
230406
230446
|
const mutationSnapshot = {
|
|
230407
230447
|
fileSources: await snapshotWorkspaceFiles([blockConfigPath, bootstrapPath, bindingsIndexPath]),
|
|
230408
230448
|
snapshotDirs: [],
|
|
@@ -230434,7 +230474,7 @@ var init_cli_add_workspace_assets = __esm(() => {
|
|
|
230434
230474
|
});
|
|
230435
230475
|
|
|
230436
230476
|
// ../wp-typia-project-tools/src/runtime/cli-add-workspace-rest-anchors.ts
|
|
230437
|
-
import
|
|
230477
|
+
import path51 from "path";
|
|
230438
230478
|
function escapeRegex4(value2) {
|
|
230439
230479
|
return value2.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
|
|
230440
230480
|
}
|
|
@@ -230485,7 +230525,7 @@ ${snippet}
|
|
|
230485
230525
|
insertPhpSnippet(registerFunction);
|
|
230486
230526
|
} else if (!nextSource.includes(REST_RESOURCE_SERVER_GLOB)) {
|
|
230487
230527
|
throw new Error([
|
|
230488
|
-
`Unable to patch ${
|
|
230528
|
+
`Unable to patch ${path51.basename(bootstrapPath)} in ensureRestResourceBootstrapAnchors.`,
|
|
230489
230529
|
`The existing ${registerFunctionName}() definition does not include ${REST_RESOURCE_SERVER_GLOB}.`,
|
|
230490
230530
|
"Restore the generated bootstrap shape or wire the REST resource loader manually before retrying."
|
|
230491
230531
|
].join(" "));
|
|
@@ -230499,7 +230539,7 @@ ${snippet}
|
|
|
230499
230539
|
function assertSyncRestAnchor(nextSource, target, anchorDescription, hasAnchor, syncRestScriptPath) {
|
|
230500
230540
|
if (!nextSource.includes(target) && !hasAnchor) {
|
|
230501
230541
|
throw new Error([
|
|
230502
|
-
`ensureRestResourceSyncScriptAnchors could not patch ${
|
|
230542
|
+
`ensureRestResourceSyncScriptAnchors could not patch ${path51.basename(syncRestScriptPath)}.`,
|
|
230503
230543
|
`Missing expected ${anchorDescription} anchor in scripts/sync-rest-contracts.ts.`,
|
|
230504
230544
|
"Restore the generated template or add the REST_RESOURCES wiring manually before retrying."
|
|
230505
230545
|
].join(" "));
|
|
@@ -230514,7 +230554,7 @@ function replaceRequiredSyncRestSource(nextSource, target, anchor, replacement,
|
|
|
230514
230554
|
return nextSource.replace(anchor, replacement);
|
|
230515
230555
|
}
|
|
230516
230556
|
async function ensureRestResourceSyncScriptAnchors(workspace) {
|
|
230517
|
-
const syncRestScriptPath =
|
|
230557
|
+
const syncRestScriptPath = path51.join(workspace.projectDir, "scripts", "sync-rest-contracts.ts");
|
|
230518
230558
|
await patchFile(syncRestScriptPath, (source) => {
|
|
230519
230559
|
let nextSource = source;
|
|
230520
230560
|
const importAnchor = "import { BLOCKS, type WorkspaceBlockConfig } from './block-config';";
|
|
@@ -230636,7 +230676,7 @@ var init_cli_add_workspace_rest_anchors = __esm(() => {
|
|
|
230636
230676
|
});
|
|
230637
230677
|
|
|
230638
230678
|
// ../wp-typia-project-tools/src/runtime/rest-resource-artifacts.ts
|
|
230639
|
-
import
|
|
230679
|
+
import path52 from "path";
|
|
230640
230680
|
import {
|
|
230641
230681
|
defineEndpointManifest as defineEndpointManifest2,
|
|
230642
230682
|
syncEndpointClient as syncEndpointClient2,
|
|
@@ -230772,8 +230812,8 @@ async function syncRestResourceArtifacts({
|
|
|
230772
230812
|
const manifest = buildRestResourceEndpointManifest(variables, methods);
|
|
230773
230813
|
for (const [baseName, contract] of Object.entries(manifest.contracts)) {
|
|
230774
230814
|
await syncTypeSchemas2({
|
|
230775
|
-
jsonSchemaFile:
|
|
230776
|
-
openApiFile:
|
|
230815
|
+
jsonSchemaFile: path52.join(outputDir, "api-schemas", `${baseName}.schema.json`),
|
|
230816
|
+
openApiFile: path52.join(outputDir, "api-schemas", `${baseName}.openapi.json`),
|
|
230777
230817
|
projectRoot: projectDir,
|
|
230778
230818
|
sourceTypeName: contract.sourceTypeName,
|
|
230779
230819
|
typesFile
|
|
@@ -230781,7 +230821,7 @@ async function syncRestResourceArtifacts({
|
|
|
230781
230821
|
}
|
|
230782
230822
|
await syncRestOpenApi2({
|
|
230783
230823
|
manifest,
|
|
230784
|
-
openApiFile:
|
|
230824
|
+
openApiFile: path52.join(outputDir, "api.openapi.json"),
|
|
230785
230825
|
projectRoot: projectDir,
|
|
230786
230826
|
typesFile
|
|
230787
230827
|
});
|
|
@@ -231186,7 +231226,7 @@ var init_cli_add_workspace_rest_source_emitters = __esm(() => {
|
|
|
231186
231226
|
|
|
231187
231227
|
// ../wp-typia-project-tools/src/runtime/cli-add-workspace-rest.ts
|
|
231188
231228
|
import { promises as fsp18 } from "fs";
|
|
231189
|
-
import
|
|
231229
|
+
import path53 from "path";
|
|
231190
231230
|
function quotePhpString2(value2) {
|
|
231191
231231
|
return `'${value2.replace(/\\/gu, "\\\\").replace(/'/gu, "\\'")}'`;
|
|
231192
231232
|
}
|
|
@@ -231619,15 +231659,15 @@ async function runAddRestResourceCommand({
|
|
|
231619
231659
|
const resolvedNamespace = resolveRestResourceNamespace(workspace.workspace.namespace, namespace);
|
|
231620
231660
|
const inventory = readWorkspaceInventory(workspace.projectDir);
|
|
231621
231661
|
assertRestResourceDoesNotExist(workspace.projectDir, restResourceSlug, inventory);
|
|
231622
|
-
const blockConfigPath =
|
|
231662
|
+
const blockConfigPath = path53.join(workspace.projectDir, "scripts", "block-config.ts");
|
|
231623
231663
|
const bootstrapPath = getWorkspaceBootstrapPath(workspace);
|
|
231624
|
-
const syncRestScriptPath =
|
|
231625
|
-
const restResourceDir =
|
|
231626
|
-
const typesFilePath =
|
|
231627
|
-
const validatorsFilePath =
|
|
231628
|
-
const apiFilePath =
|
|
231629
|
-
const dataFilePath =
|
|
231630
|
-
const phpFilePath =
|
|
231664
|
+
const syncRestScriptPath = path53.join(workspace.projectDir, "scripts", "sync-rest-contracts.ts");
|
|
231665
|
+
const restResourceDir = path53.join(workspace.projectDir, "src", "rest", restResourceSlug);
|
|
231666
|
+
const typesFilePath = path53.join(restResourceDir, "api-types.ts");
|
|
231667
|
+
const validatorsFilePath = path53.join(restResourceDir, "api-validators.ts");
|
|
231668
|
+
const apiFilePath = path53.join(restResourceDir, "api.ts");
|
|
231669
|
+
const dataFilePath = path53.join(restResourceDir, "data.ts");
|
|
231670
|
+
const phpFilePath = path53.join(workspace.projectDir, "inc", "rest", `${restResourceSlug}.php`);
|
|
231631
231671
|
const mutationSnapshot = {
|
|
231632
231672
|
fileSources: await snapshotWorkspaceFiles([
|
|
231633
231673
|
blockConfigPath,
|
|
@@ -231639,7 +231679,7 @@ async function runAddRestResourceCommand({
|
|
|
231639
231679
|
};
|
|
231640
231680
|
try {
|
|
231641
231681
|
await fsp18.mkdir(restResourceDir, { recursive: true });
|
|
231642
|
-
await fsp18.mkdir(
|
|
231682
|
+
await fsp18.mkdir(path53.dirname(phpFilePath), { recursive: true });
|
|
231643
231683
|
await ensureRestResourceBootstrapAnchors(workspace);
|
|
231644
231684
|
await ensureRestResourceSyncScriptAnchors(workspace);
|
|
231645
231685
|
await fsp18.writeFile(typesFilePath, buildRestResourceTypesSource(restResourceSlug, resolvedMethods), "utf8");
|
|
@@ -231691,7 +231731,7 @@ var init_cli_add_workspace_rest = __esm(() => {
|
|
|
231691
231731
|
// ../wp-typia-project-tools/src/runtime/cli-add-workspace-ability.ts
|
|
231692
231732
|
import fs42 from "fs";
|
|
231693
231733
|
import { promises as fsp19 } from "fs";
|
|
231694
|
-
import
|
|
231734
|
+
import path54 from "path";
|
|
231695
231735
|
import { syncTypeSchemas as syncTypeSchemas3 } from "@wp-typia/block-runtime/metadata-core";
|
|
231696
231736
|
function escapeRegex5(value2) {
|
|
231697
231737
|
return value2.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
|
|
@@ -232211,8 +232251,8 @@ function buildAbilityRegistrySource(abilitySlugs) {
|
|
|
232211
232251
|
`);
|
|
232212
232252
|
}
|
|
232213
232253
|
function resolveAbilityRegistryPath(projectDir) {
|
|
232214
|
-
const abilitiesDir =
|
|
232215
|
-
return [
|
|
232254
|
+
const abilitiesDir = path54.join(projectDir, "src", "abilities");
|
|
232255
|
+
return [path54.join(abilitiesDir, "index.ts"), path54.join(abilitiesDir, "index.js")].find((candidatePath) => fs42.existsSync(candidatePath)) ?? path54.join(abilitiesDir, "index.ts");
|
|
232216
232256
|
}
|
|
232217
232257
|
function readAbilityRegistrySlugs(registryPath) {
|
|
232218
232258
|
if (!fs42.existsSync(registryPath)) {
|
|
@@ -232222,7 +232262,7 @@ function readAbilityRegistrySlugs(registryPath) {
|
|
|
232222
232262
|
return Array.from(source.matchAll(/^\s*export\s+\*\s+from\s+['"]\.\/([^/'"]+)\/client['"];?\s*$/gmu)).map((match3) => match3[1]);
|
|
232223
232263
|
}
|
|
232224
232264
|
async function writeAbilityRegistry(projectDir, abilitySlug) {
|
|
232225
|
-
const abilitiesDir =
|
|
232265
|
+
const abilitiesDir = path54.join(projectDir, "src", "abilities");
|
|
232226
232266
|
const registryPath = resolveAbilityRegistryPath(projectDir);
|
|
232227
232267
|
await fsp19.mkdir(abilitiesDir, { recursive: true });
|
|
232228
232268
|
const existingAbilitySlugs = readWorkspaceInventory(projectDir).abilities.map((entry) => entry.slug);
|
|
@@ -232355,7 +232395,7 @@ ${snippet}
|
|
|
232355
232395
|
});
|
|
232356
232396
|
}
|
|
232357
232397
|
async function ensureAbilityPackageScripts(workspace) {
|
|
232358
|
-
const packageJsonPath =
|
|
232398
|
+
const packageJsonPath = path54.join(workspace.projectDir, "package.json");
|
|
232359
232399
|
const packageJson = JSON.parse(await fsp19.readFile(packageJsonPath, "utf8"));
|
|
232360
232400
|
const nextScripts = {
|
|
232361
232401
|
...packageJson.scripts ?? {},
|
|
@@ -232375,7 +232415,7 @@ async function ensureAbilityPackageScripts(workspace) {
|
|
|
232375
232415
|
`, "utf8");
|
|
232376
232416
|
}
|
|
232377
232417
|
async function ensureAbilitySyncProjectAnchors(workspace) {
|
|
232378
|
-
const syncProjectScriptPath =
|
|
232418
|
+
const syncProjectScriptPath = path54.join(workspace.projectDir, "scripts", "sync-project.ts");
|
|
232379
232419
|
await patchFile(syncProjectScriptPath, (source) => {
|
|
232380
232420
|
let nextSource = source;
|
|
232381
232421
|
const syncRestConst = "const syncRestScriptPath = path.join( 'scripts', 'sync-rest-contracts.ts' );";
|
|
@@ -232390,7 +232430,7 @@ async function ensureAbilitySyncProjectAnchors(workspace) {
|
|
|
232390
232430
|
if (!nextSource.includes(syncAbilitiesConst)) {
|
|
232391
232431
|
if (!nextSource.includes(syncRestConst)) {
|
|
232392
232432
|
throw new Error([
|
|
232393
|
-
`ensureAbilitySyncProjectAnchors could not patch ${
|
|
232433
|
+
`ensureAbilitySyncProjectAnchors could not patch ${path54.basename(syncProjectScriptPath)}.`,
|
|
232394
232434
|
"Missing the expected sync-rest script constant in scripts/sync-project.ts.",
|
|
232395
232435
|
"Restore the generated template or wire sync-abilities manually before retrying."
|
|
232396
232436
|
].join(" "));
|
|
@@ -232401,7 +232441,7 @@ ${syncAbilitiesConst}`);
|
|
|
232401
232441
|
if (!nextSource.includes("runSyncScript( syncAbilitiesScriptPath, options );")) {
|
|
232402
232442
|
if (!syncRestBlockPattern.test(nextSource)) {
|
|
232403
232443
|
throw new Error([
|
|
232404
|
-
`ensureAbilitySyncProjectAnchors could not patch ${
|
|
232444
|
+
`ensureAbilitySyncProjectAnchors could not patch ${path54.basename(syncProjectScriptPath)}.`,
|
|
232405
232445
|
"Missing the expected sync-rest invocation block in scripts/sync-project.ts.",
|
|
232406
232446
|
"Restore the generated template or wire sync-abilities manually before retrying."
|
|
232407
232447
|
].join(" "));
|
|
@@ -232414,7 +232454,7 @@ ${syncAbilitiesBlock}`);
|
|
|
232414
232454
|
});
|
|
232415
232455
|
}
|
|
232416
232456
|
async function ensureAbilityBuildScriptAnchors(workspace) {
|
|
232417
|
-
const buildScriptPath =
|
|
232457
|
+
const buildScriptPath = path54.join(workspace.projectDir, "scripts", "build-workspace.mjs");
|
|
232418
232458
|
await patchFile(buildScriptPath, (source) => {
|
|
232419
232459
|
let nextSource = source;
|
|
232420
232460
|
if (/['"]src\/abilities\/index\.(?:ts|js)['"]/u.test(nextSource)) {
|
|
@@ -232424,7 +232464,7 @@ async function ensureAbilityBuildScriptAnchors(workspace) {
|
|
|
232424
232464
|
const match3 = nextSource.match(sharedEntriesPattern);
|
|
232425
232465
|
if (!match3 || !match3[2].includes("src/bindings/index.ts") || !match3[2].includes("src/editor-plugins/index.ts")) {
|
|
232426
232466
|
throw new Error([
|
|
232427
|
-
`ensureAbilityBuildScriptAnchors could not patch ${
|
|
232467
|
+
`ensureAbilityBuildScriptAnchors could not patch ${path54.basename(buildScriptPath)}.`,
|
|
232428
232468
|
"Missing the expected shared editor entries array in scripts/build-workspace.mjs.",
|
|
232429
232469
|
"Restore the generated template or wire abilities/index manually before retrying."
|
|
232430
232470
|
].join(" "));
|
|
@@ -232441,7 +232481,7 @@ async function ensureAbilityBuildScriptAnchors(workspace) {
|
|
|
232441
232481
|
});
|
|
232442
232482
|
}
|
|
232443
232483
|
async function ensureAbilityWebpackAnchors(workspace) {
|
|
232444
|
-
const webpackConfigPath =
|
|
232484
|
+
const webpackConfigPath = path54.join(workspace.projectDir, "webpack.config.js");
|
|
232445
232485
|
await patchFile(webpackConfigPath, (source) => {
|
|
232446
232486
|
if (/['"]abilities\/index['"]/u.test(source)) {
|
|
232447
232487
|
return source;
|
|
@@ -232472,7 +232512,7 @@ $2`);
|
|
|
232472
232512
|
const match3 = source.match(sharedEntriesPattern);
|
|
232473
232513
|
if (!match3 || !match3[1].includes("bindings/index") || !match3[1].includes("editor-plugins/index")) {
|
|
232474
232514
|
throw new Error([
|
|
232475
|
-
`ensureAbilityWebpackAnchors could not patch ${
|
|
232515
|
+
`ensureAbilityWebpackAnchors could not patch ${path54.basename(webpackConfigPath)}.`,
|
|
232476
232516
|
"Missing the expected shared editor entries block in webpack.config.js.",
|
|
232477
232517
|
"Restore the generated template or wire abilities/index manually before retrying."
|
|
232478
232518
|
].join(" "));
|
|
@@ -232502,20 +232542,20 @@ async function runAddAbilityCommand({
|
|
|
232502
232542
|
const inventory = readWorkspaceInventory(workspace.projectDir);
|
|
232503
232543
|
assertAbilityDoesNotExist(workspace.projectDir, abilitySlug, inventory);
|
|
232504
232544
|
const compatibilityPolicy = resolveScaffoldCompatibilityPolicy(REQUIRED_WORKSPACE_ABILITY_COMPATIBILITY);
|
|
232505
|
-
const blockConfigPath =
|
|
232545
|
+
const blockConfigPath = path54.join(workspace.projectDir, "scripts", "block-config.ts");
|
|
232506
232546
|
const bootstrapPath = getWorkspaceBootstrapPath(workspace);
|
|
232507
|
-
const buildScriptPath =
|
|
232508
|
-
const packageJsonPath =
|
|
232509
|
-
const syncAbilitiesScriptPath =
|
|
232510
|
-
const syncProjectScriptPath =
|
|
232511
|
-
const webpackConfigPath =
|
|
232547
|
+
const buildScriptPath = path54.join(workspace.projectDir, "scripts", "build-workspace.mjs");
|
|
232548
|
+
const packageJsonPath = path54.join(workspace.projectDir, "package.json");
|
|
232549
|
+
const syncAbilitiesScriptPath = path54.join(workspace.projectDir, "scripts", "sync-abilities.ts");
|
|
232550
|
+
const syncProjectScriptPath = path54.join(workspace.projectDir, "scripts", "sync-project.ts");
|
|
232551
|
+
const webpackConfigPath = path54.join(workspace.projectDir, "webpack.config.js");
|
|
232512
232552
|
const abilitiesIndexPath = resolveAbilityRegistryPath(workspace.projectDir);
|
|
232513
|
-
const abilityDir =
|
|
232514
|
-
const configFilePath =
|
|
232515
|
-
const typesFilePath =
|
|
232516
|
-
const dataFilePath =
|
|
232517
|
-
const clientFilePath =
|
|
232518
|
-
const phpFilePath =
|
|
232553
|
+
const abilityDir = path54.join(workspace.projectDir, "src", "abilities", abilitySlug);
|
|
232554
|
+
const configFilePath = path54.join(abilityDir, "ability.config.json");
|
|
232555
|
+
const typesFilePath = path54.join(abilityDir, "types.ts");
|
|
232556
|
+
const dataFilePath = path54.join(abilityDir, "data.ts");
|
|
232557
|
+
const clientFilePath = path54.join(abilityDir, "client.ts");
|
|
232558
|
+
const phpFilePath = path54.join(workspace.projectDir, "inc", "abilities", `${abilitySlug}.php`);
|
|
232519
232559
|
const mutationSnapshot = {
|
|
232520
232560
|
fileSources: await snapshotWorkspaceFiles([
|
|
232521
232561
|
blockConfigPath,
|
|
@@ -232532,7 +232572,7 @@ async function runAddAbilityCommand({
|
|
|
232532
232572
|
};
|
|
232533
232573
|
try {
|
|
232534
232574
|
await fsp19.mkdir(abilityDir, { recursive: true });
|
|
232535
|
-
await fsp19.mkdir(
|
|
232575
|
+
await fsp19.mkdir(path54.dirname(phpFilePath), { recursive: true });
|
|
232536
232576
|
await ensureAbilityBootstrapAnchors(workspace);
|
|
232537
232577
|
await patchFile(bootstrapPath, (source) => updatePluginHeaderCompatibility(source, compatibilityPolicy));
|
|
232538
232578
|
await ensureAbilityPackageScripts(workspace);
|
|
@@ -232609,7 +232649,7 @@ var init_ai_artifacts = __esm(() => {
|
|
|
232609
232649
|
|
|
232610
232650
|
// ../wp-typia-project-tools/src/runtime/ai-feature-artifacts.ts
|
|
232611
232651
|
import { mkdir as mkdir3, readFile as readFile5, writeFile as writeFile5 } from "fs/promises";
|
|
232612
|
-
import
|
|
232652
|
+
import path55 from "path";
|
|
232613
232653
|
import {
|
|
232614
232654
|
defineEndpointManifest as defineEndpointManifest3,
|
|
232615
232655
|
syncEndpointClient as syncEndpointClient3,
|
|
@@ -232622,7 +232662,7 @@ function normalizeGeneratedArtifactContent(content) {
|
|
|
232622
232662
|
}
|
|
232623
232663
|
async function reconcileGeneratedArtifact(options) {
|
|
232624
232664
|
if (!options.check) {
|
|
232625
|
-
await mkdir3(
|
|
232665
|
+
await mkdir3(path55.dirname(options.filePath), {
|
|
232626
232666
|
recursive: true
|
|
232627
232667
|
});
|
|
232628
232668
|
await writeFile5(options.filePath, options.content, "utf8");
|
|
@@ -232694,8 +232734,8 @@ async function syncAiFeatureRestArtifacts({
|
|
|
232694
232734
|
const manifest = buildAiFeatureEndpointManifest(variables);
|
|
232695
232735
|
for (const [baseName, contract] of Object.entries(manifest.contracts)) {
|
|
232696
232736
|
await syncTypeSchemas4({
|
|
232697
|
-
jsonSchemaFile:
|
|
232698
|
-
openApiFile:
|
|
232737
|
+
jsonSchemaFile: path55.join(outputDir, "api-schemas", `${baseName}.schema.json`),
|
|
232738
|
+
openApiFile: path55.join(outputDir, "api-schemas", `${baseName}.openapi.json`),
|
|
232699
232739
|
projectRoot: projectDir,
|
|
232700
232740
|
sourceTypeName: contract.sourceTypeName,
|
|
232701
232741
|
typesFile
|
|
@@ -232703,7 +232743,7 @@ async function syncAiFeatureRestArtifacts({
|
|
|
232703
232743
|
}
|
|
232704
232744
|
await syncRestOpenApi3({
|
|
232705
232745
|
manifest,
|
|
232706
|
-
openApiFile:
|
|
232746
|
+
openApiFile: path55.join(outputDir, "api.openapi.json"),
|
|
232707
232747
|
projectRoot: projectDir,
|
|
232708
232748
|
typesFile
|
|
232709
232749
|
}, executionOptions);
|
|
@@ -232721,19 +232761,19 @@ async function syncAiFeatureSchemaArtifact({
|
|
|
232721
232761
|
outputDir,
|
|
232722
232762
|
projectDir
|
|
232723
232763
|
}) {
|
|
232724
|
-
const sourceSchemaPath =
|
|
232764
|
+
const sourceSchemaPath = path55.join(projectDir, outputDir, "api-schemas", "feature-result.schema.json");
|
|
232725
232765
|
const responseSchema = assertJsonObject(JSON.parse(await readFile5(sourceSchemaPath, "utf8")), sourceSchemaPath);
|
|
232726
232766
|
const aiSchema = projectWordPressAiSchema(responseSchema);
|
|
232727
232767
|
await reconcileGeneratedArtifact({
|
|
232728
232768
|
check: check2,
|
|
232729
232769
|
content: `${JSON.stringify(aiSchema, null, 2)}
|
|
232730
232770
|
`,
|
|
232731
|
-
filePath:
|
|
232771
|
+
filePath: path55.join(projectDir, aiSchemaFile),
|
|
232732
232772
|
label: "AI feature schema"
|
|
232733
232773
|
});
|
|
232734
232774
|
return {
|
|
232735
232775
|
aiSchema,
|
|
232736
|
-
aiSchemaPath:
|
|
232776
|
+
aiSchemaPath: path55.join(projectDir, aiSchemaFile),
|
|
232737
232777
|
check: check2,
|
|
232738
232778
|
sourceSchemaPath
|
|
232739
232779
|
};
|
|
@@ -233068,7 +233108,7 @@ var init_cli_add_workspace_ai_source_emitters = __esm(() => {
|
|
|
233068
233108
|
|
|
233069
233109
|
// ../wp-typia-project-tools/src/runtime/cli-add-workspace-ai-anchors.ts
|
|
233070
233110
|
import { promises as fsp20 } from "fs";
|
|
233071
|
-
import
|
|
233111
|
+
import path56 from "path";
|
|
233072
233112
|
function escapeRegex6(value2) {
|
|
233073
233113
|
return value2.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
|
|
233074
233114
|
}
|
|
@@ -233119,7 +233159,7 @@ ${snippet}
|
|
|
233119
233159
|
insertPhpSnippet(registerFunction);
|
|
233120
233160
|
} else if (!nextSource.includes(AI_FEATURE_SERVER_GLOB)) {
|
|
233121
233161
|
throw new Error([
|
|
233122
|
-
`Unable to patch ${
|
|
233162
|
+
`Unable to patch ${path56.basename(bootstrapPath)} in ensureAiFeatureBootstrapAnchors.`,
|
|
233123
233163
|
`The existing ${registerFunctionName}() definition does not include ${AI_FEATURE_SERVER_GLOB}.`,
|
|
233124
233164
|
"Restore the generated bootstrap shape or wire the AI feature loader manually before retrying."
|
|
233125
233165
|
].join(" "));
|
|
@@ -233131,7 +233171,7 @@ ${snippet}
|
|
|
233131
233171
|
});
|
|
233132
233172
|
}
|
|
233133
233173
|
async function ensureAiFeaturePackageScripts(workspace) {
|
|
233134
|
-
const packageJsonPath =
|
|
233174
|
+
const packageJsonPath = path56.join(workspace.projectDir, "package.json");
|
|
233135
233175
|
const packageJson = JSON.parse(await fsp20.readFile(packageJsonPath, "utf8"));
|
|
233136
233176
|
const nextScripts = {
|
|
233137
233177
|
...packageJson.scripts ?? {},
|
|
@@ -233159,7 +233199,7 @@ async function ensureAiFeaturePackageScripts(workspace) {
|
|
|
233159
233199
|
};
|
|
233160
233200
|
}
|
|
233161
233201
|
async function ensureAiFeatureSyncProjectAnchors(workspace) {
|
|
233162
|
-
const syncProjectScriptPath =
|
|
233202
|
+
const syncProjectScriptPath = path56.join(workspace.projectDir, "scripts", "sync-project.ts");
|
|
233163
233203
|
await patchFile(syncProjectScriptPath, (source) => {
|
|
233164
233204
|
let nextSource = source;
|
|
233165
233205
|
const syncRestConst = "const syncRestScriptPath = path.join( 'scripts', 'sync-rest-contracts.ts' );";
|
|
@@ -233174,7 +233214,7 @@ async function ensureAiFeatureSyncProjectAnchors(workspace) {
|
|
|
233174
233214
|
if (!nextSource.includes(syncAiConst)) {
|
|
233175
233215
|
if (!nextSource.includes(syncRestConst)) {
|
|
233176
233216
|
throw new Error([
|
|
233177
|
-
`ensureAiFeatureSyncProjectAnchors could not patch ${
|
|
233217
|
+
`ensureAiFeatureSyncProjectAnchors could not patch ${path56.basename(syncProjectScriptPath)}.`,
|
|
233178
233218
|
"Missing the expected sync-rest script constant in scripts/sync-project.ts.",
|
|
233179
233219
|
"Restore the generated template or wire sync-ai manually before retrying."
|
|
233180
233220
|
].join(" "));
|
|
@@ -233185,7 +233225,7 @@ ${syncAiConst}`);
|
|
|
233185
233225
|
if (!nextSource.includes("runSyncScript( syncAiScriptPath, options );")) {
|
|
233186
233226
|
if (!syncRestBlockPattern.test(nextSource)) {
|
|
233187
233227
|
throw new Error([
|
|
233188
|
-
`ensureAiFeatureSyncProjectAnchors could not patch ${
|
|
233228
|
+
`ensureAiFeatureSyncProjectAnchors could not patch ${path56.basename(syncProjectScriptPath)}.`,
|
|
233189
233229
|
"Missing the expected sync-rest invocation block in scripts/sync-project.ts.",
|
|
233190
233230
|
"Restore the generated template or wire sync-ai manually before retrying."
|
|
233191
233231
|
].join(" "));
|
|
@@ -233200,7 +233240,7 @@ ${syncAiBlock}`);
|
|
|
233200
233240
|
function assertSyncRestAnchor2(nextSource, target, anchorDescription, hasAnchor, syncRestScriptPath) {
|
|
233201
233241
|
if (!nextSource.includes(target) && !hasAnchor) {
|
|
233202
233242
|
throw new Error([
|
|
233203
|
-
`ensureAiFeatureSyncRestAnchors could not patch ${
|
|
233243
|
+
`ensureAiFeatureSyncRestAnchors could not patch ${path56.basename(syncRestScriptPath)}.`,
|
|
233204
233244
|
`Missing expected ${anchorDescription} anchor in scripts/sync-rest-contracts.ts.`,
|
|
233205
233245
|
"Restore the generated template or add the AI feature wiring manually before retrying."
|
|
233206
233246
|
].join(" "));
|
|
@@ -233215,7 +233255,7 @@ function replaceRequiredSyncRestSource2(nextSource, target, anchor, replacement,
|
|
|
233215
233255
|
return nextSource.replace(anchor, replacement);
|
|
233216
233256
|
}
|
|
233217
233257
|
async function ensureAiFeatureSyncRestAnchors(workspace) {
|
|
233218
|
-
const syncRestScriptPath =
|
|
233258
|
+
const syncRestScriptPath = path56.join(workspace.projectDir, "scripts", "sync-rest-contracts.ts");
|
|
233219
233259
|
await patchFile(syncRestScriptPath, (source) => {
|
|
233220
233260
|
let nextSource = source;
|
|
233221
233261
|
const importAnchor = [
|
|
@@ -233350,7 +233390,7 @@ var init_cli_add_workspace_ai_anchors = __esm(() => {
|
|
|
233350
233390
|
|
|
233351
233391
|
// ../wp-typia-project-tools/src/runtime/cli-add-workspace-ai.ts
|
|
233352
233392
|
import { promises as fsp21 } from "fs";
|
|
233353
|
-
import
|
|
233393
|
+
import path57 from "path";
|
|
233354
233394
|
function quotePhpString4(value2) {
|
|
233355
233395
|
return `'${value2.replace(/\\/gu, "\\\\").replace(/'/gu, "\\'")}'`;
|
|
233356
233396
|
}
|
|
@@ -233742,18 +233782,18 @@ async function runAddAiFeatureCommand({
|
|
|
233742
233782
|
const compatibilityPolicy = resolveScaffoldCompatibilityPolicy(OPTIONAL_WORDPRESS_AI_CLIENT_COMPATIBILITY);
|
|
233743
233783
|
const inventory = readWorkspaceInventory(workspace.projectDir);
|
|
233744
233784
|
assertAiFeatureDoesNotExist(workspace.projectDir, aiFeatureSlug, inventory);
|
|
233745
|
-
const blockConfigPath =
|
|
233785
|
+
const blockConfigPath = path57.join(workspace.projectDir, "scripts", "block-config.ts");
|
|
233746
233786
|
const bootstrapPath = getWorkspaceBootstrapPath(workspace);
|
|
233747
|
-
const packageJsonPath =
|
|
233748
|
-
const syncAiScriptPath =
|
|
233749
|
-
const syncProjectScriptPath =
|
|
233750
|
-
const syncRestScriptPath =
|
|
233751
|
-
const aiFeatureDir =
|
|
233752
|
-
const typesFilePath =
|
|
233753
|
-
const validatorsFilePath =
|
|
233754
|
-
const apiFilePath =
|
|
233755
|
-
const dataFilePath =
|
|
233756
|
-
const phpFilePath =
|
|
233787
|
+
const packageJsonPath = path57.join(workspace.projectDir, "package.json");
|
|
233788
|
+
const syncAiScriptPath = path57.join(workspace.projectDir, "scripts", "sync-ai-features.ts");
|
|
233789
|
+
const syncProjectScriptPath = path57.join(workspace.projectDir, "scripts", "sync-project.ts");
|
|
233790
|
+
const syncRestScriptPath = path57.join(workspace.projectDir, "scripts", "sync-rest-contracts.ts");
|
|
233791
|
+
const aiFeatureDir = path57.join(workspace.projectDir, "src", "ai-features", aiFeatureSlug);
|
|
233792
|
+
const typesFilePath = path57.join(aiFeatureDir, "api-types.ts");
|
|
233793
|
+
const validatorsFilePath = path57.join(aiFeatureDir, "api-validators.ts");
|
|
233794
|
+
const apiFilePath = path57.join(aiFeatureDir, "api.ts");
|
|
233795
|
+
const dataFilePath = path57.join(aiFeatureDir, "data.ts");
|
|
233796
|
+
const phpFilePath = path57.join(workspace.projectDir, "inc", "ai-features", `${aiFeatureSlug}.php`);
|
|
233757
233797
|
const mutationSnapshot = {
|
|
233758
233798
|
fileSources: await snapshotWorkspaceFiles([
|
|
233759
233799
|
blockConfigPath,
|
|
@@ -233768,7 +233808,7 @@ async function runAddAiFeatureCommand({
|
|
|
233768
233808
|
};
|
|
233769
233809
|
try {
|
|
233770
233810
|
await fsp21.mkdir(aiFeatureDir, { recursive: true });
|
|
233771
|
-
await fsp21.mkdir(
|
|
233811
|
+
await fsp21.mkdir(path57.dirname(phpFilePath), { recursive: true });
|
|
233772
233812
|
await ensureAiFeatureBootstrapAnchors(workspace);
|
|
233773
233813
|
await patchFile(bootstrapPath, (source) => updatePluginHeaderCompatibility(source, compatibilityPolicy));
|
|
233774
233814
|
const packageScriptChanges = await ensureAiFeaturePackageScripts(workspace);
|
|
@@ -233783,7 +233823,7 @@ async function runAddAiFeatureCommand({
|
|
|
233783
233823
|
const pascalCase = toPascalCaseFromAiFeatureSlug(aiFeatureSlug);
|
|
233784
233824
|
await syncAiFeatureRestArtifacts({
|
|
233785
233825
|
clientFile: `src/ai-features/${aiFeatureSlug}/api-client.ts`,
|
|
233786
|
-
outputDir:
|
|
233826
|
+
outputDir: path57.join("src", "ai-features", aiFeatureSlug),
|
|
233787
233827
|
projectDir: workspace.projectDir,
|
|
233788
233828
|
typesFile: `src/ai-features/${aiFeatureSlug}/api-types.ts`,
|
|
233789
233829
|
validatorsFile: `src/ai-features/${aiFeatureSlug}/api-validators.ts`,
|
|
@@ -233796,7 +233836,7 @@ async function runAddAiFeatureCommand({
|
|
|
233796
233836
|
});
|
|
233797
233837
|
await syncAiFeatureSchemaArtifact({
|
|
233798
233838
|
aiSchemaFile: `src/ai-features/${aiFeatureSlug}/ai-schemas/feature-result.ai.schema.json`,
|
|
233799
|
-
outputDir:
|
|
233839
|
+
outputDir: path57.join("src", "ai-features", aiFeatureSlug),
|
|
233800
233840
|
projectDir: workspace.projectDir
|
|
233801
233841
|
});
|
|
233802
233842
|
await appendWorkspaceInventoryEntries(workspace.projectDir, {
|
|
@@ -233832,7 +233872,7 @@ var init_cli_add_workspace_ai = __esm(() => {
|
|
|
233832
233872
|
// ../wp-typia-project-tools/src/runtime/cli-add-workspace.ts
|
|
233833
233873
|
import fs43 from "fs";
|
|
233834
233874
|
import { promises as fsp22 } from "fs";
|
|
233835
|
-
import
|
|
233875
|
+
import path58 from "path";
|
|
233836
233876
|
function buildVariationConfigEntry(blockSlug, variationSlug) {
|
|
233837
233877
|
return [
|
|
233838
233878
|
"\t{",
|
|
@@ -233933,14 +233973,14 @@ ${VARIATIONS_CALL_LINE}
|
|
|
233933
233973
|
}
|
|
233934
233974
|
}
|
|
233935
233975
|
if (!nextSource.includes(VARIATIONS_CALL_LINE)) {
|
|
233936
|
-
throw new Error(`Unable to inject ${VARIATIONS_CALL_LINE} into ${
|
|
233976
|
+
throw new Error(`Unable to inject ${VARIATIONS_CALL_LINE} into ${path58.basename(blockIndexPath)}.`);
|
|
233937
233977
|
}
|
|
233938
233978
|
return nextSource;
|
|
233939
233979
|
});
|
|
233940
233980
|
}
|
|
233941
233981
|
async function writeVariationRegistry(projectDir, blockSlug, variationSlug) {
|
|
233942
|
-
const variationsDir =
|
|
233943
|
-
const variationsIndexPath =
|
|
233982
|
+
const variationsDir = path58.join(projectDir, "src", "blocks", blockSlug, "variations");
|
|
233983
|
+
const variationsIndexPath = path58.join(variationsDir, "index.ts");
|
|
233944
233984
|
await fsp22.mkdir(variationsDir, { recursive: true });
|
|
233945
233985
|
const existingVariationSlugs = fs43.readdirSync(variationsDir).filter((entry) => entry.endsWith(".ts") && entry !== "index.ts").map((entry) => entry.replace(/\.ts$/u, ""));
|
|
233946
233986
|
const nextVariationSlugs = Array.from(new Set([...existingVariationSlugs, variationSlug])).sort();
|
|
@@ -233957,11 +233997,11 @@ async function runAddVariationCommand({
|
|
|
233957
233997
|
const inventory = readWorkspaceInventory(workspace.projectDir);
|
|
233958
233998
|
resolveWorkspaceBlock(inventory, blockSlug);
|
|
233959
233999
|
assertVariationDoesNotExist(workspace.projectDir, blockSlug, variationSlug, inventory);
|
|
233960
|
-
const blockConfigPath =
|
|
233961
|
-
const blockIndexPath =
|
|
233962
|
-
const variationsDir =
|
|
233963
|
-
const variationFilePath =
|
|
233964
|
-
const variationsIndexPath =
|
|
234000
|
+
const blockConfigPath = path58.join(workspace.projectDir, "scripts", "block-config.ts");
|
|
234001
|
+
const blockIndexPath = path58.join(workspace.projectDir, "src", "blocks", blockSlug, "index.tsx");
|
|
234002
|
+
const variationsDir = path58.join(workspace.projectDir, "src", "blocks", blockSlug, "variations");
|
|
234003
|
+
const variationFilePath = path58.join(variationsDir, `${variationSlug}.ts`);
|
|
234004
|
+
const variationsIndexPath = path58.join(variationsDir, "index.ts");
|
|
233965
234005
|
const mutationSnapshot = {
|
|
233966
234006
|
fileSources: await snapshotWorkspaceFiles([
|
|
233967
234007
|
blockConfigPath,
|
|
@@ -234006,7 +234046,7 @@ async function runAddHookedBlockCommand({
|
|
|
234006
234046
|
throw new Error("`wp-typia add hooked-block` cannot hook a block relative to its own block name.");
|
|
234007
234047
|
}
|
|
234008
234048
|
const { blockJson, blockJsonPath } = readWorkspaceBlockJson(workspace.projectDir, blockSlug);
|
|
234009
|
-
const blockJsonRelativePath =
|
|
234049
|
+
const blockJsonRelativePath = path58.relative(workspace.projectDir, blockJsonPath);
|
|
234010
234050
|
const blockHooks = getMutableBlockHooks(blockJson, blockJsonRelativePath);
|
|
234011
234051
|
if (Object.prototype.hasOwnProperty.call(blockHooks, resolvedAnchorBlockName)) {
|
|
234012
234052
|
throw new Error(`${blockJsonRelativePath} already defines a blockHooks entry for "${resolvedAnchorBlockName}".`);
|
|
@@ -234072,7 +234112,7 @@ import { execFileSync as execFileSync3 } from "child_process";
|
|
|
234072
234112
|
import { access, constants as fsConstants, rm as rm2, writeFile as writeFile6 } from "fs/promises";
|
|
234073
234113
|
import fs44 from "fs";
|
|
234074
234114
|
import os4 from "os";
|
|
234075
|
-
import
|
|
234115
|
+
import path59 from "path";
|
|
234076
234116
|
function readCommandVersion(command, args = ["--version"]) {
|
|
234077
234117
|
try {
|
|
234078
234118
|
return execFileSync3(command, args, {
|
|
@@ -234096,7 +234136,7 @@ async function checkWritableDirectory(directory) {
|
|
|
234096
234136
|
}
|
|
234097
234137
|
}
|
|
234098
234138
|
async function checkTempDirectory() {
|
|
234099
|
-
const tempFile =
|
|
234139
|
+
const tempFile = path59.join(os4.tmpdir(), `wp-typia-${Date.now()}.tmp`);
|
|
234100
234140
|
try {
|
|
234101
234141
|
await writeFile6(tempFile, "ok", "utf8");
|
|
234102
234142
|
await rm2(tempFile, { force: true });
|
|
@@ -234113,7 +234153,7 @@ function getTemplateDoctorChecks() {
|
|
|
234113
234153
|
for (const template of listTemplates()) {
|
|
234114
234154
|
if (!isBuiltInTemplateId(template.id)) {
|
|
234115
234155
|
const templateDirExists = fs44.existsSync(template.templateDir);
|
|
234116
|
-
const hasAssets2 = templateDirExists && fs44.existsSync(
|
|
234156
|
+
const hasAssets2 = templateDirExists && fs44.existsSync(path59.join(template.templateDir, "package.json.mustache"));
|
|
234117
234157
|
checks3.push({
|
|
234118
234158
|
status: !templateDirExists || hasAssets2 ? "pass" : "fail",
|
|
234119
234159
|
label: `Template ${template.id}`,
|
|
@@ -234138,7 +234178,7 @@ function getTemplateDoctorChecks() {
|
|
|
234138
234178
|
])) : getBuiltInTemplateLayerDirs(builtInTemplateId);
|
|
234139
234179
|
const missingRequiredLayer = layerDirs.some((layerDir) => !fs44.existsSync(layerDir) && !isOmittableBuiltInTemplateLayerDir(builtInTemplateId, layerDir));
|
|
234140
234180
|
const existingLayerDirs = layerDirs.filter((layerDir) => fs44.existsSync(layerDir));
|
|
234141
|
-
const hasAssets = !missingRequiredLayer && existingLayerDirs.some((layerDir) => fs44.existsSync(
|
|
234181
|
+
const hasAssets = !missingRequiredLayer && existingLayerDirs.some((layerDir) => fs44.existsSync(path59.join(layerDir, "package.json.mustache"))) && existingLayerDirs.some((layerDir) => fs44.existsSync(path59.join(layerDir, "src")));
|
|
234142
234182
|
checks3.push({
|
|
234143
234183
|
status: hasAssets ? "pass" : "fail",
|
|
234144
234184
|
label: `Template ${template.id}`,
|
|
@@ -234169,7 +234209,7 @@ var init_cli_doctor_environment = __esm(() => {
|
|
|
234169
234209
|
|
|
234170
234210
|
// ../wp-typia-project-tools/src/runtime/cli-doctor-workspace.ts
|
|
234171
234211
|
import fs45 from "fs";
|
|
234172
|
-
import
|
|
234212
|
+
import path60 from "path";
|
|
234173
234213
|
import { parseScaffoldBlockMetadata as parseScaffoldBlockMetadata2 } from "@wp-typia/block-runtime/blocks";
|
|
234174
234214
|
function createDoctorCheck2(label, status, detail) {
|
|
234175
234215
|
return { detail, label, status };
|
|
@@ -234185,7 +234225,7 @@ function getWorkspaceBootstrapRelativePath(packageName) {
|
|
|
234185
234225
|
return `${packageBaseName}.php`;
|
|
234186
234226
|
}
|
|
234187
234227
|
function checkExistingFiles(projectDir, label, filePaths) {
|
|
234188
|
-
const missing = filePaths.filter((filePath) => typeof filePath === "string").filter((filePath) => !fs45.existsSync(
|
|
234228
|
+
const missing = filePaths.filter((filePath) => typeof filePath === "string").filter((filePath) => !fs45.existsSync(path60.join(projectDir, filePath)));
|
|
234189
234229
|
return createDoctorCheck2(label, missing.length === 0 ? "pass" : "fail", missing.length === 0 ? "All referenced files exist" : `Missing: ${missing.join(", ")}`);
|
|
234190
234230
|
}
|
|
234191
234231
|
function checkWorkspacePackageMetadata(workspace, packageJson) {
|
|
@@ -234211,24 +234251,24 @@ function checkWorkspacePackageMetadata(workspace, packageJson) {
|
|
|
234211
234251
|
if (wpTypia?.phpPrefix !== workspace.workspace.phpPrefix) {
|
|
234212
234252
|
issues.push(`wpTypia.phpPrefix must equal "${workspace.workspace.phpPrefix}"`);
|
|
234213
234253
|
}
|
|
234214
|
-
if (!fs45.existsSync(
|
|
234254
|
+
if (!fs45.existsSync(path60.join(workspace.projectDir, bootstrapRelativePath))) {
|
|
234215
234255
|
issues.push(`Missing bootstrap file ${bootstrapRelativePath}`);
|
|
234216
234256
|
}
|
|
234217
234257
|
return createDoctorCheck2("Workspace package metadata", issues.length === 0 ? "pass" : "fail", issues.length === 0 ? `package.json metadata aligns with ${workspace.packageName} and ${bootstrapRelativePath}` : issues.join("; "));
|
|
234218
234258
|
}
|
|
234219
234259
|
function getWorkspaceBlockRequiredFiles(block) {
|
|
234220
|
-
const blockDir =
|
|
234260
|
+
const blockDir = path60.join("src", "blocks", block.slug);
|
|
234221
234261
|
return Array.from(new Set([
|
|
234222
234262
|
block.typesFile,
|
|
234223
234263
|
block.apiTypesFile,
|
|
234224
234264
|
block.openApiFile,
|
|
234225
|
-
|
|
234226
|
-
...WORKSPACE_GENERATED_BLOCK_ARTIFACTS.map((fileName) =>
|
|
234265
|
+
path60.join(blockDir, "index.tsx"),
|
|
234266
|
+
...WORKSPACE_GENERATED_BLOCK_ARTIFACTS.map((fileName) => path60.join(blockDir, fileName))
|
|
234227
234267
|
].filter((filePath) => typeof filePath === "string")));
|
|
234228
234268
|
}
|
|
234229
234269
|
function checkWorkspaceBlockMetadata(projectDir, workspace, block) {
|
|
234230
|
-
const blockJsonRelativePath =
|
|
234231
|
-
const blockJsonPath =
|
|
234270
|
+
const blockJsonRelativePath = path60.join("src", "blocks", block.slug, "block.json");
|
|
234271
|
+
const blockJsonPath = path60.join(projectDir, blockJsonRelativePath);
|
|
234232
234272
|
if (!fs45.existsSync(blockJsonPath)) {
|
|
234233
234273
|
return createDoctorCheck2(`Block metadata ${block.slug}`, "fail", `Missing ${blockJsonRelativePath}`);
|
|
234234
234274
|
}
|
|
@@ -234249,8 +234289,8 @@ function checkWorkspaceBlockMetadata(projectDir, workspace, block) {
|
|
|
234249
234289
|
return createDoctorCheck2(`Block metadata ${block.slug}`, issues.length === 0 ? "pass" : "fail", issues.length === 0 ? `block.json matches ${expectedName} and ${workspace.workspace.textDomain}` : issues.join("; "));
|
|
234250
234290
|
}
|
|
234251
234291
|
function checkWorkspaceBlockHooks(projectDir, blockSlug) {
|
|
234252
|
-
const blockJsonRelativePath =
|
|
234253
|
-
const blockJsonPath =
|
|
234292
|
+
const blockJsonRelativePath = path60.join("src", "blocks", blockSlug, "block.json");
|
|
234293
|
+
const blockJsonPath = path60.join(projectDir, blockJsonRelativePath);
|
|
234254
234294
|
if (!fs45.existsSync(blockJsonPath)) {
|
|
234255
234295
|
return createDoctorCheck2(`Block hooks ${blockSlug}`, "fail", `Missing ${blockJsonRelativePath}`);
|
|
234256
234296
|
}
|
|
@@ -234272,8 +234312,8 @@ function checkWorkspaceBlockHooks(projectDir, blockSlug) {
|
|
|
234272
234312
|
return createDoctorCheck2(`Block hooks ${blockSlug}`, invalidEntries.length === 0 ? "pass" : "fail", invalidEntries.length === 0 ? `blockHooks metadata is valid${Object.keys(blockHooks).length > 0 ? ` (${Object.keys(blockHooks).join(", ")})` : ""}` : `Invalid blockHooks entries: ${invalidEntries.map(([anchor, position]) => `${anchor || "<empty>"} => ${String(position)}`).join(", ")}`);
|
|
234273
234313
|
}
|
|
234274
234314
|
function checkWorkspaceBlockCollectionImport(projectDir, blockSlug) {
|
|
234275
|
-
const entryRelativePath =
|
|
234276
|
-
const entryPath =
|
|
234315
|
+
const entryRelativePath = path60.join("src", "blocks", blockSlug, "index.tsx");
|
|
234316
|
+
const entryPath = path60.join(projectDir, entryRelativePath);
|
|
234277
234317
|
if (!fs45.existsSync(entryPath)) {
|
|
234278
234318
|
return createDoctorCheck2(`Block collection ${blockSlug}`, "fail", `Missing ${entryRelativePath}`);
|
|
234279
234319
|
}
|
|
@@ -234283,9 +234323,9 @@ function checkWorkspaceBlockCollectionImport(projectDir, blockSlug) {
|
|
|
234283
234323
|
}
|
|
234284
234324
|
function checkWorkspacePatternBootstrap(projectDir, packageName) {
|
|
234285
234325
|
const packageBaseName = packageName.split("/").pop() ?? packageName;
|
|
234286
|
-
const bootstrapPath =
|
|
234326
|
+
const bootstrapPath = path60.join(projectDir, `${packageBaseName}.php`);
|
|
234287
234327
|
if (!fs45.existsSync(bootstrapPath)) {
|
|
234288
|
-
return createDoctorCheck2("Pattern bootstrap", "fail", `Missing ${
|
|
234328
|
+
return createDoctorCheck2("Pattern bootstrap", "fail", `Missing ${path60.basename(bootstrapPath)}`);
|
|
234289
234329
|
}
|
|
234290
234330
|
const source = fs45.readFileSync(bootstrapPath, "utf8");
|
|
234291
234331
|
const hasCategoryAnchor = source.includes("register_block_pattern_category");
|
|
@@ -234294,9 +234334,9 @@ function checkWorkspacePatternBootstrap(projectDir, packageName) {
|
|
|
234294
234334
|
}
|
|
234295
234335
|
function checkWorkspaceBindingBootstrap(projectDir, packageName) {
|
|
234296
234336
|
const packageBaseName = packageName.split("/").pop() ?? packageName;
|
|
234297
|
-
const bootstrapPath =
|
|
234337
|
+
const bootstrapPath = path60.join(projectDir, `${packageBaseName}.php`);
|
|
234298
234338
|
if (!fs45.existsSync(bootstrapPath)) {
|
|
234299
|
-
return createDoctorCheck2("Binding bootstrap", "fail", `Missing ${
|
|
234339
|
+
return createDoctorCheck2("Binding bootstrap", "fail", `Missing ${path60.basename(bootstrapPath)}`);
|
|
234300
234340
|
}
|
|
234301
234341
|
const source = fs45.readFileSync(bootstrapPath, "utf8");
|
|
234302
234342
|
const hasServerGlob = source.includes(WORKSPACE_BINDING_SERVER_GLOB);
|
|
@@ -234306,11 +234346,11 @@ function checkWorkspaceBindingBootstrap(projectDir, packageName) {
|
|
|
234306
234346
|
return createDoctorCheck2("Binding bootstrap", hasServerGlob && hasEditorEnqueueHook && hasEditorScript && hasEditorAsset ? "pass" : "fail", hasServerGlob && hasEditorEnqueueHook && hasEditorScript && hasEditorAsset ? "Binding source PHP and editor bootstrap hooks are present" : "Missing binding source PHP require glob or editor enqueue hook");
|
|
234307
234347
|
}
|
|
234308
234348
|
function checkWorkspaceBindingSourcesIndex(projectDir, bindingSources) {
|
|
234309
|
-
const indexRelativePath = [
|
|
234349
|
+
const indexRelativePath = [path60.join("src", "bindings", "index.ts"), path60.join("src", "bindings", "index.js")].find((relativePath) => fs45.existsSync(path60.join(projectDir, relativePath)));
|
|
234310
234350
|
if (!indexRelativePath) {
|
|
234311
234351
|
return createDoctorCheck2("Binding sources index", "fail", "Missing src/bindings/index.ts or src/bindings/index.js");
|
|
234312
234352
|
}
|
|
234313
|
-
const indexPath =
|
|
234353
|
+
const indexPath = path60.join(projectDir, indexRelativePath);
|
|
234314
234354
|
const source = fs45.readFileSync(indexPath, "utf8");
|
|
234315
234355
|
const missingImports = bindingSources.filter((bindingSource) => !source.includes(`./${bindingSource.slug}/editor`));
|
|
234316
234356
|
return createDoctorCheck2("Binding sources index", missingImports.length === 0 ? "pass" : "fail", missingImports.length === 0 ? "Binding source editor registrations are aggregated" : `Missing editor imports for: ${missingImports.map((entry) => entry.slug).join(", ")}`);
|
|
@@ -234340,7 +234380,7 @@ function getWorkspaceRestResourceRequiredFiles(restResource) {
|
|
|
234340
234380
|
}
|
|
234341
234381
|
return Array.from(new Set([
|
|
234342
234382
|
restResource.apiFile,
|
|
234343
|
-
...Array.from(schemaNames, (schemaName) =>
|
|
234383
|
+
...Array.from(schemaNames, (schemaName) => path60.join(path60.dirname(restResource.typesFile), "api-schemas", `${schemaName}.schema.json`)),
|
|
234344
234384
|
restResource.clientFile,
|
|
234345
234385
|
restResource.dataFile,
|
|
234346
234386
|
restResource.openApiFile,
|
|
@@ -234356,9 +234396,9 @@ function checkWorkspaceRestResourceConfig(restResource) {
|
|
|
234356
234396
|
}
|
|
234357
234397
|
function checkWorkspaceRestResourceBootstrap(projectDir, packageName, phpPrefix) {
|
|
234358
234398
|
const packageBaseName = packageName.split("/").pop() ?? packageName;
|
|
234359
|
-
const bootstrapPath =
|
|
234399
|
+
const bootstrapPath = path60.join(projectDir, `${packageBaseName}.php`);
|
|
234360
234400
|
if (!fs45.existsSync(bootstrapPath)) {
|
|
234361
|
-
return createDoctorCheck2("REST resource bootstrap", "fail", `Missing ${
|
|
234401
|
+
return createDoctorCheck2("REST resource bootstrap", "fail", `Missing ${path60.basename(bootstrapPath)}`);
|
|
234362
234402
|
}
|
|
234363
234403
|
const source = fs45.readFileSync(bootstrapPath, "utf8");
|
|
234364
234404
|
const registerFunctionName = `${phpPrefix}_register_rest_resources`;
|
|
@@ -234379,7 +234419,7 @@ function getWorkspaceAbilityRequiredFiles(ability) {
|
|
|
234379
234419
|
]));
|
|
234380
234420
|
}
|
|
234381
234421
|
function checkWorkspaceAbilityConfig(projectDir, ability) {
|
|
234382
|
-
const configPath =
|
|
234422
|
+
const configPath = path60.join(projectDir, ability.configFile);
|
|
234383
234423
|
if (!fs45.existsSync(configPath)) {
|
|
234384
234424
|
return createDoctorCheck2(`Ability config ${ability.slug}`, "fail", `Missing ${ability.configFile}`);
|
|
234385
234425
|
}
|
|
@@ -234396,9 +234436,9 @@ function checkWorkspaceAbilityConfig(projectDir, ability) {
|
|
|
234396
234436
|
}
|
|
234397
234437
|
function checkWorkspaceAbilityBootstrap(projectDir, packageName, phpPrefix) {
|
|
234398
234438
|
const packageBaseName = packageName.split("/").pop() ?? packageName;
|
|
234399
|
-
const bootstrapPath =
|
|
234439
|
+
const bootstrapPath = path60.join(projectDir, `${packageBaseName}.php`);
|
|
234400
234440
|
if (!fs45.existsSync(bootstrapPath)) {
|
|
234401
|
-
return createDoctorCheck2("Ability bootstrap", "fail", `Missing ${
|
|
234441
|
+
return createDoctorCheck2("Ability bootstrap", "fail", `Missing ${path60.basename(bootstrapPath)}`);
|
|
234402
234442
|
}
|
|
234403
234443
|
const source = fs45.readFileSync(bootstrapPath, "utf8");
|
|
234404
234444
|
const loadFunctionName = `${phpPrefix}_load_workflow_abilities`;
|
|
@@ -234417,13 +234457,13 @@ function checkWorkspaceAbilityBootstrap(projectDir, packageName, phpPrefix) {
|
|
|
234417
234457
|
}
|
|
234418
234458
|
function checkWorkspaceAbilityIndex(projectDir, abilities) {
|
|
234419
234459
|
const indexRelativePath = [
|
|
234420
|
-
|
|
234421
|
-
|
|
234422
|
-
].find((relativePath) => fs45.existsSync(
|
|
234460
|
+
path60.join("src", "abilities", "index.ts"),
|
|
234461
|
+
path60.join("src", "abilities", "index.js")
|
|
234462
|
+
].find((relativePath) => fs45.existsSync(path60.join(projectDir, relativePath)));
|
|
234423
234463
|
if (!indexRelativePath) {
|
|
234424
234464
|
return createDoctorCheck2("Abilities index", "fail", "Missing src/abilities/index.ts or src/abilities/index.js");
|
|
234425
234465
|
}
|
|
234426
|
-
const indexPath =
|
|
234466
|
+
const indexPath = path60.join(projectDir, indexRelativePath);
|
|
234427
234467
|
const source = fs45.readFileSync(indexPath, "utf8");
|
|
234428
234468
|
const missingExports = abilities.filter((ability) => {
|
|
234429
234469
|
const exportPattern = new RegExp(`^\\s*export\\s+(?:\\*\\s+from|\\{[^}]+\\}\\s+from)\\s+['"\`]\\./${escapeRegex7(ability.slug)}\\/client['"\`]`, "mu");
|
|
@@ -234435,9 +234475,9 @@ function getWorkspaceAiFeatureRequiredFiles(aiFeature) {
|
|
|
234435
234475
|
return Array.from(new Set([
|
|
234436
234476
|
aiFeature.aiSchemaFile,
|
|
234437
234477
|
aiFeature.apiFile,
|
|
234438
|
-
|
|
234439
|
-
|
|
234440
|
-
|
|
234478
|
+
path60.join(path60.dirname(aiFeature.typesFile), "api-schemas", "feature-request.schema.json"),
|
|
234479
|
+
path60.join(path60.dirname(aiFeature.typesFile), "api-schemas", "feature-response.schema.json"),
|
|
234480
|
+
path60.join(path60.dirname(aiFeature.typesFile), "api-schemas", "feature-result.schema.json"),
|
|
234441
234481
|
aiFeature.clientFile,
|
|
234442
234482
|
aiFeature.dataFile,
|
|
234443
234483
|
aiFeature.openApiFile,
|
|
@@ -234452,9 +234492,9 @@ function checkWorkspaceAiFeatureConfig(aiFeature) {
|
|
|
234452
234492
|
}
|
|
234453
234493
|
function checkWorkspaceAiFeatureBootstrap(projectDir, packageName, phpPrefix) {
|
|
234454
234494
|
const packageBaseName = packageName.split("/").pop() ?? packageName;
|
|
234455
|
-
const bootstrapPath =
|
|
234495
|
+
const bootstrapPath = path60.join(projectDir, `${packageBaseName}.php`);
|
|
234456
234496
|
if (!fs45.existsSync(bootstrapPath)) {
|
|
234457
|
-
return createDoctorCheck2("AI feature bootstrap", "fail", `Missing ${
|
|
234497
|
+
return createDoctorCheck2("AI feature bootstrap", "fail", `Missing ${path60.basename(bootstrapPath)}`);
|
|
234458
234498
|
}
|
|
234459
234499
|
const source = fs45.readFileSync(bootstrapPath, "utf8");
|
|
234460
234500
|
const registerFunctionName = `${phpPrefix}_register_ai_features`;
|
|
@@ -234464,13 +234504,13 @@ function checkWorkspaceAiFeatureBootstrap(projectDir, packageName, phpPrefix) {
|
|
|
234464
234504
|
return createDoctorCheck2("AI feature bootstrap", hasServerGlob && hasRegisterHook ? "pass" : "fail", hasServerGlob && hasRegisterHook ? "AI feature PHP loader hook is present" : "Missing AI feature PHP require glob or init hook");
|
|
234465
234505
|
}
|
|
234466
234506
|
function getWorkspaceEditorPluginRequiredFiles(editorPlugin) {
|
|
234467
|
-
const editorPluginDir =
|
|
234507
|
+
const editorPluginDir = path60.join("src", "editor-plugins", editorPlugin.slug);
|
|
234468
234508
|
return Array.from(new Set([
|
|
234469
234509
|
editorPlugin.file,
|
|
234470
|
-
|
|
234471
|
-
|
|
234472
|
-
|
|
234473
|
-
|
|
234510
|
+
path60.join(editorPluginDir, "Sidebar.tsx"),
|
|
234511
|
+
path60.join(editorPluginDir, "data.ts"),
|
|
234512
|
+
path60.join(editorPluginDir, "types.ts"),
|
|
234513
|
+
path60.join(editorPluginDir, "style.scss")
|
|
234474
234514
|
]));
|
|
234475
234515
|
}
|
|
234476
234516
|
function checkWorkspaceEditorPluginConfig(editorPlugin) {
|
|
@@ -234480,9 +234520,9 @@ function checkWorkspaceEditorPluginConfig(editorPlugin) {
|
|
|
234480
234520
|
}
|
|
234481
234521
|
function checkWorkspaceEditorPluginBootstrap(projectDir, packageName, phpPrefix) {
|
|
234482
234522
|
const packageBaseName = packageName.split("/").pop() ?? packageName;
|
|
234483
|
-
const bootstrapPath =
|
|
234523
|
+
const bootstrapPath = path60.join(projectDir, `${packageBaseName}.php`);
|
|
234484
234524
|
if (!fs45.existsSync(bootstrapPath)) {
|
|
234485
|
-
return createDoctorCheck2("Editor plugin bootstrap", "fail", `Missing ${
|
|
234525
|
+
return createDoctorCheck2("Editor plugin bootstrap", "fail", `Missing ${path60.basename(bootstrapPath)}`);
|
|
234486
234526
|
}
|
|
234487
234527
|
const source = fs45.readFileSync(bootstrapPath, "utf8");
|
|
234488
234528
|
const enqueueFunctionName = `${phpPrefix}_enqueue_editor_plugins_editor`;
|
|
@@ -234495,13 +234535,13 @@ function checkWorkspaceEditorPluginBootstrap(projectDir, packageName, phpPrefix)
|
|
|
234495
234535
|
}
|
|
234496
234536
|
function checkWorkspaceEditorPluginIndex(projectDir, editorPlugins) {
|
|
234497
234537
|
const indexRelativePath = [
|
|
234498
|
-
|
|
234499
|
-
|
|
234500
|
-
].find((relativePath) => fs45.existsSync(
|
|
234538
|
+
path60.join("src", "editor-plugins", "index.ts"),
|
|
234539
|
+
path60.join("src", "editor-plugins", "index.js")
|
|
234540
|
+
].find((relativePath) => fs45.existsSync(path60.join(projectDir, relativePath)));
|
|
234501
234541
|
if (!indexRelativePath) {
|
|
234502
234542
|
return createDoctorCheck2("Editor plugins index", "fail", "Missing src/editor-plugins/index.ts or src/editor-plugins/index.js");
|
|
234503
234543
|
}
|
|
234504
|
-
const indexPath =
|
|
234544
|
+
const indexPath = path60.join(projectDir, indexRelativePath);
|
|
234505
234545
|
const source = fs45.readFileSync(indexPath, "utf8");
|
|
234506
234546
|
const missingImports = editorPlugins.filter((editorPlugin) => {
|
|
234507
234547
|
const importPattern = new RegExp(`['"\`]\\./${escapeRegex7(editorPlugin.slug)}(?:/[^'"\`]*)?['"\`]`, "u");
|
|
@@ -234510,9 +234550,9 @@ function checkWorkspaceEditorPluginIndex(projectDir, editorPlugins) {
|
|
|
234510
234550
|
return createDoctorCheck2("Editor plugins index", missingImports.length === 0 ? "pass" : "fail", missingImports.length === 0 ? "Editor plugin registrations are aggregated" : `Missing editor plugin imports for: ${missingImports.map((entry) => entry.slug).join(", ")}`);
|
|
234511
234551
|
}
|
|
234512
234552
|
function checkVariationEntrypoint(projectDir, blockSlug) {
|
|
234513
|
-
const entryPath =
|
|
234553
|
+
const entryPath = path60.join(projectDir, "src", "blocks", blockSlug, "index.tsx");
|
|
234514
234554
|
if (!fs45.existsSync(entryPath)) {
|
|
234515
|
-
return createDoctorCheck2(`Variation entrypoint ${blockSlug}`, "fail", `Missing ${
|
|
234555
|
+
return createDoctorCheck2(`Variation entrypoint ${blockSlug}`, "fail", `Missing ${path60.relative(projectDir, entryPath)}`);
|
|
234516
234556
|
}
|
|
234517
234557
|
const source = fs45.readFileSync(entryPath, "utf8");
|
|
234518
234558
|
const hasImport = source.includes("./variations");
|
|
@@ -234521,8 +234561,8 @@ function checkVariationEntrypoint(projectDir, blockSlug) {
|
|
|
234521
234561
|
}
|
|
234522
234562
|
function checkMigrationWorkspaceHint(workspace, packageJson) {
|
|
234523
234563
|
const hasMigrationScript = typeof packageJson.scripts?.["migration:doctor"] === "string";
|
|
234524
|
-
const migrationConfigRelativePath =
|
|
234525
|
-
const hasMigrationConfig = fs45.existsSync(
|
|
234564
|
+
const migrationConfigRelativePath = path60.join("src", "migrations", "config.ts");
|
|
234565
|
+
const hasMigrationConfig = fs45.existsSync(path60.join(workspace.projectDir, migrationConfigRelativePath));
|
|
234526
234566
|
if (!hasMigrationScript && !hasMigrationConfig) {
|
|
234527
234567
|
return null;
|
|
234528
234568
|
}
|
|
@@ -234580,7 +234620,7 @@ function getWorkspaceDoctorChecks(cwd) {
|
|
|
234580
234620
|
for (const blockSlug of variationTargetBlocks) {
|
|
234581
234621
|
checks3.push(checkVariationEntrypoint(workspace.projectDir, blockSlug));
|
|
234582
234622
|
}
|
|
234583
|
-
const shouldCheckPatternBootstrap = inventory.patterns.length > 0 || fs45.existsSync(
|
|
234623
|
+
const shouldCheckPatternBootstrap = inventory.patterns.length > 0 || fs45.existsSync(path60.join(workspace.projectDir, "src", "patterns"));
|
|
234584
234624
|
if (shouldCheckPatternBootstrap) {
|
|
234585
234625
|
checks3.push(checkWorkspacePatternBootstrap(workspace.projectDir, workspace.packageName));
|
|
234586
234626
|
}
|
|
@@ -234696,12 +234736,12 @@ __export(exports_cli_init, {
|
|
|
234696
234736
|
getInitPlan: () => getInitPlan
|
|
234697
234737
|
});
|
|
234698
234738
|
import fs46 from "fs";
|
|
234699
|
-
import
|
|
234739
|
+
import path61 from "path";
|
|
234700
234740
|
function normalizeRelativePath2(value2) {
|
|
234701
234741
|
return value2.replace(/\\/gu, "/");
|
|
234702
234742
|
}
|
|
234703
234743
|
function readProjectPackageJson(projectDir) {
|
|
234704
|
-
const packageJsonPath =
|
|
234744
|
+
const packageJsonPath = path61.join(projectDir, "package.json");
|
|
234705
234745
|
if (!fs46.existsSync(packageJsonPath)) {
|
|
234706
234746
|
return null;
|
|
234707
234747
|
}
|
|
@@ -234711,13 +234751,13 @@ function inferInitPackageManager(projectDir, packageJson) {
|
|
|
234711
234751
|
if (packageJson?.packageManager) {
|
|
234712
234752
|
return parseWorkspacePackageManagerId(packageJson.packageManager);
|
|
234713
234753
|
}
|
|
234714
|
-
if (fs46.existsSync(
|
|
234754
|
+
if (fs46.existsSync(path61.join(projectDir, "bun.lock")) || fs46.existsSync(path61.join(projectDir, "bun.lockb"))) {
|
|
234715
234755
|
return "bun";
|
|
234716
234756
|
}
|
|
234717
|
-
if (fs46.existsSync(
|
|
234757
|
+
if (fs46.existsSync(path61.join(projectDir, "pnpm-lock.yaml"))) {
|
|
234718
234758
|
return "pnpm";
|
|
234719
234759
|
}
|
|
234720
|
-
if (fs46.existsSync(
|
|
234760
|
+
if (fs46.existsSync(path61.join(projectDir, "yarn.lock")) || fs46.existsSync(path61.join(projectDir, ".yarnrc.yml"))) {
|
|
234721
234761
|
return "yarn";
|
|
234722
234762
|
}
|
|
234723
234763
|
return "npm";
|
|
@@ -234792,13 +234832,13 @@ function buildPackageManagerFieldChange(packageJson, packageManager) {
|
|
|
234792
234832
|
};
|
|
234793
234833
|
}
|
|
234794
234834
|
function buildGeneratedArtifactPaths(blockJsonFile, manifestFile) {
|
|
234795
|
-
const manifestDir =
|
|
234835
|
+
const manifestDir = path61.dirname(manifestFile);
|
|
234796
234836
|
const artifactPaths = [
|
|
234797
234837
|
blockJsonFile,
|
|
234798
234838
|
manifestFile,
|
|
234799
|
-
|
|
234800
|
-
|
|
234801
|
-
|
|
234839
|
+
path61.join(manifestDir, "typia.schema.json"),
|
|
234840
|
+
path61.join(manifestDir, "typia-validator.php"),
|
|
234841
|
+
path61.join(manifestDir, "typia.openapi.json")
|
|
234802
234842
|
];
|
|
234803
234843
|
return Array.from(new Set(artifactPaths.map((filePath) => normalizeRelativePath2(filePath))));
|
|
234804
234844
|
}
|
|
@@ -234910,7 +234950,7 @@ function buildRequiredDevDependencyMapEntries() {
|
|
|
234910
234950
|
return Object.entries(buildRequiredDevDependencyMap()).map(([name2, version2]) => `${name2}@${version2.replace(/^workspace:/u, "")}`);
|
|
234911
234951
|
}
|
|
234912
234952
|
function getInitPlan(projectDir) {
|
|
234913
|
-
const resolvedProjectDir =
|
|
234953
|
+
const resolvedProjectDir = path61.resolve(projectDir);
|
|
234914
234954
|
const packageJson = readProjectPackageJson(resolvedProjectDir);
|
|
234915
234955
|
const packageManager = inferInitPackageManager(resolvedProjectDir, packageJson);
|
|
234916
234956
|
const workspace = tryResolveWorkspaceProject(resolvedProjectDir);
|
|
@@ -234942,7 +234982,7 @@ function getInitPlan(projectDir) {
|
|
|
234942
234982
|
summary: "This directory is already an official wp-typia workspace. No retrofit bootstrap is needed."
|
|
234943
234983
|
};
|
|
234944
234984
|
}
|
|
234945
|
-
const projectName = typeof packageJson?.name === "string" && packageJson.name.length > 0 ? packageJson.name :
|
|
234985
|
+
const projectName = typeof packageJson?.name === "string" && packageJson.name.length > 0 ? packageJson.name : path61.basename(resolvedProjectDir);
|
|
234946
234986
|
const layout = buildLayoutDetails(resolvedProjectDir);
|
|
234947
234987
|
const dependencyChanges = buildDependencyChanges(packageJson);
|
|
234948
234988
|
const scriptChanges = buildScriptChanges(packageJson, packageManager);
|
|
@@ -235025,18 +235065,18 @@ __export(exports_cli_scaffold, {
|
|
|
235025
235065
|
});
|
|
235026
235066
|
import fs47 from "fs";
|
|
235027
235067
|
import { promises as fsp23 } from "fs";
|
|
235028
|
-
import
|
|
235068
|
+
import path62 from "path";
|
|
235029
235069
|
async function listRelativeProjectFiles(rootDir) {
|
|
235030
235070
|
const relativeFiles = [];
|
|
235031
235071
|
async function visit2(currentDir) {
|
|
235032
235072
|
const entries = await fsp23.readdir(currentDir, { withFileTypes: true });
|
|
235033
235073
|
for (const entry of entries) {
|
|
235034
|
-
const absolutePath =
|
|
235074
|
+
const absolutePath = path62.join(currentDir, entry.name);
|
|
235035
235075
|
if (entry.isDirectory()) {
|
|
235036
235076
|
await visit2(absolutePath);
|
|
235037
235077
|
continue;
|
|
235038
235078
|
}
|
|
235039
|
-
relativeFiles.push(
|
|
235079
|
+
relativeFiles.push(path62.relative(rootDir, absolutePath).replace(path62.sep === "\\" ? /\\/gu : /\//gu, "/"));
|
|
235040
235080
|
}
|
|
235041
235081
|
}
|
|
235042
235082
|
await visit2(rootDir);
|
|
@@ -235074,7 +235114,7 @@ async function buildScaffoldDryRunPlan({
|
|
|
235074
235114
|
}) {
|
|
235075
235115
|
await assertDryRunTargetDirectoryReady(projectDir, allowExistingDir);
|
|
235076
235116
|
const { path: tempRoot, cleanup } = await createManagedTempRoot("wp-typia-scaffold-plan-");
|
|
235077
|
-
const previewProjectDir =
|
|
235117
|
+
const previewProjectDir = path62.join(tempRoot, "preview-project");
|
|
235078
235118
|
try {
|
|
235079
235119
|
const result = await scaffoldProject({
|
|
235080
235120
|
allowExistingDir: false,
|
|
@@ -235114,14 +235154,14 @@ function validateCreateProjectInput(projectInput) {
|
|
|
235114
235154
|
if (normalizedProjectInput.length === 0) {
|
|
235115
235155
|
throw new Error("Project directory is required. Usage: wp-typia create <project-dir> (or wp-typia <project-dir> when <project-dir> is the only positional argument).");
|
|
235116
235156
|
}
|
|
235117
|
-
const normalizedProjectPath =
|
|
235157
|
+
const normalizedProjectPath = path62.normalize(normalizedProjectInput).replace(/[\\/]+$/u, "") || path62.normalize(normalizedProjectInput);
|
|
235118
235158
|
if (normalizedProjectPath === "." || normalizedProjectPath === "..") {
|
|
235119
235159
|
throw new Error("`wp-typia create` requires a new project directory. Use an explicit child directory instead of `.` or `..`.");
|
|
235120
235160
|
}
|
|
235121
235161
|
}
|
|
235122
235162
|
function collectProjectDirectoryWarnings(projectDir) {
|
|
235123
235163
|
const warnings = [];
|
|
235124
|
-
const projectName =
|
|
235164
|
+
const projectName = path62.basename(projectDir);
|
|
235125
235165
|
if (/\s/u.test(projectName)) {
|
|
235126
235166
|
warnings.push(`Project directory "${projectName}" contains spaces. The generated next-step commands will be quoted, but a simple kebab-case directory name is usually easier to use with shells and downstream tooling.`);
|
|
235127
235167
|
}
|
|
@@ -235276,7 +235316,7 @@ function getNextSteps({
|
|
|
235276
235316
|
noInstall,
|
|
235277
235317
|
templateId
|
|
235278
235318
|
}) {
|
|
235279
|
-
const cdTarget =
|
|
235319
|
+
const cdTarget = path62.isAbsolute(projectInput) ? projectDir : projectInput;
|
|
235280
235320
|
const steps = [`cd ${quoteShellValue(cdTarget)}`];
|
|
235281
235321
|
if (noInstall) {
|
|
235282
235322
|
steps.push(formatInstallCommand(packageManager));
|
|
@@ -235424,8 +235464,8 @@ async function runScaffoldFlow({
|
|
|
235424
235464
|
select: selectWithMigrationUi,
|
|
235425
235465
|
yes
|
|
235426
235466
|
});
|
|
235427
|
-
const projectDir =
|
|
235428
|
-
const projectName =
|
|
235467
|
+
const projectDir = path62.resolve(cwd, projectInput);
|
|
235468
|
+
const projectName = path62.basename(projectDir);
|
|
235429
235469
|
const answers = await collectScaffoldAnswers({
|
|
235430
235470
|
dataStorageMode: resolvedDataStorage,
|
|
235431
235471
|
namespace,
|
|
@@ -235488,7 +235528,7 @@ async function runScaffoldFlow({
|
|
|
235488
235528
|
let availableScripts;
|
|
235489
235529
|
if (!dryRun) {
|
|
235490
235530
|
try {
|
|
235491
|
-
const parsedPackageJson = JSON.parse(fs47.readFileSync(
|
|
235531
|
+
const parsedPackageJson = JSON.parse(fs47.readFileSync(path62.join(projectDir, "package.json"), "utf8"));
|
|
235492
235532
|
const scripts = parsedPackageJson.scripts && typeof parsedPackageJson.scripts === "object" && !Array.isArray(parsedPackageJson.scripts) ? parsedPackageJson.scripts : {};
|
|
235493
235533
|
availableScripts = Object.entries(scripts).filter(([, value2]) => typeof value2 === "string").map(([scriptName]) => scriptName);
|
|
235494
235534
|
} catch {
|
|
@@ -288849,7 +288889,7 @@ import path10 from "path";
|
|
|
288849
288889
|
// package.json
|
|
288850
288890
|
var package_default2 = {
|
|
288851
288891
|
name: "wp-typia",
|
|
288852
|
-
version: "0.20.
|
|
288892
|
+
version: "0.20.5",
|
|
288853
288893
|
description: "Canonical CLI package for wp-typia scaffolding and project workflows",
|
|
288854
288894
|
packageManager: "bun@1.3.11",
|
|
288855
288895
|
type: "module",
|
|
@@ -288917,7 +288957,7 @@ var package_default2 = {
|
|
|
288917
288957
|
"@bunli/tui": "0.6.0",
|
|
288918
288958
|
"@bunli/utils": "0.6.0",
|
|
288919
288959
|
"@wp-typia/api-client": "^0.4.5",
|
|
288920
|
-
"@wp-typia/project-tools": "0.20.
|
|
288960
|
+
"@wp-typia/project-tools": "0.20.2",
|
|
288921
288961
|
"better-result": "^2.7.0",
|
|
288922
288962
|
react: "^19.2.5",
|
|
288923
288963
|
"react-dom": "^19.2.5",
|
|
@@ -290686,7 +290726,7 @@ init_cli_diagnostics();
|
|
|
290686
290726
|
|
|
290687
290727
|
// src/mcp.ts
|
|
290688
290728
|
import fs48 from "fs/promises";
|
|
290689
|
-
import
|
|
290729
|
+
import path63 from "path";
|
|
290690
290730
|
|
|
290691
290731
|
// ../../node_modules/.bun/@bunli+plugin-mcp@0.2.5+ef72ce197b058209/node_modules/@bunli/plugin-mcp/src/errors.ts
|
|
290692
290732
|
class SchemaConversionError extends TaggedError("SchemaConversionError")() {
|
|
@@ -291214,7 +291254,7 @@ function isToolGroup(value2) {
|
|
|
291214
291254
|
return isObject3(value2) && typeof value2.namespace === "string" && Array.isArray(value2.tools) && value2.tools.every(isTool);
|
|
291215
291255
|
}
|
|
291216
291256
|
async function readSchemaSource(cwd, source) {
|
|
291217
|
-
const schemaPath =
|
|
291257
|
+
const schemaPath = path63.resolve(cwd, source.path);
|
|
291218
291258
|
const raw = await fs48.readFile(schemaPath, "utf8");
|
|
291219
291259
|
const parsed = JSON.parse(raw);
|
|
291220
291260
|
if (isToolGroup(parsed)) {
|
|
@@ -291231,7 +291271,7 @@ async function readSchemaSource(cwd, source) {
|
|
|
291231
291271
|
async function loadMcpToolGroups(cwd, schemaSources) {
|
|
291232
291272
|
return Promise.all(schemaSources.map((source) => readSchemaSource(cwd, source)));
|
|
291233
291273
|
}
|
|
291234
|
-
async function syncMcpSchemas(cwd, schemaSources, outputDir =
|
|
291274
|
+
async function syncMcpSchemas(cwd, schemaSources, outputDir = path63.join(cwd, ".bunli", "mcp")) {
|
|
291235
291275
|
const groups = await loadMcpToolGroups(cwd, schemaSources);
|
|
291236
291276
|
const result = await generateMCPTypes({
|
|
291237
291277
|
outputDir,
|
|
@@ -291254,7 +291294,7 @@ async function syncMcpSchemas(cwd, schemaSources, outputDir = path62.join(cwd, "
|
|
|
291254
291294
|
}
|
|
291255
291295
|
}
|
|
291256
291296
|
await fs48.mkdir(outputDir, { recursive: true });
|
|
291257
|
-
await fs48.writeFile(
|
|
291297
|
+
await fs48.writeFile(path63.join(outputDir, "registry.json"), `${JSON.stringify(registry2, null, 2)}
|
|
291258
291298
|
`, "utf8");
|
|
291259
291299
|
return {
|
|
291260
291300
|
commandCount: registry2.reduce((count, group) => count + group.tools.length, 0),
|
|
@@ -291576,4 +291616,4 @@ export {
|
|
|
291576
291616
|
cli
|
|
291577
291617
|
};
|
|
291578
291618
|
|
|
291579
|
-
//# debugId=
|
|
291619
|
+
//# debugId=609DB696D1E292A064756E2164756E21
|