wp-typia 0.16.2 → 0.16.3
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/package.json +4 -4
- package/src/commands/add.ts +1 -2
- package/src/commands/doctor.ts +3 -3
- package/src/runtime-bridge.ts +42 -33
- package/src/ui/add-flow.tsx +36 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wp-typia",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.3",
|
|
4
4
|
"description": "Canonical CLI package for wp-typia scaffolding and project workflows",
|
|
5
5
|
"packageManager": "bun@1.3.11",
|
|
6
6
|
"type": "module",
|
|
@@ -65,10 +65,10 @@
|
|
|
65
65
|
"@bunli/tui": "0.6.0",
|
|
66
66
|
"@bunli/utils": "0.6.0",
|
|
67
67
|
"@wp-typia/api-client": "^0.4.2",
|
|
68
|
-
"@wp-typia/project-tools": "0.16.
|
|
68
|
+
"@wp-typia/project-tools": "0.16.2",
|
|
69
69
|
"better-result": "^2.7.0",
|
|
70
|
-
"react": "19.2.
|
|
71
|
-
"react-dom": "19.2.
|
|
70
|
+
"react": "^19.2.5",
|
|
71
|
+
"react-dom": "^19.2.5",
|
|
72
72
|
"zod": "4.3.6"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
package/src/commands/add.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { z } from "zod";
|
|
|
5
5
|
|
|
6
6
|
import { getAddBlockDefaults } from "../config";
|
|
7
7
|
import { resolveBundledModuleHref } from "../render-loader";
|
|
8
|
-
import { executeAddCommand
|
|
8
|
+
import { executeAddCommand } from "../runtime-bridge";
|
|
9
9
|
import type { WpTypiaRenderArgs } from "./render-types";
|
|
10
10
|
import { LazyFlow } from "../ui/lazy-flow";
|
|
11
11
|
|
|
@@ -94,7 +94,6 @@ export const addCommand = defineCommand({
|
|
|
94
94
|
template:
|
|
95
95
|
(args.flags.template as string | undefined) ?? config.template,
|
|
96
96
|
},
|
|
97
|
-
workspaceBlockOptions: getAddWorkspaceBlockOptions(args.cwd),
|
|
98
97
|
},
|
|
99
98
|
});
|
|
100
99
|
},
|
package/src/commands/doctor.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { defineCommand } from "@bunli/core";
|
|
2
|
-
|
|
3
|
-
import { getDoctorChecks, runDoctor } from "@wp-typia/project-tools";
|
|
2
|
+
import { executeDoctorCommand } from "../runtime-bridge";
|
|
4
3
|
|
|
5
4
|
export const doctorCommand = defineCommand({
|
|
6
5
|
description: "Run repository and project diagnostics.",
|
|
@@ -10,6 +9,7 @@ export const doctorCommand = defineCommand({
|
|
|
10
9
|
args.agent ||
|
|
11
10
|
Boolean(args.context?.store?.isAIAgent);
|
|
12
11
|
if (prefersStructuredOutput) {
|
|
12
|
+
const { getDoctorChecks } = await import("@wp-typia/project-tools/cli-doctor");
|
|
13
13
|
const checks = await getDoctorChecks(args.cwd);
|
|
14
14
|
args.output({ checks });
|
|
15
15
|
if (checks.some((check) => check.status === "fail")) {
|
|
@@ -17,7 +17,7 @@ export const doctorCommand = defineCommand({
|
|
|
17
17
|
}
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
|
-
await
|
|
20
|
+
await executeDoctorCommand(args.cwd);
|
|
21
21
|
},
|
|
22
22
|
name: "doctor",
|
|
23
23
|
});
|
package/src/runtime-bridge.ts
CHANGED
|
@@ -3,29 +3,15 @@ import fs from "node:fs";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
|
-
createReadlinePrompt,
|
|
7
|
-
formatRunScript,
|
|
8
|
-
formatAddHelpText,
|
|
9
|
-
formatMigrationHelpText,
|
|
10
6
|
formatTemplateDetails,
|
|
11
7
|
formatTemplateFeatures,
|
|
12
8
|
formatTemplateSummary,
|
|
13
|
-
getWorkspaceBlockSelectOptions,
|
|
14
9
|
getTemplateById,
|
|
15
|
-
getTemplateSelectOptions,
|
|
16
10
|
listTemplates,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
runAddHookedBlockCommand,
|
|
22
|
-
runAddPatternCommand,
|
|
23
|
-
runAddVariationCommand,
|
|
24
|
-
runDoctor,
|
|
25
|
-
runMigrationCommand,
|
|
26
|
-
runScaffoldFlow,
|
|
27
|
-
} from "@wp-typia/project-tools";
|
|
28
|
-
import type { ReadlinePrompt } from "@wp-typia/project-tools";
|
|
11
|
+
} from "@wp-typia/project-tools/cli-templates";
|
|
12
|
+
import { formatRunScript } from "@wp-typia/project-tools/package-managers";
|
|
13
|
+
import { tryResolveWorkspaceProject } from "@wp-typia/project-tools/workspace-project";
|
|
14
|
+
import type { ReadlinePrompt } from "@wp-typia/project-tools/cli-prompt";
|
|
29
15
|
|
|
30
16
|
type CreateExecutionInput = {
|
|
31
17
|
projectDir: string;
|
|
@@ -72,6 +58,13 @@ type SyncProjectContext = {
|
|
|
72
58
|
scripts: Partial<Record<"sync" | "sync-rest" | "sync-types", string>>;
|
|
73
59
|
};
|
|
74
60
|
|
|
61
|
+
const loadCliAddRuntime = () => import("@wp-typia/project-tools/cli-add");
|
|
62
|
+
const loadCliDoctorRuntime = () => import("@wp-typia/project-tools/cli-doctor");
|
|
63
|
+
const loadCliPromptRuntime = () => import("@wp-typia/project-tools/cli-prompt");
|
|
64
|
+
const loadCliScaffoldRuntime = () => import("@wp-typia/project-tools/cli-scaffold");
|
|
65
|
+
const loadCliTemplatesRuntime = () => import("@wp-typia/project-tools/cli-templates");
|
|
66
|
+
const loadMigrationsRuntime = () => import("@wp-typia/project-tools/migrations");
|
|
67
|
+
|
|
75
68
|
function printBlock(lines: string[], printLine: PrintLine): void {
|
|
76
69
|
for (const line of lines) {
|
|
77
70
|
printLine(line);
|
|
@@ -272,6 +265,15 @@ export async function executeCreateCommand({
|
|
|
272
265
|
interactive,
|
|
273
266
|
prompt,
|
|
274
267
|
}: CreateExecutionInput): Promise<void> {
|
|
268
|
+
const [
|
|
269
|
+
{ createReadlinePrompt },
|
|
270
|
+
{ runScaffoldFlow },
|
|
271
|
+
{ getTemplateSelectOptions },
|
|
272
|
+
] = await Promise.all([
|
|
273
|
+
loadCliPromptRuntime(),
|
|
274
|
+
loadCliScaffoldRuntime(),
|
|
275
|
+
loadCliTemplatesRuntime(),
|
|
276
|
+
]);
|
|
275
277
|
const shouldPrompt =
|
|
276
278
|
interactive ?? (!Boolean(flags.yes) && Boolean(process.stdin.isTTY) && Boolean(process.stdout.isTTY));
|
|
277
279
|
const activePrompt = shouldPrompt ? (prompt ?? createReadlinePrompt()) : undefined;
|
|
@@ -364,10 +366,13 @@ export async function executeAddCommand({
|
|
|
364
366
|
name,
|
|
365
367
|
}: AddExecutionInput): Promise<void> {
|
|
366
368
|
if (!kind) {
|
|
369
|
+
const { formatAddHelpText } = await loadCliAddRuntime();
|
|
367
370
|
console.log(formatAddHelpText());
|
|
368
371
|
return;
|
|
369
372
|
}
|
|
370
373
|
|
|
374
|
+
const addRuntime = await loadCliAddRuntime();
|
|
375
|
+
|
|
371
376
|
if (kind === "variation") {
|
|
372
377
|
if (!name) {
|
|
373
378
|
throw new Error(
|
|
@@ -380,7 +385,7 @@ export async function executeAddCommand({
|
|
|
380
385
|
throw new Error("`wp-typia add variation` requires --block <block-slug>.");
|
|
381
386
|
}
|
|
382
387
|
|
|
383
|
-
const result = await runAddVariationCommand({
|
|
388
|
+
const result = await addRuntime.runAddVariationCommand({
|
|
384
389
|
blockName: blockSlug,
|
|
385
390
|
cwd,
|
|
386
391
|
variationName: name,
|
|
@@ -396,7 +401,7 @@ export async function executeAddCommand({
|
|
|
396
401
|
);
|
|
397
402
|
}
|
|
398
403
|
|
|
399
|
-
const result = await runAddPatternCommand({
|
|
404
|
+
const result = await addRuntime.runAddPatternCommand({
|
|
400
405
|
cwd,
|
|
401
406
|
patternName: name,
|
|
402
407
|
});
|
|
@@ -411,7 +416,7 @@ export async function executeAddCommand({
|
|
|
411
416
|
);
|
|
412
417
|
}
|
|
413
418
|
|
|
414
|
-
const result = await runAddBindingSourceCommand({
|
|
419
|
+
const result = await addRuntime.runAddBindingSourceCommand({
|
|
415
420
|
bindingSourceName: name,
|
|
416
421
|
cwd,
|
|
417
422
|
});
|
|
@@ -438,7 +443,7 @@ export async function executeAddCommand({
|
|
|
438
443
|
);
|
|
439
444
|
}
|
|
440
445
|
|
|
441
|
-
const result = await runAddHookedBlockCommand({
|
|
446
|
+
const result = await addRuntime.runAddHookedBlockCommand({
|
|
442
447
|
anchorBlockName,
|
|
443
448
|
blockName: name,
|
|
444
449
|
cwd,
|
|
@@ -468,7 +473,7 @@ export async function executeAddCommand({
|
|
|
468
473
|
);
|
|
469
474
|
}
|
|
470
475
|
|
|
471
|
-
const result = await runAddBlockCommand({
|
|
476
|
+
const result = await addRuntime.runAddBlockCommand({
|
|
472
477
|
blockName: name,
|
|
473
478
|
cwd,
|
|
474
479
|
dataStorageMode: readOptionalStringFlag(flags, "data-storage"),
|
|
@@ -524,9 +529,20 @@ export async function executeTemplatesCommand(
|
|
|
524
529
|
}
|
|
525
530
|
|
|
526
531
|
export async function executeDoctorCommand(cwd: string): Promise<void> {
|
|
532
|
+
const { runDoctor } = await loadCliDoctorRuntime();
|
|
527
533
|
await runDoctor(cwd);
|
|
528
534
|
}
|
|
529
535
|
|
|
536
|
+
export async function loadAddWorkspaceBlockOptions(cwd: string) {
|
|
537
|
+
const workspace = tryResolveWorkspaceProject(cwd);
|
|
538
|
+
if (!workspace) {
|
|
539
|
+
return [];
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
const { getWorkspaceBlockSelectOptions } = await loadCliAddRuntime();
|
|
543
|
+
return getWorkspaceBlockSelectOptions(workspace.projectDir);
|
|
544
|
+
}
|
|
545
|
+
|
|
530
546
|
export async function executeSyncCommand({
|
|
531
547
|
check = false,
|
|
532
548
|
cwd,
|
|
@@ -553,6 +569,8 @@ export async function executeMigrateCommand({
|
|
|
553
569
|
prompt,
|
|
554
570
|
renderLine,
|
|
555
571
|
}: MigrateExecutionInput): Promise<void> {
|
|
572
|
+
const { formatMigrationHelpText, parseMigrationArgs, runMigrationCommand } =
|
|
573
|
+
await loadMigrationsRuntime();
|
|
556
574
|
if (!command) {
|
|
557
575
|
console.log(formatMigrationHelpText());
|
|
558
576
|
return;
|
|
@@ -587,13 +605,4 @@ export async function executeMigrateCommand({
|
|
|
587
605
|
});
|
|
588
606
|
}
|
|
589
607
|
|
|
590
|
-
export
|
|
591
|
-
const workspace = tryResolveWorkspaceProject(cwd);
|
|
592
|
-
if (!workspace) {
|
|
593
|
-
return [];
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
return getWorkspaceBlockSelectOptions(workspace.projectDir);
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
export { formatAddHelpText, formatMigrationHelpText, listTemplates };
|
|
608
|
+
export { listTemplates };
|
package/src/ui/add-flow.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createElement, useMemo } from "react";
|
|
1
|
+
import { createElement, useEffect, useMemo, useState } from "react";
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
Form,
|
|
@@ -6,9 +6,9 @@ import {
|
|
|
6
6
|
useFormContext,
|
|
7
7
|
useTerminalDimensions,
|
|
8
8
|
} from "@bunli/tui";
|
|
9
|
-
import { HOOKED_BLOCK_POSITION_IDS } from "@wp-typia/project-tools";
|
|
9
|
+
import { HOOKED_BLOCK_POSITION_IDS } from "@wp-typia/project-tools/hooked-blocks";
|
|
10
10
|
|
|
11
|
-
import { executeAddCommand } from "../runtime-bridge";
|
|
11
|
+
import { executeAddCommand, loadAddWorkspaceBlockOptions } from "../runtime-bridge";
|
|
12
12
|
import { useAlternateBufferLifecycle } from "./alternate-buffer-lifecycle";
|
|
13
13
|
import {
|
|
14
14
|
type AddFlowValues,
|
|
@@ -104,11 +104,12 @@ const HOOKED_BLOCK_POSITION_DESCRIPTIONS: Record<
|
|
|
104
104
|
type AddFlowProps = {
|
|
105
105
|
cwd: string;
|
|
106
106
|
initialValues: Partial<AddFlowValues>;
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
type WorkspaceBlockOption = {
|
|
110
|
+
description: string;
|
|
111
|
+
name: string;
|
|
112
|
+
value: string;
|
|
112
113
|
};
|
|
113
114
|
|
|
114
115
|
type AddSelectFieldName = {
|
|
@@ -134,7 +135,7 @@ function getAddNameLabel(kind?: string): string {
|
|
|
134
135
|
function AddFlowFields({
|
|
135
136
|
workspaceBlockOptions,
|
|
136
137
|
}: {
|
|
137
|
-
workspaceBlockOptions:
|
|
138
|
+
workspaceBlockOptions: WorkspaceBlockOption[];
|
|
138
139
|
}) {
|
|
139
140
|
const { activeFieldName, values } = useFormContext();
|
|
140
141
|
const { height: terminalHeight = 24 } = useTerminalDimensions();
|
|
@@ -255,8 +256,32 @@ function AddFlowFields({
|
|
|
255
256
|
);
|
|
256
257
|
}
|
|
257
258
|
|
|
258
|
-
export function AddFlow({ cwd, initialValues
|
|
259
|
-
const { handleCancel, handleSubmit } = useAlternateBufferLifecycle(
|
|
259
|
+
export function AddFlow({ cwd, initialValues }: AddFlowProps) {
|
|
260
|
+
const { handleCancel, handleFailure, handleSubmit } = useAlternateBufferLifecycle(
|
|
261
|
+
"wp-typia add failed",
|
|
262
|
+
);
|
|
263
|
+
const [workspaceBlockOptions, setWorkspaceBlockOptions] = useState<WorkspaceBlockOption[]>([]);
|
|
264
|
+
|
|
265
|
+
useEffect(() => {
|
|
266
|
+
let disposed = false;
|
|
267
|
+
setWorkspaceBlockOptions([]);
|
|
268
|
+
|
|
269
|
+
void loadAddWorkspaceBlockOptions(cwd)
|
|
270
|
+
.then((options) => {
|
|
271
|
+
if (!disposed) {
|
|
272
|
+
setWorkspaceBlockOptions(options);
|
|
273
|
+
}
|
|
274
|
+
})
|
|
275
|
+
.catch((error) => {
|
|
276
|
+
if (!disposed) {
|
|
277
|
+
handleFailure(error);
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
return () => {
|
|
282
|
+
disposed = true;
|
|
283
|
+
};
|
|
284
|
+
}, [cwd, handleFailure]);
|
|
260
285
|
|
|
261
286
|
return (
|
|
262
287
|
<Form
|