wp-typia 0.24.4 → 0.24.6
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/README.md +8 -6
- package/bin/wp-typia.js +24 -103
- package/{dist-bunli/node-cli.js → dist/cli.js} +5086 -3693
- package/package.json +9 -36
- package/bin/routing-metadata.generated.d.ts +0 -8
- package/bin/routing-metadata.generated.js +0 -93
- package/bin/runtime-routing.d.ts +0 -34
- package/bin/runtime-routing.js +0 -124
- package/dist-bunli/.bunli/commands.gen.js +0 -304441
- package/dist-bunli/.bunli/highlights-eq9cgrbb.scm +0 -604
- package/dist-bunli/.bunli/highlights-ghv9g403.scm +0 -205
- package/dist-bunli/.bunli/highlights-hk7bwhj4.scm +0 -284
- package/dist-bunli/.bunli/highlights-r812a2qc.scm +0 -150
- package/dist-bunli/.bunli/highlights-x6tmsnaa.scm +0 -115
- package/dist-bunli/.bunli/injections-73j83es3.scm +0 -27
- package/dist-bunli/.bunli/tree-sitter-javascript-nd0q4pe9.wasm +0 -0
- package/dist-bunli/.bunli/tree-sitter-markdown-411r6y9b.wasm +0 -0
- package/dist-bunli/.bunli/tree-sitter-markdown_inline-j5349f42.wasm +0 -0
- package/dist-bunli/.bunli/tree-sitter-typescript-zxjzwt75.wasm +0 -0
- package/dist-bunli/.bunli/tree-sitter-zig-e78zbjpm.wasm +0 -0
- package/dist-bunli/agents-91fpdyyt.js +0 -12
- package/dist-bunli/chunk-bdqvmfwv-f5qmzmxg.js +0 -16825
- package/dist-bunli/cli-03j0axbt.js +0 -163
- package/dist-bunli/cli-1170yyve.js +0 -106
- package/dist-bunli/cli-368d4cgy.js +0 -1235
- package/dist-bunli/cli-377p86mf.js +0 -191
- package/dist-bunli/cli-6v0pcxw6.js +0 -314
- package/dist-bunli/cli-84c7wff4.js +0 -198
- package/dist-bunli/cli-8hxf9qw6.js +0 -198
- package/dist-bunli/cli-9fx0qgb7.js +0 -3680
- package/dist-bunli/cli-ac2ebaf8.js +0 -3
- package/dist-bunli/cli-add-qjd3ba8j.js +0 -10671
- package/dist-bunli/cli-am5x7tb4.js +0 -192
- package/dist-bunli/cli-bajwv85z.js +0 -24
- package/dist-bunli/cli-ccax7s0s.js +0 -34
- package/dist-bunli/cli-cvxvcw7c.js +0 -46
- package/dist-bunli/cli-diagnostics-10drxh34.js +0 -34
- package/dist-bunli/cli-doctor-6fyxq940.js +0 -1446
- package/dist-bunli/cli-e4bwd81c.js +0 -1260
- package/dist-bunli/cli-fv4h3ydt.js +0 -173823
- package/dist-bunli/cli-hv2yedw2.js +0 -74591
- package/dist-bunli/cli-init-7avk42dh.js +0 -880
- package/dist-bunli/cli-kfm9mm68.js +0 -14679
- package/dist-bunli/cli-prompt-ncyg68rn.js +0 -12
- package/dist-bunli/cli-rdcga1bd.js +0 -135
- package/dist-bunli/cli-scaffold-0bb6pr3w.js +0 -538
- package/dist-bunli/cli-t73q5aqz.js +0 -103
- package/dist-bunli/cli-templates-g8t4fm11.js +0 -167
- package/dist-bunli/cli-tj7ajdvf.js +0 -2612
- package/dist-bunli/cli-tq730sqt.js +0 -344
- package/dist-bunli/cli-xnn9xjcy.js +0 -68
- package/dist-bunli/cli-z48frc8t.js +0 -229
- package/dist-bunli/cli.js +0 -2523
- package/dist-bunli/command-list-y3g7e9rb.js +0 -4013
- package/dist-bunli/create-template-validation-4fr851vg.js +0 -16
- package/dist-bunli/migrations-3vngdy51.js +0 -47
- package/dist-bunli/sync-k2k8svyc.js +0 -13
- package/dist-bunli/workspace-project-gmv2a71z.js +0 -22
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import {
|
|
3
|
-
createReadlinePrompt,
|
|
4
|
-
createReadlinePromptWithInterface
|
|
5
|
-
} from "./cli-rdcga1bd.js";
|
|
6
|
-
import"./cli-xnn9xjcy.js";
|
|
7
|
-
export {
|
|
8
|
-
createReadlinePromptWithInterface,
|
|
9
|
-
createReadlinePrompt
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
//# debugId=9AC7644B53382A7364756E2164756E21
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
// ../wp-typia-project-tools/src/runtime/cli-prompt.ts
|
|
3
|
-
import readline from "readline";
|
|
4
|
-
function createReadlinePrompt(output = {}) {
|
|
5
|
-
const rl = readline.createInterface({
|
|
6
|
-
input: process.stdin,
|
|
7
|
-
output: process.stdout
|
|
8
|
-
});
|
|
9
|
-
return createReadlinePromptWithInterface(rl, output);
|
|
10
|
-
}
|
|
11
|
-
function createReadlinePromptWithInterface(rl, output = {}) {
|
|
12
|
-
const { errorLine, printLine } = resolveReadlinePromptOutput(output);
|
|
13
|
-
const askQuestion = (query) => new Promise((resolve) => {
|
|
14
|
-
rl.question(query, resolve);
|
|
15
|
-
});
|
|
16
|
-
return {
|
|
17
|
-
async text(message, defaultValue, validate) {
|
|
18
|
-
while (true) {
|
|
19
|
-
const value = normalizePromptAnswer(await askQuestion(formatTextPrompt(message, defaultValue))) || defaultValue;
|
|
20
|
-
if (validate) {
|
|
21
|
-
const result = validate(value);
|
|
22
|
-
if (result !== true) {
|
|
23
|
-
errorLine(formatValidationError(message, result, defaultValue));
|
|
24
|
-
continue;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return value;
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
async select(message, options, defaultValue = 1) {
|
|
31
|
-
if (options.length === 0) {
|
|
32
|
-
throw new Error(`select() requires at least one option for prompt: ${message}`);
|
|
33
|
-
}
|
|
34
|
-
const resolvedDefaultIndex = getResolvedDefaultIndex(options, defaultValue);
|
|
35
|
-
renderSelectPrompt(message, options, resolvedDefaultIndex, printLine);
|
|
36
|
-
while (true) {
|
|
37
|
-
const answer = normalizePromptAnswer(await askQuestion(formatChoicePrompt(resolvedDefaultIndex)));
|
|
38
|
-
if (answer.length === 0) {
|
|
39
|
-
return options[resolvedDefaultIndex].value;
|
|
40
|
-
}
|
|
41
|
-
const selection = resolvePromptSelection(options, answer);
|
|
42
|
-
if (selection) {
|
|
43
|
-
return selection.value;
|
|
44
|
-
}
|
|
45
|
-
if (isPromptHelpToken(answer)) {
|
|
46
|
-
renderSelectPrompt(message, options, resolvedDefaultIndex, printLine);
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
errorLine(formatInvalidSelectionError(answer, options, resolvedDefaultIndex));
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
close() {
|
|
53
|
-
rl.close();
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
function resolveReadlinePromptOutput({
|
|
58
|
-
errorLine,
|
|
59
|
-
printLine
|
|
60
|
-
}) {
|
|
61
|
-
return {
|
|
62
|
-
errorLine: errorLine ?? writePromptErrorLine,
|
|
63
|
-
printLine: printLine ?? writePromptLine
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
function writePromptLine(line) {
|
|
67
|
-
process.stdout.write(`${line}
|
|
68
|
-
`);
|
|
69
|
-
}
|
|
70
|
-
function writePromptErrorLine(line) {
|
|
71
|
-
process.stderr.write(`${line}
|
|
72
|
-
`);
|
|
73
|
-
}
|
|
74
|
-
function normalizePromptAnswer(value) {
|
|
75
|
-
return String(value).trim();
|
|
76
|
-
}
|
|
77
|
-
function normalizePromptToken(value) {
|
|
78
|
-
return value.trim().toLowerCase();
|
|
79
|
-
}
|
|
80
|
-
function getResolvedDefaultIndex(options, defaultValue) {
|
|
81
|
-
const candidateIndex = Number.isInteger(defaultValue) ? defaultValue - 1 : -1;
|
|
82
|
-
return options[candidateIndex] ? candidateIndex : 0;
|
|
83
|
-
}
|
|
84
|
-
function formatTextPrompt(message, defaultValue) {
|
|
85
|
-
const suffix = defaultValue.length > 0 ? ` [default: ${defaultValue}]` : "";
|
|
86
|
-
return `${message}${suffix}: `;
|
|
87
|
-
}
|
|
88
|
-
function formatValidationError(message, result, defaultValue) {
|
|
89
|
-
const detail = typeof result === "string" ? result : "Invalid input";
|
|
90
|
-
const retryHint = defaultValue.length > 0 ? ` Press Enter to keep "${defaultValue}".` : "";
|
|
91
|
-
return `\u274C ${message}: ${detail}.${retryHint}`;
|
|
92
|
-
}
|
|
93
|
-
function formatChoicePrompt(defaultIndex) {
|
|
94
|
-
return `Choice [default: ${defaultIndex + 1}, ? for options]: `;
|
|
95
|
-
}
|
|
96
|
-
function renderSelectPrompt(message, options, defaultIndex, printLine) {
|
|
97
|
-
printLine(message);
|
|
98
|
-
printLine(" Enter a number, option label, or option value. Press Enter to keep the default, or type ? to list choices again.");
|
|
99
|
-
options.forEach((option, index) => {
|
|
100
|
-
const defaultMarker = index === defaultIndex ? " (default)" : "";
|
|
101
|
-
const valueHint = normalizePromptToken(option.label) === normalizePromptToken(option.value) ? "" : ` [${option.value}]`;
|
|
102
|
-
printLine(` ${index + 1}. ${option.label}${valueHint}${defaultMarker}`);
|
|
103
|
-
if (option.hint) {
|
|
104
|
-
printLine(` ${option.hint}`);
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
function isPromptHelpToken(answer) {
|
|
109
|
-
const normalized = normalizePromptToken(answer);
|
|
110
|
-
return normalized === "?" || normalized === "help" || normalized === "list";
|
|
111
|
-
}
|
|
112
|
-
function resolvePromptSelection(options, answer) {
|
|
113
|
-
const numericChoice = Number(answer);
|
|
114
|
-
if (!Number.isNaN(numericChoice) && options[numericChoice - 1]) {
|
|
115
|
-
return options[numericChoice - 1];
|
|
116
|
-
}
|
|
117
|
-
const normalizedAnswer = normalizePromptToken(answer);
|
|
118
|
-
return options.find((option) => {
|
|
119
|
-
const normalizedLabel = normalizePromptToken(option.label);
|
|
120
|
-
const normalizedValue = normalizePromptToken(option.value);
|
|
121
|
-
return normalizedAnswer === normalizedLabel || normalizedAnswer === normalizedValue;
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
function formatInvalidSelectionError(answer, options, defaultIndex) {
|
|
125
|
-
const optionValues = options.map((option) => option.value).join(", ");
|
|
126
|
-
return [
|
|
127
|
-
`\u274C Invalid selection: ${answer}.`,
|
|
128
|
-
`Enter 1-${options.length}, one of: ${optionValues},`,
|
|
129
|
-
`or press Enter for "${options[defaultIndex].label}".`
|
|
130
|
-
].join(" ");
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
export { createReadlinePrompt, createReadlinePromptWithInterface };
|
|
134
|
-
|
|
135
|
-
//# debugId=44CDFE1F16A2DE6E64756E2164756E21
|
|
@@ -1,538 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import {
|
|
3
|
-
DATA_STORAGE_MODES,
|
|
4
|
-
PERSISTENCE_POLICIES,
|
|
5
|
-
assertBuiltInTemplateVariantAllowed,
|
|
6
|
-
collectScaffoldAnswers,
|
|
7
|
-
formatNonEmptyTargetDirectoryError,
|
|
8
|
-
getOptionalOnboardingNote,
|
|
9
|
-
getOptionalOnboardingShortNote,
|
|
10
|
-
getOptionalOnboardingSteps,
|
|
11
|
-
getPrimaryDevelopmentScript,
|
|
12
|
-
isCompoundPersistenceEnabled,
|
|
13
|
-
isDataStorageMode,
|
|
14
|
-
isPersistencePolicy,
|
|
15
|
-
normalizeOptionalCliString,
|
|
16
|
-
parseAlternateRenderTargets,
|
|
17
|
-
parseCompoundInnerBlocksPreset,
|
|
18
|
-
resolveCreateProfileId,
|
|
19
|
-
resolveLocalCliPathOption,
|
|
20
|
-
resolveOptionalInteractiveExternalLayerId,
|
|
21
|
-
resolvePackageManagerId,
|
|
22
|
-
resolveTemplateId,
|
|
23
|
-
scaffoldProject
|
|
24
|
-
} from "./cli-kfm9mm68.js";
|
|
25
|
-
import"./cli-9fx0qgb7.js";
|
|
26
|
-
import"./cli-377p86mf.js";
|
|
27
|
-
import"./cli-84c7wff4.js";
|
|
28
|
-
import {
|
|
29
|
-
OFFICIAL_WORKSPACE_TEMPLATE_PACKAGE,
|
|
30
|
-
isBuiltInTemplateId
|
|
31
|
-
} from "./cli-8hxf9qw6.js";
|
|
32
|
-
import"./cli-tj7ajdvf.js";
|
|
33
|
-
import"./cli-e4bwd81c.js";
|
|
34
|
-
import {
|
|
35
|
-
pathExists
|
|
36
|
-
} from "./cli-fv4h3ydt.js";
|
|
37
|
-
import"./cli-cvxvcw7c.js";
|
|
38
|
-
import {
|
|
39
|
-
createManagedTempRoot
|
|
40
|
-
} from "./cli-t73q5aqz.js";
|
|
41
|
-
import"./cli-bajwv85z.js";
|
|
42
|
-
import"./cli-tq730sqt.js";
|
|
43
|
-
import"./cli-1170yyve.js";
|
|
44
|
-
import {
|
|
45
|
-
formatInstallCommand,
|
|
46
|
-
formatRunScript
|
|
47
|
-
} from "./cli-am5x7tb4.js";
|
|
48
|
-
import {
|
|
49
|
-
readJsonFile
|
|
50
|
-
} from "./cli-ccax7s0s.js";
|
|
51
|
-
import"./cli-rdcga1bd.js";
|
|
52
|
-
import"./cli-xnn9xjcy.js";
|
|
53
|
-
|
|
54
|
-
// ../wp-typia-project-tools/src/runtime/cli-scaffold.ts
|
|
55
|
-
import path5 from "path";
|
|
56
|
-
|
|
57
|
-
// ../wp-typia-project-tools/src/runtime/cli-scaffold-emission.ts
|
|
58
|
-
import path2 from "path";
|
|
59
|
-
|
|
60
|
-
// ../wp-typia-project-tools/src/runtime/cli-scaffold-files.ts
|
|
61
|
-
import { promises as fsp } from "fs";
|
|
62
|
-
import path from "path";
|
|
63
|
-
async function listRelativeProjectFiles(rootDir) {
|
|
64
|
-
const relativeFiles = [];
|
|
65
|
-
async function visit(currentDir) {
|
|
66
|
-
const entries = await fsp.readdir(currentDir, { withFileTypes: true });
|
|
67
|
-
for (const entry of entries) {
|
|
68
|
-
const absolutePath = path.join(currentDir, entry.name);
|
|
69
|
-
if (entry.isDirectory()) {
|
|
70
|
-
await visit(absolutePath);
|
|
71
|
-
continue;
|
|
72
|
-
}
|
|
73
|
-
relativeFiles.push(path.relative(rootDir, absolutePath).replace(path.sep === "\\" ? /\\/gu : /\//gu, "/"));
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
await visit(rootDir);
|
|
77
|
-
return relativeFiles.sort((left, right) => left.localeCompare(right));
|
|
78
|
-
}
|
|
79
|
-
async function assertDryRunTargetDirectoryReady(projectDir, allowExistingDir) {
|
|
80
|
-
if (!await pathExists(projectDir) || allowExistingDir) {
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
const entries = await fsp.readdir(projectDir);
|
|
84
|
-
if (entries.length > 0) {
|
|
85
|
-
throw new Error(formatNonEmptyTargetDirectoryError(projectDir));
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
async function readGeneratedPackageScripts(projectDir) {
|
|
89
|
-
try {
|
|
90
|
-
const parsedPackageJson = await readJsonFile(path.join(projectDir, "package.json"), {
|
|
91
|
-
context: "generated package manifest"
|
|
92
|
-
});
|
|
93
|
-
const scripts = parsedPackageJson.scripts && typeof parsedPackageJson.scripts === "object" && !Array.isArray(parsedPackageJson.scripts) ? parsedPackageJson.scripts : {};
|
|
94
|
-
return Object.entries(scripts).filter(([, value]) => typeof value === "string").map(([scriptName]) => scriptName);
|
|
95
|
-
} catch {
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// ../wp-typia-project-tools/src/runtime/cli-scaffold-emission.ts
|
|
101
|
-
async function emitScaffoldProject(options) {
|
|
102
|
-
return scaffoldProject(options);
|
|
103
|
-
}
|
|
104
|
-
async function buildScaffoldDryRunPlan(options) {
|
|
105
|
-
await assertDryRunTargetDirectoryReady(options.projectDir, options.allowExistingDir);
|
|
106
|
-
const { path: tempRoot, cleanup } = await createManagedTempRoot("wp-typia-scaffold-plan-");
|
|
107
|
-
const previewProjectDir = path2.join(tempRoot, "preview-project");
|
|
108
|
-
try {
|
|
109
|
-
const result = await emitScaffoldProject({
|
|
110
|
-
...options,
|
|
111
|
-
allowExistingDir: false,
|
|
112
|
-
noInstall: true,
|
|
113
|
-
projectDir: previewProjectDir
|
|
114
|
-
});
|
|
115
|
-
const files = await listRelativeProjectFiles(previewProjectDir);
|
|
116
|
-
return {
|
|
117
|
-
plan: {
|
|
118
|
-
dependencyInstall: options.noInstall ? "skipped-by-flag" : "would-install",
|
|
119
|
-
files
|
|
120
|
-
},
|
|
121
|
-
result
|
|
122
|
-
};
|
|
123
|
-
} finally {
|
|
124
|
-
await cleanup();
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// ../wp-typia-project-tools/src/runtime/cli-scaffold-output.ts
|
|
129
|
-
import path3 from "path";
|
|
130
|
-
function quoteShellValue(value) {
|
|
131
|
-
if (!value.startsWith("-") && /^[A-Za-z0-9._/@:-]+(?:\/[A-Za-z0-9._@:-]+)*$/.test(value)) {
|
|
132
|
-
return value;
|
|
133
|
-
}
|
|
134
|
-
return `'${value.replace(/'/g, `'"'"'`)}'`;
|
|
135
|
-
}
|
|
136
|
-
function getNextSteps({
|
|
137
|
-
projectInput,
|
|
138
|
-
projectDir,
|
|
139
|
-
packageManager,
|
|
140
|
-
noInstall,
|
|
141
|
-
templateId
|
|
142
|
-
}) {
|
|
143
|
-
const cdTarget = path3.isAbsolute(projectInput) ? projectDir : projectInput;
|
|
144
|
-
const steps = [`cd ${quoteShellValue(cdTarget)}`];
|
|
145
|
-
if (noInstall) {
|
|
146
|
-
steps.push(formatInstallCommand(packageManager));
|
|
147
|
-
}
|
|
148
|
-
steps.push(formatRunScript(packageManager, getPrimaryDevelopmentScript(templateId)));
|
|
149
|
-
return steps;
|
|
150
|
-
}
|
|
151
|
-
function getOptionalOnboarding({
|
|
152
|
-
availableScripts,
|
|
153
|
-
packageManager,
|
|
154
|
-
templateId,
|
|
155
|
-
compoundPersistenceEnabled = false
|
|
156
|
-
}) {
|
|
157
|
-
return {
|
|
158
|
-
note: getOptionalOnboardingNote(packageManager, templateId, {
|
|
159
|
-
availableScripts,
|
|
160
|
-
compoundPersistenceEnabled
|
|
161
|
-
}),
|
|
162
|
-
shortNote: getOptionalOnboardingShortNote(packageManager, templateId, {
|
|
163
|
-
availableScripts,
|
|
164
|
-
compoundPersistenceEnabled
|
|
165
|
-
}),
|
|
166
|
-
steps: getOptionalOnboardingSteps(packageManager, templateId, {
|
|
167
|
-
availableScripts,
|
|
168
|
-
compoundPersistenceEnabled
|
|
169
|
-
})
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
// ../wp-typia-project-tools/src/runtime/cli-scaffold-validation.ts
|
|
174
|
-
import path4 from "path";
|
|
175
|
-
function validateCreateProjectInput(projectInput) {
|
|
176
|
-
const normalizedProjectInput = projectInput.trim();
|
|
177
|
-
if (normalizedProjectInput.length === 0) {
|
|
178
|
-
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).");
|
|
179
|
-
}
|
|
180
|
-
const normalizedProjectPath = path4.normalize(normalizedProjectInput).replace(/[\\/]+$/u, "") || path4.normalize(normalizedProjectInput);
|
|
181
|
-
if (normalizedProjectPath === "." || normalizedProjectPath === "..") {
|
|
182
|
-
throw new Error("`wp-typia create` requires a new project directory. Use an explicit child directory instead of `.` or `..`.");
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
function collectProjectDirectoryWarnings(projectDir) {
|
|
186
|
-
const warnings = [];
|
|
187
|
-
const projectName = path4.basename(projectDir);
|
|
188
|
-
if (/\s/u.test(projectName)) {
|
|
189
|
-
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.`);
|
|
190
|
-
}
|
|
191
|
-
const shellSensitiveCharacters = Array.from(new Set(projectName.match(/[^A-Za-z0-9._ -]/gu) ?? []));
|
|
192
|
-
if (shellSensitiveCharacters.length > 0) {
|
|
193
|
-
warnings.push(`Project directory "${projectName}" contains shell-sensitive characters (${shellSensitiveCharacters.join(", ")}). Prefer letters, numbers, ".", "_" and "-" when possible.`);
|
|
194
|
-
}
|
|
195
|
-
return warnings;
|
|
196
|
-
}
|
|
197
|
-
function templateUsesPersistenceSettings(templateId, options) {
|
|
198
|
-
if (templateId === "persistence") {
|
|
199
|
-
return true;
|
|
200
|
-
}
|
|
201
|
-
if (templateId !== "compound") {
|
|
202
|
-
return false;
|
|
203
|
-
}
|
|
204
|
-
return Boolean(options.dataStorageMode || options.persistencePolicy);
|
|
205
|
-
}
|
|
206
|
-
function templateSupportsPersistenceFlags(templateId) {
|
|
207
|
-
return templateId === "persistence" || templateId === "compound";
|
|
208
|
-
}
|
|
209
|
-
function templateSupportsCompoundInnerBlocksPreset(templateId) {
|
|
210
|
-
return templateId === "compound";
|
|
211
|
-
}
|
|
212
|
-
function createTemplateLabel(templateId) {
|
|
213
|
-
return templateId === OFFICIAL_WORKSPACE_TEMPLATE_PACKAGE ? "`--template workspace`" : `"${templateId}"`;
|
|
214
|
-
}
|
|
215
|
-
function collectTemplateCapabilityWarnings(options) {
|
|
216
|
-
const warnings = [];
|
|
217
|
-
const trimmedQueryPostType = options.queryPostType?.trim();
|
|
218
|
-
if (trimmedQueryPostType && options.templateId !== "query-loop" && (isBuiltInTemplateId(options.templateId) || options.templateId === OFFICIAL_WORKSPACE_TEMPLATE_PACKAGE)) {
|
|
219
|
-
warnings.push(`\`--query-post-type\` only applies to \`wp-typia create --template query-loop\`, which scaffolds a create-time \`core/query\` variation instead of a standalone block. ${createTemplateLabel(options.templateId)} will ignore "${trimmedQueryPostType}".`);
|
|
220
|
-
}
|
|
221
|
-
if (options.withMigrationUi === true && !isBuiltInTemplateId(options.templateId) && options.templateId !== OFFICIAL_WORKSPACE_TEMPLATE_PACKAGE) {
|
|
222
|
-
warnings.push(`\`--with-migration-ui\` was ignored for ${createTemplateLabel(options.templateId)}. Migration UI currently scaffolds built-in templates and the official \`--template workspace\` flow; external templates still need to opt into that surface explicitly.`);
|
|
223
|
-
}
|
|
224
|
-
return warnings;
|
|
225
|
-
}
|
|
226
|
-
function templateSupportsAlternateRenderTargets(options) {
|
|
227
|
-
if (!options.alternateRenderTargets) {
|
|
228
|
-
return false;
|
|
229
|
-
}
|
|
230
|
-
if (options.templateId === "persistence") {
|
|
231
|
-
return true;
|
|
232
|
-
}
|
|
233
|
-
if (options.templateId !== "compound") {
|
|
234
|
-
return false;
|
|
235
|
-
}
|
|
236
|
-
return templateUsesPersistenceSettings(options.templateId, {
|
|
237
|
-
dataStorageMode: options.dataStorageMode,
|
|
238
|
-
persistencePolicy: options.persistencePolicy
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
function validateCreateFlagContract(options) {
|
|
242
|
-
const {
|
|
243
|
-
alternateRenderTargets,
|
|
244
|
-
dataStorageMode,
|
|
245
|
-
innerBlocksPreset,
|
|
246
|
-
persistencePolicy,
|
|
247
|
-
templateId,
|
|
248
|
-
variant
|
|
249
|
-
} = options;
|
|
250
|
-
if ((dataStorageMode || persistencePolicy) && !templateSupportsPersistenceFlags(templateId)) {
|
|
251
|
-
throw new Error("`--data-storage` and `--persistence-policy` are supported only for `wp-typia create --template persistence` or `--template compound`.");
|
|
252
|
-
}
|
|
253
|
-
if (alternateRenderTargets && !templateSupportsAlternateRenderTargets({
|
|
254
|
-
alternateRenderTargets,
|
|
255
|
-
dataStorageMode,
|
|
256
|
-
persistencePolicy,
|
|
257
|
-
templateId
|
|
258
|
-
})) {
|
|
259
|
-
if (templateId === "compound") {
|
|
260
|
-
throw new Error("`--alternate-render-targets` on `wp-typia create --template compound` requires the persistence-enabled server render path. Add `--data-storage <post-meta|custom-table>` or `--persistence-policy <authenticated|public>` first.");
|
|
261
|
-
}
|
|
262
|
-
throw new Error("`--alternate-render-targets` is supported only for `wp-typia create --template persistence` or persistence-enabled `--template compound` scaffolds.");
|
|
263
|
-
}
|
|
264
|
-
parseAlternateRenderTargets(alternateRenderTargets);
|
|
265
|
-
if (innerBlocksPreset && !templateSupportsCompoundInnerBlocksPreset(templateId)) {
|
|
266
|
-
throw new Error("`--inner-blocks-preset` is supported only for `wp-typia create --template compound`.");
|
|
267
|
-
}
|
|
268
|
-
parseCompoundInnerBlocksPreset(innerBlocksPreset);
|
|
269
|
-
if (isBuiltInTemplateId(templateId)) {
|
|
270
|
-
assertBuiltInTemplateVariantAllowed({
|
|
271
|
-
templateId,
|
|
272
|
-
variant
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
function parseSelectableValue(label, value, isValue, allowedValues) {
|
|
277
|
-
if (isValue(value)) {
|
|
278
|
-
return value;
|
|
279
|
-
}
|
|
280
|
-
throw new Error(`Unsupported ${label} "${value}". Expected one of: ${allowedValues.join(", ")}`);
|
|
281
|
-
}
|
|
282
|
-
async function resolveOptionalSelection({
|
|
283
|
-
defaultValue,
|
|
284
|
-
explicitValue,
|
|
285
|
-
isInteractive,
|
|
286
|
-
isValue,
|
|
287
|
-
label,
|
|
288
|
-
allowedValues,
|
|
289
|
-
select,
|
|
290
|
-
shouldResolve = true,
|
|
291
|
-
yes
|
|
292
|
-
}) {
|
|
293
|
-
if (!shouldResolve) {
|
|
294
|
-
return;
|
|
295
|
-
}
|
|
296
|
-
if (explicitValue !== undefined) {
|
|
297
|
-
return parseSelectableValue(label, explicitValue, isValue, allowedValues);
|
|
298
|
-
}
|
|
299
|
-
if (yes) {
|
|
300
|
-
return defaultValue;
|
|
301
|
-
}
|
|
302
|
-
if (isInteractive && select) {
|
|
303
|
-
return select();
|
|
304
|
-
}
|
|
305
|
-
return defaultValue;
|
|
306
|
-
}
|
|
307
|
-
async function resolveOptionalBooleanFlag({
|
|
308
|
-
defaultValue = false,
|
|
309
|
-
disabled = false,
|
|
310
|
-
explicitValue,
|
|
311
|
-
isInteractive,
|
|
312
|
-
select,
|
|
313
|
-
yes
|
|
314
|
-
}) {
|
|
315
|
-
if (disabled) {
|
|
316
|
-
return defaultValue;
|
|
317
|
-
}
|
|
318
|
-
if (typeof explicitValue === "boolean") {
|
|
319
|
-
return explicitValue;
|
|
320
|
-
}
|
|
321
|
-
if (yes) {
|
|
322
|
-
return defaultValue;
|
|
323
|
-
}
|
|
324
|
-
if (isInteractive && select) {
|
|
325
|
-
return select();
|
|
326
|
-
}
|
|
327
|
-
return defaultValue;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
// ../wp-typia-project-tools/src/runtime/cli-scaffold.ts
|
|
331
|
-
async function runScaffoldFlow({
|
|
332
|
-
projectInput,
|
|
333
|
-
cwd = process.cwd(),
|
|
334
|
-
templateId,
|
|
335
|
-
alternateRenderTargets,
|
|
336
|
-
dataStorageMode,
|
|
337
|
-
dryRun = false,
|
|
338
|
-
externalLayerId,
|
|
339
|
-
externalLayerSource,
|
|
340
|
-
innerBlocksPreset,
|
|
341
|
-
persistencePolicy,
|
|
342
|
-
packageManager,
|
|
343
|
-
namespace,
|
|
344
|
-
profile,
|
|
345
|
-
textDomain,
|
|
346
|
-
phpPrefix,
|
|
347
|
-
queryPostType,
|
|
348
|
-
yes = false,
|
|
349
|
-
noInstall = false,
|
|
350
|
-
onProgress,
|
|
351
|
-
isInteractive = false,
|
|
352
|
-
allowExistingDir = false,
|
|
353
|
-
selectTemplate,
|
|
354
|
-
selectDataStorage,
|
|
355
|
-
selectExternalLayerId,
|
|
356
|
-
selectPersistencePolicy,
|
|
357
|
-
selectPackageManager,
|
|
358
|
-
promptText,
|
|
359
|
-
installDependencies = undefined,
|
|
360
|
-
variant,
|
|
361
|
-
selectWithTestPreset,
|
|
362
|
-
selectWithWpEnv,
|
|
363
|
-
selectWithMigrationUi,
|
|
364
|
-
withMigrationUi,
|
|
365
|
-
withTestPreset,
|
|
366
|
-
withWpEnv
|
|
367
|
-
}) {
|
|
368
|
-
const normalizedExternalLayerId = normalizeOptionalCliString(externalLayerId);
|
|
369
|
-
const normalizedExternalLayerSource = resolveLocalCliPathOption({
|
|
370
|
-
cwd,
|
|
371
|
-
label: "--external-layer-source",
|
|
372
|
-
value: externalLayerSource
|
|
373
|
-
});
|
|
374
|
-
validateCreateProjectInput(projectInput);
|
|
375
|
-
const resolvedTemplateId = await resolveTemplateId({
|
|
376
|
-
templateId,
|
|
377
|
-
yes,
|
|
378
|
-
isInteractive,
|
|
379
|
-
selectTemplate
|
|
380
|
-
});
|
|
381
|
-
const resolvedProfile = resolveCreateProfileId(profile);
|
|
382
|
-
validateCreateFlagContract({
|
|
383
|
-
alternateRenderTargets,
|
|
384
|
-
dataStorageMode,
|
|
385
|
-
innerBlocksPreset,
|
|
386
|
-
persistencePolicy,
|
|
387
|
-
templateId: resolvedTemplateId,
|
|
388
|
-
variant
|
|
389
|
-
});
|
|
390
|
-
const resolvedInnerBlocksPreset = parseCompoundInnerBlocksPreset(innerBlocksPreset);
|
|
391
|
-
const resolvedExternalLayerSelection = isBuiltInTemplateId(resolvedTemplateId) && isInteractive ? await resolveOptionalInteractiveExternalLayerId({
|
|
392
|
-
callerCwd: cwd,
|
|
393
|
-
externalLayerId: normalizedExternalLayerId,
|
|
394
|
-
externalLayerSource: normalizedExternalLayerSource,
|
|
395
|
-
selectExternalLayerId
|
|
396
|
-
}) : {
|
|
397
|
-
externalLayerId: normalizedExternalLayerId,
|
|
398
|
-
externalLayerSource: normalizedExternalLayerSource
|
|
399
|
-
};
|
|
400
|
-
try {
|
|
401
|
-
const shouldResolvePersistence = templateUsesPersistenceSettings(resolvedTemplateId, {
|
|
402
|
-
dataStorageMode,
|
|
403
|
-
persistencePolicy
|
|
404
|
-
});
|
|
405
|
-
const resolvedDataStorage = await resolveOptionalSelection({
|
|
406
|
-
allowedValues: DATA_STORAGE_MODES,
|
|
407
|
-
defaultValue: "custom-table",
|
|
408
|
-
explicitValue: dataStorageMode,
|
|
409
|
-
isInteractive,
|
|
410
|
-
isValue: isDataStorageMode,
|
|
411
|
-
label: "data storage mode",
|
|
412
|
-
select: selectDataStorage,
|
|
413
|
-
shouldResolve: shouldResolvePersistence,
|
|
414
|
-
yes
|
|
415
|
-
});
|
|
416
|
-
const resolvedPersistencePolicy = await resolveOptionalSelection({
|
|
417
|
-
allowedValues: PERSISTENCE_POLICIES,
|
|
418
|
-
defaultValue: "authenticated",
|
|
419
|
-
explicitValue: persistencePolicy,
|
|
420
|
-
isInteractive,
|
|
421
|
-
isValue: isPersistencePolicy,
|
|
422
|
-
label: "persistence policy",
|
|
423
|
-
select: selectPersistencePolicy,
|
|
424
|
-
shouldResolve: shouldResolvePersistence,
|
|
425
|
-
yes
|
|
426
|
-
});
|
|
427
|
-
const resolvedPackageManager = await resolvePackageManagerId({
|
|
428
|
-
packageManager,
|
|
429
|
-
yes,
|
|
430
|
-
isInteractive,
|
|
431
|
-
selectPackageManager
|
|
432
|
-
});
|
|
433
|
-
const resolvedWithWpEnv = resolvedProfile === "plugin-qa" ? true : await resolveOptionalBooleanFlag({
|
|
434
|
-
explicitValue: withWpEnv,
|
|
435
|
-
isInteractive,
|
|
436
|
-
select: selectWithWpEnv,
|
|
437
|
-
yes
|
|
438
|
-
});
|
|
439
|
-
const resolvedWithTestPreset = await resolveOptionalBooleanFlag({
|
|
440
|
-
explicitValue: withTestPreset,
|
|
441
|
-
isInteractive,
|
|
442
|
-
select: selectWithTestPreset,
|
|
443
|
-
yes
|
|
444
|
-
});
|
|
445
|
-
const resolvedWithMigrationUi = await resolveOptionalBooleanFlag({
|
|
446
|
-
disabled: !isBuiltInTemplateId(resolvedTemplateId) && resolvedTemplateId !== OFFICIAL_WORKSPACE_TEMPLATE_PACKAGE,
|
|
447
|
-
explicitValue: withMigrationUi,
|
|
448
|
-
isInteractive,
|
|
449
|
-
select: selectWithMigrationUi,
|
|
450
|
-
yes
|
|
451
|
-
});
|
|
452
|
-
const projectDir = path5.resolve(cwd, projectInput);
|
|
453
|
-
const projectName = path5.basename(projectDir);
|
|
454
|
-
const answers = await collectScaffoldAnswers({
|
|
455
|
-
dataStorageMode: resolvedDataStorage,
|
|
456
|
-
namespace,
|
|
457
|
-
persistencePolicy: resolvedPersistencePolicy,
|
|
458
|
-
phpPrefix,
|
|
459
|
-
projectName,
|
|
460
|
-
queryPostType,
|
|
461
|
-
templateId: resolvedTemplateId,
|
|
462
|
-
textDomain,
|
|
463
|
-
yes,
|
|
464
|
-
promptText
|
|
465
|
-
});
|
|
466
|
-
if (resolvedTemplateId === "compound" && resolvedInnerBlocksPreset) {
|
|
467
|
-
answers.compoundInnerBlocksPreset = resolvedInnerBlocksPreset;
|
|
468
|
-
}
|
|
469
|
-
const emissionOptions = {
|
|
470
|
-
allowExistingDir,
|
|
471
|
-
alternateRenderTargets,
|
|
472
|
-
answers,
|
|
473
|
-
cwd,
|
|
474
|
-
dataStorageMode: resolvedDataStorage,
|
|
475
|
-
externalLayerId: resolvedExternalLayerSelection.externalLayerId,
|
|
476
|
-
externalLayerSource: resolvedExternalLayerSelection.externalLayerSource,
|
|
477
|
-
externalLayerSourceLabel: normalizedExternalLayerSource,
|
|
478
|
-
installDependencies,
|
|
479
|
-
noInstall,
|
|
480
|
-
onProgress,
|
|
481
|
-
packageManager: resolvedPackageManager,
|
|
482
|
-
persistencePolicy: resolvedPersistencePolicy,
|
|
483
|
-
profile: resolvedProfile,
|
|
484
|
-
projectDir,
|
|
485
|
-
templateId: resolvedTemplateId,
|
|
486
|
-
variant,
|
|
487
|
-
withMigrationUi: resolvedWithMigrationUi,
|
|
488
|
-
withTestPreset: resolvedWithTestPreset,
|
|
489
|
-
withWpEnv: resolvedWithWpEnv
|
|
490
|
-
};
|
|
491
|
-
const resolvedResult = dryRun ? await buildScaffoldDryRunPlan(emissionOptions) : {
|
|
492
|
-
plan: undefined,
|
|
493
|
-
result: await emitScaffoldProject(emissionOptions)
|
|
494
|
-
};
|
|
495
|
-
const availableScripts = dryRun ? undefined : await readGeneratedPackageScripts(projectDir);
|
|
496
|
-
return {
|
|
497
|
-
dryRun,
|
|
498
|
-
optionalOnboarding: getOptionalOnboarding({
|
|
499
|
-
availableScripts,
|
|
500
|
-
packageManager: resolvedPackageManager,
|
|
501
|
-
templateId: resolvedTemplateId,
|
|
502
|
-
compoundPersistenceEnabled: isCompoundPersistenceEnabled(resolvedResult.result.variables)
|
|
503
|
-
}),
|
|
504
|
-
plan: resolvedResult.plan,
|
|
505
|
-
projectDir,
|
|
506
|
-
projectInput,
|
|
507
|
-
packageManager: resolvedPackageManager,
|
|
508
|
-
nextSteps: getNextSteps({
|
|
509
|
-
projectInput,
|
|
510
|
-
projectDir,
|
|
511
|
-
packageManager: resolvedPackageManager,
|
|
512
|
-
noInstall,
|
|
513
|
-
templateId: resolvedTemplateId
|
|
514
|
-
}),
|
|
515
|
-
result: {
|
|
516
|
-
...resolvedResult.result,
|
|
517
|
-
warnings: [
|
|
518
|
-
...resolvedResult.result.warnings,
|
|
519
|
-
...collectTemplateCapabilityWarnings({
|
|
520
|
-
queryPostType,
|
|
521
|
-
templateId: resolvedTemplateId,
|
|
522
|
-
withMigrationUi
|
|
523
|
-
}),
|
|
524
|
-
...collectProjectDirectoryWarnings(projectDir)
|
|
525
|
-
]
|
|
526
|
-
}
|
|
527
|
-
};
|
|
528
|
-
} finally {
|
|
529
|
-
await resolvedExternalLayerSelection.cleanup?.();
|
|
530
|
-
}
|
|
531
|
-
}
|
|
532
|
-
export {
|
|
533
|
-
runScaffoldFlow,
|
|
534
|
-
getOptionalOnboarding,
|
|
535
|
-
getNextSteps
|
|
536
|
-
};
|
|
537
|
-
|
|
538
|
-
//# debugId=3CB466F01953BF7F64756E2164756E21
|