create-taserjs 0.0.5 → 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/README.md +1 -1
- package/dist/cjs/addons/registry.cjs +3 -4
- package/dist/cjs/addons/registry.cjs.map +1 -1
- package/dist/cjs/addons/validators.cjs +10 -13
- package/dist/cjs/addons/validators.cjs.map +1 -1
- package/dist/cjs/cli.cjs +7 -5
- package/dist/cjs/cli.cjs.map +1 -1
- package/dist/cjs/commands/create.cjs +68 -48
- package/dist/cjs/commands/create.cjs.map +1 -1
- package/dist/cjs/commands/create.d.cts +2 -1
- package/dist/cjs/core/parse-options.cjs +48 -22
- package/dist/cjs/core/parse-options.cjs.map +1 -1
- package/dist/cjs/core/parse-options.d.cts +19 -4
- package/dist/cjs/core/project-config.cjs +5 -1
- package/dist/cjs/core/project-config.cjs.map +1 -1
- package/dist/cjs/core/resolve-packages.cjs +28 -66
- package/dist/cjs/core/resolve-packages.cjs.map +1 -1
- package/dist/cjs/core/resolve-packages.d.cts +1 -4
- package/dist/cjs/core/scaffold-engine.cjs +18 -49
- package/dist/cjs/core/scaffold-engine.cjs.map +1 -1
- package/dist/cjs/core/targets.cjs +162 -0
- package/dist/cjs/core/targets.cjs.map +1 -0
- package/dist/cjs/core/targets.d.cts +49 -0
- package/dist/cjs/core/types.cjs +21 -11
- package/dist/cjs/core/types.cjs.map +1 -1
- package/dist/cjs/core/types.d.cts +20 -4
- package/dist/cjs/frameworks/index.cjs +76 -194
- package/dist/cjs/frameworks/index.cjs.map +1 -1
- package/dist/cjs/frameworks/index.d.cts +18 -3
- package/dist/cjs/scaffold.d.cts +2 -2
- package/dist/cjs/templates/base.cjs +15 -99
- package/dist/cjs/templates/base.cjs.map +1 -1
- package/dist/cjs/templates/base.d.cts +0 -3
- package/dist/cjs/types.d.cts +1 -1
- package/dist/esm/addons/registry.js +4 -5
- package/dist/esm/addons/registry.js.map +1 -1
- package/dist/esm/addons/validators.js +10 -13
- package/dist/esm/addons/validators.js.map +1 -1
- package/dist/esm/cli.js +7 -5
- package/dist/esm/cli.js.map +1 -1
- package/dist/esm/commands/create.d.ts +2 -1
- package/dist/esm/commands/create.js +70 -50
- package/dist/esm/commands/create.js.map +1 -1
- package/dist/esm/core/parse-options.d.ts +19 -4
- package/dist/esm/core/parse-options.js +47 -23
- package/dist/esm/core/parse-options.js.map +1 -1
- package/dist/esm/core/project-config.js +5 -1
- package/dist/esm/core/project-config.js.map +1 -1
- package/dist/esm/core/resolve-packages.d.ts +1 -4
- package/dist/esm/core/resolve-packages.js +28 -66
- package/dist/esm/core/resolve-packages.js.map +1 -1
- package/dist/esm/core/scaffold-engine.js +20 -51
- package/dist/esm/core/scaffold-engine.js.map +1 -1
- package/dist/esm/core/targets.d.ts +49 -0
- package/dist/esm/core/targets.js +157 -0
- package/dist/esm/core/targets.js.map +1 -0
- package/dist/esm/core/types.d.ts +20 -4
- package/dist/esm/core/types.js +19 -11
- package/dist/esm/core/types.js.map +1 -1
- package/dist/esm/frameworks/index.d.ts +18 -3
- package/dist/esm/frameworks/index.js +73 -194
- package/dist/esm/frameworks/index.js.map +1 -1
- package/dist/esm/scaffold.d.ts +2 -2
- package/dist/esm/templates/base.d.ts +0 -3
- package/dist/esm/templates/base.js +16 -98
- package/dist/esm/templates/base.js.map +1 -1
- package/dist/esm/types.d.ts +1 -1
- package/package.json +3 -2
- package/src/addons/registry.ts +6 -17
- package/src/addons/validators.ts +10 -13
- package/src/cli.ts +6 -4
- package/src/commands/create.ts +82 -26
- package/src/core/parse-options.ts +84 -35
- package/src/core/project-config.ts +6 -1
- package/src/core/resolve-packages.ts +38 -76
- package/src/core/scaffold-engine.ts +43 -81
- package/src/core/targets.ts +202 -0
- package/src/core/types.ts +38 -24
- package/src/frameworks/index.ts +75 -211
- package/src/scaffold.ts +2 -2
- package/src/templates/base.ts +14 -98
- package/src/types.ts +3 -1
|
@@ -2,11 +2,13 @@ import { copyFile, mkdir, writeFile } from "node:fs/promises";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
|
|
4
4
|
import { collectBootBindings, resolveAddons } from "../addons/registry.js";
|
|
5
|
-
import {
|
|
5
|
+
import { nitroConfigTemplate, taserTsTemplate, viteConfigTemplate } from "../frameworks/index.js";
|
|
6
6
|
import { installPackages, resolveUserAgent } from "./package-manager.js";
|
|
7
7
|
import { writeProjectConfig } from "./project-config.js";
|
|
8
8
|
import { resolvePackages } from "./resolve-packages.js";
|
|
9
|
-
import
|
|
9
|
+
import { resolveDeployEntry, validateCombination } from "./targets.js";
|
|
10
|
+
import { FRAMEWORK_ENTRIES } from "../frameworks/index.js";
|
|
11
|
+
import type { ScaffoldContext, ScaffoldOptions, ScaffoldResult } from "./types.js";
|
|
10
12
|
import {
|
|
11
13
|
contextTemplate,
|
|
12
14
|
gitignoreTemplate,
|
|
@@ -14,9 +16,7 @@ import {
|
|
|
14
16
|
indexRouteTemplate,
|
|
15
17
|
packageJsonTemplate,
|
|
16
18
|
rootLayoutTemplate,
|
|
17
|
-
starterManifestTemplate,
|
|
18
19
|
tsconfigTemplate,
|
|
19
|
-
tsdownConfigTemplate,
|
|
20
20
|
} from "../templates/base.js";
|
|
21
21
|
|
|
22
22
|
async function write(filePath: string, contents: string): Promise<void> {
|
|
@@ -26,10 +26,23 @@ async function write(filePath: string, contents: string): Promise<void> {
|
|
|
26
26
|
|
|
27
27
|
export async function scaffoldProject(options: ScaffoldOptions): Promise<ScaffoldResult> {
|
|
28
28
|
const root = options.targetDir;
|
|
29
|
-
const
|
|
29
|
+
const preset = options.preset ?? "node-server";
|
|
30
|
+
const framework = options.framework ?? "none";
|
|
31
|
+
|
|
32
|
+
// Guards direct/library callers; the CLI path is validated earlier in
|
|
33
|
+
// resolveScaffoldDefaults. Throws with a precise reason on impossible
|
|
34
|
+
// runtime × framework × deploy combinations.
|
|
35
|
+
const combination = validateCombination(options.runtime, framework, preset);
|
|
36
|
+
if (!combination.ok) {
|
|
37
|
+
throw new Error(combination.reason);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const ctx: ScaffoldContext = {
|
|
30
41
|
projectName: options.projectName,
|
|
31
42
|
targetDir: root,
|
|
32
|
-
|
|
43
|
+
framework,
|
|
44
|
+
preset,
|
|
45
|
+
...(options.runtime !== undefined ? { runtime: options.runtime } : {}),
|
|
33
46
|
...(options.db ? { db: options.db, driver: options.driver } : {}),
|
|
34
47
|
...(options.logger ? { logger: options.logger } : {}),
|
|
35
48
|
...(options.validator ? { validator: options.validator } : {}),
|
|
@@ -38,79 +51,42 @@ export async function scaffoldProject(options: ScaffoldOptions): Promise<Scaffol
|
|
|
38
51
|
const addons = resolveAddons(ctx);
|
|
39
52
|
const packages = resolvePackages(ctx);
|
|
40
53
|
const bootBindings = collectBootBindings(ctx);
|
|
54
|
+
const frameworkEntry = FRAMEWORK_ENTRIES[framework];
|
|
55
|
+
const { entry: deployEntry } = resolveDeployEntry(ctx.preset ?? "node-server");
|
|
41
56
|
|
|
42
57
|
await write(
|
|
43
58
|
path.join(root, "package.json"),
|
|
44
59
|
packageJsonTemplate(options.projectName, packages.scripts),
|
|
45
60
|
);
|
|
46
61
|
await write(path.join(root, "tsconfig.json"), tsconfigTemplate());
|
|
47
|
-
await write(path.join(root, "
|
|
62
|
+
await write(path.join(root, "vite.config.ts"), viteConfigTemplate());
|
|
48
63
|
await write(path.join(root, ".gitignore"), gitignoreTemplate());
|
|
49
64
|
await write(path.join(root, "src/context.ts"), contextTemplate(bootBindings));
|
|
50
|
-
await write(path.join(root, "src/taser.ts"), taserTsTemplate(
|
|
51
|
-
await write(path.join(root, "src/index.ts"), indexTemplate(options.type));
|
|
65
|
+
await write(path.join(root, "src/taser.ts"), taserTsTemplate());
|
|
52
66
|
await write(path.join(root, "src/routes/$.ts"), rootLayoutTemplate());
|
|
53
67
|
await write(path.join(root, "src/routes/index.get.ts"), indexRouteTemplate());
|
|
54
68
|
await write(path.join(root, "src/routes/health.get.ts"), healthRouteTemplate(ctx));
|
|
55
|
-
await write(path.join(root, "src/routeManifest.gen.ts"), starterManifestTemplate());
|
|
56
|
-
|
|
57
|
-
if (options.type === "cloudflare-workers") {
|
|
58
|
-
await write(
|
|
59
|
-
path.join(root, "wrangler.jsonc"),
|
|
60
|
-
JSON.stringify(
|
|
61
|
-
{
|
|
62
|
-
$schema: "node_modules/wrangler/config-schema.json",
|
|
63
|
-
name: options.projectName,
|
|
64
|
-
main: "src/index.ts",
|
|
65
|
-
compatibility_date: "2024-11-01",
|
|
66
|
-
},
|
|
67
|
-
null,
|
|
68
|
-
2,
|
|
69
|
-
) + "\n",
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
69
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
{
|
|
78
|
-
rewrites: [{ source: "/(.*)", destination: "/src/index.ts" }],
|
|
79
|
-
},
|
|
80
|
-
null,
|
|
81
|
-
2,
|
|
82
|
-
) + "\n",
|
|
83
|
-
);
|
|
70
|
+
// Nitro's default preset is node-server — only emit an explicit config when
|
|
71
|
+
// the deployment target differs.
|
|
72
|
+
if (ctx.preset !== "node-server") {
|
|
73
|
+
await write(path.join(root, "nitro.config.ts"), nitroConfigTemplate(deployEntry.id));
|
|
84
74
|
}
|
|
85
75
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
extensionBundle: {
|
|
101
|
-
id: "Microsoft.Azure.Functions.ExtensionBundle",
|
|
102
|
-
version: "[4.*, 5.0.0)",
|
|
103
|
-
},
|
|
104
|
-
extensions: {
|
|
105
|
-
http: {
|
|
106
|
-
routePrefix: "",
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
null,
|
|
111
|
-
2,
|
|
112
|
-
) + "\n",
|
|
113
|
-
);
|
|
76
|
+
await Promise.all(
|
|
77
|
+
deployEntry.files.map((file) =>
|
|
78
|
+
write(
|
|
79
|
+
path.join(root, file.name),
|
|
80
|
+
typeof file.content === "function"
|
|
81
|
+
? file.content({ projectName: options.projectName })
|
|
82
|
+
: file.content,
|
|
83
|
+
),
|
|
84
|
+
),
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
const serverEntry = frameworkEntry.serverEntry;
|
|
88
|
+
if (serverEntry) {
|
|
89
|
+
await write(path.join(root, serverEntry.fileName), serverEntry.content);
|
|
114
90
|
}
|
|
115
91
|
|
|
116
92
|
await Promise.all(
|
|
@@ -128,14 +104,7 @@ export async function scaffoldProject(options: ScaffoldOptions): Promise<Scaffol
|
|
|
128
104
|
await writeProjectConfig(root, ctx);
|
|
129
105
|
|
|
130
106
|
if (options.skipInstall) {
|
|
131
|
-
return
|
|
132
|
-
projectName: ctx.projectName,
|
|
133
|
-
targetDir: root,
|
|
134
|
-
type: ctx.type,
|
|
135
|
-
...(ctx.db ? { db: ctx.db, driver: ctx.driver } : {}),
|
|
136
|
-
...(ctx.logger ? { logger: ctx.logger } : {}),
|
|
137
|
-
...(ctx.validator ? { validator: ctx.validator } : {}),
|
|
138
|
-
};
|
|
107
|
+
return ctx as ScaffoldResult;
|
|
139
108
|
}
|
|
140
109
|
|
|
141
110
|
const agent = options.agent ?? resolveUserAgent();
|
|
@@ -144,12 +113,5 @@ export async function scaffoldProject(options: ScaffoldOptions): Promise<Scaffol
|
|
|
144
113
|
devDependencies: packages.devDependencies,
|
|
145
114
|
});
|
|
146
115
|
|
|
147
|
-
return
|
|
148
|
-
projectName: ctx.projectName,
|
|
149
|
-
targetDir: root,
|
|
150
|
-
type: ctx.type,
|
|
151
|
-
...(ctx.db ? { db: ctx.db, driver: ctx.driver } : {}),
|
|
152
|
-
...(ctx.logger ? { logger: ctx.logger } : {}),
|
|
153
|
-
...(ctx.validator ? { validator: ctx.validator } : {}),
|
|
154
|
-
};
|
|
116
|
+
return ctx as ScaffoldResult;
|
|
155
117
|
}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registry for the three scaffold dimensions — runtime, framework, deploy —
|
|
3
|
+
* plus the compatibility rules between them.
|
|
4
|
+
*
|
|
5
|
+
* Dependency direction: deploy implies the runtime family; the effective
|
|
6
|
+
* runtime constrains which frameworks can run. `--runtime` is an override
|
|
7
|
+
* available only where it is meaningful (self-hosted node-family targets).
|
|
8
|
+
*/
|
|
9
|
+
import { DEPLOY_TARGETS, type DeployTarget, type Framework, type Runtime } from "./types.js";
|
|
10
|
+
|
|
11
|
+
export type PlatformFile = {
|
|
12
|
+
name: string;
|
|
13
|
+
content: string | ((ctx: { projectName: string }) => string);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type DeployEntry = {
|
|
17
|
+
id: DeployTarget;
|
|
18
|
+
/** Runtime this target builds for ("workerd" = Cloudflare's V8 runtime). */
|
|
19
|
+
impliedRuntime: Runtime | "workerd";
|
|
20
|
+
/** Whether the built output is a long-running server you start locally. */
|
|
21
|
+
selfHosted: boolean;
|
|
22
|
+
/** `start` script value; null for platform-deployed targets. */
|
|
23
|
+
startScript: string | null;
|
|
24
|
+
/** Runtime/platform tooling devDependencies beyond the base set. */
|
|
25
|
+
devDeps: string[];
|
|
26
|
+
files: PlatformFile[];
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const NODE_START = "node .output/server/index.mjs";
|
|
30
|
+
|
|
31
|
+
export const DEPLOY_ENTRIES: Record<DeployTarget, DeployEntry> = {
|
|
32
|
+
"node-server": {
|
|
33
|
+
id: "node-server",
|
|
34
|
+
impliedRuntime: "node",
|
|
35
|
+
selfHosted: true,
|
|
36
|
+
startScript: NODE_START,
|
|
37
|
+
devDeps: [],
|
|
38
|
+
files: [],
|
|
39
|
+
},
|
|
40
|
+
"node-cluster": {
|
|
41
|
+
id: "node-cluster",
|
|
42
|
+
impliedRuntime: "node",
|
|
43
|
+
selfHosted: true,
|
|
44
|
+
startScript: NODE_START,
|
|
45
|
+
devDeps: [],
|
|
46
|
+
files: [],
|
|
47
|
+
},
|
|
48
|
+
bun: {
|
|
49
|
+
id: "bun",
|
|
50
|
+
impliedRuntime: "bun",
|
|
51
|
+
selfHosted: true,
|
|
52
|
+
startScript: "bun .output/server/index.mjs",
|
|
53
|
+
devDeps: ["@types/bun"],
|
|
54
|
+
files: [],
|
|
55
|
+
},
|
|
56
|
+
"deno-server": {
|
|
57
|
+
id: "deno-server",
|
|
58
|
+
impliedRuntime: "deno",
|
|
59
|
+
selfHosted: true,
|
|
60
|
+
startScript: "deno run -A .output/server/index.mjs",
|
|
61
|
+
devDeps: [],
|
|
62
|
+
files: [],
|
|
63
|
+
},
|
|
64
|
+
"deno-deploy": {
|
|
65
|
+
id: "deno-deploy",
|
|
66
|
+
impliedRuntime: "deno",
|
|
67
|
+
selfHosted: false,
|
|
68
|
+
startScript: null,
|
|
69
|
+
devDeps: [],
|
|
70
|
+
files: [],
|
|
71
|
+
},
|
|
72
|
+
"cloudflare-module": {
|
|
73
|
+
id: "cloudflare-module",
|
|
74
|
+
impliedRuntime: "workerd",
|
|
75
|
+
selfHosted: false,
|
|
76
|
+
startScript: null,
|
|
77
|
+
devDeps: ["wrangler", "@cloudflare/workers-types"],
|
|
78
|
+
files: [
|
|
79
|
+
{
|
|
80
|
+
name: "wrangler.jsonc",
|
|
81
|
+
content: ({ projectName }) =>
|
|
82
|
+
`${JSON.stringify(
|
|
83
|
+
{
|
|
84
|
+
$schema: "node_modules/wrangler/config-schema.json",
|
|
85
|
+
name: projectName,
|
|
86
|
+
main: ".output/server/index.mjs",
|
|
87
|
+
compatibility_date: "2024-11-01",
|
|
88
|
+
},
|
|
89
|
+
null,
|
|
90
|
+
2,
|
|
91
|
+
)}\n`,
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
},
|
|
95
|
+
vercel: {
|
|
96
|
+
id: "vercel",
|
|
97
|
+
impliedRuntime: "node",
|
|
98
|
+
selfHosted: false,
|
|
99
|
+
startScript: null,
|
|
100
|
+
devDeps: ["@vercel/node"],
|
|
101
|
+
files: [],
|
|
102
|
+
},
|
|
103
|
+
"aws-lambda": {
|
|
104
|
+
id: "aws-lambda",
|
|
105
|
+
impliedRuntime: "node",
|
|
106
|
+
selfHosted: false,
|
|
107
|
+
startScript: null,
|
|
108
|
+
devDeps: ["@types/aws-lambda"],
|
|
109
|
+
files: [],
|
|
110
|
+
},
|
|
111
|
+
netlify: {
|
|
112
|
+
id: "netlify",
|
|
113
|
+
impliedRuntime: "node",
|
|
114
|
+
selfHosted: false,
|
|
115
|
+
startScript: null,
|
|
116
|
+
devDeps: [],
|
|
117
|
+
files: [],
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
/** Runtimes a `--runtime` override may select per self-hosted deploy target. */
|
|
122
|
+
const RUNTIME_OVERRIDES: Partial<Record<DeployTarget, readonly Runtime[]>> = {
|
|
123
|
+
"node-server": ["node", "bun"],
|
|
124
|
+
"node-cluster": ["node", "bun"],
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
export const DEFAULT_DEPLOY: DeployTarget = "node-server";
|
|
128
|
+
export const DEFAULT_FRAMEWORK: Framework = "none";
|
|
129
|
+
|
|
130
|
+
export function isCuratedDeploy(value: string): value is DeployTarget {
|
|
131
|
+
return (DEPLOY_TARGETS as readonly string[]).includes(value);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Resolves any preset id to its emission entry. Curated ids come from the
|
|
136
|
+
* registry; unknown strings pass through to Nitro verbatim as non-self-hosted
|
|
137
|
+
* node-family targets.
|
|
138
|
+
*/
|
|
139
|
+
export function resolveDeployEntry(id: string): { entry: DeployEntry; curated: boolean } {
|
|
140
|
+
if (isCuratedDeploy(id)) {
|
|
141
|
+
return { entry: DEPLOY_ENTRIES[id], curated: true };
|
|
142
|
+
}
|
|
143
|
+
return {
|
|
144
|
+
entry: {
|
|
145
|
+
// Cast: passthrough ids are valid Nitro PresetNameInputs by contract.
|
|
146
|
+
id: id as DeployTarget,
|
|
147
|
+
impliedRuntime: "node",
|
|
148
|
+
selfHosted: false,
|
|
149
|
+
startScript: null,
|
|
150
|
+
devDeps: [],
|
|
151
|
+
files: [],
|
|
152
|
+
},
|
|
153
|
+
curated: false,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** Runtime overrides permitted for a deploy target; empty = no override. */
|
|
158
|
+
export function allowedRuntimeOverrides(id: DeployTarget): readonly Runtime[] {
|
|
159
|
+
return RUNTIME_OVERRIDES[id] ?? [];
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export type CombinationError = { ok: false; reason: string };
|
|
163
|
+
export type CombinationOk = { ok: true; runtime: Runtime | "workerd" };
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Validates a runtime × framework × deploy combination.
|
|
167
|
+
*
|
|
168
|
+
* @param runtimeOverride explicit `--runtime` selection, if any
|
|
169
|
+
* @param deploy preset id (curated or passthrough)
|
|
170
|
+
*/
|
|
171
|
+
export function validateCombination(
|
|
172
|
+
runtimeOverride: Runtime | undefined,
|
|
173
|
+
framework: Framework,
|
|
174
|
+
deploy: string,
|
|
175
|
+
): CombinationOk | CombinationError {
|
|
176
|
+
const { entry } = resolveDeployEntry(deploy);
|
|
177
|
+
|
|
178
|
+
if (runtimeOverride !== undefined) {
|
|
179
|
+
const allowed = entry.selfHosted ? allowedRuntimeOverrides(entry.id) : [];
|
|
180
|
+
if (!allowed.includes(runtimeOverride)) {
|
|
181
|
+
return {
|
|
182
|
+
ok: false,
|
|
183
|
+
reason:
|
|
184
|
+
`Runtime "${runtimeOverride}" is not valid for deploy target "${entry.id}". ` +
|
|
185
|
+
(allowed.length > 0
|
|
186
|
+
? `Allowed overrides: ${allowed.join(", ")}.`
|
|
187
|
+
: `It implies runtime "${String(entry.impliedRuntime)}".`),
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const effective = runtimeOverride ?? entry.impliedRuntime;
|
|
193
|
+
|
|
194
|
+
if ((framework === "express" || framework === "fastify") && effective !== "node") {
|
|
195
|
+
return {
|
|
196
|
+
ok: false,
|
|
197
|
+
reason: `Framework "${framework}" requires the Node runtime, but deploy target "${entry.id}" implies "${String(effective)}".`,
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
return { ok: true, runtime: effective };
|
|
202
|
+
}
|
package/src/core/types.ts
CHANGED
|
@@ -1,32 +1,39 @@
|
|
|
1
1
|
import type { Agent } from "package-manager-detector";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
/** Host framework layered on top of pure Taser pass-through dispatch. */
|
|
4
|
+
export type Framework = "none" | "hono" | "express" | "fastify";
|
|
5
|
+
|
|
6
|
+
export const FRAMEWORKS: readonly Framework[] = ["none", "hono", "express", "fastify"];
|
|
7
|
+
|
|
8
|
+
export type Runtime = "node" | "bun" | "deno";
|
|
9
|
+
|
|
10
|
+
export const RUNTIMES: readonly Runtime[] = ["node", "bun", "deno"];
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Deployment target. Values are Nitro preset ids (see `nitro/config`
|
|
14
|
+
* PresetNameInput) so `--preset` passes straight through to Nitro.
|
|
15
|
+
*/
|
|
16
|
+
export type DeployTarget =
|
|
17
|
+
| "node-server"
|
|
18
|
+
| "node-cluster"
|
|
8
19
|
| "bun"
|
|
9
|
-
| "deno"
|
|
10
|
-
| "
|
|
11
|
-
| "cloudflare-
|
|
12
|
-
| "netlify"
|
|
20
|
+
| "deno-server"
|
|
21
|
+
| "deno-deploy"
|
|
22
|
+
| "cloudflare-module"
|
|
13
23
|
| "vercel"
|
|
14
|
-
| "
|
|
15
|
-
| "
|
|
16
|
-
|
|
17
|
-
export const
|
|
18
|
-
"node",
|
|
19
|
-
"
|
|
20
|
-
"fastify",
|
|
21
|
-
"hono",
|
|
24
|
+
| "aws-lambda"
|
|
25
|
+
| "netlify";
|
|
26
|
+
|
|
27
|
+
export const DEPLOY_TARGETS: readonly DeployTarget[] = [
|
|
28
|
+
"node-server",
|
|
29
|
+
"node-cluster",
|
|
22
30
|
"bun",
|
|
23
|
-
"deno",
|
|
31
|
+
"deno-server",
|
|
32
|
+
"deno-deploy",
|
|
33
|
+
"cloudflare-module",
|
|
34
|
+
"vercel",
|
|
24
35
|
"aws-lambda",
|
|
25
|
-
"cloudflare-workers",
|
|
26
36
|
"netlify",
|
|
27
|
-
"vercel",
|
|
28
|
-
"azure-functions",
|
|
29
|
-
"google-cloud-run",
|
|
30
37
|
];
|
|
31
38
|
|
|
32
39
|
export type DbOdm = "drizzle" | "prisma" | "kysely";
|
|
@@ -56,7 +63,12 @@ export type PackageGroups = {
|
|
|
56
63
|
export type ScaffoldContext = {
|
|
57
64
|
projectName: string;
|
|
58
65
|
targetDir: string;
|
|
59
|
-
|
|
66
|
+
/** Host framework; "none" is pure Taser pass-through dispatch. Defaults to "none". */
|
|
67
|
+
framework?: Framework;
|
|
68
|
+
/** Deployment target — a Nitro preset id. Defaults to "node-server". */
|
|
69
|
+
preset?: DeployTarget;
|
|
70
|
+
/** Set only when explicitly overriding the runtime implied by the preset. */
|
|
71
|
+
runtime?: Runtime;
|
|
60
72
|
db?: DbOdm;
|
|
61
73
|
driver?: DbDriver;
|
|
62
74
|
logger?: LoggerId;
|
|
@@ -71,7 +83,9 @@ export type ScaffoldOptions = ScaffoldContext & {
|
|
|
71
83
|
export type ScaffoldResult = ScaffoldContext;
|
|
72
84
|
|
|
73
85
|
export type CapabilitiesCatalog = {
|
|
74
|
-
|
|
86
|
+
frameworks: Framework[];
|
|
87
|
+
deployTargets: DeployTarget[];
|
|
88
|
+
runtimes: Runtime[];
|
|
75
89
|
db: {
|
|
76
90
|
odms: DbOdm[];
|
|
77
91
|
drivers: DbDriver[];
|