create-taserjs 0.0.2 → 0.0.3
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 +2 -0
- package/dist/cjs/addons/arktype/index.cjs.map +1 -1
- package/dist/cjs/addons/drizzle/index.cjs.map +1 -1
- package/dist/cjs/addons/kysely/index.cjs.map +1 -1
- package/dist/cjs/addons/pino/index.cjs.map +1 -1
- package/dist/cjs/addons/prisma/index.cjs +84 -24
- package/dist/cjs/addons/prisma/index.cjs.map +1 -1
- package/dist/cjs/addons/registry.cjs +1 -1
- package/dist/cjs/addons/registry.cjs.map +1 -1
- package/dist/cjs/addons/types.d.cts +1 -1
- package/dist/cjs/addons/valibot/index.cjs.map +1 -1
- package/dist/cjs/addons/validators.cjs.map +1 -1
- package/dist/cjs/addons/winston/index.cjs.map +1 -1
- package/dist/cjs/addons/zod/index.cjs.map +1 -1
- package/dist/cjs/cli.cjs +5 -0
- package/dist/cjs/cli.cjs.map +1 -1
- package/dist/cjs/commands/create.cjs +44 -11
- package/dist/cjs/commands/create.cjs.map +1 -1
- package/dist/cjs/commands/create.d.cts +1 -0
- package/dist/cjs/core/json-output.cjs.map +1 -1
- package/dist/cjs/core/package-manager.cjs.map +1 -1
- package/dist/cjs/core/package-manager.d.cts +1 -1
- package/dist/cjs/core/parse-options.cjs +7 -7
- package/dist/cjs/core/parse-options.cjs.map +1 -1
- package/dist/cjs/core/parse-options.d.cts +3 -3
- package/dist/cjs/core/project-config.cjs +1 -1
- package/dist/cjs/core/project-config.cjs.map +1 -1
- package/dist/cjs/core/resolve-packages.cjs +41 -7
- package/dist/cjs/core/resolve-packages.cjs.map +1 -1
- package/dist/cjs/core/resolve-packages.d.cts +2 -2
- package/dist/cjs/core/scaffold-engine.cjs +33 -6
- package/dist/cjs/core/scaffold-engine.cjs.map +1 -1
- package/dist/cjs/core/types.cjs +11 -3
- package/dist/cjs/core/types.cjs.map +1 -1
- package/dist/cjs/core/types.d.cts +8 -8
- package/dist/cjs/core/validate-project-name.cjs.map +1 -1
- package/dist/cjs/frameworks/index.cjs +138 -17
- package/dist/cjs/frameworks/index.cjs.map +1 -1
- package/dist/cjs/frameworks/index.d.cts +3 -3
- package/dist/cjs/scaffold.d.cts +1 -1
- package/dist/cjs/templates/base.cjs +6 -6
- package/dist/cjs/templates/base.cjs.map +1 -1
- package/dist/cjs/types.d.cts +1 -1
- package/dist/esm/addons/arktype/index.js.map +1 -1
- package/dist/esm/addons/drizzle/index.js.map +1 -1
- package/dist/esm/addons/kysely/index.js.map +1 -1
- package/dist/esm/addons/pino/index.js.map +1 -1
- package/dist/esm/addons/prisma/index.js +84 -24
- package/dist/esm/addons/prisma/index.js.map +1 -1
- package/dist/esm/addons/registry.js +2 -2
- package/dist/esm/addons/registry.js.map +1 -1
- package/dist/esm/addons/types.d.ts +1 -1
- package/dist/esm/addons/valibot/index.js.map +1 -1
- package/dist/esm/addons/validators.js.map +1 -1
- package/dist/esm/addons/winston/index.js.map +1 -1
- package/dist/esm/addons/zod/index.js.map +1 -1
- package/dist/esm/cli.js +5 -0
- package/dist/esm/cli.js.map +1 -1
- package/dist/esm/commands/create.d.ts +1 -0
- package/dist/esm/commands/create.js +46 -13
- package/dist/esm/commands/create.js.map +1 -1
- package/dist/esm/core/json-output.js.map +1 -1
- package/dist/esm/core/package-manager.d.ts +1 -1
- package/dist/esm/core/package-manager.js.map +1 -1
- package/dist/esm/core/parse-options.d.ts +3 -3
- package/dist/esm/core/parse-options.js +8 -8
- package/dist/esm/core/parse-options.js.map +1 -1
- package/dist/esm/core/project-config.js +1 -1
- package/dist/esm/core/project-config.js.map +1 -1
- package/dist/esm/core/resolve-packages.d.ts +2 -2
- package/dist/esm/core/resolve-packages.js +41 -7
- package/dist/esm/core/resolve-packages.js.map +1 -1
- package/dist/esm/core/scaffold-engine.js +34 -7
- package/dist/esm/core/scaffold-engine.js.map +1 -1
- package/dist/esm/core/types.d.ts +8 -8
- package/dist/esm/core/types.js +11 -3
- package/dist/esm/core/types.js.map +1 -1
- package/dist/esm/core/validate-project-name.js.map +1 -1
- package/dist/esm/frameworks/index.d.ts +3 -3
- package/dist/esm/frameworks/index.js +138 -17
- package/dist/esm/frameworks/index.js.map +1 -1
- package/dist/esm/scaffold.d.ts +1 -1
- package/dist/esm/templates/base.js +6 -6
- package/dist/esm/templates/base.js.map +1 -1
- package/dist/esm/types.d.ts +1 -1
- package/package.json +13 -13
- package/src/addons/arktype/index.ts +2 -2
- package/src/addons/drizzle/index.ts +53 -53
- package/src/addons/kysely/index.ts +42 -42
- package/src/addons/pino/index.ts +12 -12
- package/src/addons/prisma/index.ts +128 -55
- package/src/addons/registry.ts +37 -37
- package/src/addons/types.ts +14 -14
- package/src/addons/valibot/index.ts +2 -2
- package/src/addons/validators.ts +9 -9
- package/src/addons/winston/index.ts +12 -12
- package/src/addons/zod/index.ts +2 -2
- package/src/cli.ts +27 -26
- package/src/commands/create.ts +181 -152
- package/src/core/json-output.ts +4 -4
- package/src/core/package-manager.ts +38 -31
- package/src/core/parse-options.ts +50 -48
- package/src/core/project-config.ts +10 -14
- package/src/core/resolve-packages.ts +79 -41
- package/src/core/scaffold-engine.ts +106 -36
- package/src/core/types.ts +61 -36
- package/src/core/validate-project-name.ts +40 -40
- package/src/frameworks/index.ts +164 -29
- package/src/scaffold.ts +3 -3
- package/src/templates/base.ts +57 -51
- package/src/types.ts +5 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scaffold-engine.js","names":[],"sources":["../../../src/core/scaffold-engine.ts"],"sourcesContent":["import { mkdir, writeFile } from
|
|
1
|
+
{"version":3,"file":"scaffold-engine.js","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 { indexTemplate, taserTsTemplate } from \"../frameworks/index.js\";\nimport { installPackages, resolveUserAgent } from \"./package-manager.js\";\nimport { writeProjectConfig } from \"./project-config.js\";\nimport { resolvePackages } from \"./resolve-packages.js\";\nimport type { ScaffoldOptions, ScaffoldResult } from \"./types.js\";\nimport {\n contextTemplate,\n gitignoreTemplate,\n healthRouteTemplate,\n indexRouteTemplate,\n packageJsonTemplate,\n rootLayoutTemplate,\n starterManifestTemplate,\n tsconfigTemplate,\n tsdownConfigTemplate,\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 ctx = {\n projectName: options.projectName,\n targetDir: root,\n type: options.type,\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\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, \"tsdown.config.ts\"), tsdownConfigTemplate());\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(options.type));\n await write(path.join(root, \"src/index.ts\"), indexTemplate(options.type));\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 await write(path.join(root, \"src/routeManifest.gen.ts\"), starterManifestTemplate());\n\n if (options.type === \"cloudflare-workers\") {\n await write(\n path.join(root, \"wrangler.jsonc\"),\n JSON.stringify(\n {\n $schema: \"node_modules/wrangler/config-schema.json\",\n name: options.projectName,\n main: \"src/index.ts\",\n compatibility_date: \"2024-11-01\",\n },\n null,\n 2,\n ) + \"\\n\",\n );\n }\n\n if (options.type === \"vercel\") {\n await write(\n path.join(root, \"vercel.json\"),\n JSON.stringify(\n {\n rewrites: [{ source: \"/(.*)\", destination: \"/src/index.ts\" }],\n },\n null,\n 2,\n ) + \"\\n\",\n );\n }\n\n if (options.type === \"azure-functions\") {\n await write(\n path.join(root, \"host.json\"),\n JSON.stringify(\n {\n version: \"2.0\",\n logging: {\n applicationInsights: {\n samplingSettings: {\n isEnabled: true,\n excludedTypes: \"Request\",\n },\n },\n },\n extensionBundle: {\n id: \"Microsoft.Azure.Functions.ExtensionBundle\",\n version: \"[4.*, 5.0.0)\",\n },\n extensions: {\n http: {\n routePrefix: \"\",\n },\n },\n },\n null,\n 2,\n ) + \"\\n\",\n );\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 {\n projectName: ctx.projectName,\n targetDir: root,\n type: ctx.type,\n ...(ctx.db ? { db: ctx.db, driver: ctx.driver } : {}),\n ...(ctx.logger ? { logger: ctx.logger } : {}),\n ...(ctx.validator ? { validator: ctx.validator } : {}),\n };\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 {\n projectName: ctx.projectName,\n targetDir: root,\n type: ctx.type,\n ...(ctx.db ? { db: ctx.db, driver: ctx.driver } : {}),\n ...(ctx.logger ? { logger: ctx.logger } : {}),\n ...(ctx.validator ? { validator: ctx.validator } : {}),\n };\n}\n"],"mappings":";;;;;;;;;AAqBA,eAAe,MAAM,UAAkB,UAAiC;CACtE,MAAM,MAAM,KAAK,QAAQ,QAAQ,GAA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I,UAAU,IAAI,CAAC;CACtD;CAGF,MAAM,QAAQ,QAAQ,SAAS,iBAAiB;CAChD,MAAM,gBAAgB,OAAO,MAAM;EACjC,cAAc,SAAS;EACvB,iBAAiB,SAAS;CAC5B,CAAC;CAED,OAAO;EACL,aAAa,IAAI;EACjB,WAAW;EACX,MAAM,IAAI;EACV,GAAI,IAAI,KAAK;GAAE,IAAI,IAAI;GAAI,QAAQ,IAAI;EAAO,IAAI,CAAC;EACnD,GAAI,IAAI,SAAS,EAAE,QAAQ,IAAI,OAAO,IAAI,CAAC;EAC3C,GAAI,IAAI,YAAY,EAAE,WAAW,IAAI,UAAU,IAAI,CAAC;CACtD;AACF"}
|
package/dist/esm/core/types.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { Agent } from 'package-manager-detector';
|
|
2
|
-
export type
|
|
3
|
-
export declare const
|
|
4
|
-
export type DbOdm =
|
|
2
|
+
export type ProjectType = "node" | "express" | "fastify" | "hono" | "bun" | "deno" | "aws-lambda" | "cloudflare-workers" | "netlify" | "vercel" | "azure-functions" | "google-cloud-run";
|
|
3
|
+
export declare const PROJECT_TYPES: readonly ProjectType[];
|
|
4
|
+
export type DbOdm = "drizzle" | "prisma" | "kysely";
|
|
5
5
|
export declare const DB_ODMS: readonly DbOdm[];
|
|
6
|
-
export type DbDriver =
|
|
6
|
+
export type DbDriver = "postgres" | "sqlite" | "mysql";
|
|
7
7
|
export declare const DB_DRIVERS: readonly DbDriver[];
|
|
8
8
|
export declare const DEFAULT_DB_DRIVER: DbDriver;
|
|
9
|
-
export type LoggerId =
|
|
9
|
+
export type LoggerId = "pino" | "winston";
|
|
10
10
|
export declare const LOGGERS: readonly LoggerId[];
|
|
11
|
-
export type ValidatorId =
|
|
11
|
+
export type ValidatorId = "zod" | "arktype" | "valibot";
|
|
12
12
|
export declare const VALIDATORS: readonly ValidatorId[];
|
|
13
13
|
export type PackageGroups = {
|
|
14
14
|
dependencies: string[];
|
|
@@ -18,7 +18,7 @@ export type PackageGroups = {
|
|
|
18
18
|
export type ScaffoldContext = {
|
|
19
19
|
projectName: string;
|
|
20
20
|
targetDir: string;
|
|
21
|
-
|
|
21
|
+
type: ProjectType;
|
|
22
22
|
db?: DbOdm;
|
|
23
23
|
driver?: DbDriver;
|
|
24
24
|
logger?: LoggerId;
|
|
@@ -30,7 +30,7 @@ export type ScaffoldOptions = ScaffoldContext & {
|
|
|
30
30
|
};
|
|
31
31
|
export type ScaffoldResult = ScaffoldContext;
|
|
32
32
|
export type CapabilitiesCatalog = {
|
|
33
|
-
|
|
33
|
+
types: ProjectType[];
|
|
34
34
|
db: {
|
|
35
35
|
odms: DbOdm[];
|
|
36
36
|
drivers: DbDriver[];
|
package/dist/esm/core/types.js
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
//#region src/core/types.ts
|
|
2
|
-
var
|
|
2
|
+
var PROJECT_TYPES = [
|
|
3
3
|
"node",
|
|
4
4
|
"express",
|
|
5
|
+
"fastify",
|
|
5
6
|
"hono",
|
|
6
|
-
"
|
|
7
|
+
"bun",
|
|
8
|
+
"deno",
|
|
9
|
+
"aws-lambda",
|
|
10
|
+
"cloudflare-workers",
|
|
11
|
+
"netlify",
|
|
12
|
+
"vercel",
|
|
13
|
+
"azure-functions",
|
|
14
|
+
"google-cloud-run"
|
|
7
15
|
];
|
|
8
16
|
var DB_ODMS = [
|
|
9
17
|
"drizzle",
|
|
@@ -23,6 +31,6 @@ var VALIDATORS = [
|
|
|
23
31
|
"valibot"
|
|
24
32
|
];
|
|
25
33
|
//#endregion
|
|
26
|
-
export { DB_DRIVERS, DB_ODMS, DEFAULT_DB_DRIVER,
|
|
34
|
+
export { DB_DRIVERS, DB_ODMS, DEFAULT_DB_DRIVER, LOGGERS, PROJECT_TYPES, VALIDATORS };
|
|
27
35
|
|
|
28
36
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../src/core/types.ts"],"sourcesContent":["import type { Agent } from
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../src/core/types.ts"],"sourcesContent":["import type { Agent } from \"package-manager-detector\";\n\nexport type ProjectType =\n | \"node\"\n | \"express\"\n | \"fastify\"\n | \"hono\"\n | \"bun\"\n | \"deno\"\n | \"aws-lambda\"\n | \"cloudflare-workers\"\n | \"netlify\"\n | \"vercel\"\n | \"azure-functions\"\n | \"google-cloud-run\";\n\nexport const PROJECT_TYPES: readonly ProjectType[] = [\n \"node\",\n \"express\",\n \"fastify\",\n \"hono\",\n \"bun\",\n \"deno\",\n \"aws-lambda\",\n \"cloudflare-workers\",\n \"netlify\",\n \"vercel\",\n \"azure-functions\",\n \"google-cloud-run\",\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 type: ProjectType;\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 types: ProjectType[];\n db: {\n odms: DbOdm[];\n drivers: DbDriver[];\n defaultDriver: DbDriver;\n };\n loggers: LoggerId[];\n validators: ValidatorId[];\n};\n"],"mappings":";AAgBA,IAAa,gBAAwC;CACnD;CACA;CACA;CACA;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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-project-name.js","names":[],"sources":["../../../src/core/validate-project-name.ts"],"sourcesContent":["import path from
|
|
1
|
+
{"version":3,"file":"validate-project-name.js","names":[],"sources":["../../../src/core/validate-project-name.ts"],"sourcesContent":["import path from \"node:path\";\n\nconst RESERVED_WINDOWS_NAMES = new Set([\n \"CON\",\n \"PRN\",\n \"AUX\",\n \"NVR\",\n \"NULL\",\n \"COM1\",\n \"COM2\",\n \"COM3\",\n \"COM4\",\n \"COM5\",\n \"COM6\",\n \"COM7\",\n \"COM8\",\n \"COM9\",\n \"LPT1\",\n \"LPT2\",\n \"LPT3\",\n \"LPT4\",\n \"LPT5\",\n \"LPT6\",\n \"LPT7\",\n \"LPT8\",\n \"LPT9\",\n]);\n\nexport function validateProjectName(name: string, cwd = process.cwd()): string | undefined {\n const trimmed = name.trim();\n if (!trimmed) {\n return \"Project name is required\";\n }\n\n if (trimmed.includes(\"..\")) {\n return 'Project name cannot contain \"..\"';\n }\n\n if (trimmed.includes(\"/\") || trimmed.includes(\"\\\\\")) {\n return \"Project name cannot contain path separators\";\n }\n\n if (trimmed.startsWith(\".\") || trimmed.endsWith(\".\")) {\n return \"Project name cannot start or end with a dot\";\n }\n\n const baseName = trimmed.split(\".\")[0]?.toUpperCase();\n if (baseName && RESERVED_WINDOWS_NAMES.has(baseName)) {\n return `Project name \"${trimmed}\" is reserved on Windows`;\n }\n\n const targetDir = path.resolve(cwd, trimmed);\n const relative = path.relative(cwd, targetDir);\n if (relative.startsWith(\"..\") || path.isAbsolute(relative)) {\n return \"Project name resolves outside the current directory\";\n }\n\n return undefined;\n}\n"],"mappings":";;AAEA,IAAM,yCAAyB,IAAI,IAAI;CACrC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAgB,oBAAoB,MAAc,MAAM,QAAQ,IAAI,GAAuB;CACzF,MAAM,UAAU,KAAK,KAAK;CAC1B,IAAI,CAAC,SACH,OAAO;CAGT,IAAI,QAAQ,SAAS,IAAI,GACvB,OAAO;CAGT,IAAI,QAAQ,SAAS,GAAG,KAAK,QAAQ,SAAS,IAAI,GAChD,OAAO;CAGT,IAAI,QAAQ,WAAW,GAAG,KAAK,QAAQ,SAAS,GAAG,GACjD,OAAO;CAGT,MAAM,WAAW,QAAQ,MAAM,GAAG,CAAC,CAAC,EAAE,EAAE,YAAY;CACpD,IAAI,YAAY,uBAAuB,IAAI,QAAQ,GACjD,OAAO,iBAAiB,QAAQ;CAGlC,MAAM,YAAY,KAAK,QAAQ,KAAK,OAAO;CAC3C,MAAM,WAAW,KAAK,SAAS,KAAK,SAAS;CAC7C,IAAI,SAAS,WAAW,IAAI,KAAK,KAAK,WAAW,QAAQ,GACvD,OAAO;AAIX"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function indexTemplate(
|
|
3
|
-
export declare function taserTsTemplate(
|
|
1
|
+
import { ProjectType } from '../core/types.js';
|
|
2
|
+
export declare function indexTemplate(type: ProjectType): string;
|
|
3
|
+
export declare function taserTsTemplate(type?: ProjectType): string;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
//#region src/frameworks/index.ts
|
|
2
|
-
function indexTemplate(
|
|
3
|
-
switch (
|
|
4
|
-
case "express": return `import
|
|
2
|
+
function indexTemplate(type) {
|
|
3
|
+
switch (type) {
|
|
4
|
+
case "express": return `import 'dotenv/config'
|
|
5
|
+
|
|
6
|
+
import express from 'express'
|
|
5
7
|
import { createExpressHandler } from '@taserjs/adapter-express'
|
|
6
8
|
|
|
7
9
|
import { routeManifest } from '#src/routeManifest.gen.js'
|
|
@@ -11,14 +13,16 @@ const router = t.create(routeManifest)
|
|
|
11
13
|
|
|
12
14
|
const taser = createExpressHandler(router)
|
|
13
15
|
const app = express()
|
|
14
|
-
taser.mount('/
|
|
16
|
+
taser.mount('/{*splat}', app)
|
|
15
17
|
|
|
16
18
|
const port = Number(process.env.PORT ?? 3000)
|
|
17
19
|
app.listen(port, () => {
|
|
18
20
|
console.log(\`Express listening on http://localhost:\${port}\`)
|
|
19
21
|
})
|
|
20
22
|
`;
|
|
21
|
-
case "hono": return `import
|
|
23
|
+
case "hono": return `import 'dotenv/config'
|
|
24
|
+
|
|
25
|
+
import { serve } from '@hono/node-server'
|
|
22
26
|
import { Hono } from 'hono'
|
|
23
27
|
|
|
24
28
|
import { routeManifest } from '#src/routeManifest.gen.js'
|
|
@@ -27,15 +31,16 @@ import { t } from '#src/taser.js'
|
|
|
27
31
|
const router = t.create(routeManifest)
|
|
28
32
|
|
|
29
33
|
const app = new Hono()
|
|
30
|
-
|
|
31
|
-
app.all('/api/*', c => api.native(c).fetch(c.req.raw))
|
|
34
|
+
app.all('/*', c => router.native(c).fetch(c.req.raw))
|
|
32
35
|
|
|
33
36
|
const port = Number(process.env.PORT ?? 3000)
|
|
34
37
|
serve({ fetch: app.fetch, port }, () => {
|
|
35
38
|
console.log(\`Hono listening on http://localhost:\${port}\`)
|
|
36
39
|
})
|
|
37
40
|
`;
|
|
38
|
-
case "fastify": return `import
|
|
41
|
+
case "fastify": return `import 'dotenv/config'
|
|
42
|
+
|
|
43
|
+
import Fastify from 'fastify'
|
|
39
44
|
import { createFastifyHandler } from '@taserjs/adapter-fastify'
|
|
40
45
|
|
|
41
46
|
import { routeManifest } from '#src/routeManifest.gen.js'
|
|
@@ -45,33 +50,149 @@ const router = t.create(routeManifest)
|
|
|
45
50
|
|
|
46
51
|
const taser = createFastifyHandler(router)
|
|
47
52
|
const app = Fastify()
|
|
48
|
-
taser.mount('
|
|
53
|
+
taser.mount('/*', app)
|
|
49
54
|
|
|
50
55
|
const port = Number(process.env.PORT ?? 3000)
|
|
51
56
|
await app.listen({ port })
|
|
52
57
|
console.log(\`Fastify listening on http://localhost:\${port}\`)
|
|
53
58
|
`;
|
|
54
|
-
|
|
55
|
-
|
|
59
|
+
case "bun": return `import 'dotenv/config'
|
|
60
|
+
|
|
61
|
+
import { routeManifest } from '#src/routeManifest.gen.js'
|
|
62
|
+
import { t } from '#src/taser.js'
|
|
63
|
+
|
|
64
|
+
const router = t.create(routeManifest)
|
|
65
|
+
|
|
66
|
+
const port = Number(process.env.PORT ?? 3000)
|
|
67
|
+
|
|
68
|
+
export default {
|
|
69
|
+
port,
|
|
70
|
+
fetch(request: Request) {
|
|
71
|
+
return router.fetch(request)
|
|
72
|
+
},
|
|
73
|
+
}
|
|
74
|
+
`;
|
|
75
|
+
case "deno": return `import 'dotenv/config'
|
|
76
|
+
|
|
77
|
+
import { routeManifest } from '#src/routeManifest.gen.js'
|
|
78
|
+
import { t } from '#src/taser.js'
|
|
79
|
+
|
|
80
|
+
const router = t.create(routeManifest)
|
|
81
|
+
|
|
82
|
+
const port = Number(process.env.PORT ?? 8000)
|
|
83
|
+
Deno.serve({ port }, (request: Request) => router.fetch(request))
|
|
84
|
+
`;
|
|
85
|
+
case "aws-lambda": return `import 'dotenv/config'
|
|
86
|
+
|
|
87
|
+
import { Hono } from 'hono'
|
|
88
|
+
import { handle } from 'hono/aws-lambda'
|
|
89
|
+
|
|
90
|
+
import { routeManifest } from '#src/routeManifest.gen.js'
|
|
91
|
+
import { t } from '#src/taser.js'
|
|
92
|
+
|
|
93
|
+
const router = t.create(routeManifest)
|
|
94
|
+
|
|
95
|
+
const app = new Hono()
|
|
96
|
+
app.all('/*', c => router.native(c).fetch(c.req.raw))
|
|
97
|
+
|
|
98
|
+
export const handler = handle(app)
|
|
99
|
+
`;
|
|
100
|
+
case "cloudflare-workers": return `import 'dotenv/config'
|
|
101
|
+
|
|
102
|
+
import { routeManifest } from '#src/routeManifest.gen.js'
|
|
103
|
+
import { t } from '#src/taser.js'
|
|
104
|
+
|
|
105
|
+
const router = t.create(routeManifest)
|
|
106
|
+
|
|
107
|
+
export default {
|
|
108
|
+
fetch(request: Request, env: unknown, ctx: unknown) {
|
|
109
|
+
return router.fetch(request, env, ctx)
|
|
110
|
+
},
|
|
111
|
+
}
|
|
112
|
+
`;
|
|
113
|
+
case "netlify": return `import 'dotenv/config'
|
|
114
|
+
|
|
115
|
+
import { Hono } from 'hono'
|
|
116
|
+
import { handle } from 'hono/netlify'
|
|
117
|
+
|
|
118
|
+
import { routeManifest } from '#src/routeManifest.gen.js'
|
|
119
|
+
import { t } from '#src/taser.js'
|
|
120
|
+
|
|
121
|
+
const router = t.create(routeManifest)
|
|
122
|
+
|
|
123
|
+
const app = new Hono()
|
|
124
|
+
app.all('/*', c => router.native(c).fetch(c.req.raw))
|
|
125
|
+
|
|
126
|
+
export default handle(app)
|
|
127
|
+
`;
|
|
128
|
+
case "vercel": return `import 'dotenv/config'
|
|
129
|
+
|
|
130
|
+
import { Hono } from 'hono'
|
|
131
|
+
import { handle } from 'hono/vercel'
|
|
56
132
|
|
|
57
133
|
import { routeManifest } from '#src/routeManifest.gen.js'
|
|
58
134
|
import { t } from '#src/taser.js'
|
|
59
135
|
|
|
60
136
|
const router = t.create(routeManifest)
|
|
61
137
|
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
138
|
+
const app = new Hono()
|
|
139
|
+
app.all('/*', c => router.native(c).fetch(c.req.raw))
|
|
140
|
+
|
|
141
|
+
export default handle(app)
|
|
142
|
+
`;
|
|
143
|
+
case "azure-functions": return `import 'dotenv/config'
|
|
144
|
+
|
|
145
|
+
import { app } from '@azure/functions'
|
|
146
|
+
import { Hono } from 'hono'
|
|
147
|
+
import { azureHonoHandler } from '@marplex/hono-azurefunc-adapter'
|
|
148
|
+
|
|
149
|
+
import { routeManifest } from '#src/routeManifest.gen.js'
|
|
150
|
+
import { t } from '#src/taser.js'
|
|
151
|
+
|
|
152
|
+
const router = t.create(routeManifest)
|
|
153
|
+
|
|
154
|
+
const honoApp = new Hono()
|
|
155
|
+
honoApp.all('/*', c => router.native(c).fetch(c.req.raw))
|
|
156
|
+
|
|
157
|
+
app.http('httpTrigger', {
|
|
158
|
+
methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS'],
|
|
159
|
+
authLevel: 'anonymous',
|
|
160
|
+
route: '{*proxy}',
|
|
161
|
+
handler: azureHonoHandler(honoApp.fetch),
|
|
162
|
+
})
|
|
163
|
+
`;
|
|
164
|
+
case "google-cloud-run": return `import 'dotenv/config'
|
|
165
|
+
|
|
166
|
+
import { serve } from '@hono/node-server'
|
|
167
|
+
|
|
168
|
+
import { routeManifest } from '#src/routeManifest.gen.js'
|
|
169
|
+
import { t } from '#src/taser.js'
|
|
170
|
+
|
|
171
|
+
const router = t.create(routeManifest)
|
|
172
|
+
|
|
173
|
+
const port = Number(process.env.PORT ?? 8080)
|
|
174
|
+
serve({ fetch: router.fetch, port }, () => {
|
|
175
|
+
console.log(\`Cloud Run listening on http://localhost:\${port}\`)
|
|
176
|
+
})
|
|
177
|
+
`;
|
|
178
|
+
default: return `import 'dotenv/config'
|
|
179
|
+
|
|
180
|
+
import { serve } from '@hono/node-server'
|
|
181
|
+
|
|
182
|
+
import { routeManifest } from '#src/routeManifest.gen.js'
|
|
183
|
+
import { t } from '#src/taser.js'
|
|
184
|
+
|
|
185
|
+
const router = t.create(routeManifest)
|
|
65
186
|
|
|
66
187
|
const port = Number(process.env.PORT ?? 3000)
|
|
67
|
-
|
|
188
|
+
serve({ fetch: router.fetch, port }, () => {
|
|
68
189
|
console.log(\`Node listening on http://localhost:\${port}\`)
|
|
69
190
|
})
|
|
70
191
|
`;
|
|
71
192
|
}
|
|
72
193
|
}
|
|
73
|
-
function taserTsTemplate(
|
|
74
|
-
if (
|
|
194
|
+
function taserTsTemplate(type = "node") {
|
|
195
|
+
if (type === "hono" || type === "aws-lambda" || type === "netlify" || type === "vercel" || type === "azure-functions") return `import type { Context } from 'hono'
|
|
75
196
|
import { createTaserApp, type InferAppContext } from '@taserjs/router'
|
|
76
197
|
|
|
77
198
|
import { context } from '#src/context.js'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/frameworks/index.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/frameworks/index.ts"],"sourcesContent":["import type { ProjectType } from \"../core/types.js\";\n\nexport function indexTemplate(type: ProjectType): string {\n switch (type) {\n case \"express\":\n return `import 'dotenv/config'\n\nimport express from 'express'\nimport { createExpressHandler } from '@taserjs/adapter-express'\n\nimport { routeManifest } from '#src/routeManifest.gen.js'\nimport { t } from '#src/taser.js'\n\nconst router = t.create(routeManifest)\n\nconst taser = createExpressHandler(router)\nconst app = express()\ntaser.mount('/{*splat}', app)\n\nconst port = Number(process.env.PORT ?? 3000)\napp.listen(port, () => {\n console.log(\\`Express listening on http://localhost:\\${port}\\`)\n})\n`;\n case \"hono\":\n return `import 'dotenv/config'\n\nimport { serve } from '@hono/node-server'\nimport { Hono } from 'hono'\n\nimport { routeManifest } from '#src/routeManifest.gen.js'\nimport { t } from '#src/taser.js'\n\nconst router = t.create(routeManifest)\n\nconst app = new Hono()\napp.all('/*', c => router.native(c).fetch(c.req.raw))\n\nconst port = Number(process.env.PORT ?? 3000)\nserve({ fetch: app.fetch, port }, () => {\n console.log(\\`Hono listening on http://localhost:\\${port}\\`)\n})\n`;\n case \"fastify\":\n return `import 'dotenv/config'\n\nimport Fastify from 'fastify'\nimport { createFastifyHandler } from '@taserjs/adapter-fastify'\n\nimport { routeManifest } from '#src/routeManifest.gen.js'\nimport { t } from '#src/taser.js'\n\nconst router = t.create(routeManifest)\n\nconst taser = createFastifyHandler(router)\nconst app = Fastify()\ntaser.mount('/*', app)\n\nconst port = Number(process.env.PORT ?? 3000)\nawait app.listen({ port })\nconsole.log(\\`Fastify listening on http://localhost:\\${port}\\`)\n`;\n case \"bun\":\n return `import 'dotenv/config'\n\nimport { routeManifest } from '#src/routeManifest.gen.js'\nimport { t } from '#src/taser.js'\n\nconst router = t.create(routeManifest)\n\nconst port = Number(process.env.PORT ?? 3000)\n\nexport default {\n port,\n fetch(request: Request) {\n return router.fetch(request)\n },\n}\n`;\n case \"deno\":\n return `import 'dotenv/config'\n\nimport { routeManifest } from '#src/routeManifest.gen.js'\nimport { t } from '#src/taser.js'\n\nconst router = t.create(routeManifest)\n\nconst port = Number(process.env.PORT ?? 8000)\nDeno.serve({ port }, (request: Request) => router.fetch(request))\n`;\n case \"aws-lambda\":\n return `import 'dotenv/config'\n\nimport { Hono } from 'hono'\nimport { handle } from 'hono/aws-lambda'\n\nimport { routeManifest } from '#src/routeManifest.gen.js'\nimport { t } from '#src/taser.js'\n\nconst router = t.create(routeManifest)\n\nconst app = new Hono()\napp.all('/*', c => router.native(c).fetch(c.req.raw))\n\nexport const handler = handle(app)\n`;\n case \"cloudflare-workers\":\n return `import 'dotenv/config'\n\nimport { routeManifest } from '#src/routeManifest.gen.js'\nimport { t } from '#src/taser.js'\n\nconst router = t.create(routeManifest)\n\nexport default {\n fetch(request: Request, env: unknown, ctx: unknown) {\n return router.fetch(request, env, ctx)\n },\n}\n`;\n case \"netlify\":\n return `import 'dotenv/config'\n\nimport { Hono } from 'hono'\nimport { handle } from 'hono/netlify'\n\nimport { routeManifest } from '#src/routeManifest.gen.js'\nimport { t } from '#src/taser.js'\n\nconst router = t.create(routeManifest)\n\nconst app = new Hono()\napp.all('/*', c => router.native(c).fetch(c.req.raw))\n\nexport default handle(app)\n`;\n case \"vercel\":\n return `import 'dotenv/config'\n\nimport { Hono } from 'hono'\nimport { handle } from 'hono/vercel'\n\nimport { routeManifest } from '#src/routeManifest.gen.js'\nimport { t } from '#src/taser.js'\n\nconst router = t.create(routeManifest)\n\nconst app = new Hono()\napp.all('/*', c => router.native(c).fetch(c.req.raw))\n\nexport default handle(app)\n`;\n case \"azure-functions\":\n return `import 'dotenv/config'\n\nimport { app } from '@azure/functions'\nimport { Hono } from 'hono'\nimport { azureHonoHandler } from '@marplex/hono-azurefunc-adapter'\n\nimport { routeManifest } from '#src/routeManifest.gen.js'\nimport { t } from '#src/taser.js'\n\nconst router = t.create(routeManifest)\n\nconst honoApp = new Hono()\nhonoApp.all('/*', c => router.native(c).fetch(c.req.raw))\n\napp.http('httpTrigger', {\n methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS'],\n authLevel: 'anonymous',\n route: '{*proxy}',\n handler: azureHonoHandler(honoApp.fetch),\n})\n`;\n case \"google-cloud-run\":\n return `import 'dotenv/config'\n\nimport { serve } from '@hono/node-server'\n\nimport { routeManifest } from '#src/routeManifest.gen.js'\nimport { t } from '#src/taser.js'\n\nconst router = t.create(routeManifest)\n\nconst port = Number(process.env.PORT ?? 8080)\nserve({ fetch: router.fetch, port }, () => {\n console.log(\\`Cloud Run listening on http://localhost:\\${port}\\`)\n})\n`;\n case \"node\":\n default:\n return `import 'dotenv/config'\n\nimport { serve } from '@hono/node-server'\n\nimport { routeManifest } from '#src/routeManifest.gen.js'\nimport { t } from '#src/taser.js'\n\nconst router = t.create(routeManifest)\n\nconst port = Number(process.env.PORT ?? 3000)\nserve({ fetch: router.fetch, port }, () => {\n console.log(\\`Node listening on http://localhost:\\${port}\\`)\n})\n`;\n }\n}\n\nexport function taserTsTemplate(type: ProjectType = \"node\"): string {\n if (\n type === \"hono\" ||\n type === \"aws-lambda\" ||\n type === \"netlify\" ||\n type === \"vercel\" ||\n type === \"azure-functions\"\n ) {\n return `import type { Context } from 'hono'\nimport { createTaserApp, type InferAppContext } from '@taserjs/router'\n\nimport { context } from '#src/context.js'\n\ndeclare module '@taserjs/router' {\n interface RouterRegister {\n NativeContext: Context\n }\n}\n\nexport const t = createTaserApp({\n response: { validate: true },\n}).context(context)\n\nexport type AppContext = InferAppContext<typeof context>\n`;\n }\n\n return `import { createTaserApp, type InferAppContext } from '@taserjs/router'\n\nimport { context } from '#src/context.js'\n\nexport const t = createTaserApp({\n response: { validate: true },\n}).context(context)\n\nexport type AppContext = InferAppContext<typeof context>\n`;\n}\n"],"mappings":";AAEA,SAAgB,cAAc,MAA2B;CACvD,QAAQ,MAAR;EACE,KAAK,WACH,OAAO;;;;;;;;;;;;;;;;;;;EAmBT,KAAK,QACH,OAAO;;;;;;;;;;;;;;;;;;EAkBT,KAAK,WACH,OAAO;;;;;;;;;;;;;;;;;;EAkBT,KAAK,OACH,OAAO;;;;;;;;;;;;;;;;EAgBT,KAAK,QACH,OAAO;;;;;;;;;;EAUT,KAAK,cACH,OAAO;;;;;;;;;;;;;;;EAeT,KAAK,sBACH,OAAO;;;;;;;;;;;;;EAaT,KAAK,WACH,OAAO;;;;;;;;;;;;;;;EAeT,KAAK,UACH,OAAO;;;;;;;;;;;;;;;EAeT,KAAK,mBACH,OAAO;;;;;;;;;;;;;;;;;;;;;EAqBT,KAAK,oBACH,OAAO;;;;;;;;;;;;;;EAeT,SACE,OAAO;;;;;;;;;;;;;;CAcX;AACF;AAEA,SAAgB,gBAAgB,OAAoB,QAAgB;CAClE,IACE,SAAS,UACT,SAAS,gBACT,SAAS,aACT,SAAS,YACT,SAAS,mBAET,OAAO;;;;;;;;;;;;;;;;;CAmBT,OAAO;;;;;;;;;;AAUT"}
|
package/dist/esm/scaffold.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { scaffoldProject } from './core/scaffold-engine.js';
|
|
2
2
|
export { getPackageGroups, resolvePackages } from './core/resolve-packages.js';
|
|
3
|
-
export type {
|
|
3
|
+
export type { PackageGroups, ProjectType, ScaffoldOptions, ScaffoldResult } from './core/types.js';
|
|
@@ -7,14 +7,14 @@ function packageJsonTemplate(projectName, scripts = {}) {
|
|
|
7
7
|
type: "module",
|
|
8
8
|
imports: { "#src/*": "./src/*" },
|
|
9
9
|
scripts: {
|
|
10
|
-
|
|
10
|
+
dev: "run-p dev:server dev:taser",
|
|
11
11
|
"dev:server": "tsx watch src/index.ts",
|
|
12
12
|
"dev:taser": "taser watch",
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
start: "tsx src/index.ts",
|
|
14
|
+
generate: "taser generate",
|
|
15
|
+
build: "taser generate && tsdown",
|
|
16
|
+
serve: "node dist/index.mjs",
|
|
17
|
+
typecheck: "tsc --noEmit -p tsconfig.json",
|
|
18
18
|
...scripts
|
|
19
19
|
}
|
|
20
20
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","names":[],"sources":["../../../src/templates/base.ts"],"sourcesContent":["import type { BootBinding } from
|
|
1
|
+
{"version":3,"file":"base.js","names":[],"sources":["../../../src/templates/base.ts"],"sourcesContent":["import type { BootBinding } from \"../addons/types.js\";\nimport type { ScaffoldContext } from \"../core/types.js\";\n\nexport function packageJsonTemplate(\n projectName: string,\n scripts: Record<string, string> = {},\n): string {\n const pkg = {\n name: projectName,\n version: \"1.0.0\",\n private: true,\n type: \"module\",\n imports: {\n \"#src/*\": \"./src/*\",\n },\n scripts: {\n dev: \"run-p dev:server dev:taser\",\n \"dev:server\": \"tsx watch src/index.ts\",\n \"dev:taser\": \"taser watch\",\n start: \"tsx src/index.ts\",\n generate: \"taser generate\",\n build: \"taser generate && tsdown\",\n serve: \"node dist/index.mjs\",\n typecheck: \"tsc --noEmit -p tsconfig.json\",\n ...scripts,\n },\n };\n\n return `${JSON.stringify(pkg, null, 2)}\\n`;\n}\n\nexport function tsdownConfigTemplate(): string {\n return `import { defineConfig } from 'tsdown'\n\nexport default defineConfig({\n entry: ['./src/index.ts'],\n platform: 'node',\n outDir: 'dist',\n clean: true,\n sourcemap: true,\n})\n`;\n}\n\nexport function tsconfigTemplate(): string {\n return `${JSON.stringify(\n {\n compilerOptions: {\n target: \"ES2022\",\n module: \"NodeNext\",\n paths: {\n \"#src/*\": [\"./src/*\"],\n },\n strict: true,\n skipLibCheck: true,\n verbatimModuleSyntax: true,\n isolatedModules: true,\n noEmit: true,\n types: [\"node\"],\n },\n include: [\"src\"],\n },\n null,\n 2,\n )}\\n`;\n}\n\nexport function gitignoreTemplate(): string {\n return `node_modules\ndist\n.DS_Store\n*.log\n.env\nlocal.db\ndrizzle\n`;\n}\n\nexport function contextTemplate(bindings: BootBinding[]): string {\n const imports = bindings.map(\n (binding) => `import { ${binding.factoryName} } from '${binding.importPath}'`,\n );\n\n const bootBody =\n bindings.length > 0\n ? bindings.map((binding) => ` ${binding.key}: ${binding.factoryName}(),`).join(\"\\n\")\n : \"\";\n\n const bootBlock = bindings.length > 0 ? ` boot: () => ({\\n${bootBody}\\n }),` : \"\";\n\n const importBlock = imports.length > 0 ? `${imports.join(\"\\n\")}\\n\\n` : \"\";\n\n return `${importBlock}import { createContext } from '@taserjs/router'\n\nexport const context = createContext({\n${bootBlock}\n request: () => ({\n requestId: crypto.randomUUID(),\n }),\n})\n`;\n}\n\nexport function rootLayoutTemplate(): string {\n return `import { bodyLimit } from '@taserjs/router/body-limit'\nimport { secureHeaders } from '@taserjs/router/secure-headers'\n\nimport { t } from '#src/taser.js'\n\nexport const Middleware = t.middleware('/$')\n .use(secureHeaders())\n .use(bodyLimit({ maxSize: 1_000_000 }))\n`;\n}\n\nexport function indexRouteTemplate(): string {\n return `import { reply } from '@taserjs/router'\nimport { t } from '#src/taser.js'\n\nexport const Route = t.get('/').handler(() => {\n return reply.json({ message: 'Welcome to Taser' })\n})\n`;\n}\n\nexport function healthRouteTemplate(ctx: ScaffoldContext): string {\n const lines: string[] = [];\n\n if (ctx.logger) {\n lines.push(\" ctx.logger.info('health check')\");\n }\n\n if (ctx.db) {\n lines.push(\" // ctx.db is available from context boot\");\n }\n\n const body = lines.length > 0 ? `${lines.join(\"\\n\")}\\n` : \"\";\n const ctxArg = lines.length > 0 ? \"(ctx)\" : \"()\";\n\n return `import { reply } from '@taserjs/router'\nimport { t } from '#src/taser.js'\n\nexport const Route = t.get('/health').handler(${ctxArg} => {\n${body} return reply.json({ ok: true })\n})\n`;\n}\n\n/** Minimal placeholder until `taser generate` runs. */\nexport function starterManifestTemplate(): string {\n return `/* eslint-disable */\n// Run \\`pnpm generate\\` (taser generate) to replace this file.\nimport { Middleware as RootSplatLayoutImport } from './routes/$.js'\nimport { Route as RootIndexGetRouteImport } from './routes/index.get.js'\nimport { Route as HealthGetRouteImport } from './routes/health.get.js'\n\nexport const routeManifest = {\n layouts: {\n '/$': {\n middlewares: RootSplatLayoutImport,\n },\n },\n routes: {\n '/': {\n GET: {\n layoutChain: ['/$'],\n route: RootIndexGetRouteImport,\n },\n },\n '/health': {\n GET: {\n layoutChain: ['/$'],\n route: HealthGetRouteImport,\n },\n },\n },\n} as const\n\nexport type RoutePathGen = '/' | '/health'\nexport type LayoutIdGen = '/$'\nexport type LayoutTreeGen = {\n '/$': {\n parent: null\n middlewares: typeof RootSplatLayoutImport\n }\n}\nexport type RouteByPathMethodGen = {\n '/': {\n GET: {\n parent: '/$'\n layoutChain: ['/$']\n route: typeof RootIndexGetRouteImport\n }\n }\n '/health': {\n GET: {\n parent: '/$'\n layoutChain: ['/$']\n route: typeof HealthGetRouteImport\n }\n }\n}\nexport type RouteManifest = typeof routeManifest\n\ndeclare module '@taserjs/router' {\n interface RouterRegister {\n RoutePath: RoutePathGen\n LayoutId: LayoutIdGen\n LayoutTree: LayoutTreeGen\n RouteByPathMethod: RouteByPathMethodGen\n }\n}\n`;\n}\n"],"mappings":";AAGA,SAAgB,oBACd,aACA,UAAkC,CAAC,GAC3B;CACR,MAAM,MAAM;EACV,MAAM;EACN,SAAS;EACT,SAAS;EACT,M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A4C;CAGzD,MAAM,OAAO,MAAM,SAAS,IAAI,GAAG,MAAM,KAAK,IAAI,EAAE,MAAM;CAG1D,OAAO;;;gDAFQ,MAAM,SAAS,IAAI,UAAU,KAKS;EACrD,KAAK;;;AAGP;;AAGA,SAAgB,0BAAkC;CAChD,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+DT"}
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export type {
|
|
1
|
+
export type { DbDriver, DbOdm, LoggerId, PackageGroups, ProjectType, ScaffoldOptions, ScaffoldResult, ValidatorId, } from './core/types.js';
|
package/package.json
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-taserjs",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "Scaffold a new Taser application",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
5
|
+
"license": "ISC",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/taserjs/taserjs.git",
|
|
9
|
+
"directory": "packages/create-taserjs"
|
|
10
|
+
},
|
|
7
11
|
"bin": {
|
|
8
12
|
"create-taserjs": "./dist/esm/cli.js"
|
|
9
13
|
},
|
|
@@ -11,6 +15,12 @@
|
|
|
11
15
|
"dist",
|
|
12
16
|
"src"
|
|
13
17
|
],
|
|
18
|
+
"type": "module",
|
|
19
|
+
"sideEffects": false,
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public",
|
|
22
|
+
"registry": "https://registry.npmjs.org"
|
|
23
|
+
},
|
|
14
24
|
"dependencies": {
|
|
15
25
|
"@clack/prompts": "^0.11.0",
|
|
16
26
|
"package-manager-detector": "^1.8.0",
|
|
@@ -26,16 +36,6 @@
|
|
|
26
36
|
"engines": {
|
|
27
37
|
"node": ">=20.19"
|
|
28
38
|
},
|
|
29
|
-
"license": "ISC",
|
|
30
|
-
"repository": {
|
|
31
|
-
"type": "git",
|
|
32
|
-
"url": "git+https://github.com/taserjs/taserjs.git",
|
|
33
|
-
"directory": "packages/create-taserjs"
|
|
34
|
-
},
|
|
35
|
-
"publishConfig": {
|
|
36
|
-
"access": "public",
|
|
37
|
-
"registry": "https://registry.npmjs.org"
|
|
38
|
-
},
|
|
39
39
|
"scripts": {
|
|
40
40
|
"clean": "rimraf dist",
|
|
41
41
|
"build": "vite build && publint --strict",
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ValidatorAddon } from
|
|
1
|
+
import { ValidatorAddon } from "../validators.js";
|
|
2
2
|
|
|
3
|
-
export const arktypeAddon = ValidatorAddon(
|
|
3
|
+
export const arktypeAddon = ValidatorAddon("arktype");
|