@wp-typia/project-tools 0.17.0 → 0.19.0
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/alternate-render-targets.d.ts +5 -0
- package/dist/runtime/alternate-render-targets.js +29 -0
- package/dist/runtime/block-generator-service-core.d.ts +2 -2
- package/dist/runtime/block-generator-service-core.js +13 -8
- package/dist/runtime/block-generator-service-spec.d.ts +10 -2
- package/dist/runtime/block-generator-service-spec.js +43 -1
- package/dist/runtime/built-in-block-artifacts.js +1 -0
- package/dist/runtime/built-in-block-code-templates/compound-child.d.ts +2 -2
- package/dist/runtime/built-in-block-code-templates/compound-child.js +35 -2
- package/dist/runtime/built-in-block-code-templates/compound-parent.d.ts +2 -2
- package/dist/runtime/built-in-block-code-templates/compound-parent.js +204 -27
- package/dist/runtime/built-in-block-code-templates/compound-persistence.d.ts +1 -1
- package/dist/runtime/built-in-block-code-templates/compound-persistence.js +11 -8
- package/dist/runtime/built-in-block-non-ts-artifacts.js +505 -2
- package/dist/runtime/cli-add-block.d.ts +6 -2
- package/dist/runtime/cli-add-block.js +71 -24
- package/dist/runtime/cli-add-shared.d.ts +58 -2
- package/dist/runtime/cli-add-shared.js +111 -12
- package/dist/runtime/cli-add-workspace-assets.d.ts +21 -1
- package/dist/runtime/cli-add-workspace-assets.js +417 -1
- package/dist/runtime/cli-add-workspace-rest.d.ts +14 -0
- package/dist/runtime/cli-add-workspace-rest.js +1060 -0
- package/dist/runtime/cli-add-workspace.d.ts +10 -1
- package/dist/runtime/cli-add-workspace.js +10 -1
- package/dist/runtime/cli-add.d.ts +3 -3
- package/dist/runtime/cli-add.js +2 -2
- package/dist/runtime/cli-core.d.ts +5 -1
- package/dist/runtime/cli-core.js +3 -1
- package/dist/runtime/cli-doctor-workspace.js +135 -1
- package/dist/runtime/cli-help.js +12 -7
- package/dist/runtime/cli-scaffold.d.ts +12 -2
- package/dist/runtime/cli-scaffold.js +222 -46
- package/dist/runtime/cli-templates.d.ts +4 -4
- package/dist/runtime/cli-templates.js +104 -39
- package/dist/runtime/cli-validation.d.ts +66 -0
- package/dist/runtime/cli-validation.js +92 -0
- package/dist/runtime/compound-inner-blocks.d.ts +78 -0
- package/dist/runtime/compound-inner-blocks.js +88 -0
- package/dist/runtime/index.d.ts +6 -3
- package/dist/runtime/index.js +4 -2
- package/dist/runtime/local-dev-presets.js +7 -2
- package/dist/runtime/migration-command-surface.js +2 -0
- package/dist/runtime/package-versions.d.ts +1 -0
- package/dist/runtime/package-versions.js +12 -0
- package/dist/runtime/rest-resource-artifacts.d.ts +35 -0
- package/dist/runtime/rest-resource-artifacts.js +158 -0
- package/dist/runtime/scaffold-answer-resolution.js +78 -8
- package/dist/runtime/scaffold-apply-utils.d.ts +4 -3
- package/dist/runtime/scaffold-apply-utils.js +34 -17
- package/dist/runtime/scaffold-bootstrap.d.ts +15 -0
- package/dist/runtime/scaffold-bootstrap.js +29 -7
- package/dist/runtime/scaffold-documents.js +24 -3
- package/dist/runtime/scaffold-identifiers.d.ts +17 -0
- package/dist/runtime/scaffold-identifiers.js +22 -0
- package/dist/runtime/scaffold-onboarding.js +25 -13
- package/dist/runtime/scaffold-package-manager-files.js +6 -1
- package/dist/runtime/scaffold-template-variables.js +22 -0
- package/dist/runtime/scaffold.d.ts +22 -1
- package/dist/runtime/scaffold.js +56 -11
- package/dist/runtime/template-render.d.ts +5 -2
- package/dist/runtime/template-render.js +9 -3
- package/dist/runtime/template-source-contracts.d.ts +11 -0
- package/dist/runtime/template-source-external.d.ts +1 -1
- package/dist/runtime/template-source-external.js +45 -13
- package/dist/runtime/template-source-normalization.d.ts +1 -1
- package/dist/runtime/template-source-normalization.js +5 -1
- package/dist/runtime/template-source-remote.d.ts +5 -0
- package/dist/runtime/template-source-remote.js +33 -0
- package/dist/runtime/template-source.js +35 -4
- package/dist/runtime/workspace-inventory.d.ts +43 -1
- package/dist/runtime/workspace-inventory.js +132 -1
- package/dist/runtime/workspace-project.d.ts +1 -1
- package/dist/runtime/workspace-project.js +3 -3
- package/package.json +9 -4
- package/templates/_shared/compound/core/scripts/add-compound-child.ts.mustache +728 -49
- package/templates/query-loop/src/validator-toolkit.ts.mustache +0 -1
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
/**
|
|
4
|
+
* Normalize one optional CLI string flag by trimming whitespace and collapsing
|
|
5
|
+
* empty strings to `undefined`.
|
|
6
|
+
*
|
|
7
|
+
* @param value Raw CLI value before normalization.
|
|
8
|
+
* @returns The trimmed string when present, otherwise `undefined`.
|
|
9
|
+
*/
|
|
10
|
+
export function normalizeOptionalCliString(value) {
|
|
11
|
+
if (typeof value !== "string") {
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
const trimmed = value.trim();
|
|
15
|
+
return trimmed.length > 0 ? trimmed : undefined;
|
|
16
|
+
}
|
|
17
|
+
function looksLikeLocalCliPath(value) {
|
|
18
|
+
return (path.isAbsolute(value) ||
|
|
19
|
+
value.startsWith("./") ||
|
|
20
|
+
value.startsWith("../") ||
|
|
21
|
+
value.startsWith(".\\") ||
|
|
22
|
+
value.startsWith("..\\"));
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Resolve one CLI path flag relative to the caller when it is expressed as a
|
|
26
|
+
* local filesystem path.
|
|
27
|
+
*
|
|
28
|
+
* Non-local values such as npm package specs or `github:` locators pass
|
|
29
|
+
* through unchanged. Local relative and absolute paths are resolved against the
|
|
30
|
+
* provided `cwd` and must exist on disk.
|
|
31
|
+
*
|
|
32
|
+
* @param options Path resolution inputs for one CLI flag.
|
|
33
|
+
* @param options.cwd Caller working directory used for relative path
|
|
34
|
+
* resolution.
|
|
35
|
+
* @param options.label Human-readable option label used in thrown errors.
|
|
36
|
+
* @param options.value Raw CLI value before trimming and path resolution.
|
|
37
|
+
* @returns The normalized string, or `undefined` when the option was omitted.
|
|
38
|
+
* @throws When a local-looking path resolves to a missing filesystem entry.
|
|
39
|
+
*/
|
|
40
|
+
export function resolveLocalCliPathOption(options) {
|
|
41
|
+
const normalizedValue = normalizeOptionalCliString(options.value);
|
|
42
|
+
if (!normalizedValue || !looksLikeLocalCliPath(normalizedValue)) {
|
|
43
|
+
return normalizedValue;
|
|
44
|
+
}
|
|
45
|
+
const resolvedPath = path.resolve(options.cwd, normalizedValue);
|
|
46
|
+
if (!fs.existsSync(resolvedPath)) {
|
|
47
|
+
throw new Error(`\`${options.label}\` path does not exist: ${resolvedPath}. Check the path relative to ${options.cwd}.`);
|
|
48
|
+
}
|
|
49
|
+
return resolvedPath;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Validate the built-in template composition rule for external layers.
|
|
53
|
+
*
|
|
54
|
+
* @param options External layer CLI options after normalization.
|
|
55
|
+
* @param options.externalLayerId Optional selected layer id.
|
|
56
|
+
* @param options.externalLayerSource Optional layer source locator or path.
|
|
57
|
+
* @throws When `externalLayerId` is provided without `externalLayerSource`.
|
|
58
|
+
*/
|
|
59
|
+
export function assertExternalLayerCompositionOptions(options) {
|
|
60
|
+
if (options.externalLayerId && !options.externalLayerSource) {
|
|
61
|
+
throw new Error("externalLayerId requires externalLayerSource when composing built-in template layers.");
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Build the shared error message used when a built-in template receives a
|
|
66
|
+
* `--variant` override.
|
|
67
|
+
*
|
|
68
|
+
* @param options Built-in template context.
|
|
69
|
+
* @param options.templateId Built-in template id that rejected the variant.
|
|
70
|
+
* @param options.variant User-supplied variant override.
|
|
71
|
+
* @returns The canonical user-facing error message.
|
|
72
|
+
*/
|
|
73
|
+
export function createBuiltInVariantErrorMessage(options) {
|
|
74
|
+
return `--variant is only supported for official external template configs. Received variant "${options.variant}" for built-in template "${options.templateId}".`;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Reject unsupported `--variant` usage for built-in templates.
|
|
78
|
+
*
|
|
79
|
+
* @param options Built-in template validation context.
|
|
80
|
+
* @param options.templateId Built-in template id being scaffolded.
|
|
81
|
+
* @param options.variant Optional variant override from CLI flags.
|
|
82
|
+
* @throws When a built-in template receives any explicit `--variant` value.
|
|
83
|
+
*/
|
|
84
|
+
export function assertBuiltInTemplateVariantAllowed(options) {
|
|
85
|
+
if (!options.variant) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
throw new Error(createBuiltInVariantErrorMessage({
|
|
89
|
+
templateId: options.templateId,
|
|
90
|
+
variant: options.variant,
|
|
91
|
+
}));
|
|
92
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable preset ids exposed to scaffold and UI consumers for compound
|
|
3
|
+
* InnerBlocks authoring behavior.
|
|
4
|
+
*/
|
|
5
|
+
export declare const COMPOUND_INNER_BLOCKS_PRESET_IDS: readonly ["freeform", "ordered", "horizontal", "locked-structure"];
|
|
6
|
+
export type CompoundInnerBlocksPresetId = (typeof COMPOUND_INNER_BLOCKS_PRESET_IDS)[number];
|
|
7
|
+
/**
|
|
8
|
+
* Default preset applied when callers do not provide an explicit compound
|
|
9
|
+
* InnerBlocks mode.
|
|
10
|
+
*/
|
|
11
|
+
export declare const DEFAULT_COMPOUND_INNER_BLOCKS_PRESET_ID: CompoundInnerBlocksPresetId;
|
|
12
|
+
export type CompoundInnerBlocksOrientation = "horizontal" | "vertical";
|
|
13
|
+
export type CompoundInnerBlocksTemplateLock = false | "insert" | "all";
|
|
14
|
+
/**
|
|
15
|
+
* Runtime-facing description of one compound InnerBlocks preset.
|
|
16
|
+
*/
|
|
17
|
+
export interface CompoundInnerBlocksPresetDefinition {
|
|
18
|
+
description: string;
|
|
19
|
+
directInsert: boolean;
|
|
20
|
+
label: string;
|
|
21
|
+
orientation?: CompoundInnerBlocksOrientation;
|
|
22
|
+
templateLock: CompoundInnerBlocksTemplateLock;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Canonical preset registry used by the CLI, generated scaffolds, and TUI
|
|
26
|
+
* forms.
|
|
27
|
+
*/
|
|
28
|
+
export declare const COMPOUND_INNER_BLOCKS_PRESET_REGISTRY: {
|
|
29
|
+
readonly freeform: {
|
|
30
|
+
readonly description: "Unlocked nested authoring with the default inserter and starter child template.";
|
|
31
|
+
readonly directInsert: false;
|
|
32
|
+
readonly label: "freeform";
|
|
33
|
+
readonly orientation: "vertical";
|
|
34
|
+
readonly templateLock: false;
|
|
35
|
+
};
|
|
36
|
+
readonly ordered: {
|
|
37
|
+
readonly description: "Vertical ordered flow that keeps starter structure fixed while allowing new sibling inserts.";
|
|
38
|
+
readonly directInsert: true;
|
|
39
|
+
readonly label: "ordered";
|
|
40
|
+
readonly orientation: "vertical";
|
|
41
|
+
readonly templateLock: "insert";
|
|
42
|
+
};
|
|
43
|
+
readonly horizontal: {
|
|
44
|
+
readonly description: "Horizontal nested layout with one-click direct inserts for row or tab style containers.";
|
|
45
|
+
readonly directInsert: true;
|
|
46
|
+
readonly label: "horizontal";
|
|
47
|
+
readonly orientation: "horizontal";
|
|
48
|
+
readonly templateLock: false;
|
|
49
|
+
};
|
|
50
|
+
readonly "locked-structure": {
|
|
51
|
+
readonly description: "Locked starter structure for guided document shells where authors should only edit seeded children.";
|
|
52
|
+
readonly directInsert: false;
|
|
53
|
+
readonly label: "locked-structure";
|
|
54
|
+
readonly orientation: "vertical";
|
|
55
|
+
readonly templateLock: "all";
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Returns whether a string matches one of the supported compound preset ids.
|
|
60
|
+
*/
|
|
61
|
+
export declare function isCompoundInnerBlocksPresetId(value: string): value is CompoundInnerBlocksPresetId;
|
|
62
|
+
/**
|
|
63
|
+
* Parses a raw CLI or config value into a supported preset id.
|
|
64
|
+
*
|
|
65
|
+
* Returns `undefined` for non-string or empty input, and throws when the input
|
|
66
|
+
* is a non-empty unsupported preset id.
|
|
67
|
+
*/
|
|
68
|
+
export declare function parseCompoundInnerBlocksPreset(value?: string): CompoundInnerBlocksPresetId | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* Resolves an optional preset id to a concrete preset, defaulting to
|
|
71
|
+
* `DEFAULT_COMPOUND_INNER_BLOCKS_PRESET_ID`.
|
|
72
|
+
*/
|
|
73
|
+
export declare function resolveCompoundInnerBlocksPreset(value?: CompoundInnerBlocksPresetId): CompoundInnerBlocksPresetId;
|
|
74
|
+
/**
|
|
75
|
+
* Looks up the preset definition for the provided preset id, applying the
|
|
76
|
+
* default preset when the input is omitted.
|
|
77
|
+
*/
|
|
78
|
+
export declare function getCompoundInnerBlocksPresetDefinition(value?: CompoundInnerBlocksPresetId): CompoundInnerBlocksPresetDefinition;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable preset ids exposed to scaffold and UI consumers for compound
|
|
3
|
+
* InnerBlocks authoring behavior.
|
|
4
|
+
*/
|
|
5
|
+
export const COMPOUND_INNER_BLOCKS_PRESET_IDS = [
|
|
6
|
+
"freeform",
|
|
7
|
+
"ordered",
|
|
8
|
+
"horizontal",
|
|
9
|
+
"locked-structure",
|
|
10
|
+
];
|
|
11
|
+
/**
|
|
12
|
+
* Default preset applied when callers do not provide an explicit compound
|
|
13
|
+
* InnerBlocks mode.
|
|
14
|
+
*/
|
|
15
|
+
export const DEFAULT_COMPOUND_INNER_BLOCKS_PRESET_ID = "freeform";
|
|
16
|
+
/**
|
|
17
|
+
* Canonical preset registry used by the CLI, generated scaffolds, and TUI
|
|
18
|
+
* forms.
|
|
19
|
+
*/
|
|
20
|
+
export const COMPOUND_INNER_BLOCKS_PRESET_REGISTRY = {
|
|
21
|
+
freeform: {
|
|
22
|
+
description: "Unlocked nested authoring with the default inserter and starter child template.",
|
|
23
|
+
directInsert: false,
|
|
24
|
+
label: "freeform",
|
|
25
|
+
orientation: "vertical",
|
|
26
|
+
templateLock: false,
|
|
27
|
+
},
|
|
28
|
+
ordered: {
|
|
29
|
+
description: "Vertical ordered flow that keeps starter structure fixed while allowing new sibling inserts.",
|
|
30
|
+
directInsert: true,
|
|
31
|
+
label: "ordered",
|
|
32
|
+
orientation: "vertical",
|
|
33
|
+
templateLock: "insert",
|
|
34
|
+
},
|
|
35
|
+
horizontal: {
|
|
36
|
+
description: "Horizontal nested layout with one-click direct inserts for row or tab style containers.",
|
|
37
|
+
directInsert: true,
|
|
38
|
+
label: "horizontal",
|
|
39
|
+
orientation: "horizontal",
|
|
40
|
+
templateLock: false,
|
|
41
|
+
},
|
|
42
|
+
"locked-structure": {
|
|
43
|
+
description: "Locked starter structure for guided document shells where authors should only edit seeded children.",
|
|
44
|
+
directInsert: false,
|
|
45
|
+
label: "locked-structure",
|
|
46
|
+
orientation: "vertical",
|
|
47
|
+
templateLock: "all",
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Returns whether a string matches one of the supported compound preset ids.
|
|
52
|
+
*/
|
|
53
|
+
export function isCompoundInnerBlocksPresetId(value) {
|
|
54
|
+
return COMPOUND_INNER_BLOCKS_PRESET_IDS.includes(value);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Parses a raw CLI or config value into a supported preset id.
|
|
58
|
+
*
|
|
59
|
+
* Returns `undefined` for non-string or empty input, and throws when the input
|
|
60
|
+
* is a non-empty unsupported preset id.
|
|
61
|
+
*/
|
|
62
|
+
export function parseCompoundInnerBlocksPreset(value) {
|
|
63
|
+
if (typeof value !== "string") {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
const normalizedValue = value.trim();
|
|
67
|
+
if (normalizedValue.length === 0) {
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
if (!isCompoundInnerBlocksPresetId(normalizedValue)) {
|
|
71
|
+
throw new Error(`Unsupported InnerBlocks preset "${value}". Expected one of: ${COMPOUND_INNER_BLOCKS_PRESET_IDS.join(", ")}.`);
|
|
72
|
+
}
|
|
73
|
+
return normalizedValue;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Resolves an optional preset id to a concrete preset, defaulting to
|
|
77
|
+
* `DEFAULT_COMPOUND_INNER_BLOCKS_PRESET_ID`.
|
|
78
|
+
*/
|
|
79
|
+
export function resolveCompoundInnerBlocksPreset(value) {
|
|
80
|
+
return value ?? DEFAULT_COMPOUND_INNER_BLOCKS_PRESET_ID;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Looks up the preset definition for the provided preset id, applying the
|
|
84
|
+
* default preset when the input is omitted.
|
|
85
|
+
*/
|
|
86
|
+
export function getCompoundInnerBlocksPresetDefinition(value) {
|
|
87
|
+
return COMPOUND_INNER_BLOCKS_PRESET_REGISTRY[resolveCompoundInnerBlocksPreset(value)];
|
|
88
|
+
}
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -6,9 +6,12 @@
|
|
|
6
6
|
* Consumers should prefer these exports for scaffold, add, migrate, doctor,
|
|
7
7
|
* and workspace-aware helpers such as `getWorkspaceBlockSelectOptions`,
|
|
8
8
|
* `runAddBlockCommand`, `runAddVariationCommand`, `runAddPatternCommand`,
|
|
9
|
-
* `runAddBindingSourceCommand`, `
|
|
9
|
+
* `runAddBindingSourceCommand`, `runAddEditorPluginCommand`,
|
|
10
|
+
* `runAddHookedBlockCommand`,
|
|
10
11
|
* `HOOKED_BLOCK_POSITION_IDS`, and `runDoctor`.
|
|
11
12
|
*/
|
|
13
|
+
export { COMPOUND_INNER_BLOCKS_PRESET_IDS, DEFAULT_COMPOUND_INNER_BLOCKS_PRESET_ID, getCompoundInnerBlocksPresetDefinition, isCompoundInnerBlocksPresetId, parseCompoundInnerBlocksPreset, resolveCompoundInnerBlocksPreset, } from "./compound-inner-blocks.js";
|
|
14
|
+
export type { CompoundInnerBlocksPresetDefinition, CompoundInnerBlocksPresetId, CompoundInnerBlocksTemplateLock, } from "./compound-inner-blocks.js";
|
|
12
15
|
export { scaffoldProject, collectScaffoldAnswers, getDefaultAnswers, getTemplateVariables, resolvePackageManagerId, resolveTemplateId, } from "./scaffold.js";
|
|
13
16
|
export { BlockGeneratorService } from "./block-generator-service.js";
|
|
14
17
|
export type { ApplyBlockInput, BlockGenerationTarget, BlockSpec, PlanBlockInput, PlanBlockResult, RenderBlockInput, RenderBlockResult, ValidateBlockInput, ValidateBlockResult, } from "./block-generator-service.js";
|
|
@@ -21,5 +24,5 @@ export { buildCompoundChildStarterManifestDocument, getStarterManifestFiles, str
|
|
|
21
24
|
export type { EndpointAuthIntent, EndpointOpenApiAuthMode, EndpointOpenApiContractDocument, EndpointOpenApiDocumentOptions, EndpointOpenApiEndpointDefinition, EndpointOpenApiMethod, EndpointWordPressAuthDefinition, EndpointWordPressAuthMechanism, JsonSchemaDocument, JsonSchemaProjectionProfile, JsonSchemaObject, NormalizedEndpointAuthDefinition, OpenApiDocument, OpenApiInfo, OpenApiOperation, OpenApiParameter, OpenApiPathItem, OpenApiSecurityScheme, } from "./schema-core.js";
|
|
22
25
|
export { PACKAGE_MANAGER_IDS, PACKAGE_MANAGERS, formatPackageExecCommand, formatInstallCommand, formatRunScript, getPackageManager, getPackageManagerSelectOptions, transformPackageManagerText, } from "./package-managers.js";
|
|
23
26
|
export { TEMPLATE_IDS, TEMPLATE_REGISTRY, getTemplateById, getTemplateSelectOptions, listTemplates, } from "./template-registry.js";
|
|
24
|
-
export { createReadlinePrompt, createCliCommandError, CliDiagnosticError, formatCliDiagnosticError, formatAddHelpText, formatDoctorCheckLine, formatDoctorSummaryLine, formatHelpText, formatTemplateDetails, formatTemplateFeatures, formatTemplateSummary, getDoctorChecks, getDoctorFailureDetailLines, getFailingDoctorChecks, getNextSteps, getOptionalOnboarding, getWorkspaceBlockSelectOptions, HOOKED_BLOCK_POSITION_IDS, isCliDiagnosticError, runAddBindingSourceCommand, runAddBlockCommand, runAddHookedBlockCommand, runAddPatternCommand, runDoctor, runAddVariationCommand, runScaffoldFlow, } from "./cli-core.js";
|
|
25
|
-
export type { CliDiagnosticMessage, DoctorCheck, HookedBlockPositionId, ReadlinePrompt, } from "./cli-core.js";
|
|
27
|
+
export { createReadlinePrompt, createCliCommandError, CliDiagnosticError, formatCliDiagnosticError, formatAddHelpText, formatDoctorCheckLine, formatDoctorSummaryLine, formatHelpText, formatTemplateDetails, formatTemplateFeatures, formatTemplateSummary, getDoctorChecks, getDoctorFailureDetailLines, getFailingDoctorChecks, getNextSteps, getOptionalOnboarding, getWorkspaceBlockSelectOptions, HOOKED_BLOCK_POSITION_IDS, EDITOR_PLUGIN_SLOT_IDS, isCliDiagnosticError, runAddBindingSourceCommand, runAddBlockCommand, runAddEditorPluginCommand, runAddHookedBlockCommand, runAddPatternCommand, runDoctor, runAddVariationCommand, runScaffoldFlow, } from "./cli-core.js";
|
|
28
|
+
export type { CliDiagnosticMessage, DoctorCheck, EditorPluginSlotId, HookedBlockPositionId, ReadlinePrompt, } from "./cli-core.js";
|
package/dist/runtime/index.js
CHANGED
|
@@ -6,9 +6,11 @@
|
|
|
6
6
|
* Consumers should prefer these exports for scaffold, add, migrate, doctor,
|
|
7
7
|
* and workspace-aware helpers such as `getWorkspaceBlockSelectOptions`,
|
|
8
8
|
* `runAddBlockCommand`, `runAddVariationCommand`, `runAddPatternCommand`,
|
|
9
|
-
* `runAddBindingSourceCommand`, `
|
|
9
|
+
* `runAddBindingSourceCommand`, `runAddEditorPluginCommand`,
|
|
10
|
+
* `runAddHookedBlockCommand`,
|
|
10
11
|
* `HOOKED_BLOCK_POSITION_IDS`, and `runDoctor`.
|
|
11
12
|
*/
|
|
13
|
+
export { COMPOUND_INNER_BLOCKS_PRESET_IDS, DEFAULT_COMPOUND_INNER_BLOCKS_PRESET_ID, getCompoundInnerBlocksPresetDefinition, isCompoundInnerBlocksPresetId, parseCompoundInnerBlocksPreset, resolveCompoundInnerBlocksPreset, } from "./compound-inner-blocks.js";
|
|
12
14
|
export { scaffoldProject, collectScaffoldAnswers, getDefaultAnswers, getTemplateVariables, resolvePackageManagerId, resolveTemplateId, } from "./scaffold.js";
|
|
13
15
|
export { BlockGeneratorService } from "./block-generator-service.js";
|
|
14
16
|
export { BLOCK_GENERATION_TOOL_CONTRACT_VERSION, inspectBlockGeneration, } from "./block-generator-tool-contract.js";
|
|
@@ -18,4 +20,4 @@ export { manifestAttributeToJsonSchema, projectJsonSchemaDocument, manifestToJso
|
|
|
18
20
|
export { buildCompoundChildStarterManifestDocument, getStarterManifestFiles, stringifyStarterManifest, } from "./starter-manifests.js";
|
|
19
21
|
export { PACKAGE_MANAGER_IDS, PACKAGE_MANAGERS, formatPackageExecCommand, formatInstallCommand, formatRunScript, getPackageManager, getPackageManagerSelectOptions, transformPackageManagerText, } from "./package-managers.js";
|
|
20
22
|
export { TEMPLATE_IDS, TEMPLATE_REGISTRY, getTemplateById, getTemplateSelectOptions, listTemplates, } from "./template-registry.js";
|
|
21
|
-
export { createReadlinePrompt, createCliCommandError, CliDiagnosticError, formatCliDiagnosticError, formatAddHelpText, formatDoctorCheckLine, formatDoctorSummaryLine, formatHelpText, formatTemplateDetails, formatTemplateFeatures, formatTemplateSummary, getDoctorChecks, getDoctorFailureDetailLines, getFailingDoctorChecks, getNextSteps, getOptionalOnboarding, getWorkspaceBlockSelectOptions, HOOKED_BLOCK_POSITION_IDS, isCliDiagnosticError, runAddBindingSourceCommand, runAddBlockCommand, runAddHookedBlockCommand, runAddPatternCommand, runDoctor, runAddVariationCommand, runScaffoldFlow, } from "./cli-core.js";
|
|
23
|
+
export { createReadlinePrompt, createCliCommandError, CliDiagnosticError, formatCliDiagnosticError, formatAddHelpText, formatDoctorCheckLine, formatDoctorSummaryLine, formatHelpText, formatTemplateDetails, formatTemplateFeatures, formatTemplateSummary, getDoctorChecks, getDoctorFailureDetailLines, getFailingDoctorChecks, getNextSteps, getOptionalOnboarding, getWorkspaceBlockSelectOptions, HOOKED_BLOCK_POSITION_IDS, EDITOR_PLUGIN_SLOT_IDS, isCliDiagnosticError, runAddBindingSourceCommand, runAddBlockCommand, runAddEditorPluginCommand, runAddHookedBlockCommand, runAddPatternCommand, runDoctor, runAddVariationCommand, runScaffoldFlow, } from "./cli-core.js";
|
|
@@ -8,7 +8,7 @@ import fs from "node:fs";
|
|
|
8
8
|
import { promises as fsp } from "node:fs";
|
|
9
9
|
import path from "node:path";
|
|
10
10
|
import { formatRunScript, } from "./package-managers.js";
|
|
11
|
-
import { SHARED_TEST_PRESET_TEMPLATE_ROOT, SHARED_WP_ENV_PRESET_TEMPLATE_ROOT, } from "./template-registry.js";
|
|
11
|
+
import { OFFICIAL_WORKSPACE_TEMPLATE_PACKAGE, SHARED_TEST_PRESET_TEMPLATE_ROOT, SHARED_WP_ENV_PRESET_TEMPLATE_ROOT, } from "./template-registry.js";
|
|
12
12
|
import { copyInterpolatedDirectory } from "./template-render.js";
|
|
13
13
|
function templateHasPersistenceSync(templateId, compoundPersistenceEnabled) {
|
|
14
14
|
return templateId === "persistence" || (templateId === "compound" && compoundPersistenceEnabled);
|
|
@@ -19,6 +19,11 @@ function templateSupportsGeneratedSyncWatchers(templateId) {
|
|
|
19
19
|
templateId === "persistence" ||
|
|
20
20
|
templateId === "compound");
|
|
21
21
|
}
|
|
22
|
+
function templateUsesDevAsPrimaryEntrypoint(templateId) {
|
|
23
|
+
return (templateSupportsGeneratedSyncWatchers(templateId) ||
|
|
24
|
+
templateId === "query-loop" ||
|
|
25
|
+
templateId === OFFICIAL_WORKSPACE_TEMPLATE_PACKAGE);
|
|
26
|
+
}
|
|
22
27
|
function getWatchSyncTypesScript(packageManager, templateId) {
|
|
23
28
|
if (templateId === "compound") {
|
|
24
29
|
return `chokidar "src/blocks/**/types.ts" "scripts/block-config.ts" --debounce 200 -c "${formatRunScript(packageManager, "sync-types")}"`;
|
|
@@ -138,5 +143,5 @@ export async function applyGeneratedProjectDxPackageJson({ compoundPersistenceEn
|
|
|
138
143
|
* scaffolded template.
|
|
139
144
|
*/
|
|
140
145
|
export function getPrimaryDevelopmentScript(templateId) {
|
|
141
|
-
return
|
|
146
|
+
return templateUsesDevAsPrimaryEntrypoint(templateId) ? "dev" : "start";
|
|
142
147
|
}
|
|
@@ -19,6 +19,8 @@ export function formatMigrationHelpText() {
|
|
|
19
19
|
|
|
20
20
|
Notes:
|
|
21
21
|
\`migrate init\` auto-detects supported single-block and \`src/blocks/*\` multi-block layouts.
|
|
22
|
+
\`migrate init\` only retrofits migration support into projects that already match those layouts.
|
|
23
|
+
A broader project-level \`wp-typia init\` path remains future work.
|
|
22
24
|
Migration versions use strict schema labels like \`v1\`, \`v2\`, and \`v3\`.
|
|
23
25
|
\`migrate wizard\` is TTY-only and helps you choose one legacy migration version to preview.
|
|
24
26
|
\`migrate plan\` and \`migrate wizard\` are read-only previews; they do not scaffold rules or fixtures.
|
|
@@ -4,6 +4,7 @@ interface PackageVersions {
|
|
|
4
4
|
blockTypesPackageVersion: string;
|
|
5
5
|
projectToolsPackageVersion: string;
|
|
6
6
|
restPackageVersion: string;
|
|
7
|
+
wpTypiaPackageExactVersion: string;
|
|
7
8
|
wpTypiaPackageVersion: string;
|
|
8
9
|
}
|
|
9
10
|
export declare function getPackageVersions(): PackageVersions;
|
|
@@ -4,6 +4,7 @@ import path from "node:path";
|
|
|
4
4
|
import { PROJECT_TOOLS_PACKAGE_ROOT } from "./template-registry.js";
|
|
5
5
|
const require = createRequire(import.meta.url);
|
|
6
6
|
const DEFAULT_VERSION_RANGE = "^0.0.0";
|
|
7
|
+
const DEFAULT_EXACT_VERSION = "0.0.0";
|
|
7
8
|
let cachedPackageVersions = null;
|
|
8
9
|
function getErrorCode(error) {
|
|
9
10
|
return typeof error === "object" && error !== null && "code" in error
|
|
@@ -20,6 +21,16 @@ function normalizeVersionRange(value) {
|
|
|
20
21
|
}
|
|
21
22
|
return /^[~^<>=]/.test(trimmed) ? trimmed : `^${trimmed}`;
|
|
22
23
|
}
|
|
24
|
+
function normalizeExactVersion(value) {
|
|
25
|
+
const trimmed = value?.trim();
|
|
26
|
+
if (!trimmed) {
|
|
27
|
+
return DEFAULT_EXACT_VERSION;
|
|
28
|
+
}
|
|
29
|
+
if (trimmed.startsWith("workspace:")) {
|
|
30
|
+
return DEFAULT_EXACT_VERSION;
|
|
31
|
+
}
|
|
32
|
+
return trimmed.replace(/^[~^<>=]+/, "");
|
|
33
|
+
}
|
|
23
34
|
function readPackageManifest(packageJsonPath) {
|
|
24
35
|
try {
|
|
25
36
|
return JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
@@ -67,6 +78,7 @@ export function getPackageVersions() {
|
|
|
67
78
|
projectToolsPackageVersion: normalizeVersionRange(createManifest.version),
|
|
68
79
|
restPackageVersion: normalizeVersionRange(createManifest.dependencies?.["@wp-typia/rest"] ??
|
|
69
80
|
resolveInstalledPackageManifest("@wp-typia/rest")?.version),
|
|
81
|
+
wpTypiaPackageExactVersion: normalizeExactVersion(wpTypiaManifest.version),
|
|
70
82
|
wpTypiaPackageVersion: normalizeVersionRange(wpTypiaManifest.version),
|
|
71
83
|
};
|
|
72
84
|
return cachedPackageVersions;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { RestResourceMethodId } from "./cli-add-shared.js";
|
|
2
|
+
interface RestResourceTemplateVariablesLike {
|
|
3
|
+
namespace: string;
|
|
4
|
+
pascalCase: string;
|
|
5
|
+
slugKebabCase: string;
|
|
6
|
+
title: string;
|
|
7
|
+
}
|
|
8
|
+
interface SyncRestResourceArtifactsOptions {
|
|
9
|
+
clientFile: string;
|
|
10
|
+
methods: RestResourceMethodId[];
|
|
11
|
+
outputDir: string;
|
|
12
|
+
projectDir: string;
|
|
13
|
+
typesFile: string;
|
|
14
|
+
validatorsFile: string;
|
|
15
|
+
variables: RestResourceTemplateVariablesLike;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Build the endpoint manifest for a workspace-level REST resource scaffold.
|
|
19
|
+
*
|
|
20
|
+
* @param variables Template naming data used for contract names, routes, and OpenAPI info.
|
|
21
|
+
* @param methods Enabled REST methods for the generated resource.
|
|
22
|
+
* @returns Endpoint manifest consumed by schema, OpenAPI, and client generators.
|
|
23
|
+
*/
|
|
24
|
+
export declare function buildRestResourceEndpointManifest(variables: RestResourceTemplateVariablesLike, methods: RestResourceMethodId[]): import("@wp-typia/block-runtime/metadata-core").EndpointManifestDefinition<Record<string, {
|
|
25
|
+
sourceTypeName: string;
|
|
26
|
+
}>, import("@wp-typia/block-runtime/schema-core").EndpointOpenApiEndpointDefinition[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Synchronize generated schemas, OpenAPI output, and endpoint client code for
|
|
29
|
+
* a workspace-level REST resource scaffold.
|
|
30
|
+
*
|
|
31
|
+
* @param options Resource file paths, enabled methods, and naming variables.
|
|
32
|
+
* @returns A promise that resolves after every generated REST artifact has been refreshed.
|
|
33
|
+
*/
|
|
34
|
+
export declare function syncRestResourceArtifacts({ clientFile, methods, outputDir, projectDir, typesFile, validatorsFile, variables, }: SyncRestResourceArtifactsOptions): Promise<void>;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { defineEndpointManifest, syncEndpointClient, syncRestOpenApi, syncTypeSchemas, } from "@wp-typia/block-runtime/metadata-core";
|
|
3
|
+
/**
|
|
4
|
+
* Build the endpoint manifest for a workspace-level REST resource scaffold.
|
|
5
|
+
*
|
|
6
|
+
* @param variables Template naming data used for contract names, routes, and OpenAPI info.
|
|
7
|
+
* @param methods Enabled REST methods for the generated resource.
|
|
8
|
+
* @returns Endpoint manifest consumed by schema, OpenAPI, and client generators.
|
|
9
|
+
*/
|
|
10
|
+
export function buildRestResourceEndpointManifest(variables, methods) {
|
|
11
|
+
const basePath = `/${variables.namespace}/${variables.slugKebabCase}`;
|
|
12
|
+
const itemPath = `${basePath}/item`;
|
|
13
|
+
const contracts = {};
|
|
14
|
+
const endpoints = [];
|
|
15
|
+
if (methods.includes("list")) {
|
|
16
|
+
contracts["list-query"] = {
|
|
17
|
+
sourceTypeName: `${variables.pascalCase}ListQuery`,
|
|
18
|
+
};
|
|
19
|
+
contracts["list-response"] = {
|
|
20
|
+
sourceTypeName: `${variables.pascalCase}ListResponse`,
|
|
21
|
+
};
|
|
22
|
+
endpoints.push({
|
|
23
|
+
auth: "public",
|
|
24
|
+
method: "GET",
|
|
25
|
+
operationId: `list${variables.pascalCase}Resources`,
|
|
26
|
+
path: basePath,
|
|
27
|
+
queryContract: "list-query",
|
|
28
|
+
responseContract: "list-response",
|
|
29
|
+
summary: `List ${variables.title} resources.`,
|
|
30
|
+
tags: [variables.title],
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
if (methods.includes("read")) {
|
|
34
|
+
contracts["read-query"] = {
|
|
35
|
+
sourceTypeName: `${variables.pascalCase}ReadQuery`,
|
|
36
|
+
};
|
|
37
|
+
contracts["read-response"] = {
|
|
38
|
+
sourceTypeName: `${variables.pascalCase}ReadResponse`,
|
|
39
|
+
};
|
|
40
|
+
endpoints.push({
|
|
41
|
+
auth: "public",
|
|
42
|
+
method: "GET",
|
|
43
|
+
operationId: `read${variables.pascalCase}Resource`,
|
|
44
|
+
path: itemPath,
|
|
45
|
+
queryContract: "read-query",
|
|
46
|
+
responseContract: "read-response",
|
|
47
|
+
summary: `Read one ${variables.title} resource.`,
|
|
48
|
+
tags: [variables.title],
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
if (methods.includes("create")) {
|
|
52
|
+
contracts["create-request"] = {
|
|
53
|
+
sourceTypeName: `${variables.pascalCase}CreateRequest`,
|
|
54
|
+
};
|
|
55
|
+
contracts["create-response"] = {
|
|
56
|
+
sourceTypeName: `${variables.pascalCase}CreateResponse`,
|
|
57
|
+
};
|
|
58
|
+
endpoints.push({
|
|
59
|
+
auth: "authenticated",
|
|
60
|
+
bodyContract: "create-request",
|
|
61
|
+
method: "POST",
|
|
62
|
+
operationId: `create${variables.pascalCase}Resource`,
|
|
63
|
+
path: basePath,
|
|
64
|
+
responseContract: "create-response",
|
|
65
|
+
summary: `Create one ${variables.title} resource.`,
|
|
66
|
+
tags: [variables.title],
|
|
67
|
+
wordpressAuth: {
|
|
68
|
+
mechanism: "rest-nonce",
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
if (methods.includes("update")) {
|
|
73
|
+
contracts["update-query"] = {
|
|
74
|
+
sourceTypeName: `${variables.pascalCase}UpdateQuery`,
|
|
75
|
+
};
|
|
76
|
+
contracts["update-request"] = {
|
|
77
|
+
sourceTypeName: `${variables.pascalCase}UpdateRequest`,
|
|
78
|
+
};
|
|
79
|
+
contracts["update-response"] = {
|
|
80
|
+
sourceTypeName: `${variables.pascalCase}UpdateResponse`,
|
|
81
|
+
};
|
|
82
|
+
endpoints.push({
|
|
83
|
+
auth: "authenticated",
|
|
84
|
+
bodyContract: "update-request",
|
|
85
|
+
method: "POST",
|
|
86
|
+
operationId: `update${variables.pascalCase}Resource`,
|
|
87
|
+
path: itemPath,
|
|
88
|
+
queryContract: "update-query",
|
|
89
|
+
responseContract: "update-response",
|
|
90
|
+
summary: `Update one ${variables.title} resource.`,
|
|
91
|
+
tags: [variables.title],
|
|
92
|
+
wordpressAuth: {
|
|
93
|
+
mechanism: "rest-nonce",
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
if (methods.includes("delete")) {
|
|
98
|
+
contracts["delete-query"] = {
|
|
99
|
+
sourceTypeName: `${variables.pascalCase}DeleteQuery`,
|
|
100
|
+
};
|
|
101
|
+
contracts["delete-response"] = {
|
|
102
|
+
sourceTypeName: `${variables.pascalCase}DeleteResponse`,
|
|
103
|
+
};
|
|
104
|
+
endpoints.push({
|
|
105
|
+
auth: "authenticated",
|
|
106
|
+
method: "DELETE",
|
|
107
|
+
operationId: `delete${variables.pascalCase}Resource`,
|
|
108
|
+
path: itemPath,
|
|
109
|
+
queryContract: "delete-query",
|
|
110
|
+
responseContract: "delete-response",
|
|
111
|
+
summary: `Delete one ${variables.title} resource.`,
|
|
112
|
+
tags: [variables.title],
|
|
113
|
+
wordpressAuth: {
|
|
114
|
+
mechanism: "rest-nonce",
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
return defineEndpointManifest({
|
|
119
|
+
contracts,
|
|
120
|
+
endpoints,
|
|
121
|
+
info: {
|
|
122
|
+
title: `${variables.title} REST API`,
|
|
123
|
+
version: "1.0.0",
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Synchronize generated schemas, OpenAPI output, and endpoint client code for
|
|
129
|
+
* a workspace-level REST resource scaffold.
|
|
130
|
+
*
|
|
131
|
+
* @param options Resource file paths, enabled methods, and naming variables.
|
|
132
|
+
* @returns A promise that resolves after every generated REST artifact has been refreshed.
|
|
133
|
+
*/
|
|
134
|
+
export async function syncRestResourceArtifacts({ clientFile, methods, outputDir, projectDir, typesFile, validatorsFile, variables, }) {
|
|
135
|
+
const manifest = buildRestResourceEndpointManifest(variables, methods);
|
|
136
|
+
for (const [baseName, contract] of Object.entries(manifest.contracts)) {
|
|
137
|
+
await syncTypeSchemas({
|
|
138
|
+
jsonSchemaFile: path.join(outputDir, "api-schemas", `${baseName}.schema.json`),
|
|
139
|
+
openApiFile: path.join(outputDir, "api-schemas", `${baseName}.openapi.json`),
|
|
140
|
+
projectRoot: projectDir,
|
|
141
|
+
sourceTypeName: contract.sourceTypeName,
|
|
142
|
+
typesFile,
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
await syncRestOpenApi({
|
|
146
|
+
manifest,
|
|
147
|
+
openApiFile: path.join(outputDir, "api.openapi.json"),
|
|
148
|
+
projectRoot: projectDir,
|
|
149
|
+
typesFile,
|
|
150
|
+
});
|
|
151
|
+
await syncEndpointClient({
|
|
152
|
+
clientFile,
|
|
153
|
+
manifest,
|
|
154
|
+
projectRoot: projectDir,
|
|
155
|
+
typesFile,
|
|
156
|
+
validatorsFile,
|
|
157
|
+
});
|
|
158
|
+
}
|