create-yaebal 0.0.0-test → 0.1.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/LICENSE +21 -0
- package/README.md +100 -0
- package/bin/cli.mjs +3 -0
- package/lib/args.d.ts +27 -0
- package/lib/args.d.ts.map +1 -0
- package/lib/args.js +122 -0
- package/lib/args.js.map +1 -0
- package/lib/args.test.d.ts +2 -0
- package/lib/args.test.d.ts.map +1 -0
- package/lib/args.test.js +38 -0
- package/lib/args.test.js.map +1 -0
- package/lib/catalog.d.ts +56 -0
- package/lib/catalog.d.ts.map +1 -0
- package/lib/catalog.js +241 -0
- package/lib/catalog.js.map +1 -0
- package/lib/config.d.ts +21 -0
- package/lib/config.d.ts.map +1 -0
- package/lib/config.js +35 -0
- package/lib/config.js.map +1 -0
- package/lib/index.d.ts +15 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +125 -0
- package/lib/index.js.map +1 -0
- package/lib/prompts.d.ts +10 -0
- package/lib/prompts.d.ts.map +1 -0
- package/lib/prompts.js +95 -0
- package/lib/prompts.js.map +1 -0
- package/lib/scaffold.d.ts +29 -0
- package/lib/scaffold.d.ts.map +1 -0
- package/lib/scaffold.js +296 -0
- package/lib/scaffold.js.map +1 -0
- package/lib/scaffold.test.d.ts +2 -0
- package/lib/scaffold.test.d.ts.map +1 -0
- package/lib/scaffold.test.js +96 -0
- package/lib/scaffold.test.js.map +1 -0
- package/lib/tui/ansi.d.ts +39 -0
- package/lib/tui/ansi.d.ts.map +1 -0
- package/lib/tui/ansi.js +84 -0
- package/lib/tui/ansi.js.map +1 -0
- package/lib/tui/app.d.ts +20 -0
- package/lib/tui/app.d.ts.map +1 -0
- package/lib/tui/app.js +381 -0
- package/lib/tui/app.js.map +1 -0
- package/lib/tui/app.test.d.ts +2 -0
- package/lib/tui/app.test.d.ts.map +1 -0
- package/lib/tui/app.test.js +87 -0
- package/lib/tui/app.test.js.map +1 -0
- package/lib/tui/theme.d.ts +23 -0
- package/lib/tui/theme.d.ts.map +1 -0
- package/lib/tui/theme.js +23 -0
- package/lib/tui/theme.js.map +1 -0
- package/lib/util.d.ts +27 -0
- package/lib/util.d.ts.map +1 -0
- package/lib/util.js +95 -0
- package/lib/util.js.map +1 -0
- package/package.json +38 -7
package/lib/config.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* the fully-resolved set of choices that drives generation. every front-end
|
|
3
|
+
* (flags-only, plain prompts, tui) produces one of these; `writeProject` and
|
|
4
|
+
* `renderFiles` consume it.
|
|
5
|
+
*/
|
|
6
|
+
import type { ParsedArgs } from "./args.js";
|
|
7
|
+
import { type PackageManager, type Runtime, type TemplateId } from "./catalog.js";
|
|
8
|
+
export interface Selections {
|
|
9
|
+
name: string;
|
|
10
|
+
runtime: Runtime;
|
|
11
|
+
packageManager: PackageManager;
|
|
12
|
+
template: TemplateId;
|
|
13
|
+
plugins: string[];
|
|
14
|
+
git: boolean;
|
|
15
|
+
install: boolean;
|
|
16
|
+
}
|
|
17
|
+
/** the sensible default for each field, given what the user already passed. */
|
|
18
|
+
export declare function defaults(args: ParsedArgs): Selections;
|
|
19
|
+
/** drop any plugin ids that aren't in the catalog, preserving order + dedupe. */
|
|
20
|
+
export declare function sanitizePlugins(ids: string[]): string[];
|
|
21
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,KAAK,cAAc,EAAc,KAAK,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAI9F,MAAM,WAAW,UAAU;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,cAAc,EAAE,cAAc,CAAC;IAC/B,QAAQ,EAAE,UAAU,CAAC;IACrB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,GAAG,EAAE,OAAO,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;CACjB;AAED,+EAA+E;AAC/E,wBAAgB,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAcrD;AAED,iFAAiF;AACjF,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAYvD"}
|
package/lib/config.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* the fully-resolved set of choices that drives generation. every front-end
|
|
3
|
+
* (flags-only, plain prompts, tui) produces one of these; `writeProject` and
|
|
4
|
+
* `renderFiles` consume it.
|
|
5
|
+
*/
|
|
6
|
+
import { PLUGIN_IDS } from "./catalog.js";
|
|
7
|
+
import { defaultPackageManager } from "./scaffold.js";
|
|
8
|
+
import { detectPackageManager, detectRuntime } from "./util.js";
|
|
9
|
+
/** the sensible default for each field, given what the user already passed. */
|
|
10
|
+
export function defaults(args) {
|
|
11
|
+
const runtime = args.runtime ?? detectRuntime();
|
|
12
|
+
const packageManager = args.packageManager ?? detectPackageManager() ?? defaultPackageManager(runtime);
|
|
13
|
+
return {
|
|
14
|
+
name: args.name ?? "my-bot",
|
|
15
|
+
runtime,
|
|
16
|
+
packageManager,
|
|
17
|
+
template: args.template ?? "minimal",
|
|
18
|
+
plugins: args.plugins ?? ["session", "again", "fmt"],
|
|
19
|
+
git: args.git ?? true,
|
|
20
|
+
install: args.install ?? false,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/** drop any plugin ids that aren't in the catalog, preserving order + dedupe. */
|
|
24
|
+
export function sanitizePlugins(ids) {
|
|
25
|
+
const seen = new Set();
|
|
26
|
+
const out = [];
|
|
27
|
+
for (const id of ids) {
|
|
28
|
+
if (PLUGIN_IDS.includes(id) && !seen.has(id)) {
|
|
29
|
+
seen.add(id);
|
|
30
|
+
out.push(id);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return out;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAuB,UAAU,EAAiC,MAAM,cAAc,CAAC;AAC9F,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAYhE,+EAA+E;AAC/E,MAAM,UAAU,QAAQ,CAAC,IAAgB;IACxC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,aAAa,EAAE,CAAC;IAChD,MAAM,cAAc,GACnB,IAAI,CAAC,cAAc,IAAI,oBAAoB,EAAE,IAAI,qBAAqB,CAAC,OAAO,CAAC,CAAC;IAEjF,OAAO;QACN,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,QAAQ;QAC3B,OAAO;QACP,cAAc;QACd,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,SAAS;QACpC,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,KAAK,CAAC;QACpD,GAAG,EAAE,IAAI,CAAC,GAAG,IAAI,IAAI;QACrB,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,KAAK;KAC9B,CAAC;AACH,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,eAAe,CAAC,GAAa;IAC5C,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,MAAM,GAAG,GAAa,EAAE,CAAC;IAEzB,KAAK,MAAM,EAAE,IAAI,GAAG,EAAE,CAAC;QACtB,IAAI,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;YAC9C,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACb,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACd,CAAC;IACF,CAAC;IAED,OAAO,GAAG,CAAC;AACZ,CAAC"}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* create-yaebal — scaffold a type-safe telegram bot.
|
|
3
|
+
*
|
|
4
|
+
* three front-ends, one pipeline:
|
|
5
|
+
* flags (`--yes`) → no prompts · plain readline → fallback · ansi wizard → the
|
|
6
|
+
* hype. all of them produce a `Selections`, which `renderFiles` + `writeProject`
|
|
7
|
+
* turn into a working project.
|
|
8
|
+
*/
|
|
9
|
+
export type { ParsedArgs } from "./args.js";
|
|
10
|
+
export { parseArgs } from "./args.js";
|
|
11
|
+
export * from "./catalog.js";
|
|
12
|
+
export * from "./config.js";
|
|
13
|
+
export * from "./scaffold.js";
|
|
14
|
+
export declare function main(argv?: string[]): Promise<void>;
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAYH,YAAY,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AA2D9B,wBAAsB,IAAI,CAAC,IAAI,GAAE,MAAM,EAA0B,GAAG,OAAO,CAAC,IAAI,CAAC,CAoEhF"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* create-yaebal — scaffold a type-safe telegram bot.
|
|
3
|
+
*
|
|
4
|
+
* three front-ends, one pipeline:
|
|
5
|
+
* flags (`--yes`) → no prompts · plain readline → fallback · ansi wizard → the
|
|
6
|
+
* hype. all of them produce a `Selections`, which `renderFiles` + `writeProject`
|
|
7
|
+
* turn into a working project.
|
|
8
|
+
*/
|
|
9
|
+
import { existsSync } from "node:fs";
|
|
10
|
+
import { createRequire } from "node:module";
|
|
11
|
+
import { resolve } from "node:path";
|
|
12
|
+
import process from "node:process";
|
|
13
|
+
import { HELP, parseArgs } from "./args.js";
|
|
14
|
+
import { defaults, sanitizePlugins } from "./config.js";
|
|
15
|
+
import { runPrompts } from "./prompts.js";
|
|
16
|
+
import { installCommand, renderFiles, runCommand, writeProject } from "./scaffold.js";
|
|
17
|
+
import { gitInit, installDeps, isInteractive, supportsTui, validateProjectName } from "./util.js";
|
|
18
|
+
export { parseArgs } from "./args.js";
|
|
19
|
+
// re-exports so the package is usable as a library / from tests ---------------
|
|
20
|
+
export * from "./catalog.js";
|
|
21
|
+
export * from "./config.js";
|
|
22
|
+
export * from "./scaffold.js";
|
|
23
|
+
const c = {
|
|
24
|
+
cyan: (s) => `\x1b[36m${s}\x1b[0m`,
|
|
25
|
+
green: (s) => `\x1b[32m${s}\x1b[0m`,
|
|
26
|
+
dim: (s) => `\x1b[2m${s}\x1b[0m`,
|
|
27
|
+
bold: (s) => `\x1b[1m${s}\x1b[0m`,
|
|
28
|
+
red: (s) => `\x1b[31m${s}\x1b[0m`,
|
|
29
|
+
};
|
|
30
|
+
function version() {
|
|
31
|
+
try {
|
|
32
|
+
const require = createRequire(import.meta.url);
|
|
33
|
+
return require("../package.json").version;
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return "0.0.0";
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/** decide and run the front-end that gathers the user's choices. */
|
|
40
|
+
async function gather(args) {
|
|
41
|
+
// fully non-interactive: take defaults, no questions asked.
|
|
42
|
+
if (args.yes) {
|
|
43
|
+
const d = defaults(args);
|
|
44
|
+
return { ...d, plugins: sanitizePlugins(d.plugins) };
|
|
45
|
+
}
|
|
46
|
+
// no tty (piped/CI) and not --yes: we can't prompt. accept defaults if we
|
|
47
|
+
// at least have a name, otherwise tell the user how to proceed.
|
|
48
|
+
if (!isInteractive()) {
|
|
49
|
+
if (args.name) {
|
|
50
|
+
const d = defaults(args);
|
|
51
|
+
return { ...d, plugins: sanitizePlugins(d.plugins) };
|
|
52
|
+
}
|
|
53
|
+
console.error(c.red("✗ no interactive terminal."), "pass a name and flags, e.g. `create-yaebal my-bot --yes`.");
|
|
54
|
+
process.exitCode = 1;
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
const wantTui = args.tui === true || (args.tui !== false && supportsTui());
|
|
58
|
+
if (wantTui) {
|
|
59
|
+
try {
|
|
60
|
+
const { runTui } = await import("./tui/app.js");
|
|
61
|
+
return await runTui(args);
|
|
62
|
+
}
|
|
63
|
+
catch (err) {
|
|
64
|
+
if (process.env.YAEBAL_DEBUG)
|
|
65
|
+
console.error(c.dim(`tui unavailable: ${String(err)}`));
|
|
66
|
+
// fall through to plain prompts
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return runPrompts(args);
|
|
70
|
+
}
|
|
71
|
+
export async function main(argv = process.argv.slice(2)) {
|
|
72
|
+
const args = parseArgs(argv);
|
|
73
|
+
if (args.help) {
|
|
74
|
+
console.log(HELP);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (args.version) {
|
|
78
|
+
console.log(version());
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
for (const u of args.unknown)
|
|
82
|
+
console.error(c.dim(`warning: ignoring unknown argument "${u}"`));
|
|
83
|
+
const selections = await gather(args);
|
|
84
|
+
if (!selections) {
|
|
85
|
+
if (process.exitCode !== 1)
|
|
86
|
+
console.log(c.dim("\n✗ cancelled — nothing was created."));
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
const nameError = validateProjectName(selections.name);
|
|
90
|
+
if (nameError) {
|
|
91
|
+
console.error(c.red(`✗ ${nameError}`));
|
|
92
|
+
process.exitCode = 1;
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const target = resolve(process.cwd(), selections.name);
|
|
96
|
+
if (existsSync(target)) {
|
|
97
|
+
console.error(c.red(`✗ directory "${selections.name}" already exists`));
|
|
98
|
+
process.exitCode = 1;
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const files = renderFiles(selections);
|
|
102
|
+
await writeProject(target, files);
|
|
103
|
+
console.log(c.green(`\n✓ created ${selections.name}/`));
|
|
104
|
+
if (selections.git) {
|
|
105
|
+
const ok = await gitInit(target);
|
|
106
|
+
console.log(ok ? c.dim(" • initialised git repository") : c.dim(" • skipped git (not available)"));
|
|
107
|
+
}
|
|
108
|
+
if (selections.install) {
|
|
109
|
+
console.log(c.dim(` • installing dependencies with ${selections.packageManager}…`));
|
|
110
|
+
const ok = await installDeps(selections.packageManager, target);
|
|
111
|
+
if (!ok)
|
|
112
|
+
console.log(c.red(" • install failed — run it manually"));
|
|
113
|
+
}
|
|
114
|
+
// next steps -----------------------------------------------------------------
|
|
115
|
+
const steps = [`cd ${selections.name}`];
|
|
116
|
+
if (!selections.install)
|
|
117
|
+
steps.push(installCommand(selections.packageManager));
|
|
118
|
+
steps.push(c.dim("# add your BOT_TOKEN to .env"));
|
|
119
|
+
steps.push(runCommand(selections.packageManager, "dev"));
|
|
120
|
+
console.log(`\n${c.bold("next steps:")}`);
|
|
121
|
+
for (const s of steps)
|
|
122
|
+
console.log(` ${s}`);
|
|
123
|
+
console.log(`\n${c.cyan("happy hacking ✦")}\n`);
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,C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8B,CAAC,CAAC,CAAC;IAClD,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC,CAAC;IAEzD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;IAE1C,KAAK,MAAM,CAAC,IAAI,KAAK;QAAE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAE7C,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;AACjD,CAAC"}
|
package/lib/prompts.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* the plain, dependency-free wizard used when the rich tui can't run (no tty,
|
|
3
|
+
* `--no-tui`, or a dumb terminal). it's deliberately
|
|
4
|
+
* close to create-gramio's minimal flow: one question per line, sane defaults
|
|
5
|
+
* in brackets, enter to accept.
|
|
6
|
+
*/
|
|
7
|
+
import type { ParsedArgs } from "./args.js";
|
|
8
|
+
import { type Selections } from "./config.js";
|
|
9
|
+
export declare function runPrompts(args: ParsedArgs): Promise<Selections | undefined>;
|
|
10
|
+
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAW5C,OAAO,EAAY,KAAK,UAAU,EAAmB,MAAM,aAAa,CAAC;AAkCzE,wBAAsB,UAAU,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAmElF"}
|
package/lib/prompts.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* the plain, dependency-free wizard used when the rich tui can't run (no tty,
|
|
3
|
+
* `--no-tui`, or a dumb terminal). it's deliberately
|
|
4
|
+
* close to create-gramio's minimal flow: one question per line, sane defaults
|
|
5
|
+
* in brackets, enter to accept.
|
|
6
|
+
*/
|
|
7
|
+
import process from "node:process";
|
|
8
|
+
import { createInterface } from "node:readline/promises";
|
|
9
|
+
import { PACKAGE_MANAGERS, PLUGINS, RUNTIMES, TEMPLATES, } from "./catalog.js";
|
|
10
|
+
import { defaults, sanitizePlugins } from "./config.js";
|
|
11
|
+
import { validateProjectName } from "./util.js";
|
|
12
|
+
const c = {
|
|
13
|
+
dim: (s) => `\x1b[2m${s}\x1b[0m`,
|
|
14
|
+
cyan: (s) => `\x1b[36m${s}\x1b[0m`,
|
|
15
|
+
green: (s) => `\x1b[32m${s}\x1b[0m`,
|
|
16
|
+
bold: (s) => `\x1b[1m${s}\x1b[0m`,
|
|
17
|
+
};
|
|
18
|
+
async function pickOne(rl, question, choices, fallback) {
|
|
19
|
+
console.log(`\n${c.bold(question)}`);
|
|
20
|
+
choices.forEach((ch, i) => {
|
|
21
|
+
const mark = ch.value === fallback ? c.green("›") : " ";
|
|
22
|
+
console.log(` ${mark} ${i + 1}. ${ch.label} ${c.dim(`— ${ch.hint}`)}`);
|
|
23
|
+
});
|
|
24
|
+
const def = choices.findIndex((ch) => ch.value === fallback) + 1;
|
|
25
|
+
const ans = (await rl.question(c.dim(` choose 1-${choices.length} [${def}]: `))).trim();
|
|
26
|
+
if (!ans)
|
|
27
|
+
return fallback;
|
|
28
|
+
const idx = Number.parseInt(ans, 10) - 1;
|
|
29
|
+
return choices[idx]?.value ?? fallback;
|
|
30
|
+
}
|
|
31
|
+
export async function runPrompts(args) {
|
|
32
|
+
const d = defaults(args);
|
|
33
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
34
|
+
try {
|
|
35
|
+
console.log(c.cyan("\n ✦ create-yaebal — let's scaffold a bot\n"));
|
|
36
|
+
let name = args.name;
|
|
37
|
+
while (name === undefined) {
|
|
38
|
+
const ans = (await rl.question(`${c.bold("project name")} ${c.dim(`[${d.name}]: `)}`)).trim();
|
|
39
|
+
const candidate = ans || d.name;
|
|
40
|
+
const err = validateProjectName(candidate);
|
|
41
|
+
if (err) {
|
|
42
|
+
console.log(c.dim(` ✗ ${err}`));
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
name = candidate;
|
|
46
|
+
}
|
|
47
|
+
const runtime = args.runtime ?? (await pickOne(rl, "runtime", RUNTIMES, d.runtime));
|
|
48
|
+
const packageManager = args.packageManager ??
|
|
49
|
+
(await pickOne(rl, "package manager", PACKAGE_MANAGERS, d.packageManager));
|
|
50
|
+
const template = args.template ?? (await pickOne(rl, "template", TEMPLATES, d.template));
|
|
51
|
+
let plugins = args.plugins;
|
|
52
|
+
if (plugins === undefined) {
|
|
53
|
+
console.log(`\n${c.bold("plugins")} ${c.dim("(space/comma separated ids, or 'all')")}`);
|
|
54
|
+
PLUGINS.forEach((p) => {
|
|
55
|
+
const star = p.recommended ? c.green(" ★") : "";
|
|
56
|
+
console.log(` ${p.id}${star} ${c.dim(`— ${p.hint}`)}`);
|
|
57
|
+
});
|
|
58
|
+
const def = d.plugins.join(", ");
|
|
59
|
+
const ans = (await rl.question(c.dim(` plugins [${def}]: `))).trim();
|
|
60
|
+
if (!ans)
|
|
61
|
+
plugins = d.plugins;
|
|
62
|
+
else if (ans.toLowerCase() === "all")
|
|
63
|
+
plugins = PLUGINS.map((p) => p.id);
|
|
64
|
+
else if (ans.toLowerCase() === "none")
|
|
65
|
+
plugins = [];
|
|
66
|
+
else
|
|
67
|
+
plugins = ans.split(/[\s,]+/).filter(Boolean);
|
|
68
|
+
}
|
|
69
|
+
plugins = sanitizePlugins(plugins);
|
|
70
|
+
const git = args.git ?? (await confirm(rl, "initialise a git repository?", d.git));
|
|
71
|
+
const install = args.install ?? (await confirm(rl, "install dependencies now?", d.install));
|
|
72
|
+
return { name, runtime, packageManager, template, plugins, git, install };
|
|
73
|
+
}
|
|
74
|
+
catch (err) {
|
|
75
|
+
// ctrl+c during a question rejects with an AbortError — treat as cancel.
|
|
76
|
+
if (err instanceof Error &&
|
|
77
|
+
(err.name === "AbortError" || err.code === "ABORT_ERR")) {
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
throw err;
|
|
81
|
+
}
|
|
82
|
+
finally {
|
|
83
|
+
rl.close();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
async function confirm(rl, question, fallback) {
|
|
87
|
+
const def = fallback ? "Y/n" : "y/N";
|
|
88
|
+
const ans = (await rl.question(`\n${c.bold(question)} ${c.dim(`[${def}]: `)}`))
|
|
89
|
+
.trim()
|
|
90
|
+
.toLowerCase();
|
|
91
|
+
if (!ans)
|
|
92
|
+
return fallback;
|
|
93
|
+
return ans === "y" || ans === "yes";
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=prompts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,EAEN,gBAAgB,EAEhB,OAAO,EACP,QAAQ,EAER,SAAS,GAET,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,QAAQ,EAAmB,eAAe,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAEhD,MAAM,CAAC,GAAG;IACT,GAAG,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,UAAU,CAAC,SAAS;IACxC,IAAI,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,WAAW,CAAC,SAAS;IAC1C,KAAK,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,WAAW,CAAC,SAAS;IAC3C,IAAI,EAAE,CAAC,CAAS,EAAE,EAAE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AAG,IAAI,GAAG,KAAK,KAAK,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* project generation. `renderFiles` is pure — options in, a `path → contents`
|
|
3
|
+
* map out — so it is trivially testable. `writeProject` is the thin fs wrapper
|
|
4
|
+
* that flushes that map to disk.
|
|
5
|
+
*
|
|
6
|
+
* a template is more than a bot body: it can pull in plugins, add real imports,
|
|
7
|
+
* declare consts before the bot, extend the `.install()` chain and even replace
|
|
8
|
+
* the bootstrap (`bot.start()` → `serve()` / `run()`). everything it generates
|
|
9
|
+
* type-checks against the real `@yaebal/*` apis.
|
|
10
|
+
*/
|
|
11
|
+
import { type PackageManager, type Runtime, type TemplateId } from "./catalog.js";
|
|
12
|
+
export interface ScaffoldOptions {
|
|
13
|
+
name: string;
|
|
14
|
+
runtime: Runtime;
|
|
15
|
+
plugins: string[];
|
|
16
|
+
packageManager?: PackageManager;
|
|
17
|
+
template?: TemplateId;
|
|
18
|
+
}
|
|
19
|
+
/** default package manager that matches a runtime when the user didn't pick one */
|
|
20
|
+
export declare function defaultPackageManager(runtime: Runtime): PackageManager;
|
|
21
|
+
/** turn options into a `relative path → file content` map. pure. */
|
|
22
|
+
export declare function renderFiles(opts: ScaffoldOptions): Record<string, string>;
|
|
23
|
+
/** the install command for a package manager (deno has none) */
|
|
24
|
+
export declare function installCommand(pm: PackageManager): string;
|
|
25
|
+
/** the `<pm> run <script>` invocation (npm/yarn/bun) or runtime command (deno) */
|
|
26
|
+
export declare function runCommand(pm: PackageManager, script: "dev" | "start"): string;
|
|
27
|
+
/** flush a rendered file map to `targetDir`, creating parent dirs as needed. */
|
|
28
|
+
export declare function writeProject(targetDir: string, files: Record<string, string>): Promise<void>;
|
|
29
|
+
//# sourceMappingURL=scaffold.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scaffold.d.ts","sourceRoot":"","sources":["../src/scaffold.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EAAc,KAAK,cAAc,EAAE,KAAK,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAE9F,MAAM,WAAW,eAAe;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,EAAE,UAAU,CAAC;CACtB;AA4ID,mFAAmF;AACnF,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,cAAc,CAItE;AAID,oEAAoE;AACpE,wBAAgB,WAAW,CAAC,IAAI,EAAE,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA0IzE;AAED,gEAAgE;AAChE,wBAAgB,cAAc,CAAC,EAAE,EAAE,cAAc,GAAG,MAAM,CAazD;AAED,kFAAkF;AAClF,wBAAgB,UAAU,CAAC,EAAE,EAAE,cAAc,EAAE,MAAM,EAAE,KAAK,GAAG,OAAO,GAAG,MAAM,CAa9E;AAED,gFAAgF;AAChF,wBAAsB,YAAY,CACjC,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC3B,OAAO,CAAC,IAAI,CAAC,CAMf"}
|