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
|
@@ -1,75 +1,37 @@
|
|
|
1
1
|
const require_registry = require("../addons/registry.cjs");
|
|
2
|
+
const require_targets = require("./targets.cjs");
|
|
3
|
+
const require_index = require("../frameworks/index.cjs");
|
|
2
4
|
//#region src/core/resolve-packages.ts
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
case "
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
break;
|
|
19
|
-
case "fastify":
|
|
20
|
-
dependencies.push("@taserjs/adapter-fastify", "fastify");
|
|
21
|
-
break;
|
|
22
|
-
case "hono":
|
|
23
|
-
dependencies.push("@hono/node-server", "hono");
|
|
24
|
-
break;
|
|
25
|
-
case "bun":
|
|
26
|
-
devDependencies.push("@types/bun");
|
|
27
|
-
scripts["dev:server"] = "bun --watch src/index.ts";
|
|
28
|
-
scripts.start = "bun src/index.ts";
|
|
29
|
-
scripts.serve = "bun dist/index.mjs";
|
|
30
|
-
break;
|
|
31
|
-
case "deno":
|
|
32
|
-
scripts["dev:server"] = "deno run --watch --allow-net --allow-env --allow-read src/index.ts";
|
|
33
|
-
scripts.start = "deno run --allow-net --allow-env --allow-read src/index.ts";
|
|
34
|
-
scripts.serve = "deno run --allow-net --allow-env --allow-read dist/index.mjs";
|
|
35
|
-
break;
|
|
36
|
-
case "aws-lambda":
|
|
37
|
-
dependencies.push("hono");
|
|
38
|
-
devDependencies.push("@types/aws-lambda");
|
|
39
|
-
break;
|
|
40
|
-
case "cloudflare-workers": {
|
|
41
|
-
const cfDevDeps = devDependencies.filter((d) => d !== "tsx");
|
|
42
|
-
cfDevDeps.push("wrangler", "@cloudflare/workers-types");
|
|
43
|
-
devDependencies.length = 0;
|
|
44
|
-
devDependencies.push(...cfDevDeps);
|
|
45
|
-
scripts["dev:server"] = "wrangler dev";
|
|
46
|
-
scripts.deploy = "wrangler deploy";
|
|
47
|
-
break;
|
|
48
|
-
}
|
|
49
|
-
case "netlify":
|
|
50
|
-
dependencies.push("hono", "@netlify/functions");
|
|
51
|
-
break;
|
|
52
|
-
case "vercel":
|
|
53
|
-
dependencies.push("hono");
|
|
54
|
-
devDependencies.push("@vercel/node");
|
|
55
|
-
break;
|
|
56
|
-
case "azure-functions":
|
|
57
|
-
dependencies.push("hono", "@azure/functions", "@marplex/hono-azurefunc-adapter");
|
|
58
|
-
break;
|
|
59
|
-
default: dependencies.push("@hono/node-server");
|
|
5
|
+
var BASE_DEPENDENCIES = ["@taserjs/router", "dotenv"];
|
|
6
|
+
/** Runtime-agnostic build/dev tooling every scaffolded project needs. */
|
|
7
|
+
var BASE_DEV_DEPENDENCIES = [
|
|
8
|
+
"@taserjs/router-plugin",
|
|
9
|
+
"nitro",
|
|
10
|
+
"typescript@^5.9.3",
|
|
11
|
+
"vite@^8.1.5"
|
|
12
|
+
];
|
|
13
|
+
function runtimeDevDeps(ctx) {
|
|
14
|
+
const { entry } = require_targets.resolveDeployEntry(ctx.preset ?? "node-server");
|
|
15
|
+
switch (ctx.runtime ?? entry.impliedRuntime) {
|
|
16
|
+
case "bun": return ["@types/bun"];
|
|
17
|
+
case "deno": return [];
|
|
18
|
+
case "workerd": return ["@cloudflare/workers-types"];
|
|
19
|
+
default: return ["@types/node"];
|
|
60
20
|
}
|
|
61
|
-
return {
|
|
62
|
-
dependencies,
|
|
63
|
-
devDependencies,
|
|
64
|
-
scripts
|
|
65
|
-
};
|
|
66
21
|
}
|
|
67
22
|
function resolvePackages(ctx) {
|
|
68
|
-
const
|
|
23
|
+
const frameworkEntry = require_index.FRAMEWORK_ENTRIES[ctx.framework ?? "none"];
|
|
24
|
+
const { entry: deployEntry } = require_targets.resolveDeployEntry(ctx.preset ?? "node-server");
|
|
25
|
+
const dependencies = [...BASE_DEPENDENCIES, ...frameworkEntry.deps];
|
|
26
|
+
const devDependencies = [
|
|
27
|
+
...BASE_DEV_DEPENDENCIES,
|
|
28
|
+
...runtimeDevDeps(ctx),
|
|
29
|
+
...deployEntry.devDeps,
|
|
30
|
+
...frameworkEntry.devDeps
|
|
31
|
+
];
|
|
32
|
+
const scripts = {};
|
|
33
|
+
if (deployEntry.startScript) scripts.start = deployEntry.startScript;
|
|
69
34
|
const addons = require_registry.resolveAddons(ctx);
|
|
70
|
-
const dependencies = [...base.dependencies];
|
|
71
|
-
const devDependencies = [...base.devDependencies];
|
|
72
|
-
const scripts = { ...base.scripts };
|
|
73
35
|
for (const addon of addons) {
|
|
74
36
|
dependencies.push(...addon.dependencies(ctx));
|
|
75
37
|
devDependencies.push(...addon.devDependencies(ctx));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-packages.cjs","names":[],"sources":["../../../src/core/resolve-packages.ts"],"sourcesContent":["import { resolveAddons } from \"../addons/registry.js\";\nimport type { PackageGroups,
|
|
1
|
+
{"version":3,"file":"resolve-packages.cjs","names":[],"sources":["../../../src/core/resolve-packages.ts"],"sourcesContent":["import { resolveAddons } from \"../addons/registry.js\";\nimport { FRAMEWORK_ENTRIES } from \"../frameworks/index.js\";\nimport type { PackageGroups, ScaffoldContext } from \"../core/types.js\";\nimport { resolveDeployEntry } from \"./targets.js\";\n\nconst BASE_DEPENDENCIES = [\"@taserjs/router\", \"dotenv\"];\n\n/** Runtime-agnostic build/dev tooling every scaffolded project needs. */\nconst BASE_DEV_DEPENDENCIES = [\n \"@taserjs/router-plugin\",\n \"nitro\",\n \"typescript@^5.9.3\",\n \"vite@^8.1.5\",\n];\n\nfunction runtimeDevDeps(ctx: ScaffoldContext): string[] {\n const { entry } = resolveDeployEntry(ctx.preset ?? \"node-server\");\n const effective = ctx.runtime ?? entry.impliedRuntime;\n switch (effective) {\n case \"bun\":\n return [\"@types/bun\"];\n case \"deno\":\n return []; // Deno ships its own tooling and types.\n case \"workerd\":\n return [\"@cloudflare/workers-types\"];\n case \"node\":\n default:\n return [\"@types/node\"];\n }\n}\n\nexport function resolvePackages(ctx: ScaffoldContext): PackageGroups {\n const frameworkEntry = FRAMEWORK_ENTRIES[ctx.framework ?? \"none\"];\n const { entry: deployEntry } = resolveDeployEntry(ctx.preset ?? \"node-server\");\n\n const dependencies = [...BASE_DEPENDENCIES, ...frameworkEntry.deps];\n const devDependencies = [\n ...BASE_DEV_DEPENDENCIES,\n ...runtimeDevDeps(ctx),\n ...deployEntry.devDeps,\n ...frameworkEntry.devDeps,\n ];\n\n const scripts: Record<string, string> = {};\n if (deployEntry.startScript) {\n scripts.start = deployEntry.startScript;\n }\n\n const addons = resolveAddons(ctx);\n for (const addon of addons) {\n dependencies.push(...addon.dependencies(ctx));\n devDependencies.push(...addon.devDependencies(ctx));\n if (addon.scripts) {\n Object.assign(scripts, addon.scripts(ctx));\n }\n }\n\n return {\n dependencies: [...new Set(dependencies)],\n devDependencies: [...new Set(devDependencies)],\n scripts,\n };\n}\n"],"mappings":";;;;AAKA,IAAM,oBAAoB,CAAC,mBAAmB,QAAQ;;AAGtD,IAAM,wBAAwB;CAC5B;CACA;CACA;CACA;AACF;AAEA,SAAS,eAAe,KAAgC;CACtD,MAAM,EAAE,UAAU,gBAAA,mBAAmB,IAAI,UAAU,aAAa;CAEhE,QADkB,IAAI,WAAW,MAAM,gBACvC;EACE,KAAK,OACH,OAAO,CAAC,YAAY;EACtB,KAAK,QACH,OAAO,CAAC;EACV,KAAK,WACH,OAAO,CAAC,2BAA2B;EAErC,SACE,OAAO,CAAC,aAAa;CACzB;AACF;AAEA,SAAgB,gBAAgB,KAAqC;CACnE,MAAM,iBAAiB,cAAA,kBAAkB,IAAI,aAAa;CAC1D,MAAM,EAAE,OAAO,gBAAgB,gBAAA,mBAAmB,IAAI,UAAU,aAAa;CAE7E,MAAM,eAAe,CAAC,GAAG,mBAAmB,GAAG,eAAe,IAAI;CAClE,MAAM,kBAAkB;EACtB,GAAG;EACH,GAAG,eAAe,GAAG;EACrB,GAAG,YAAY;EACf,GAAG,eAAe;CACpB;CAEA,MAAM,UAAkC,CAAC;CACzC,IAAI,YAAY,aACd,QAAQ,QAAQ,YAAY;CAG9B,MAAM,SAAS,iBAAA,cAAc,GAAG;CAChC,KAAK,MAAM,SAAS,QAAQ;EAC1B,aAAa,KAAK,GAAG,MAAM,aAAa,GAAG,CAAC;EAC5C,gBAAgB,KAAK,GAAG,MAAM,gBAAgB,GAAG,CAAC;EAClD,IAAI,MAAM,SACR,OAAO,OAAO,SAAS,MAAM,QAAQ,GAAG,CAAC;CAE7C;CAEA,OAAO;EACL,cAAc,CAAC,GAAG,IAAI,IAAI,YAAY,CAAC;EACvC,iBAAiB,CAAC,GAAG,IAAI,IAAI,eAAe,CAAC;EAC7C;CACF;AACF"}
|
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
import { PackageGroups,
|
|
1
|
+
import { PackageGroups, ScaffoldContext } from '../core/types.js';
|
|
2
2
|
export declare function resolvePackages(ctx: ScaffoldContext): PackageGroups;
|
|
3
|
-
export declare function getPackageGroups(type: ProjectType): Omit<PackageGroups, "scripts"> & {
|
|
4
|
-
scripts?: Record<string, string>;
|
|
5
|
-
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
2
2
|
const require_registry = require("../addons/registry.cjs");
|
|
3
|
+
const require_targets = require("./targets.cjs");
|
|
3
4
|
const require_index = require("../frameworks/index.cjs");
|
|
4
5
|
const require_package_manager = require("./package-manager.cjs");
|
|
5
6
|
const require_project_config = require("./project-config.cjs");
|
|
@@ -15,10 +16,16 @@ async function write(filePath, contents) {
|
|
|
15
16
|
}
|
|
16
17
|
async function scaffoldProject(options) {
|
|
17
18
|
const root = options.targetDir;
|
|
19
|
+
const preset = options.preset ?? "node-server";
|
|
20
|
+
const framework = options.framework ?? "none";
|
|
21
|
+
const combination = require_targets.validateCombination(options.runtime, framework, preset);
|
|
22
|
+
if (!combination.ok) throw new Error(combination.reason);
|
|
18
23
|
const ctx = {
|
|
19
24
|
projectName: options.projectName,
|
|
20
25
|
targetDir: root,
|
|
21
|
-
|
|
26
|
+
framework,
|
|
27
|
+
preset,
|
|
28
|
+
...options.runtime !== void 0 ? { runtime: options.runtime } : {},
|
|
22
29
|
...options.db ? {
|
|
23
30
|
db: options.db,
|
|
24
31
|
driver: options.driver
|
|
@@ -29,39 +36,21 @@ async function scaffoldProject(options) {
|
|
|
29
36
|
const addons = require_registry.resolveAddons(ctx);
|
|
30
37
|
const packages = require_resolve_packages.resolvePackages(ctx);
|
|
31
38
|
const bootBindings = require_registry.collectBootBindings(ctx);
|
|
39
|
+
const frameworkEntry = require_index.FRAMEWORK_ENTRIES[framework];
|
|
40
|
+
const { entry: deployEntry } = require_targets.resolveDeployEntry(ctx.preset ?? "node-server");
|
|
32
41
|
await write(node_path.default.join(root, "package.json"), require_base.packageJsonTemplate(options.projectName, packages.scripts));
|
|
33
42
|
await write(node_path.default.join(root, "tsconfig.json"), require_base.tsconfigTemplate());
|
|
34
|
-
await write(node_path.default.join(root, "
|
|
43
|
+
await write(node_path.default.join(root, "vite.config.ts"), require_index.viteConfigTemplate());
|
|
35
44
|
await write(node_path.default.join(root, ".gitignore"), require_base.gitignoreTemplate());
|
|
36
45
|
await write(node_path.default.join(root, "src/context.ts"), require_base.contextTemplate(bootBindings));
|
|
37
|
-
await write(node_path.default.join(root, "src/taser.ts"), require_index.taserTsTemplate(
|
|
38
|
-
await write(node_path.default.join(root, "src/index.ts"), require_index.indexTemplate(options.type));
|
|
46
|
+
await write(node_path.default.join(root, "src/taser.ts"), require_index.taserTsTemplate());
|
|
39
47
|
await write(node_path.default.join(root, "src/routes/$.ts"), require_base.rootLayoutTemplate());
|
|
40
48
|
await write(node_path.default.join(root, "src/routes/index.get.ts"), require_base.indexRouteTemplate());
|
|
41
49
|
await write(node_path.default.join(root, "src/routes/health.get.ts"), require_base.healthRouteTemplate(ctx));
|
|
42
|
-
await write(node_path.default.join(root, "
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
main: "src/index.ts",
|
|
47
|
-
compatibility_date: "2024-11-01"
|
|
48
|
-
}, null, 2) + "\n");
|
|
49
|
-
if (options.type === "vercel") await write(node_path.default.join(root, "vercel.json"), JSON.stringify({ rewrites: [{
|
|
50
|
-
source: "/(.*)",
|
|
51
|
-
destination: "/src/index.ts"
|
|
52
|
-
}] }, null, 2) + "\n");
|
|
53
|
-
if (options.type === "azure-functions") await write(node_path.default.join(root, "host.json"), JSON.stringify({
|
|
54
|
-
version: "2.0",
|
|
55
|
-
logging: { applicationInsights: { samplingSettings: {
|
|
56
|
-
isEnabled: true,
|
|
57
|
-
excludedTypes: "Request"
|
|
58
|
-
} } },
|
|
59
|
-
extensionBundle: {
|
|
60
|
-
id: "Microsoft.Azure.Functions.ExtensionBundle",
|
|
61
|
-
version: "[4.*, 5.0.0)"
|
|
62
|
-
},
|
|
63
|
-
extensions: { http: { routePrefix: "" } }
|
|
64
|
-
}, null, 2) + "\n");
|
|
50
|
+
if (ctx.preset !== "node-server") await write(node_path.default.join(root, "nitro.config.ts"), require_index.nitroConfigTemplate(deployEntry.id));
|
|
51
|
+
await Promise.all(deployEntry.files.map((file) => write(node_path.default.join(root, file.name), typeof file.content === "function" ? file.content({ projectName: options.projectName }) : file.content)));
|
|
52
|
+
const serverEntry = frameworkEntry.serverEntry;
|
|
53
|
+
if (serverEntry) await write(node_path.default.join(root, serverEntry.fileName), serverEntry.content);
|
|
65
54
|
await Promise.all(addons.map(async (addon) => {
|
|
66
55
|
await addon.apply(ctx, (filePath, contents) => write(node_path.default.join(root, filePath), contents));
|
|
67
56
|
}));
|
|
@@ -69,33 +58,13 @@ async function scaffoldProject(options) {
|
|
|
69
58
|
await (0, node_fs_promises.copyFile)(node_path.default.join(root, ".env.example"), node_path.default.join(root, ".env"));
|
|
70
59
|
} catch {}
|
|
71
60
|
await require_project_config.writeProjectConfig(root, ctx);
|
|
72
|
-
if (options.skipInstall) return
|
|
73
|
-
projectName: ctx.projectName,
|
|
74
|
-
targetDir: root,
|
|
75
|
-
type: ctx.type,
|
|
76
|
-
...ctx.db ? {
|
|
77
|
-
db: ctx.db,
|
|
78
|
-
driver: ctx.driver
|
|
79
|
-
} : {},
|
|
80
|
-
...ctx.logger ? { logger: ctx.logger } : {},
|
|
81
|
-
...ctx.validator ? { validator: ctx.validator } : {}
|
|
82
|
-
};
|
|
61
|
+
if (options.skipInstall) return ctx;
|
|
83
62
|
const agent = options.agent ?? require_package_manager.resolveUserAgent();
|
|
84
63
|
await require_package_manager.installPackages(agent, root, {
|
|
85
64
|
dependencies: packages.dependencies,
|
|
86
65
|
devDependencies: packages.devDependencies
|
|
87
66
|
});
|
|
88
|
-
return
|
|
89
|
-
projectName: ctx.projectName,
|
|
90
|
-
targetDir: root,
|
|
91
|
-
type: ctx.type,
|
|
92
|
-
...ctx.db ? {
|
|
93
|
-
db: ctx.db,
|
|
94
|
-
driver: ctx.driver
|
|
95
|
-
} : {},
|
|
96
|
-
...ctx.logger ? { logger: ctx.logger } : {},
|
|
97
|
-
...ctx.validator ? { validator: ctx.validator } : {}
|
|
98
|
-
};
|
|
67
|
+
return ctx;
|
|
99
68
|
}
|
|
100
69
|
//#endregion
|
|
101
70
|
exports.scaffoldProject = scaffoldProject;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scaffold-engine.cjs","names":[],"sources":["../../../src/core/scaffold-engine.ts"],"sourcesContent":["import { copyFile, mkdir, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\n\nimport { collectBootBindings, resolveAddons } from \"../addons/registry.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"scaffold-engine.cjs","names":[],"sources":["../../../src/core/scaffold-engine.ts"],"sourcesContent":["import { copyFile, mkdir, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\n\nimport { collectBootBindings, resolveAddons } from \"../addons/registry.js\";\nimport { nitroConfigTemplate, taserTsTemplate, viteConfigTemplate } from \"../frameworks/index.js\";\nimport { installPackages, resolveUserAgent } from \"./package-manager.js\";\nimport { writeProjectConfig } from \"./project-config.js\";\nimport { resolvePackages } from \"./resolve-packages.js\";\nimport { resolveDeployEntry, validateCombination } from \"./targets.js\";\nimport { FRAMEWORK_ENTRIES } from \"../frameworks/index.js\";\nimport type { ScaffoldContext, ScaffoldOptions, ScaffoldResult } from \"./types.js\";\nimport {\n contextTemplate,\n gitignoreTemplate,\n healthRouteTemplate,\n indexRouteTemplate,\n packageJsonTemplate,\n rootLayoutTemplate,\n tsconfigTemplate,\n} from \"../templates/base.js\";\n\nasync function write(filePath: string, contents: string): Promise<void> {\n await mkdir(path.dirname(filePath), { recursive: true });\n await writeFile(filePath, contents, \"utf8\");\n}\n\nexport async function scaffoldProject(options: ScaffoldOptions): Promise<ScaffoldResult> {\n const root = options.targetDir;\n const preset = options.preset ?? \"node-server\";\n const framework = options.framework ?? \"none\";\n\n // Guards direct/library callers; the CLI path is validated earlier in\n // resolveScaffoldDefaults. Throws with a precise reason on impossible\n // runtime × framework × deploy combinations.\n const combination = validateCombination(options.runtime, framework, preset);\n if (!combination.ok) {\n throw new Error(combination.reason);\n }\n\n const ctx: ScaffoldContext = {\n projectName: options.projectName,\n targetDir: root,\n framework,\n preset,\n ...(options.runtime !== undefined ? { runtime: options.runtime } : {}),\n ...(options.db ? { db: options.db, driver: options.driver } : {}),\n ...(options.logger ? { logger: options.logger } : {}),\n ...(options.validator ? { validator: options.validator } : {}),\n };\n\n const addons = resolveAddons(ctx);\n const packages = resolvePackages(ctx);\n const bootBindings = collectBootBindings(ctx);\n const frameworkEntry = FRAMEWORK_ENTRIES[framework];\n const { entry: deployEntry } = resolveDeployEntry(ctx.preset ?? \"node-server\");\n\n await write(\n path.join(root, \"package.json\"),\n packageJsonTemplate(options.projectName, packages.scripts),\n );\n await write(path.join(root, \"tsconfig.json\"), tsconfigTemplate());\n await write(path.join(root, \"vite.config.ts\"), viteConfigTemplate());\n await write(path.join(root, \".gitignore\"), gitignoreTemplate());\n await write(path.join(root, \"src/context.ts\"), contextTemplate(bootBindings));\n await write(path.join(root, \"src/taser.ts\"), taserTsTemplate());\n await write(path.join(root, \"src/routes/$.ts\"), rootLayoutTemplate());\n await write(path.join(root, \"src/routes/index.get.ts\"), indexRouteTemplate());\n await write(path.join(root, \"src/routes/health.get.ts\"), healthRouteTemplate(ctx));\n\n // Nitro's default preset is node-server — only emit an explicit config when\n // the deployment target differs.\n if (ctx.preset !== \"node-server\") {\n await write(path.join(root, \"nitro.config.ts\"), nitroConfigTemplate(deployEntry.id));\n }\n\n await Promise.all(\n deployEntry.files.map((file) =>\n write(\n path.join(root, file.name),\n typeof file.content === \"function\"\n ? file.content({ projectName: options.projectName })\n : file.content,\n ),\n ),\n );\n\n const serverEntry = frameworkEntry.serverEntry;\n if (serverEntry) {\n await write(path.join(root, serverEntry.fileName), serverEntry.content);\n }\n\n await Promise.all(\n addons.map(async (addon) => {\n await addon.apply(ctx, (filePath, contents) => write(path.join(root, filePath), contents));\n }),\n );\n\n try {\n await copyFile(path.join(root, \".env.example\"), path.join(root, \".env\"));\n } catch {\n // .env.example was not created\n }\n\n await writeProjectConfig(root, ctx);\n\n if (options.skipInstall) {\n return ctx as ScaffoldResult;\n }\n\n const agent = options.agent ?? resolveUserAgent();\n await installPackages(agent, root, {\n dependencies: packages.dependencies,\n devDependencies: packages.devDependencies,\n });\n\n return ctx as ScaffoldResult;\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
const require_types = require("./types.cjs");
|
|
2
|
+
//#region src/core/targets.ts
|
|
3
|
+
/**
|
|
4
|
+
* Registry for the three scaffold dimensions — runtime, framework, deploy —
|
|
5
|
+
* plus the compatibility rules between them.
|
|
6
|
+
*
|
|
7
|
+
* Dependency direction: deploy implies the runtime family; the effective
|
|
8
|
+
* runtime constrains which frameworks can run. `--runtime` is an override
|
|
9
|
+
* available only where it is meaningful (self-hosted node-family targets).
|
|
10
|
+
*/
|
|
11
|
+
var NODE_START = "node .output/server/index.mjs";
|
|
12
|
+
var DEPLOY_ENTRIES = {
|
|
13
|
+
"node-server": {
|
|
14
|
+
id: "node-server",
|
|
15
|
+
impliedRuntime: "node",
|
|
16
|
+
selfHosted: true,
|
|
17
|
+
startScript: NODE_START,
|
|
18
|
+
devDeps: [],
|
|
19
|
+
files: []
|
|
20
|
+
},
|
|
21
|
+
"node-cluster": {
|
|
22
|
+
id: "node-cluster",
|
|
23
|
+
impliedRuntime: "node",
|
|
24
|
+
selfHosted: true,
|
|
25
|
+
startScript: NODE_START,
|
|
26
|
+
devDeps: [],
|
|
27
|
+
files: []
|
|
28
|
+
},
|
|
29
|
+
bun: {
|
|
30
|
+
id: "bun",
|
|
31
|
+
impliedRuntime: "bun",
|
|
32
|
+
selfHosted: true,
|
|
33
|
+
startScript: "bun .output/server/index.mjs",
|
|
34
|
+
devDeps: ["@types/bun"],
|
|
35
|
+
files: []
|
|
36
|
+
},
|
|
37
|
+
"deno-server": {
|
|
38
|
+
id: "deno-server",
|
|
39
|
+
impliedRuntime: "deno",
|
|
40
|
+
selfHosted: true,
|
|
41
|
+
startScript: "deno run -A .output/server/index.mjs",
|
|
42
|
+
devDeps: [],
|
|
43
|
+
files: []
|
|
44
|
+
},
|
|
45
|
+
"deno-deploy": {
|
|
46
|
+
id: "deno-deploy",
|
|
47
|
+
impliedRuntime: "deno",
|
|
48
|
+
selfHosted: false,
|
|
49
|
+
startScript: null,
|
|
50
|
+
devDeps: [],
|
|
51
|
+
files: []
|
|
52
|
+
},
|
|
53
|
+
"cloudflare-module": {
|
|
54
|
+
id: "cloudflare-module",
|
|
55
|
+
impliedRuntime: "workerd",
|
|
56
|
+
selfHosted: false,
|
|
57
|
+
startScript: null,
|
|
58
|
+
devDeps: ["wrangler", "@cloudflare/workers-types"],
|
|
59
|
+
files: [{
|
|
60
|
+
name: "wrangler.jsonc",
|
|
61
|
+
content: ({ projectName }) => `${JSON.stringify({
|
|
62
|
+
$schema: "node_modules/wrangler/config-schema.json",
|
|
63
|
+
name: projectName,
|
|
64
|
+
main: ".output/server/index.mjs",
|
|
65
|
+
compatibility_date: "2024-11-01"
|
|
66
|
+
}, null, 2)}\n`
|
|
67
|
+
}]
|
|
68
|
+
},
|
|
69
|
+
vercel: {
|
|
70
|
+
id: "vercel",
|
|
71
|
+
impliedRuntime: "node",
|
|
72
|
+
selfHosted: false,
|
|
73
|
+
startScript: null,
|
|
74
|
+
devDeps: ["@vercel/node"],
|
|
75
|
+
files: []
|
|
76
|
+
},
|
|
77
|
+
"aws-lambda": {
|
|
78
|
+
id: "aws-lambda",
|
|
79
|
+
impliedRuntime: "node",
|
|
80
|
+
selfHosted: false,
|
|
81
|
+
startScript: null,
|
|
82
|
+
devDeps: ["@types/aws-lambda"],
|
|
83
|
+
files: []
|
|
84
|
+
},
|
|
85
|
+
netlify: {
|
|
86
|
+
id: "netlify",
|
|
87
|
+
impliedRuntime: "node",
|
|
88
|
+
selfHosted: false,
|
|
89
|
+
startScript: null,
|
|
90
|
+
devDeps: [],
|
|
91
|
+
files: []
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
/** Runtimes a `--runtime` override may select per self-hosted deploy target. */
|
|
95
|
+
var RUNTIME_OVERRIDES = {
|
|
96
|
+
"node-server": ["node", "bun"],
|
|
97
|
+
"node-cluster": ["node", "bun"]
|
|
98
|
+
};
|
|
99
|
+
var DEFAULT_DEPLOY = "node-server";
|
|
100
|
+
function isCuratedDeploy(value) {
|
|
101
|
+
return require_types.DEPLOY_TARGETS.includes(value);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Resolves any preset id to its emission entry. Curated ids come from the
|
|
105
|
+
* registry; unknown strings pass through to Nitro verbatim as non-self-hosted
|
|
106
|
+
* node-family targets.
|
|
107
|
+
*/
|
|
108
|
+
function resolveDeployEntry(id) {
|
|
109
|
+
if (isCuratedDeploy(id)) return {
|
|
110
|
+
entry: DEPLOY_ENTRIES[id],
|
|
111
|
+
curated: true
|
|
112
|
+
};
|
|
113
|
+
return {
|
|
114
|
+
entry: {
|
|
115
|
+
id,
|
|
116
|
+
impliedRuntime: "node",
|
|
117
|
+
selfHosted: false,
|
|
118
|
+
startScript: null,
|
|
119
|
+
devDeps: [],
|
|
120
|
+
files: []
|
|
121
|
+
},
|
|
122
|
+
curated: false
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
/** Runtime overrides permitted for a deploy target; empty = no override. */
|
|
126
|
+
function allowedRuntimeOverrides(id) {
|
|
127
|
+
return RUNTIME_OVERRIDES[id] ?? [];
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Validates a runtime × framework × deploy combination.
|
|
131
|
+
*
|
|
132
|
+
* @param runtimeOverride explicit `--runtime` selection, if any
|
|
133
|
+
* @param deploy preset id (curated or passthrough)
|
|
134
|
+
*/
|
|
135
|
+
function validateCombination(runtimeOverride, framework, deploy) {
|
|
136
|
+
const { entry } = resolveDeployEntry(deploy);
|
|
137
|
+
if (runtimeOverride !== void 0) {
|
|
138
|
+
const allowed = entry.selfHosted ? allowedRuntimeOverrides(entry.id) : [];
|
|
139
|
+
if (!allowed.includes(runtimeOverride)) return {
|
|
140
|
+
ok: false,
|
|
141
|
+
reason: `Runtime "${runtimeOverride}" is not valid for deploy target "${entry.id}". ` + (allowed.length > 0 ? `Allowed overrides: ${allowed.join(", ")}.` : `It implies runtime "${String(entry.impliedRuntime)}".`)
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
const effective = runtimeOverride ?? entry.impliedRuntime;
|
|
145
|
+
if ((framework === "express" || framework === "fastify") && effective !== "node") return {
|
|
146
|
+
ok: false,
|
|
147
|
+
reason: `Framework "${framework}" requires the Node runtime, but deploy target "${entry.id}" implies "${String(effective)}".`
|
|
148
|
+
};
|
|
149
|
+
return {
|
|
150
|
+
ok: true,
|
|
151
|
+
runtime: effective
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
//#endregion
|
|
155
|
+
exports.DEFAULT_DEPLOY = DEFAULT_DEPLOY;
|
|
156
|
+
exports.DEPLOY_ENTRIES = DEPLOY_ENTRIES;
|
|
157
|
+
exports.allowedRuntimeOverrides = allowedRuntimeOverrides;
|
|
158
|
+
exports.isCuratedDeploy = isCuratedDeploy;
|
|
159
|
+
exports.resolveDeployEntry = resolveDeployEntry;
|
|
160
|
+
exports.validateCombination = validateCombination;
|
|
161
|
+
|
|
162
|
+
//# sourceMappingURL=targets.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"targets.cjs","names":[],"sources":["../../../src/core/targets.ts"],"sourcesContent":["/**\n * Registry for the three scaffold dimensions — runtime, framework, deploy —\n * plus the compatibility rules between them.\n *\n * Dependency direction: deploy implies the runtime family; the effective\n * runtime constrains which frameworks can run. `--runtime` is an override\n * available only where it is meaningful (self-hosted node-family targets).\n */\nimport { DEPLOY_TARGETS, type DeployTarget, type Framework, type Runtime } from \"./types.js\";\n\nexport type PlatformFile = {\n name: string;\n content: string | ((ctx: { projectName: string }) => string);\n};\n\nexport type DeployEntry = {\n id: DeployTarget;\n /** Runtime this target builds for (\"workerd\" = Cloudflare's V8 runtime). */\n impliedRuntime: Runtime | \"workerd\";\n /** Whether the built output is a long-running server you start locally. */\n selfHosted: boolean;\n /** `start` script value; null for platform-deployed targets. */\n startScript: string | null;\n /** Runtime/platform tooling devDependencies beyond the base set. */\n devDeps: string[];\n files: PlatformFile[];\n};\n\nconst NODE_START = \"node .output/server/index.mjs\";\n\nexport const DEPLOY_ENTRIES: Record<DeployTarget, DeployEntry> = {\n \"node-server\": {\n id: \"node-server\",\n impliedRuntime: \"node\",\n selfHosted: true,\n startScript: NODE_START,\n devDeps: [],\n files: [],\n },\n \"node-cluster\": {\n id: \"node-cluster\",\n impliedRuntime: \"node\",\n selfHosted: true,\n startScript: NODE_START,\n devDeps: [],\n files: [],\n },\n bun: {\n id: \"bun\",\n impliedRuntime: \"bun\",\n selfHosted: true,\n startScript: \"bun .output/server/index.mjs\",\n devDeps: [\"@types/bun\"],\n files: [],\n },\n \"deno-server\": {\n id: \"deno-server\",\n impliedRuntime: \"deno\",\n selfHosted: true,\n startScript: \"deno run -A .output/server/index.mjs\",\n devDeps: [],\n files: [],\n },\n \"deno-deploy\": {\n id: \"deno-deploy\",\n impliedRuntime: \"deno\",\n selfHosted: false,\n startScript: null,\n devDeps: [],\n files: [],\n },\n \"cloudflare-module\": {\n id: \"cloudflare-module\",\n impliedRuntime: \"workerd\",\n selfHosted: false,\n startScript: null,\n devDeps: [\"wrangler\", \"@cloudflare/workers-types\"],\n files: [\n {\n name: \"wrangler.jsonc\",\n content: ({ projectName }) =>\n `${JSON.stringify(\n {\n $schema: \"node_modules/wrangler/config-schema.json\",\n name: projectName,\n main: \".output/server/index.mjs\",\n compatibility_date: \"2024-11-01\",\n },\n null,\n 2,\n )}\\n`,\n },\n ],\n },\n vercel: {\n id: \"vercel\",\n impliedRuntime: \"node\",\n selfHosted: false,\n startScript: null,\n devDeps: [\"@vercel/node\"],\n files: [],\n },\n \"aws-lambda\": {\n id: \"aws-lambda\",\n impliedRuntime: \"node\",\n selfHosted: false,\n startScript: null,\n devDeps: [\"@types/aws-lambda\"],\n files: [],\n },\n netlify: {\n id: \"netlify\",\n impliedRuntime: \"node\",\n selfHosted: false,\n startScript: null,\n devDeps: [],\n files: [],\n },\n};\n\n/** Runtimes a `--runtime` override may select per self-hosted deploy target. */\nconst RUNTIME_OVERRIDES: Partial<Record<DeployTarget, readonly Runtime[]>> = {\n \"node-server\": [\"node\", \"bun\"],\n \"node-cluster\": [\"node\", \"bun\"],\n};\n\nexport const DEFAULT_DEPLOY: DeployTarget = \"node-server\";\nexport const DEFAULT_FRAMEWORK: Framework = \"none\";\n\nexport function isCuratedDeploy(value: string): value is DeployTarget {\n return (DEPLOY_TARGETS as readonly string[]).includes(value);\n}\n\n/**\n * Resolves any preset id to its emission entry. Curated ids come from the\n * registry; unknown strings pass through to Nitro verbatim as non-self-hosted\n * node-family targets.\n */\nexport function resolveDeployEntry(id: string): { entry: DeployEntry; curated: boolean } {\n if (isCuratedDeploy(id)) {\n return { entry: DEPLOY_ENTRIES[id], curated: true };\n }\n return {\n entry: {\n // Cast: passthrough ids are valid Nitro PresetNameInputs by contract.\n id: id as DeployTarget,\n impliedRuntime: \"node\",\n selfHosted: false,\n startScript: null,\n devDeps: [],\n files: [],\n },\n curated: false,\n };\n}\n\n/** Runtime overrides permitted for a deploy target; empty = no override. */\nexport function allowedRuntimeOverrides(id: DeployTarget): readonly Runtime[] {\n return RUNTIME_OVERRIDES[id] ?? [];\n}\n\nexport type CombinationError = { ok: false; reason: string };\nexport type CombinationOk = { ok: true; runtime: Runtime | \"workerd\" };\n\n/**\n * Validates a runtime × framework × deploy combination.\n *\n * @param runtimeOverride explicit `--runtime` selection, if any\n * @param deploy preset id (curated or passthrough)\n */\nexport function validateCombination(\n runtimeOverride: Runtime | undefined,\n framework: Framework,\n deploy: string,\n): CombinationOk | CombinationError {\n const { entry } = resolveDeployEntry(deploy);\n\n if (runtimeOverride !== undefined) {\n const allowed = entry.selfHosted ? allowedRuntimeOverrides(entry.id) : [];\n if (!allowed.includes(runtimeOverride)) {\n return {\n ok: false,\n reason:\n `Runtime \"${runtimeOverride}\" is not valid for deploy target \"${entry.id}\". ` +\n (allowed.length > 0\n ? `Allowed overrides: ${allowed.join(\", \")}.`\n : `It implies runtime \"${String(entry.impliedRuntime)}\".`),\n };\n }\n }\n\n const effective = runtimeOverride ?? entry.impliedRuntime;\n\n if ((framework === \"express\" || framework === \"fastify\") && effective !== \"node\") {\n return {\n ok: false,\n reason: `Framework \"${framework}\" requires the Node runtime, but deploy target \"${entry.id}\" implies \"${String(effective)}\".`,\n };\n }\n\n return { ok: true, runtime: effective };\n}\n"],"mappings":";;;;;;;;;;AA4BA,IAAM,aAAa;AAEnB,IAAa,iBAAoD;CAC/D,eAAe;EACb,IAAI;EACJ,gBAAgB;EAChB,YAAY;EACZ,aAAa;EACb,SAAS,CAAC;EACV,OAAO,CAAC;CACV;CACA,gBAAgB;EACd,IAAI;EACJ,gBAAgB;EAChB,YAAY;EACZ,aAAa;EACb,SAAS,CAAC;EACV,OAAO,CAAC;CACV;CACA,KAAK;EACH,IAAI;EACJ,gBAAgB;EAChB,YAAY;EACZ,aAAa;EACb,SAAS,CAAC,YAAY;EACtB,OAAO,CAAC;CACV;CACA,eAAe;EACb,IAAI;EACJ,gBAAgB;EAChB,YAAY;EACZ,aAAa;EACb,SAAS,CAAC;EACV,OAAO,CAAC;CACV;CACA,eAAe;EACb,IAAI;EACJ,gBAAgB;EAChB,YAAY;EACZ,aAAa;EACb,SAAS,CAAC;EACV,OAAO,CAAC;CACV;CACA,qBAAqB;EACnB,IAAI;EACJ,gBAAgB;EAChB,YAAY;EACZ,aAAa;EACb,SAAS,CAAC,YAAY,2BAA2B;EACjD,OAAO,CACL;GACE,MAAM;GACN,UAAU,EAAE,kBACV,GAAG,KAAK,UACN;IACE,SAAS;IACT,MAAM;IACN,MAAM;IACN,oBAAoB;GACtB,GACA,MACA,CACF,EAAE;EACN,CACF;CACF;CACA,QAAQ;EACN,IAAI;EACJ,gBAAgB;EAChB,YAAY;EACZ,aAAa;EACb,SAAS,CAAC,cAAc;EACxB,OAAO,CAAC;CACV;CACA,cAAc;EACZ,IAAI;EACJ,gBAAgB;EAChB,YAAY;EACZ,aAAa;EACb,SAAS,CAAC,mBAAmB;EAC7B,OAAO,CAAC;CACV;CACA,SAAS;EACP,IAAI;EACJ,gBAAgB;EAChB,YAAY;EACZ,aAAa;EACb,SAAS,CAAC;EACV,OAAO,CAAC;CACV;AACF;;AAGA,IAAM,oBAAuE;CAC3E,eAAe,CAAC,QAAQ,KAAK;CAC7B,gBAAgB,CAAC,QAAQ,KAAK;AAChC;AAEA,IAAa,iBAA+B;AAG5C,SAAgB,gBAAgB,OAAsC;CACpE,OAAQ,cAAA,eAAqC,SAAS,KAAK;AAC7D;;;;;;AAOA,SAAgB,mBAAmB,IAAsD;CACvF,IAAI,gBAAgB,EAAE,GACpB,OAAO;EAAE,OAAO,eAAe;EAAK,SAAS;CAAK;CAEpD,OAAO;EACL,OAAO;GAED;GACJ,gBAAgB;GAChB,YAAY;GACZ,aAAa;GACb,SAAS,CAAC;GACV,OAAO,CAAC;EACV;EACA,SAAS;CACX;AACF;;AAGA,SAAgB,wBAAwB,IAAsC;CAC5E,OAAO,kBAAkB,OAAO,CAAC;AACnC;;;;;;;AAWA,SAAgB,oBACd,iBACA,WACA,QACkC;CAClC,MAAM,EAAE,UAAU,mBAAmB,MAAM;CAE3C,IAAI,oBAAoB,KAAA,GAAW;EACjC,MAAM,UAAU,MAAM,aAAa,wBAAwB,MAAM,EAAE,IAAI,CAAC;EACxE,IAAI,CAAC,QAAQ,SAAS,eAAe,GACnC,OAAO;GACL,IAAI;GACJ,QACE,YAAY,gBAAgB,oCAAoC,MAAM,GAAG,QACxE,QAAQ,SAAS,IACd,sBAAsB,QAAQ,KAAK,IAAI,EAAE,KACzC,uBAAuB,OAAO,MAAM,cAAc,EAAE;EAC5D;CAEJ;CAEA,MAAM,YAAY,mBAAmB,MAAM;CAE3C,KAAK,cAAc,aAAa,cAAc,cAAc,cAAc,QACxE,OAAO;EACL,IAAI;EACJ,QAAQ,cAAc,UAAU,kDAAkD,MAAM,GAAG,aAAa,OAAO,SAAS,EAAE;CAC5H;CAGF,OAAO;EAAE,IAAI;EAAM,SAAS;CAAU;AACxC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { DeployTarget, Framework, Runtime } from './types.js';
|
|
2
|
+
export type PlatformFile = {
|
|
3
|
+
name: string;
|
|
4
|
+
content: string | ((ctx: {
|
|
5
|
+
projectName: string;
|
|
6
|
+
}) => string);
|
|
7
|
+
};
|
|
8
|
+
export type DeployEntry = {
|
|
9
|
+
id: DeployTarget;
|
|
10
|
+
/** Runtime this target builds for ("workerd" = Cloudflare's V8 runtime). */
|
|
11
|
+
impliedRuntime: Runtime | "workerd";
|
|
12
|
+
/** Whether the built output is a long-running server you start locally. */
|
|
13
|
+
selfHosted: boolean;
|
|
14
|
+
/** `start` script value; null for platform-deployed targets. */
|
|
15
|
+
startScript: string | null;
|
|
16
|
+
/** Runtime/platform tooling devDependencies beyond the base set. */
|
|
17
|
+
devDeps: string[];
|
|
18
|
+
files: PlatformFile[];
|
|
19
|
+
};
|
|
20
|
+
export declare const DEPLOY_ENTRIES: Record<DeployTarget, DeployEntry>;
|
|
21
|
+
export declare const DEFAULT_DEPLOY: DeployTarget;
|
|
22
|
+
export declare const DEFAULT_FRAMEWORK: Framework;
|
|
23
|
+
export declare function isCuratedDeploy(value: string): value is DeployTarget;
|
|
24
|
+
/**
|
|
25
|
+
* Resolves any preset id to its emission entry. Curated ids come from the
|
|
26
|
+
* registry; unknown strings pass through to Nitro verbatim as non-self-hosted
|
|
27
|
+
* node-family targets.
|
|
28
|
+
*/
|
|
29
|
+
export declare function resolveDeployEntry(id: string): {
|
|
30
|
+
entry: DeployEntry;
|
|
31
|
+
curated: boolean;
|
|
32
|
+
};
|
|
33
|
+
/** Runtime overrides permitted for a deploy target; empty = no override. */
|
|
34
|
+
export declare function allowedRuntimeOverrides(id: DeployTarget): readonly Runtime[];
|
|
35
|
+
export type CombinationError = {
|
|
36
|
+
ok: false;
|
|
37
|
+
reason: string;
|
|
38
|
+
};
|
|
39
|
+
export type CombinationOk = {
|
|
40
|
+
ok: true;
|
|
41
|
+
runtime: Runtime | "workerd";
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Validates a runtime × framework × deploy combination.
|
|
45
|
+
*
|
|
46
|
+
* @param runtimeOverride explicit `--runtime` selection, if any
|
|
47
|
+
* @param deploy preset id (curated or passthrough)
|
|
48
|
+
*/
|
|
49
|
+
export declare function validateCombination(runtimeOverride: Runtime | undefined, framework: Framework, deploy: string): CombinationOk | CombinationError;
|
package/dist/cjs/core/types.cjs
CHANGED
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
//#region src/core/types.ts
|
|
2
|
-
var
|
|
3
|
-
"
|
|
4
|
-
"express",
|
|
5
|
-
"fastify",
|
|
2
|
+
var FRAMEWORKS = [
|
|
3
|
+
"none",
|
|
6
4
|
"hono",
|
|
5
|
+
"express",
|
|
6
|
+
"fastify"
|
|
7
|
+
];
|
|
8
|
+
var RUNTIMES = [
|
|
9
|
+
"node",
|
|
7
10
|
"bun",
|
|
8
|
-
"deno"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"
|
|
11
|
+
"deno"
|
|
12
|
+
];
|
|
13
|
+
var DEPLOY_TARGETS = [
|
|
14
|
+
"node-server",
|
|
15
|
+
"node-cluster",
|
|
16
|
+
"bun",
|
|
17
|
+
"deno-server",
|
|
18
|
+
"deno-deploy",
|
|
19
|
+
"cloudflare-module",
|
|
12
20
|
"vercel",
|
|
13
|
-
"
|
|
14
|
-
"
|
|
21
|
+
"aws-lambda",
|
|
22
|
+
"netlify"
|
|
15
23
|
];
|
|
16
24
|
var DB_ODMS = [
|
|
17
25
|
"drizzle",
|
|
@@ -34,8 +42,10 @@ var VALIDATORS = [
|
|
|
34
42
|
exports.DB_DRIVERS = DB_DRIVERS;
|
|
35
43
|
exports.DB_ODMS = DB_ODMS;
|
|
36
44
|
exports.DEFAULT_DB_DRIVER = DEFAULT_DB_DRIVER;
|
|
45
|
+
exports.DEPLOY_TARGETS = DEPLOY_TARGETS;
|
|
46
|
+
exports.FRAMEWORKS = FRAMEWORKS;
|
|
37
47
|
exports.LOGGERS = LOGGERS;
|
|
38
|
-
exports.
|
|
48
|
+
exports.RUNTIMES = RUNTIMES;
|
|
39
49
|
exports.VALIDATORS = VALIDATORS;
|
|
40
50
|
|
|
41
51
|
//# sourceMappingURL=types.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.cjs","names":[],"sources":["../../../src/core/types.ts"],"sourcesContent":["import type { Agent } from \"package-manager-detector\";\n\nexport type
|
|
1
|
+
{"version":3,"file":"types.cjs","names":[],"sources":["../../../src/core/types.ts"],"sourcesContent":["import type { Agent } from \"package-manager-detector\";\n\n/** Host framework layered on top of pure Taser pass-through dispatch. */\nexport type Framework = \"none\" | \"hono\" | \"express\" | \"fastify\";\n\nexport const FRAMEWORKS: readonly Framework[] = [\"none\", \"hono\", \"express\", \"fastify\"];\n\nexport type Runtime = \"node\" | \"bun\" | \"deno\";\n\nexport const RUNTIMES: readonly Runtime[] = [\"node\", \"bun\", \"deno\"];\n\n/**\n * Deployment target. Values are Nitro preset ids (see `nitro/config`\n * PresetNameInput) so `--preset` passes straight through to Nitro.\n */\nexport type DeployTarget =\n | \"node-server\"\n | \"node-cluster\"\n | \"bun\"\n | \"deno-server\"\n | \"deno-deploy\"\n | \"cloudflare-module\"\n | \"vercel\"\n | \"aws-lambda\"\n | \"netlify\";\n\nexport const DEPLOY_TARGETS: readonly DeployTarget[] = [\n \"node-server\",\n \"node-cluster\",\n \"bun\",\n \"deno-server\",\n \"deno-deploy\",\n \"cloudflare-module\",\n \"vercel\",\n \"aws-lambda\",\n \"netlify\",\n];\n\nexport type DbOdm = \"drizzle\" | \"prisma\" | \"kysely\";\n\nexport const DB_ODMS: readonly DbOdm[] = [\"drizzle\", \"prisma\", \"kysely\"];\n\nexport type DbDriver = \"postgres\" | \"sqlite\" | \"mysql\";\n\nexport const DB_DRIVERS: readonly DbDriver[] = [\"postgres\", \"sqlite\", \"mysql\"];\n\nexport const DEFAULT_DB_DRIVER: DbDriver = \"sqlite\";\n\nexport type LoggerId = \"pino\" | \"winston\";\n\nexport const LOGGERS: readonly LoggerId[] = [\"pino\", \"winston\"];\n\nexport type ValidatorId = \"zod\" | \"arktype\" | \"valibot\";\n\nexport const VALIDATORS: readonly ValidatorId[] = [\"zod\", \"arktype\", \"valibot\"];\n\nexport type PackageGroups = {\n dependencies: string[];\n devDependencies: string[];\n scripts: Record<string, string>;\n};\n\nexport type ScaffoldContext = {\n projectName: string;\n targetDir: string;\n /** Host framework; \"none\" is pure Taser pass-through dispatch. Defaults to \"none\". */\n framework?: Framework;\n /** Deployment target — a Nitro preset id. Defaults to \"node-server\". */\n preset?: DeployTarget;\n /** Set only when explicitly overriding the runtime implied by the preset. */\n runtime?: Runtime;\n db?: DbOdm;\n driver?: DbDriver;\n logger?: LoggerId;\n validator?: ValidatorId;\n};\n\nexport type ScaffoldOptions = ScaffoldContext & {\n skipInstall?: boolean;\n agent?: Agent;\n};\n\nexport type ScaffoldResult = ScaffoldContext;\n\nexport type CapabilitiesCatalog = {\n frameworks: Framework[];\n deployTargets: DeployTarget[];\n runtimes: Runtime[];\n db: {\n odms: DbOdm[];\n drivers: DbDriver[];\n defaultDriver: DbDriver;\n };\n loggers: LoggerId[];\n validators: ValidatorId[];\n};\n"],"mappings":";AAKA,IAAa,aAAmC;CAAC;CAAQ;CAAQ;CAAW;AAAS;AAIrF,IAAa,WAA+B;CAAC;CAAQ;CAAO;AAAM;AAiBlE,IAAa,iBAA0C;CACrD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAIA,IAAa,UAA4B;CAAC;CAAW;CAAU;AAAQ;AAIvE,IAAa,aAAkC;CAAC;CAAY;CAAU;AAAO;AAE7E,IAAa,oBAA8B;AAI3C,IAAa,UAA+B,CAAC,QAAQ,SAAS;AAI9D,IAAa,aAAqC;CAAC;CAAO;CAAW;AAAS"}
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { Agent } from 'package-manager-detector';
|
|
2
|
-
|
|
3
|
-
export
|
|
2
|
+
/** Host framework layered on top of pure Taser pass-through dispatch. */
|
|
3
|
+
export type Framework = "none" | "hono" | "express" | "fastify";
|
|
4
|
+
export declare const FRAMEWORKS: readonly Framework[];
|
|
5
|
+
export type Runtime = "node" | "bun" | "deno";
|
|
6
|
+
export declare const RUNTIMES: readonly Runtime[];
|
|
7
|
+
/**
|
|
8
|
+
* Deployment target. Values are Nitro preset ids (see `nitro/config`
|
|
9
|
+
* PresetNameInput) so `--preset` passes straight through to Nitro.
|
|
10
|
+
*/
|
|
11
|
+
export type DeployTarget = "node-server" | "node-cluster" | "bun" | "deno-server" | "deno-deploy" | "cloudflare-module" | "vercel" | "aws-lambda" | "netlify";
|
|
12
|
+
export declare const DEPLOY_TARGETS: readonly DeployTarget[];
|
|
4
13
|
export type DbOdm = "drizzle" | "prisma" | "kysely";
|
|
5
14
|
export declare const DB_ODMS: readonly DbOdm[];
|
|
6
15
|
export type DbDriver = "postgres" | "sqlite" | "mysql";
|
|
@@ -18,7 +27,12 @@ export type PackageGroups = {
|
|
|
18
27
|
export type ScaffoldContext = {
|
|
19
28
|
projectName: string;
|
|
20
29
|
targetDir: string;
|
|
21
|
-
|
|
30
|
+
/** Host framework; "none" is pure Taser pass-through dispatch. Defaults to "none". */
|
|
31
|
+
framework?: Framework;
|
|
32
|
+
/** Deployment target — a Nitro preset id. Defaults to "node-server". */
|
|
33
|
+
preset?: DeployTarget;
|
|
34
|
+
/** Set only when explicitly overriding the runtime implied by the preset. */
|
|
35
|
+
runtime?: Runtime;
|
|
22
36
|
db?: DbOdm;
|
|
23
37
|
driver?: DbDriver;
|
|
24
38
|
logger?: LoggerId;
|
|
@@ -30,7 +44,9 @@ export type ScaffoldOptions = ScaffoldContext & {
|
|
|
30
44
|
};
|
|
31
45
|
export type ScaffoldResult = ScaffoldContext;
|
|
32
46
|
export type CapabilitiesCatalog = {
|
|
33
|
-
|
|
47
|
+
frameworks: Framework[];
|
|
48
|
+
deployTargets: DeployTarget[];
|
|
49
|
+
runtimes: Runtime[];
|
|
34
50
|
db: {
|
|
35
51
|
odms: DbOdm[];
|
|
36
52
|
drivers: DbDriver[];
|