wp-typia 0.24.7 → 0.24.8
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/cli.js +47 -6
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -21,7 +21,7 @@ var package_default;
|
|
|
21
21
|
var init_package = __esm(() => {
|
|
22
22
|
package_default = {
|
|
23
23
|
name: "wp-typia",
|
|
24
|
-
version: "0.24.
|
|
24
|
+
version: "0.24.8",
|
|
25
25
|
description: "Canonical CLI package for wp-typia scaffolding and project workflows",
|
|
26
26
|
packageManager: "bun@1.3.11",
|
|
27
27
|
type: "module",
|
|
@@ -2498,6 +2498,21 @@ async function executePlannedAddKind(kind, executionContext, context) {
|
|
|
2498
2498
|
function contextAllowsInteractivePrompts(flags) {
|
|
2499
2499
|
return flags.format !== "json";
|
|
2500
2500
|
}
|
|
2501
|
+
function shouldPromptForRequiredAddField(flags, fieldName) {
|
|
2502
|
+
const value = flags[fieldName];
|
|
2503
|
+
return value === undefined || value === null || typeof value === "string" && value.trim().length === 0;
|
|
2504
|
+
}
|
|
2505
|
+
async function promptForRequiredAddFields(options) {
|
|
2506
|
+
const requiredFields = REQUIRED_FIELD_PROMPTS_BY_ADD_KIND[options.kind] ?? [];
|
|
2507
|
+
for (const fieldName of requiredFields) {
|
|
2508
|
+
if (!shouldPromptForRequiredAddField(options.flags, fieldName)) {
|
|
2509
|
+
continue;
|
|
2510
|
+
}
|
|
2511
|
+
const label = REQUIRED_FIELD_PROMPT_LABELS[fieldName];
|
|
2512
|
+
const fieldPrompt = await options.getOrCreatePrompt();
|
|
2513
|
+
options.flags[fieldName] = await fieldPrompt.text(label, "", (value) => value.trim().length > 0 ? true : `${label} is required.`);
|
|
2514
|
+
}
|
|
2515
|
+
}
|
|
2501
2516
|
async function executeAddCommand({
|
|
2502
2517
|
cwd,
|
|
2503
2518
|
emitOutput = true,
|
|
@@ -2511,7 +2526,8 @@ async function executeAddCommand({
|
|
|
2511
2526
|
warnLine = console.warn
|
|
2512
2527
|
}) {
|
|
2513
2528
|
let activePrompt;
|
|
2514
|
-
const
|
|
2529
|
+
const resolvedFlags = { ...flags };
|
|
2530
|
+
const dryRun = Boolean(resolvedFlags["dry-run"]);
|
|
2515
2531
|
try {
|
|
2516
2532
|
const addRuntime = await loadCliAddRuntime();
|
|
2517
2533
|
const isInteractiveSession = interactive ?? isInteractiveTerminal();
|
|
@@ -2526,7 +2542,7 @@ async function executeAddCommand({
|
|
|
2526
2542
|
let resolvedKind = kind;
|
|
2527
2543
|
let resolvedName = name;
|
|
2528
2544
|
let promptedForKind = false;
|
|
2529
|
-
if (!resolvedKind && isInteractiveSession && contextAllowsInteractivePrompts(
|
|
2545
|
+
if (!resolvedKind && isInteractiveSession && contextAllowsInteractivePrompts(resolvedFlags)) {
|
|
2530
2546
|
const kindPrompt = await getOrCreatePrompt();
|
|
2531
2547
|
resolvedKind = await kindPrompt.select("Select what to add", getAddKindOptions().map((option) => ({
|
|
2532
2548
|
hint: option.description,
|
|
@@ -2548,13 +2564,20 @@ async function executeAddCommand({
|
|
|
2548
2564
|
const namePrompt = await getOrCreatePrompt();
|
|
2549
2565
|
resolvedName = await namePrompt.text(getAddNameLabel(resolvedKind), "", (value) => value.trim().length > 0 ? true : `${getAddNameLabel(resolvedKind)} is required.`);
|
|
2550
2566
|
}
|
|
2567
|
+
if (promptedForKind) {
|
|
2568
|
+
await promptForRequiredAddFields({
|
|
2569
|
+
flags: resolvedFlags,
|
|
2570
|
+
getOrCreatePrompt,
|
|
2571
|
+
kind: resolvedKind
|
|
2572
|
+
});
|
|
2573
|
+
}
|
|
2551
2574
|
if (dryRun && !supportsAddKindDryRun(resolvedKind)) {
|
|
2552
2575
|
throw createCliDiagnosticCodeError12(CLI_DIAGNOSTIC_CODES16.INVALID_ARGUMENT, `\`wp-typia add ${resolvedKind}\` does not support \`--dry-run\` yet.`);
|
|
2553
2576
|
}
|
|
2554
2577
|
const executionContext = {
|
|
2555
2578
|
addRuntime,
|
|
2556
2579
|
cwd,
|
|
2557
|
-
flags,
|
|
2580
|
+
flags: resolvedFlags,
|
|
2558
2581
|
getOrCreatePrompt,
|
|
2559
2582
|
isInteractiveSession,
|
|
2560
2583
|
name: resolvedName,
|
|
@@ -2578,13 +2601,29 @@ async function executeAddCommand({
|
|
|
2578
2601
|
}
|
|
2579
2602
|
}
|
|
2580
2603
|
}
|
|
2581
|
-
var loadCliAddRuntime = () => import("@wp-typia/project-tools/cli-add"), loadCliPromptRuntime = () => import("@wp-typia/project-tools/cli-prompt");
|
|
2604
|
+
var loadCliAddRuntime = () => import("@wp-typia/project-tools/cli-add"), loadCliPromptRuntime = () => import("@wp-typia/project-tools/cli-prompt"), REQUIRED_FIELD_PROMPTS_BY_ADD_KIND, REQUIRED_FIELD_PROMPT_LABELS;
|
|
2582
2605
|
var init_runtime_bridge_add = __esm(() => {
|
|
2583
2606
|
init_add_kind_registry();
|
|
2584
2607
|
init_cli_error_messages();
|
|
2585
2608
|
init_runtime_bridge_add_dry_run();
|
|
2586
2609
|
init_runtime_bridge_output();
|
|
2587
2610
|
init_runtime_bridge_shared();
|
|
2611
|
+
REQUIRED_FIELD_PROMPTS_BY_ADD_KIND = {
|
|
2612
|
+
"core-variation": ["block"],
|
|
2613
|
+
"hooked-block": ["anchor", "position"],
|
|
2614
|
+
"post-meta": ["post-type"],
|
|
2615
|
+
style: ["block"],
|
|
2616
|
+
transform: ["from", "to"],
|
|
2617
|
+
variation: ["block"]
|
|
2618
|
+
};
|
|
2619
|
+
REQUIRED_FIELD_PROMPT_LABELS = {
|
|
2620
|
+
anchor: "Anchor block",
|
|
2621
|
+
block: "Target block",
|
|
2622
|
+
from: "Source block",
|
|
2623
|
+
position: "Hook position",
|
|
2624
|
+
"post-type": "Post type",
|
|
2625
|
+
to: "Target block"
|
|
2626
|
+
};
|
|
2588
2627
|
});
|
|
2589
2628
|
|
|
2590
2629
|
// src/runtime-bridge-create.ts
|
|
@@ -4314,8 +4353,10 @@ function renderNoCommandHelp(printLine) {
|
|
|
4314
4353
|
renderGeneralHelp(printLine);
|
|
4315
4354
|
}
|
|
4316
4355
|
function renderUnknownHelpTarget(printLine, target) {
|
|
4356
|
+
const suggestion = suggestTopLevelCommandTypo(target);
|
|
4317
4357
|
printBlock(printLine, [
|
|
4318
4358
|
`Unknown help target "${target}".`,
|
|
4359
|
+
...suggestion ? [`Did you mean "${suggestion}"? Run wp-typia ${suggestion} --help.`] : [],
|
|
4319
4360
|
`Supported commands: ${WP_TYPIA_PORTABLE_CLI_TOP_LEVEL_COMMAND_NAMES.join(", ")}.`,
|
|
4320
4361
|
"Run wp-typia --help for general usage."
|
|
4321
4362
|
]);
|
|
@@ -5945,4 +5986,4 @@ export {
|
|
|
5945
5986
|
runGunshiCli
|
|
5946
5987
|
};
|
|
5947
5988
|
|
|
5948
|
-
//# debugId=
|
|
5989
|
+
//# debugId=C5F9F3777C8262A064756E2164756E21
|