create-nifra 3.5.0 → 4.0.2
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 +3 -3
- package/dist/agent-files.d.ts +41 -26
- package/dist/agent-files.d.ts.map +1 -1
- package/dist/agent-files.js +80 -47
- package/dist/agent-files.js.map +1 -1
- package/dist/agents.d.ts +3 -3
- package/dist/agents.d.ts.map +1 -1
- package/dist/agents.js +65 -69
- package/dist/agents.js.map +1 -1
- package/dist/auth.d.ts +5 -4
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +27 -14
- package/dist/auth.js.map +1 -1
- package/dist/cli.d.ts +23 -25
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +141 -130
- package/dist/cli.js.map +1 -1
- package/dist/db.d.ts.map +1 -1
- package/dist/db.js +49 -48
- package/dist/db.js.map +1 -1
- package/dist/scaffold/frameworks.d.ts +13 -38
- package/dist/scaffold/frameworks.d.ts.map +1 -1
- package/dist/scaffold/frameworks.js +9 -32
- package/dist/scaffold/frameworks.js.map +1 -1
- package/dist/scaffold/route-types.d.ts +9 -0
- package/dist/scaffold/route-types.d.ts.map +1 -0
- package/dist/scaffold/route-types.js +61 -0
- package/dist/scaffold/route-types.js.map +1 -0
- package/dist/scaffold/site-files.d.ts +14 -8
- package/dist/scaffold/site-files.d.ts.map +1 -1
- package/dist/scaffold/site-files.js +29 -60
- package/dist/scaffold/site-files.js.map +1 -1
- package/dist/scaffold/site.d.ts +8 -5
- package/dist/scaffold/site.d.ts.map +1 -1
- package/dist/scaffold/site.js +47 -34
- package/dist/scaffold/site.js.map +1 -1
- package/dist/scaffold/targets.d.ts +39 -0
- package/dist/scaffold/targets.d.ts.map +1 -0
- package/dist/scaffold/targets.js +116 -0
- package/dist/scaffold/targets.js.map +1 -0
- package/package.json +4 -1
- package/src/agent-files.ts +89 -47
- package/template/README.md +12 -6
- package/template/{src → backend}/app.test.ts +2 -2
- package/template/{src → backend}/app.ts +8 -3
- package/template/{src → backend}/index.ts +2 -2
- package/template/{src → backend}/routes.ts +1 -1
- package/template/nifra.assurance.ts +16 -14
- package/template/package.json +7 -7
- package/template/tsconfig.json +1 -1
- package/template-batteries/README.md +10 -6
- package/template-batteries/{src → backend}/app.test.ts +23 -23
- package/template-batteries/{src → backend}/app.ts +8 -3
- package/template-batteries/{src → backend}/index.ts +2 -2
- package/template-batteries/{src → backend}/notes.ts +1 -1
- package/template-batteries/nifra.assurance.ts +16 -14
- package/template-batteries/package.json +10 -9
- package/template-batteries/tsconfig.json +1 -1
- package/template-isr/README.md +3 -0
- package/template-isr/{backend.ts → backend/app.ts} +2 -0
- package/template-isr/{server.ts → backend/dev-server.ts} +4 -4
- package/template-isr/{worker.ts → backend/worker.ts} +4 -2
- package/template-isr/build.ts +3 -1
- package/template-isr/gitignore +7 -1
- package/template-isr/nifra.assurance.ts +15 -13
- package/template-isr/package.json +10 -9
- package/template-isr/routes/index.backend.ts +14 -0
- package/template-isr/routes/index.tsx +5 -17
- package/template-isr/tsconfig.json +5 -4
- package/template-isr/wrangler.toml +6 -1
- package/template-site/README.md +24 -23
- package/template-site/{backend.ts → backend/app.ts} +6 -4
- package/template-site/gitignore +5 -10
- package/template-site/nifra.assurance.ts +15 -13
- package/template-site/nifra.config.ts +4 -4
- package/template-site/routes/index.backend.ts +18 -0
- package/template-site/routes/index.tsx +2 -15
- package/template-site-preact/README.md +21 -20
- package/template-site-preact/nifra.config.ts +4 -4
- package/template-site-preact/routes/_layout.tsx +3 -1
- package/template-site-preact/routes/index.tsx +2 -15
- package/template-site-solid/README.md +21 -19
- package/template-site-solid/nifra.config.ts +5 -4
- package/template-site-solid/routes/index.tsx +2 -15
- package/template-site-svelte/README.md +21 -19
- package/template-site-svelte/nifra.config.ts +3 -2
- package/template-site-svelte/routes/index.svelte +3 -16
- package/template-site-vue/README.md +21 -20
- package/template-site-vue/nifra.config.ts +4 -3
- package/template-site-vue/routes/_layout.vue +21 -25
- package/template-site-vue/routes/index.vue +12 -18
- package/dist/scaffold/site-build.d.ts +0 -60
- package/dist/scaffold/site-build.d.ts.map +0 -1
- package/dist/scaffold/site-build.js +0 -198
- package/dist/scaffold/site-build.js.map +0 -1
- package/template-site/.dockerignore +0 -14
- package/template-site/Dockerfile +0 -25
- package/template-site/_worker.ts +0 -17
- package/template-site/deno.json +0 -7
- package/template-site/server-bun.ts +0 -35
- package/template-site/server-deno.ts +0 -38
- package/template-site/server-node.ts +0 -40
- package/template-site/server-vercel.ts +0 -17
- package/template-site/wrangler.toml +0 -4
- /package/template-isr/{page.ts → backend/page.ts} +0 -0
- /package/template-site/{counter.ts → backend/counter.ts} +0 -0
package/dist/agents.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../src/agents.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../src/agents.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAA;AAG3E,OAAO,EAAE,UAAU,EAAgC,MAAM,SAAS,CAAA;AAElE,MAAM,eAAe,GAAwC;IAC3D,KAAK,EAAE,OAAO;IACd,KAAK,EAAE,OAAO;IACd,GAAG,EAAE,KAAK;IACV,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;CACjB,CAAA;AAED,iFAAiF;AACjF,MAAM,SAAS,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyEjB,CAAA;AAED,sFAAsF;AACtF,SAAS,QAAQ,CAAC,SAAoB;IACpC,MAAM,KAAK,GAAG,eAAe,CAAC,SAAS,CAAC,CAAA;IACxC,OAAO,4CAA4C,KAAK;;;;;;;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AC,SAAS,CAAC,QAAQ;QACpI,CAAC,CAAC,4DAA4D,CAAA;IAEhE,sGAAsG;IACtG,8FAA8F;IAC9F,MAAM,MAAM,GAAG;QACb,iBAAiB,IAAI,CAAC,IAAI,mEAAmE,IAAI,kHAAkH;QACnN,kBAAkB,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;QAC3C,mGAAmG;QACnG,6FAA6F;QAC7F,gBAAgB,EAAE;QAClB,SAAS,CAAC,IAAI,EAAE;QAChB,IAAI,CAAC,EAAE,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE;QAC7C,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE;QACnD,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE;QAC5C,cAAc,CAAC,IAAI,EAAE;QACrB,IAAI;QACJ,8QAA8Q;KAC/Q,CAAA;IACD,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAA;AACnD,CAAC"}
|
package/dist/auth.d.ts
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
* `--auth better-auth` - wire authentication into a scaffolded app, the same "bundle the right tool,
|
|
3
3
|
* correctly" move as `--db`. nifra owns the *mount* (`@nifrajs/better-auth` plugs better-auth's handler
|
|
4
4
|
* into a `server()` and gives typed `getSession`/`requireSession` guards); better-auth owns the auth
|
|
5
|
-
* logic. Auth needs a database, so this composes with `--db`: the generated `auth.ts` reuses
|
|
6
|
-
* from `./db` via better-auth's adapter for the chosen ORM (`drizzleAdapter` /
|
|
7
|
-
* agent then runs `bunx @better-auth/cli generate` to add the auth tables and
|
|
5
|
+
* logic. Auth needs a database, so this composes with `--db`: the generated `backend/auth.ts` reuses
|
|
6
|
+
* the client from `./db` via better-auth's adapter for the chosen ORM (`drizzleAdapter` /
|
|
7
|
+
* `prismaAdapter`). The agent then runs `bunx @better-auth/cli generate` to add the auth tables and
|
|
8
|
+
* migrates.
|
|
8
9
|
*
|
|
9
10
|
* `--auth` therefore requires `--db` (the CLI enforces it). better-auth's clean adapters cover Drizzle
|
|
10
11
|
* and Prisma; Kysely is rejected (it has no drop-in adapter - wire better-auth's own dialect manually).
|
|
@@ -25,6 +26,6 @@ export interface AuthPreset {
|
|
|
25
26
|
readonly deps: Readonly<Record<string, string>>;
|
|
26
27
|
}
|
|
27
28
|
export declare const AUTH_PRESETS: Readonly<Record<AuthChoice, AuthPreset>>;
|
|
28
|
-
/** Write `auth.ts` and append the auth env vars to the (db-preset-created) `.env.example`. */
|
|
29
|
+
/** Write `backend/auth.ts` and append the auth env vars to the (db-preset-created) `.env.example`. */
|
|
29
30
|
export declare function writeAuthFiles(target: string, _auth: AuthChoice, db: DbChoice): Promise<void>;
|
|
30
31
|
//# sourceMappingURL=auth.d.ts.map
|
package/dist/auth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,EAAc,KAAK,QAAQ,EAAY,MAAM,SAAS,CAAA;AAE7D,eAAO,MAAM,YAAY,0BAA2B,CAAA;AACpD,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAA;AAKtD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CAQnD;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;CAChD;AAED,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,UAAU,CAAC,CAOjE,CAAA;AA6DD,sGAAsG;AACtG,wBAAsB,cAAc,CAClC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,UAAU,EACjB,EAAE,EAAE,QAAQ,GACX,OAAO,CAAC,IAAI,CAAC,CAKf"}
|
package/dist/auth.js
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
* `--auth better-auth` - wire authentication into a scaffolded app, the same "bundle the right tool,
|
|
3
3
|
* correctly" move as `--db`. nifra owns the *mount* (`@nifrajs/better-auth` plugs better-auth's handler
|
|
4
4
|
* into a `server()` and gives typed `getSession`/`requireSession` guards); better-auth owns the auth
|
|
5
|
-
* logic. Auth needs a database, so this composes with `--db`: the generated `auth.ts` reuses
|
|
6
|
-
* from `./db` via better-auth's adapter for the chosen ORM (`drizzleAdapter` /
|
|
7
|
-
* agent then runs `bunx @better-auth/cli generate` to add the auth tables and
|
|
5
|
+
* logic. Auth needs a database, so this composes with `--db`: the generated `backend/auth.ts` reuses
|
|
6
|
+
* the client from `./db` via better-auth's adapter for the chosen ORM (`drizzleAdapter` /
|
|
7
|
+
* `prismaAdapter`). The agent then runs `bunx @better-auth/cli generate` to add the auth tables and
|
|
8
|
+
* migrates.
|
|
8
9
|
*
|
|
9
10
|
* `--auth` therefore requires `--db` (the CLI enforces it). better-auth's clean adapters cover Drizzle
|
|
10
11
|
* and Prisma; Kysely is rejected (it has no drop-in adapter - wire better-auth's own dialect manually).
|
|
@@ -25,15 +26,15 @@ export function assertAuthableDb(db) {
|
|
|
25
26
|
const { orm } = DB_PRESETS[db];
|
|
26
27
|
if (!AUTHABLE_ORMS.has(orm)) {
|
|
27
28
|
throw new Error(`--auth better-auth doesn't scaffold for --db ${db} (${orm} has no drop-in better-auth adapter). ` +
|
|
28
|
-
"Use a drizzle-* or prisma-* preset, or wire better-auth's database dialect manually in auth.ts.");
|
|
29
|
+
"Use a drizzle-* or prisma-* preset, or wire better-auth's database dialect manually in backend/auth.ts.");
|
|
29
30
|
}
|
|
30
31
|
}
|
|
31
32
|
export const AUTH_PRESETS = {
|
|
32
33
|
"better-auth": {
|
|
33
34
|
label: "better-auth",
|
|
34
|
-
note: "email/password + sessions, mounted at /api/auth/* - add OAuth providers in auth.ts.",
|
|
35
|
+
note: "email/password + sessions, mounted at /api/auth/* - add OAuth providers in backend/auth.ts.",
|
|
35
36
|
// @nifrajs/better-auth mounts it; better-auth is the implementation (peer-installed alongside).
|
|
36
|
-
deps: { "@nifrajs/better-auth": "^
|
|
37
|
+
deps: { "@nifrajs/better-auth": "^4.0.2", "better-auth": "^1.2.0" },
|
|
37
38
|
},
|
|
38
39
|
};
|
|
39
40
|
/** The better-auth `database` adapter expression + its import line, for the scaffolded DB's ORM. */
|
|
@@ -54,36 +55,48 @@ function adapterFor(db) {
|
|
|
54
55
|
database: `drizzleAdapter(db, { provider: "${provider}" })`,
|
|
55
56
|
};
|
|
56
57
|
}
|
|
57
|
-
/** The generated `auth.ts` - a better-auth instance backed by the scaffolded DB client. */
|
|
58
|
+
/** The generated `backend/auth.ts` - a better-auth instance backed by the scaffolded DB client. */
|
|
58
59
|
function authModule(db) {
|
|
59
60
|
const { importLine, database } = adapterFor(db);
|
|
60
61
|
return `import { betterAuth as createBetterAuth } from "better-auth"
|
|
61
62
|
${importLine}
|
|
62
63
|
import { db } from "./db"
|
|
63
64
|
|
|
64
|
-
// better-auth stores users + sessions in your database (
|
|
65
|
+
// better-auth stores users + sessions in your database (backend/db/). After editing the config
|
|
65
66
|
// (e.g. adding OAuth providers), generate its tables: \`bunx @better-auth/cli generate\` writes the auth
|
|
66
67
|
// schema for your ORM, then \`bun run db:migrate\` applies it.
|
|
68
|
+
|
|
69
|
+
// Set in .env: openssl rand -base64 32. better-auth refuses a missing secret in production but only
|
|
70
|
+
// warns about a short one, so a short one is refused here.
|
|
71
|
+
const secret = process.env.BETTER_AUTH_SECRET
|
|
72
|
+
if (process.env.NODE_ENV === "production" && secret && secret.length < 32) {
|
|
73
|
+
throw new Error(
|
|
74
|
+
"BETTER_AUTH_SECRET is shorter than 32 characters. Generate one with: openssl rand -base64 32",
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
|
|
67
78
|
export const auth = createBetterAuth({
|
|
68
79
|
database: ${database},
|
|
69
80
|
emailAndPassword: { enabled: true },
|
|
70
|
-
|
|
71
|
-
secret: process.env.BETTER_AUTH_SECRET,
|
|
81
|
+
secret,
|
|
72
82
|
baseURL: process.env.BETTER_AUTH_URL,
|
|
73
83
|
})
|
|
74
84
|
|
|
75
85
|
export type Auth = typeof auth
|
|
76
86
|
`;
|
|
77
87
|
}
|
|
88
|
+
// No placeholder secret: left empty, better-auth uses its development secret locally and refuses to
|
|
89
|
+
// start in production, where a placeholder would only draw a warning.
|
|
78
90
|
const ENV = `
|
|
79
|
-
# better-auth - REQUIRED. Generate a 32+ char secret: openssl rand -base64 32
|
|
80
|
-
|
|
91
|
+
# better-auth - REQUIRED in production. Generate a 32+ char secret: openssl rand -base64 32
|
|
92
|
+
# Left empty, development uses better-auth's built-in secret and production refuses to start.
|
|
93
|
+
BETTER_AUTH_SECRET=""
|
|
81
94
|
BETTER_AUTH_URL="http://localhost:3000"
|
|
82
95
|
`;
|
|
83
|
-
/** Write `auth.ts` and append the auth env vars to the (db-preset-created) `.env.example`. */
|
|
96
|
+
/** Write `backend/auth.ts` and append the auth env vars to the (db-preset-created) `.env.example`. */
|
|
84
97
|
export async function writeAuthFiles(target, _auth, db) {
|
|
85
98
|
assertAuthableDb(db); // defensive: the CLI already checks, but never emit a broken adapter import
|
|
86
|
-
await writeFile(join(target, "auth.ts"), authModule(db));
|
|
99
|
+
await writeFile(join(target, "backend/auth.ts"), authModule(db));
|
|
87
100
|
// .env.example already exists (the DB preset wrote it; `--auth` requires `--db`); append, don't clobber.
|
|
88
101
|
await appendFile(join(target, ".env.example"), ENV);
|
|
89
102
|
}
|
package/dist/auth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,UAAU,EAA2B,MAAM,SAAS,CAAA;AAE7D,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,aAAa,CAAU,CAAA;AAGpD,uGAAuG;AACvG,MAAM,aAAa,GAAqB,IAAI,GAAG,CAAM,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAA;AAE3E;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,EAAY;IAC3C,MAAM,EAAE,GAAG,EAAE,GAAG,UAAU,CAAC,EAAE,CAAC,CAAA;IAC9B,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CACb,gDAAgD,EAAE,KAAK,GAAG,wCAAwC;YAChG,yGAAyG,CAC5G,CAAA;IACH,CAAC;AACH,CAAC;AAQD,MAAM,CAAC,MAAM,YAAY,GAA6C;IACpE,aAAa,EAAE;QACb,KAAK,EAAE,aAAa;QACpB,IAAI,EAAE,6FAA6F;QACnG,gGAAgG;QAChG,IAAI,EAAE,EAAE,sBAAsB,EAAE,QAAQ,EAAE,aAAa,EAAE,QAAQ,EAAE;KACpE;CACF,CAAA;AAED,oGAAoG;AACpG,SAAS,UAAU,CA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@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { type AuthChoice } from "./auth.js";
|
|
3
3
|
import { type DbChoice } from "./db.js";
|
|
4
|
+
import { type DeployTarget } from "./scaffold/targets.js";
|
|
4
5
|
declare const TEMPLATES: {
|
|
5
6
|
readonly api: "../template";
|
|
6
7
|
readonly site: "../template-site";
|
|
@@ -13,23 +14,10 @@ export type TemplateName = keyof typeof TEMPLATES;
|
|
|
13
14
|
* + routes. */
|
|
14
15
|
declare const FRAMEWORKS: readonly ["react", "preact", "vue", "solid", "svelte"];
|
|
15
16
|
export type Framework = (typeof FRAMEWORKS)[number];
|
|
16
|
-
/**
|
|
17
|
-
* Deploy targets for the multi-target `site` template. Every target's build + server entry already ships
|
|
18
|
-
* in the template; choosing one repoints the canonical `build`/`deploy` scripts at it (the per-target
|
|
19
|
-
* `build:*` scripts stay, so you can still switch). nifra never runs the deploy or enters credentials -
|
|
20
|
-
* `deploy` shells out to the vendor CLI you've authed yourself.
|
|
21
|
-
*/
|
|
22
|
-
interface DeployPreset {
|
|
23
|
-
readonly label: string;
|
|
24
|
-
readonly build: string;
|
|
25
|
-
/** `deploy` script; `NAME` is replaced with the app directory name. */
|
|
26
|
-
readonly deploy: string;
|
|
27
|
-
readonly steps: readonly string[];
|
|
28
|
-
}
|
|
29
17
|
/**
|
|
30
18
|
* Build a GitHub Actions workflow that builds on every push/PR and deploys `target` on a push to `main`.
|
|
31
|
-
*
|
|
32
|
-
*
|
|
19
|
+
* Runs `bun run build` (`nifra build` for the app's target), then the target's official deploy
|
|
20
|
+
* mechanism. Exported for unit tests. Throws on an unknown target.
|
|
33
21
|
*/
|
|
34
22
|
export declare function githubDeployWorkflow(target: string, appName: string): string;
|
|
35
23
|
export interface ScaffoldOptions {
|
|
@@ -39,9 +27,12 @@ export interface ScaffoldOptions {
|
|
|
39
27
|
readonly template?: TemplateName;
|
|
40
28
|
/** Frontend framework (site template only). Default `"react"`. */
|
|
41
29
|
readonly framework?: string;
|
|
42
|
-
/**
|
|
43
|
-
|
|
44
|
-
|
|
30
|
+
/** Where the site deploys (site template only): `bun` (default), `node`, `deno`, `cloudflare` or
|
|
31
|
+
* `vercel`. */
|
|
32
|
+
readonly deployTarget?: string;
|
|
33
|
+
/** Add a Dockerfile that builds and runs the server (`bun` and `node` targets). */
|
|
34
|
+
readonly docker?: boolean;
|
|
35
|
+
/** Emit a CI deploy workflow for the site's target. Only `"github"` today. */
|
|
45
36
|
readonly ci?: string;
|
|
46
37
|
/** Wire a data layer: `drizzle-{libsql,postgres,sqlite}` | `prisma-{postgres,sqlite}` | `kysely-postgres`. */
|
|
47
38
|
readonly db?: string;
|
|
@@ -57,7 +48,12 @@ export interface ScaffoldResult {
|
|
|
57
48
|
readonly name: string;
|
|
58
49
|
readonly template: TemplateName;
|
|
59
50
|
readonly framework?: Framework;
|
|
60
|
-
|
|
51
|
+
/** Where a site deploys, and whether it ships a Dockerfile. */
|
|
52
|
+
readonly deploy?: {
|
|
53
|
+
readonly target: DeployTarget;
|
|
54
|
+
readonly label: string;
|
|
55
|
+
readonly docker: boolean;
|
|
56
|
+
};
|
|
61
57
|
/** The CI provider a workflow was generated for, when `--ci` was passed. */
|
|
62
58
|
readonly ci?: "github";
|
|
63
59
|
/** Repo secrets the generated workflow needs (for the next-steps message). */
|
|
@@ -70,25 +66,27 @@ export interface ScaffoldResult {
|
|
|
70
66
|
readonly link?: string;
|
|
71
67
|
}
|
|
72
68
|
/**
|
|
73
|
-
* Copy a template into `target` and finalize it (gitignore rename, package name,
|
|
74
|
-
* Throws on: unknown template, `--
|
|
75
|
-
* destination. Pure enough to unit-test (no argv, no process.exit).
|
|
69
|
+
* Copy a template into `target` and finalize it (gitignore rename, package name, the site's deploy target).
|
|
70
|
+
* Throws on: unknown template, `--target`/`--docker` with a non-site template, unknown deploy target, or
|
|
71
|
+
* an existing destination. Pure enough to unit-test (no argv, no process.exit).
|
|
76
72
|
*/
|
|
77
73
|
export declare function scaffold(opts: ScaffoldOptions): Promise<ScaffoldResult>;
|
|
78
74
|
interface ParsedArgs {
|
|
79
75
|
readonly target?: string;
|
|
80
76
|
readonly template?: TemplateName;
|
|
81
77
|
readonly framework?: string;
|
|
82
|
-
readonly
|
|
78
|
+
readonly deployTarget?: string;
|
|
79
|
+
readonly docker?: boolean;
|
|
83
80
|
readonly ci?: string;
|
|
84
81
|
readonly db?: string;
|
|
85
82
|
readonly auth?: string;
|
|
86
83
|
readonly force?: boolean;
|
|
87
84
|
readonly link?: string;
|
|
88
85
|
}
|
|
89
|
-
/** Parse `[dir] [--template|-t <t>] [--framework|-f <fw>] [--
|
|
86
|
+
/** Parse `[dir] [--template|-t <t>] [--framework|-f <fw>] [--target <t>] [--docker] [--ci|-c github]
|
|
90
87
|
* [--db <preset>] [--auth <preset>] [--force] [--link <path>]`.
|
|
91
|
-
* `--framework`/`--
|
|
88
|
+
* `--framework`/`--target`/`--docker`/`--ci` all default the template to `site`. Throws on the retired
|
|
89
|
+
* `--deploy`. */
|
|
92
90
|
export declare function parseArgs(argv: readonly string[]): ParsedArgs;
|
|
93
91
|
/**
|
|
94
92
|
* Run the CLI for `argv` and return the exit code + the message to print - no `process.exit`, `console`,
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAoBA,OAAO,EAGL,KAAK,UAAU,EAGhB,MAAM,WAAW,CAAA;AAClB,OAAO,EAA0B,KAAK,QAAQ,EAAgB,MAAM,SAAS,CAAA;AAI7E,OAAO,EAEL,KAAK,YAAY,EAIlB,MAAM,uBAAuB,CAAA;AAE9B,QAAA,MAAM,SAAS;;;;;CAKL,CAAA;AACV,MAAM,MAAM,YAAY,GAAG,MAAM,OAAO,SAAS,CAAA;AAEjD;;eAEe;AACf,QA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