openuispec 0.1.30 → 0.1.31
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/cli/index.ts +2 -0
- package/cli/init.ts +70 -1
- package/package.json +1 -1
package/cli/index.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* Usage:
|
|
6
6
|
* openuispec init Create a new spec project
|
|
7
7
|
* openuispec init --defaults Scaffold non-interactively with unconfirmed defaults
|
|
8
|
+
* openuispec init --list-options Print init prompt options as JSON
|
|
8
9
|
* openuispec configure-target <t> Configure and confirm target stack choices
|
|
9
10
|
* openuispec configure-target <t> --list-options Print target stack prompt options as JSON
|
|
10
11
|
* openuispec drift [--target <t>] Check for spec drift
|
|
@@ -102,6 +103,7 @@ OpenUISpec CLI v0.1
|
|
|
102
103
|
Usage:
|
|
103
104
|
openuispec init Create a new spec project
|
|
104
105
|
openuispec init --defaults Scaffold non-interactively with unconfirmed defaults
|
|
106
|
+
openuispec init --list-options Print init prompt options as JSON
|
|
105
107
|
openuispec init --no-configure-targets Skip target stack setup during init
|
|
106
108
|
openuispec update-rules Update AI rules to match installed version
|
|
107
109
|
openuispec configure-target <t> [--defaults] Configure target stack; --defaults stays unconfirmed
|
package/cli/init.ts
CHANGED
|
@@ -19,6 +19,70 @@ import { join, relative, dirname, resolve } from "node:path";
|
|
|
19
19
|
import { fileURLToPath } from "node:url";
|
|
20
20
|
import { SUPPORTED_TARGETS, isSupportedTarget, type SupportedTarget } from "../drift/index.js";
|
|
21
21
|
|
|
22
|
+
// ── list-options ────────────────────────────────────────────────────
|
|
23
|
+
|
|
24
|
+
export type InitOptionsResponse = {
|
|
25
|
+
command: "init";
|
|
26
|
+
note: string;
|
|
27
|
+
questions: Array<{
|
|
28
|
+
key: string;
|
|
29
|
+
prompt: string;
|
|
30
|
+
type: "text" | "list" | "yes_no";
|
|
31
|
+
default: string | string[] | boolean;
|
|
32
|
+
options?: string[];
|
|
33
|
+
}>;
|
|
34
|
+
configure_targets_note: string;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export function listInitOptions(): InitOptionsResponse {
|
|
38
|
+
const defaults = collectDefaults();
|
|
39
|
+
return {
|
|
40
|
+
command: "init",
|
|
41
|
+
note: "After init, run `openuispec configure-target <target> --list-options` for each target to get stack choices.",
|
|
42
|
+
questions: [
|
|
43
|
+
{
|
|
44
|
+
key: "name",
|
|
45
|
+
prompt: "Project name",
|
|
46
|
+
type: "text",
|
|
47
|
+
default: defaults.name,
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
key: "spec_dir",
|
|
51
|
+
prompt: "Spec directory",
|
|
52
|
+
type: "text",
|
|
53
|
+
default: defaults.specDir,
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
key: "targets",
|
|
57
|
+
prompt: "Which platforms?",
|
|
58
|
+
type: "list",
|
|
59
|
+
default: defaults.targets,
|
|
60
|
+
options: [...SUPPORTED_TARGETS],
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
key: "with_api",
|
|
64
|
+
prompt: "Will this spec declare API endpoints?",
|
|
65
|
+
type: "yes_no",
|
|
66
|
+
default: defaults.withApi,
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
key: "backend_path",
|
|
70
|
+
prompt: "Backend folder path relative to openuispec.yaml",
|
|
71
|
+
type: "text",
|
|
72
|
+
default: defaults.backendPath ?? "../backend/",
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
key: "configure_targets",
|
|
76
|
+
prompt: "Configure target stacks now?",
|
|
77
|
+
type: "yes_no",
|
|
78
|
+
default: defaults.configureTargets,
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
configure_targets_note:
|
|
82
|
+
"If configure_targets is true, use `openuispec configure-target <target> --list-options` for each target after init to present stack choices to the user.",
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
22
86
|
// ── prompts ──────────────────────────────────────────────────────────
|
|
23
87
|
|
|
24
88
|
export async function ask(
|
|
@@ -563,7 +627,7 @@ function collectNonInteractiveAnswers(argv: string[]): InitAnswers {
|
|
|
563
627
|
if (!parsed.defaults && argv.filter((a) => a !== "--quiet").length === 0) {
|
|
564
628
|
console.error(
|
|
565
629
|
"Error: `openuispec init` needs a TTY for prompts.\n" +
|
|
566
|
-
"Run with `--
|
|
630
|
+
"Run with `--list-options` to get prompt definitions as JSON, or pass flags such as `--name`, `--targets`, `--with-api`, `--backend`, and `--configure-targets`."
|
|
567
631
|
);
|
|
568
632
|
process.exit(1);
|
|
569
633
|
}
|
|
@@ -590,6 +654,11 @@ function collectNonInteractiveAnswers(argv: string[]): InitAnswers {
|
|
|
590
654
|
// ── main ─────────────────────────────────────────────────────────────
|
|
591
655
|
|
|
592
656
|
export async function init(argv: string[] = []): Promise<void> {
|
|
657
|
+
if (argv.includes("--list-options")) {
|
|
658
|
+
console.log(JSON.stringify(listInitOptions(), null, 2));
|
|
659
|
+
return;
|
|
660
|
+
}
|
|
661
|
+
|
|
593
662
|
const quiet = argv.includes("--quiet");
|
|
594
663
|
const interactive = stdin.isTTY && stdout.isTTY && !argv.includes("--defaults");
|
|
595
664
|
const rl = interactive ? createInterface({ input: stdin, output: stdout }) : null;
|