@wp-typia/project-tools 0.22.8 → 0.22.10
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/runtime/ai-artifacts.js +3 -4
- package/dist/runtime/ai-feature-artifacts.js +2 -4
- package/dist/runtime/cli-add-block.js +12 -1
- package/dist/runtime/cli-add-filesystem.js +2 -15
- package/dist/runtime/cli-add-types.d.ts +8 -0
- package/dist/runtime/cli-add-types.js +13 -0
- package/dist/runtime/cli-add.d.ts +3 -2
- package/dist/runtime/cli-add.js +2 -2
- package/dist/runtime/cli-core.d.ts +4 -2
- package/dist/runtime/cli-core.js +3 -2
- package/dist/runtime/cli-doctor-workspace-shared.js +3 -0
- package/dist/runtime/cli-doctor-workspace.d.ts +1 -1
- package/dist/runtime/cli-doctor-workspace.js +8 -3
- package/dist/runtime/cli-doctor.js +1 -1
- package/dist/runtime/cli-scaffold.js +3 -3
- package/dist/runtime/create-template-validation.js +2 -28
- package/dist/runtime/fs-async.d.ts +7 -0
- package/dist/runtime/fs-async.js +11 -2
- package/dist/runtime/id-suggestions.d.ts +21 -0
- package/dist/runtime/id-suggestions.js +48 -0
- package/dist/runtime/index.d.ts +5 -2
- package/dist/runtime/index.js +3 -1
- package/dist/runtime/migration-maintenance-verify.js +5 -0
- package/dist/runtime/migration-render-generated.js +4 -0
- package/dist/runtime/package-versions.js +3 -7
- package/dist/runtime/scaffold-repository-reference.js +3 -7
- package/dist/runtime/scaffold.js +3 -3
- package/dist/runtime/template-builtins.js +11 -8
- package/dist/runtime/template-layers.js +2 -2
- package/dist/runtime/template-source-external.d.ts +3 -0
- package/dist/runtime/template-source-external.js +5 -2
- package/dist/runtime/template-source-remote.d.ts +6 -0
- package/dist/runtime/template-source-remote.js +8 -2
- package/dist/runtime/template-source-seeds.d.ts +13 -0
- package/dist/runtime/template-source-seeds.js +36 -8
- package/dist/runtime/template-source.js +2 -2
- package/dist/runtime/typia-llm.js +3 -4
- package/dist/runtime/workspace-inventory-mutations.d.ts +24 -0
- package/dist/runtime/workspace-inventory-mutations.js +132 -0
- package/dist/runtime/workspace-inventory-parser.d.ts +52 -0
- package/dist/runtime/workspace-inventory-parser.js +511 -0
- package/dist/runtime/workspace-inventory-read.d.ts +44 -0
- package/dist/runtime/workspace-inventory-read.js +91 -0
- package/dist/runtime/workspace-inventory-templates.d.ts +35 -0
- package/dist/runtime/workspace-inventory-templates.js +198 -0
- package/dist/runtime/workspace-inventory-types.d.ts +171 -0
- package/dist/runtime/workspace-inventory-types.js +1 -0
- package/dist/runtime/workspace-inventory.d.ts +5 -238
- package/dist/runtime/workspace-inventory.js +4 -901
- package/package.json +7 -2
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { buildWordPressAiArtifacts, } from './wordpress-ai.js';
|
|
4
|
+
import { getOptionalNodeErrorCode, isFileNotFoundError, } from './fs-async.js';
|
|
4
5
|
export { buildWordPressAiArtifacts, buildWordPressAbilitiesDocument, projectWordPressAiSchema, } from './wordpress-ai.js';
|
|
5
6
|
function normalizeGeneratedArtifactContent(content) {
|
|
6
7
|
return content.replace(/\r\n?/g, '\n');
|
|
@@ -25,13 +26,11 @@ async function reconcileGeneratedAiArtifacts(artifacts, check) {
|
|
|
25
26
|
}
|
|
26
27
|
}
|
|
27
28
|
catch (error) {
|
|
28
|
-
|
|
29
|
-
? error.code
|
|
30
|
-
: undefined;
|
|
31
|
-
if (code === 'ENOENT') {
|
|
29
|
+
if (isFileNotFoundError(error)) {
|
|
32
30
|
issues.push(`- ${artifact.filePath} (missing)`);
|
|
33
31
|
continue;
|
|
34
32
|
}
|
|
33
|
+
const code = getOptionalNodeErrorCode(error);
|
|
35
34
|
issues.push(`- ${artifact.filePath} (unreadable: ${error instanceof Error ? error.message : code ?? 'unknown'})`);
|
|
36
35
|
}
|
|
37
36
|
}
|
|
@@ -2,6 +2,7 @@ import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { defineEndpointManifest, syncEndpointClient, syncRestOpenApi, syncTypeSchemas, } from "@wp-typia/block-runtime/metadata-core";
|
|
4
4
|
import { projectWordPressAiSchema } from "./ai-artifacts.js";
|
|
5
|
+
import { isFileNotFoundError } from "./fs-async.js";
|
|
5
6
|
function normalizeGeneratedArtifactContent(content) {
|
|
6
7
|
return content.replace(/\r\n?/g, "\n");
|
|
7
8
|
}
|
|
@@ -21,10 +22,7 @@ async function reconcileGeneratedArtifact(options) {
|
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
catch (error) {
|
|
24
|
-
|
|
25
|
-
? error.code
|
|
26
|
-
: undefined;
|
|
27
|
-
if (code === "ENOENT") {
|
|
25
|
+
if (isFileNotFoundError(error)) {
|
|
28
26
|
throw new Error(`Generated AI feature artifact is missing: ${options.label} (${options.filePath}).`);
|
|
29
27
|
}
|
|
30
28
|
throw error;
|
|
@@ -9,7 +9,7 @@ import { copyInterpolatedDirectory, listInterpolatedDirectoryOutputs, } from "./
|
|
|
9
9
|
import { appendWorkspaceInventoryEntries, } from "./workspace-inventory.js";
|
|
10
10
|
import { createManagedTempRoot } from "./temp-roots.js";
|
|
11
11
|
import { resolveWorkspaceProject, } from "./workspace-project.js";
|
|
12
|
-
import { ADD_BLOCK_TEMPLATE_IDS, buildWorkspacePhpPrefix, isAddBlockTemplateId, patchFile, readOptionalFile, rollbackWorkspaceMutation, snapshotWorkspaceFiles, } from "./cli-add-shared.js";
|
|
12
|
+
import { ADD_BLOCK_TEMPLATE_IDS, buildWorkspacePhpPrefix, isAddBlockTemplateId, patchFile, readOptionalFile, rollbackWorkspaceMutation, snapshotWorkspaceFiles, suggestAddBlockTemplateId, } from "./cli-add-shared.js";
|
|
13
13
|
import { resolveNonEmptyNormalizedBlockSlug, } from "./scaffold-identifiers.js";
|
|
14
14
|
import { buildConfigEntries, buildMigrationBlocks, buildServerTemplateRoot, } from "./cli-add-block-config.js";
|
|
15
15
|
import { COMPOUND_SHARED_SUPPORT_FILES, collectLegacyCompoundValidatorPaths, ensureBlockConfigCanAddRestManifests, ensureCompoundWorkspaceSupportFiles, } from "./cli-add-block-legacy-validator.js";
|
|
@@ -80,6 +80,13 @@ async function assertWorkspaceDependenciesInstalled(workspace) {
|
|
|
80
80
|
}
|
|
81
81
|
throw new Error(`Workspace dependencies have not been installed yet. Run \`${formatInstallCommand(workspace.packageManager)}\` from the workspace root before using \`wp-typia add block ...\`.`);
|
|
82
82
|
}
|
|
83
|
+
function getMistypedAddBlockTemplateMessage(templateId) {
|
|
84
|
+
const suggestion = suggestAddBlockTemplateId(templateId);
|
|
85
|
+
if (!suggestion) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
return `Unknown add-block template "${templateId}". Did you mean "${suggestion}"? Use \`--template ${suggestion}\`, or run \`wp-typia templates list\` to inspect available templates.`;
|
|
89
|
+
}
|
|
83
90
|
async function copyScaffoldedBlockSlice(projectDir, templateId, tempProjectDir, variables, legacyValidatorPaths = []) {
|
|
84
91
|
if (templateId === "compound") {
|
|
85
92
|
await ensureCompoundWorkspaceSupportFiles(projectDir, tempProjectDir, legacyValidatorPaths);
|
|
@@ -287,6 +294,10 @@ export async function runAddBlockCommand({ alternateRenderTargets, blockName, cw
|
|
|
287
294
|
throw new Error("`wp-typia add block --template query-loop` is not supported. Query Loop is a create-time `core/query` variation scaffold, so use `wp-typia create <project-dir> --template query-loop` instead.");
|
|
288
295
|
}
|
|
289
296
|
if (!isAddBlockTemplateId(templateId)) {
|
|
297
|
+
const mistypedAddBlockTemplateMessage = getMistypedAddBlockTemplateMessage(templateId);
|
|
298
|
+
if (mistypedAddBlockTemplateMessage) {
|
|
299
|
+
throw new Error(mistypedAddBlockTemplateMessage);
|
|
300
|
+
}
|
|
290
301
|
throw new Error(`Unknown add-block template "${templateId}". Expected one of: ${ADD_BLOCK_TEMPLATE_IDS.join(", ")}. Run \`wp-typia templates list\` to inspect available templates.`);
|
|
291
302
|
}
|
|
292
303
|
const resolvedTemplateId = templateId;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { promises as fsp } from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
import { readOptionalUtf8File } from "./fs-async.js";
|
|
3
4
|
/**
|
|
4
5
|
* Resolve the primary PHP bootstrap file for an official workspace.
|
|
5
6
|
*
|
|
@@ -24,15 +25,7 @@ export async function patchFile(filePath, transform) {
|
|
|
24
25
|
* Read a file when it exists and otherwise return `null`.
|
|
25
26
|
*/
|
|
26
27
|
export async function readOptionalFile(filePath) {
|
|
27
|
-
|
|
28
|
-
return await fsp.readFile(filePath, "utf8");
|
|
29
|
-
}
|
|
30
|
-
catch (error) {
|
|
31
|
-
if (isFileNotFoundError(error)) {
|
|
32
|
-
return null;
|
|
33
|
-
}
|
|
34
|
-
throw error;
|
|
35
|
-
}
|
|
28
|
+
return readOptionalUtf8File(filePath);
|
|
36
29
|
}
|
|
37
30
|
/**
|
|
38
31
|
* Restore a file to its captured source, deleting it when the snapshot was `null`.
|
|
@@ -69,9 +62,3 @@ export async function rollbackWorkspaceMutation(snapshot) {
|
|
|
69
62
|
await restoreOptionalFile(filePath, source);
|
|
70
63
|
}
|
|
71
64
|
}
|
|
72
|
-
function isFileNotFoundError(error) {
|
|
73
|
-
return (typeof error === "object" &&
|
|
74
|
-
error !== null &&
|
|
75
|
-
"code" in error &&
|
|
76
|
-
error.code === "ENOENT");
|
|
77
|
-
}
|
|
@@ -42,6 +42,14 @@ export declare const ADD_BLOCK_TEMPLATE_IDS: readonly ["basic", "interactivity",
|
|
|
42
42
|
* Union of supported built-in block template ids.
|
|
43
43
|
*/
|
|
44
44
|
export type AddBlockTemplateId = (typeof ADD_BLOCK_TEMPLATE_IDS)[number];
|
|
45
|
+
/**
|
|
46
|
+
* Suggest the closest supported add-block template id for typo diagnostics.
|
|
47
|
+
*
|
|
48
|
+
* @param templateId Raw `wp-typia add block --template` value.
|
|
49
|
+
* @returns The closest supported template id when it is within the shared
|
|
50
|
+
* close-id threshold, otherwise `null`.
|
|
51
|
+
*/
|
|
52
|
+
export declare function suggestAddBlockTemplateId(templateId: string): AddBlockTemplateId | null;
|
|
45
53
|
/**
|
|
46
54
|
* Options for `wp-typia add variation`.
|
|
47
55
|
*
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { suggestCloseId } from "./id-suggestions.js";
|
|
1
2
|
export { ADD_KIND_IDS } from "./cli-add-kind-ids.js";
|
|
2
3
|
/**
|
|
3
4
|
* Supported plugin-level REST resource methods accepted by
|
|
@@ -46,3 +47,15 @@ export const ADD_BLOCK_TEMPLATE_IDS = [
|
|
|
46
47
|
"persistence",
|
|
47
48
|
"compound",
|
|
48
49
|
];
|
|
50
|
+
/**
|
|
51
|
+
* Suggest the closest supported add-block template id for typo diagnostics.
|
|
52
|
+
*
|
|
53
|
+
* @param templateId Raw `wp-typia add block --template` value.
|
|
54
|
+
* @returns The closest supported template id when it is within the shared
|
|
55
|
+
* close-id threshold, otherwise `null`.
|
|
56
|
+
*/
|
|
57
|
+
export function suggestAddBlockTemplateId(templateId) {
|
|
58
|
+
return suggestCloseId(templateId, ADD_BLOCK_TEMPLATE_IDS, {
|
|
59
|
+
maxDistance: 3,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
@@ -7,8 +7,9 @@
|
|
|
7
7
|
* - `cli-add-block` for built-in block scaffolding
|
|
8
8
|
* - `cli-add-workspace` for workspace mutation commands
|
|
9
9
|
*/
|
|
10
|
-
export { ADD_BLOCK_TEMPLATE_IDS, ADD_KIND_IDS, EDITOR_PLUGIN_SLOT_IDS, formatAddHelpText, isAddBlockTemplateId, } from "./cli-add-shared.js";
|
|
10
|
+
export { ADD_BLOCK_TEMPLATE_IDS, ADD_KIND_IDS, EDITOR_PLUGIN_SLOT_IDS, formatAddHelpText, isAddBlockTemplateId, suggestAddBlockTemplateId, } from "./cli-add-shared.js";
|
|
11
11
|
export type { AddBlockTemplateId, AddKindId, EditorPluginSlotId, } from "./cli-add-shared.js";
|
|
12
12
|
export { runAddBlockCommand, seedWorkspaceMigrationProject, } from "./cli-add-block.js";
|
|
13
13
|
export { runAddAdminViewCommand, runAddAbilityCommand, runAddAiFeatureCommand, runAddBindingSourceCommand, runAddBlockStyleCommand, runAddBlockTransformCommand, runAddEditorPluginCommand, runAddHookedBlockCommand, runAddPatternCommand, runAddRestResourceCommand, runAddVariationCommand, } from "./cli-add-workspace.js";
|
|
14
|
-
export { getWorkspaceBlockSelectOptions } from "./workspace-inventory.js";
|
|
14
|
+
export { getWorkspaceBlockSelectOptions, getWorkspaceBlockSelectOptionsAsync, } from "./workspace-inventory.js";
|
|
15
|
+
export type { WorkspaceBlockSelectOption } from "./workspace-inventory.js";
|
package/dist/runtime/cli-add.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* - `cli-add-block` for built-in block scaffolding
|
|
8
8
|
* - `cli-add-workspace` for workspace mutation commands
|
|
9
9
|
*/
|
|
10
|
-
export { ADD_BLOCK_TEMPLATE_IDS, ADD_KIND_IDS, EDITOR_PLUGIN_SLOT_IDS, formatAddHelpText, isAddBlockTemplateId, } from "./cli-add-shared.js";
|
|
10
|
+
export { ADD_BLOCK_TEMPLATE_IDS, ADD_KIND_IDS, EDITOR_PLUGIN_SLOT_IDS, formatAddHelpText, isAddBlockTemplateId, suggestAddBlockTemplateId, } from "./cli-add-shared.js";
|
|
11
11
|
export { runAddBlockCommand, seedWorkspaceMigrationProject, } from "./cli-add-block.js";
|
|
12
12
|
export { runAddAdminViewCommand, runAddAbilityCommand, runAddAiFeatureCommand, runAddBindingSourceCommand, runAddBlockStyleCommand, runAddBlockTransformCommand, runAddEditorPluginCommand, runAddHookedBlockCommand, runAddPatternCommand, runAddRestResourceCommand, runAddVariationCommand, } from "./cli-add-workspace.js";
|
|
13
|
-
export { getWorkspaceBlockSelectOptions } from "./workspace-inventory.js";
|
|
13
|
+
export { getWorkspaceBlockSelectOptions, getWorkspaceBlockSelectOptionsAsync, } from "./workspace-inventory.js";
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
* `runAddAdminViewCommand` for DataViews-backed admin screen scaffolds,
|
|
12
12
|
* `runAddAbilityCommand` for typed workflow ability scaffolds,
|
|
13
13
|
* and `HOOKED_BLOCK_POSITION_IDS`,
|
|
14
|
-
* `getWorkspaceBlockSelectOptions`,
|
|
14
|
+
* `getWorkspaceBlockSelectOptions`, `getWorkspaceBlockSelectOptionsAsync`, and
|
|
15
|
+
* `seedWorkspaceMigrationProject` for
|
|
15
16
|
* explicit `wp-typia add` flows,
|
|
16
17
|
* `runAddAiFeatureCommand` for server-owned WordPress AI feature scaffolds,
|
|
17
18
|
* `runAddRestResourceCommand` for plugin-level REST resource scaffolds,
|
|
@@ -31,11 +32,12 @@
|
|
|
31
32
|
export { getDoctorChecks, runDoctor, type DoctorCheck } from "./cli-doctor.js";
|
|
32
33
|
export { createCliCommandError, createCliDiagnosticCodeError, CliDiagnosticError, CLI_DIAGNOSTIC_CODE_METADATA, CLI_DIAGNOSTIC_CODES, formatCliDiagnosticError, formatDoctorCheckLine, formatDoctorSummaryLine, getCliDiagnosticCodeMetadata, getDoctorFailureDetailLines, getFailingDoctorChecks, isCliDiagnosticError, } from "./cli-diagnostics.js";
|
|
33
34
|
export type { CliDiagnosticCode, CliDiagnosticCodeError, CliDiagnosticMessage, } from "./cli-diagnostics.js";
|
|
34
|
-
export { EDITOR_PLUGIN_SLOT_IDS, formatAddHelpText, getWorkspaceBlockSelectOptions, runAddAdminViewCommand, runAddAbilityCommand, runAddBindingSourceCommand, runAddAiFeatureCommand, runAddBlockCommand, runAddBlockStyleCommand, runAddBlockTransformCommand, runAddEditorPluginCommand, runAddHookedBlockCommand, runAddPatternCommand, runAddRestResourceCommand, runAddVariationCommand, seedWorkspaceMigrationProject, } from "./cli-add.js";
|
|
35
|
+
export { EDITOR_PLUGIN_SLOT_IDS, formatAddHelpText, getWorkspaceBlockSelectOptions, getWorkspaceBlockSelectOptionsAsync, runAddAdminViewCommand, runAddAbilityCommand, runAddBindingSourceCommand, runAddAiFeatureCommand, runAddBlockCommand, runAddBlockStyleCommand, runAddBlockTransformCommand, runAddEditorPluginCommand, runAddHookedBlockCommand, runAddPatternCommand, runAddRestResourceCommand, runAddVariationCommand, seedWorkspaceMigrationProject, } from "./cli-add.js";
|
|
35
36
|
export { COMPOUND_INNER_BLOCKS_PRESET_IDS, getCompoundInnerBlocksPresetDefinition, } from "./compound-inner-blocks.js";
|
|
36
37
|
export type { CompoundInnerBlocksPresetId } from "./compound-inner-blocks.js";
|
|
37
38
|
export { HOOKED_BLOCK_POSITION_IDS } from "./hooked-blocks.js";
|
|
38
39
|
export type { EditorPluginSlotId } from "./cli-add.js";
|
|
40
|
+
export type { WorkspaceBlockSelectOption } from "./workspace-inventory.js";
|
|
39
41
|
export type { HookedBlockPositionId } from "./hooked-blocks.js";
|
|
40
42
|
export { formatHelpText } from "./cli-help.js";
|
|
41
43
|
export { getNextSteps, getOptionalOnboarding, runScaffoldFlow, } from "./cli-scaffold.js";
|
package/dist/runtime/cli-core.js
CHANGED
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
* `runAddAdminViewCommand` for DataViews-backed admin screen scaffolds,
|
|
12
12
|
* `runAddAbilityCommand` for typed workflow ability scaffolds,
|
|
13
13
|
* and `HOOKED_BLOCK_POSITION_IDS`,
|
|
14
|
-
* `getWorkspaceBlockSelectOptions`,
|
|
14
|
+
* `getWorkspaceBlockSelectOptions`, `getWorkspaceBlockSelectOptionsAsync`, and
|
|
15
|
+
* `seedWorkspaceMigrationProject` for
|
|
15
16
|
* explicit `wp-typia add` flows,
|
|
16
17
|
* `runAddAiFeatureCommand` for server-owned WordPress AI feature scaffolds,
|
|
17
18
|
* `runAddRestResourceCommand` for plugin-level REST resource scaffolds,
|
|
@@ -30,7 +31,7 @@
|
|
|
30
31
|
*/
|
|
31
32
|
export { getDoctorChecks, runDoctor } from "./cli-doctor.js";
|
|
32
33
|
export { createCliCommandError, createCliDiagnosticCodeError, CliDiagnosticError, CLI_DIAGNOSTIC_CODE_METADATA, CLI_DIAGNOSTIC_CODES, formatCliDiagnosticError, formatDoctorCheckLine, formatDoctorSummaryLine, getCliDiagnosticCodeMetadata, getDoctorFailureDetailLines, getFailingDoctorChecks, isCliDiagnosticError, } from "./cli-diagnostics.js";
|
|
33
|
-
export { EDITOR_PLUGIN_SLOT_IDS, formatAddHelpText, getWorkspaceBlockSelectOptions, runAddAdminViewCommand, runAddAbilityCommand, runAddBindingSourceCommand, runAddAiFeatureCommand, runAddBlockCommand, runAddBlockStyleCommand, runAddBlockTransformCommand, runAddEditorPluginCommand, runAddHookedBlockCommand, runAddPatternCommand, runAddRestResourceCommand, runAddVariationCommand, seedWorkspaceMigrationProject, } from "./cli-add.js";
|
|
34
|
+
export { EDITOR_PLUGIN_SLOT_IDS, formatAddHelpText, getWorkspaceBlockSelectOptions, getWorkspaceBlockSelectOptionsAsync, runAddAdminViewCommand, runAddAbilityCommand, runAddBindingSourceCommand, runAddAiFeatureCommand, runAddBlockCommand, runAddBlockStyleCommand, runAddBlockTransformCommand, runAddEditorPluginCommand, runAddHookedBlockCommand, runAddPatternCommand, runAddRestResourceCommand, runAddVariationCommand, seedWorkspaceMigrationProject, } from "./cli-add.js";
|
|
34
35
|
export { COMPOUND_INNER_BLOCKS_PRESET_IDS, getCompoundInnerBlocksPresetDefinition, } from "./compound-inner-blocks.js";
|
|
35
36
|
export { HOOKED_BLOCK_POSITION_IDS } from "./hooked-blocks.js";
|
|
36
37
|
export { formatHelpText } from "./cli-help.js";
|
|
@@ -90,6 +90,9 @@ export function resolveWorkspaceBootstrapPath(projectDir, packageName) {
|
|
|
90
90
|
* @returns A passing or failing `DoctorCheck` describing any missing files.
|
|
91
91
|
*/
|
|
92
92
|
export function checkExistingFiles(projectDir, label, filePaths) {
|
|
93
|
+
// Workspace category collectors remain synchronous pure mappers after the
|
|
94
|
+
// async inventory snapshot is loaded, so these small existence probes stay
|
|
95
|
+
// sync to preserve their current non-Promise APIs and output ordering.
|
|
93
96
|
const missing = filePaths
|
|
94
97
|
.filter((filePath) => typeof filePath === "string")
|
|
95
98
|
.filter((filePath) => !fs.existsSync(path.join(projectDir, filePath)));
|
|
@@ -15,4 +15,4 @@ import type { DoctorCheck } from "./cli-doctor.js";
|
|
|
15
15
|
* @param cwd Working directory expected to host an official workspace.
|
|
16
16
|
* @returns Ordered workspace check rows ready for CLI rendering.
|
|
17
17
|
*/
|
|
18
|
-
export declare function getWorkspaceDoctorChecks(cwd: string): DoctorCheck[]
|
|
18
|
+
export declare function getWorkspaceDoctorChecks(cwd: string): Promise<DoctorCheck[]>;
|
|
@@ -3,7 +3,7 @@ import { getWorkspaceBlockDoctorChecks, } from "./cli-doctor-workspace-blocks.js
|
|
|
3
3
|
import { getWorkspaceFeatureDoctorChecks, } from "./cli-doctor-workspace-features.js";
|
|
4
4
|
import { getMigrationWorkspaceHintCheck, getWorkspacePackageMetadataCheck, } from "./cli-doctor-workspace-package.js";
|
|
5
5
|
import { createDoctorCheck, createDoctorScopeCheck, } from "./cli-doctor-workspace-shared.js";
|
|
6
|
-
import {
|
|
6
|
+
import { readWorkspaceInventoryAsync, } from "./workspace-inventory.js";
|
|
7
7
|
import { getInvalidWorkspaceProjectReason, parseWorkspacePackageJson, tryResolveWorkspaceProject, } from "./workspace-project.js";
|
|
8
8
|
function formatWorkspaceInventorySummary(inventory) {
|
|
9
9
|
return [
|
|
@@ -36,11 +36,13 @@ function formatWorkspaceInventorySummary(inventory) {
|
|
|
36
36
|
* @param cwd Working directory expected to host an official workspace.
|
|
37
37
|
* @returns Ordered workspace check rows ready for CLI rendering.
|
|
38
38
|
*/
|
|
39
|
-
export function getWorkspaceDoctorChecks(cwd) {
|
|
39
|
+
export async function getWorkspaceDoctorChecks(cwd) {
|
|
40
40
|
const checks = [];
|
|
41
41
|
let workspace = null;
|
|
42
42
|
let invalidWorkspaceReason = null;
|
|
43
43
|
try {
|
|
44
|
+
// Workspace discovery and package parsing intentionally stay synchronous
|
|
45
|
+
// because they share compatibility helpers with sync add/migration callers.
|
|
44
46
|
invalidWorkspaceReason = getInvalidWorkspaceProjectReason(cwd);
|
|
45
47
|
workspace = tryResolveWorkspaceProject(cwd);
|
|
46
48
|
}
|
|
@@ -62,6 +64,9 @@ export function getWorkspaceDoctorChecks(cwd) {
|
|
|
62
64
|
checks.push(createDoctorScopeCheck("pass", `Scope: full workspace diagnostics for ${workspace.workspace.namespace}. Environment readiness checks ran and workspace-scoped diagnostics are enabled for the package metadata, inventory, source-tree drift, and any configured migration hint rows below.`));
|
|
63
65
|
let workspacePackageJson;
|
|
64
66
|
try {
|
|
67
|
+
// Keep package metadata parsing sync until workspace-project exposes an
|
|
68
|
+
// async companion; the surrounding doctor orchestration already awaits
|
|
69
|
+
// async inventory reads below.
|
|
65
70
|
workspacePackageJson = parseWorkspacePackageJson(workspace.projectDir);
|
|
66
71
|
}
|
|
67
72
|
catch (error) {
|
|
@@ -70,7 +75,7 @@ export function getWorkspaceDoctorChecks(cwd) {
|
|
|
70
75
|
}
|
|
71
76
|
checks.push(getWorkspacePackageMetadataCheck(workspace, workspacePackageJson));
|
|
72
77
|
try {
|
|
73
|
-
const inventory =
|
|
78
|
+
const inventory = await readWorkspaceInventoryAsync(workspace.projectDir);
|
|
74
79
|
checks.push(createDoctorCheck("Workspace inventory", "pass", formatWorkspaceInventorySummary(inventory)));
|
|
75
80
|
checks.push(...getWorkspaceBlockDoctorChecks(workspace, inventory));
|
|
76
81
|
checks.push(...getWorkspaceBindingDoctorChecks(workspace, inventory));
|
|
@@ -15,7 +15,7 @@ import { getWorkspaceDoctorChecks } from "./cli-doctor-workspace.js";
|
|
|
15
15
|
export async function getDoctorChecks(cwd) {
|
|
16
16
|
return [
|
|
17
17
|
...(await getEnvironmentDoctorChecks(cwd)),
|
|
18
|
-
...getWorkspaceDoctorChecks(cwd),
|
|
18
|
+
...(await getWorkspaceDoctorChecks(cwd)),
|
|
19
19
|
];
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
1
|
import { promises as fsp } from "node:fs";
|
|
3
2
|
import path from "node:path";
|
|
4
3
|
import { collectScaffoldAnswers, DATA_STORAGE_MODES, PERSISTENCE_POLICIES, isDataStorageMode, isPersistencePolicy, resolvePackageManagerId, resolveTemplateId, scaffoldProject, } from "./scaffold.js";
|
|
@@ -10,6 +9,7 @@ import { getPrimaryDevelopmentScript } from "./local-dev-presets.js";
|
|
|
10
9
|
import { createManagedTempRoot } from "./temp-roots.js";
|
|
11
10
|
import { getOptionalOnboardingNote, getOptionalOnboardingShortNote, getOptionalOnboardingSteps, } from "./scaffold-onboarding.js";
|
|
12
11
|
import { formatNonEmptyTargetDirectoryError } from "./scaffold-bootstrap.js";
|
|
12
|
+
import { pathExists } from "./fs-async.js";
|
|
13
13
|
import { OFFICIAL_WORKSPACE_TEMPLATE_PACKAGE, isBuiltInTemplateId, } from "./template-registry.js";
|
|
14
14
|
import { resolveOptionalInteractiveExternalLayerId, } from "./external-layer-selection.js";
|
|
15
15
|
import { assertBuiltInTemplateVariantAllowed, resolveLocalCliPathOption, normalizeOptionalCliString, } from "./cli-validation.js";
|
|
@@ -32,7 +32,7 @@ async function listRelativeProjectFiles(rootDir) {
|
|
|
32
32
|
return relativeFiles.sort((left, right) => left.localeCompare(right));
|
|
33
33
|
}
|
|
34
34
|
async function assertDryRunTargetDirectoryReady(projectDir, allowExistingDir) {
|
|
35
|
-
if (!
|
|
35
|
+
if (!(await pathExists(projectDir)) || allowExistingDir) {
|
|
36
36
|
return;
|
|
37
37
|
}
|
|
38
38
|
const entries = await fsp.readdir(projectDir);
|
|
@@ -425,7 +425,7 @@ export async function runScaffoldFlow({ projectInput, cwd = process.cwd(), templ
|
|
|
425
425
|
let availableScripts;
|
|
426
426
|
if (!dryRun) {
|
|
427
427
|
try {
|
|
428
|
-
const parsedPackageJson = JSON.parse(
|
|
428
|
+
const parsedPackageJson = JSON.parse(await fsp.readFile(path.join(projectDir, "package.json"), "utf8"));
|
|
429
429
|
const scripts = parsedPackageJson.scripts &&
|
|
430
430
|
typeof parsedPackageJson.scripts === "object" &&
|
|
431
431
|
!Array.isArray(parsedPackageJson.scripts)
|
|
@@ -3,6 +3,7 @@ import { CLI_DIAGNOSTIC_CODES, createCliDiagnosticCodeError, } from "./cli-diagn
|
|
|
3
3
|
import { OFFICIAL_WORKSPACE_TEMPLATE_ALIAS, OFFICIAL_WORKSPACE_TEMPLATE_PACKAGE, TEMPLATE_IDS, getTemplateById, isBuiltInTemplateId, } from "./template-registry.js";
|
|
4
4
|
import { getRemovedBuiltInTemplateMessage, isRemovedBuiltInTemplateId, } from "./template-defaults.js";
|
|
5
5
|
import { parseNpmTemplateLocator } from "./template-source-locators.js";
|
|
6
|
+
import { suggestCloseId } from "./id-suggestions.js";
|
|
6
7
|
export const CREATE_TEMPLATE_SELECTION_HINT = `--template <${[
|
|
7
8
|
...TEMPLATE_IDS,
|
|
8
9
|
OFFICIAL_WORKSPACE_TEMPLATE_ALIAS,
|
|
@@ -39,40 +40,13 @@ function looksLikeExplicitCreateExternalTemplateLocator(templateId) {
|
|
|
39
40
|
return (looksLikeExplicitNonNpmExternalTemplateLocator(templateId) ||
|
|
40
41
|
parseNpmTemplateLocator(templateId) !== null);
|
|
41
42
|
}
|
|
42
|
-
function getEditDistance(left, right) {
|
|
43
|
-
const previous = Array.from({ length: right.length + 1 }, (_, index) => index);
|
|
44
|
-
const current = new Array(right.length + 1);
|
|
45
|
-
for (let leftIndex = 0; leftIndex < left.length; leftIndex += 1) {
|
|
46
|
-
current[0] = leftIndex + 1;
|
|
47
|
-
for (let rightIndex = 0; rightIndex < right.length; rightIndex += 1) {
|
|
48
|
-
const substitutionCost = left[leftIndex] === right[rightIndex] ? 0 : 1;
|
|
49
|
-
current[rightIndex + 1] = Math.min(current[rightIndex] + 1, previous[rightIndex + 1] + 1, previous[rightIndex] + substitutionCost);
|
|
50
|
-
}
|
|
51
|
-
for (let index = 0; index < current.length; index += 1) {
|
|
52
|
-
previous[index] = current[index];
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return previous[right.length];
|
|
56
|
-
}
|
|
57
43
|
function findMistypedBuiltInTemplateSuggestion(templateId) {
|
|
58
44
|
const normalizedTemplateId = templateId.trim().toLowerCase();
|
|
59
45
|
if (normalizedTemplateId.length === 0 ||
|
|
60
46
|
looksLikeExplicitNonNpmExternalTemplateLocator(normalizedTemplateId)) {
|
|
61
47
|
return null;
|
|
62
48
|
}
|
|
63
|
-
|
|
64
|
-
for (const candidateId of TEMPLATE_SUGGESTION_IDS) {
|
|
65
|
-
const distance = getEditDistance(normalizedTemplateId, candidateId);
|
|
66
|
-
if (bestCandidate === null || distance < bestCandidate.distance) {
|
|
67
|
-
bestCandidate = {
|
|
68
|
-
distance,
|
|
69
|
-
id: candidateId,
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
return bestCandidate && bestCandidate.distance <= 2
|
|
74
|
-
? bestCandidate.id
|
|
75
|
-
: null;
|
|
49
|
+
return suggestCloseId(normalizedTemplateId, TEMPLATE_SUGGESTION_IDS);
|
|
76
50
|
}
|
|
77
51
|
function getMistypedBuiltInTemplateMessage(templateId) {
|
|
78
52
|
const suggestion = findMistypedBuiltInTemplateSuggestion(templateId);
|
|
@@ -19,6 +19,13 @@ export declare function readOptionalUtf8File(filePath: string): Promise<string |
|
|
|
19
19
|
* @returns The string error code, or an empty string when unavailable.
|
|
20
20
|
*/
|
|
21
21
|
export declare function getNodeErrorCode(error: unknown): string;
|
|
22
|
+
/**
|
|
23
|
+
* Extract a Node.js error code from an unknown thrown value when available.
|
|
24
|
+
*
|
|
25
|
+
* @param error Unknown error value.
|
|
26
|
+
* @returns The string error code, or `undefined` when unavailable.
|
|
27
|
+
*/
|
|
28
|
+
export declare function getOptionalNodeErrorCode(error: unknown): string | undefined;
|
|
22
29
|
/**
|
|
23
30
|
* Return whether an unknown error represents a missing filesystem path.
|
|
24
31
|
*
|
package/dist/runtime/fs-async.js
CHANGED
|
@@ -38,9 +38,18 @@ export async function readOptionalUtf8File(filePath) {
|
|
|
38
38
|
* @returns The string error code, or an empty string when unavailable.
|
|
39
39
|
*/
|
|
40
40
|
export function getNodeErrorCode(error) {
|
|
41
|
+
return getOptionalNodeErrorCode(error) ?? "";
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Extract a Node.js error code from an unknown thrown value when available.
|
|
45
|
+
*
|
|
46
|
+
* @param error Unknown error value.
|
|
47
|
+
* @returns The string error code, or `undefined` when unavailable.
|
|
48
|
+
*/
|
|
49
|
+
export function getOptionalNodeErrorCode(error) {
|
|
41
50
|
return typeof error === "object" && error !== null && "code" in error
|
|
42
51
|
? String(error.code)
|
|
43
|
-
:
|
|
52
|
+
: undefined;
|
|
44
53
|
}
|
|
45
54
|
/**
|
|
46
55
|
* Return whether an unknown error represents a missing filesystem path.
|
|
@@ -49,5 +58,5 @@ export function getNodeErrorCode(error) {
|
|
|
49
58
|
* @returns `true` when the error has Node.js code `ENOENT`.
|
|
50
59
|
*/
|
|
51
60
|
export function isFileNotFoundError(error) {
|
|
52
|
-
return
|
|
61
|
+
return getOptionalNodeErrorCode(error) === "ENOENT";
|
|
53
62
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface SuggestCloseIdOptions {
|
|
2
|
+
/**
|
|
3
|
+
* Maximum edit distance accepted for a suggestion.
|
|
4
|
+
*
|
|
5
|
+
* Defaults to `2`, matching the create-template typo guard.
|
|
6
|
+
*/
|
|
7
|
+
maxDistance?: number;
|
|
8
|
+
/**
|
|
9
|
+
* Normalizes user input and candidates before comparing them.
|
|
10
|
+
*
|
|
11
|
+
* Defaults to trimming and lowercasing for CLI id-like values.
|
|
12
|
+
*/
|
|
13
|
+
normalize?: (value: string) => string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Suggest the closest known id for a user-provided CLI value.
|
|
17
|
+
*
|
|
18
|
+
* This helper is intentionally generic so command-specific validation can keep
|
|
19
|
+
* its own wording and special-case handling while sharing typo thresholds.
|
|
20
|
+
*/
|
|
21
|
+
export declare function suggestCloseId<const TCandidate extends string>(input: string, candidates: readonly TCandidate[], options?: SuggestCloseIdOptions): TCandidate | null;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
function normalizeCloseId(value) {
|
|
2
|
+
return value.trim().toLowerCase();
|
|
3
|
+
}
|
|
4
|
+
function getEditDistance(left, right) {
|
|
5
|
+
const previous = Array.from({ length: right.length + 1 }, (_, index) => index);
|
|
6
|
+
const current = new Array(right.length + 1);
|
|
7
|
+
for (let leftIndex = 0; leftIndex < left.length; leftIndex += 1) {
|
|
8
|
+
current[0] = leftIndex + 1;
|
|
9
|
+
for (let rightIndex = 0; rightIndex < right.length; rightIndex += 1) {
|
|
10
|
+
const substitutionCost = left[leftIndex] === right[rightIndex] ? 0 : 1;
|
|
11
|
+
current[rightIndex + 1] = Math.min(current[rightIndex] + 1, previous[rightIndex + 1] + 1, previous[rightIndex] + substitutionCost);
|
|
12
|
+
}
|
|
13
|
+
for (let index = 0; index < current.length; index += 1) {
|
|
14
|
+
previous[index] = current[index];
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return previous[right.length];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Suggest the closest known id for a user-provided CLI value.
|
|
21
|
+
*
|
|
22
|
+
* This helper is intentionally generic so command-specific validation can keep
|
|
23
|
+
* its own wording and special-case handling while sharing typo thresholds.
|
|
24
|
+
*/
|
|
25
|
+
export function suggestCloseId(input, candidates, options = {}) {
|
|
26
|
+
const normalize = options.normalize ?? normalizeCloseId;
|
|
27
|
+
const normalizedInput = normalize(input);
|
|
28
|
+
if (normalizedInput.length === 0) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
const maxDistance = options.maxDistance ?? 2;
|
|
32
|
+
if (maxDistance < 0) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
let bestCandidate = null;
|
|
36
|
+
for (const candidateId of candidates) {
|
|
37
|
+
const distance = getEditDistance(normalizedInput, normalize(candidateId));
|
|
38
|
+
if (bestCandidate === null || distance < bestCandidate.distance) {
|
|
39
|
+
bestCandidate = {
|
|
40
|
+
distance,
|
|
41
|
+
id: candidateId,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return bestCandidate && bestCandidate.distance <= maxDistance
|
|
46
|
+
? bestCandidate.id
|
|
47
|
+
: null;
|
|
48
|
+
}
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* CLI while keeping reusable project logic out of the CLI package itself.
|
|
6
6
|
* Consumers should prefer these exports for scaffold, add, migrate, doctor,
|
|
7
7
|
* and workspace-aware helpers such as `getWorkspaceBlockSelectOptions`,
|
|
8
|
+
* `getWorkspaceBlockSelectOptionsAsync`,
|
|
8
9
|
* `runAddBlockCommand`, `runAddBlockStyleCommand`,
|
|
9
10
|
* `runAddBlockTransformCommand`, `runAddVariationCommand`,
|
|
10
11
|
* `runAddPatternCommand`, `runAddBindingSourceCommand`,
|
|
@@ -29,11 +30,13 @@ export { manifestAttributeToJsonSchema, projectJsonSchemaDocument, manifestToJso
|
|
|
29
30
|
export { buildCompoundChildStarterManifestDocument, getStarterManifestFiles, stringifyStarterManifest, } from "./starter-manifests.js";
|
|
30
31
|
export type { EndpointAuthIntent, EndpointOpenApiAuthMode, EndpointOpenApiContractDocument, EndpointOpenApiDocumentOptions, EndpointOpenApiEndpointDefinition, EndpointOpenApiMethod, EndpointWordPressAuthDefinition, EndpointWordPressAuthMechanism, JsonSchemaDocument, JsonSchemaProjectionProfile, JsonSchemaObject, NormalizedEndpointAuthDefinition, OpenApiDocument, OpenApiInfo, OpenApiOperation, OpenApiParameter, OpenApiPathItem, OpenApiSecurityScheme, } from "./schema-core.js";
|
|
31
32
|
export { PACKAGE_MANAGER_IDS, PACKAGE_MANAGERS, formatPackageExecCommand, formatInstallCommand, formatRunScript, getPackageManager, getPackageManagerSelectOptions, transformPackageManagerText, } from "./package-managers.js";
|
|
33
|
+
export { suggestCloseId } from "./id-suggestions.js";
|
|
34
|
+
export type { SuggestCloseIdOptions } from "./id-suggestions.js";
|
|
32
35
|
export { clearPackageVersionsCache, getPackageVersions, invalidatePackageVersionsCache, } from "./package-versions.js";
|
|
33
36
|
export type { PackageVersions } from "./package-versions.js";
|
|
34
37
|
export { TEMPLATE_IDS, TEMPLATE_REGISTRY, getTemplateById, getTemplateSelectOptions, listTemplates, } from "./template-registry.js";
|
|
35
38
|
export { EXTERNAL_TEMPLATE_CACHE_TTL_DAYS_ENV, pruneExternalTemplateCache, } from "./template-source-cache.js";
|
|
36
39
|
export type { ExternalTemplateCachePruneOptions, ExternalTemplateCachePruneResult, } from "./template-source-cache.js";
|
|
37
40
|
export { STALE_TEMP_ROOT_MAX_AGE_MS, WP_TYPIA_TEMP_ROOT_PREFIX, cleanupManagedTempRoot, cleanupStaleTempRoots, createManagedTempRoot, getTrackedTempRoots, } from "./temp-roots.js";
|
|
38
|
-
export { createReadlinePrompt, createCliCommandError, createCliDiagnosticCodeError, CliDiagnosticError, CLI_DIAGNOSTIC_CODES, formatCliDiagnosticError, formatAddHelpText, formatDoctorCheckLine, formatDoctorSummaryLine, formatHelpText, formatTemplateDetails, formatTemplateFeatures, formatTemplateSummary, getDoctorChecks, getDoctorFailureDetailLines, getFailingDoctorChecks, getNextSteps, getOptionalOnboarding, getWorkspaceBlockSelectOptions, HOOKED_BLOCK_POSITION_IDS, EDITOR_PLUGIN_SLOT_IDS, isCliDiagnosticError, runAddAdminViewCommand, runAddAbilityCommand, runAddAiFeatureCommand, runAddBindingSourceCommand, runAddBlockCommand, runAddBlockStyleCommand, runAddBlockTransformCommand, runAddEditorPluginCommand, runAddHookedBlockCommand, runAddPatternCommand, runDoctor, runAddVariationCommand, runScaffoldFlow, } from "./cli-core.js";
|
|
39
|
-
export type { CliDiagnosticCode, CliDiagnosticCodeError, CliDiagnosticMessage, DoctorCheck, EditorPluginSlotId, HookedBlockPositionId, ReadlinePrompt, } from "./cli-core.js";
|
|
41
|
+
export { createReadlinePrompt, createCliCommandError, createCliDiagnosticCodeError, CliDiagnosticError, CLI_DIAGNOSTIC_CODES, formatCliDiagnosticError, formatAddHelpText, formatDoctorCheckLine, formatDoctorSummaryLine, formatHelpText, formatTemplateDetails, formatTemplateFeatures, formatTemplateSummary, getDoctorChecks, getDoctorFailureDetailLines, getFailingDoctorChecks, getNextSteps, getOptionalOnboarding, getWorkspaceBlockSelectOptions, getWorkspaceBlockSelectOptionsAsync, HOOKED_BLOCK_POSITION_IDS, EDITOR_PLUGIN_SLOT_IDS, isCliDiagnosticError, runAddAdminViewCommand, runAddAbilityCommand, runAddAiFeatureCommand, runAddBindingSourceCommand, runAddBlockCommand, runAddBlockStyleCommand, runAddBlockTransformCommand, runAddEditorPluginCommand, runAddHookedBlockCommand, runAddPatternCommand, runDoctor, runAddVariationCommand, runScaffoldFlow, } from "./cli-core.js";
|
|
42
|
+
export type { CliDiagnosticCode, CliDiagnosticCodeError, CliDiagnosticMessage, DoctorCheck, EditorPluginSlotId, HookedBlockPositionId, ReadlinePrompt, WorkspaceBlockSelectOption, } from "./cli-core.js";
|
package/dist/runtime/index.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* CLI while keeping reusable project logic out of the CLI package itself.
|
|
6
6
|
* Consumers should prefer these exports for scaffold, add, migrate, doctor,
|
|
7
7
|
* and workspace-aware helpers such as `getWorkspaceBlockSelectOptions`,
|
|
8
|
+
* `getWorkspaceBlockSelectOptionsAsync`,
|
|
8
9
|
* `runAddBlockCommand`, `runAddBlockStyleCommand`,
|
|
9
10
|
* `runAddBlockTransformCommand`, `runAddVariationCommand`,
|
|
10
11
|
* `runAddPatternCommand`, `runAddBindingSourceCommand`,
|
|
@@ -23,8 +24,9 @@ export { parseWorkspacePackageManagerId, resolveWorkspaceProject, tryResolveWork
|
|
|
23
24
|
export { manifestAttributeToJsonSchema, projectJsonSchemaDocument, manifestToJsonSchema, manifestToOpenApi, normalizeEndpointAuthDefinition, } from "./schema-core.js";
|
|
24
25
|
export { buildCompoundChildStarterManifestDocument, getStarterManifestFiles, stringifyStarterManifest, } from "./starter-manifests.js";
|
|
25
26
|
export { PACKAGE_MANAGER_IDS, PACKAGE_MANAGERS, formatPackageExecCommand, formatInstallCommand, formatRunScript, getPackageManager, getPackageManagerSelectOptions, transformPackageManagerText, } from "./package-managers.js";
|
|
27
|
+
export { suggestCloseId } from "./id-suggestions.js";
|
|
26
28
|
export { clearPackageVersionsCache, getPackageVersions, invalidatePackageVersionsCache, } from "./package-versions.js";
|
|
27
29
|
export { TEMPLATE_IDS, TEMPLATE_REGISTRY, getTemplateById, getTemplateSelectOptions, listTemplates, } from "./template-registry.js";
|
|
28
30
|
export { EXTERNAL_TEMPLATE_CACHE_TTL_DAYS_ENV, pruneExternalTemplateCache, } from "./template-source-cache.js";
|
|
29
31
|
export { STALE_TEMP_ROOT_MAX_AGE_MS, WP_TYPIA_TEMP_ROOT_PREFIX, cleanupManagedTempRoot, cleanupStaleTempRoots, createManagedTempRoot, getTrackedTempRoots, } from "./temp-roots.js";
|
|
30
|
-
export { createReadlinePrompt, createCliCommandError, createCliDiagnosticCodeError, CliDiagnosticError, CLI_DIAGNOSTIC_CODES, formatCliDiagnosticError, formatAddHelpText, formatDoctorCheckLine, formatDoctorSummaryLine, formatHelpText, formatTemplateDetails, formatTemplateFeatures, formatTemplateSummary, getDoctorChecks, getDoctorFailureDetailLines, getFailingDoctorChecks, getNextSteps, getOptionalOnboarding, getWorkspaceBlockSelectOptions, HOOKED_BLOCK_POSITION_IDS, EDITOR_PLUGIN_SLOT_IDS, isCliDiagnosticError, runAddAdminViewCommand, runAddAbilityCommand, runAddAiFeatureCommand, runAddBindingSourceCommand, runAddBlockCommand, runAddBlockStyleCommand, runAddBlockTransformCommand, runAddEditorPluginCommand, runAddHookedBlockCommand, runAddPatternCommand, runDoctor, runAddVariationCommand, runScaffoldFlow, } from "./cli-core.js";
|
|
32
|
+
export { createReadlinePrompt, createCliCommandError, createCliDiagnosticCodeError, CliDiagnosticError, CLI_DIAGNOSTIC_CODES, formatCliDiagnosticError, formatAddHelpText, formatDoctorCheckLine, formatDoctorSummaryLine, formatHelpText, formatTemplateDetails, formatTemplateFeatures, formatTemplateSummary, getDoctorChecks, getDoctorFailureDetailLines, getFailingDoctorChecks, getNextSteps, getOptionalOnboarding, getWorkspaceBlockSelectOptions, getWorkspaceBlockSelectOptionsAsync, HOOKED_BLOCK_POSITION_IDS, EDITOR_PLUGIN_SLOT_IDS, isCliDiagnosticError, runAddAdminViewCommand, runAddAbilityCommand, runAddAiFeatureCommand, runAddBindingSourceCommand, runAddBlockCommand, runAddBlockStyleCommand, runAddBlockTransformCommand, runAddEditorPluginCommand, runAddHookedBlockCommand, runAddPatternCommand, runDoctor, runAddVariationCommand, runScaffoldFlow, } from "./cli-core.js";
|
|
@@ -59,6 +59,9 @@ export function verifyProjectMigrations(projectDir, { all = false, fromMigration
|
|
|
59
59
|
return { verifiedVersions: targetVersions };
|
|
60
60
|
}
|
|
61
61
|
function recordWorkspaceMigrationTargetAlignment(projectDir, state, recordCheck) {
|
|
62
|
+
// `migrate doctor` is still a synchronous maintenance command: it shares
|
|
63
|
+
// sync migration project loading, generated artifact comparisons, and
|
|
64
|
+
// execFileSync verification with the rest of migration maintenance.
|
|
62
65
|
let invalidWorkspaceReason = null;
|
|
63
66
|
let workspace;
|
|
64
67
|
try {
|
|
@@ -76,6 +79,8 @@ function recordWorkspaceMigrationTargetAlignment(projectDir, state, recordCheck)
|
|
|
76
79
|
return;
|
|
77
80
|
}
|
|
78
81
|
try {
|
|
82
|
+
// Maintenance verification is intentionally synchronous so it can compare
|
|
83
|
+
// migration state against a single inventory snapshot.
|
|
79
84
|
const inventory = readWorkspaceInventory(workspace.projectDir);
|
|
80
85
|
const expectedTargets = inventory.blocks.map((block) => `${workspace.workspace.namespace}/${block.slug}`);
|
|
81
86
|
const configuredTargets = state.blocks.map((block) => block.blockName);
|
|
@@ -217,6 +217,10 @@ export function renderPhpMigrationRegistryFile(state, entries) {
|
|
|
217
217
|
return `<?php
|
|
218
218
|
declare(strict_types=1);
|
|
219
219
|
|
|
220
|
+
if ( ! defined( 'ABSPATH' ) ) {
|
|
221
|
+
\texit;
|
|
222
|
+
}
|
|
223
|
+
|
|
220
224
|
/**
|
|
221
225
|
* Generated from advanced migration snapshots. Do not edit manually.
|
|
222
226
|
*/
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import { createRequire } from 'node:module';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
+
import { getOptionalNodeErrorCode } from './fs-async.js';
|
|
4
5
|
import { PROJECT_TOOLS_PACKAGE_ROOT } from './template-registry.js';
|
|
5
6
|
const require = createRequire(import.meta.url);
|
|
6
7
|
const DEFAULT_VERSION_RANGE = '^0.0.0';
|
|
@@ -21,11 +22,6 @@ export const DEFAULT_WORDPRESS_DATA_VERSION = '^9.28.0';
|
|
|
21
22
|
export const DEFAULT_WORDPRESS_DATAVIEWS_VERSION = '^14.1.0';
|
|
22
23
|
export const DEFAULT_WP_TYPIA_DATAVIEWS_VERSION = '^0.1.1';
|
|
23
24
|
let cachedPackageVersions = null;
|
|
24
|
-
function getErrorCode(error) {
|
|
25
|
-
return typeof error === 'object' && error !== null && 'code' in error
|
|
26
|
-
? String(error.code)
|
|
27
|
-
: undefined;
|
|
28
|
-
}
|
|
29
25
|
function normalizeVersionRange(value) {
|
|
30
26
|
const trimmed = value?.trim();
|
|
31
27
|
if (!trimmed) {
|
|
@@ -82,7 +78,7 @@ function resolvePackageManifestLocation(packageJsonPath) {
|
|
|
82
78
|
};
|
|
83
79
|
}
|
|
84
80
|
catch (error) {
|
|
85
|
-
if (
|
|
81
|
+
if (getOptionalNodeErrorCode(error) === 'ENOENT') {
|
|
86
82
|
return {
|
|
87
83
|
cacheKey: `missing-file:${packageJsonPath}`,
|
|
88
84
|
packageJsonPath: null,
|
|
@@ -114,7 +110,7 @@ function resolveInstalledPackageManifestLocation(packageName) {
|
|
|
114
110
|
return resolvePackageManifestLocation(require.resolve(`${packageName}/package.json`));
|
|
115
111
|
}
|
|
116
112
|
catch (error) {
|
|
117
|
-
if (
|
|
113
|
+
if (getOptionalNodeErrorCode(error) === 'MODULE_NOT_FOUND') {
|
|
118
114
|
return {
|
|
119
115
|
cacheKey: `missing-module:${packageName}`,
|
|
120
116
|
packageJsonPath: null,
|