wp-typia 0.20.0 → 0.20.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 +360 -335
- package/dist-bunli/.bunli/commands.gen.js.map +9 -5
- package/dist-bunli/{cli-add-pq6wm87p.js → cli-add-gcwww85p.js} +249 -243
- package/dist-bunli/{cli-add-pq6wm87p.js.map → cli-add-gcwww85p.js.map} +7 -5
- package/dist-bunli/{cli-2ybmc22r.js → cli-cfx3gm1r.js} +48 -44
- package/dist-bunli/{cli-2ybmc22r.js.map → cli-cfx3gm1r.js.map} +6 -4
- package/dist-bunli/{cli-7yg38ht2.js → cli-mgh3f3k5.js} +3 -3
- package/dist-bunli/{cli-7yg38ht2.js.map → cli-mgh3f3k5.js.map} +1 -1
- package/dist-bunli/{cli-scaffold-s3nhwe7x.js → cli-scaffold-f1bdt68d.js} +1 -1
- package/dist-bunli/cli.js +2 -2
- package/dist-bunli/{command-list-37n1za5q.js → command-list-66cqt7y8.js} +3 -3
- package/dist-bunli/node-cli.js +3 -3
- package/dist-bunli/node-cli.js.map +1 -1
- package/package.json +2 -2
- /package/dist-bunli/{cli-scaffold-s3nhwe7x.js.map → cli-scaffold-f1bdt68d.js.map} +0 -0
- /package/dist-bunli/{command-list-37n1za5q.js.map → command-list-66cqt7y8.js.map} +0 -0
|
@@ -223172,7 +223172,7 @@ var init_block_generator_service_spec = __esm(() => {
|
|
|
223172
223172
|
];
|
|
223173
223173
|
});
|
|
223174
223174
|
|
|
223175
|
-
// ../wp-typia-project-tools/src/runtime/built-in-block-non-ts-
|
|
223175
|
+
// ../wp-typia-project-tools/src/runtime/built-in-block-non-ts-render-utils.ts
|
|
223176
223176
|
function renderArtifact(relativePath, template, view) {
|
|
223177
223177
|
const source = renderMustacheTemplateString(template, view);
|
|
223178
223178
|
return {
|
|
@@ -223203,6 +223203,11 @@ return {{phpPrefix}}_{{slugSnakeCase}}_render_target( '${target}', $attributes,
|
|
|
223203
223203
|
function toPhpSingleQuotedString(value2) {
|
|
223204
223204
|
return `'${value2.replace(/\\/g, "\\\\").replace(/'/g, "\\'")}'`;
|
|
223205
223205
|
}
|
|
223206
|
+
var init_built_in_block_non_ts_render_utils = __esm(() => {
|
|
223207
|
+
init_template_render();
|
|
223208
|
+
});
|
|
223209
|
+
|
|
223210
|
+
// ../wp-typia-project-tools/src/runtime/built-in-block-non-ts-family-artifacts.ts
|
|
223206
223211
|
function buildBasicArtifacts(variables) {
|
|
223207
223212
|
return [
|
|
223208
223213
|
renderArtifact("src/editor.scss", BASIC_EDITOR_STYLE_TEMPLATE, variables),
|
|
@@ -223296,12 +223301,6 @@ $post_id = is_object( $block ) && isset( $block->context['postId'] )
|
|
|
223296
223301
|
$storage_mode = '{{dataStorageMode}}';
|
|
223297
223302
|
$persistence_policy = '{{persistencePolicy}}';
|
|
223298
223303
|
|
|
223299
|
-
{{phpPrefix}}_record_rendered_block_instance(
|
|
223300
|
-
(int) $post_id,
|
|
223301
|
-
'{{namespace}}/{{slugKebabCase}}',
|
|
223302
|
-
$resource_key
|
|
223303
|
-
);
|
|
223304
|
-
|
|
223305
223304
|
$notice_message = 'authenticated' === $persistence_policy
|
|
223306
223305
|
? __( 'Sign in to persist this counter.', '{{textDomain}}' )
|
|
223307
223306
|
: __( 'Public writes are temporarily unavailable.', '{{textDomain}}' );
|
|
@@ -223310,6 +223309,12 @@ if ( empty( $validation['valid'] ) || '' === $resource_key ) {
|
|
|
223310
223309
|
return '';
|
|
223311
223310
|
}
|
|
223312
223311
|
|
|
223312
|
+
{{phpPrefix}}_record_rendered_block_instance(
|
|
223313
|
+
(int) $post_id,
|
|
223314
|
+
'{{namespace}}/{{slugKebabCase}}',
|
|
223315
|
+
$resource_key
|
|
223316
|
+
);
|
|
223317
|
+
|
|
223313
223318
|
$context = array(
|
|
223314
223319
|
'bootstrapReady' => false,
|
|
223315
223320
|
'buttonLabel' => $button_label,
|
|
@@ -223418,27 +223423,6 @@ $wrapper_attributes = get_block_wrapper_attributes(
|
|
|
223418
223423
|
}
|
|
223419
223424
|
return artifacts;
|
|
223420
223425
|
}
|
|
223421
|
-
function buildBuiltInNonTsArtifacts({
|
|
223422
|
-
templateId,
|
|
223423
|
-
variables
|
|
223424
|
-
}) {
|
|
223425
|
-
switch (templateId) {
|
|
223426
|
-
case "basic":
|
|
223427
|
-
return buildBasicArtifacts(variables);
|
|
223428
|
-
case "interactivity":
|
|
223429
|
-
return buildInteractivityArtifacts(variables);
|
|
223430
|
-
case "persistence":
|
|
223431
|
-
return buildPersistenceArtifacts(variables);
|
|
223432
|
-
case "compound":
|
|
223433
|
-
return buildCompoundArtifacts(variables);
|
|
223434
|
-
case "query-loop":
|
|
223435
|
-
return [];
|
|
223436
|
-
default: {
|
|
223437
|
-
const unhandledTemplateId = templateId;
|
|
223438
|
-
throw new Error(`Unhandled built-in template id: ${unhandledTemplateId}`);
|
|
223439
|
-
}
|
|
223440
|
-
}
|
|
223441
|
-
}
|
|
223442
223426
|
var BASIC_STYLE_TEMPLATE = `/**
|
|
223443
223427
|
* {{title}} Block Styles
|
|
223444
223428
|
*/
|
|
@@ -223983,12 +223967,6 @@ if ( ! function_exists( '{{phpPrefix}}_{{slugSnakeCase}}_build_render_context' )
|
|
|
223983
223967
|
$storage_mode = '{{dataStorageMode}}';
|
|
223984
223968
|
$persistence_policy = '{{persistencePolicy}}';
|
|
223985
223969
|
|
|
223986
|
-
{{phpPrefix}}_record_rendered_block_instance(
|
|
223987
|
-
(int) $post_id,
|
|
223988
|
-
'{{namespace}}/{{slugKebabCase}}',
|
|
223989
|
-
$resource_key
|
|
223990
|
-
);
|
|
223991
|
-
|
|
223992
223970
|
$notice_message = 'authenticated' === $persistence_policy
|
|
223993
223971
|
? __( 'Sign in to persist this counter.', '{{textDomain}}' )
|
|
223994
223972
|
: __( 'Public writes are temporarily unavailable.', '{{textDomain}}' );
|
|
@@ -223997,6 +223975,12 @@ if ( ! function_exists( '{{phpPrefix}}_{{slugSnakeCase}}_build_render_context' )
|
|
|
223997
223975
|
return null;
|
|
223998
223976
|
}
|
|
223999
223977
|
|
|
223978
|
+
{{phpPrefix}}_record_rendered_block_instance(
|
|
223979
|
+
(int) $post_id,
|
|
223980
|
+
'{{namespace}}/{{slugKebabCase}}',
|
|
223981
|
+
$resource_key
|
|
223982
|
+
);
|
|
223983
|
+
|
|
224000
223984
|
$web_context = array(
|
|
224001
223985
|
'bootstrapReady' => false,
|
|
224002
223986
|
'buttonLabel' => $button_label,
|
|
@@ -224225,8 +224209,34 @@ if ( ! function_exists( '{{phpPrefix}}_{{slugSnakeCase}}_render_target' ) ) {
|
|
|
224225
224209
|
padding-top: 0;
|
|
224226
224210
|
}
|
|
224227
224211
|
`;
|
|
224212
|
+
var init_built_in_block_non_ts_family_artifacts = __esm(() => {
|
|
224213
|
+
init_built_in_block_non_ts_render_utils();
|
|
224214
|
+
});
|
|
224215
|
+
|
|
224216
|
+
// ../wp-typia-project-tools/src/runtime/built-in-block-non-ts-artifacts.ts
|
|
224217
|
+
function buildBuiltInNonTsArtifacts({
|
|
224218
|
+
templateId,
|
|
224219
|
+
variables
|
|
224220
|
+
}) {
|
|
224221
|
+
switch (templateId) {
|
|
224222
|
+
case "basic":
|
|
224223
|
+
return buildBasicArtifacts(variables);
|
|
224224
|
+
case "interactivity":
|
|
224225
|
+
return buildInteractivityArtifacts(variables);
|
|
224226
|
+
case "persistence":
|
|
224227
|
+
return buildPersistenceArtifacts(variables);
|
|
224228
|
+
case "compound":
|
|
224229
|
+
return buildCompoundArtifacts(variables);
|
|
224230
|
+
case "query-loop":
|
|
224231
|
+
return [];
|
|
224232
|
+
default: {
|
|
224233
|
+
const unhandledTemplateId = templateId;
|
|
224234
|
+
throw new Error(`Unhandled built-in template id: ${unhandledTemplateId}`);
|
|
224235
|
+
}
|
|
224236
|
+
}
|
|
224237
|
+
}
|
|
224228
224238
|
var init_built_in_block_non_ts_artifacts = __esm(() => {
|
|
224229
|
-
|
|
224239
|
+
init_built_in_block_non_ts_family_artifacts();
|
|
224230
224240
|
});
|
|
224231
224241
|
|
|
224232
224242
|
// ../wp-typia-project-tools/src/runtime/built-in-block-code-templates/shared.ts
|
|
@@ -229398,8 +229408,210 @@ var init_cli_add_workspace_assets = __esm(() => {
|
|
|
229398
229408
|
init_cli_add_shared();
|
|
229399
229409
|
});
|
|
229400
229410
|
|
|
229401
|
-
// ../wp-typia-project-tools/src/runtime/rest-
|
|
229411
|
+
// ../wp-typia-project-tools/src/runtime/cli-add-workspace-rest-anchors.ts
|
|
229402
229412
|
import path50 from "path";
|
|
229413
|
+
function escapeRegex3(value2) {
|
|
229414
|
+
return value2.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
|
|
229415
|
+
}
|
|
229416
|
+
async function ensureRestResourceBootstrapAnchors(workspace) {
|
|
229417
|
+
const bootstrapPath = getWorkspaceBootstrapPath(workspace);
|
|
229418
|
+
await patchFile(bootstrapPath, (source) => {
|
|
229419
|
+
let nextSource = source;
|
|
229420
|
+
const registerFunctionName = `${workspace.workspace.phpPrefix}_register_rest_resources`;
|
|
229421
|
+
const registerHook = `add_action( 'init', '${registerFunctionName}', 20 );`;
|
|
229422
|
+
const registerFunction = `
|
|
229423
|
+
|
|
229424
|
+
function ${registerFunctionName}() {
|
|
229425
|
+
foreach ( glob( __DIR__ . '${REST_RESOURCE_SERVER_GLOB}' ) ?: array() as $rest_resource_module ) {
|
|
229426
|
+
require_once $rest_resource_module;
|
|
229427
|
+
}
|
|
229428
|
+
}
|
|
229429
|
+
`;
|
|
229430
|
+
const insertionAnchors = [
|
|
229431
|
+
/add_action\(\s*["']init["']\s*,\s*["'][^"']+_load_textdomain["']\s*\);\s*\n/u,
|
|
229432
|
+
/\?>\s*$/u
|
|
229433
|
+
];
|
|
229434
|
+
const hasPhpFunctionDefinition = (functionName) => new RegExp(`function\\s+${escapeRegex3(functionName)}\\s*\\(`, "u").test(nextSource);
|
|
229435
|
+
const insertPhpSnippet = (snippet) => {
|
|
229436
|
+
for (const anchor of insertionAnchors) {
|
|
229437
|
+
const candidate = nextSource.replace(anchor, (match3) => `${snippet}
|
|
229438
|
+
${match3}`);
|
|
229439
|
+
if (candidate !== nextSource) {
|
|
229440
|
+
nextSource = candidate;
|
|
229441
|
+
return;
|
|
229442
|
+
}
|
|
229443
|
+
}
|
|
229444
|
+
nextSource = `${nextSource.trimEnd()}
|
|
229445
|
+
${snippet}
|
|
229446
|
+
`;
|
|
229447
|
+
};
|
|
229448
|
+
const appendPhpSnippet = (snippet) => {
|
|
229449
|
+
const closingTagPattern = /\?>\s*$/u;
|
|
229450
|
+
if (closingTagPattern.test(nextSource)) {
|
|
229451
|
+
nextSource = nextSource.replace(closingTagPattern, `${snippet}
|
|
229452
|
+
?>`);
|
|
229453
|
+
return;
|
|
229454
|
+
}
|
|
229455
|
+
nextSource = `${nextSource.trimEnd()}
|
|
229456
|
+
${snippet}
|
|
229457
|
+
`;
|
|
229458
|
+
};
|
|
229459
|
+
if (!hasPhpFunctionDefinition(registerFunctionName)) {
|
|
229460
|
+
insertPhpSnippet(registerFunction);
|
|
229461
|
+
} else if (!nextSource.includes(REST_RESOURCE_SERVER_GLOB)) {
|
|
229462
|
+
throw new Error([
|
|
229463
|
+
`Unable to patch ${path50.basename(bootstrapPath)} in ensureRestResourceBootstrapAnchors.`,
|
|
229464
|
+
`The existing ${registerFunctionName}() definition does not include ${REST_RESOURCE_SERVER_GLOB}.`,
|
|
229465
|
+
"Restore the generated bootstrap shape or wire the REST resource loader manually before retrying."
|
|
229466
|
+
].join(" "));
|
|
229467
|
+
}
|
|
229468
|
+
if (!nextSource.includes(registerHook)) {
|
|
229469
|
+
appendPhpSnippet(registerHook);
|
|
229470
|
+
}
|
|
229471
|
+
return nextSource;
|
|
229472
|
+
});
|
|
229473
|
+
}
|
|
229474
|
+
function assertSyncRestAnchor(nextSource, target, anchorDescription, hasAnchor, syncRestScriptPath) {
|
|
229475
|
+
if (!nextSource.includes(target) && !hasAnchor) {
|
|
229476
|
+
throw new Error([
|
|
229477
|
+
`ensureRestResourceSyncScriptAnchors could not patch ${path50.basename(syncRestScriptPath)}.`,
|
|
229478
|
+
`Missing expected ${anchorDescription} anchor in scripts/sync-rest-contracts.ts.`,
|
|
229479
|
+
"Restore the generated template or add the REST_RESOURCES wiring manually before retrying."
|
|
229480
|
+
].join(" "));
|
|
229481
|
+
}
|
|
229482
|
+
}
|
|
229483
|
+
function replaceRequiredSyncRestSource(nextSource, target, anchor, replacement, anchorDescription, syncRestScriptPath) {
|
|
229484
|
+
if (nextSource.includes(target)) {
|
|
229485
|
+
return nextSource;
|
|
229486
|
+
}
|
|
229487
|
+
const hasAnchor = typeof anchor === "string" ? nextSource.includes(anchor) : anchor.test(nextSource);
|
|
229488
|
+
assertSyncRestAnchor(nextSource, target, anchorDescription, hasAnchor, syncRestScriptPath);
|
|
229489
|
+
return nextSource.replace(anchor, replacement);
|
|
229490
|
+
}
|
|
229491
|
+
async function ensureRestResourceSyncScriptAnchors(workspace) {
|
|
229492
|
+
const syncRestScriptPath = path50.join(workspace.projectDir, "scripts", "sync-rest-contracts.ts");
|
|
229493
|
+
await patchFile(syncRestScriptPath, (source) => {
|
|
229494
|
+
let nextSource = source;
|
|
229495
|
+
const importAnchor = "import { BLOCKS, type WorkspaceBlockConfig } from './block-config';";
|
|
229496
|
+
const helperInsertionAnchor = "async function assertTypeArtifactsCurrent";
|
|
229497
|
+
const restBlocksAnchor = "const restBlocks = BLOCKS.filter( isRestEnabledBlock );";
|
|
229498
|
+
const noResourcesPattern = /if \( restBlocks.length === 0 \) \{[\s\S]*?\n\t\treturn;\n\t\}/u;
|
|
229499
|
+
const consoleLogPattern = /\n\tconsole\.log\(\n\t\toptions\.check/u;
|
|
229500
|
+
nextSource = replaceRequiredSyncRestSource(nextSource, "REST_RESOURCES", importAnchor, [
|
|
229501
|
+
"import {",
|
|
229502
|
+
"\tBLOCKS,",
|
|
229503
|
+
"\tREST_RESOURCES,",
|
|
229504
|
+
"\ttype WorkspaceBlockConfig,",
|
|
229505
|
+
"\ttype WorkspaceRestResourceConfig,",
|
|
229506
|
+
"} from './block-config';"
|
|
229507
|
+
].join(`
|
|
229508
|
+
`), "BLOCKS import", syncRestScriptPath);
|
|
229509
|
+
nextSource = replaceRequiredSyncRestSource(nextSource, "function isWorkspaceRestResource(", helperInsertionAnchor, [
|
|
229510
|
+
"function isWorkspaceRestResource(",
|
|
229511
|
+
"\tresource: WorkspaceRestResourceConfig",
|
|
229512
|
+
"): resource is WorkspaceRestResourceConfig & {",
|
|
229513
|
+
"\tclientFile: string;",
|
|
229514
|
+
"\topenApiFile: string;",
|
|
229515
|
+
"\trestManifest: NonNullable< WorkspaceRestResourceConfig[ 'restManifest' ] >;",
|
|
229516
|
+
"\ttypesFile: string;",
|
|
229517
|
+
"\tvalidatorsFile: string;",
|
|
229518
|
+
"} {",
|
|
229519
|
+
"\treturn (",
|
|
229520
|
+
"\t\ttypeof resource.clientFile === 'string' &&",
|
|
229521
|
+
"\t\ttypeof resource.openApiFile === 'string' &&",
|
|
229522
|
+
"\t\ttypeof resource.typesFile === 'string' &&",
|
|
229523
|
+
"\t\ttypeof resource.validatorsFile === 'string' &&",
|
|
229524
|
+
"\t\ttypeof resource.restManifest === 'object' &&",
|
|
229525
|
+
"\t\tresource.restManifest !== null",
|
|
229526
|
+
"\t);",
|
|
229527
|
+
"}",
|
|
229528
|
+
"",
|
|
229529
|
+
"async function assertTypeArtifactsCurrent"
|
|
229530
|
+
].join(`
|
|
229531
|
+
`), "type artifact assertion helper", syncRestScriptPath);
|
|
229532
|
+
nextSource = replaceRequiredSyncRestSource(nextSource, "const restResources = REST_RESOURCES.filter( isWorkspaceRestResource );", restBlocksAnchor, [
|
|
229533
|
+
"const restBlocks = BLOCKS.filter( isRestEnabledBlock );",
|
|
229534
|
+
"const restResources = REST_RESOURCES.filter( isWorkspaceRestResource );"
|
|
229535
|
+
].join(`
|
|
229536
|
+
`), "restBlocks filter", syncRestScriptPath);
|
|
229537
|
+
nextSource = replaceRequiredSyncRestSource(nextSource, "restBlocks.length === 0 && restResources.length === 0", noResourcesPattern, [
|
|
229538
|
+
"if ( restBlocks.length === 0 && restResources.length === 0 ) {",
|
|
229539
|
+
"\t\tconsole.log(",
|
|
229540
|
+
"\t\t\toptions.check",
|
|
229541
|
+
"\t\t\t\t? '\u2139\uFE0F No REST-enabled workspace blocks or plugin-level REST resources are registered yet. `sync-rest --check` is already clean.'",
|
|
229542
|
+
"\t\t\t\t: '\u2139\uFE0F No REST-enabled workspace blocks or plugin-level REST resources are registered yet.'",
|
|
229543
|
+
"\t\t);",
|
|
229544
|
+
"\t\treturn;",
|
|
229545
|
+
"\t}"
|
|
229546
|
+
].join(`
|
|
229547
|
+
`), "no-resources guard", syncRestScriptPath);
|
|
229548
|
+
nextSource = replaceRequiredSyncRestSource(nextSource, "for ( const resource of restResources ) {", consoleLogPattern, [
|
|
229549
|
+
"",
|
|
229550
|
+
"\tfor ( const resource of restResources ) {",
|
|
229551
|
+
"\t\tconst contracts = resource.restManifest.contracts;",
|
|
229552
|
+
"",
|
|
229553
|
+
"\t\tfor ( const [ baseName, contract ] of Object.entries( contracts ) ) {",
|
|
229554
|
+
"\t\t\tawait syncTypeSchemas(",
|
|
229555
|
+
"\t\t\t\t{",
|
|
229556
|
+
"\t\t\t\t\tjsonSchemaFile: path.join(",
|
|
229557
|
+
"\t\t\t\t\t\tpath.dirname( resource.typesFile ),",
|
|
229558
|
+
"\t\t\t\t\t\t'api-schemas',",
|
|
229559
|
+
"\t\t\t\t\t\t`${ baseName }.schema.json`",
|
|
229560
|
+
"\t\t\t\t\t),",
|
|
229561
|
+
"\t\t\t\t\topenApiFile: path.join(",
|
|
229562
|
+
"\t\t\t\t\t\tpath.dirname( resource.typesFile ),",
|
|
229563
|
+
"\t\t\t\t\t\t'api-schemas',",
|
|
229564
|
+
"\t\t\t\t\t\t`${ baseName }.openapi.json`",
|
|
229565
|
+
"\t\t\t\t\t),",
|
|
229566
|
+
"\t\t\t\t\tsourceTypeName: contract.sourceTypeName,",
|
|
229567
|
+
"\t\t\t\t\ttypesFile: resource.typesFile,",
|
|
229568
|
+
"\t\t\t\t},",
|
|
229569
|
+
"\t\t\t\t{",
|
|
229570
|
+
"\t\t\t\t\tcheck: options.check,",
|
|
229571
|
+
"\t\t\t\t}",
|
|
229572
|
+
"\t\t\t);",
|
|
229573
|
+
"\t\t}",
|
|
229574
|
+
"",
|
|
229575
|
+
"\t\tawait syncRestOpenApi(",
|
|
229576
|
+
"\t\t\t{",
|
|
229577
|
+
"\t\t\t\tmanifest: resource.restManifest,",
|
|
229578
|
+
"\t\t\t\topenApiFile: resource.openApiFile,",
|
|
229579
|
+
"\t\t\t\ttypesFile: resource.typesFile,",
|
|
229580
|
+
"\t\t\t},",
|
|
229581
|
+
"\t\t\t{",
|
|
229582
|
+
"\t\t\t\tcheck: options.check,",
|
|
229583
|
+
"\t\t\t}",
|
|
229584
|
+
"\t\t);",
|
|
229585
|
+
"",
|
|
229586
|
+
"\t\tawait syncEndpointClient(",
|
|
229587
|
+
"\t\t\t{",
|
|
229588
|
+
"\t\t\t\tclientFile: resource.clientFile,",
|
|
229589
|
+
"\t\t\t\tmanifest: resource.restManifest,",
|
|
229590
|
+
"\t\t\t\ttypesFile: resource.typesFile,",
|
|
229591
|
+
"\t\t\t\tvalidatorsFile: resource.validatorsFile,",
|
|
229592
|
+
"\t\t\t},",
|
|
229593
|
+
"\t\t\t{",
|
|
229594
|
+
"\t\t\t\tcheck: options.check,",
|
|
229595
|
+
"\t\t\t}",
|
|
229596
|
+
"\t\t);",
|
|
229597
|
+
"\t}",
|
|
229598
|
+
"",
|
|
229599
|
+
"\tconsole.log(",
|
|
229600
|
+
"\t\toptions.check"
|
|
229601
|
+
].join(`
|
|
229602
|
+
`), "success log insertion point", syncRestScriptPath);
|
|
229603
|
+
nextSource = nextSource.replace("\u2705 REST contract schemas, portable API clients, and endpoint-aware OpenAPI documents are already up to date with the TypeScript types!", "\u2705 REST contract schemas, portable API clients, and endpoint-aware OpenAPI documents are already up to date for workspace blocks and plugin-level resources!");
|
|
229604
|
+
nextSource = nextSource.replace("\u2705 REST contract schemas, portable API clients, and endpoint-aware OpenAPI documents generated from TypeScript types!", "\u2705 REST contract schemas, portable API clients, and endpoint-aware OpenAPI documents generated for workspace blocks and plugin-level resources!");
|
|
229605
|
+
return nextSource;
|
|
229606
|
+
});
|
|
229607
|
+
}
|
|
229608
|
+
var REST_RESOURCE_SERVER_GLOB = "/inc/rest/*.php";
|
|
229609
|
+
var init_cli_add_workspace_rest_anchors = __esm(() => {
|
|
229610
|
+
init_cli_add_shared();
|
|
229611
|
+
});
|
|
229612
|
+
|
|
229613
|
+
// ../wp-typia-project-tools/src/runtime/rest-resource-artifacts.ts
|
|
229614
|
+
import path51 from "path";
|
|
229403
229615
|
import {
|
|
229404
229616
|
defineEndpointManifest as defineEndpointManifest2,
|
|
229405
229617
|
syncEndpointClient as syncEndpointClient2,
|
|
@@ -229535,8 +229747,8 @@ async function syncRestResourceArtifacts({
|
|
|
229535
229747
|
const manifest = buildRestResourceEndpointManifest(variables, methods);
|
|
229536
229748
|
for (const [baseName, contract] of Object.entries(manifest.contracts)) {
|
|
229537
229749
|
await syncTypeSchemas2({
|
|
229538
|
-
jsonSchemaFile:
|
|
229539
|
-
openApiFile:
|
|
229750
|
+
jsonSchemaFile: path51.join(outputDir, "api-schemas", `${baseName}.schema.json`),
|
|
229751
|
+
openApiFile: path51.join(outputDir, "api-schemas", `${baseName}.openapi.json`),
|
|
229540
229752
|
projectRoot: projectDir,
|
|
229541
229753
|
sourceTypeName: contract.sourceTypeName,
|
|
229542
229754
|
typesFile
|
|
@@ -229544,7 +229756,7 @@ async function syncRestResourceArtifacts({
|
|
|
229544
229756
|
}
|
|
229545
229757
|
await syncRestOpenApi2({
|
|
229546
229758
|
manifest,
|
|
229547
|
-
openApiFile:
|
|
229759
|
+
openApiFile: path51.join(outputDir, "api.openapi.json"),
|
|
229548
229760
|
projectRoot: projectDir,
|
|
229549
229761
|
typesFile
|
|
229550
229762
|
});
|
|
@@ -229558,15 +229770,7 @@ async function syncRestResourceArtifacts({
|
|
|
229558
229770
|
}
|
|
229559
229771
|
var init_rest_resource_artifacts = () => {};
|
|
229560
229772
|
|
|
229561
|
-
// ../wp-typia-project-tools/src/runtime/cli-add-workspace-rest.ts
|
|
229562
|
-
import { promises as fsp18 } from "fs";
|
|
229563
|
-
import path51 from "path";
|
|
229564
|
-
function escapeRegex3(value2) {
|
|
229565
|
-
return value2.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
|
|
229566
|
-
}
|
|
229567
|
-
function quotePhpString2(value2) {
|
|
229568
|
-
return `'${value2.replace(/\\/gu, "\\\\").replace(/'/gu, "\\'")}'`;
|
|
229569
|
-
}
|
|
229773
|
+
// ../wp-typia-project-tools/src/runtime/cli-add-workspace-rest-source-emitters.ts
|
|
229570
229774
|
function toPascalCaseFromSlug2(slug) {
|
|
229571
229775
|
return normalizeBlockSlug(slug).split("-").filter(Boolean).map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1)).join("");
|
|
229572
229776
|
}
|
|
@@ -229789,21 +229993,7 @@ export function deleteResource( request: ${pascalCase}DeleteQuery ) {
|
|
|
229789
229993
|
return callEndpoint( restResourceDeleteEndpoint, request );
|
|
229790
229994
|
}`);
|
|
229791
229995
|
}
|
|
229792
|
-
|
|
229793
|
-
callEndpoint,
|
|
229794
|
-
resolveRestRouteUrl,
|
|
229795
|
-
} from '@wp-typia/rest';
|
|
229796
|
-
|
|
229797
|
-
import type {
|
|
229798
|
-
${Array.from(typeImports).sort().join(`,
|
|
229799
|
-
`)},
|
|
229800
|
-
} from './api-types';
|
|
229801
|
-
import {
|
|
229802
|
-
${clientEndpointImports.sort().join(`,
|
|
229803
|
-
`)},
|
|
229804
|
-
} from './api-client';
|
|
229805
|
-
${writeMethods.length > 0 ? `
|
|
229806
|
-
function resolveRestNonce( fallback?: string ): string | undefined {
|
|
229996
|
+
const resolveRestNonceSource = writeMethods.length > 0 ? `function resolveRestNonce( fallback?: string ): string | undefined {
|
|
229807
229997
|
if ( typeof fallback === 'string' && fallback.length > 0 ) {
|
|
229808
229998
|
return fallback;
|
|
229809
229999
|
}
|
|
@@ -229823,7 +230013,22 @@ function resolveRestNonce( fallback?: string ): string | undefined {
|
|
|
229823
230013
|
? wpApiSettings.nonce
|
|
229824
230014
|
: undefined;
|
|
229825
230015
|
}
|
|
229826
|
-
|
|
230016
|
+
|
|
230017
|
+
` : "";
|
|
230018
|
+
return `import {
|
|
230019
|
+
callEndpoint,
|
|
230020
|
+
resolveRestRouteUrl,
|
|
230021
|
+
} from '@wp-typia/rest';
|
|
230022
|
+
|
|
230023
|
+
import type {
|
|
230024
|
+
${Array.from(typeImports).sort().join(`,
|
|
230025
|
+
`)},
|
|
230026
|
+
} from './api-types';
|
|
230027
|
+
import {
|
|
230028
|
+
${clientEndpointImports.sort().join(`,
|
|
230029
|
+
`)},
|
|
230030
|
+
} from './api-client';
|
|
230031
|
+
${resolveRestNonceSource}
|
|
229827
230032
|
${exportedBindings.join(`
|
|
229828
230033
|
|
|
229829
230034
|
`)}
|
|
@@ -229949,6 +230154,17 @@ ${exportedBindings.join(`
|
|
|
229949
230154
|
`)}
|
|
229950
230155
|
`;
|
|
229951
230156
|
}
|
|
230157
|
+
var init_cli_add_workspace_rest_source_emitters = __esm(() => {
|
|
230158
|
+
init_cli_add_shared();
|
|
230159
|
+
init_rest_resource_artifacts();
|
|
230160
|
+
});
|
|
230161
|
+
|
|
230162
|
+
// ../wp-typia-project-tools/src/runtime/cli-add-workspace-rest.ts
|
|
230163
|
+
import { promises as fsp18 } from "fs";
|
|
230164
|
+
import path52 from "path";
|
|
230165
|
+
function quotePhpString2(value2) {
|
|
230166
|
+
return `'${value2.replace(/\\/gu, "\\\\").replace(/'/gu, "\\'")}'`;
|
|
230167
|
+
}
|
|
229952
230168
|
function buildRestResourceRouteRegistrations(restResourceSlug, methods, functions) {
|
|
229953
230169
|
const collectionRoutes = [];
|
|
229954
230170
|
const itemRoutes = [];
|
|
@@ -230366,198 +230582,6 @@ ${routeRegistrations}
|
|
|
230366
230582
|
add_action( 'rest_api_init', '${registerRoutesFunctionName}' );
|
|
230367
230583
|
`;
|
|
230368
230584
|
}
|
|
230369
|
-
async function ensureRestResourceBootstrapAnchors(workspace) {
|
|
230370
|
-
const bootstrapPath = getWorkspaceBootstrapPath(workspace);
|
|
230371
|
-
await patchFile(bootstrapPath, (source) => {
|
|
230372
|
-
let nextSource = source;
|
|
230373
|
-
const registerFunctionName = `${workspace.workspace.phpPrefix}_register_rest_resources`;
|
|
230374
|
-
const registerHook = `add_action( 'init', '${registerFunctionName}', 20 );`;
|
|
230375
|
-
const registerFunction = `
|
|
230376
|
-
|
|
230377
|
-
function ${registerFunctionName}() {
|
|
230378
|
-
foreach ( glob( __DIR__ . '${REST_RESOURCE_SERVER_GLOB}' ) ?: array() as $rest_resource_module ) {
|
|
230379
|
-
require_once $rest_resource_module;
|
|
230380
|
-
}
|
|
230381
|
-
}
|
|
230382
|
-
`;
|
|
230383
|
-
const insertionAnchors = [
|
|
230384
|
-
/add_action\(\s*["']init["']\s*,\s*["'][^"']+_load_textdomain["']\s*\);\s*\n/u,
|
|
230385
|
-
/\?>\s*$/u
|
|
230386
|
-
];
|
|
230387
|
-
const hasPhpFunctionDefinition = (functionName) => new RegExp(`function\\s+${escapeRegex3(functionName)}\\s*\\(`, "u").test(nextSource);
|
|
230388
|
-
const insertPhpSnippet = (snippet) => {
|
|
230389
|
-
for (const anchor of insertionAnchors) {
|
|
230390
|
-
const candidate = nextSource.replace(anchor, (match3) => `${snippet}
|
|
230391
|
-
${match3}`);
|
|
230392
|
-
if (candidate !== nextSource) {
|
|
230393
|
-
nextSource = candidate;
|
|
230394
|
-
return;
|
|
230395
|
-
}
|
|
230396
|
-
}
|
|
230397
|
-
nextSource = `${nextSource.trimEnd()}
|
|
230398
|
-
${snippet}
|
|
230399
|
-
`;
|
|
230400
|
-
};
|
|
230401
|
-
const appendPhpSnippet = (snippet) => {
|
|
230402
|
-
const closingTagPattern = /\?>\s*$/u;
|
|
230403
|
-
if (closingTagPattern.test(nextSource)) {
|
|
230404
|
-
nextSource = nextSource.replace(closingTagPattern, `${snippet}
|
|
230405
|
-
?>`);
|
|
230406
|
-
return;
|
|
230407
|
-
}
|
|
230408
|
-
nextSource = `${nextSource.trimEnd()}
|
|
230409
|
-
${snippet}
|
|
230410
|
-
`;
|
|
230411
|
-
};
|
|
230412
|
-
if (!hasPhpFunctionDefinition(registerFunctionName)) {
|
|
230413
|
-
insertPhpSnippet(registerFunction);
|
|
230414
|
-
} else if (!nextSource.includes(REST_RESOURCE_SERVER_GLOB)) {
|
|
230415
|
-
throw new Error([
|
|
230416
|
-
`Unable to patch ${path51.basename(bootstrapPath)} in ensureRestResourceBootstrapAnchors.`,
|
|
230417
|
-
`The existing ${registerFunctionName}() definition does not include ${REST_RESOURCE_SERVER_GLOB}.`,
|
|
230418
|
-
"Restore the generated bootstrap shape or wire the REST resource loader manually before retrying."
|
|
230419
|
-
].join(" "));
|
|
230420
|
-
}
|
|
230421
|
-
if (!nextSource.includes(registerHook)) {
|
|
230422
|
-
appendPhpSnippet(registerHook);
|
|
230423
|
-
}
|
|
230424
|
-
return nextSource;
|
|
230425
|
-
});
|
|
230426
|
-
}
|
|
230427
|
-
function assertSyncRestAnchor(nextSource, target, anchorDescription, hasAnchor, syncRestScriptPath) {
|
|
230428
|
-
if (!nextSource.includes(target) && !hasAnchor) {
|
|
230429
|
-
throw new Error([
|
|
230430
|
-
`ensureRestResourceSyncScriptAnchors could not patch ${path51.basename(syncRestScriptPath)}.`,
|
|
230431
|
-
`Missing expected ${anchorDescription} anchor in scripts/sync-rest-contracts.ts.`,
|
|
230432
|
-
"Restore the generated template or add the REST_RESOURCES wiring manually before retrying."
|
|
230433
|
-
].join(" "));
|
|
230434
|
-
}
|
|
230435
|
-
}
|
|
230436
|
-
function replaceRequiredSyncRestSource(nextSource, target, anchor, replacement, anchorDescription, syncRestScriptPath) {
|
|
230437
|
-
if (nextSource.includes(target)) {
|
|
230438
|
-
return nextSource;
|
|
230439
|
-
}
|
|
230440
|
-
const hasAnchor = typeof anchor === "string" ? nextSource.includes(anchor) : anchor.test(nextSource);
|
|
230441
|
-
assertSyncRestAnchor(nextSource, target, anchorDescription, hasAnchor, syncRestScriptPath);
|
|
230442
|
-
return nextSource.replace(anchor, replacement);
|
|
230443
|
-
}
|
|
230444
|
-
async function ensureRestResourceSyncScriptAnchors(workspace) {
|
|
230445
|
-
const syncRestScriptPath = path51.join(workspace.projectDir, "scripts", "sync-rest-contracts.ts");
|
|
230446
|
-
await patchFile(syncRestScriptPath, (source) => {
|
|
230447
|
-
let nextSource = source;
|
|
230448
|
-
const importAnchor = "import { BLOCKS, type WorkspaceBlockConfig } from './block-config';";
|
|
230449
|
-
const helperInsertionAnchor = "async function assertTypeArtifactsCurrent";
|
|
230450
|
-
const restBlocksAnchor = "const restBlocks = BLOCKS.filter( isRestEnabledBlock );";
|
|
230451
|
-
const noResourcesPattern = /if \( restBlocks.length === 0 \) \{[\s\S]*?\n\t\treturn;\n\t\}/u;
|
|
230452
|
-
const consoleLogPattern = /\n\tconsole\.log\(\n\t\toptions\.check/u;
|
|
230453
|
-
nextSource = replaceRequiredSyncRestSource(nextSource, "REST_RESOURCES", importAnchor, [
|
|
230454
|
-
"import {",
|
|
230455
|
-
"\tBLOCKS,",
|
|
230456
|
-
"\tREST_RESOURCES,",
|
|
230457
|
-
"\ttype WorkspaceBlockConfig,",
|
|
230458
|
-
"\ttype WorkspaceRestResourceConfig,",
|
|
230459
|
-
"} from './block-config';"
|
|
230460
|
-
].join(`
|
|
230461
|
-
`), "BLOCKS import", syncRestScriptPath);
|
|
230462
|
-
nextSource = replaceRequiredSyncRestSource(nextSource, "function isWorkspaceRestResource(", helperInsertionAnchor, [
|
|
230463
|
-
"function isWorkspaceRestResource(",
|
|
230464
|
-
"\tresource: WorkspaceRestResourceConfig",
|
|
230465
|
-
"): resource is WorkspaceRestResourceConfig & {",
|
|
230466
|
-
"\tclientFile: string;",
|
|
230467
|
-
"\topenApiFile: string;",
|
|
230468
|
-
"\trestManifest: NonNullable< WorkspaceRestResourceConfig[ 'restManifest' ] >;",
|
|
230469
|
-
"\ttypesFile: string;",
|
|
230470
|
-
"\tvalidatorsFile: string;",
|
|
230471
|
-
"} {",
|
|
230472
|
-
"\treturn (",
|
|
230473
|
-
"\t\ttypeof resource.clientFile === 'string' &&",
|
|
230474
|
-
"\t\ttypeof resource.openApiFile === 'string' &&",
|
|
230475
|
-
"\t\ttypeof resource.typesFile === 'string' &&",
|
|
230476
|
-
"\t\ttypeof resource.validatorsFile === 'string' &&",
|
|
230477
|
-
"\t\ttypeof resource.restManifest === 'object' &&",
|
|
230478
|
-
"\t\tresource.restManifest !== null",
|
|
230479
|
-
"\t);",
|
|
230480
|
-
"}",
|
|
230481
|
-
"",
|
|
230482
|
-
"async function assertTypeArtifactsCurrent"
|
|
230483
|
-
].join(`
|
|
230484
|
-
`), "type artifact assertion helper", syncRestScriptPath);
|
|
230485
|
-
nextSource = replaceRequiredSyncRestSource(nextSource, "const restResources = REST_RESOURCES.filter( isWorkspaceRestResource );", restBlocksAnchor, [
|
|
230486
|
-
"const restBlocks = BLOCKS.filter( isRestEnabledBlock );",
|
|
230487
|
-
"const restResources = REST_RESOURCES.filter( isWorkspaceRestResource );"
|
|
230488
|
-
].join(`
|
|
230489
|
-
`), "restBlocks filter", syncRestScriptPath);
|
|
230490
|
-
nextSource = replaceRequiredSyncRestSource(nextSource, "restBlocks.length === 0 && restResources.length === 0", noResourcesPattern, [
|
|
230491
|
-
"if ( restBlocks.length === 0 && restResources.length === 0 ) {",
|
|
230492
|
-
"\t\tconsole.log(",
|
|
230493
|
-
"\t\t\toptions.check",
|
|
230494
|
-
"\t\t\t\t? '\u2139\uFE0F No REST-enabled workspace blocks or plugin-level REST resources are registered yet. `sync-rest --check` is already clean.'",
|
|
230495
|
-
"\t\t\t\t: '\u2139\uFE0F No REST-enabled workspace blocks or plugin-level REST resources are registered yet.'",
|
|
230496
|
-
"\t\t);",
|
|
230497
|
-
"\t\treturn;",
|
|
230498
|
-
"\t}"
|
|
230499
|
-
].join(`
|
|
230500
|
-
`), "no-resources guard", syncRestScriptPath);
|
|
230501
|
-
nextSource = replaceRequiredSyncRestSource(nextSource, "for ( const resource of restResources ) {", consoleLogPattern, [
|
|
230502
|
-
"",
|
|
230503
|
-
"\tfor ( const resource of restResources ) {",
|
|
230504
|
-
"\t\tconst contracts = resource.restManifest.contracts;",
|
|
230505
|
-
"",
|
|
230506
|
-
"\t\tfor ( const [ baseName, contract ] of Object.entries( contracts ) ) {",
|
|
230507
|
-
"\t\t\tawait syncTypeSchemas(",
|
|
230508
|
-
"\t\t\t\t{",
|
|
230509
|
-
"\t\t\t\t\tjsonSchemaFile: path.join(",
|
|
230510
|
-
"\t\t\t\t\t\tpath.dirname( resource.typesFile ),",
|
|
230511
|
-
"\t\t\t\t\t\t'api-schemas',",
|
|
230512
|
-
"\t\t\t\t\t\t`${ baseName }.schema.json`",
|
|
230513
|
-
"\t\t\t\t\t),",
|
|
230514
|
-
"\t\t\t\t\topenApiFile: path.join(",
|
|
230515
|
-
"\t\t\t\t\t\tpath.dirname( resource.typesFile ),",
|
|
230516
|
-
"\t\t\t\t\t\t'api-schemas',",
|
|
230517
|
-
"\t\t\t\t\t\t`${ baseName }.openapi.json`",
|
|
230518
|
-
"\t\t\t\t\t),",
|
|
230519
|
-
"\t\t\t\t\tsourceTypeName: contract.sourceTypeName,",
|
|
230520
|
-
"\t\t\t\t\ttypesFile: resource.typesFile,",
|
|
230521
|
-
"\t\t\t\t},",
|
|
230522
|
-
"\t\t\t\t{",
|
|
230523
|
-
"\t\t\t\t\tcheck: options.check,",
|
|
230524
|
-
"\t\t\t\t}",
|
|
230525
|
-
"\t\t\t);",
|
|
230526
|
-
"\t\t}",
|
|
230527
|
-
"",
|
|
230528
|
-
"\t\tawait syncRestOpenApi(",
|
|
230529
|
-
"\t\t\t{",
|
|
230530
|
-
"\t\t\t\tmanifest: resource.restManifest,",
|
|
230531
|
-
"\t\t\t\topenApiFile: resource.openApiFile,",
|
|
230532
|
-
"\t\t\t\ttypesFile: resource.typesFile,",
|
|
230533
|
-
"\t\t\t},",
|
|
230534
|
-
"\t\t\t{",
|
|
230535
|
-
"\t\t\t\tcheck: options.check,",
|
|
230536
|
-
"\t\t\t}",
|
|
230537
|
-
"\t\t);",
|
|
230538
|
-
"",
|
|
230539
|
-
"\t\tawait syncEndpointClient(",
|
|
230540
|
-
"\t\t\t{",
|
|
230541
|
-
"\t\t\t\tclientFile: resource.clientFile,",
|
|
230542
|
-
"\t\t\t\tmanifest: resource.restManifest,",
|
|
230543
|
-
"\t\t\t\ttypesFile: resource.typesFile,",
|
|
230544
|
-
"\t\t\t\tvalidatorsFile: resource.validatorsFile,",
|
|
230545
|
-
"\t\t\t},",
|
|
230546
|
-
"\t\t\t{",
|
|
230547
|
-
"\t\t\t\tcheck: options.check,",
|
|
230548
|
-
"\t\t\t}",
|
|
230549
|
-
"\t\t);",
|
|
230550
|
-
"\t}",
|
|
230551
|
-
"",
|
|
230552
|
-
"\tconsole.log(",
|
|
230553
|
-
"\t\toptions.check"
|
|
230554
|
-
].join(`
|
|
230555
|
-
`), "success log insertion point", syncRestScriptPath);
|
|
230556
|
-
nextSource = nextSource.replace("\u2705 REST contract schemas, portable API clients, and endpoint-aware OpenAPI documents are already up to date with the TypeScript types!", "\u2705 REST contract schemas, portable API clients, and endpoint-aware OpenAPI documents are already up to date for workspace blocks and plugin-level resources!");
|
|
230557
|
-
nextSource = nextSource.replace("\u2705 REST contract schemas, portable API clients, and endpoint-aware OpenAPI documents generated from TypeScript types!", "\u2705 REST contract schemas, portable API clients, and endpoint-aware OpenAPI documents generated for workspace blocks and plugin-level resources!");
|
|
230558
|
-
return nextSource;
|
|
230559
|
-
});
|
|
230560
|
-
}
|
|
230561
230585
|
async function runAddRestResourceCommand({
|
|
230562
230586
|
cwd = process.cwd(),
|
|
230563
230587
|
methods,
|
|
@@ -230570,16 +230594,16 @@ async function runAddRestResourceCommand({
|
|
|
230570
230594
|
const resolvedNamespace = resolveRestResourceNamespace(workspace.workspace.namespace, namespace);
|
|
230571
230595
|
const inventory = readWorkspaceInventory(workspace.projectDir);
|
|
230572
230596
|
assertRestResourceDoesNotExist(workspace.projectDir, restResourceSlug, inventory);
|
|
230573
|
-
const blockConfigPath =
|
|
230597
|
+
const blockConfigPath = path52.join(workspace.projectDir, "scripts", "block-config.ts");
|
|
230574
230598
|
const bootstrapPath = getWorkspaceBootstrapPath(workspace);
|
|
230575
|
-
const syncRestScriptPath =
|
|
230576
|
-
const restResourceDir =
|
|
230577
|
-
const typesFilePath =
|
|
230578
|
-
const validatorsFilePath =
|
|
230579
|
-
const apiFilePath =
|
|
230580
|
-
const dataFilePath =
|
|
230581
|
-
const clientFilePath =
|
|
230582
|
-
const phpFilePath =
|
|
230599
|
+
const syncRestScriptPath = path52.join(workspace.projectDir, "scripts", "sync-rest-contracts.ts");
|
|
230600
|
+
const restResourceDir = path52.join(workspace.projectDir, "src", "rest", restResourceSlug);
|
|
230601
|
+
const typesFilePath = path52.join(restResourceDir, "api-types.ts");
|
|
230602
|
+
const validatorsFilePath = path52.join(restResourceDir, "api-validators.ts");
|
|
230603
|
+
const apiFilePath = path52.join(restResourceDir, "api.ts");
|
|
230604
|
+
const dataFilePath = path52.join(restResourceDir, "data.ts");
|
|
230605
|
+
const clientFilePath = path52.join(restResourceDir, "api-client.ts");
|
|
230606
|
+
const phpFilePath = path52.join(workspace.projectDir, "inc", "rest", `${restResourceSlug}.php`);
|
|
230583
230607
|
const mutationSnapshot = {
|
|
230584
230608
|
fileSources: await snapshotWorkspaceFiles([
|
|
230585
230609
|
blockConfigPath,
|
|
@@ -230591,7 +230615,7 @@ async function runAddRestResourceCommand({
|
|
|
230591
230615
|
};
|
|
230592
230616
|
try {
|
|
230593
230617
|
await fsp18.mkdir(restResourceDir, { recursive: true });
|
|
230594
|
-
await fsp18.mkdir(
|
|
230618
|
+
await fsp18.mkdir(path52.dirname(phpFilePath), { recursive: true });
|
|
230595
230619
|
await ensureRestResourceBootstrapAnchors(workspace);
|
|
230596
230620
|
await ensureRestResourceSyncScriptAnchors(workspace);
|
|
230597
230621
|
await fsp18.writeFile(typesFilePath, buildRestResourceTypesSource(restResourceSlug, resolvedMethods), "utf8");
|
|
@@ -230630,10 +230654,11 @@ async function runAddRestResourceCommand({
|
|
|
230630
230654
|
throw error48;
|
|
230631
230655
|
}
|
|
230632
230656
|
}
|
|
230633
|
-
var REST_RESOURCE_SERVER_GLOB = "/inc/rest/*.php";
|
|
230634
230657
|
var init_cli_add_workspace_rest = __esm(() => {
|
|
230635
230658
|
init_cli_add_block_legacy_validator();
|
|
230636
230659
|
init_cli_add_shared();
|
|
230660
|
+
init_cli_add_workspace_rest_anchors();
|
|
230661
|
+
init_cli_add_workspace_rest_source_emitters();
|
|
230637
230662
|
init_rest_resource_artifacts();
|
|
230638
230663
|
init_workspace_inventory();
|
|
230639
230664
|
init_workspace_project();
|
|
@@ -230642,7 +230667,7 @@ var init_cli_add_workspace_rest = __esm(() => {
|
|
|
230642
230667
|
// ../wp-typia-project-tools/src/runtime/cli-add-workspace.ts
|
|
230643
230668
|
import fs41 from "fs";
|
|
230644
230669
|
import { promises as fsp19 } from "fs";
|
|
230645
|
-
import
|
|
230670
|
+
import path53 from "path";
|
|
230646
230671
|
function buildVariationConfigEntry(blockSlug, variationSlug) {
|
|
230647
230672
|
return [
|
|
230648
230673
|
"\t{",
|
|
@@ -230743,14 +230768,14 @@ ${VARIATIONS_CALL_LINE}
|
|
|
230743
230768
|
}
|
|
230744
230769
|
}
|
|
230745
230770
|
if (!nextSource.includes(VARIATIONS_CALL_LINE)) {
|
|
230746
|
-
throw new Error(`Unable to inject ${VARIATIONS_CALL_LINE} into ${
|
|
230771
|
+
throw new Error(`Unable to inject ${VARIATIONS_CALL_LINE} into ${path53.basename(blockIndexPath)}.`);
|
|
230747
230772
|
}
|
|
230748
230773
|
return nextSource;
|
|
230749
230774
|
});
|
|
230750
230775
|
}
|
|
230751
230776
|
async function writeVariationRegistry(projectDir, blockSlug, variationSlug) {
|
|
230752
|
-
const variationsDir =
|
|
230753
|
-
const variationsIndexPath =
|
|
230777
|
+
const variationsDir = path53.join(projectDir, "src", "blocks", blockSlug, "variations");
|
|
230778
|
+
const variationsIndexPath = path53.join(variationsDir, "index.ts");
|
|
230754
230779
|
await fsp19.mkdir(variationsDir, { recursive: true });
|
|
230755
230780
|
const existingVariationSlugs = fs41.readdirSync(variationsDir).filter((entry) => entry.endsWith(".ts") && entry !== "index.ts").map((entry) => entry.replace(/\.ts$/u, ""));
|
|
230756
230781
|
const nextVariationSlugs = Array.from(new Set([...existingVariationSlugs, variationSlug])).sort();
|
|
@@ -230767,11 +230792,11 @@ async function runAddVariationCommand({
|
|
|
230767
230792
|
const inventory = readWorkspaceInventory(workspace.projectDir);
|
|
230768
230793
|
resolveWorkspaceBlock(inventory, blockSlug);
|
|
230769
230794
|
assertVariationDoesNotExist(workspace.projectDir, blockSlug, variationSlug, inventory);
|
|
230770
|
-
const blockConfigPath =
|
|
230771
|
-
const blockIndexPath =
|
|
230772
|
-
const variationsDir =
|
|
230773
|
-
const variationFilePath =
|
|
230774
|
-
const variationsIndexPath =
|
|
230795
|
+
const blockConfigPath = path53.join(workspace.projectDir, "scripts", "block-config.ts");
|
|
230796
|
+
const blockIndexPath = path53.join(workspace.projectDir, "src", "blocks", blockSlug, "index.tsx");
|
|
230797
|
+
const variationsDir = path53.join(workspace.projectDir, "src", "blocks", blockSlug, "variations");
|
|
230798
|
+
const variationFilePath = path53.join(variationsDir, `${variationSlug}.ts`);
|
|
230799
|
+
const variationsIndexPath = path53.join(variationsDir, "index.ts");
|
|
230775
230800
|
const mutationSnapshot = {
|
|
230776
230801
|
fileSources: await snapshotWorkspaceFiles([
|
|
230777
230802
|
blockConfigPath,
|
|
@@ -230816,7 +230841,7 @@ async function runAddHookedBlockCommand({
|
|
|
230816
230841
|
throw new Error("`wp-typia add hooked-block` cannot hook a block relative to its own block name.");
|
|
230817
230842
|
}
|
|
230818
230843
|
const { blockJson, blockJsonPath } = readWorkspaceBlockJson(workspace.projectDir, blockSlug);
|
|
230819
|
-
const blockJsonRelativePath =
|
|
230844
|
+
const blockJsonRelativePath = path53.relative(workspace.projectDir, blockJsonPath);
|
|
230820
230845
|
const blockHooks = getMutableBlockHooks(blockJson, blockJsonRelativePath);
|
|
230821
230846
|
if (Object.prototype.hasOwnProperty.call(blockHooks, resolvedAnchorBlockName)) {
|
|
230822
230847
|
throw new Error(`${blockJsonRelativePath} already defines a blockHooks entry for "${resolvedAnchorBlockName}".`);
|
|
@@ -231148,7 +231173,7 @@ import { execFileSync as execFileSync4 } from "child_process";
|
|
|
231148
231173
|
import { access, constants as fsConstants, rm as rm2, writeFile as writeFile5 } from "fs/promises";
|
|
231149
231174
|
import fs42 from "fs";
|
|
231150
231175
|
import os4 from "os";
|
|
231151
|
-
import
|
|
231176
|
+
import path54 from "path";
|
|
231152
231177
|
function readCommandVersion(command, args = ["--version"]) {
|
|
231153
231178
|
try {
|
|
231154
231179
|
return execFileSync4(command, args, {
|
|
@@ -231172,7 +231197,7 @@ async function checkWritableDirectory(directory) {
|
|
|
231172
231197
|
}
|
|
231173
231198
|
}
|
|
231174
231199
|
async function checkTempDirectory() {
|
|
231175
|
-
const tempFile =
|
|
231200
|
+
const tempFile = path54.join(os4.tmpdir(), `wp-typia-${Date.now()}.tmp`);
|
|
231176
231201
|
try {
|
|
231177
231202
|
await writeFile5(tempFile, "ok", "utf8");
|
|
231178
231203
|
await rm2(tempFile, { force: true });
|
|
@@ -231189,7 +231214,7 @@ function getTemplateDoctorChecks() {
|
|
|
231189
231214
|
for (const template of listTemplates()) {
|
|
231190
231215
|
if (!isBuiltInTemplateId(template.id)) {
|
|
231191
231216
|
const templateDirExists = fs42.existsSync(template.templateDir);
|
|
231192
|
-
const hasAssets2 = templateDirExists && fs42.existsSync(
|
|
231217
|
+
const hasAssets2 = templateDirExists && fs42.existsSync(path54.join(template.templateDir, "package.json.mustache"));
|
|
231193
231218
|
checks3.push({
|
|
231194
231219
|
status: !templateDirExists || hasAssets2 ? "pass" : "fail",
|
|
231195
231220
|
label: `Template ${template.id}`,
|
|
@@ -231214,7 +231239,7 @@ function getTemplateDoctorChecks() {
|
|
|
231214
231239
|
])) : getBuiltInTemplateLayerDirs(builtInTemplateId);
|
|
231215
231240
|
const missingRequiredLayer = layerDirs.some((layerDir) => !fs42.existsSync(layerDir) && !isOmittableBuiltInTemplateLayerDir(builtInTemplateId, layerDir));
|
|
231216
231241
|
const existingLayerDirs = layerDirs.filter((layerDir) => fs42.existsSync(layerDir));
|
|
231217
|
-
const hasAssets = !missingRequiredLayer && existingLayerDirs.some((layerDir) => fs42.existsSync(
|
|
231242
|
+
const hasAssets = !missingRequiredLayer && existingLayerDirs.some((layerDir) => fs42.existsSync(path54.join(layerDir, "package.json.mustache"))) && existingLayerDirs.some((layerDir) => fs42.existsSync(path54.join(layerDir, "src")));
|
|
231218
231243
|
checks3.push({
|
|
231219
231244
|
status: hasAssets ? "pass" : "fail",
|
|
231220
231245
|
label: `Template ${template.id}`,
|
|
@@ -231245,7 +231270,7 @@ var init_cli_doctor_environment = __esm(() => {
|
|
|
231245
231270
|
|
|
231246
231271
|
// ../wp-typia-project-tools/src/runtime/cli-doctor-workspace.ts
|
|
231247
231272
|
import fs43 from "fs";
|
|
231248
|
-
import
|
|
231273
|
+
import path55 from "path";
|
|
231249
231274
|
import { parseScaffoldBlockMetadata as parseScaffoldBlockMetadata2 } from "@wp-typia/block-runtime/blocks";
|
|
231250
231275
|
function createDoctorCheck2(label, status, detail) {
|
|
231251
231276
|
return { detail, label, status };
|
|
@@ -231261,7 +231286,7 @@ function getWorkspaceBootstrapRelativePath(packageName) {
|
|
|
231261
231286
|
return `${packageBaseName}.php`;
|
|
231262
231287
|
}
|
|
231263
231288
|
function checkExistingFiles(projectDir, label, filePaths) {
|
|
231264
|
-
const missing = filePaths.filter((filePath) => typeof filePath === "string").filter((filePath) => !fs43.existsSync(
|
|
231289
|
+
const missing = filePaths.filter((filePath) => typeof filePath === "string").filter((filePath) => !fs43.existsSync(path55.join(projectDir, filePath)));
|
|
231265
231290
|
return createDoctorCheck2(label, missing.length === 0 ? "pass" : "fail", missing.length === 0 ? "All referenced files exist" : `Missing: ${missing.join(", ")}`);
|
|
231266
231291
|
}
|
|
231267
231292
|
function checkWorkspacePackageMetadata(workspace, packageJson) {
|
|
@@ -231287,24 +231312,24 @@ function checkWorkspacePackageMetadata(workspace, packageJson) {
|
|
|
231287
231312
|
if (wpTypia?.phpPrefix !== workspace.workspace.phpPrefix) {
|
|
231288
231313
|
issues.push(`wpTypia.phpPrefix must equal "${workspace.workspace.phpPrefix}"`);
|
|
231289
231314
|
}
|
|
231290
|
-
if (!fs43.existsSync(
|
|
231315
|
+
if (!fs43.existsSync(path55.join(workspace.projectDir, bootstrapRelativePath))) {
|
|
231291
231316
|
issues.push(`Missing bootstrap file ${bootstrapRelativePath}`);
|
|
231292
231317
|
}
|
|
231293
231318
|
return createDoctorCheck2("Workspace package metadata", issues.length === 0 ? "pass" : "fail", issues.length === 0 ? `package.json metadata aligns with ${workspace.packageName} and ${bootstrapRelativePath}` : issues.join("; "));
|
|
231294
231319
|
}
|
|
231295
231320
|
function getWorkspaceBlockRequiredFiles(block) {
|
|
231296
|
-
const blockDir =
|
|
231321
|
+
const blockDir = path55.join("src", "blocks", block.slug);
|
|
231297
231322
|
return Array.from(new Set([
|
|
231298
231323
|
block.typesFile,
|
|
231299
231324
|
block.apiTypesFile,
|
|
231300
231325
|
block.openApiFile,
|
|
231301
|
-
|
|
231302
|
-
...WORKSPACE_GENERATED_BLOCK_ARTIFACTS.map((fileName) =>
|
|
231326
|
+
path55.join(blockDir, "index.tsx"),
|
|
231327
|
+
...WORKSPACE_GENERATED_BLOCK_ARTIFACTS.map((fileName) => path55.join(blockDir, fileName))
|
|
231303
231328
|
].filter((filePath) => typeof filePath === "string")));
|
|
231304
231329
|
}
|
|
231305
231330
|
function checkWorkspaceBlockMetadata(projectDir, workspace, block) {
|
|
231306
|
-
const blockJsonRelativePath =
|
|
231307
|
-
const blockJsonPath =
|
|
231331
|
+
const blockJsonRelativePath = path55.join("src", "blocks", block.slug, "block.json");
|
|
231332
|
+
const blockJsonPath = path55.join(projectDir, blockJsonRelativePath);
|
|
231308
231333
|
if (!fs43.existsSync(blockJsonPath)) {
|
|
231309
231334
|
return createDoctorCheck2(`Block metadata ${block.slug}`, "fail", `Missing ${blockJsonRelativePath}`);
|
|
231310
231335
|
}
|
|
@@ -231325,8 +231350,8 @@ function checkWorkspaceBlockMetadata(projectDir, workspace, block) {
|
|
|
231325
231350
|
return createDoctorCheck2(`Block metadata ${block.slug}`, issues.length === 0 ? "pass" : "fail", issues.length === 0 ? `block.json matches ${expectedName} and ${workspace.workspace.textDomain}` : issues.join("; "));
|
|
231326
231351
|
}
|
|
231327
231352
|
function checkWorkspaceBlockHooks(projectDir, blockSlug) {
|
|
231328
|
-
const blockJsonRelativePath =
|
|
231329
|
-
const blockJsonPath =
|
|
231353
|
+
const blockJsonRelativePath = path55.join("src", "blocks", blockSlug, "block.json");
|
|
231354
|
+
const blockJsonPath = path55.join(projectDir, blockJsonRelativePath);
|
|
231330
231355
|
if (!fs43.existsSync(blockJsonPath)) {
|
|
231331
231356
|
return createDoctorCheck2(`Block hooks ${blockSlug}`, "fail", `Missing ${blockJsonRelativePath}`);
|
|
231332
231357
|
}
|
|
@@ -231348,8 +231373,8 @@ function checkWorkspaceBlockHooks(projectDir, blockSlug) {
|
|
|
231348
231373
|
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(", ")}`);
|
|
231349
231374
|
}
|
|
231350
231375
|
function checkWorkspaceBlockCollectionImport(projectDir, blockSlug) {
|
|
231351
|
-
const entryRelativePath =
|
|
231352
|
-
const entryPath =
|
|
231376
|
+
const entryRelativePath = path55.join("src", "blocks", blockSlug, "index.tsx");
|
|
231377
|
+
const entryPath = path55.join(projectDir, entryRelativePath);
|
|
231353
231378
|
if (!fs43.existsSync(entryPath)) {
|
|
231354
231379
|
return createDoctorCheck2(`Block collection ${blockSlug}`, "fail", `Missing ${entryRelativePath}`);
|
|
231355
231380
|
}
|
|
@@ -231359,9 +231384,9 @@ function checkWorkspaceBlockCollectionImport(projectDir, blockSlug) {
|
|
|
231359
231384
|
}
|
|
231360
231385
|
function checkWorkspacePatternBootstrap(projectDir, packageName) {
|
|
231361
231386
|
const packageBaseName = packageName.split("/").pop() ?? packageName;
|
|
231362
|
-
const bootstrapPath =
|
|
231387
|
+
const bootstrapPath = path55.join(projectDir, `${packageBaseName}.php`);
|
|
231363
231388
|
if (!fs43.existsSync(bootstrapPath)) {
|
|
231364
|
-
return createDoctorCheck2("Pattern bootstrap", "fail", `Missing ${
|
|
231389
|
+
return createDoctorCheck2("Pattern bootstrap", "fail", `Missing ${path55.basename(bootstrapPath)}`);
|
|
231365
231390
|
}
|
|
231366
231391
|
const source = fs43.readFileSync(bootstrapPath, "utf8");
|
|
231367
231392
|
const hasCategoryAnchor = source.includes("register_block_pattern_category");
|
|
@@ -231370,9 +231395,9 @@ function checkWorkspacePatternBootstrap(projectDir, packageName) {
|
|
|
231370
231395
|
}
|
|
231371
231396
|
function checkWorkspaceBindingBootstrap(projectDir, packageName) {
|
|
231372
231397
|
const packageBaseName = packageName.split("/").pop() ?? packageName;
|
|
231373
|
-
const bootstrapPath =
|
|
231398
|
+
const bootstrapPath = path55.join(projectDir, `${packageBaseName}.php`);
|
|
231374
231399
|
if (!fs43.existsSync(bootstrapPath)) {
|
|
231375
|
-
return createDoctorCheck2("Binding bootstrap", "fail", `Missing ${
|
|
231400
|
+
return createDoctorCheck2("Binding bootstrap", "fail", `Missing ${path55.basename(bootstrapPath)}`);
|
|
231376
231401
|
}
|
|
231377
231402
|
const source = fs43.readFileSync(bootstrapPath, "utf8");
|
|
231378
231403
|
const hasServerGlob = source.includes(WORKSPACE_BINDING_SERVER_GLOB);
|
|
@@ -231382,11 +231407,11 @@ function checkWorkspaceBindingBootstrap(projectDir, packageName) {
|
|
|
231382
231407
|
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");
|
|
231383
231408
|
}
|
|
231384
231409
|
function checkWorkspaceBindingSourcesIndex(projectDir, bindingSources) {
|
|
231385
|
-
const indexRelativePath = [
|
|
231410
|
+
const indexRelativePath = [path55.join("src", "bindings", "index.ts"), path55.join("src", "bindings", "index.js")].find((relativePath) => fs43.existsSync(path55.join(projectDir, relativePath)));
|
|
231386
231411
|
if (!indexRelativePath) {
|
|
231387
231412
|
return createDoctorCheck2("Binding sources index", "fail", "Missing src/bindings/index.ts or src/bindings/index.js");
|
|
231388
231413
|
}
|
|
231389
|
-
const indexPath =
|
|
231414
|
+
const indexPath = path55.join(projectDir, indexRelativePath);
|
|
231390
231415
|
const source = fs43.readFileSync(indexPath, "utf8");
|
|
231391
231416
|
const missingImports = bindingSources.filter((bindingSource) => !source.includes(`./${bindingSource.slug}/editor`));
|
|
231392
231417
|
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(", ")}`);
|
|
@@ -231416,7 +231441,7 @@ function getWorkspaceRestResourceRequiredFiles(restResource) {
|
|
|
231416
231441
|
}
|
|
231417
231442
|
return Array.from(new Set([
|
|
231418
231443
|
restResource.apiFile,
|
|
231419
|
-
...Array.from(schemaNames, (schemaName) =>
|
|
231444
|
+
...Array.from(schemaNames, (schemaName) => path55.join(path55.dirname(restResource.typesFile), "api-schemas", `${schemaName}.schema.json`)),
|
|
231420
231445
|
restResource.clientFile,
|
|
231421
231446
|
restResource.dataFile,
|
|
231422
231447
|
restResource.openApiFile,
|
|
@@ -231432,9 +231457,9 @@ function checkWorkspaceRestResourceConfig(restResource) {
|
|
|
231432
231457
|
}
|
|
231433
231458
|
function checkWorkspaceRestResourceBootstrap(projectDir, packageName, phpPrefix) {
|
|
231434
231459
|
const packageBaseName = packageName.split("/").pop() ?? packageName;
|
|
231435
|
-
const bootstrapPath =
|
|
231460
|
+
const bootstrapPath = path55.join(projectDir, `${packageBaseName}.php`);
|
|
231436
231461
|
if (!fs43.existsSync(bootstrapPath)) {
|
|
231437
|
-
return createDoctorCheck2("REST resource bootstrap", "fail", `Missing ${
|
|
231462
|
+
return createDoctorCheck2("REST resource bootstrap", "fail", `Missing ${path55.basename(bootstrapPath)}`);
|
|
231438
231463
|
}
|
|
231439
231464
|
const source = fs43.readFileSync(bootstrapPath, "utf8");
|
|
231440
231465
|
const registerFunctionName = `${phpPrefix}_register_rest_resources`;
|
|
@@ -231444,13 +231469,13 @@ function checkWorkspaceRestResourceBootstrap(projectDir, packageName, phpPrefix)
|
|
|
231444
231469
|
return createDoctorCheck2("REST resource bootstrap", hasServerGlob && hasRegisterHook ? "pass" : "fail", hasServerGlob && hasRegisterHook ? "REST resource PHP loader hook is present" : "Missing REST resource PHP require glob or init hook");
|
|
231445
231470
|
}
|
|
231446
231471
|
function getWorkspaceEditorPluginRequiredFiles(editorPlugin) {
|
|
231447
|
-
const editorPluginDir =
|
|
231472
|
+
const editorPluginDir = path55.join("src", "editor-plugins", editorPlugin.slug);
|
|
231448
231473
|
return Array.from(new Set([
|
|
231449
231474
|
editorPlugin.file,
|
|
231450
|
-
|
|
231451
|
-
|
|
231452
|
-
|
|
231453
|
-
|
|
231475
|
+
path55.join(editorPluginDir, "Sidebar.tsx"),
|
|
231476
|
+
path55.join(editorPluginDir, "data.ts"),
|
|
231477
|
+
path55.join(editorPluginDir, "types.ts"),
|
|
231478
|
+
path55.join(editorPluginDir, "style.scss")
|
|
231454
231479
|
]));
|
|
231455
231480
|
}
|
|
231456
231481
|
function checkWorkspaceEditorPluginConfig(editorPlugin) {
|
|
@@ -231460,9 +231485,9 @@ function checkWorkspaceEditorPluginConfig(editorPlugin) {
|
|
|
231460
231485
|
}
|
|
231461
231486
|
function checkWorkspaceEditorPluginBootstrap(projectDir, packageName, phpPrefix) {
|
|
231462
231487
|
const packageBaseName = packageName.split("/").pop() ?? packageName;
|
|
231463
|
-
const bootstrapPath =
|
|
231488
|
+
const bootstrapPath = path55.join(projectDir, `${packageBaseName}.php`);
|
|
231464
231489
|
if (!fs43.existsSync(bootstrapPath)) {
|
|
231465
|
-
return createDoctorCheck2("Editor plugin bootstrap", "fail", `Missing ${
|
|
231490
|
+
return createDoctorCheck2("Editor plugin bootstrap", "fail", `Missing ${path55.basename(bootstrapPath)}`);
|
|
231466
231491
|
}
|
|
231467
231492
|
const source = fs43.readFileSync(bootstrapPath, "utf8");
|
|
231468
231493
|
const enqueueFunctionName = `${phpPrefix}_enqueue_editor_plugins_editor`;
|
|
@@ -231475,13 +231500,13 @@ function checkWorkspaceEditorPluginBootstrap(projectDir, packageName, phpPrefix)
|
|
|
231475
231500
|
}
|
|
231476
231501
|
function checkWorkspaceEditorPluginIndex(projectDir, editorPlugins) {
|
|
231477
231502
|
const indexRelativePath = [
|
|
231478
|
-
|
|
231479
|
-
|
|
231480
|
-
].find((relativePath) => fs43.existsSync(
|
|
231503
|
+
path55.join("src", "editor-plugins", "index.ts"),
|
|
231504
|
+
path55.join("src", "editor-plugins", "index.js")
|
|
231505
|
+
].find((relativePath) => fs43.existsSync(path55.join(projectDir, relativePath)));
|
|
231481
231506
|
if (!indexRelativePath) {
|
|
231482
231507
|
return createDoctorCheck2("Editor plugins index", "fail", "Missing src/editor-plugins/index.ts or src/editor-plugins/index.js");
|
|
231483
231508
|
}
|
|
231484
|
-
const indexPath =
|
|
231509
|
+
const indexPath = path55.join(projectDir, indexRelativePath);
|
|
231485
231510
|
const source = fs43.readFileSync(indexPath, "utf8");
|
|
231486
231511
|
const missingImports = editorPlugins.filter((editorPlugin) => {
|
|
231487
231512
|
const importPattern = new RegExp(`['"\`]\\./${escapeRegex4(editorPlugin.slug)}(?:/[^'"\`]*)?['"\`]`, "u");
|
|
@@ -231490,9 +231515,9 @@ function checkWorkspaceEditorPluginIndex(projectDir, editorPlugins) {
|
|
|
231490
231515
|
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(", ")}`);
|
|
231491
231516
|
}
|
|
231492
231517
|
function checkVariationEntrypoint(projectDir, blockSlug) {
|
|
231493
|
-
const entryPath =
|
|
231518
|
+
const entryPath = path55.join(projectDir, "src", "blocks", blockSlug, "index.tsx");
|
|
231494
231519
|
if (!fs43.existsSync(entryPath)) {
|
|
231495
|
-
return createDoctorCheck2(`Variation entrypoint ${blockSlug}`, "fail", `Missing ${
|
|
231520
|
+
return createDoctorCheck2(`Variation entrypoint ${blockSlug}`, "fail", `Missing ${path55.relative(projectDir, entryPath)}`);
|
|
231496
231521
|
}
|
|
231497
231522
|
const source = fs43.readFileSync(entryPath, "utf8");
|
|
231498
231523
|
const hasImport = source.includes("./variations");
|
|
@@ -231501,8 +231526,8 @@ function checkVariationEntrypoint(projectDir, blockSlug) {
|
|
|
231501
231526
|
}
|
|
231502
231527
|
function checkMigrationWorkspaceHint(workspace, packageJson) {
|
|
231503
231528
|
const hasMigrationScript = typeof packageJson.scripts?.["migration:doctor"] === "string";
|
|
231504
|
-
const migrationConfigRelativePath =
|
|
231505
|
-
const hasMigrationConfig = fs43.existsSync(
|
|
231529
|
+
const migrationConfigRelativePath = path55.join("src", "migrations", "config.ts");
|
|
231530
|
+
const hasMigrationConfig = fs43.existsSync(path55.join(workspace.projectDir, migrationConfigRelativePath));
|
|
231506
231531
|
if (!hasMigrationScript && !hasMigrationConfig) {
|
|
231507
231532
|
return null;
|
|
231508
231533
|
}
|
|
@@ -231560,7 +231585,7 @@ function getWorkspaceDoctorChecks(cwd) {
|
|
|
231560
231585
|
for (const blockSlug of variationTargetBlocks) {
|
|
231561
231586
|
checks3.push(checkVariationEntrypoint(workspace.projectDir, blockSlug));
|
|
231562
231587
|
}
|
|
231563
|
-
const shouldCheckPatternBootstrap = inventory.patterns.length > 0 || fs43.existsSync(
|
|
231588
|
+
const shouldCheckPatternBootstrap = inventory.patterns.length > 0 || fs43.existsSync(path55.join(workspace.projectDir, "src", "patterns"));
|
|
231564
231589
|
if (shouldCheckPatternBootstrap) {
|
|
231565
231590
|
checks3.push(checkWorkspacePatternBootstrap(workspace.projectDir, workspace.packageName));
|
|
231566
231591
|
}
|
|
@@ -231664,18 +231689,18 @@ __export(exports_cli_scaffold, {
|
|
|
231664
231689
|
});
|
|
231665
231690
|
import fs44 from "fs";
|
|
231666
231691
|
import { promises as fsp20 } from "fs";
|
|
231667
|
-
import
|
|
231692
|
+
import path56 from "path";
|
|
231668
231693
|
async function listRelativeProjectFiles(rootDir) {
|
|
231669
231694
|
const relativeFiles = [];
|
|
231670
231695
|
async function visit2(currentDir) {
|
|
231671
231696
|
const entries = await fsp20.readdir(currentDir, { withFileTypes: true });
|
|
231672
231697
|
for (const entry of entries) {
|
|
231673
|
-
const absolutePath =
|
|
231698
|
+
const absolutePath = path56.join(currentDir, entry.name);
|
|
231674
231699
|
if (entry.isDirectory()) {
|
|
231675
231700
|
await visit2(absolutePath);
|
|
231676
231701
|
continue;
|
|
231677
231702
|
}
|
|
231678
|
-
relativeFiles.push(
|
|
231703
|
+
relativeFiles.push(path56.relative(rootDir, absolutePath).replace(path56.sep === "\\" ? /\\/gu : /\//gu, "/"));
|
|
231679
231704
|
}
|
|
231680
231705
|
}
|
|
231681
231706
|
await visit2(rootDir);
|
|
@@ -231713,7 +231738,7 @@ async function buildScaffoldDryRunPlan({
|
|
|
231713
231738
|
}) {
|
|
231714
231739
|
await assertDryRunTargetDirectoryReady(projectDir, allowExistingDir);
|
|
231715
231740
|
const { path: tempRoot, cleanup } = await createManagedTempRoot("wp-typia-scaffold-plan-");
|
|
231716
|
-
const previewProjectDir =
|
|
231741
|
+
const previewProjectDir = path56.join(tempRoot, "preview-project");
|
|
231717
231742
|
try {
|
|
231718
231743
|
const result = await scaffoldProject({
|
|
231719
231744
|
allowExistingDir: false,
|
|
@@ -231753,14 +231778,14 @@ function validateCreateProjectInput(projectInput) {
|
|
|
231753
231778
|
if (normalizedProjectInput.length === 0) {
|
|
231754
231779
|
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).");
|
|
231755
231780
|
}
|
|
231756
|
-
const normalizedProjectPath =
|
|
231781
|
+
const normalizedProjectPath = path56.normalize(normalizedProjectInput).replace(/[\\/]+$/u, "") || path56.normalize(normalizedProjectInput);
|
|
231757
231782
|
if (normalizedProjectPath === "." || normalizedProjectPath === "..") {
|
|
231758
231783
|
throw new Error("`wp-typia create` requires a new project directory. Use an explicit child directory instead of `.` or `..`.");
|
|
231759
231784
|
}
|
|
231760
231785
|
}
|
|
231761
231786
|
function collectProjectDirectoryWarnings(projectDir) {
|
|
231762
231787
|
const warnings = [];
|
|
231763
|
-
const projectName =
|
|
231788
|
+
const projectName = path56.basename(projectDir);
|
|
231764
231789
|
if (/\s/u.test(projectName)) {
|
|
231765
231790
|
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.`);
|
|
231766
231791
|
}
|
|
@@ -231915,7 +231940,7 @@ function getNextSteps({
|
|
|
231915
231940
|
noInstall,
|
|
231916
231941
|
templateId
|
|
231917
231942
|
}) {
|
|
231918
|
-
const cdTarget =
|
|
231943
|
+
const cdTarget = path56.isAbsolute(projectInput) ? projectDir : projectInput;
|
|
231919
231944
|
const steps = [`cd ${quoteShellValue(cdTarget)}`];
|
|
231920
231945
|
if (noInstall) {
|
|
231921
231946
|
steps.push(formatInstallCommand(packageManager));
|
|
@@ -232059,8 +232084,8 @@ async function runScaffoldFlow({
|
|
|
232059
232084
|
select: selectWithMigrationUi,
|
|
232060
232085
|
yes
|
|
232061
232086
|
});
|
|
232062
|
-
const projectDir =
|
|
232063
|
-
const projectName =
|
|
232087
|
+
const projectDir = path56.resolve(cwd, projectInput);
|
|
232088
|
+
const projectName = path56.basename(projectDir);
|
|
232064
232089
|
const answers = await collectScaffoldAnswers({
|
|
232065
232090
|
dataStorageMode: resolvedDataStorage,
|
|
232066
232091
|
namespace,
|
|
@@ -232123,7 +232148,7 @@ async function runScaffoldFlow({
|
|
|
232123
232148
|
let availableScripts;
|
|
232124
232149
|
if (!dryRun) {
|
|
232125
232150
|
try {
|
|
232126
|
-
const parsedPackageJson = JSON.parse(fs44.readFileSync(
|
|
232151
|
+
const parsedPackageJson = JSON.parse(fs44.readFileSync(path56.join(projectDir, "package.json"), "utf8"));
|
|
232127
232152
|
const scripts = parsedPackageJson.scripts && typeof parsedPackageJson.scripts === "object" && !Array.isArray(parsedPackageJson.scripts) ? parsedPackageJson.scripts : {};
|
|
232128
232153
|
availableScripts = Object.entries(scripts).filter(([, value2]) => typeof value2 === "string").map(([scriptName]) => scriptName);
|
|
232129
232154
|
} catch {
|
|
@@ -285184,7 +285209,7 @@ import path10 from "path";
|
|
|
285184
285209
|
// package.json
|
|
285185
285210
|
var package_default2 = {
|
|
285186
285211
|
name: "wp-typia",
|
|
285187
|
-
version: "0.20.
|
|
285212
|
+
version: "0.20.1",
|
|
285188
285213
|
description: "Canonical CLI package for wp-typia scaffolding and project workflows",
|
|
285189
285214
|
packageManager: "bun@1.3.11",
|
|
285190
285215
|
type: "module",
|
|
@@ -285251,7 +285276,7 @@ var package_default2 = {
|
|
|
285251
285276
|
"@bunli/tui": "0.6.0",
|
|
285252
285277
|
"@bunli/utils": "0.6.0",
|
|
285253
285278
|
"@wp-typia/api-client": "^0.4.5",
|
|
285254
|
-
"@wp-typia/project-tools": "0.19.
|
|
285279
|
+
"@wp-typia/project-tools": "0.19.2",
|
|
285255
285280
|
"better-result": "^2.7.0",
|
|
285256
285281
|
react: "^19.2.5",
|
|
285257
285282
|
"react-dom": "^19.2.5",
|
|
@@ -286798,7 +286823,7 @@ init_cli_diagnostics();
|
|
|
286798
286823
|
|
|
286799
286824
|
// src/mcp.ts
|
|
286800
286825
|
import fs45 from "fs/promises";
|
|
286801
|
-
import
|
|
286826
|
+
import path57 from "path";
|
|
286802
286827
|
|
|
286803
286828
|
// ../../node_modules/.bun/@bunli+plugin-mcp@0.2.5+ef72ce197b058209/node_modules/@bunli/plugin-mcp/src/errors.ts
|
|
286804
286829
|
class SchemaConversionError extends TaggedError("SchemaConversionError")() {
|
|
@@ -287326,7 +287351,7 @@ function isToolGroup(value2) {
|
|
|
287326
287351
|
return isObject3(value2) && typeof value2.namespace === "string" && Array.isArray(value2.tools) && value2.tools.every(isTool);
|
|
287327
287352
|
}
|
|
287328
287353
|
async function readSchemaSource(cwd, source) {
|
|
287329
|
-
const schemaPath =
|
|
287354
|
+
const schemaPath = path57.resolve(cwd, source.path);
|
|
287330
287355
|
const raw = await fs45.readFile(schemaPath, "utf8");
|
|
287331
287356
|
const parsed = JSON.parse(raw);
|
|
287332
287357
|
if (isToolGroup(parsed)) {
|
|
@@ -287343,7 +287368,7 @@ async function readSchemaSource(cwd, source) {
|
|
|
287343
287368
|
async function loadMcpToolGroups(cwd, schemaSources) {
|
|
287344
287369
|
return Promise.all(schemaSources.map((source) => readSchemaSource(cwd, source)));
|
|
287345
287370
|
}
|
|
287346
|
-
async function syncMcpSchemas(cwd, schemaSources, outputDir =
|
|
287371
|
+
async function syncMcpSchemas(cwd, schemaSources, outputDir = path57.join(cwd, ".bunli", "mcp")) {
|
|
287347
287372
|
const groups = await loadMcpToolGroups(cwd, schemaSources);
|
|
287348
287373
|
const result = await generateMCPTypes({
|
|
287349
287374
|
outputDir,
|
|
@@ -287366,7 +287391,7 @@ async function syncMcpSchemas(cwd, schemaSources, outputDir = path56.join(cwd, "
|
|
|
287366
287391
|
}
|
|
287367
287392
|
}
|
|
287368
287393
|
await fs45.mkdir(outputDir, { recursive: true });
|
|
287369
|
-
await fs45.writeFile(
|
|
287394
|
+
await fs45.writeFile(path57.join(outputDir, "registry.json"), `${JSON.stringify(registry2, null, 2)}
|
|
287370
287395
|
`, "utf8");
|
|
287371
287396
|
return {
|
|
287372
287397
|
commandCount: registry2.reduce((count, group) => count + group.tools.length, 0),
|
|
@@ -287647,4 +287672,4 @@ export {
|
|
|
287647
287672
|
cli
|
|
287648
287673
|
};
|
|
287649
287674
|
|
|
287650
|
-
//# debugId=
|
|
287675
|
+
//# debugId=7E578141DFFCF7E164756E2164756E21
|