wp-typia 0.22.0 → 0.22.1
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 +655 -520
- package/dist-bunli/{cli-ktp869eh.js → cli-0p8wz4a4.js} +36 -23
- package/dist-bunli/{cli-39er8888.js → cli-1sm60g1z.js} +19 -2
- package/dist-bunli/{cli-j180bk07.js → cli-5md428hf.js} +6 -2
- package/dist-bunli/{cli-1w5vkye4.js → cli-886tjd8m.js} +6 -6
- package/dist-bunli/{cli-add-kjhghdqq.js → cli-add-5z3wpzkh.js} +283 -264
- package/dist-bunli/{cli-doctor-p3jxvn0k.js → cli-doctor-jd7qyr5s.js} +1 -1
- package/dist-bunli/{cli-init-djhwr245.js → cli-init-10nktmme.js} +2 -2
- package/dist-bunli/{cli-scaffold-376yw891.js → cli-scaffold-837x3xsv.js} +4 -4
- package/dist-bunli/{cli-e623rs7g.js → cli-yzmkz95r.js} +1 -1
- package/dist-bunli/cli.js +2 -2
- package/dist-bunli/{command-list-jt1a1w7r.js → command-list-tgyxdhb0.js} +184 -127
- package/dist-bunli/{migrations-nwas5bwt.js → migrations-x3a9t9yf.js} +2 -2
- package/dist-bunli/node-cli.js +287 -197
- package/package.json +2 -2
|
@@ -36061,6 +36061,10 @@ function toSnakeCase(input) {
|
|
|
36061
36061
|
function toPascalCase(input) {
|
|
36062
36062
|
return toKebabCase(input).split("-").filter(Boolean).map(capitalizeSegment).join("");
|
|
36063
36063
|
}
|
|
36064
|
+
function toCamelCase(input) {
|
|
36065
|
+
const pascalCase = toPascalCase(input);
|
|
36066
|
+
return `${pascalCase.charAt(0).toLowerCase()}${pascalCase.slice(1)}`;
|
|
36067
|
+
}
|
|
36064
36068
|
function toSegmentPascalCase(input) {
|
|
36065
36069
|
return input.replace(/[^A-Za-z0-9]+/g, " ").trim().split(/\s+/).filter(Boolean).map(capitalizeSegment).join("");
|
|
36066
36070
|
}
|
|
@@ -213271,6 +213275,16 @@ function readPackageManifest(location) {
|
|
|
213271
213275
|
}
|
|
213272
213276
|
return JSON.parse(location.source);
|
|
213273
213277
|
}
|
|
213278
|
+
function tryReadPackageManifest(location) {
|
|
213279
|
+
if (!location) {
|
|
213280
|
+
return null;
|
|
213281
|
+
}
|
|
213282
|
+
try {
|
|
213283
|
+
return readPackageManifest(location);
|
|
213284
|
+
} catch {
|
|
213285
|
+
return null;
|
|
213286
|
+
}
|
|
213287
|
+
}
|
|
213274
213288
|
function resolveInstalledPackageManifestLocation(packageName) {
|
|
213275
213289
|
try {
|
|
213276
213290
|
return resolvePackageManifestLocation(require2.resolve(`${packageName}/package.json`));
|
|
@@ -213288,6 +213302,13 @@ function resolveInstalledPackageManifestLocation(packageName) {
|
|
|
213288
213302
|
function composePackageVersionsCacheKey(locations) {
|
|
213289
213303
|
return locations.map((location) => location.cacheKey).join("|");
|
|
213290
213304
|
}
|
|
213305
|
+
function resolveManagedPackageVersionRange(options) {
|
|
213306
|
+
const workspaceManifestLocation = options.workspacePackageDirName ? resolvePackageManifestLocation(path31.join(PROJECT_TOOLS_PACKAGE_ROOT, "..", options.workspacePackageDirName, "package.json")) : null;
|
|
213307
|
+
const installedManifestLocation = resolveInstalledPackageManifestLocation(options.packageName);
|
|
213308
|
+
const workspaceManifest = tryReadPackageManifest(workspaceManifestLocation);
|
|
213309
|
+
const installedManifest = tryReadPackageManifest(installedManifestLocation);
|
|
213310
|
+
return normalizeVersionRangeWithFallback(workspaceManifest?.version ?? installedManifest?.version, options.fallback);
|
|
213311
|
+
}
|
|
213291
213312
|
function getPackageVersions() {
|
|
213292
213313
|
const createManifestLocation = resolvePackageManifestLocation(path31.join(PROJECT_TOOLS_PACKAGE_ROOT, "package.json"));
|
|
213293
213314
|
const monorepoManifestLocation = resolvePackageManifestLocation(path31.join(PROJECT_TOOLS_PACKAGE_ROOT, "..", "..", "package.json"));
|
|
@@ -226861,7 +226882,7 @@ type InteractivityActionShape = object;
|
|
|
226861
226882
|
type InteractivityCallbackShape = object;
|
|
226862
226883
|
type InteractivityContextShape = object;
|
|
226863
226884
|
type InteractivityStateShape = object;
|
|
226864
|
-
type InteractivityCallable =
|
|
226885
|
+
type InteractivityCallable = CallableFunction;
|
|
226865
226886
|
type InteractivityKey<T extends object> = Extract<keyof T, string>;
|
|
226866
226887
|
type InteractivityMethodKey<T extends object> = {
|
|
226867
226888
|
[Key in InteractivityKey<T>]: T[Key] extends InteractivityCallable ? Key : never;
|
|
@@ -226964,7 +226985,7 @@ export function defineInteractivityStore<
|
|
|
226964
226985
|
};
|
|
226965
226986
|
}
|
|
226966
226987
|
|
|
226967
|
-
type InteractivityActionHandler =
|
|
226988
|
+
type InteractivityActionHandler = CallableFunction;
|
|
226968
226989
|
|
|
226969
226990
|
export interface {{pascalCase}}StoreActions {
|
|
226970
226991
|
handleClick: InteractivityActionHandler;
|
|
@@ -230697,32 +230718,30 @@ var init_cli_add_block = __esm(() => {
|
|
|
230697
230718
|
WORKSPACE_INSTALL_MARKERS = ["node_modules", ".pnp.cjs", ".pnp.loader.mjs"];
|
|
230698
230719
|
});
|
|
230699
230720
|
|
|
230700
|
-
// ../wp-typia-project-tools/src/runtime/cli-add-workspace-admin-view.ts
|
|
230701
|
-
|
|
230702
|
-
|
|
230703
|
-
import { createRequire as createRequire4 } from "module";
|
|
230704
|
-
import path51 from "path";
|
|
230705
|
-
function toCamelCase(input) {
|
|
230706
|
-
const pascalCase = toPascalCase(input);
|
|
230707
|
-
return `${pascalCase.charAt(0).toLowerCase()}${pascalCase.slice(1)}`;
|
|
230721
|
+
// ../wp-typia-project-tools/src/runtime/cli-add-workspace-admin-view-types.ts
|
|
230722
|
+
function isAdminViewCoreDataSource(source) {
|
|
230723
|
+
return source?.kind === ADMIN_VIEW_CORE_DATA_SOURCE_KIND;
|
|
230708
230724
|
}
|
|
230709
|
-
function
|
|
230710
|
-
|
|
230711
|
-
if (!trimmed || trimmed.startsWith("workspace:")) {
|
|
230712
|
-
return fallback;
|
|
230713
|
-
}
|
|
230714
|
-
return /^[~^<>=]/u.test(trimmed) ? trimmed : `^${trimmed}`;
|
|
230725
|
+
function isAdminViewRestResourceSource(source) {
|
|
230726
|
+
return source?.kind === ADMIN_VIEW_REST_SOURCE_KIND;
|
|
230715
230727
|
}
|
|
230716
|
-
function
|
|
230717
|
-
|
|
230718
|
-
return
|
|
230719
|
-
} catch {
|
|
230720
|
-
return;
|
|
230728
|
+
function formatAdminViewSourceLocator(source) {
|
|
230729
|
+
if (isAdminViewCoreDataSource(source)) {
|
|
230730
|
+
return `${source.kind}:${source.entityKind}/${source.entityName}`;
|
|
230721
230731
|
}
|
|
230732
|
+
return `${source.kind}:${source.slug}`;
|
|
230722
230733
|
}
|
|
230723
|
-
|
|
230724
|
-
|
|
230725
|
-
|
|
230734
|
+
var ADMIN_VIEW_REST_SOURCE_KIND = "rest-resource", ADMIN_VIEW_CORE_DATA_SOURCE_KIND = "core-data", ADMIN_VIEW_CORE_DATA_ENTITY_KIND_IDS, ADMIN_VIEW_CORE_DATA_ENTITY_SEGMENT_PATTERN, ADMIN_VIEW_CORE_DATA_ENTITY_NAME_PATTERN, ADMIN_VIEW_SOURCE_USAGE = "wp-typia add admin-view <name> --source <rest-resource:slug|core-data:kind/name>", ADMIN_VIEWS_SCRIPT = "build/admin-views/index.js", ADMIN_VIEWS_ASSET = "build/admin-views/index.asset.php", ADMIN_VIEWS_STYLE = "build/admin-views/style-index.css", ADMIN_VIEWS_STYLE_RTL = "build/admin-views/style-index-rtl.css", ADMIN_VIEWS_PHP_GLOB = "/inc/admin-views/*.php", ADMIN_VIEW_ALLOW_UNPUBLISHED_DATAVIEWS_ENV = "WP_TYPIA_ALLOW_UNPUBLISHED_DATAVIEWS", ADMIN_VIEW_PUBLIC_INSTALLS_ENABLED = false;
|
|
230735
|
+
var init_cli_add_workspace_admin_view_types = __esm(() => {
|
|
230736
|
+
ADMIN_VIEW_CORE_DATA_ENTITY_KIND_IDS = [
|
|
230737
|
+
"postType",
|
|
230738
|
+
"taxonomy"
|
|
230739
|
+
];
|
|
230740
|
+
ADMIN_VIEW_CORE_DATA_ENTITY_SEGMENT_PATTERN = /^[A-Za-z][A-Za-z0-9_-]*$/u;
|
|
230741
|
+
ADMIN_VIEW_CORE_DATA_ENTITY_NAME_PATTERN = /^[a-z0-9][a-z0-9_-]*$/u;
|
|
230742
|
+
});
|
|
230743
|
+
|
|
230744
|
+
// ../wp-typia-project-tools/src/runtime/cli-add-workspace-admin-view-source.ts
|
|
230726
230745
|
function isAdminViewUnpublishedDataViewsOverrideEnabled() {
|
|
230727
230746
|
return process.env[ADMIN_VIEW_ALLOW_UNPUBLISHED_DATAVIEWS_ENV]?.trim() === "1";
|
|
230728
230747
|
}
|
|
@@ -230732,36 +230751,6 @@ function assertAdminViewPackageAvailability() {
|
|
|
230732
230751
|
}
|
|
230733
230752
|
throw createCliDiagnosticCodeError(CLI_DIAGNOSTIC_CODES.INVALID_ARGUMENT, "`wp-typia add admin-view` is temporarily unavailable because `@wp-typia/dataviews` is not published to npm for public installs yet.");
|
|
230734
230753
|
}
|
|
230735
|
-
function detectJsonIndent(source) {
|
|
230736
|
-
const indentMatch = /\n([ \t]+)"/u.exec(source);
|
|
230737
|
-
return indentMatch?.[1] ?? 2;
|
|
230738
|
-
}
|
|
230739
|
-
function resolvePackageVersionRange(packageName, fallback, workspacePackageDirName) {
|
|
230740
|
-
if (workspacePackageDirName) {
|
|
230741
|
-
const workspaceVersion = readPackageManifestVersion(path51.join(PROJECT_TOOLS_PACKAGE_ROOT, "..", workspacePackageDirName, "package.json"));
|
|
230742
|
-
if (workspaceVersion) {
|
|
230743
|
-
return normalizeVersionRange2(workspaceVersion, fallback);
|
|
230744
|
-
}
|
|
230745
|
-
}
|
|
230746
|
-
try {
|
|
230747
|
-
return normalizeVersionRange2(readPackageManifestVersion(require4.resolve(`${packageName}/package.json`)), fallback);
|
|
230748
|
-
} catch {
|
|
230749
|
-
return fallback;
|
|
230750
|
-
}
|
|
230751
|
-
}
|
|
230752
|
-
function getAdminViewRelativeModuleSpecifier(adminViewSlug, workspaceFile) {
|
|
230753
|
-
const adminViewDir = `src/admin-views/${adminViewSlug}`;
|
|
230754
|
-
const normalizedFile = workspaceFile.replace(/\\/gu, "/");
|
|
230755
|
-
const modulePath = normalizedFile.replace(/\.[cm]?[jt]sx?$/u, "");
|
|
230756
|
-
const relativeModulePath = path51.posix.relative(adminViewDir, modulePath);
|
|
230757
|
-
return relativeModulePath.startsWith(".") ? relativeModulePath : `./${relativeModulePath}`;
|
|
230758
|
-
}
|
|
230759
|
-
function isAdminViewCoreDataSource(source) {
|
|
230760
|
-
return source?.kind === ADMIN_VIEW_CORE_DATA_SOURCE_KIND;
|
|
230761
|
-
}
|
|
230762
|
-
function isAdminViewRestResourceSource(source) {
|
|
230763
|
-
return source?.kind === ADMIN_VIEW_REST_SOURCE_KIND;
|
|
230764
|
-
}
|
|
230765
230754
|
function assertValidCoreDataEntitySegment(label, value2) {
|
|
230766
230755
|
const trimmed = value2.trim();
|
|
230767
230756
|
if (!trimmed) {
|
|
@@ -230789,12 +230778,6 @@ function assertValidCoreDataEntityKind(value2) {
|
|
|
230789
230778
|
}
|
|
230790
230779
|
return normalized;
|
|
230791
230780
|
}
|
|
230792
|
-
function formatAdminViewSourceLocator(source) {
|
|
230793
|
-
if (isAdminViewCoreDataSource(source)) {
|
|
230794
|
-
return `${source.kind}:${source.entityKind}/${source.entityName}`;
|
|
230795
|
-
}
|
|
230796
|
-
return `${source.kind}:${source.slug}`;
|
|
230797
|
-
}
|
|
230798
230781
|
function parseAdminViewSource(source) {
|
|
230799
230782
|
const trimmed = source?.trim();
|
|
230800
230783
|
if (!trimmed) {
|
|
@@ -230838,6 +230821,24 @@ function resolveRestResourceSource(restResources, source) {
|
|
|
230838
230821
|
}
|
|
230839
230822
|
return restResource;
|
|
230840
230823
|
}
|
|
230824
|
+
function resolveAdminViewCoreDataSource(source) {
|
|
230825
|
+
return isAdminViewCoreDataSource(source) ? source : undefined;
|
|
230826
|
+
}
|
|
230827
|
+
var init_cli_add_workspace_admin_view_source = __esm(() => {
|
|
230828
|
+
init_cli_add_shared();
|
|
230829
|
+
init_cli_diagnostics();
|
|
230830
|
+
init_cli_add_workspace_admin_view_types();
|
|
230831
|
+
});
|
|
230832
|
+
|
|
230833
|
+
// ../wp-typia-project-tools/src/runtime/cli-add-workspace-admin-view-templates.ts
|
|
230834
|
+
import path51 from "path";
|
|
230835
|
+
function getAdminViewRelativeModuleSpecifier(adminViewSlug, workspaceFile) {
|
|
230836
|
+
const adminViewDir = `src/admin-views/${adminViewSlug}`;
|
|
230837
|
+
const normalizedFile = workspaceFile.replace(/\\/gu, "/");
|
|
230838
|
+
const modulePath = normalizedFile.replace(/\.[cm]?[jt]sx?$/u, "");
|
|
230839
|
+
const relativeModulePath = path51.posix.relative(adminViewDir, modulePath);
|
|
230840
|
+
return relativeModulePath.startsWith(".") ? relativeModulePath : `./${relativeModulePath}`;
|
|
230841
|
+
}
|
|
230841
230842
|
function buildAdminViewConfigEntry(adminViewSlug, source) {
|
|
230842
230843
|
return [
|
|
230843
230844
|
"\t{",
|
|
@@ -230970,8 +230971,8 @@ function buildAdminViewConfigSource(adminViewSlug, textDomain, source, restResou
|
|
|
230970
230971
|
const camelName = toCamelCase(adminViewSlug);
|
|
230971
230972
|
const itemTypeName = `${pascalName}AdminViewItem`;
|
|
230972
230973
|
const dataViewsName = `${camelName}AdminDataViews`;
|
|
230973
|
-
const isCoreDataSource = source
|
|
230974
|
-
const isTaxonomyCoreDataSource = source
|
|
230974
|
+
const isCoreDataSource = isAdminViewCoreDataSource(source);
|
|
230975
|
+
const isTaxonomyCoreDataSource = isAdminViewCoreDataSource(source) && source.entityKind === "taxonomy";
|
|
230975
230976
|
const defaultViewFields = restResource ? "['id']" : isTaxonomyCoreDataSource ? "['name', 'slug', 'count']" : isCoreDataSource ? "['title', 'slug', 'status', 'updatedAt']" : "['title', 'status', 'updatedAt']";
|
|
230976
230977
|
const searchEnabled = restResource ? "false" : "true";
|
|
230977
230978
|
const titleFieldSource = restResource ? "" : isTaxonomyCoreDataSource ? ` titleField: 'name',
|
|
@@ -231787,12 +231788,38 @@ add_action( 'admin_menu', '${registerFunctionName}' );
|
|
|
231787
231788
|
add_action( 'admin_enqueue_scripts', '${enqueueFunctionName}' );
|
|
231788
231789
|
`;
|
|
231789
231790
|
}
|
|
231791
|
+
var init_cli_add_workspace_admin_view_templates = __esm(() => {
|
|
231792
|
+
init_cli_add_shared();
|
|
231793
|
+
init_cli_add_workspace_admin_view_types();
|
|
231794
|
+
});
|
|
231795
|
+
|
|
231796
|
+
// ../wp-typia-project-tools/src/runtime/cli-add-workspace-admin-view-scaffold.ts
|
|
231797
|
+
import fs42 from "fs";
|
|
231798
|
+
import { promises as fsp18 } from "fs";
|
|
231799
|
+
import path52 from "path";
|
|
231800
|
+
function detectJsonIndent(source) {
|
|
231801
|
+
const indentMatch = /\n([ \t]+)"/u.exec(source);
|
|
231802
|
+
return indentMatch?.[1] ?? 2;
|
|
231803
|
+
}
|
|
231790
231804
|
async function ensureAdminViewPackageDependencies(workspace, adminViewSource) {
|
|
231791
|
-
const packageJsonPath =
|
|
231792
|
-
const wpTypiaDataViewsVersion =
|
|
231793
|
-
|
|
231794
|
-
|
|
231795
|
-
|
|
231805
|
+
const packageJsonPath = path52.join(workspace.projectDir, "package.json");
|
|
231806
|
+
const wpTypiaDataViewsVersion = resolveManagedPackageVersionRange({
|
|
231807
|
+
fallback: DEFAULT_WP_TYPIA_DATAVIEWS_VERSION,
|
|
231808
|
+
packageName: "@wp-typia/dataviews",
|
|
231809
|
+
workspacePackageDirName: "wp-typia-dataviews"
|
|
231810
|
+
});
|
|
231811
|
+
const wordpressDataViewsVersion = resolveManagedPackageVersionRange({
|
|
231812
|
+
fallback: DEFAULT_WORDPRESS_DATAVIEWS_VERSION,
|
|
231813
|
+
packageName: "@wordpress/dataviews"
|
|
231814
|
+
});
|
|
231815
|
+
const wordpressCoreDataVersion = resolveManagedPackageVersionRange({
|
|
231816
|
+
fallback: DEFAULT_WORDPRESS_CORE_DATA_VERSION,
|
|
231817
|
+
packageName: "@wordpress/core-data"
|
|
231818
|
+
});
|
|
231819
|
+
const wordpressDataVersion = resolveManagedPackageVersionRange({
|
|
231820
|
+
fallback: DEFAULT_WORDPRESS_DATA_VERSION,
|
|
231821
|
+
packageName: "@wordpress/data"
|
|
231822
|
+
});
|
|
231796
231823
|
await patchFile(packageJsonPath, (source) => {
|
|
231797
231824
|
const packageJson = JSON.parse(source);
|
|
231798
231825
|
const coreDataDependencies = isAdminViewCoreDataSource(adminViewSource) ? {
|
|
@@ -231823,6 +231850,7 @@ async function ensureAdminViewBootstrapAnchors(workspace) {
|
|
|
231823
231850
|
let nextSource = source;
|
|
231824
231851
|
const loadFunctionName = `${workspace.workspace.phpPrefix}_load_admin_views`;
|
|
231825
231852
|
const loadHook = `add_action( 'plugins_loaded', '${loadFunctionName}' );`;
|
|
231853
|
+
const loadHookPattern = new RegExp(`add_action\\(\\s*['"]plugins_loaded['"]\\s*,\\s*['"]${loadFunctionName}['"]\\s*\\)\\s*;`, "u");
|
|
231826
231854
|
const loadFunction = `
|
|
231827
231855
|
|
|
231828
231856
|
function ${loadFunctionName}() {
|
|
@@ -231867,19 +231895,19 @@ ${snippet}
|
|
|
231867
231895
|
if (!functionSource.includes(ADMIN_VIEWS_PHP_GLOB)) {
|
|
231868
231896
|
const replacedSource = replacePhpFunctionDefinition(nextSource, loadFunctionName, loadFunction);
|
|
231869
231897
|
if (!replacedSource) {
|
|
231870
|
-
throw new Error(`Unable to repair ${
|
|
231898
|
+
throw new Error(`Unable to repair ${path52.basename(bootstrapPath)} for ${loadFunctionName}.`);
|
|
231871
231899
|
}
|
|
231872
231900
|
nextSource = replacedSource;
|
|
231873
231901
|
}
|
|
231874
231902
|
}
|
|
231875
|
-
if (!
|
|
231903
|
+
if (!loadHookPattern.test(nextSource)) {
|
|
231876
231904
|
appendPhpSnippet(loadHook);
|
|
231877
231905
|
}
|
|
231878
231906
|
return nextSource;
|
|
231879
231907
|
});
|
|
231880
231908
|
}
|
|
231881
231909
|
async function ensureAdminViewBuildScriptAnchors(workspace) {
|
|
231882
|
-
const buildScriptPath =
|
|
231910
|
+
const buildScriptPath = path52.join(workspace.projectDir, "scripts", "build-workspace.mjs");
|
|
231883
231911
|
await patchFile(buildScriptPath, (source) => {
|
|
231884
231912
|
if (/['"]src\/admin-views\/index\.(?:ts|js)['"]/u.test(source)) {
|
|
231885
231913
|
return source;
|
|
@@ -231903,11 +231931,11 @@ async function ensureAdminViewBuildScriptAnchors(workspace) {
|
|
|
231903
231931
|
if (nextSource !== source) {
|
|
231904
231932
|
return nextSource;
|
|
231905
231933
|
}
|
|
231906
|
-
throw new Error(`Unable to update ${
|
|
231934
|
+
throw new Error(`Unable to update ${path52.relative(workspace.projectDir, buildScriptPath)} for admin view shared entries.`);
|
|
231907
231935
|
});
|
|
231908
231936
|
}
|
|
231909
231937
|
async function ensureAdminViewWebpackAnchors(workspace) {
|
|
231910
|
-
const webpackConfigPath =
|
|
231938
|
+
const webpackConfigPath = path52.join(workspace.projectDir, "webpack.config.js");
|
|
231911
231939
|
await patchFile(webpackConfigPath, (source) => {
|
|
231912
231940
|
if (/['"]admin-views\/index['"]/u.test(source)) {
|
|
231913
231941
|
return source;
|
|
@@ -231948,17 +231976,17 @@ async function ensureAdminViewWebpackAnchors(workspace) {
|
|
|
231948
231976
|
}`;
|
|
231949
231977
|
nextSource = source.replace(legacySharedEntriesBlockPattern, nextSharedEntriesBlock);
|
|
231950
231978
|
if (nextSource === source) {
|
|
231951
|
-
throw new Error(`Unable to update ${
|
|
231979
|
+
throw new Error(`Unable to update ${path52.relative(workspace.projectDir, webpackConfigPath)} for admin view shared entries.`);
|
|
231952
231980
|
}
|
|
231953
231981
|
return nextSource;
|
|
231954
231982
|
});
|
|
231955
231983
|
}
|
|
231956
231984
|
function resolveAdminViewRegistryPath(projectDir) {
|
|
231957
|
-
const adminViewsDir =
|
|
231985
|
+
const adminViewsDir = path52.join(projectDir, "src", "admin-views");
|
|
231958
231986
|
return [
|
|
231959
|
-
|
|
231960
|
-
|
|
231961
|
-
].find((candidatePath) => fs42.existsSync(candidatePath)) ??
|
|
231987
|
+
path52.join(adminViewsDir, "index.ts"),
|
|
231988
|
+
path52.join(adminViewsDir, "index.js")
|
|
231989
|
+
].find((candidatePath) => fs42.existsSync(candidatePath)) ?? path52.join(adminViewsDir, "index.ts");
|
|
231962
231990
|
}
|
|
231963
231991
|
function readAdminViewRegistrySlugs(registryPath) {
|
|
231964
231992
|
if (!fs42.existsSync(registryPath)) {
|
|
@@ -231968,35 +231996,34 @@ function readAdminViewRegistrySlugs(registryPath) {
|
|
|
231968
231996
|
return Array.from(source.matchAll(/^\s*import\s+['"]\.\/([^/'"]+)(?:\/index(?:\.[cm]?[jt]sx?)?)?['"];?\s*$/gmu)).map((match3) => match3[1]);
|
|
231969
231997
|
}
|
|
231970
231998
|
async function writeAdminViewRegistry(projectDir, adminViewSlug) {
|
|
231971
|
-
const adminViewsDir =
|
|
231999
|
+
const adminViewsDir = path52.join(projectDir, "src", "admin-views");
|
|
231972
232000
|
const registryPath = resolveAdminViewRegistryPath(projectDir);
|
|
231973
232001
|
await fsp18.mkdir(adminViewsDir, { recursive: true });
|
|
231974
232002
|
const existingAdminViewSlugs = readWorkspaceInventory(projectDir).adminViews.map((entry) => entry.slug);
|
|
231975
232003
|
const existingRegistrySlugs = readAdminViewRegistrySlugs(registryPath);
|
|
231976
|
-
const nextAdminViewSlugs = Array.from(new Set([
|
|
232004
|
+
const nextAdminViewSlugs = Array.from(new Set([
|
|
232005
|
+
...existingAdminViewSlugs,
|
|
232006
|
+
...existingRegistrySlugs,
|
|
232007
|
+
adminViewSlug
|
|
232008
|
+
])).sort();
|
|
231977
232009
|
await fsp18.writeFile(registryPath, buildAdminViewRegistrySource(nextAdminViewSlugs), "utf8");
|
|
231978
232010
|
}
|
|
231979
|
-
async function
|
|
231980
|
-
|
|
231981
|
-
|
|
231982
|
-
|
|
231983
|
-
|
|
231984
|
-
|
|
231985
|
-
|
|
231986
|
-
|
|
231987
|
-
const
|
|
231988
|
-
const inventory = readWorkspaceInventory(workspace.projectDir);
|
|
231989
|
-
const restResource = resolveRestResourceSource(inventory.restResources, parsedSource);
|
|
231990
|
-
const coreDataSource = isAdminViewCoreDataSource(parsedSource) ? parsedSource : undefined;
|
|
231991
|
-
assertAdminViewDoesNotExist(workspace.projectDir, adminViewSlug, inventory);
|
|
231992
|
-
const blockConfigPath = path51.join(workspace.projectDir, "scripts", "block-config.ts");
|
|
232011
|
+
async function scaffoldAdminViewWorkspace(options) {
|
|
232012
|
+
const {
|
|
232013
|
+
adminViewSlug,
|
|
232014
|
+
coreDataSource,
|
|
232015
|
+
parsedSource,
|
|
232016
|
+
restResource,
|
|
232017
|
+
workspace
|
|
232018
|
+
} = options;
|
|
232019
|
+
const blockConfigPath = path52.join(workspace.projectDir, "scripts", "block-config.ts");
|
|
231993
232020
|
const bootstrapPath = getWorkspaceBootstrapPath(workspace);
|
|
231994
|
-
const buildScriptPath =
|
|
231995
|
-
const packageJsonPath =
|
|
231996
|
-
const webpackConfigPath =
|
|
232021
|
+
const buildScriptPath = path52.join(workspace.projectDir, "scripts", "build-workspace.mjs");
|
|
232022
|
+
const packageJsonPath = path52.join(workspace.projectDir, "package.json");
|
|
232023
|
+
const webpackConfigPath = path52.join(workspace.projectDir, "webpack.config.js");
|
|
231997
232024
|
const adminViewsIndexPath = resolveAdminViewRegistryPath(workspace.projectDir);
|
|
231998
|
-
const adminViewDir =
|
|
231999
|
-
const adminViewPhpPath =
|
|
232025
|
+
const adminViewDir = path52.join(workspace.projectDir, "src", "admin-views", adminViewSlug);
|
|
232026
|
+
const adminViewPhpPath = path52.join(workspace.projectDir, "inc", "admin-views", `${adminViewSlug}.php`);
|
|
232000
232027
|
const mutationSnapshot = {
|
|
232001
232028
|
fileSources: await snapshotWorkspaceFiles([
|
|
232002
232029
|
adminViewsIndexPath,
|
|
@@ -232011,50 +232038,78 @@ async function runAddAdminViewCommand({
|
|
|
232011
232038
|
};
|
|
232012
232039
|
try {
|
|
232013
232040
|
await fsp18.mkdir(adminViewDir, { recursive: true });
|
|
232014
|
-
await fsp18.mkdir(
|
|
232041
|
+
await fsp18.mkdir(path52.dirname(adminViewPhpPath), { recursive: true });
|
|
232015
232042
|
await ensureAdminViewPackageDependencies(workspace, parsedSource);
|
|
232016
232043
|
await ensureAdminViewBootstrapAnchors(workspace);
|
|
232017
232044
|
await ensureAdminViewBuildScriptAnchors(workspace);
|
|
232018
232045
|
await ensureAdminViewWebpackAnchors(workspace);
|
|
232019
|
-
await fsp18.writeFile(
|
|
232020
|
-
await fsp18.writeFile(
|
|
232021
|
-
await fsp18.writeFile(
|
|
232022
|
-
await fsp18.writeFile(
|
|
232023
|
-
await fsp18.writeFile(
|
|
232024
|
-
await fsp18.writeFile(
|
|
232046
|
+
await fsp18.writeFile(path52.join(adminViewDir, "types.ts"), buildAdminViewTypesSource(adminViewSlug, restResource, coreDataSource), "utf8");
|
|
232047
|
+
await fsp18.writeFile(path52.join(adminViewDir, "config.ts"), buildAdminViewConfigSource(adminViewSlug, workspace.workspace.textDomain, parsedSource, restResource), "utf8");
|
|
232048
|
+
await fsp18.writeFile(path52.join(adminViewDir, "data.ts"), coreDataSource ? buildCoreDataAdminViewDataSource(adminViewSlug, coreDataSource) : restResource ? buildRestAdminViewDataSource(adminViewSlug, restResource) : buildDefaultAdminViewDataSource(adminViewSlug), "utf8");
|
|
232049
|
+
await fsp18.writeFile(path52.join(adminViewDir, "Screen.tsx"), coreDataSource ? buildCoreDataAdminViewScreenSource(adminViewSlug, workspace.workspace.textDomain) : buildAdminViewScreenSource(adminViewSlug, workspace.workspace.textDomain), "utf8");
|
|
232050
|
+
await fsp18.writeFile(path52.join(adminViewDir, "index.tsx"), buildAdminViewEntrySource(adminViewSlug), "utf8");
|
|
232051
|
+
await fsp18.writeFile(path52.join(adminViewDir, "style.scss"), buildAdminViewStyleSource(), "utf8");
|
|
232025
232052
|
await fsp18.writeFile(adminViewPhpPath, buildAdminViewPhpSource(adminViewSlug, workspace), "utf8");
|
|
232026
232053
|
await writeAdminViewRegistry(workspace.projectDir, adminViewSlug);
|
|
232027
232054
|
await appendWorkspaceInventoryEntries(workspace.projectDir, {
|
|
232028
|
-
adminViewEntries: [
|
|
232055
|
+
adminViewEntries: [
|
|
232056
|
+
buildAdminViewConfigEntry(adminViewSlug, parsedSource)
|
|
232057
|
+
]
|
|
232029
232058
|
});
|
|
232030
|
-
return {
|
|
232031
|
-
adminViewSlug,
|
|
232032
|
-
projectDir: workspace.projectDir,
|
|
232033
|
-
source: parsedSource ? formatAdminViewSourceLocator(parsedSource) : undefined
|
|
232034
|
-
};
|
|
232035
232059
|
} catch (error48) {
|
|
232036
232060
|
await rollbackWorkspaceMutation(mutationSnapshot);
|
|
232037
232061
|
throw error48;
|
|
232038
232062
|
}
|
|
232039
232063
|
}
|
|
232040
|
-
var
|
|
232041
|
-
var init_cli_add_workspace_admin_view = __esm(() => {
|
|
232042
|
-
init_workspace_project();
|
|
232064
|
+
var init_cli_add_workspace_admin_view_scaffold = __esm(() => {
|
|
232043
232065
|
init_workspace_inventory();
|
|
232044
|
-
|
|
232066
|
+
init_cli_add_workspace_admin_view_templates();
|
|
232067
|
+
init_cli_add_workspace_admin_view_types();
|
|
232045
232068
|
init_cli_add_shared();
|
|
232046
|
-
init_cli_diagnostics();
|
|
232047
232069
|
init_package_versions();
|
|
232048
|
-
|
|
232049
|
-
|
|
232050
|
-
|
|
232051
|
-
|
|
232070
|
+
});
|
|
232071
|
+
|
|
232072
|
+
// ../wp-typia-project-tools/src/runtime/cli-add-workspace-admin-view.ts
|
|
232073
|
+
async function runAddAdminViewCommand({
|
|
232074
|
+
adminViewName,
|
|
232075
|
+
cwd = process.cwd(),
|
|
232076
|
+
source
|
|
232077
|
+
}) {
|
|
232078
|
+
const workspace = resolveWorkspaceProject(cwd);
|
|
232079
|
+
assertAdminViewPackageAvailability();
|
|
232080
|
+
const adminViewSlug = assertValidGeneratedSlug("Admin view name", normalizeBlockSlug(adminViewName), ADD_ADMIN_VIEW_USAGE);
|
|
232081
|
+
const parsedSource = parseAdminViewSource(source);
|
|
232082
|
+
const inventory = readWorkspaceInventory(workspace.projectDir);
|
|
232083
|
+
const restResource = resolveRestResourceSource(inventory.restResources, parsedSource);
|
|
232084
|
+
const coreDataSource = resolveAdminViewCoreDataSource(parsedSource);
|
|
232085
|
+
assertAdminViewDoesNotExist(workspace.projectDir, adminViewSlug, inventory);
|
|
232086
|
+
await scaffoldAdminViewWorkspace({
|
|
232087
|
+
adminViewSlug,
|
|
232088
|
+
coreDataSource,
|
|
232089
|
+
parsedSource,
|
|
232090
|
+
restResource,
|
|
232091
|
+
workspace
|
|
232092
|
+
});
|
|
232093
|
+
return {
|
|
232094
|
+
adminViewSlug,
|
|
232095
|
+
projectDir: workspace.projectDir,
|
|
232096
|
+
source: parsedSource ? formatAdminViewSourceLocator(parsedSource) : undefined
|
|
232097
|
+
};
|
|
232098
|
+
}
|
|
232099
|
+
var ADD_ADMIN_VIEW_USAGE = "wp-typia add admin-view <name> [--source <rest-resource:slug|core-data:kind/name>]";
|
|
232100
|
+
var init_cli_add_workspace_admin_view = __esm(() => {
|
|
232101
|
+
init_cli_add_shared();
|
|
232102
|
+
init_cli_add_workspace_admin_view_source();
|
|
232103
|
+
init_cli_add_workspace_admin_view_scaffold();
|
|
232104
|
+
init_cli_add_workspace_admin_view_types();
|
|
232105
|
+
init_workspace_inventory();
|
|
232106
|
+
init_workspace_project();
|
|
232052
232107
|
});
|
|
232053
232108
|
|
|
232054
232109
|
// ../wp-typia-project-tools/src/runtime/cli-add-workspace-assets.ts
|
|
232055
232110
|
import fs43 from "fs";
|
|
232056
232111
|
import { promises as fsp19 } from "fs";
|
|
232057
|
-
import
|
|
232112
|
+
import path53 from "path";
|
|
232058
232113
|
import {
|
|
232059
232114
|
syncBlockMetadata as syncBlockMetadata2
|
|
232060
232115
|
} from "@wp-typia/block-runtime/metadata-core";
|
|
@@ -232329,7 +232384,7 @@ async function ensureBindingTargetBlockAttributeType(projectDir, block, target)
|
|
|
232329
232384
|
if (!block.attributeTypeName) {
|
|
232330
232385
|
throw new Error(`Workspace block "${block.slug}" must include attributeTypeName in scripts/block-config.ts before it can receive binding-source targets.`);
|
|
232331
232386
|
}
|
|
232332
|
-
const typesPath =
|
|
232387
|
+
const typesPath = path53.join(projectDir, block.typesFile);
|
|
232333
232388
|
const source = await fsp19.readFile(typesPath, "utf8");
|
|
232334
232389
|
const targetInterface = getInterfaceDeclaration(source, block.attributeTypeName);
|
|
232335
232390
|
if (!targetInterface) {
|
|
@@ -232341,10 +232396,10 @@ async function ensureBindingTargetBlockAttributeType(projectDir, block, target)
|
|
|
232341
232396
|
await fsp19.writeFile(typesPath, nextSource, "utf8");
|
|
232342
232397
|
}
|
|
232343
232398
|
await syncBlockMetadata2({
|
|
232344
|
-
blockJsonFile:
|
|
232345
|
-
jsonSchemaFile:
|
|
232346
|
-
manifestFile:
|
|
232347
|
-
openApiFile:
|
|
232399
|
+
blockJsonFile: path53.join("src", "blocks", block.slug, "block.json"),
|
|
232400
|
+
jsonSchemaFile: path53.join("src", "blocks", block.slug, "typia.schema.json"),
|
|
232401
|
+
manifestFile: path53.join("src", "blocks", block.slug, "typia.manifest.json"),
|
|
232402
|
+
openApiFile: path53.join("src", "blocks", block.slug, "typia.openapi.json"),
|
|
232348
232403
|
projectRoot: projectDir,
|
|
232349
232404
|
sourceTypeName: block.attributeTypeName,
|
|
232350
232405
|
typesFile: block.typesFile
|
|
@@ -232583,7 +232638,7 @@ ${patternFunctions}
|
|
|
232583
232638
|
}
|
|
232584
232639
|
}
|
|
232585
232640
|
if (!nextSource.includes(patternCategoryFunctionName) || !nextSource.includes(patternRegistrationFunctionName)) {
|
|
232586
|
-
throw new Error(`Unable to inject pattern bootstrap functions into ${
|
|
232641
|
+
throw new Error(`Unable to inject pattern bootstrap functions into ${path53.basename(bootstrapPath)}.`);
|
|
232587
232642
|
}
|
|
232588
232643
|
if (!nextSource.includes(patternCategoryHook)) {
|
|
232589
232644
|
nextSource = `${nextSource.trimEnd()}
|
|
@@ -232771,7 +232826,7 @@ ${snippet}
|
|
|
232771
232826
|
if (missingReferences.length > 0) {
|
|
232772
232827
|
const replacedSource = replacePhpFunctionDefinition(nextSource, enqueueFunctionName, enqueueFunction);
|
|
232773
232828
|
if (!replacedSource) {
|
|
232774
|
-
throw new Error(`Unable to repair ${
|
|
232829
|
+
throw new Error(`Unable to repair ${path53.basename(bootstrapPath)} for ${enqueueFunctionName}.`);
|
|
232775
232830
|
}
|
|
232776
232831
|
nextSource = replacedSource;
|
|
232777
232832
|
}
|
|
@@ -232783,7 +232838,7 @@ ${snippet}
|
|
|
232783
232838
|
});
|
|
232784
232839
|
}
|
|
232785
232840
|
async function ensureEditorPluginBuildScriptAnchors(workspace) {
|
|
232786
|
-
const buildScriptPath =
|
|
232841
|
+
const buildScriptPath = path53.join(workspace.projectDir, "scripts", "build-workspace.mjs");
|
|
232787
232842
|
await patchFile(buildScriptPath, (source) => {
|
|
232788
232843
|
if (/['"]src\/editor-plugins\/index\.(?:ts|js)['"]/u.test(source)) {
|
|
232789
232844
|
return source;
|
|
@@ -232796,13 +232851,13 @@ async function ensureEditorPluginBuildScriptAnchors(workspace) {
|
|
|
232796
232851
|
'src/editor-plugins/index.js',
|
|
232797
232852
|
]`);
|
|
232798
232853
|
if (nextSource === source) {
|
|
232799
|
-
throw new Error(`Unable to update ${
|
|
232854
|
+
throw new Error(`Unable to update ${path53.relative(workspace.projectDir, buildScriptPath)} for editor plugin shared entries.`);
|
|
232800
232855
|
}
|
|
232801
232856
|
return nextSource;
|
|
232802
232857
|
});
|
|
232803
232858
|
}
|
|
232804
232859
|
async function ensureEditorPluginWebpackAnchors(workspace) {
|
|
232805
|
-
const webpackConfigPath =
|
|
232860
|
+
const webpackConfigPath = path53.join(workspace.projectDir, "webpack.config.js");
|
|
232806
232861
|
await patchFile(webpackConfigPath, (source) => {
|
|
232807
232862
|
if (/['"]editor-plugins\/index['"]/u.test(source)) {
|
|
232808
232863
|
return source;
|
|
@@ -232830,17 +232885,17 @@ async function ensureEditorPluginWebpackAnchors(workspace) {
|
|
|
232830
232885
|
}`;
|
|
232831
232886
|
const nextSource = source.replace(legacySharedEntriesBlockPattern, nextSharedEntriesBlock);
|
|
232832
232887
|
if (nextSource === source) {
|
|
232833
|
-
throw new Error(`Unable to update ${
|
|
232888
|
+
throw new Error(`Unable to update ${path53.relative(workspace.projectDir, webpackConfigPath)} for editor plugin shared entries.`);
|
|
232834
232889
|
}
|
|
232835
232890
|
return nextSource;
|
|
232836
232891
|
});
|
|
232837
232892
|
}
|
|
232838
232893
|
function resolveBindingSourceRegistryPath(projectDir) {
|
|
232839
|
-
const bindingsDir =
|
|
232840
|
-
return [
|
|
232894
|
+
const bindingsDir = path53.join(projectDir, "src", "bindings");
|
|
232895
|
+
return [path53.join(bindingsDir, "index.ts"), path53.join(bindingsDir, "index.js")].find((candidatePath) => fs43.existsSync(candidatePath)) ?? path53.join(bindingsDir, "index.ts");
|
|
232841
232896
|
}
|
|
232842
232897
|
async function writeBindingSourceRegistry(projectDir, bindingSourceSlug) {
|
|
232843
|
-
const bindingsDir =
|
|
232898
|
+
const bindingsDir = path53.join(projectDir, "src", "bindings");
|
|
232844
232899
|
const bindingsIndexPath = resolveBindingSourceRegistryPath(projectDir);
|
|
232845
232900
|
await fsp19.mkdir(bindingsDir, { recursive: true });
|
|
232846
232901
|
const existingBindingSourceSlugs = fs43.readdirSync(bindingsDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
@@ -232848,11 +232903,11 @@ async function writeBindingSourceRegistry(projectDir, bindingSourceSlug) {
|
|
|
232848
232903
|
await fsp19.writeFile(bindingsIndexPath, buildBindingSourceIndexSource(nextBindingSourceSlugs), "utf8");
|
|
232849
232904
|
}
|
|
232850
232905
|
function resolveEditorPluginRegistryPath(projectDir) {
|
|
232851
|
-
const editorPluginsDir =
|
|
232906
|
+
const editorPluginsDir = path53.join(projectDir, "src", "editor-plugins");
|
|
232852
232907
|
return [
|
|
232853
|
-
|
|
232854
|
-
|
|
232855
|
-
].find((candidatePath) => fs43.existsSync(candidatePath)) ??
|
|
232908
|
+
path53.join(editorPluginsDir, "index.ts"),
|
|
232909
|
+
path53.join(editorPluginsDir, "index.js")
|
|
232910
|
+
].find((candidatePath) => fs43.existsSync(candidatePath)) ?? path53.join(editorPluginsDir, "index.ts");
|
|
232856
232911
|
}
|
|
232857
232912
|
function readEditorPluginRegistrySlugs(registryPath) {
|
|
232858
232913
|
if (!fs43.existsSync(registryPath)) {
|
|
@@ -232862,7 +232917,7 @@ function readEditorPluginRegistrySlugs(registryPath) {
|
|
|
232862
232917
|
return Array.from(source.matchAll(/^\s*import\s+['"]\.\/([^/'"]+)(?:\/index(?:\.[cm]?[jt]sx?)?)?['"];?\s*$/gmu)).map((match3) => match3[1]);
|
|
232863
232918
|
}
|
|
232864
232919
|
async function writeEditorPluginRegistry(projectDir, editorPluginSlug) {
|
|
232865
|
-
const editorPluginsDir =
|
|
232920
|
+
const editorPluginsDir = path53.join(projectDir, "src", "editor-plugins");
|
|
232866
232921
|
const registryPath = resolveEditorPluginRegistryPath(projectDir);
|
|
232867
232922
|
await fsp19.mkdir(editorPluginsDir, { recursive: true });
|
|
232868
232923
|
const existingEditorPluginSlugs = readWorkspaceInventory(projectDir).editorPlugins.map((entry) => entry.slug);
|
|
@@ -232880,17 +232935,17 @@ async function runAddEditorPluginCommand({
|
|
|
232880
232935
|
const resolvedSlot = assertValidEditorPluginSlot(slot);
|
|
232881
232936
|
const inventory = readWorkspaceInventory(workspace.projectDir);
|
|
232882
232937
|
assertEditorPluginDoesNotExist(workspace.projectDir, editorPluginSlug, inventory);
|
|
232883
|
-
const blockConfigPath =
|
|
232938
|
+
const blockConfigPath = path53.join(workspace.projectDir, "scripts", "block-config.ts");
|
|
232884
232939
|
const bootstrapPath = getWorkspaceBootstrapPath(workspace);
|
|
232885
|
-
const buildScriptPath =
|
|
232940
|
+
const buildScriptPath = path53.join(workspace.projectDir, "scripts", "build-workspace.mjs");
|
|
232886
232941
|
const editorPluginsIndexPath = resolveEditorPluginRegistryPath(workspace.projectDir);
|
|
232887
|
-
const webpackConfigPath =
|
|
232888
|
-
const editorPluginDir =
|
|
232889
|
-
const entryFilePath =
|
|
232890
|
-
const surfaceFilePath =
|
|
232891
|
-
const dataFilePath =
|
|
232892
|
-
const typesFilePath =
|
|
232893
|
-
const styleFilePath =
|
|
232942
|
+
const webpackConfigPath = path53.join(workspace.projectDir, "webpack.config.js");
|
|
232943
|
+
const editorPluginDir = path53.join(workspace.projectDir, "src", "editor-plugins", editorPluginSlug);
|
|
232944
|
+
const entryFilePath = path53.join(editorPluginDir, "index.tsx");
|
|
232945
|
+
const surfaceFilePath = path53.join(editorPluginDir, "Surface.tsx");
|
|
232946
|
+
const dataFilePath = path53.join(editorPluginDir, "data.ts");
|
|
232947
|
+
const typesFilePath = path53.join(editorPluginDir, "types.ts");
|
|
232948
|
+
const styleFilePath = path53.join(editorPluginDir, "style.scss");
|
|
232894
232949
|
const mutationSnapshot = {
|
|
232895
232950
|
fileSources: await snapshotWorkspaceFiles([
|
|
232896
232951
|
blockConfigPath,
|
|
@@ -232936,16 +232991,16 @@ async function runAddPatternCommand({
|
|
|
232936
232991
|
const patternSlug = assertValidGeneratedSlug("Pattern name", normalizeBlockSlug(patternName), "wp-typia add pattern <name>");
|
|
232937
232992
|
const inventory = readWorkspaceInventory(workspace.projectDir);
|
|
232938
232993
|
assertPatternDoesNotExist(workspace.projectDir, patternSlug, inventory);
|
|
232939
|
-
const blockConfigPath =
|
|
232994
|
+
const blockConfigPath = path53.join(workspace.projectDir, "scripts", "block-config.ts");
|
|
232940
232995
|
const bootstrapPath = getWorkspaceBootstrapPath(workspace);
|
|
232941
|
-
const patternFilePath =
|
|
232996
|
+
const patternFilePath = path53.join(workspace.projectDir, "src", "patterns", `${patternSlug}.php`);
|
|
232942
232997
|
const mutationSnapshot = {
|
|
232943
232998
|
fileSources: await snapshotWorkspaceFiles([blockConfigPath, bootstrapPath]),
|
|
232944
232999
|
snapshotDirs: [],
|
|
232945
233000
|
targetPaths: [patternFilePath]
|
|
232946
233001
|
};
|
|
232947
233002
|
try {
|
|
232948
|
-
await fsp19.mkdir(
|
|
233003
|
+
await fsp19.mkdir(path53.dirname(patternFilePath), { recursive: true });
|
|
232949
233004
|
await ensurePatternBootstrapAnchors(workspace);
|
|
232950
233005
|
await fsp19.writeFile(patternFilePath, buildPatternSource(patternSlug, workspace.workspace.namespace, workspace.workspace.textDomain), "utf8");
|
|
232951
233006
|
await appendWorkspaceInventoryEntries(workspace.projectDir, {
|
|
@@ -232975,18 +233030,18 @@ async function runAddBindingSourceCommand({
|
|
|
232975
233030
|
blockName
|
|
232976
233031
|
}, workspace.workspace.namespace);
|
|
232977
233032
|
const targetBlock = target ? resolveWorkspaceBlock(inventory, target.blockSlug) : undefined;
|
|
232978
|
-
const blockConfigPath =
|
|
233033
|
+
const blockConfigPath = path53.join(workspace.projectDir, "scripts", "block-config.ts");
|
|
232979
233034
|
const bootstrapPath = getWorkspaceBootstrapPath(workspace);
|
|
232980
233035
|
const bindingsIndexPath = resolveBindingSourceRegistryPath(workspace.projectDir);
|
|
232981
|
-
const bindingSourceDir =
|
|
232982
|
-
const serverFilePath =
|
|
232983
|
-
const editorFilePath =
|
|
232984
|
-
const blockJsonPath = target ?
|
|
233036
|
+
const bindingSourceDir = path53.join(workspace.projectDir, "src", "bindings", bindingSourceSlug);
|
|
233037
|
+
const serverFilePath = path53.join(bindingSourceDir, "server.php");
|
|
233038
|
+
const editorFilePath = path53.join(bindingSourceDir, "editor.ts");
|
|
233039
|
+
const blockJsonPath = target ? path53.join(workspace.projectDir, "src", "blocks", target.blockSlug, "block.json") : undefined;
|
|
232985
233040
|
const targetGeneratedMetadataPaths = target ? [
|
|
232986
|
-
|
|
232987
|
-
|
|
232988
|
-
|
|
232989
|
-
|
|
233041
|
+
path53.join(workspace.projectDir, "src", "blocks", target.blockSlug, "typia.manifest.json"),
|
|
233042
|
+
path53.join(workspace.projectDir, "src", "blocks", target.blockSlug, "typia.openapi.json"),
|
|
233043
|
+
path53.join(workspace.projectDir, "src", "blocks", target.blockSlug, "typia.schema.json"),
|
|
233044
|
+
path53.join(workspace.projectDir, "src", "blocks", target.blockSlug, "typia-validator.php")
|
|
232990
233045
|
] : [];
|
|
232991
233046
|
const mutationSnapshot = {
|
|
232992
233047
|
fileSources: await snapshotWorkspaceFiles([
|
|
@@ -232994,7 +233049,7 @@ async function runAddBindingSourceCommand({
|
|
|
232994
233049
|
bootstrapPath,
|
|
232995
233050
|
bindingsIndexPath,
|
|
232996
233051
|
...blockJsonPath ? [blockJsonPath] : [],
|
|
232997
|
-
...targetBlock ? [
|
|
233052
|
+
...targetBlock ? [path53.join(workspace.projectDir, targetBlock.typesFile)] : [],
|
|
232998
233053
|
...targetGeneratedMetadataPaths
|
|
232999
233054
|
]),
|
|
233000
233055
|
snapshotDirs: [],
|
|
@@ -233032,7 +233087,7 @@ var init_cli_add_workspace_assets = __esm(() => {
|
|
|
233032
233087
|
});
|
|
233033
233088
|
|
|
233034
233089
|
// ../wp-typia-project-tools/src/runtime/cli-add-workspace-rest-anchors.ts
|
|
233035
|
-
import
|
|
233090
|
+
import path54 from "path";
|
|
233036
233091
|
async function ensureRestResourceBootstrapAnchors(workspace) {
|
|
233037
233092
|
const bootstrapPath = getWorkspaceBootstrapPath(workspace);
|
|
233038
233093
|
await patchFile(bootstrapPath, (source) => {
|
|
@@ -233079,7 +233134,7 @@ ${snippet}
|
|
|
233079
233134
|
insertPhpSnippet(registerFunction);
|
|
233080
233135
|
} else if (!nextSource.includes(REST_RESOURCE_SERVER_GLOB)) {
|
|
233081
233136
|
throw new Error([
|
|
233082
|
-
`Unable to patch ${
|
|
233137
|
+
`Unable to patch ${path54.basename(bootstrapPath)} in ensureRestResourceBootstrapAnchors.`,
|
|
233083
233138
|
`The existing ${registerFunctionName}() definition does not include ${REST_RESOURCE_SERVER_GLOB}.`,
|
|
233084
233139
|
"Restore the generated bootstrap shape or wire the REST resource loader manually before retrying."
|
|
233085
233140
|
].join(" "));
|
|
@@ -233093,7 +233148,7 @@ ${snippet}
|
|
|
233093
233148
|
function assertSyncRestAnchor(nextSource, target, anchorDescription, hasAnchor, syncRestScriptPath) {
|
|
233094
233149
|
if (!nextSource.includes(target) && !hasAnchor) {
|
|
233095
233150
|
throw new Error([
|
|
233096
|
-
`ensureRestResourceSyncScriptAnchors could not patch ${
|
|
233151
|
+
`ensureRestResourceSyncScriptAnchors could not patch ${path54.basename(syncRestScriptPath)}.`,
|
|
233097
233152
|
`Missing expected ${anchorDescription} anchor in scripts/sync-rest-contracts.ts.`,
|
|
233098
233153
|
"Restore the generated template or add the REST_RESOURCES wiring manually before retrying."
|
|
233099
233154
|
].join(" "));
|
|
@@ -233108,7 +233163,7 @@ function replaceRequiredSyncRestSource(nextSource, target, anchor, replacement,
|
|
|
233108
233163
|
return nextSource.replace(anchor, replacement);
|
|
233109
233164
|
}
|
|
233110
233165
|
async function ensureRestResourceSyncScriptAnchors(workspace) {
|
|
233111
|
-
const syncRestScriptPath =
|
|
233166
|
+
const syncRestScriptPath = path54.join(workspace.projectDir, "scripts", "sync-rest-contracts.ts");
|
|
233112
233167
|
await patchFile(syncRestScriptPath, (source) => {
|
|
233113
233168
|
let nextSource = source;
|
|
233114
233169
|
const importAnchor = "import { BLOCKS, type WorkspaceBlockConfig } from './block-config';";
|
|
@@ -233230,7 +233285,7 @@ var init_cli_add_workspace_rest_anchors = __esm(() => {
|
|
|
233230
233285
|
});
|
|
233231
233286
|
|
|
233232
233287
|
// ../wp-typia-project-tools/src/runtime/rest-resource-artifacts.ts
|
|
233233
|
-
import
|
|
233288
|
+
import path55 from "path";
|
|
233234
233289
|
import {
|
|
233235
233290
|
defineEndpointManifest as defineEndpointManifest2,
|
|
233236
233291
|
syncEndpointClient as syncEndpointClient2,
|
|
@@ -233366,8 +233421,8 @@ async function syncRestResourceArtifacts({
|
|
|
233366
233421
|
const manifest = buildRestResourceEndpointManifest(variables, methods);
|
|
233367
233422
|
for (const [baseName, contract] of Object.entries(manifest.contracts)) {
|
|
233368
233423
|
await syncTypeSchemas2({
|
|
233369
|
-
jsonSchemaFile:
|
|
233370
|
-
openApiFile:
|
|
233424
|
+
jsonSchemaFile: path55.join(outputDir, "api-schemas", `${baseName}.schema.json`),
|
|
233425
|
+
openApiFile: path55.join(outputDir, "api-schemas", `${baseName}.openapi.json`),
|
|
233371
233426
|
projectRoot: projectDir,
|
|
233372
233427
|
sourceTypeName: contract.sourceTypeName,
|
|
233373
233428
|
typesFile
|
|
@@ -233375,7 +233430,7 @@ async function syncRestResourceArtifacts({
|
|
|
233375
233430
|
}
|
|
233376
233431
|
await syncRestOpenApi2({
|
|
233377
233432
|
manifest,
|
|
233378
|
-
openApiFile:
|
|
233433
|
+
openApiFile: path55.join(outputDir, "api.openapi.json"),
|
|
233379
233434
|
projectRoot: projectDir,
|
|
233380
233435
|
typesFile
|
|
233381
233436
|
});
|
|
@@ -233777,7 +233832,7 @@ var init_cli_add_workspace_rest_source_emitters = __esm(() => {
|
|
|
233777
233832
|
|
|
233778
233833
|
// ../wp-typia-project-tools/src/runtime/cli-add-workspace-rest.ts
|
|
233779
233834
|
import { promises as fsp20 } from "fs";
|
|
233780
|
-
import
|
|
233835
|
+
import path56 from "path";
|
|
233781
233836
|
function buildRestResourceRouteRegistrations(restResourceSlug, methods, functions) {
|
|
233782
233837
|
const collectionRoutes = [];
|
|
233783
233838
|
const itemRoutes = [];
|
|
@@ -234207,15 +234262,15 @@ async function runAddRestResourceCommand({
|
|
|
234207
234262
|
const resolvedNamespace = resolveRestResourceNamespace(workspace.workspace.namespace, namespace);
|
|
234208
234263
|
const inventory = readWorkspaceInventory(workspace.projectDir);
|
|
234209
234264
|
assertRestResourceDoesNotExist(workspace.projectDir, restResourceSlug, inventory);
|
|
234210
|
-
const blockConfigPath =
|
|
234265
|
+
const blockConfigPath = path56.join(workspace.projectDir, "scripts", "block-config.ts");
|
|
234211
234266
|
const bootstrapPath = getWorkspaceBootstrapPath(workspace);
|
|
234212
|
-
const syncRestScriptPath =
|
|
234213
|
-
const restResourceDir =
|
|
234214
|
-
const typesFilePath =
|
|
234215
|
-
const validatorsFilePath =
|
|
234216
|
-
const apiFilePath =
|
|
234217
|
-
const dataFilePath =
|
|
234218
|
-
const phpFilePath =
|
|
234267
|
+
const syncRestScriptPath = path56.join(workspace.projectDir, "scripts", "sync-rest-contracts.ts");
|
|
234268
|
+
const restResourceDir = path56.join(workspace.projectDir, "src", "rest", restResourceSlug);
|
|
234269
|
+
const typesFilePath = path56.join(restResourceDir, "api-types.ts");
|
|
234270
|
+
const validatorsFilePath = path56.join(restResourceDir, "api-validators.ts");
|
|
234271
|
+
const apiFilePath = path56.join(restResourceDir, "api.ts");
|
|
234272
|
+
const dataFilePath = path56.join(restResourceDir, "data.ts");
|
|
234273
|
+
const phpFilePath = path56.join(workspace.projectDir, "inc", "rest", `${restResourceSlug}.php`);
|
|
234219
234274
|
const mutationSnapshot = {
|
|
234220
234275
|
fileSources: await snapshotWorkspaceFiles([
|
|
234221
234276
|
blockConfigPath,
|
|
@@ -234227,7 +234282,7 @@ async function runAddRestResourceCommand({
|
|
|
234227
234282
|
};
|
|
234228
234283
|
try {
|
|
234229
234284
|
await fsp20.mkdir(restResourceDir, { recursive: true });
|
|
234230
|
-
await fsp20.mkdir(
|
|
234285
|
+
await fsp20.mkdir(path56.dirname(phpFilePath), { recursive: true });
|
|
234231
234286
|
await ensureRestResourceBootstrapAnchors(workspace);
|
|
234232
234287
|
await ensureRestResourceSyncScriptAnchors(workspace);
|
|
234233
234288
|
await fsp20.writeFile(typesFilePath, buildRestResourceTypesSource(restResourceSlug, resolvedMethods), "utf8");
|
|
@@ -234279,7 +234334,7 @@ var init_cli_add_workspace_rest = __esm(() => {
|
|
|
234279
234334
|
// ../wp-typia-project-tools/src/runtime/cli-add-workspace-ability.ts
|
|
234280
234335
|
import fs44 from "fs";
|
|
234281
234336
|
import { promises as fsp21 } from "fs";
|
|
234282
|
-
import
|
|
234337
|
+
import path57 from "path";
|
|
234283
234338
|
import { syncTypeSchemas as syncTypeSchemas3 } from "@wp-typia/block-runtime/metadata-core";
|
|
234284
234339
|
function resolveManagedDependencyVersion(existingVersion, requiredVersion) {
|
|
234285
234340
|
if (!existingVersion) {
|
|
@@ -234757,8 +234812,8 @@ function buildAbilityRegistrySource(abilitySlugs) {
|
|
|
234757
234812
|
`);
|
|
234758
234813
|
}
|
|
234759
234814
|
function resolveAbilityRegistryPath(projectDir) {
|
|
234760
|
-
const abilitiesDir =
|
|
234761
|
-
return [
|
|
234815
|
+
const abilitiesDir = path57.join(projectDir, "src", "abilities");
|
|
234816
|
+
return [path57.join(abilitiesDir, "index.ts"), path57.join(abilitiesDir, "index.js")].find((candidatePath) => fs44.existsSync(candidatePath)) ?? path57.join(abilitiesDir, "index.ts");
|
|
234762
234817
|
}
|
|
234763
234818
|
function readAbilityRegistrySlugs(registryPath) {
|
|
234764
234819
|
if (!fs44.existsSync(registryPath)) {
|
|
@@ -234768,7 +234823,7 @@ function readAbilityRegistrySlugs(registryPath) {
|
|
|
234768
234823
|
return Array.from(source.matchAll(/^\s*export\s+\*\s+from\s+['"]\.\/([^/'"]+)\/client['"];?\s*$/gmu)).map((match3) => match3[1]);
|
|
234769
234824
|
}
|
|
234770
234825
|
async function writeAbilityRegistry(projectDir, abilitySlug) {
|
|
234771
|
-
const abilitiesDir =
|
|
234826
|
+
const abilitiesDir = path57.join(projectDir, "src", "abilities");
|
|
234772
234827
|
const registryPath = resolveAbilityRegistryPath(projectDir);
|
|
234773
234828
|
await fsp21.mkdir(abilitiesDir, { recursive: true });
|
|
234774
234829
|
const existingAbilitySlugs = readWorkspaceInventory(projectDir).abilities.map((entry) => entry.slug);
|
|
@@ -234900,7 +234955,7 @@ ${snippet}
|
|
|
234900
234955
|
});
|
|
234901
234956
|
}
|
|
234902
234957
|
async function ensureAbilityPackageScripts(workspace) {
|
|
234903
|
-
const packageJsonPath =
|
|
234958
|
+
const packageJsonPath = path57.join(workspace.projectDir, "package.json");
|
|
234904
234959
|
const packageJson = JSON.parse(await fsp21.readFile(packageJsonPath, "utf8"));
|
|
234905
234960
|
const nextScripts = {
|
|
234906
234961
|
...packageJson.scripts ?? {},
|
|
@@ -234920,7 +234975,7 @@ async function ensureAbilityPackageScripts(workspace) {
|
|
|
234920
234975
|
`, "utf8");
|
|
234921
234976
|
}
|
|
234922
234977
|
async function ensureAbilitySyncProjectAnchors(workspace) {
|
|
234923
|
-
const syncProjectScriptPath =
|
|
234978
|
+
const syncProjectScriptPath = path57.join(workspace.projectDir, "scripts", "sync-project.ts");
|
|
234924
234979
|
await patchFile(syncProjectScriptPath, (source) => {
|
|
234925
234980
|
let nextSource = source;
|
|
234926
234981
|
const syncRestConst = "const syncRestScriptPath = path.join( 'scripts', 'sync-rest-contracts.ts' );";
|
|
@@ -234935,7 +234990,7 @@ async function ensureAbilitySyncProjectAnchors(workspace) {
|
|
|
234935
234990
|
if (!nextSource.includes(syncAbilitiesConst)) {
|
|
234936
234991
|
if (!nextSource.includes(syncRestConst)) {
|
|
234937
234992
|
throw new Error([
|
|
234938
|
-
`ensureAbilitySyncProjectAnchors could not patch ${
|
|
234993
|
+
`ensureAbilitySyncProjectAnchors could not patch ${path57.basename(syncProjectScriptPath)}.`,
|
|
234939
234994
|
"Missing the expected sync-rest script constant in scripts/sync-project.ts.",
|
|
234940
234995
|
"Restore the generated template or wire sync-abilities manually before retrying."
|
|
234941
234996
|
].join(" "));
|
|
@@ -234946,7 +235001,7 @@ ${syncAbilitiesConst}`);
|
|
|
234946
235001
|
if (!nextSource.includes("runSyncScript( syncAbilitiesScriptPath, options );")) {
|
|
234947
235002
|
if (!syncRestBlockPattern.test(nextSource)) {
|
|
234948
235003
|
throw new Error([
|
|
234949
|
-
`ensureAbilitySyncProjectAnchors could not patch ${
|
|
235004
|
+
`ensureAbilitySyncProjectAnchors could not patch ${path57.basename(syncProjectScriptPath)}.`,
|
|
234950
235005
|
"Missing the expected sync-rest invocation block in scripts/sync-project.ts.",
|
|
234951
235006
|
"Restore the generated template or wire sync-abilities manually before retrying."
|
|
234952
235007
|
].join(" "));
|
|
@@ -234959,7 +235014,7 @@ ${syncAbilitiesBlock}`);
|
|
|
234959
235014
|
});
|
|
234960
235015
|
}
|
|
234961
235016
|
async function ensureAbilityBuildScriptAnchors(workspace) {
|
|
234962
|
-
const buildScriptPath =
|
|
235017
|
+
const buildScriptPath = path57.join(workspace.projectDir, "scripts", "build-workspace.mjs");
|
|
234963
235018
|
await patchFile(buildScriptPath, (source) => {
|
|
234964
235019
|
let nextSource = source;
|
|
234965
235020
|
if (/['"]src\/abilities\/index\.(?:ts|js)['"]/u.test(nextSource)) {
|
|
@@ -234969,7 +235024,7 @@ async function ensureAbilityBuildScriptAnchors(workspace) {
|
|
|
234969
235024
|
const match3 = nextSource.match(sharedEntriesPattern);
|
|
234970
235025
|
if (!match3 || !match3[2].includes("src/bindings/index.ts") || !match3[2].includes("src/editor-plugins/index.ts")) {
|
|
234971
235026
|
throw new Error([
|
|
234972
|
-
`ensureAbilityBuildScriptAnchors could not patch ${
|
|
235027
|
+
`ensureAbilityBuildScriptAnchors could not patch ${path57.basename(buildScriptPath)}.`,
|
|
234973
235028
|
"Missing the expected shared editor entries array in scripts/build-workspace.mjs.",
|
|
234974
235029
|
"Restore the generated template or wire abilities/index manually before retrying."
|
|
234975
235030
|
].join(" "));
|
|
@@ -234986,7 +235041,7 @@ async function ensureAbilityBuildScriptAnchors(workspace) {
|
|
|
234986
235041
|
});
|
|
234987
235042
|
}
|
|
234988
235043
|
async function ensureAbilityWebpackAnchors(workspace) {
|
|
234989
|
-
const webpackConfigPath =
|
|
235044
|
+
const webpackConfigPath = path57.join(workspace.projectDir, "webpack.config.js");
|
|
234990
235045
|
await patchFile(webpackConfigPath, (source) => {
|
|
234991
235046
|
if (/['"]abilities\/index['"]/u.test(source)) {
|
|
234992
235047
|
return source;
|
|
@@ -235017,7 +235072,7 @@ $2`);
|
|
|
235017
235072
|
const match3 = source.match(sharedEntriesPattern);
|
|
235018
235073
|
if (!match3 || !match3[1].includes("bindings/index") || !match3[1].includes("editor-plugins/index")) {
|
|
235019
235074
|
throw new Error([
|
|
235020
|
-
`ensureAbilityWebpackAnchors could not patch ${
|
|
235075
|
+
`ensureAbilityWebpackAnchors could not patch ${path57.basename(webpackConfigPath)}.`,
|
|
235021
235076
|
"Missing the expected shared editor entries block in webpack.config.js.",
|
|
235022
235077
|
"Restore the generated template or wire abilities/index manually before retrying."
|
|
235023
235078
|
].join(" "));
|
|
@@ -235047,20 +235102,20 @@ async function runAddAbilityCommand({
|
|
|
235047
235102
|
const inventory = readWorkspaceInventory(workspace.projectDir);
|
|
235048
235103
|
assertAbilityDoesNotExist(workspace.projectDir, abilitySlug, inventory);
|
|
235049
235104
|
const compatibilityPolicy = resolveScaffoldCompatibilityPolicy(REQUIRED_WORKSPACE_ABILITY_COMPATIBILITY);
|
|
235050
|
-
const blockConfigPath =
|
|
235105
|
+
const blockConfigPath = path57.join(workspace.projectDir, "scripts", "block-config.ts");
|
|
235051
235106
|
const bootstrapPath = getWorkspaceBootstrapPath(workspace);
|
|
235052
|
-
const buildScriptPath =
|
|
235053
|
-
const packageJsonPath =
|
|
235054
|
-
const syncAbilitiesScriptPath =
|
|
235055
|
-
const syncProjectScriptPath =
|
|
235056
|
-
const webpackConfigPath =
|
|
235107
|
+
const buildScriptPath = path57.join(workspace.projectDir, "scripts", "build-workspace.mjs");
|
|
235108
|
+
const packageJsonPath = path57.join(workspace.projectDir, "package.json");
|
|
235109
|
+
const syncAbilitiesScriptPath = path57.join(workspace.projectDir, "scripts", "sync-abilities.ts");
|
|
235110
|
+
const syncProjectScriptPath = path57.join(workspace.projectDir, "scripts", "sync-project.ts");
|
|
235111
|
+
const webpackConfigPath = path57.join(workspace.projectDir, "webpack.config.js");
|
|
235057
235112
|
const abilitiesIndexPath = resolveAbilityRegistryPath(workspace.projectDir);
|
|
235058
|
-
const abilityDir =
|
|
235059
|
-
const configFilePath =
|
|
235060
|
-
const typesFilePath =
|
|
235061
|
-
const dataFilePath =
|
|
235062
|
-
const clientFilePath =
|
|
235063
|
-
const phpFilePath =
|
|
235113
|
+
const abilityDir = path57.join(workspace.projectDir, "src", "abilities", abilitySlug);
|
|
235114
|
+
const configFilePath = path57.join(abilityDir, "ability.config.json");
|
|
235115
|
+
const typesFilePath = path57.join(abilityDir, "types.ts");
|
|
235116
|
+
const dataFilePath = path57.join(abilityDir, "data.ts");
|
|
235117
|
+
const clientFilePath = path57.join(abilityDir, "client.ts");
|
|
235118
|
+
const phpFilePath = path57.join(workspace.projectDir, "inc", "abilities", `${abilitySlug}.php`);
|
|
235064
235119
|
const mutationSnapshot = {
|
|
235065
235120
|
fileSources: await snapshotWorkspaceFiles([
|
|
235066
235121
|
blockConfigPath,
|
|
@@ -235077,7 +235132,7 @@ async function runAddAbilityCommand({
|
|
|
235077
235132
|
};
|
|
235078
235133
|
try {
|
|
235079
235134
|
await fsp21.mkdir(abilityDir, { recursive: true });
|
|
235080
|
-
await fsp21.mkdir(
|
|
235135
|
+
await fsp21.mkdir(path57.dirname(phpFilePath), { recursive: true });
|
|
235081
235136
|
await ensureAbilityBootstrapAnchors(workspace);
|
|
235082
235137
|
await patchFile(bootstrapPath, (source) => updatePluginHeaderCompatibility(source, compatibilityPolicy));
|
|
235083
235138
|
await ensureAbilityPackageScripts(workspace);
|
|
@@ -235155,7 +235210,7 @@ var init_ai_artifacts = __esm(() => {
|
|
|
235155
235210
|
|
|
235156
235211
|
// ../wp-typia-project-tools/src/runtime/ai-feature-artifacts.ts
|
|
235157
235212
|
import { mkdir as mkdir3, readFile as readFile5, writeFile as writeFile5 } from "fs/promises";
|
|
235158
|
-
import
|
|
235213
|
+
import path58 from "path";
|
|
235159
235214
|
import {
|
|
235160
235215
|
defineEndpointManifest as defineEndpointManifest3,
|
|
235161
235216
|
syncEndpointClient as syncEndpointClient3,
|
|
@@ -235168,7 +235223,7 @@ function normalizeGeneratedArtifactContent(content) {
|
|
|
235168
235223
|
}
|
|
235169
235224
|
async function reconcileGeneratedArtifact(options) {
|
|
235170
235225
|
if (!options.check) {
|
|
235171
|
-
await mkdir3(
|
|
235226
|
+
await mkdir3(path58.dirname(options.filePath), {
|
|
235172
235227
|
recursive: true
|
|
235173
235228
|
});
|
|
235174
235229
|
await writeFile5(options.filePath, options.content, "utf8");
|
|
@@ -235240,8 +235295,8 @@ async function syncAiFeatureRestArtifacts({
|
|
|
235240
235295
|
const manifest = buildAiFeatureEndpointManifest(variables);
|
|
235241
235296
|
for (const [baseName, contract] of Object.entries(manifest.contracts)) {
|
|
235242
235297
|
await syncTypeSchemas4({
|
|
235243
|
-
jsonSchemaFile:
|
|
235244
|
-
openApiFile:
|
|
235298
|
+
jsonSchemaFile: path58.join(outputDir, "api-schemas", `${baseName}.schema.json`),
|
|
235299
|
+
openApiFile: path58.join(outputDir, "api-schemas", `${baseName}.openapi.json`),
|
|
235245
235300
|
projectRoot: projectDir,
|
|
235246
235301
|
sourceTypeName: contract.sourceTypeName,
|
|
235247
235302
|
typesFile
|
|
@@ -235249,7 +235304,7 @@ async function syncAiFeatureRestArtifacts({
|
|
|
235249
235304
|
}
|
|
235250
235305
|
await syncRestOpenApi3({
|
|
235251
235306
|
manifest,
|
|
235252
|
-
openApiFile:
|
|
235307
|
+
openApiFile: path58.join(outputDir, "api.openapi.json"),
|
|
235253
235308
|
projectRoot: projectDir,
|
|
235254
235309
|
typesFile
|
|
235255
235310
|
}, executionOptions);
|
|
@@ -235267,19 +235322,19 @@ async function syncAiFeatureSchemaArtifact({
|
|
|
235267
235322
|
outputDir,
|
|
235268
235323
|
projectDir
|
|
235269
235324
|
}) {
|
|
235270
|
-
const sourceSchemaPath =
|
|
235325
|
+
const sourceSchemaPath = path58.join(projectDir, outputDir, "api-schemas", "feature-result.schema.json");
|
|
235271
235326
|
const responseSchema = assertJsonObject(JSON.parse(await readFile5(sourceSchemaPath, "utf8")), sourceSchemaPath);
|
|
235272
235327
|
const aiSchema = projectWordPressAiSchema(responseSchema);
|
|
235273
235328
|
await reconcileGeneratedArtifact({
|
|
235274
235329
|
check: check2,
|
|
235275
235330
|
content: `${JSON.stringify(aiSchema, null, 2)}
|
|
235276
235331
|
`,
|
|
235277
|
-
filePath:
|
|
235332
|
+
filePath: path58.join(projectDir, aiSchemaFile),
|
|
235278
235333
|
label: "AI feature schema"
|
|
235279
235334
|
});
|
|
235280
235335
|
return {
|
|
235281
235336
|
aiSchema,
|
|
235282
|
-
aiSchemaPath:
|
|
235337
|
+
aiSchemaPath: path58.join(projectDir, aiSchemaFile),
|
|
235283
235338
|
check: check2,
|
|
235284
235339
|
sourceSchemaPath
|
|
235285
235340
|
};
|
|
@@ -235611,7 +235666,7 @@ var init_cli_add_workspace_ai_source_emitters = __esm(() => {
|
|
|
235611
235666
|
|
|
235612
235667
|
// ../wp-typia-project-tools/src/runtime/cli-add-workspace-ai-anchors.ts
|
|
235613
235668
|
import { promises as fsp22 } from "fs";
|
|
235614
|
-
import
|
|
235669
|
+
import path59 from "path";
|
|
235615
235670
|
async function ensureAiFeatureBootstrapAnchors(workspace) {
|
|
235616
235671
|
const bootstrapPath = getWorkspaceBootstrapPath(workspace);
|
|
235617
235672
|
await patchFile(bootstrapPath, (source) => {
|
|
@@ -235658,7 +235713,7 @@ ${snippet}
|
|
|
235658
235713
|
insertPhpSnippet(registerFunction);
|
|
235659
235714
|
} else if (!nextSource.includes(AI_FEATURE_SERVER_GLOB)) {
|
|
235660
235715
|
throw new Error([
|
|
235661
|
-
`Unable to patch ${
|
|
235716
|
+
`Unable to patch ${path59.basename(bootstrapPath)} in ensureAiFeatureBootstrapAnchors.`,
|
|
235662
235717
|
`The existing ${registerFunctionName}() definition does not include ${AI_FEATURE_SERVER_GLOB}.`,
|
|
235663
235718
|
"Restore the generated bootstrap shape or wire the AI feature loader manually before retrying."
|
|
235664
235719
|
].join(" "));
|
|
@@ -235670,7 +235725,7 @@ ${snippet}
|
|
|
235670
235725
|
});
|
|
235671
235726
|
}
|
|
235672
235727
|
async function ensureAiFeaturePackageScripts(workspace) {
|
|
235673
|
-
const packageJsonPath =
|
|
235728
|
+
const packageJsonPath = path59.join(workspace.projectDir, "package.json");
|
|
235674
235729
|
const packageJson = JSON.parse(await fsp22.readFile(packageJsonPath, "utf8"));
|
|
235675
235730
|
const nextScripts = {
|
|
235676
235731
|
...packageJson.scripts ?? {},
|
|
@@ -235698,7 +235753,7 @@ async function ensureAiFeaturePackageScripts(workspace) {
|
|
|
235698
235753
|
};
|
|
235699
235754
|
}
|
|
235700
235755
|
async function ensureAiFeatureSyncProjectAnchors(workspace) {
|
|
235701
|
-
const syncProjectScriptPath =
|
|
235756
|
+
const syncProjectScriptPath = path59.join(workspace.projectDir, "scripts", "sync-project.ts");
|
|
235702
235757
|
await patchFile(syncProjectScriptPath, (source) => {
|
|
235703
235758
|
let nextSource = source;
|
|
235704
235759
|
const syncRestConst = "const syncRestScriptPath = path.join( 'scripts', 'sync-rest-contracts.ts' );";
|
|
@@ -235713,7 +235768,7 @@ async function ensureAiFeatureSyncProjectAnchors(workspace) {
|
|
|
235713
235768
|
if (!nextSource.includes(syncAiConst)) {
|
|
235714
235769
|
if (!nextSource.includes(syncRestConst)) {
|
|
235715
235770
|
throw new Error([
|
|
235716
|
-
`ensureAiFeatureSyncProjectAnchors could not patch ${
|
|
235771
|
+
`ensureAiFeatureSyncProjectAnchors could not patch ${path59.basename(syncProjectScriptPath)}.`,
|
|
235717
235772
|
"Missing the expected sync-rest script constant in scripts/sync-project.ts.",
|
|
235718
235773
|
"Restore the generated template or wire sync-ai manually before retrying."
|
|
235719
235774
|
].join(" "));
|
|
@@ -235724,7 +235779,7 @@ ${syncAiConst}`);
|
|
|
235724
235779
|
if (!nextSource.includes("runSyncScript( syncAiScriptPath, options );")) {
|
|
235725
235780
|
if (!syncRestBlockPattern.test(nextSource)) {
|
|
235726
235781
|
throw new Error([
|
|
235727
|
-
`ensureAiFeatureSyncProjectAnchors could not patch ${
|
|
235782
|
+
`ensureAiFeatureSyncProjectAnchors could not patch ${path59.basename(syncProjectScriptPath)}.`,
|
|
235728
235783
|
"Missing the expected sync-rest invocation block in scripts/sync-project.ts.",
|
|
235729
235784
|
"Restore the generated template or wire sync-ai manually before retrying."
|
|
235730
235785
|
].join(" "));
|
|
@@ -235739,7 +235794,7 @@ ${syncAiBlock}`);
|
|
|
235739
235794
|
function assertSyncRestAnchor2(nextSource, target, anchorDescription, hasAnchor, syncRestScriptPath) {
|
|
235740
235795
|
if (!nextSource.includes(target) && !hasAnchor) {
|
|
235741
235796
|
throw new Error([
|
|
235742
|
-
`ensureAiFeatureSyncRestAnchors could not patch ${
|
|
235797
|
+
`ensureAiFeatureSyncRestAnchors could not patch ${path59.basename(syncRestScriptPath)}.`,
|
|
235743
235798
|
`Missing expected ${anchorDescription} anchor in scripts/sync-rest-contracts.ts.`,
|
|
235744
235799
|
"Restore the generated template or add the AI feature wiring manually before retrying."
|
|
235745
235800
|
].join(" "));
|
|
@@ -235754,7 +235809,7 @@ function replaceRequiredSyncRestSource2(nextSource, target, anchor, replacement,
|
|
|
235754
235809
|
return nextSource.replace(anchor, replacement);
|
|
235755
235810
|
}
|
|
235756
235811
|
async function ensureAiFeatureSyncRestAnchors(workspace) {
|
|
235757
|
-
const syncRestScriptPath =
|
|
235812
|
+
const syncRestScriptPath = path59.join(workspace.projectDir, "scripts", "sync-rest-contracts.ts");
|
|
235758
235813
|
await patchFile(syncRestScriptPath, (source) => {
|
|
235759
235814
|
let nextSource = source;
|
|
235760
235815
|
const importAnchor = [
|
|
@@ -235889,7 +235944,7 @@ var init_cli_add_workspace_ai_anchors = __esm(() => {
|
|
|
235889
235944
|
|
|
235890
235945
|
// ../wp-typia-project-tools/src/runtime/cli-add-workspace-ai.ts
|
|
235891
235946
|
import { promises as fsp23 } from "fs";
|
|
235892
|
-
import
|
|
235947
|
+
import path60 from "path";
|
|
235893
235948
|
function buildAiFeaturePhpSource(aiFeatureSlug, namespace, phpPrefix, textDomain) {
|
|
235894
235949
|
const aiFeatureTitle = toTitleCase(aiFeatureSlug);
|
|
235895
235950
|
const aiFeaturePhpId = aiFeatureSlug.replace(/-/g, "_");
|
|
@@ -236278,18 +236333,18 @@ async function runAddAiFeatureCommand({
|
|
|
236278
236333
|
const compatibilityPolicy = resolveScaffoldCompatibilityPolicy(OPTIONAL_WORDPRESS_AI_CLIENT_COMPATIBILITY);
|
|
236279
236334
|
const inventory = readWorkspaceInventory(workspace.projectDir);
|
|
236280
236335
|
assertAiFeatureDoesNotExist(workspace.projectDir, aiFeatureSlug, inventory);
|
|
236281
|
-
const blockConfigPath =
|
|
236336
|
+
const blockConfigPath = path60.join(workspace.projectDir, "scripts", "block-config.ts");
|
|
236282
236337
|
const bootstrapPath = getWorkspaceBootstrapPath(workspace);
|
|
236283
|
-
const packageJsonPath =
|
|
236284
|
-
const syncAiScriptPath =
|
|
236285
|
-
const syncProjectScriptPath =
|
|
236286
|
-
const syncRestScriptPath =
|
|
236287
|
-
const aiFeatureDir =
|
|
236288
|
-
const typesFilePath =
|
|
236289
|
-
const validatorsFilePath =
|
|
236290
|
-
const apiFilePath =
|
|
236291
|
-
const dataFilePath =
|
|
236292
|
-
const phpFilePath =
|
|
236338
|
+
const packageJsonPath = path60.join(workspace.projectDir, "package.json");
|
|
236339
|
+
const syncAiScriptPath = path60.join(workspace.projectDir, "scripts", "sync-ai-features.ts");
|
|
236340
|
+
const syncProjectScriptPath = path60.join(workspace.projectDir, "scripts", "sync-project.ts");
|
|
236341
|
+
const syncRestScriptPath = path60.join(workspace.projectDir, "scripts", "sync-rest-contracts.ts");
|
|
236342
|
+
const aiFeatureDir = path60.join(workspace.projectDir, "src", "ai-features", aiFeatureSlug);
|
|
236343
|
+
const typesFilePath = path60.join(aiFeatureDir, "api-types.ts");
|
|
236344
|
+
const validatorsFilePath = path60.join(aiFeatureDir, "api-validators.ts");
|
|
236345
|
+
const apiFilePath = path60.join(aiFeatureDir, "api.ts");
|
|
236346
|
+
const dataFilePath = path60.join(aiFeatureDir, "data.ts");
|
|
236347
|
+
const phpFilePath = path60.join(workspace.projectDir, "inc", "ai-features", `${aiFeatureSlug}.php`);
|
|
236293
236348
|
const mutationSnapshot = {
|
|
236294
236349
|
fileSources: await snapshotWorkspaceFiles([
|
|
236295
236350
|
blockConfigPath,
|
|
@@ -236304,7 +236359,7 @@ async function runAddAiFeatureCommand({
|
|
|
236304
236359
|
};
|
|
236305
236360
|
try {
|
|
236306
236361
|
await fsp23.mkdir(aiFeatureDir, { recursive: true });
|
|
236307
|
-
await fsp23.mkdir(
|
|
236362
|
+
await fsp23.mkdir(path60.dirname(phpFilePath), { recursive: true });
|
|
236308
236363
|
await ensureAiFeatureBootstrapAnchors(workspace);
|
|
236309
236364
|
await patchFile(bootstrapPath, (source) => updatePluginHeaderCompatibility(source, compatibilityPolicy));
|
|
236310
236365
|
const packageScriptChanges = await ensureAiFeaturePackageScripts(workspace);
|
|
@@ -236319,7 +236374,7 @@ async function runAddAiFeatureCommand({
|
|
|
236319
236374
|
const pascalCase = toPascalCase(aiFeatureSlug);
|
|
236320
236375
|
await syncAiFeatureRestArtifacts({
|
|
236321
236376
|
clientFile: `src/ai-features/${aiFeatureSlug}/api-client.ts`,
|
|
236322
|
-
outputDir:
|
|
236377
|
+
outputDir: path60.join("src", "ai-features", aiFeatureSlug),
|
|
236323
236378
|
projectDir: workspace.projectDir,
|
|
236324
236379
|
typesFile: `src/ai-features/${aiFeatureSlug}/api-types.ts`,
|
|
236325
236380
|
validatorsFile: `src/ai-features/${aiFeatureSlug}/api-validators.ts`,
|
|
@@ -236332,7 +236387,7 @@ async function runAddAiFeatureCommand({
|
|
|
236332
236387
|
});
|
|
236333
236388
|
await syncAiFeatureSchemaArtifact({
|
|
236334
236389
|
aiSchemaFile: `src/ai-features/${aiFeatureSlug}/ai-schemas/feature-result.ai.schema.json`,
|
|
236335
|
-
outputDir:
|
|
236390
|
+
outputDir: path60.join("src", "ai-features", aiFeatureSlug),
|
|
236336
236391
|
projectDir: workspace.projectDir
|
|
236337
236392
|
});
|
|
236338
236393
|
await appendWorkspaceInventoryEntries(workspace.projectDir, {
|
|
@@ -236368,7 +236423,7 @@ var init_cli_add_workspace_ai = __esm(() => {
|
|
|
236368
236423
|
// ../wp-typia-project-tools/src/runtime/cli-add-workspace.ts
|
|
236369
236424
|
import fs45 from "fs";
|
|
236370
236425
|
import { promises as fsp24 } from "fs";
|
|
236371
|
-
import
|
|
236426
|
+
import path61 from "path";
|
|
236372
236427
|
function maskSourceSegment(segment) {
|
|
236373
236428
|
return segment.replace(/[^\n\r]/gu, " ");
|
|
236374
236429
|
}
|
|
@@ -236752,7 +236807,7 @@ ${VARIATIONS_CALL_LINE}
|
|
|
236752
236807
|
}
|
|
236753
236808
|
}
|
|
236754
236809
|
if (!hasExecutablePattern(nextSource, VARIATIONS_CALL_PATTERN)) {
|
|
236755
|
-
throw new Error(`Unable to inject ${VARIATIONS_CALL_LINE} into ${
|
|
236810
|
+
throw new Error(`Unable to inject ${VARIATIONS_CALL_LINE} into ${path61.basename(blockIndexPath)}.`);
|
|
236756
236811
|
}
|
|
236757
236812
|
return nextSource;
|
|
236758
236813
|
});
|
|
@@ -236782,7 +236837,7 @@ ${BLOCK_STYLES_CALL_LINE}
|
|
|
236782
236837
|
}
|
|
236783
236838
|
}
|
|
236784
236839
|
if (!hasExecutablePattern(nextSource, BLOCK_STYLES_CALL_PATTERN)) {
|
|
236785
|
-
throw new Error(`Unable to inject ${BLOCK_STYLES_CALL_LINE} into ${
|
|
236840
|
+
throw new Error(`Unable to inject ${BLOCK_STYLES_CALL_LINE} into ${path61.basename(blockIndexPath)}.`);
|
|
236786
236841
|
}
|
|
236787
236842
|
return nextSource;
|
|
236788
236843
|
});
|
|
@@ -236799,7 +236854,7 @@ ${nextSource}`;
|
|
|
236799
236854
|
SCAFFOLD_REGISTRATION_SETTINGS_CALL_PATTERN
|
|
236800
236855
|
]);
|
|
236801
236856
|
if (!callRange) {
|
|
236802
|
-
throw new Error(`Unable to inject ${BLOCK_TRANSFORMS_CALL_LINE} into ${
|
|
236857
|
+
throw new Error(`Unable to inject ${BLOCK_TRANSFORMS_CALL_LINE} into ${path61.basename(blockIndexPath)} because it does not expose a scaffold registration settings object.`);
|
|
236803
236858
|
}
|
|
236804
236859
|
nextSource = [
|
|
236805
236860
|
nextSource.slice(0, callRange.start),
|
|
@@ -236812,42 +236867,42 @@ ${nextSource}`;
|
|
|
236812
236867
|
});
|
|
236813
236868
|
}
|
|
236814
236869
|
async function writeVariationRegistry(projectDir, blockSlug, variationSlug) {
|
|
236815
|
-
const variationsDir =
|
|
236816
|
-
const variationsIndexPath =
|
|
236870
|
+
const variationsDir = path61.join(projectDir, "src", "blocks", blockSlug, "variations");
|
|
236871
|
+
const variationsIndexPath = path61.join(variationsDir, "index.ts");
|
|
236817
236872
|
await fsp24.mkdir(variationsDir, { recursive: true });
|
|
236818
236873
|
const existingVariationSlugs = fs45.readdirSync(variationsDir).filter((entry) => entry.endsWith(".ts") && entry !== "index.ts").map((entry) => entry.replace(/\.ts$/u, ""));
|
|
236819
236874
|
const nextVariationSlugs = Array.from(new Set([...existingVariationSlugs, variationSlug])).sort();
|
|
236820
236875
|
await fsp24.writeFile(variationsIndexPath, buildVariationIndexSource(nextVariationSlugs), "utf8");
|
|
236821
236876
|
}
|
|
236822
236877
|
async function writeBlockStyleRegistry(projectDir, blockSlug, styleSlug) {
|
|
236823
|
-
const stylesDir =
|
|
236824
|
-
const stylesIndexPath =
|
|
236878
|
+
const stylesDir = path61.join(projectDir, "src", "blocks", blockSlug, "styles");
|
|
236879
|
+
const stylesIndexPath = path61.join(stylesDir, "index.ts");
|
|
236825
236880
|
await fsp24.mkdir(stylesDir, { recursive: true });
|
|
236826
236881
|
const existingStyleSlugs = fs45.readdirSync(stylesDir).filter((entry) => entry.endsWith(".ts") && entry !== "index.ts").map((entry) => entry.replace(/\.ts$/u, ""));
|
|
236827
236882
|
const nextStyleSlugs = Array.from(new Set([...existingStyleSlugs, styleSlug])).sort();
|
|
236828
236883
|
await fsp24.writeFile(stylesIndexPath, buildBlockStyleIndexSource(nextStyleSlugs), "utf8");
|
|
236829
236884
|
}
|
|
236830
236885
|
async function writeBlockTransformRegistry(projectDir, blockSlug, transformSlug) {
|
|
236831
|
-
const transformsDir =
|
|
236832
|
-
const transformsIndexPath =
|
|
236886
|
+
const transformsDir = path61.join(projectDir, "src", "blocks", blockSlug, "transforms");
|
|
236887
|
+
const transformsIndexPath = path61.join(transformsDir, "index.ts");
|
|
236833
236888
|
await fsp24.mkdir(transformsDir, { recursive: true });
|
|
236834
236889
|
const existingTransformSlugs = fs45.readdirSync(transformsDir).filter((entry) => entry.endsWith(".ts") && entry !== "index.ts").map((entry) => entry.replace(/\.ts$/u, ""));
|
|
236835
236890
|
const nextTransformSlugs = Array.from(new Set([...existingTransformSlugs, transformSlug])).sort();
|
|
236836
236891
|
await fsp24.writeFile(transformsIndexPath, buildBlockTransformIndexSource(nextTransformSlugs), "utf8");
|
|
236837
236892
|
}
|
|
236838
236893
|
function assertBlockStyleDoesNotExist(projectDir, blockSlug, styleSlug, inventory) {
|
|
236839
|
-
const stylePath =
|
|
236894
|
+
const stylePath = path61.join(projectDir, "src", "blocks", blockSlug, "styles", `${styleSlug}.ts`);
|
|
236840
236895
|
if (fs45.existsSync(stylePath)) {
|
|
236841
|
-
throw new Error(`A block style already exists at ${
|
|
236896
|
+
throw new Error(`A block style already exists at ${path61.relative(projectDir, stylePath)}. Choose a different name.`);
|
|
236842
236897
|
}
|
|
236843
236898
|
if (inventory.blockStyles.some((entry) => entry.block === blockSlug && entry.slug === styleSlug)) {
|
|
236844
236899
|
throw new Error(`A block style inventory entry already exists for ${blockSlug}/${styleSlug}. Choose a different name.`);
|
|
236845
236900
|
}
|
|
236846
236901
|
}
|
|
236847
236902
|
function assertBlockTransformDoesNotExist(projectDir, blockSlug, transformSlug, inventory) {
|
|
236848
|
-
const transformPath =
|
|
236903
|
+
const transformPath = path61.join(projectDir, "src", "blocks", blockSlug, "transforms", `${transformSlug}.ts`);
|
|
236849
236904
|
if (fs45.existsSync(transformPath)) {
|
|
236850
|
-
throw new Error(`A block transform already exists at ${
|
|
236905
|
+
throw new Error(`A block transform already exists at ${path61.relative(projectDir, transformPath)}. Choose a different name.`);
|
|
236851
236906
|
}
|
|
236852
236907
|
if (inventory.blockTransforms.some((entry) => entry.block === blockSlug && entry.slug === transformSlug)) {
|
|
236853
236908
|
throw new Error(`A block transform inventory entry already exists for ${blockSlug}/${transformSlug}. Choose a different name.`);
|
|
@@ -236893,11 +236948,11 @@ async function runAddVariationCommand({
|
|
|
236893
236948
|
const inventory = readWorkspaceInventory(workspace.projectDir);
|
|
236894
236949
|
resolveWorkspaceBlock(inventory, blockSlug);
|
|
236895
236950
|
assertVariationDoesNotExist(workspace.projectDir, blockSlug, variationSlug, inventory);
|
|
236896
|
-
const blockConfigPath =
|
|
236897
|
-
const blockIndexPath =
|
|
236898
|
-
const variationsDir =
|
|
236899
|
-
const variationFilePath =
|
|
236900
|
-
const variationsIndexPath =
|
|
236951
|
+
const blockConfigPath = path61.join(workspace.projectDir, "scripts", "block-config.ts");
|
|
236952
|
+
const blockIndexPath = path61.join(workspace.projectDir, "src", "blocks", blockSlug, "index.tsx");
|
|
236953
|
+
const variationsDir = path61.join(workspace.projectDir, "src", "blocks", blockSlug, "variations");
|
|
236954
|
+
const variationFilePath = path61.join(variationsDir, `${variationSlug}.ts`);
|
|
236955
|
+
const variationsIndexPath = path61.join(variationsDir, "index.ts");
|
|
236901
236956
|
const shouldRemoveVariationsDirOnRollback = !fs45.existsSync(variationsDir);
|
|
236902
236957
|
const mutationSnapshot = {
|
|
236903
236958
|
fileSources: await snapshotWorkspaceFiles([
|
|
@@ -236940,11 +236995,11 @@ async function runAddBlockStyleCommand({
|
|
|
236940
236995
|
const inventory = readWorkspaceInventory(workspace.projectDir);
|
|
236941
236996
|
resolveWorkspaceBlock(inventory, blockSlug);
|
|
236942
236997
|
assertBlockStyleDoesNotExist(workspace.projectDir, blockSlug, styleSlug, inventory);
|
|
236943
|
-
const blockConfigPath =
|
|
236944
|
-
const blockIndexPath =
|
|
236945
|
-
const stylesDir =
|
|
236946
|
-
const styleFilePath =
|
|
236947
|
-
const stylesIndexPath =
|
|
236998
|
+
const blockConfigPath = path61.join(workspace.projectDir, "scripts", "block-config.ts");
|
|
236999
|
+
const blockIndexPath = path61.join(workspace.projectDir, "src", "blocks", blockSlug, "index.tsx");
|
|
237000
|
+
const stylesDir = path61.join(workspace.projectDir, "src", "blocks", blockSlug, "styles");
|
|
237001
|
+
const styleFilePath = path61.join(stylesDir, `${styleSlug}.ts`);
|
|
237002
|
+
const stylesIndexPath = path61.join(stylesDir, "index.ts");
|
|
236948
237003
|
const shouldRemoveStylesDirOnRollback = !fs45.existsSync(stylesDir);
|
|
236949
237004
|
const mutationSnapshot = {
|
|
236950
237005
|
fileSources: await snapshotWorkspaceFiles([
|
|
@@ -236989,11 +237044,11 @@ async function runAddBlockTransformCommand({
|
|
|
236989
237044
|
const inventory = readWorkspaceInventory(workspace.projectDir);
|
|
236990
237045
|
resolveWorkspaceBlock(inventory, target.blockSlug);
|
|
236991
237046
|
assertBlockTransformDoesNotExist(workspace.projectDir, target.blockSlug, transformSlug, inventory);
|
|
236992
|
-
const blockConfigPath =
|
|
236993
|
-
const blockIndexPath =
|
|
236994
|
-
const transformsDir =
|
|
236995
|
-
const transformFilePath =
|
|
236996
|
-
const transformsIndexPath =
|
|
237047
|
+
const blockConfigPath = path61.join(workspace.projectDir, "scripts", "block-config.ts");
|
|
237048
|
+
const blockIndexPath = path61.join(workspace.projectDir, "src", "blocks", target.blockSlug, "index.tsx");
|
|
237049
|
+
const transformsDir = path61.join(workspace.projectDir, "src", "blocks", target.blockSlug, "transforms");
|
|
237050
|
+
const transformFilePath = path61.join(transformsDir, `${transformSlug}.ts`);
|
|
237051
|
+
const transformsIndexPath = path61.join(transformsDir, "index.ts");
|
|
236997
237052
|
const shouldRemoveTransformsDirOnRollback = !fs45.existsSync(transformsDir);
|
|
236998
237053
|
const mutationSnapshot = {
|
|
236999
237054
|
fileSources: await snapshotWorkspaceFiles([
|
|
@@ -237055,7 +237110,7 @@ async function runAddHookedBlockCommand({
|
|
|
237055
237110
|
throw new Error("`wp-typia add hooked-block` cannot hook a block relative to its own block name.");
|
|
237056
237111
|
}
|
|
237057
237112
|
const { blockJson, blockJsonPath } = readWorkspaceBlockJson(workspace.projectDir, blockSlug);
|
|
237058
|
-
const blockJsonRelativePath =
|
|
237113
|
+
const blockJsonRelativePath = path61.relative(workspace.projectDir, blockJsonPath);
|
|
237059
237114
|
const blockHooks = getMutableBlockHooks(blockJson, blockJsonRelativePath);
|
|
237060
237115
|
if (Object.prototype.hasOwnProperty.call(blockHooks, resolvedAnchorBlockName)) {
|
|
237061
237116
|
throw new Error(`${blockJsonRelativePath} already defines a blockHooks entry for "${resolvedAnchorBlockName}".`);
|
|
@@ -237133,7 +237188,7 @@ import { execFileSync as execFileSync3 } from "child_process";
|
|
|
237133
237188
|
import { access, constants as fsConstants, rm as rm2, writeFile as writeFile6 } from "fs/promises";
|
|
237134
237189
|
import fs46 from "fs";
|
|
237135
237190
|
import os5 from "os";
|
|
237136
|
-
import
|
|
237191
|
+
import path62 from "path";
|
|
237137
237192
|
function readCommandVersion(command, args = ["--version"]) {
|
|
237138
237193
|
try {
|
|
237139
237194
|
return execFileSync3(command, args, {
|
|
@@ -237157,7 +237212,7 @@ async function checkWritableDirectory(directory) {
|
|
|
237157
237212
|
}
|
|
237158
237213
|
}
|
|
237159
237214
|
async function checkTempDirectory() {
|
|
237160
|
-
const tempFile =
|
|
237215
|
+
const tempFile = path62.join(os5.tmpdir(), `wp-typia-${Date.now()}.tmp`);
|
|
237161
237216
|
try {
|
|
237162
237217
|
await writeFile6(tempFile, "ok", "utf8");
|
|
237163
237218
|
await rm2(tempFile, { force: true });
|
|
@@ -237174,7 +237229,7 @@ function getTemplateDoctorChecks() {
|
|
|
237174
237229
|
for (const template of listTemplates()) {
|
|
237175
237230
|
if (!isBuiltInTemplateId(template.id)) {
|
|
237176
237231
|
const templateDirExists = fs46.existsSync(template.templateDir);
|
|
237177
|
-
const hasAssets2 = templateDirExists && fs46.existsSync(
|
|
237232
|
+
const hasAssets2 = templateDirExists && fs46.existsSync(path62.join(template.templateDir, "package.json.mustache"));
|
|
237178
237233
|
checks3.push({
|
|
237179
237234
|
status: !templateDirExists || hasAssets2 ? "pass" : "fail",
|
|
237180
237235
|
label: `Template ${template.id}`,
|
|
@@ -237199,7 +237254,7 @@ function getTemplateDoctorChecks() {
|
|
|
237199
237254
|
])) : getBuiltInTemplateLayerDirs(builtInTemplateId);
|
|
237200
237255
|
const missingRequiredLayer = layerDirs.some((layerDir) => !fs46.existsSync(layerDir) && !isOmittableBuiltInTemplateLayerDir(builtInTemplateId, layerDir));
|
|
237201
237256
|
const existingLayerDirs = layerDirs.filter((layerDir) => fs46.existsSync(layerDir));
|
|
237202
|
-
const hasAssets = !missingRequiredLayer && existingLayerDirs.some((layerDir) => fs46.existsSync(
|
|
237257
|
+
const hasAssets = !missingRequiredLayer && existingLayerDirs.some((layerDir) => fs46.existsSync(path62.join(layerDir, "package.json.mustache"))) && existingLayerDirs.some((layerDir) => fs46.existsSync(path62.join(layerDir, "src")));
|
|
237203
237258
|
checks3.push({
|
|
237204
237259
|
status: hasAssets ? "pass" : "fail",
|
|
237205
237260
|
label: `Template ${template.id}`,
|
|
@@ -237230,7 +237285,7 @@ var init_cli_doctor_environment = __esm(() => {
|
|
|
237230
237285
|
|
|
237231
237286
|
// ../wp-typia-project-tools/src/runtime/cli-doctor-workspace.ts
|
|
237232
237287
|
import fs47 from "fs";
|
|
237233
|
-
import
|
|
237288
|
+
import path63 from "path";
|
|
237234
237289
|
import { parseScaffoldBlockMetadata as parseScaffoldBlockMetadata2 } from "@wp-typia/block-runtime/blocks";
|
|
237235
237290
|
function createDoctorCheck2(label, status, detail, code) {
|
|
237236
237291
|
return code ? { code, detail, label, status } : { detail, label, status };
|
|
@@ -237300,7 +237355,7 @@ function hasExecutablePattern2(source, pattern) {
|
|
|
237300
237355
|
return pattern.test(maskTypeScriptCommentsAndLiterals2(source));
|
|
237301
237356
|
}
|
|
237302
237357
|
function normalizePathSeparators(relativePath) {
|
|
237303
|
-
return relativePath.split(
|
|
237358
|
+
return relativePath.split(path63.sep).join("/");
|
|
237304
237359
|
}
|
|
237305
237360
|
function hasRegisteredBlockAsset(value2) {
|
|
237306
237361
|
if (typeof value2 === "string") {
|
|
@@ -237312,8 +237367,8 @@ function hasRegisteredBlockAsset(value2) {
|
|
|
237312
237367
|
return false;
|
|
237313
237368
|
}
|
|
237314
237369
|
function readWorkspaceBlockIframeMetadata(projectDir, blockSlug) {
|
|
237315
|
-
const blockJsonRelativePath =
|
|
237316
|
-
const blockJsonPath =
|
|
237370
|
+
const blockJsonRelativePath = path63.join("src", "blocks", blockSlug, "block.json");
|
|
237371
|
+
const blockJsonPath = path63.join(projectDir, blockJsonRelativePath);
|
|
237317
237372
|
if (!fs47.existsSync(blockJsonPath)) {
|
|
237318
237373
|
return {
|
|
237319
237374
|
blockJsonRelativePath,
|
|
@@ -237358,14 +237413,14 @@ function isWorkspaceBlockSaveSource(relativePath) {
|
|
|
237358
237413
|
return fileName.replace(/\.[^.]+$/u, "").toLowerCase() === "save";
|
|
237359
237414
|
}
|
|
237360
237415
|
function collectWorkspaceBlockEditorSources(projectDir, blockSlug) {
|
|
237361
|
-
const blockDir =
|
|
237416
|
+
const blockDir = path63.join(projectDir, "src", "blocks", blockSlug);
|
|
237362
237417
|
if (!fs47.existsSync(blockDir)) {
|
|
237363
237418
|
return [];
|
|
237364
237419
|
}
|
|
237365
237420
|
const sources = [];
|
|
237366
237421
|
const visitDirectory = (directory) => {
|
|
237367
237422
|
for (const entry of fs47.readdirSync(directory, { withFileTypes: true })) {
|
|
237368
|
-
const entryPath =
|
|
237423
|
+
const entryPath = path63.join(directory, entry.name);
|
|
237369
237424
|
if (entry.isDirectory()) {
|
|
237370
237425
|
visitDirectory(entryPath);
|
|
237371
237426
|
continue;
|
|
@@ -237373,8 +237428,8 @@ function collectWorkspaceBlockEditorSources(projectDir, blockSlug) {
|
|
|
237373
237428
|
if (!entry.isFile()) {
|
|
237374
237429
|
continue;
|
|
237375
237430
|
}
|
|
237376
|
-
const relativePath = normalizePathSeparators(
|
|
237377
|
-
const blockRelativePath =
|
|
237431
|
+
const relativePath = normalizePathSeparators(path63.relative(projectDir, entryPath));
|
|
237432
|
+
const blockRelativePath = path63.relative(blockDir, entryPath);
|
|
237378
237433
|
if (!isWorkspaceBlockEditorSource(blockRelativePath)) {
|
|
237379
237434
|
continue;
|
|
237380
237435
|
}
|
|
@@ -237440,7 +237495,7 @@ function getWorkspaceBootstrapRelativePath(packageName) {
|
|
|
237440
237495
|
return `${packageBaseName}.php`;
|
|
237441
237496
|
}
|
|
237442
237497
|
function checkExistingFiles(projectDir, label, filePaths) {
|
|
237443
|
-
const missing = filePaths.filter((filePath) => typeof filePath === "string").filter((filePath) => !fs47.existsSync(
|
|
237498
|
+
const missing = filePaths.filter((filePath) => typeof filePath === "string").filter((filePath) => !fs47.existsSync(path63.join(projectDir, filePath)));
|
|
237444
237499
|
return createDoctorCheck2(label, missing.length === 0 ? "pass" : "fail", missing.length === 0 ? "All referenced files exist" : `Missing: ${missing.join(", ")}`);
|
|
237445
237500
|
}
|
|
237446
237501
|
function checkWorkspacePackageMetadata(workspace, packageJson) {
|
|
@@ -237466,24 +237521,24 @@ function checkWorkspacePackageMetadata(workspace, packageJson) {
|
|
|
237466
237521
|
if (wpTypia?.phpPrefix !== workspace.workspace.phpPrefix) {
|
|
237467
237522
|
issues.push(`wpTypia.phpPrefix must equal "${workspace.workspace.phpPrefix}"`);
|
|
237468
237523
|
}
|
|
237469
|
-
if (!fs47.existsSync(
|
|
237524
|
+
if (!fs47.existsSync(path63.join(workspace.projectDir, bootstrapRelativePath))) {
|
|
237470
237525
|
issues.push(`Missing bootstrap file ${bootstrapRelativePath}`);
|
|
237471
237526
|
}
|
|
237472
237527
|
return createDoctorCheck2("Workspace package metadata", issues.length === 0 ? "pass" : "fail", issues.length === 0 ? `package.json metadata aligns with ${workspace.packageName} and ${bootstrapRelativePath}` : issues.join("; "));
|
|
237473
237528
|
}
|
|
237474
237529
|
function getWorkspaceBlockRequiredFiles(block) {
|
|
237475
|
-
const blockDir =
|
|
237530
|
+
const blockDir = path63.join("src", "blocks", block.slug);
|
|
237476
237531
|
return Array.from(new Set([
|
|
237477
237532
|
block.typesFile,
|
|
237478
237533
|
block.apiTypesFile,
|
|
237479
237534
|
block.openApiFile,
|
|
237480
|
-
|
|
237481
|
-
...WORKSPACE_GENERATED_BLOCK_ARTIFACTS.map((fileName) =>
|
|
237535
|
+
path63.join(blockDir, "index.tsx"),
|
|
237536
|
+
...WORKSPACE_GENERATED_BLOCK_ARTIFACTS.map((fileName) => path63.join(blockDir, fileName))
|
|
237482
237537
|
].filter((filePath) => typeof filePath === "string")));
|
|
237483
237538
|
}
|
|
237484
237539
|
function checkWorkspaceBlockMetadata(projectDir, workspace, block) {
|
|
237485
|
-
const blockJsonRelativePath =
|
|
237486
|
-
const blockJsonPath =
|
|
237540
|
+
const blockJsonRelativePath = path63.join("src", "blocks", block.slug, "block.json");
|
|
237541
|
+
const blockJsonPath = path63.join(projectDir, blockJsonRelativePath);
|
|
237487
237542
|
if (!fs47.existsSync(blockJsonPath)) {
|
|
237488
237543
|
return createDoctorCheck2(`Block metadata ${block.slug}`, "fail", `Missing ${blockJsonRelativePath}`);
|
|
237489
237544
|
}
|
|
@@ -237504,8 +237559,8 @@ function checkWorkspaceBlockMetadata(projectDir, workspace, block) {
|
|
|
237504
237559
|
return createDoctorCheck2(`Block metadata ${block.slug}`, issues.length === 0 ? "pass" : "fail", issues.length === 0 ? `block.json matches ${expectedName} and ${workspace.workspace.textDomain}` : issues.join("; "));
|
|
237505
237560
|
}
|
|
237506
237561
|
function checkWorkspaceBlockHooks(projectDir, blockSlug) {
|
|
237507
|
-
const blockJsonRelativePath =
|
|
237508
|
-
const blockJsonPath =
|
|
237562
|
+
const blockJsonRelativePath = path63.join("src", "blocks", blockSlug, "block.json");
|
|
237563
|
+
const blockJsonPath = path63.join(projectDir, blockJsonRelativePath);
|
|
237509
237564
|
if (!fs47.existsSync(blockJsonPath)) {
|
|
237510
237565
|
return createDoctorCheck2(`Block hooks ${blockSlug}`, "fail", `Missing ${blockJsonRelativePath}`);
|
|
237511
237566
|
}
|
|
@@ -237527,8 +237582,8 @@ function checkWorkspaceBlockHooks(projectDir, blockSlug) {
|
|
|
237527
237582
|
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(", ")}`);
|
|
237528
237583
|
}
|
|
237529
237584
|
function checkWorkspaceBlockCollectionImport(projectDir, blockSlug) {
|
|
237530
|
-
const entryRelativePath =
|
|
237531
|
-
const entryPath =
|
|
237585
|
+
const entryRelativePath = path63.join("src", "blocks", blockSlug, "index.tsx");
|
|
237586
|
+
const entryPath = path63.join(projectDir, entryRelativePath);
|
|
237532
237587
|
if (!fs47.existsSync(entryPath)) {
|
|
237533
237588
|
return createDoctorCheck2(`Block collection ${blockSlug}`, "fail", `Missing ${entryRelativePath}`);
|
|
237534
237589
|
}
|
|
@@ -237545,8 +237600,8 @@ function checkWorkspaceBlockIframeCompatibility(projectDir, blockSlug) {
|
|
|
237545
237600
|
}
|
|
237546
237601
|
const blockJson = metadataResult.document;
|
|
237547
237602
|
const apiVersion = typeof blockJson.apiVersion === "number" && Number.isFinite(blockJson.apiVersion) ? blockJson.apiVersion : null;
|
|
237548
|
-
const blockDir =
|
|
237549
|
-
const localStyleFiles = WORKSPACE_BLOCK_LOCAL_STYLE_FILES.filter((fileName) => fs47.existsSync(
|
|
237603
|
+
const blockDir = path63.join(projectDir, "src", "blocks", blockSlug);
|
|
237604
|
+
const localStyleFiles = WORKSPACE_BLOCK_LOCAL_STYLE_FILES.filter((fileName) => fs47.existsSync(path63.join(blockDir, fileName))).map((fileName) => normalizePathSeparators(path63.join("src", "blocks", blockSlug, fileName)));
|
|
237550
237605
|
const hasRegisteredEditorStyles = hasRegisteredBlockAsset(blockJson.style) || hasRegisteredBlockAsset(blockJson.editorStyle);
|
|
237551
237606
|
const editorSources = collectWorkspaceBlockEditorSources(projectDir, blockSlug);
|
|
237552
237607
|
const editorWrapperSources = editorSources.filter((source) => !isWorkspaceBlockSaveSource(source.relativePath));
|
|
@@ -237564,9 +237619,9 @@ function checkWorkspaceBlockIframeCompatibility(projectDir, blockSlug) {
|
|
|
237564
237619
|
}
|
|
237565
237620
|
function checkWorkspacePatternBootstrap(projectDir, packageName) {
|
|
237566
237621
|
const packageBaseName = packageName.split("/").pop() ?? packageName;
|
|
237567
|
-
const bootstrapPath =
|
|
237622
|
+
const bootstrapPath = path63.join(projectDir, `${packageBaseName}.php`);
|
|
237568
237623
|
if (!fs47.existsSync(bootstrapPath)) {
|
|
237569
|
-
return createDoctorCheck2("Pattern bootstrap", "fail", `Missing ${
|
|
237624
|
+
return createDoctorCheck2("Pattern bootstrap", "fail", `Missing ${path63.basename(bootstrapPath)}`);
|
|
237570
237625
|
}
|
|
237571
237626
|
const source = fs47.readFileSync(bootstrapPath, "utf8");
|
|
237572
237627
|
const hasCategoryAnchor = source.includes("register_block_pattern_category");
|
|
@@ -237575,9 +237630,9 @@ function checkWorkspacePatternBootstrap(projectDir, packageName) {
|
|
|
237575
237630
|
}
|
|
237576
237631
|
function checkWorkspaceBindingBootstrap(projectDir, packageName) {
|
|
237577
237632
|
const packageBaseName = packageName.split("/").pop() ?? packageName;
|
|
237578
|
-
const bootstrapPath =
|
|
237633
|
+
const bootstrapPath = path63.join(projectDir, `${packageBaseName}.php`);
|
|
237579
237634
|
if (!fs47.existsSync(bootstrapPath)) {
|
|
237580
|
-
return createDoctorCheck2("Binding bootstrap", "fail", `Missing ${
|
|
237635
|
+
return createDoctorCheck2("Binding bootstrap", "fail", `Missing ${path63.basename(bootstrapPath)}`);
|
|
237581
237636
|
}
|
|
237582
237637
|
const source = fs47.readFileSync(bootstrapPath, "utf8");
|
|
237583
237638
|
const hasServerGlob = source.includes(WORKSPACE_BINDING_SERVER_GLOB);
|
|
@@ -237587,11 +237642,11 @@ function checkWorkspaceBindingBootstrap(projectDir, packageName) {
|
|
|
237587
237642
|
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");
|
|
237588
237643
|
}
|
|
237589
237644
|
function checkWorkspaceBindingSourcesIndex(projectDir, bindingSources) {
|
|
237590
|
-
const indexRelativePath = [
|
|
237645
|
+
const indexRelativePath = [path63.join("src", "bindings", "index.ts"), path63.join("src", "bindings", "index.js")].find((relativePath) => fs47.existsSync(path63.join(projectDir, relativePath)));
|
|
237591
237646
|
if (!indexRelativePath) {
|
|
237592
237647
|
return createDoctorCheck2("Binding sources index", "fail", "Missing src/bindings/index.ts or src/bindings/index.js");
|
|
237593
237648
|
}
|
|
237594
|
-
const indexPath =
|
|
237649
|
+
const indexPath = path63.join(projectDir, indexRelativePath);
|
|
237595
237650
|
const source = fs47.readFileSync(indexPath, "utf8");
|
|
237596
237651
|
const missingImports = bindingSources.filter((bindingSource) => !source.includes(`./${bindingSource.slug}/editor`));
|
|
237597
237652
|
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(", ")}`);
|
|
@@ -237608,8 +237663,8 @@ function checkWorkspaceBindingTarget(projectDir, workspace, registeredBlockSlugs
|
|
|
237608
237663
|
if (!registeredBlockSlugs.has(bindingSource.block)) {
|
|
237609
237664
|
return createDoctorCheck2(`Binding target ${bindingSource.slug}`, "fail", `Binding target references unknown block "${bindingSource.block}".`);
|
|
237610
237665
|
}
|
|
237611
|
-
const blockJsonRelativePath =
|
|
237612
|
-
const blockJsonPath =
|
|
237666
|
+
const blockJsonRelativePath = path63.join("src", "blocks", bindingSource.block, "block.json");
|
|
237667
|
+
const blockJsonPath = path63.join(projectDir, blockJsonRelativePath);
|
|
237613
237668
|
const issues = [];
|
|
237614
237669
|
try {
|
|
237615
237670
|
const blockJson = parseScaffoldBlockMetadata2(JSON.parse(fs47.readFileSync(blockJsonPath, "utf8")));
|
|
@@ -237625,7 +237680,7 @@ function checkWorkspaceBindingTarget(projectDir, workspace, registeredBlockSlugs
|
|
|
237625
237680
|
} catch (error48) {
|
|
237626
237681
|
issues.push(error48 instanceof Error ? `Unable to read ${blockJsonRelativePath}: ${error48.message}` : `Unable to read ${blockJsonRelativePath}.`);
|
|
237627
237682
|
}
|
|
237628
|
-
const serverPath =
|
|
237683
|
+
const serverPath = path63.join(projectDir, bindingSource.serverFile);
|
|
237629
237684
|
if (fs47.existsSync(serverPath)) {
|
|
237630
237685
|
const serverSource = fs47.readFileSync(serverPath, "utf8");
|
|
237631
237686
|
const supportedAttributesFilter = `block_bindings_supported_attributes_${workspace.workspace.namespace}/${bindingSource.block}`;
|
|
@@ -237638,7 +237693,7 @@ function checkWorkspaceBindingTarget(projectDir, workspace, registeredBlockSlugs
|
|
|
237638
237693
|
} else {
|
|
237639
237694
|
issues.push(`Missing ${bindingSource.serverFile}`);
|
|
237640
237695
|
}
|
|
237641
|
-
const editorPath =
|
|
237696
|
+
const editorPath = path63.join(projectDir, bindingSource.editorFile);
|
|
237642
237697
|
if (fs47.existsSync(editorPath)) {
|
|
237643
237698
|
const editorSource = fs47.readFileSync(editorPath, "utf8");
|
|
237644
237699
|
const blockName = `${workspace.workspace.namespace}/${bindingSource.block}`;
|
|
@@ -237686,7 +237741,7 @@ function getWorkspaceRestResourceRequiredFiles(restResource) {
|
|
|
237686
237741
|
}
|
|
237687
237742
|
return Array.from(new Set([
|
|
237688
237743
|
restResource.apiFile,
|
|
237689
|
-
...Array.from(schemaNames, (schemaName) =>
|
|
237744
|
+
...Array.from(schemaNames, (schemaName) => path63.join(path63.dirname(restResource.typesFile), "api-schemas", `${schemaName}.schema.json`)),
|
|
237690
237745
|
restResource.clientFile,
|
|
237691
237746
|
restResource.dataFile,
|
|
237692
237747
|
restResource.openApiFile,
|
|
@@ -237702,9 +237757,9 @@ function checkWorkspaceRestResourceConfig(restResource) {
|
|
|
237702
237757
|
}
|
|
237703
237758
|
function checkWorkspaceRestResourceBootstrap(projectDir, packageName, phpPrefix) {
|
|
237704
237759
|
const packageBaseName = packageName.split("/").pop() ?? packageName;
|
|
237705
|
-
const bootstrapPath =
|
|
237760
|
+
const bootstrapPath = path63.join(projectDir, `${packageBaseName}.php`);
|
|
237706
237761
|
if (!fs47.existsSync(bootstrapPath)) {
|
|
237707
|
-
return createDoctorCheck2("REST resource bootstrap", "fail", `Missing ${
|
|
237762
|
+
return createDoctorCheck2("REST resource bootstrap", "fail", `Missing ${path63.basename(bootstrapPath)}`);
|
|
237708
237763
|
}
|
|
237709
237764
|
const source = fs47.readFileSync(bootstrapPath, "utf8");
|
|
237710
237765
|
const registerFunctionName = `${phpPrefix}_register_rest_resources`;
|
|
@@ -237725,7 +237780,7 @@ function getWorkspaceAbilityRequiredFiles(ability) {
|
|
|
237725
237780
|
]));
|
|
237726
237781
|
}
|
|
237727
237782
|
function checkWorkspaceAbilityConfig(projectDir, ability) {
|
|
237728
|
-
const configPath =
|
|
237783
|
+
const configPath = path63.join(projectDir, ability.configFile);
|
|
237729
237784
|
if (!fs47.existsSync(configPath)) {
|
|
237730
237785
|
return createDoctorCheck2(`Ability config ${ability.slug}`, "fail", `Missing ${ability.configFile}`);
|
|
237731
237786
|
}
|
|
@@ -237742,9 +237797,9 @@ function checkWorkspaceAbilityConfig(projectDir, ability) {
|
|
|
237742
237797
|
}
|
|
237743
237798
|
function checkWorkspaceAbilityBootstrap(projectDir, packageName, phpPrefix) {
|
|
237744
237799
|
const packageBaseName = packageName.split("/").pop() ?? packageName;
|
|
237745
|
-
const bootstrapPath =
|
|
237800
|
+
const bootstrapPath = path63.join(projectDir, `${packageBaseName}.php`);
|
|
237746
237801
|
if (!fs47.existsSync(bootstrapPath)) {
|
|
237747
|
-
return createDoctorCheck2("Ability bootstrap", "fail", `Missing ${
|
|
237802
|
+
return createDoctorCheck2("Ability bootstrap", "fail", `Missing ${path63.basename(bootstrapPath)}`);
|
|
237748
237803
|
}
|
|
237749
237804
|
const source = fs47.readFileSync(bootstrapPath, "utf8");
|
|
237750
237805
|
const loadFunctionName = `${phpPrefix}_load_workflow_abilities`;
|
|
@@ -237763,13 +237818,13 @@ function checkWorkspaceAbilityBootstrap(projectDir, packageName, phpPrefix) {
|
|
|
237763
237818
|
}
|
|
237764
237819
|
function checkWorkspaceAbilityIndex(projectDir, abilities) {
|
|
237765
237820
|
const indexRelativePath = [
|
|
237766
|
-
|
|
237767
|
-
|
|
237768
|
-
].find((relativePath) => fs47.existsSync(
|
|
237821
|
+
path63.join("src", "abilities", "index.ts"),
|
|
237822
|
+
path63.join("src", "abilities", "index.js")
|
|
237823
|
+
].find((relativePath) => fs47.existsSync(path63.join(projectDir, relativePath)));
|
|
237769
237824
|
if (!indexRelativePath) {
|
|
237770
237825
|
return createDoctorCheck2("Abilities index", "fail", "Missing src/abilities/index.ts or src/abilities/index.js");
|
|
237771
237826
|
}
|
|
237772
|
-
const indexPath =
|
|
237827
|
+
const indexPath = path63.join(projectDir, indexRelativePath);
|
|
237773
237828
|
const source = fs47.readFileSync(indexPath, "utf8");
|
|
237774
237829
|
const missingExports = abilities.filter((ability) => {
|
|
237775
237830
|
const exportPattern = new RegExp(`^\\s*export\\s+(?:\\*\\s+from|\\{[^}]+\\}\\s+from)\\s+['"\`]\\./${escapeRegex2(ability.slug)}\\/client['"\`]`, "mu");
|
|
@@ -237781,9 +237836,9 @@ function getWorkspaceAiFeatureRequiredFiles(aiFeature) {
|
|
|
237781
237836
|
return Array.from(new Set([
|
|
237782
237837
|
aiFeature.aiSchemaFile,
|
|
237783
237838
|
aiFeature.apiFile,
|
|
237784
|
-
|
|
237785
|
-
|
|
237786
|
-
|
|
237839
|
+
path63.join(path63.dirname(aiFeature.typesFile), "api-schemas", "feature-request.schema.json"),
|
|
237840
|
+
path63.join(path63.dirname(aiFeature.typesFile), "api-schemas", "feature-response.schema.json"),
|
|
237841
|
+
path63.join(path63.dirname(aiFeature.typesFile), "api-schemas", "feature-result.schema.json"),
|
|
237787
237842
|
aiFeature.clientFile,
|
|
237788
237843
|
aiFeature.dataFile,
|
|
237789
237844
|
aiFeature.openApiFile,
|
|
@@ -237798,9 +237853,9 @@ function checkWorkspaceAiFeatureConfig(aiFeature) {
|
|
|
237798
237853
|
}
|
|
237799
237854
|
function checkWorkspaceAiFeatureBootstrap(projectDir, packageName, phpPrefix) {
|
|
237800
237855
|
const packageBaseName = packageName.split("/").pop() ?? packageName;
|
|
237801
|
-
const bootstrapPath =
|
|
237856
|
+
const bootstrapPath = path63.join(projectDir, `${packageBaseName}.php`);
|
|
237802
237857
|
if (!fs47.existsSync(bootstrapPath)) {
|
|
237803
|
-
return createDoctorCheck2("AI feature bootstrap", "fail", `Missing ${
|
|
237858
|
+
return createDoctorCheck2("AI feature bootstrap", "fail", `Missing ${path63.basename(bootstrapPath)}`);
|
|
237804
237859
|
}
|
|
237805
237860
|
const source = fs47.readFileSync(bootstrapPath, "utf8");
|
|
237806
237861
|
const registerFunctionName = `${phpPrefix}_register_ai_features`;
|
|
@@ -237810,14 +237865,14 @@ function checkWorkspaceAiFeatureBootstrap(projectDir, packageName, phpPrefix) {
|
|
|
237810
237865
|
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");
|
|
237811
237866
|
}
|
|
237812
237867
|
function getWorkspaceEditorPluginRequiredFiles(editorPlugin) {
|
|
237813
|
-
const editorPluginDir =
|
|
237814
|
-
const surfaceFile = editorPlugin.slot === "PluginSidebar" ?
|
|
237868
|
+
const editorPluginDir = path63.join("src", "editor-plugins", editorPlugin.slug);
|
|
237869
|
+
const surfaceFile = editorPlugin.slot === "PluginSidebar" ? path63.join(editorPluginDir, "Sidebar.tsx") : path63.join(editorPluginDir, "Surface.tsx");
|
|
237815
237870
|
return Array.from(new Set([
|
|
237816
237871
|
editorPlugin.file,
|
|
237817
237872
|
surfaceFile,
|
|
237818
|
-
|
|
237819
|
-
|
|
237820
|
-
|
|
237873
|
+
path63.join(editorPluginDir, "data.ts"),
|
|
237874
|
+
path63.join(editorPluginDir, "types.ts"),
|
|
237875
|
+
path63.join(editorPluginDir, "style.scss")
|
|
237821
237876
|
]));
|
|
237822
237877
|
}
|
|
237823
237878
|
function checkWorkspaceEditorPluginConfig(editorPlugin) {
|
|
@@ -237827,9 +237882,9 @@ function checkWorkspaceEditorPluginConfig(editorPlugin) {
|
|
|
237827
237882
|
}
|
|
237828
237883
|
function checkWorkspaceEditorPluginBootstrap(projectDir, packageName, phpPrefix) {
|
|
237829
237884
|
const packageBaseName = packageName.split("/").pop() ?? packageName;
|
|
237830
|
-
const bootstrapPath =
|
|
237885
|
+
const bootstrapPath = path63.join(projectDir, `${packageBaseName}.php`);
|
|
237831
237886
|
if (!fs47.existsSync(bootstrapPath)) {
|
|
237832
|
-
return createDoctorCheck2("Editor plugin bootstrap", "fail", `Missing ${
|
|
237887
|
+
return createDoctorCheck2("Editor plugin bootstrap", "fail", `Missing ${path63.basename(bootstrapPath)}`);
|
|
237833
237888
|
}
|
|
237834
237889
|
const source = fs47.readFileSync(bootstrapPath, "utf8");
|
|
237835
237890
|
const enqueueFunctionName = `${phpPrefix}_enqueue_editor_plugins_editor`;
|
|
@@ -237842,13 +237897,13 @@ function checkWorkspaceEditorPluginBootstrap(projectDir, packageName, phpPrefix)
|
|
|
237842
237897
|
}
|
|
237843
237898
|
function checkWorkspaceEditorPluginIndex(projectDir, editorPlugins) {
|
|
237844
237899
|
const indexRelativePath = [
|
|
237845
|
-
|
|
237846
|
-
|
|
237847
|
-
].find((relativePath) => fs47.existsSync(
|
|
237900
|
+
path63.join("src", "editor-plugins", "index.ts"),
|
|
237901
|
+
path63.join("src", "editor-plugins", "index.js")
|
|
237902
|
+
].find((relativePath) => fs47.existsSync(path63.join(projectDir, relativePath)));
|
|
237848
237903
|
if (!indexRelativePath) {
|
|
237849
237904
|
return createDoctorCheck2("Editor plugins index", "fail", "Missing src/editor-plugins/index.ts or src/editor-plugins/index.js");
|
|
237850
237905
|
}
|
|
237851
|
-
const indexPath =
|
|
237906
|
+
const indexPath = path63.join(projectDir, indexRelativePath);
|
|
237852
237907
|
const source = fs47.readFileSync(indexPath, "utf8");
|
|
237853
237908
|
const missingImports = editorPlugins.filter((editorPlugin) => {
|
|
237854
237909
|
const importPattern = new RegExp(`['"\`]\\./${escapeRegex2(editorPlugin.slug)}(?:/[^'"\`]*)?['"\`]`, "u");
|
|
@@ -237857,15 +237912,15 @@ function checkWorkspaceEditorPluginIndex(projectDir, editorPlugins) {
|
|
|
237857
237912
|
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(", ")}`);
|
|
237858
237913
|
}
|
|
237859
237914
|
function getWorkspaceAdminViewRequiredFiles(adminView) {
|
|
237860
|
-
const adminViewDir =
|
|
237915
|
+
const adminViewDir = path63.join("src", "admin-views", adminView.slug);
|
|
237861
237916
|
return Array.from(new Set([
|
|
237862
237917
|
adminView.file,
|
|
237863
237918
|
adminView.phpFile,
|
|
237864
|
-
|
|
237865
|
-
|
|
237866
|
-
|
|
237867
|
-
|
|
237868
|
-
|
|
237919
|
+
path63.join(adminViewDir, "Screen.tsx"),
|
|
237920
|
+
path63.join(adminViewDir, "config.ts"),
|
|
237921
|
+
path63.join(adminViewDir, "data.ts"),
|
|
237922
|
+
path63.join(adminViewDir, "style.scss"),
|
|
237923
|
+
path63.join(adminViewDir, "types.ts")
|
|
237869
237924
|
]));
|
|
237870
237925
|
}
|
|
237871
237926
|
function checkWorkspaceAdminViewConfig(adminView, inventory) {
|
|
@@ -237882,9 +237937,9 @@ function checkWorkspaceAdminViewConfig(adminView, inventory) {
|
|
|
237882
237937
|
}
|
|
237883
237938
|
function checkWorkspaceAdminViewBootstrap(projectDir, packageName, phpPrefix) {
|
|
237884
237939
|
const packageBaseName = packageName.split("/").pop() ?? packageName;
|
|
237885
|
-
const bootstrapPath =
|
|
237940
|
+
const bootstrapPath = path63.join(projectDir, `${packageBaseName}.php`);
|
|
237886
237941
|
if (!fs47.existsSync(bootstrapPath)) {
|
|
237887
|
-
return createDoctorCheck2("Admin view bootstrap", "fail", `Missing ${
|
|
237942
|
+
return createDoctorCheck2("Admin view bootstrap", "fail", `Missing ${path63.basename(bootstrapPath)}`);
|
|
237888
237943
|
}
|
|
237889
237944
|
const source = fs47.readFileSync(bootstrapPath, "utf8");
|
|
237890
237945
|
const loadFunctionName = `${phpPrefix}_load_admin_views`;
|
|
@@ -237895,13 +237950,13 @@ function checkWorkspaceAdminViewBootstrap(projectDir, packageName, phpPrefix) {
|
|
|
237895
237950
|
}
|
|
237896
237951
|
function checkWorkspaceAdminViewIndex(projectDir, adminViews) {
|
|
237897
237952
|
const indexRelativePath = [
|
|
237898
|
-
|
|
237899
|
-
|
|
237900
|
-
].find((relativePath) => fs47.existsSync(
|
|
237953
|
+
path63.join("src", "admin-views", "index.ts"),
|
|
237954
|
+
path63.join("src", "admin-views", "index.js")
|
|
237955
|
+
].find((relativePath) => fs47.existsSync(path63.join(projectDir, relativePath)));
|
|
237901
237956
|
if (!indexRelativePath) {
|
|
237902
237957
|
return createDoctorCheck2("Admin views index", "fail", "Missing src/admin-views/index.ts or src/admin-views/index.js");
|
|
237903
237958
|
}
|
|
237904
|
-
const indexPath =
|
|
237959
|
+
const indexPath = path63.join(projectDir, indexRelativePath);
|
|
237905
237960
|
const source = fs47.readFileSync(indexPath, "utf8");
|
|
237906
237961
|
const missingImports = adminViews.filter((adminView) => {
|
|
237907
237962
|
const importPattern = new RegExp(`['"\`]\\./${escapeRegex2(adminView.slug)}(?:/[^'"\`]*)?['"\`]`, "u");
|
|
@@ -237910,7 +237965,7 @@ function checkWorkspaceAdminViewIndex(projectDir, adminViews) {
|
|
|
237910
237965
|
return createDoctorCheck2("Admin views index", missingImports.length === 0 ? "pass" : "fail", missingImports.length === 0 ? "Admin view registrations are aggregated" : `Missing admin view imports for: ${missingImports.map((entry) => entry.slug).join(", ")}`);
|
|
237911
237966
|
}
|
|
237912
237967
|
function checkWorkspaceAdminViewPhp(projectDir, adminView) {
|
|
237913
|
-
const phpPath =
|
|
237968
|
+
const phpPath = path63.join(projectDir, adminView.phpFile);
|
|
237914
237969
|
if (!fs47.existsSync(phpPath)) {
|
|
237915
237970
|
return createDoctorCheck2(`Admin view PHP ${adminView.slug}`, "fail", `Missing ${adminView.phpFile}`);
|
|
237916
237971
|
}
|
|
@@ -237924,9 +237979,9 @@ function checkWorkspaceAdminViewPhp(projectDir, adminView) {
|
|
|
237924
237979
|
return createDoctorCheck2(`Admin view PHP ${adminView.slug}`, hasAdminMenu && hasAdminEnqueue && hasScript && hasAsset && hasStyle && hasComponentsStyleDependency ? "pass" : "fail", hasAdminMenu && hasAdminEnqueue && hasScript && hasAsset && hasStyle && hasComponentsStyleDependency ? "Admin menu, script, style, and wp-components style dependency are wired" : "Missing admin menu, enqueue hook, build/admin-views asset reference, or wp-components style dependency");
|
|
237925
237980
|
}
|
|
237926
237981
|
function checkVariationEntrypoint(projectDir, blockSlug) {
|
|
237927
|
-
const entryPath =
|
|
237982
|
+
const entryPath = path63.join(projectDir, "src", "blocks", blockSlug, "index.tsx");
|
|
237928
237983
|
if (!fs47.existsSync(entryPath)) {
|
|
237929
|
-
return createDoctorCheck2(`Variation entrypoint ${blockSlug}`, "fail", `Missing ${
|
|
237984
|
+
return createDoctorCheck2(`Variation entrypoint ${blockSlug}`, "fail", `Missing ${path63.relative(projectDir, entryPath)}`);
|
|
237930
237985
|
}
|
|
237931
237986
|
const source = fs47.readFileSync(entryPath, "utf8");
|
|
237932
237987
|
const hasImport = hasUncommentedPattern2(source, WORKSPACE_VARIATIONS_IMPORT_PATTERN);
|
|
@@ -237934,9 +237989,9 @@ function checkVariationEntrypoint(projectDir, blockSlug) {
|
|
|
237934
237989
|
return createDoctorCheck2(`Variation entrypoint ${blockSlug}`, hasImport && hasCall ? "pass" : "fail", hasImport && hasCall ? "Variations registration hook is present" : "Missing ./variations import or registerWorkspaceVariations() call");
|
|
237935
237990
|
}
|
|
237936
237991
|
function checkBlockStyleEntrypoint(projectDir, blockSlug) {
|
|
237937
|
-
const entryPath =
|
|
237992
|
+
const entryPath = path63.join(projectDir, "src", "blocks", blockSlug, "index.tsx");
|
|
237938
237993
|
if (!fs47.existsSync(entryPath)) {
|
|
237939
|
-
return createDoctorCheck2(`Block style entrypoint ${blockSlug}`, "fail", `Missing ${
|
|
237994
|
+
return createDoctorCheck2(`Block style entrypoint ${blockSlug}`, "fail", `Missing ${path63.relative(projectDir, entryPath)}`);
|
|
237940
237995
|
}
|
|
237941
237996
|
const source = fs47.readFileSync(entryPath, "utf8");
|
|
237942
237997
|
const hasImport = hasUncommentedPattern2(source, WORKSPACE_BLOCK_STYLES_IMPORT_PATTERN);
|
|
@@ -237944,9 +237999,9 @@ function checkBlockStyleEntrypoint(projectDir, blockSlug) {
|
|
|
237944
237999
|
return createDoctorCheck2(`Block style entrypoint ${blockSlug}`, hasImport && hasCall ? "pass" : "fail", hasImport && hasCall ? "Block style registration hook is present" : "Missing ./styles import or registerWorkspaceBlockStyles() call");
|
|
237945
238000
|
}
|
|
237946
238001
|
function checkBlockTransformEntrypoint(projectDir, blockSlug) {
|
|
237947
|
-
const entryPath =
|
|
238002
|
+
const entryPath = path63.join(projectDir, "src", "blocks", blockSlug, "index.tsx");
|
|
237948
238003
|
if (!fs47.existsSync(entryPath)) {
|
|
237949
|
-
return createDoctorCheck2(`Block transform entrypoint ${blockSlug}`, "fail", `Missing ${
|
|
238004
|
+
return createDoctorCheck2(`Block transform entrypoint ${blockSlug}`, "fail", `Missing ${path63.relative(projectDir, entryPath)}`);
|
|
237950
238005
|
}
|
|
237951
238006
|
const source = fs47.readFileSync(entryPath, "utf8");
|
|
237952
238007
|
const hasImport = hasUncommentedPattern2(source, WORKSPACE_BLOCK_TRANSFORMS_IMPORT_PATTERN);
|
|
@@ -237966,8 +238021,8 @@ function checkBlockTransformConfig(workspace, transform2) {
|
|
|
237966
238021
|
}
|
|
237967
238022
|
function checkMigrationWorkspaceHint(workspace, packageJson) {
|
|
237968
238023
|
const hasMigrationScript = typeof packageJson.scripts?.["migration:doctor"] === "string";
|
|
237969
|
-
const migrationConfigRelativePath =
|
|
237970
|
-
const hasMigrationConfig = fs47.existsSync(
|
|
238024
|
+
const migrationConfigRelativePath = path63.join("src", "migrations", "config.ts");
|
|
238025
|
+
const hasMigrationConfig = fs47.existsSync(path63.join(workspace.projectDir, migrationConfigRelativePath));
|
|
237971
238026
|
if (!hasMigrationScript && !hasMigrationConfig) {
|
|
237972
238027
|
return null;
|
|
237973
238028
|
}
|
|
@@ -238037,7 +238092,7 @@ function getWorkspaceDoctorChecks(cwd) {
|
|
|
238037
238092
|
}
|
|
238038
238093
|
for (const blockSlug of blockStyleTargetBlocks) {
|
|
238039
238094
|
checks3.push(checkExistingFiles(workspace.projectDir, `Block style registry ${blockSlug}`, [
|
|
238040
|
-
|
|
238095
|
+
path63.join("src", "blocks", blockSlug, "styles", "index.ts")
|
|
238041
238096
|
]));
|
|
238042
238097
|
checks3.push(checkBlockStyleEntrypoint(workspace.projectDir, blockSlug));
|
|
238043
238098
|
}
|
|
@@ -238053,11 +238108,11 @@ function getWorkspaceDoctorChecks(cwd) {
|
|
|
238053
238108
|
}
|
|
238054
238109
|
for (const blockSlug of blockTransformTargetBlocks) {
|
|
238055
238110
|
checks3.push(checkExistingFiles(workspace.projectDir, `Block transform registry ${blockSlug}`, [
|
|
238056
|
-
|
|
238111
|
+
path63.join("src", "blocks", blockSlug, "transforms", "index.ts")
|
|
238057
238112
|
]));
|
|
238058
238113
|
checks3.push(checkBlockTransformEntrypoint(workspace.projectDir, blockSlug));
|
|
238059
238114
|
}
|
|
238060
|
-
const shouldCheckPatternBootstrap = inventory.patterns.length > 0 || fs47.existsSync(
|
|
238115
|
+
const shouldCheckPatternBootstrap = inventory.patterns.length > 0 || fs47.existsSync(path63.join(workspace.projectDir, "src", "patterns"));
|
|
238061
238116
|
if (shouldCheckPatternBootstrap) {
|
|
238062
238117
|
checks3.push(checkWorkspacePatternBootstrap(workspace.projectDir, workspace.packageName));
|
|
238063
238118
|
}
|
|
@@ -238225,13 +238280,13 @@ __export(exports_cli_init, {
|
|
|
238225
238280
|
});
|
|
238226
238281
|
import fs48 from "fs";
|
|
238227
238282
|
import { promises as fsp25 } from "fs";
|
|
238228
|
-
import
|
|
238283
|
+
import path64 from "path";
|
|
238229
238284
|
import { analyzeSourceTypes } from "@wp-typia/block-runtime/metadata-parser";
|
|
238230
238285
|
function normalizeRelativePath2(value2) {
|
|
238231
238286
|
return value2.replace(/\\/gu, "/");
|
|
238232
238287
|
}
|
|
238233
238288
|
function readProjectPackageJson(projectDir) {
|
|
238234
|
-
const packageJsonPath =
|
|
238289
|
+
const packageJsonPath = path64.join(projectDir, "package.json");
|
|
238235
238290
|
if (!fs48.existsSync(packageJsonPath)) {
|
|
238236
238291
|
return null;
|
|
238237
238292
|
}
|
|
@@ -238247,13 +238302,13 @@ function inferInitPackageManager(projectDir, packageJson) {
|
|
|
238247
238302
|
if (packageJson?.packageManager) {
|
|
238248
238303
|
return parseWorkspacePackageManagerId(packageJson.packageManager);
|
|
238249
238304
|
}
|
|
238250
|
-
if (fs48.existsSync(
|
|
238305
|
+
if (fs48.existsSync(path64.join(projectDir, "bun.lock")) || fs48.existsSync(path64.join(projectDir, "bun.lockb"))) {
|
|
238251
238306
|
return "bun";
|
|
238252
238307
|
}
|
|
238253
|
-
if (fs48.existsSync(
|
|
238308
|
+
if (fs48.existsSync(path64.join(projectDir, "pnpm-lock.yaml"))) {
|
|
238254
238309
|
return "pnpm";
|
|
238255
238310
|
}
|
|
238256
|
-
if (fs48.existsSync(
|
|
238311
|
+
if (fs48.existsSync(path64.join(projectDir, "yarn.lock")) || fs48.existsSync(path64.join(projectDir, ".yarnrc.yml"))) {
|
|
238257
238312
|
return "yarn";
|
|
238258
238313
|
}
|
|
238259
238314
|
return "npm";
|
|
@@ -238337,13 +238392,13 @@ function buildPackageManagerFieldChange(packageJson, packageManager, options = {
|
|
|
238337
238392
|
};
|
|
238338
238393
|
}
|
|
238339
238394
|
function buildGeneratedArtifactPaths(blockJsonFile, manifestFile) {
|
|
238340
|
-
const manifestDir =
|
|
238395
|
+
const manifestDir = path64.dirname(manifestFile);
|
|
238341
238396
|
const artifactPaths = [
|
|
238342
238397
|
blockJsonFile,
|
|
238343
238398
|
manifestFile,
|
|
238344
|
-
|
|
238345
|
-
|
|
238346
|
-
|
|
238399
|
+
path64.join(manifestDir, "typia.schema.json"),
|
|
238400
|
+
path64.join(manifestDir, "typia-validator.php"),
|
|
238401
|
+
path64.join(manifestDir, "typia.openapi.json")
|
|
238347
238402
|
];
|
|
238348
238403
|
return Array.from(new Set(artifactPaths.map((filePath) => normalizeRelativePath2(filePath))));
|
|
238349
238404
|
}
|
|
@@ -238364,7 +238419,7 @@ function isObjectLikeSourceType(projectDir, typesFile, sourceTypeName) {
|
|
|
238364
238419
|
return analyzedTypes[sourceTypeName]?.kind === "object";
|
|
238365
238420
|
}
|
|
238366
238421
|
function inferRetrofitAttributeTypeName(projectDir, block) {
|
|
238367
|
-
const typesPath =
|
|
238422
|
+
const typesPath = path64.join(projectDir, block.typesFile);
|
|
238368
238423
|
const typesSource = fs48.readFileSync(typesPath, "utf8");
|
|
238369
238424
|
const blockNameSegments = block.blockName.split("/");
|
|
238370
238425
|
const slug = blockNameSegments[blockNameSegments.length - 1] ?? block.key;
|
|
@@ -238670,10 +238725,10 @@ function hasExistingWpTypiaProjectSurface(projectDir, packageJson) {
|
|
|
238670
238725
|
const scripts = packageJson?.scripts ?? {};
|
|
238671
238726
|
const hasSyncSurface = typeof scripts.sync === "string" || typeof scripts["sync-types"] === "string";
|
|
238672
238727
|
const hasHelperFiles = [
|
|
238673
|
-
|
|
238674
|
-
|
|
238675
|
-
|
|
238676
|
-
].every((relativePath) => fs48.existsSync(
|
|
238728
|
+
path64.join("scripts", "block-config.ts"),
|
|
238729
|
+
path64.join("scripts", "sync-project.ts"),
|
|
238730
|
+
path64.join("scripts", "sync-types-to-block-json.ts")
|
|
238731
|
+
].every((relativePath) => fs48.existsSync(path64.join(projectDir, relativePath)));
|
|
238677
238732
|
const hasRuntimeDeps = typeof getExistingDependencyVersion(packageJson, "@wp-typia/block-runtime") === "string" && typeof getExistingDependencyVersion(packageJson, "@wp-typia/block-types") === "string";
|
|
238678
238733
|
return hasSyncSurface && hasHelperFiles && hasRuntimeDeps;
|
|
238679
238734
|
}
|
|
@@ -238683,17 +238738,17 @@ function buildPlannedFiles(projectDir, layoutKind) {
|
|
|
238683
238738
|
}
|
|
238684
238739
|
return [
|
|
238685
238740
|
{
|
|
238686
|
-
action: fs48.existsSync(
|
|
238741
|
+
action: fs48.existsSync(path64.join(projectDir, "scripts", "block-config.ts")) ? "update" : "add",
|
|
238687
238742
|
path: "scripts/block-config.ts",
|
|
238688
238743
|
purpose: "Declare the current retrofit block targets so sync-types can regenerate metadata from the existing TypeScript source of truth."
|
|
238689
238744
|
},
|
|
238690
238745
|
{
|
|
238691
|
-
action: fs48.existsSync(
|
|
238746
|
+
action: fs48.existsSync(path64.join(projectDir, "scripts", "sync-types-to-block-json.ts")) ? "update" : "add",
|
|
238692
238747
|
path: "scripts/sync-types-to-block-json.ts",
|
|
238693
238748
|
purpose: "Generate block.json and Typia metadata artifacts from the current TypeScript source of truth."
|
|
238694
238749
|
},
|
|
238695
238750
|
{
|
|
238696
|
-
action: fs48.existsSync(
|
|
238751
|
+
action: fs48.existsSync(path64.join(projectDir, "scripts", "sync-project.ts")) ? "update" : "add",
|
|
238697
238752
|
path: "scripts/sync-project.ts",
|
|
238698
238753
|
purpose: "Provide one shared sync entrypoint that can grow into sync-rest or workspace-aware refresh steps later."
|
|
238699
238754
|
}
|
|
@@ -238841,13 +238896,13 @@ function buildProjectPackageJsonSource(packageJson) {
|
|
|
238841
238896
|
}
|
|
238842
238897
|
function buildRetrofitHelperFiles(blockTargets) {
|
|
238843
238898
|
return {
|
|
238844
|
-
[
|
|
238845
|
-
[
|
|
238846
|
-
[
|
|
238899
|
+
[path64.join("scripts", "block-config.ts")]: buildRetrofitBlockConfigSource(blockTargets),
|
|
238900
|
+
[path64.join("scripts", "sync-project.ts")]: buildRetrofitSyncProjectScriptSource(),
|
|
238901
|
+
[path64.join("scripts", "sync-types-to-block-json.ts")]: buildRetrofitSyncTypesScriptSource()
|
|
238847
238902
|
};
|
|
238848
238903
|
}
|
|
238849
238904
|
async function createRetrofitMutationSnapshot(projectDir, filePaths) {
|
|
238850
|
-
const scriptsDir =
|
|
238905
|
+
const scriptsDir = path64.join(projectDir, "scripts");
|
|
238851
238906
|
const scriptsDirExisted = fs48.existsSync(scriptsDir);
|
|
238852
238907
|
const fileSources = await snapshotWorkspaceFiles(filePaths);
|
|
238853
238908
|
const targetPaths = fileSources.filter((entry) => entry.source === null).map((entry) => entry.filePath);
|
|
@@ -238862,11 +238917,11 @@ async function createRetrofitMutationSnapshot(projectDir, filePaths) {
|
|
|
238862
238917
|
}
|
|
238863
238918
|
async function writeRetrofitFiles(options) {
|
|
238864
238919
|
const helperFiles = buildRetrofitHelperFiles(options.blockTargets);
|
|
238865
|
-
const scriptsDir =
|
|
238920
|
+
const scriptsDir = path64.join(options.projectDir, "scripts");
|
|
238866
238921
|
await fsp25.mkdir(scriptsDir, { recursive: true });
|
|
238867
|
-
await fsp25.writeFile(
|
|
238922
|
+
await fsp25.writeFile(path64.join(options.projectDir, "package.json"), buildProjectPackageJsonSource(options.packageJson), "utf8");
|
|
238868
238923
|
for (const [relativePath, source] of Object.entries(helperFiles)) {
|
|
238869
|
-
await fsp25.writeFile(
|
|
238924
|
+
await fsp25.writeFile(path64.join(options.projectDir, relativePath), source, "utf8");
|
|
238870
238925
|
}
|
|
238871
238926
|
}
|
|
238872
238927
|
function buildApplyFailureError(error48) {
|
|
@@ -238874,7 +238929,7 @@ function buildApplyFailureError(error48) {
|
|
|
238874
238929
|
return createCliDiagnosticCodeError(CLI_DIAGNOSTIC_CODES.INVALID_ARGUMENT, `Unable to apply the retrofit init plan safely. The command restored the previous package.json/helper-file snapshot. ${message}`, error48 instanceof Error ? { cause: error48 } : undefined);
|
|
238875
238930
|
}
|
|
238876
238931
|
function getInitPlan(projectDir, options = {}) {
|
|
238877
|
-
const resolvedProjectDir =
|
|
238932
|
+
const resolvedProjectDir = path64.resolve(projectDir);
|
|
238878
238933
|
const packageJson = readProjectPackageJson(resolvedProjectDir);
|
|
238879
238934
|
const packageManager = resolveInitPackageManager(resolvedProjectDir, packageJson, options.packageManager);
|
|
238880
238935
|
const workspace = tryResolveWorkspaceProject(resolvedProjectDir);
|
|
@@ -238910,7 +238965,7 @@ function getInitPlan(projectDir, options = {}) {
|
|
|
238910
238965
|
status: "already-initialized"
|
|
238911
238966
|
});
|
|
238912
238967
|
}
|
|
238913
|
-
const projectName = typeof packageJson?.name === "string" && packageJson.name.length > 0 ? packageJson.name :
|
|
238968
|
+
const projectName = typeof packageJson?.name === "string" && packageJson.name.length > 0 ? packageJson.name : path64.basename(resolvedProjectDir);
|
|
238914
238969
|
const layout = buildLayoutDetails(resolvedProjectDir);
|
|
238915
238970
|
const dependencyChanges = buildDependencyChanges(packageJson);
|
|
238916
238971
|
const scriptChanges = buildScriptChanges(packageJson, packageManager);
|
|
@@ -238976,8 +239031,8 @@ async function applyInitPlan(projectDir, options = {}) {
|
|
|
238976
239031
|
});
|
|
238977
239032
|
const helperFiles = buildRetrofitHelperFiles(previewPlan.blockTargets);
|
|
238978
239033
|
const filePaths = [
|
|
238979
|
-
|
|
238980
|
-
...Object.keys(helperFiles).map((relativePath) =>
|
|
239034
|
+
path64.join(previewPlan.projectDir, "package.json"),
|
|
239035
|
+
...Object.keys(helperFiles).map((relativePath) => path64.join(previewPlan.projectDir, relativePath))
|
|
238981
239036
|
];
|
|
238982
239037
|
const mutationSnapshot = await createRetrofitMutationSnapshot(previewPlan.projectDir, filePaths);
|
|
238983
239038
|
try {
|
|
@@ -239041,18 +239096,18 @@ __export(exports_cli_scaffold, {
|
|
|
239041
239096
|
});
|
|
239042
239097
|
import fs49 from "fs";
|
|
239043
239098
|
import { promises as fsp26 } from "fs";
|
|
239044
|
-
import
|
|
239099
|
+
import path65 from "path";
|
|
239045
239100
|
async function listRelativeProjectFiles(rootDir) {
|
|
239046
239101
|
const relativeFiles = [];
|
|
239047
239102
|
async function visit2(currentDir) {
|
|
239048
239103
|
const entries = await fsp26.readdir(currentDir, { withFileTypes: true });
|
|
239049
239104
|
for (const entry of entries) {
|
|
239050
|
-
const absolutePath =
|
|
239105
|
+
const absolutePath = path65.join(currentDir, entry.name);
|
|
239051
239106
|
if (entry.isDirectory()) {
|
|
239052
239107
|
await visit2(absolutePath);
|
|
239053
239108
|
continue;
|
|
239054
239109
|
}
|
|
239055
|
-
relativeFiles.push(
|
|
239110
|
+
relativeFiles.push(path65.relative(rootDir, absolutePath).replace(path65.sep === "\\" ? /\\/gu : /\//gu, "/"));
|
|
239056
239111
|
}
|
|
239057
239112
|
}
|
|
239058
239113
|
await visit2(rootDir);
|
|
@@ -239090,7 +239145,7 @@ async function buildScaffoldDryRunPlan({
|
|
|
239090
239145
|
}) {
|
|
239091
239146
|
await assertDryRunTargetDirectoryReady(projectDir, allowExistingDir);
|
|
239092
239147
|
const { path: tempRoot, cleanup } = await createManagedTempRoot("wp-typia-scaffold-plan-");
|
|
239093
|
-
const previewProjectDir =
|
|
239148
|
+
const previewProjectDir = path65.join(tempRoot, "preview-project");
|
|
239094
239149
|
try {
|
|
239095
239150
|
const result = await scaffoldProject({
|
|
239096
239151
|
allowExistingDir: false,
|
|
@@ -239130,14 +239185,14 @@ function validateCreateProjectInput(projectInput) {
|
|
|
239130
239185
|
if (normalizedProjectInput.length === 0) {
|
|
239131
239186
|
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).");
|
|
239132
239187
|
}
|
|
239133
|
-
const normalizedProjectPath =
|
|
239188
|
+
const normalizedProjectPath = path65.normalize(normalizedProjectInput).replace(/[\\/]+$/u, "") || path65.normalize(normalizedProjectInput);
|
|
239134
239189
|
if (normalizedProjectPath === "." || normalizedProjectPath === "..") {
|
|
239135
239190
|
throw new Error("`wp-typia create` requires a new project directory. Use an explicit child directory instead of `.` or `..`.");
|
|
239136
239191
|
}
|
|
239137
239192
|
}
|
|
239138
239193
|
function collectProjectDirectoryWarnings(projectDir) {
|
|
239139
239194
|
const warnings = [];
|
|
239140
|
-
const projectName =
|
|
239195
|
+
const projectName = path65.basename(projectDir);
|
|
239141
239196
|
if (/\s/u.test(projectName)) {
|
|
239142
239197
|
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.`);
|
|
239143
239198
|
}
|
|
@@ -239292,7 +239347,7 @@ function getNextSteps({
|
|
|
239292
239347
|
noInstall,
|
|
239293
239348
|
templateId
|
|
239294
239349
|
}) {
|
|
239295
|
-
const cdTarget =
|
|
239350
|
+
const cdTarget = path65.isAbsolute(projectInput) ? projectDir : projectInput;
|
|
239296
239351
|
const steps = [`cd ${quoteShellValue(cdTarget)}`];
|
|
239297
239352
|
if (noInstall) {
|
|
239298
239353
|
steps.push(formatInstallCommand(packageManager));
|
|
@@ -239440,8 +239495,8 @@ async function runScaffoldFlow({
|
|
|
239440
239495
|
select: selectWithMigrationUi,
|
|
239441
239496
|
yes
|
|
239442
239497
|
});
|
|
239443
|
-
const projectDir =
|
|
239444
|
-
const projectName =
|
|
239498
|
+
const projectDir = path65.resolve(cwd, projectInput);
|
|
239499
|
+
const projectName = path65.basename(projectDir);
|
|
239445
239500
|
const answers = await collectScaffoldAnswers({
|
|
239446
239501
|
dataStorageMode: resolvedDataStorage,
|
|
239447
239502
|
namespace,
|
|
@@ -239504,7 +239559,7 @@ async function runScaffoldFlow({
|
|
|
239504
239559
|
let availableScripts;
|
|
239505
239560
|
if (!dryRun) {
|
|
239506
239561
|
try {
|
|
239507
|
-
const parsedPackageJson = JSON.parse(fs49.readFileSync(
|
|
239562
|
+
const parsedPackageJson = JSON.parse(fs49.readFileSync(path65.join(projectDir, "package.json"), "utf8"));
|
|
239508
239563
|
const scripts = parsedPackageJson.scripts && typeof parsedPackageJson.scripts === "object" && !Array.isArray(parsedPackageJson.scripts) ? parsedPackageJson.scripts : {};
|
|
239509
239564
|
availableScripts = Object.entries(scripts).filter(([, value2]) => typeof value2 === "string").map(([scriptName]) => scriptName);
|
|
239510
239565
|
} catch {
|
|
@@ -292421,6 +292476,12 @@ var MIGRATE_OPTION_METADATA = {
|
|
|
292421
292476
|
type: "string"
|
|
292422
292477
|
}
|
|
292423
292478
|
};
|
|
292479
|
+
var MCP_OPTION_METADATA = {
|
|
292480
|
+
"output-dir": {
|
|
292481
|
+
description: "Output directory for generated MCP metadata.",
|
|
292482
|
+
type: "string"
|
|
292483
|
+
}
|
|
292484
|
+
};
|
|
292424
292485
|
var SYNC_OPTION_METADATA = {
|
|
292425
292486
|
check: {
|
|
292426
292487
|
argumentKind: "flag",
|
|
@@ -292458,10 +292519,6 @@ var GLOBAL_OPTION_METADATA = {
|
|
|
292458
292519
|
id: {
|
|
292459
292520
|
description: "Template id for top-level `templates inspect` convenience.",
|
|
292460
292521
|
type: "string"
|
|
292461
|
-
},
|
|
292462
|
-
"output-dir": {
|
|
292463
|
-
description: "Output directory for generated MCP metadata.",
|
|
292464
|
-
type: "string"
|
|
292465
292522
|
}
|
|
292466
292523
|
};
|
|
292467
292524
|
var COMMAND_OPTION_METADATA_BY_GROUP = {
|
|
@@ -292471,6 +292528,7 @@ var COMMAND_OPTION_METADATA_BY_GROUP = {
|
|
|
292471
292528
|
global: GLOBAL_OPTION_METADATA,
|
|
292472
292529
|
init: INIT_OPTION_METADATA,
|
|
292473
292530
|
migrate: MIGRATE_OPTION_METADATA,
|
|
292531
|
+
mcp: MCP_OPTION_METADATA,
|
|
292474
292532
|
sync: SYNC_OPTION_METADATA,
|
|
292475
292533
|
templates: TEMPLATES_OPTION_METADATA
|
|
292476
292534
|
};
|
|
@@ -292547,13 +292605,17 @@ function resolveCommandOptionValues(metadata2, options) {
|
|
|
292547
292605
|
|
|
292548
292606
|
// src/cli-diagnostic-output.ts
|
|
292549
292607
|
init_cli_diagnostics();
|
|
292608
|
+
function writeStructuredCliJsonToStderr(payload) {
|
|
292609
|
+
process.stderr.write(`${JSON.stringify(payload, null, 2)}
|
|
292610
|
+
`);
|
|
292611
|
+
}
|
|
292550
292612
|
function prefersStructuredCliOutput(args) {
|
|
292551
292613
|
return args.formatExplicit && args.format !== "toon" || Boolean(args.agent) || Boolean(args.context?.store?.isAIAgent);
|
|
292552
292614
|
}
|
|
292553
292615
|
function emitCliDiagnosticFailure(args, options) {
|
|
292554
292616
|
const diagnostic = createCliCommandError(options);
|
|
292555
292617
|
if (prefersStructuredCliOutput(args)) {
|
|
292556
|
-
|
|
292618
|
+
writeStructuredCliJsonToStderr({
|
|
292557
292619
|
...options.extraOutput ?? {},
|
|
292558
292620
|
error: serializeCliDiagnosticError(diagnostic),
|
|
292559
292621
|
ok: false
|
|
@@ -292603,6 +292665,24 @@ init_cli_diagnostics();
|
|
|
292603
292665
|
|
|
292604
292666
|
// src/add-kind-registry.ts
|
|
292605
292667
|
init_cli_diagnostics();
|
|
292668
|
+
|
|
292669
|
+
// src/add-kind-ids.ts
|
|
292670
|
+
var ADD_KIND_IDS = [
|
|
292671
|
+
"admin-view",
|
|
292672
|
+
"block",
|
|
292673
|
+
"variation",
|
|
292674
|
+
"style",
|
|
292675
|
+
"transform",
|
|
292676
|
+
"pattern",
|
|
292677
|
+
"binding-source",
|
|
292678
|
+
"rest-resource",
|
|
292679
|
+
"ability",
|
|
292680
|
+
"ai-feature",
|
|
292681
|
+
"hooked-block",
|
|
292682
|
+
"editor-plugin"
|
|
292683
|
+
];
|
|
292684
|
+
|
|
292685
|
+
// src/add-kind-registry.ts
|
|
292606
292686
|
var BLOCK_VISIBLE_FIELD_ORDER = [
|
|
292607
292687
|
"kind",
|
|
292608
292688
|
"name",
|
|
@@ -292612,6 +292692,54 @@ var BLOCK_VISIBLE_FIELD_ORDER = [
|
|
|
292612
292692
|
"data-storage",
|
|
292613
292693
|
"persistence-policy"
|
|
292614
292694
|
];
|
|
292695
|
+
var NAME_ONLY_VISIBLE_FIELDS = [
|
|
292696
|
+
"kind",
|
|
292697
|
+
"name"
|
|
292698
|
+
];
|
|
292699
|
+
var NAME_SOURCE_VISIBLE_FIELDS = [
|
|
292700
|
+
"kind",
|
|
292701
|
+
"name",
|
|
292702
|
+
"source"
|
|
292703
|
+
];
|
|
292704
|
+
var NAME_BLOCK_ATTRIBUTE_VISIBLE_FIELDS = [
|
|
292705
|
+
"kind",
|
|
292706
|
+
"name",
|
|
292707
|
+
"block",
|
|
292708
|
+
"attribute"
|
|
292709
|
+
];
|
|
292710
|
+
var NAME_BLOCK_VISIBLE_FIELDS = [
|
|
292711
|
+
"kind",
|
|
292712
|
+
"name",
|
|
292713
|
+
"block"
|
|
292714
|
+
];
|
|
292715
|
+
var NAME_SLOT_VISIBLE_FIELDS = [
|
|
292716
|
+
"kind",
|
|
292717
|
+
"name",
|
|
292718
|
+
"slot"
|
|
292719
|
+
];
|
|
292720
|
+
var NAME_ANCHOR_POSITION_VISIBLE_FIELDS = [
|
|
292721
|
+
"kind",
|
|
292722
|
+
"name",
|
|
292723
|
+
"anchor",
|
|
292724
|
+
"position"
|
|
292725
|
+
];
|
|
292726
|
+
var NAME_FROM_TO_VISIBLE_FIELDS = [
|
|
292727
|
+
"kind",
|
|
292728
|
+
"name",
|
|
292729
|
+
"from",
|
|
292730
|
+
"to"
|
|
292731
|
+
];
|
|
292732
|
+
var NAME_NAMESPACE_METHODS_VISIBLE_FIELDS = [
|
|
292733
|
+
"kind",
|
|
292734
|
+
"name",
|
|
292735
|
+
"namespace",
|
|
292736
|
+
"methods"
|
|
292737
|
+
];
|
|
292738
|
+
var NAME_NAMESPACE_VISIBLE_FIELDS = [
|
|
292739
|
+
"kind",
|
|
292740
|
+
"name",
|
|
292741
|
+
"namespace"
|
|
292742
|
+
];
|
|
292615
292743
|
function readOptionalStringFlag(flags2, name2) {
|
|
292616
292744
|
const value2 = flags2[name2];
|
|
292617
292745
|
if (value2 === undefined || value2 === null) {
|
|
@@ -292622,6 +292750,21 @@ function readOptionalStringFlag(flags2, name2) {
|
|
|
292622
292750
|
}
|
|
292623
292751
|
return value2;
|
|
292624
292752
|
}
|
|
292753
|
+
function requireStringFlag(flags2, name2, message) {
|
|
292754
|
+
const value2 = readOptionalStringFlag(flags2, name2);
|
|
292755
|
+
if (!value2) {
|
|
292756
|
+
throw createCliDiagnosticCodeError(CLI_DIAGNOSTIC_CODES.MISSING_ARGUMENT, message);
|
|
292757
|
+
}
|
|
292758
|
+
return value2;
|
|
292759
|
+
}
|
|
292760
|
+
function readOptionalPairedStringFlags(flags2, leftName, rightName, message) {
|
|
292761
|
+
const leftValue = readOptionalStringFlag(flags2, leftName);
|
|
292762
|
+
const rightValue = readOptionalStringFlag(flags2, rightName);
|
|
292763
|
+
if (Boolean(leftValue) !== Boolean(rightValue)) {
|
|
292764
|
+
throw createCliDiagnosticCodeError(CLI_DIAGNOSTIC_CODES.MISSING_ARGUMENT, message);
|
|
292765
|
+
}
|
|
292766
|
+
return [leftValue, rightValue];
|
|
292767
|
+
}
|
|
292625
292768
|
function requireAddKindName(context, message) {
|
|
292626
292769
|
if (!context.name) {
|
|
292627
292770
|
throw createCliDiagnosticCodeError(CLI_DIAGNOSTIC_CODES.MISSING_ARGUMENT, message);
|
|
@@ -292645,6 +292788,15 @@ function toExternalLayerPromptOptions(options) {
|
|
|
292645
292788
|
function defineAddKindRegistryEntry(entry) {
|
|
292646
292789
|
return entry;
|
|
292647
292790
|
}
|
|
292791
|
+
function createNamedExecutionPlan(context, options) {
|
|
292792
|
+
const name2 = options.name ?? requireAddKindName(context, options.missingNameMessage);
|
|
292793
|
+
return {
|
|
292794
|
+
execute: (cwd) => options.execute({ cwd, name: name2 }),
|
|
292795
|
+
getValues: options.getValues,
|
|
292796
|
+
...options.getWarnings ? { getWarnings: options.getWarnings } : {},
|
|
292797
|
+
...options.warnLine ? { warnLine: options.warnLine } : {}
|
|
292798
|
+
};
|
|
292799
|
+
}
|
|
292648
292800
|
function isAddPersistenceTemplate(template) {
|
|
292649
292801
|
return template === "persistence" || template === "compound";
|
|
292650
292802
|
}
|
|
@@ -292667,22 +292819,24 @@ var ADD_KIND_REGISTRY = {
|
|
|
292667
292819
|
async prepareExecution(context) {
|
|
292668
292820
|
const name2 = requireAddKindName(context, "`wp-typia add admin-view` requires <name>. Usage: wp-typia add admin-view <name> [--source <rest-resource:slug|core-data:kind/name>].");
|
|
292669
292821
|
const source = readOptionalStringFlag(context.flags, "source");
|
|
292670
|
-
return {
|
|
292671
|
-
execute: (cwd) => context.addRuntime.runAddAdminViewCommand({
|
|
292672
|
-
adminViewName:
|
|
292822
|
+
return createNamedExecutionPlan(context, {
|
|
292823
|
+
execute: ({ cwd, name: name3 }) => context.addRuntime.runAddAdminViewCommand({
|
|
292824
|
+
adminViewName: name3,
|
|
292673
292825
|
cwd,
|
|
292674
292826
|
source
|
|
292675
292827
|
}),
|
|
292676
292828
|
getValues: (result) => ({
|
|
292677
292829
|
adminViewSlug: result.adminViewSlug,
|
|
292678
292830
|
...result.source ? { source: result.source } : {}
|
|
292679
|
-
})
|
|
292680
|
-
|
|
292831
|
+
}),
|
|
292832
|
+
missingNameMessage: "`wp-typia add admin-view` requires <name>. Usage: wp-typia add admin-view <name> [--source <rest-resource:slug|core-data:kind/name>].",
|
|
292833
|
+
name: name2
|
|
292834
|
+
});
|
|
292681
292835
|
},
|
|
292682
292836
|
sortOrder: 10,
|
|
292683
292837
|
supportsDryRun: true,
|
|
292684
292838
|
usage: "wp-typia add admin-view <name> [--source <rest-resource:slug|core-data:kind/name>] [--dry-run]",
|
|
292685
|
-
visibleFieldNames: () =>
|
|
292839
|
+
visibleFieldNames: () => NAME_SOURCE_VISIBLE_FIELDS
|
|
292686
292840
|
}),
|
|
292687
292841
|
"binding-source": defineAddKindRegistryEntry({
|
|
292688
292842
|
completion: {
|
|
@@ -292704,15 +292858,11 @@ var ADD_KIND_REGISTRY = {
|
|
|
292704
292858
|
nameLabel: "Binding source name",
|
|
292705
292859
|
async prepareExecution(context) {
|
|
292706
292860
|
const name2 = requireAddKindName(context, "`wp-typia add binding-source` requires <name>. Usage: wp-typia add binding-source <name> [--block <block-slug|namespace/block-slug> --attribute <attribute>].");
|
|
292707
|
-
const blockName =
|
|
292708
|
-
|
|
292709
|
-
|
|
292710
|
-
throw createCliDiagnosticCodeError(CLI_DIAGNOSTIC_CODES.MISSING_ARGUMENT, "`wp-typia add binding-source` requires --block and --attribute to be provided together.");
|
|
292711
|
-
}
|
|
292712
|
-
return {
|
|
292713
|
-
execute: (cwd) => context.addRuntime.runAddBindingSourceCommand({
|
|
292861
|
+
const [blockName, attributeName] = readOptionalPairedStringFlags(context.flags, "block", "attribute", "`wp-typia add binding-source` requires --block and --attribute to be provided together.");
|
|
292862
|
+
return createNamedExecutionPlan(context, {
|
|
292863
|
+
execute: ({ cwd, name: name3 }) => context.addRuntime.runAddBindingSourceCommand({
|
|
292714
292864
|
attributeName,
|
|
292715
|
-
bindingSourceName:
|
|
292865
|
+
bindingSourceName: name3,
|
|
292716
292866
|
blockName,
|
|
292717
292867
|
cwd
|
|
292718
292868
|
}),
|
|
@@ -292720,13 +292870,15 @@ var ADD_KIND_REGISTRY = {
|
|
|
292720
292870
|
...result.attributeName ? { attributeName: result.attributeName } : {},
|
|
292721
292871
|
...result.blockSlug ? { blockSlug: result.blockSlug } : {},
|
|
292722
292872
|
bindingSourceSlug: result.bindingSourceSlug
|
|
292723
|
-
})
|
|
292724
|
-
|
|
292873
|
+
}),
|
|
292874
|
+
missingNameMessage: "`wp-typia add binding-source` requires <name>. Usage: wp-typia add binding-source <name> [--block <block-slug|namespace/block-slug> --attribute <attribute>].",
|
|
292875
|
+
name: name2
|
|
292876
|
+
});
|
|
292725
292877
|
},
|
|
292726
292878
|
sortOrder: 70,
|
|
292727
292879
|
supportsDryRun: true,
|
|
292728
292880
|
usage: "wp-typia add binding-source <name> [--block <block-slug|namespace/block-slug> --attribute <attribute>] [--dry-run]",
|
|
292729
|
-
visibleFieldNames: () =>
|
|
292881
|
+
visibleFieldNames: () => NAME_BLOCK_ATTRIBUTE_VISIBLE_FIELDS
|
|
292730
292882
|
}),
|
|
292731
292883
|
block: defineAddKindRegistryEntry({
|
|
292732
292884
|
completion: {
|
|
@@ -292764,10 +292916,10 @@ var ADD_KIND_REGISTRY = {
|
|
|
292764
292916
|
})), 1);
|
|
292765
292917
|
}
|
|
292766
292918
|
resolvedTemplateId ??= "basic";
|
|
292767
|
-
return {
|
|
292768
|
-
execute: (cwd) => context.addRuntime.runAddBlockCommand({
|
|
292919
|
+
return createNamedExecutionPlan(context, {
|
|
292920
|
+
execute: ({ cwd, name: name3 }) => context.addRuntime.runAddBlockCommand({
|
|
292769
292921
|
alternateRenderTargets,
|
|
292770
|
-
blockName:
|
|
292922
|
+
blockName: name3,
|
|
292771
292923
|
cwd,
|
|
292772
292924
|
dataStorageMode,
|
|
292773
292925
|
externalLayerId,
|
|
@@ -292782,8 +292934,10 @@ var ADD_KIND_REGISTRY = {
|
|
|
292782
292934
|
templateId: result.templateId
|
|
292783
292935
|
}),
|
|
292784
292936
|
getWarnings: (result) => result.warnings,
|
|
292937
|
+
missingNameMessage: "`wp-typia add block` requires <name>. Usage: wp-typia add block <name> [--template <basic|interactivity|persistence|compound>]",
|
|
292938
|
+
name: name2,
|
|
292785
292939
|
warnLine: context.warnLine
|
|
292786
|
-
};
|
|
292940
|
+
});
|
|
292787
292941
|
},
|
|
292788
292942
|
sortOrder: 20,
|
|
292789
292943
|
supportsDryRun: true,
|
|
@@ -292816,21 +292970,21 @@ var ADD_KIND_REGISTRY = {
|
|
|
292816
292970
|
description: "Add a typed server/client workflow ability scaffold",
|
|
292817
292971
|
nameLabel: "Ability name",
|
|
292818
292972
|
async prepareExecution(context) {
|
|
292819
|
-
|
|
292820
|
-
|
|
292821
|
-
execute: (cwd) => context.addRuntime.runAddAbilityCommand({
|
|
292973
|
+
return createNamedExecutionPlan(context, {
|
|
292974
|
+
execute: ({ cwd, name: name2 }) => context.addRuntime.runAddAbilityCommand({
|
|
292822
292975
|
abilityName: name2,
|
|
292823
292976
|
cwd
|
|
292824
292977
|
}),
|
|
292825
292978
|
getValues: (result) => ({
|
|
292826
292979
|
abilitySlug: result.abilitySlug
|
|
292827
|
-
})
|
|
292828
|
-
|
|
292980
|
+
}),
|
|
292981
|
+
missingNameMessage: "`wp-typia add ability` requires <name>. Usage: wp-typia add ability <name>."
|
|
292982
|
+
});
|
|
292829
292983
|
},
|
|
292830
292984
|
sortOrder: 90,
|
|
292831
292985
|
supportsDryRun: true,
|
|
292832
292986
|
usage: "wp-typia add ability <name> [--dry-run]",
|
|
292833
|
-
visibleFieldNames: () =>
|
|
292987
|
+
visibleFieldNames: () => NAME_ONLY_VISIBLE_FIELDS
|
|
292834
292988
|
}),
|
|
292835
292989
|
"editor-plugin": defineAddKindRegistryEntry({
|
|
292836
292990
|
completion: {
|
|
@@ -292850,22 +293004,24 @@ var ADD_KIND_REGISTRY = {
|
|
|
292850
293004
|
async prepareExecution(context) {
|
|
292851
293005
|
const name2 = requireAddKindName(context, "`wp-typia add editor-plugin` requires <name>. Usage: wp-typia add editor-plugin <name> [--slot <sidebar|document-setting-panel>].");
|
|
292852
293006
|
const slot = readOptionalStringFlag(context.flags, "slot");
|
|
292853
|
-
return {
|
|
292854
|
-
execute: (cwd) => context.addRuntime.runAddEditorPluginCommand({
|
|
293007
|
+
return createNamedExecutionPlan(context, {
|
|
293008
|
+
execute: ({ cwd, name: name3 }) => context.addRuntime.runAddEditorPluginCommand({
|
|
292855
293009
|
cwd,
|
|
292856
|
-
editorPluginName:
|
|
293010
|
+
editorPluginName: name3,
|
|
292857
293011
|
slot
|
|
292858
293012
|
}),
|
|
292859
293013
|
getValues: (result) => ({
|
|
292860
293014
|
editorPluginSlug: result.editorPluginSlug,
|
|
292861
293015
|
slot: result.slot
|
|
292862
|
-
})
|
|
292863
|
-
|
|
293016
|
+
}),
|
|
293017
|
+
missingNameMessage: "`wp-typia add editor-plugin` requires <name>. Usage: wp-typia add editor-plugin <name> [--slot <sidebar|document-setting-panel>].",
|
|
293018
|
+
name: name2
|
|
293019
|
+
});
|
|
292864
293020
|
},
|
|
292865
293021
|
sortOrder: 120,
|
|
292866
293022
|
supportsDryRun: true,
|
|
292867
293023
|
usage: "wp-typia add editor-plugin <name> [--slot <sidebar|document-setting-panel>] [--dry-run]",
|
|
292868
|
-
visibleFieldNames: () =>
|
|
293024
|
+
visibleFieldNames: () => NAME_SLOT_VISIBLE_FIELDS
|
|
292869
293025
|
}),
|
|
292870
293026
|
"hooked-block": defineAddKindRegistryEntry({
|
|
292871
293027
|
completion: {
|
|
@@ -292885,18 +293041,12 @@ var ADD_KIND_REGISTRY = {
|
|
|
292885
293041
|
nameLabel: "Target block",
|
|
292886
293042
|
async prepareExecution(context) {
|
|
292887
293043
|
const name2 = requireAddKindName(context, "`wp-typia add hooked-block` requires <block-slug>. Usage: wp-typia add hooked-block <block-slug> --anchor <anchor-block-name> --position <before|after|firstChild|lastChild>.");
|
|
292888
|
-
const anchorBlockName =
|
|
292889
|
-
|
|
292890
|
-
|
|
292891
|
-
|
|
292892
|
-
const position = readOptionalStringFlag(context.flags, "position");
|
|
292893
|
-
if (!position) {
|
|
292894
|
-
throw createCliDiagnosticCodeError(CLI_DIAGNOSTIC_CODES.MISSING_ARGUMENT, "`wp-typia add hooked-block` requires --position <before|after|firstChild|lastChild>.");
|
|
292895
|
-
}
|
|
292896
|
-
return {
|
|
292897
|
-
execute: (cwd) => context.addRuntime.runAddHookedBlockCommand({
|
|
293044
|
+
const anchorBlockName = requireStringFlag(context.flags, "anchor", "`wp-typia add hooked-block` requires --anchor <anchor-block-name>.");
|
|
293045
|
+
const position = requireStringFlag(context.flags, "position", "`wp-typia add hooked-block` requires --position <before|after|firstChild|lastChild>.");
|
|
293046
|
+
return createNamedExecutionPlan(context, {
|
|
293047
|
+
execute: ({ cwd, name: name3 }) => context.addRuntime.runAddHookedBlockCommand({
|
|
292898
293048
|
anchorBlockName,
|
|
292899
|
-
blockName:
|
|
293049
|
+
blockName: name3,
|
|
292900
293050
|
cwd,
|
|
292901
293051
|
position
|
|
292902
293052
|
}),
|
|
@@ -292904,13 +293054,15 @@ var ADD_KIND_REGISTRY = {
|
|
|
292904
293054
|
anchorBlockName: result.anchorBlockName,
|
|
292905
293055
|
blockSlug: result.blockSlug,
|
|
292906
293056
|
position: result.position
|
|
292907
|
-
})
|
|
292908
|
-
|
|
293057
|
+
}),
|
|
293058
|
+
missingNameMessage: "`wp-typia add hooked-block` requires <block-slug>. Usage: wp-typia add hooked-block <block-slug> --anchor <anchor-block-name> --position <before|after|firstChild|lastChild>.",
|
|
293059
|
+
name: name2
|
|
293060
|
+
});
|
|
292909
293061
|
},
|
|
292910
293062
|
sortOrder: 110,
|
|
292911
293063
|
supportsDryRun: true,
|
|
292912
293064
|
usage: "wp-typia add hooked-block <block-slug> --anchor <anchor-block-name> --position <before|after|firstChild|lastChild> [--dry-run]",
|
|
292913
|
-
visibleFieldNames: () =>
|
|
293065
|
+
visibleFieldNames: () => NAME_ANCHOR_POSITION_VISIBLE_FIELDS
|
|
292914
293066
|
}),
|
|
292915
293067
|
pattern: defineAddKindRegistryEntry({
|
|
292916
293068
|
completion: {
|
|
@@ -292927,21 +293079,21 @@ var ADD_KIND_REGISTRY = {
|
|
|
292927
293079
|
description: "Add a PHP block pattern shell",
|
|
292928
293080
|
nameLabel: "Pattern name",
|
|
292929
293081
|
async prepareExecution(context) {
|
|
292930
|
-
|
|
292931
|
-
|
|
292932
|
-
execute: (cwd) => context.addRuntime.runAddPatternCommand({
|
|
293082
|
+
return createNamedExecutionPlan(context, {
|
|
293083
|
+
execute: ({ cwd, name: name2 }) => context.addRuntime.runAddPatternCommand({
|
|
292933
293084
|
cwd,
|
|
292934
293085
|
patternName: name2
|
|
292935
293086
|
}),
|
|
292936
293087
|
getValues: (result) => ({
|
|
292937
293088
|
patternSlug: result.patternSlug
|
|
292938
|
-
})
|
|
292939
|
-
|
|
293089
|
+
}),
|
|
293090
|
+
missingNameMessage: "`wp-typia add pattern` requires <name>. Usage: wp-typia add pattern <name>."
|
|
293091
|
+
});
|
|
292940
293092
|
},
|
|
292941
293093
|
sortOrder: 60,
|
|
292942
293094
|
supportsDryRun: true,
|
|
292943
293095
|
usage: "wp-typia add pattern <name> [--dry-run]",
|
|
292944
|
-
visibleFieldNames: () =>
|
|
293096
|
+
visibleFieldNames: () => NAME_ONLY_VISIBLE_FIELDS
|
|
292945
293097
|
}),
|
|
292946
293098
|
style: defineAddKindRegistryEntry({
|
|
292947
293099
|
completion: {
|
|
@@ -292960,26 +293112,25 @@ var ADD_KIND_REGISTRY = {
|
|
|
292960
293112
|
nameLabel: "Style name",
|
|
292961
293113
|
async prepareExecution(context) {
|
|
292962
293114
|
const name2 = requireAddKindName(context, "`wp-typia add style` requires <name>. Usage: wp-typia add style <name> --block <block-slug>.");
|
|
292963
|
-
const blockSlug =
|
|
292964
|
-
|
|
292965
|
-
|
|
292966
|
-
}
|
|
292967
|
-
return {
|
|
292968
|
-
execute: (cwd) => context.addRuntime.runAddBlockStyleCommand({
|
|
293115
|
+
const blockSlug = requireStringFlag(context.flags, "block", "`wp-typia add style` requires --block <block-slug>.");
|
|
293116
|
+
return createNamedExecutionPlan(context, {
|
|
293117
|
+
execute: ({ cwd, name: name3 }) => context.addRuntime.runAddBlockStyleCommand({
|
|
292969
293118
|
blockName: blockSlug,
|
|
292970
293119
|
cwd,
|
|
292971
|
-
styleName:
|
|
293120
|
+
styleName: name3
|
|
292972
293121
|
}),
|
|
292973
293122
|
getValues: (result) => ({
|
|
292974
293123
|
blockSlug: result.blockSlug,
|
|
292975
293124
|
styleSlug: result.styleSlug
|
|
292976
|
-
})
|
|
292977
|
-
|
|
293125
|
+
}),
|
|
293126
|
+
missingNameMessage: "`wp-typia add style` requires <name>. Usage: wp-typia add style <name> --block <block-slug>.",
|
|
293127
|
+
name: name2
|
|
293128
|
+
});
|
|
292978
293129
|
},
|
|
292979
293130
|
sortOrder: 40,
|
|
292980
293131
|
supportsDryRun: true,
|
|
292981
293132
|
usage: "wp-typia add style <name> --block <block-slug> [--dry-run]",
|
|
292982
|
-
visibleFieldNames: () =>
|
|
293133
|
+
visibleFieldNames: () => NAME_BLOCK_VISIBLE_FIELDS
|
|
292983
293134
|
}),
|
|
292984
293135
|
transform: defineAddKindRegistryEntry({
|
|
292985
293136
|
completion: {
|
|
@@ -292999,33 +293150,29 @@ var ADD_KIND_REGISTRY = {
|
|
|
292999
293150
|
nameLabel: "Transform name",
|
|
293000
293151
|
async prepareExecution(context) {
|
|
293001
293152
|
const name2 = requireAddKindName(context, "`wp-typia add transform` requires <name>. Usage: wp-typia add transform <name> --from <namespace/block> --to <block-slug|namespace/block-slug>.");
|
|
293002
|
-
const fromBlockName =
|
|
293003
|
-
|
|
293004
|
-
|
|
293005
|
-
|
|
293006
|
-
const toBlockName = readOptionalStringFlag(context.flags, "to");
|
|
293007
|
-
if (!toBlockName) {
|
|
293008
|
-
throw createCliDiagnosticCodeError(CLI_DIAGNOSTIC_CODES.MISSING_ARGUMENT, "`wp-typia add transform` requires --to <block-slug|namespace/block-slug>.");
|
|
293009
|
-
}
|
|
293010
|
-
return {
|
|
293011
|
-
execute: (cwd) => context.addRuntime.runAddBlockTransformCommand({
|
|
293153
|
+
const fromBlockName = requireStringFlag(context.flags, "from", "`wp-typia add transform` requires --from <namespace/block>.");
|
|
293154
|
+
const toBlockName = requireStringFlag(context.flags, "to", "`wp-typia add transform` requires --to <block-slug|namespace/block-slug>.");
|
|
293155
|
+
return createNamedExecutionPlan(context, {
|
|
293156
|
+
execute: ({ cwd, name: name3 }) => context.addRuntime.runAddBlockTransformCommand({
|
|
293012
293157
|
cwd,
|
|
293013
293158
|
fromBlockName,
|
|
293014
293159
|
toBlockName,
|
|
293015
|
-
transformName:
|
|
293160
|
+
transformName: name3
|
|
293016
293161
|
}),
|
|
293017
293162
|
getValues: (result) => ({
|
|
293018
293163
|
blockSlug: result.blockSlug,
|
|
293019
293164
|
fromBlockName: result.fromBlockName,
|
|
293020
293165
|
toBlockName: result.toBlockName,
|
|
293021
293166
|
transformSlug: result.transformSlug
|
|
293022
|
-
})
|
|
293023
|
-
|
|
293167
|
+
}),
|
|
293168
|
+
missingNameMessage: "`wp-typia add transform` requires <name>. Usage: wp-typia add transform <name> --from <namespace/block> --to <block-slug|namespace/block-slug>.",
|
|
293169
|
+
name: name2
|
|
293170
|
+
});
|
|
293024
293171
|
},
|
|
293025
293172
|
sortOrder: 50,
|
|
293026
293173
|
supportsDryRun: true,
|
|
293027
293174
|
usage: "wp-typia add transform <name> --from <namespace/block> --to <block-slug|namespace/block-slug> [--dry-run]",
|
|
293028
|
-
visibleFieldNames: () =>
|
|
293175
|
+
visibleFieldNames: () => NAME_FROM_TO_VISIBLE_FIELDS
|
|
293029
293176
|
}),
|
|
293030
293177
|
"rest-resource": defineAddKindRegistryEntry({
|
|
293031
293178
|
completion: {
|
|
@@ -293047,24 +293194,26 @@ var ADD_KIND_REGISTRY = {
|
|
|
293047
293194
|
const name2 = requireAddKindName(context, "`wp-typia add rest-resource` requires <name>. Usage: wp-typia add rest-resource <name> [--namespace <vendor/v1>] [--methods <list,read,create>].");
|
|
293048
293195
|
const methods = readOptionalStringFlag(context.flags, "methods");
|
|
293049
293196
|
const namespace = readOptionalStringFlag(context.flags, "namespace");
|
|
293050
|
-
return {
|
|
293051
|
-
execute: (cwd) => context.addRuntime.runAddRestResourceCommand({
|
|
293197
|
+
return createNamedExecutionPlan(context, {
|
|
293198
|
+
execute: ({ cwd, name: name3 }) => context.addRuntime.runAddRestResourceCommand({
|
|
293052
293199
|
cwd,
|
|
293053
293200
|
methods,
|
|
293054
293201
|
namespace,
|
|
293055
|
-
restResourceName:
|
|
293202
|
+
restResourceName: name3
|
|
293056
293203
|
}),
|
|
293057
293204
|
getValues: (result) => ({
|
|
293058
293205
|
methods: result.methods.join(", "),
|
|
293059
293206
|
namespace: result.namespace,
|
|
293060
293207
|
restResourceSlug: result.restResourceSlug
|
|
293061
|
-
})
|
|
293062
|
-
|
|
293208
|
+
}),
|
|
293209
|
+
missingNameMessage: "`wp-typia add rest-resource` requires <name>. Usage: wp-typia add rest-resource <name> [--namespace <vendor/v1>] [--methods <list,read,create>].",
|
|
293210
|
+
name: name2
|
|
293211
|
+
});
|
|
293063
293212
|
},
|
|
293064
293213
|
sortOrder: 80,
|
|
293065
293214
|
supportsDryRun: true,
|
|
293066
293215
|
usage: "wp-typia add rest-resource <name> [--namespace <vendor/v1>] [--methods <list,read,create,update,delete>] [--dry-run]",
|
|
293067
|
-
visibleFieldNames: () =>
|
|
293216
|
+
visibleFieldNames: () => NAME_NAMESPACE_METHODS_VISIBLE_FIELDS
|
|
293068
293217
|
}),
|
|
293069
293218
|
"ai-feature": defineAddKindRegistryEntry({
|
|
293070
293219
|
completion: {
|
|
@@ -293084,9 +293233,9 @@ var ADD_KIND_REGISTRY = {
|
|
|
293084
293233
|
async prepareExecution(context) {
|
|
293085
293234
|
const name2 = requireAddKindName(context, "`wp-typia add ai-feature` requires <name>. Usage: wp-typia add ai-feature <name> [--namespace <vendor/v1>].");
|
|
293086
293235
|
const namespace = readOptionalStringFlag(context.flags, "namespace");
|
|
293087
|
-
return {
|
|
293088
|
-
execute: (cwd) => context.addRuntime.runAddAiFeatureCommand({
|
|
293089
|
-
aiFeatureName:
|
|
293236
|
+
return createNamedExecutionPlan(context, {
|
|
293237
|
+
execute: ({ cwd, name: name3 }) => context.addRuntime.runAddAiFeatureCommand({
|
|
293238
|
+
aiFeatureName: name3,
|
|
293090
293239
|
cwd,
|
|
293091
293240
|
namespace
|
|
293092
293241
|
}),
|
|
@@ -293095,13 +293244,15 @@ var ADD_KIND_REGISTRY = {
|
|
|
293095
293244
|
namespace: result.namespace
|
|
293096
293245
|
}),
|
|
293097
293246
|
getWarnings: (result) => result.warnings,
|
|
293247
|
+
missingNameMessage: "`wp-typia add ai-feature` requires <name>. Usage: wp-typia add ai-feature <name> [--namespace <vendor/v1>].",
|
|
293248
|
+
name: name2,
|
|
293098
293249
|
warnLine: context.warnLine
|
|
293099
|
-
};
|
|
293250
|
+
});
|
|
293100
293251
|
},
|
|
293101
293252
|
sortOrder: 100,
|
|
293102
293253
|
supportsDryRun: true,
|
|
293103
293254
|
usage: "wp-typia add ai-feature <name> [--namespace <vendor/v1>] [--dry-run]",
|
|
293104
|
-
visibleFieldNames: () =>
|
|
293255
|
+
visibleFieldNames: () => NAME_NAMESPACE_VISIBLE_FIELDS
|
|
293105
293256
|
}),
|
|
293106
293257
|
variation: defineAddKindRegistryEntry({
|
|
293107
293258
|
completion: {
|
|
@@ -293120,29 +293271,27 @@ var ADD_KIND_REGISTRY = {
|
|
|
293120
293271
|
nameLabel: "Variation name",
|
|
293121
293272
|
async prepareExecution(context) {
|
|
293122
293273
|
const name2 = requireAddKindName(context, "`wp-typia add variation` requires <name>. Usage: wp-typia add variation <name> --block <block-slug>");
|
|
293123
|
-
const blockSlug =
|
|
293124
|
-
|
|
293125
|
-
|
|
293126
|
-
}
|
|
293127
|
-
return {
|
|
293128
|
-
execute: (cwd) => context.addRuntime.runAddVariationCommand({
|
|
293274
|
+
const blockSlug = requireStringFlag(context.flags, "block", "`wp-typia add variation` requires --block <block-slug>.");
|
|
293275
|
+
return createNamedExecutionPlan(context, {
|
|
293276
|
+
execute: ({ cwd, name: name3 }) => context.addRuntime.runAddVariationCommand({
|
|
293129
293277
|
blockName: blockSlug,
|
|
293130
293278
|
cwd,
|
|
293131
|
-
variationName:
|
|
293279
|
+
variationName: name3
|
|
293132
293280
|
}),
|
|
293133
293281
|
getValues: (result) => ({
|
|
293134
293282
|
blockSlug: result.blockSlug,
|
|
293135
293283
|
variationSlug: result.variationSlug
|
|
293136
|
-
})
|
|
293137
|
-
|
|
293284
|
+
}),
|
|
293285
|
+
missingNameMessage: "`wp-typia add variation` requires <name>. Usage: wp-typia add variation <name> --block <block-slug>",
|
|
293286
|
+
name: name2
|
|
293287
|
+
});
|
|
293138
293288
|
},
|
|
293139
293289
|
sortOrder: 30,
|
|
293140
293290
|
supportsDryRun: true,
|
|
293141
293291
|
usage: "wp-typia add variation <name> --block <block-slug> [--dry-run]",
|
|
293142
|
-
visibleFieldNames: () =>
|
|
293292
|
+
visibleFieldNames: () => NAME_BLOCK_VISIBLE_FIELDS
|
|
293143
293293
|
})
|
|
293144
293294
|
};
|
|
293145
|
-
var ADD_KIND_IDS = Object.keys(ADD_KIND_REGISTRY).sort((left, right) => ADD_KIND_REGISTRY[left].sortOrder - ADD_KIND_REGISTRY[right].sortOrder);
|
|
293146
293295
|
function isAddKindId(value2) {
|
|
293147
293296
|
return typeof value2 === "string" && ADD_KIND_IDS.includes(value2);
|
|
293148
293297
|
}
|
|
@@ -293300,7 +293449,7 @@ import path10 from "path";
|
|
|
293300
293449
|
// package.json
|
|
293301
293450
|
var package_default2 = {
|
|
293302
293451
|
name: "wp-typia",
|
|
293303
|
-
version: "0.22.
|
|
293452
|
+
version: "0.22.1",
|
|
293304
293453
|
description: "Canonical CLI package for wp-typia scaffolding and project workflows",
|
|
293305
293454
|
packageManager: "bun@1.3.11",
|
|
293306
293455
|
type: "module",
|
|
@@ -293370,7 +293519,7 @@ var package_default2 = {
|
|
|
293370
293519
|
"@bunli/tui": "0.6.0",
|
|
293371
293520
|
"@bunli/utils": "0.6.0",
|
|
293372
293521
|
"@wp-typia/api-client": "^0.4.5",
|
|
293373
|
-
"@wp-typia/project-tools": "0.22.
|
|
293522
|
+
"@wp-typia/project-tools": "0.22.1",
|
|
293374
293523
|
"better-result": "^2.7.0",
|
|
293375
293524
|
react: "^19.2.5",
|
|
293376
293525
|
"react-dom": "^19.2.5",
|
|
@@ -293540,15 +293689,7 @@ function buildStructuredCompletionSuccessPayload(command, completion, metadata2
|
|
|
293540
293689
|
command,
|
|
293541
293690
|
...serializedCompletion ? {
|
|
293542
293691
|
completion: serializedCompletion,
|
|
293543
|
-
files: extractPlannedFiles(serializedCompletion)
|
|
293544
|
-
nextSteps: serializedCompletion.nextSteps,
|
|
293545
|
-
optionalLines: serializedCompletion.optionalLines,
|
|
293546
|
-
optionalNote: serializedCompletion.optionalNote,
|
|
293547
|
-
optionalTitle: serializedCompletion.optionalTitle,
|
|
293548
|
-
preambleLines: serializedCompletion.preambleLines,
|
|
293549
|
-
summaryLines: serializedCompletion.summaryLines,
|
|
293550
|
-
title: serializedCompletion.title,
|
|
293551
|
-
warnings: serializedCompletion.warningLines
|
|
293692
|
+
files: extractPlannedFiles(serializedCompletion)
|
|
293552
293693
|
} : {}
|
|
293553
293694
|
}
|
|
293554
293695
|
};
|
|
@@ -293567,14 +293708,11 @@ function buildStructuredInitSuccessPayload(plan) {
|
|
|
293567
293708
|
detectedLayout: plan.detectedLayout,
|
|
293568
293709
|
files: toNonEmptyArray(files),
|
|
293569
293710
|
mode: plan.commandMode === "apply" ? "apply" : "preview",
|
|
293570
|
-
nextSteps: toNonEmptyArray(plan.nextSteps),
|
|
293571
293711
|
packageManager: plan.packageManager,
|
|
293572
293712
|
plan,
|
|
293573
293713
|
projectDir: plan.projectDir,
|
|
293574
293714
|
status: plan.status,
|
|
293575
|
-
summary: plan.summary
|
|
293576
|
-
title: completion.title,
|
|
293577
|
-
warnings: toNonEmptyArray(plan.notes)
|
|
293715
|
+
summary: plan.summary
|
|
293578
293716
|
}
|
|
293579
293717
|
};
|
|
293580
293718
|
}
|
|
@@ -295046,7 +295184,7 @@ init_cli_diagnostics();
|
|
|
295046
295184
|
|
|
295047
295185
|
// src/mcp.ts
|
|
295048
295186
|
import fs50 from "fs/promises";
|
|
295049
|
-
import
|
|
295187
|
+
import path66 from "path";
|
|
295050
295188
|
|
|
295051
295189
|
// ../../node_modules/.bun/@bunli+plugin-mcp@0.2.5+ef72ce197b058209/node_modules/@bunli/plugin-mcp/src/errors.ts
|
|
295052
295190
|
class SchemaConversionError extends TaggedError("SchemaConversionError")() {
|
|
@@ -295574,7 +295712,7 @@ function isToolGroup(value2) {
|
|
|
295574
295712
|
return isObject3(value2) && typeof value2.namespace === "string" && Array.isArray(value2.tools) && value2.tools.every(isTool);
|
|
295575
295713
|
}
|
|
295576
295714
|
async function readSchemaSource(cwd, source) {
|
|
295577
|
-
const schemaPath =
|
|
295715
|
+
const schemaPath = path66.resolve(cwd, source.path);
|
|
295578
295716
|
const raw = await fs50.readFile(schemaPath, "utf8");
|
|
295579
295717
|
const parsed = JSON.parse(raw);
|
|
295580
295718
|
if (isToolGroup(parsed)) {
|
|
@@ -295591,7 +295729,7 @@ async function readSchemaSource(cwd, source) {
|
|
|
295591
295729
|
async function loadMcpToolGroups(cwd, schemaSources) {
|
|
295592
295730
|
return Promise.all(schemaSources.map((source) => readSchemaSource(cwd, source)));
|
|
295593
295731
|
}
|
|
295594
|
-
async function syncMcpSchemas(cwd, schemaSources, outputDir =
|
|
295732
|
+
async function syncMcpSchemas(cwd, schemaSources, outputDir = path66.join(cwd, ".bunli", "mcp")) {
|
|
295595
295733
|
const groups = await loadMcpToolGroups(cwd, schemaSources);
|
|
295596
295734
|
const result = await generateMCPTypes({
|
|
295597
295735
|
outputDir,
|
|
@@ -295614,7 +295752,7 @@ async function syncMcpSchemas(cwd, schemaSources, outputDir = path65.join(cwd, "
|
|
|
295614
295752
|
}
|
|
295615
295753
|
}
|
|
295616
295754
|
await fs50.mkdir(outputDir, { recursive: true });
|
|
295617
|
-
await fs50.writeFile(
|
|
295755
|
+
await fs50.writeFile(path66.join(outputDir, "registry.json"), `${JSON.stringify(registry2, null, 2)}
|
|
295618
295756
|
`, "utf8");
|
|
295619
295757
|
return {
|
|
295620
295758
|
commandCount: registry2.reduce((count, group) => count + group.tools.length, 0),
|
|
@@ -295675,7 +295813,9 @@ var mcpCommand = defineCommand({
|
|
|
295675
295813
|
emitCliDiagnosticFailure(args, {
|
|
295676
295814
|
code: CLI_DIAGNOSTIC_CODES.INVALID_COMMAND,
|
|
295677
295815
|
command: "mcp",
|
|
295678
|
-
detailLines: [
|
|
295816
|
+
detailLines: [
|
|
295817
|
+
`Unknown mcp subcommand "${subcommand}". Expected list or sync.`
|
|
295818
|
+
]
|
|
295679
295819
|
});
|
|
295680
295820
|
} catch (error48) {
|
|
295681
295821
|
emitCliDiagnosticFailure(args, {
|
|
@@ -295685,12 +295825,7 @@ var mcpCommand = defineCommand({
|
|
|
295685
295825
|
}
|
|
295686
295826
|
},
|
|
295687
295827
|
name: "mcp",
|
|
295688
|
-
options:
|
|
295689
|
-
"output-dir": {
|
|
295690
|
-
description: "Output directory for generated MCP metadata during `mcp sync`.",
|
|
295691
|
-
schema: exports_external.string().optional()
|
|
295692
|
-
}
|
|
295693
|
-
}
|
|
295828
|
+
options: buildCommandOptions(MCP_OPTION_METADATA)
|
|
295694
295829
|
});
|
|
295695
295830
|
var mcp_default = mcpCommand;
|
|
295696
295831
|
|
|
@@ -295936,4 +296071,4 @@ export {
|
|
|
295936
296071
|
cli
|
|
295937
296072
|
};
|
|
295938
296073
|
|
|
295939
|
-
//# debugId=
|
|
296074
|
+
//# debugId=7FC90D52A694344264756E2164756E21
|