create-taserjs 0.1.8 → 0.1.10
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/dist/cjs/cli.cjs +1 -1
- package/dist/cjs/cli.cjs.map +1 -1
- package/dist/cjs/templates/base.cjs +1 -1
- package/dist/cjs/templates/base.cjs.map +1 -1
- package/dist/esm/cli.js +1 -1
- package/dist/esm/cli.js.map +1 -1
- package/dist/esm/templates/base.js +1 -1
- package/dist/esm/templates/base.js.map +1 -1
- package/package.json +2 -2
- package/src/cli.ts +1 -1
- package/src/templates/base.ts +1 -1
package/dist/cjs/cli.cjs
CHANGED
|
@@ -43,7 +43,7 @@ async function main() {
|
|
|
43
43
|
}, positionals);
|
|
44
44
|
if (!parsed.json) {
|
|
45
45
|
console.clear();
|
|
46
|
-
_clack_prompts.intro(picocolors.default.bgCyan(picocolors.default.black(" create-
|
|
46
|
+
_clack_prompts.intro(picocolors.default.bgCyan(picocolors.default.black(" create-taserjs ")));
|
|
47
47
|
}
|
|
48
48
|
try {
|
|
49
49
|
await require_create.runCreateCommand(parsed);
|
package/dist/cjs/cli.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.cjs","names":[],"sources":["../../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { parseArgs } from \"node:util\";\n\nimport * as p from \"@clack/prompts\";\nimport color from \"picocolors\";\n\nimport { buildParsedArgsFromCli, runCreateCommand } from \"./commands/create.js\";\nimport { printJsonError } from \"./core/json-output.js\";\n\nasync function main(): Promise<void> {\n const { values, positionals } = parseArgs({\n args: process.argv.slice(2),\n options: {\n preset: { type: \"string\", short: \"p\" },\n db: { type: \"string\" },\n logger: { type: \"string\" },\n validator: { type: \"string\" },\n framework: { type: \"string\" },\n runtime: { type: \"string\" },\n y: { type: \"boolean\", short: \"y\" },\n noInstall: { type: \"boolean\" },\n json: { type: \"boolean\" },\n },\n allowPositionals: true,\n });\n\n const parsed = buildParsedArgsFromCli(\n {\n ...(values.preset !== undefined ? { preset: values.preset } : {}),\n ...(values.db !== undefined ? { db: values.db } : {}),\n ...(values.logger !== undefined ? { logger: values.logger } : {}),\n ...(values.validator !== undefined ? { validator: values.validator } : {}),\n ...(values.framework !== undefined ? { framework: values.framework } : {}),\n ...(values.runtime !== undefined ? { runtime: values.runtime } : {}),\n ...(values.y !== undefined ? { y: values.y } : {}),\n ...(values.noInstall !== undefined ? { noInstall: values.noInstall } : {}),\n ...(values.json !== undefined ? { json: values.json } : {}),\n },\n positionals,\n );\n\n if (!parsed.json) {\n console.clear();\n p.intro(color.bgCyan(color.black(\" create-
|
|
1
|
+
{"version":3,"file":"cli.cjs","names":[],"sources":["../../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { parseArgs } from \"node:util\";\n\nimport * as p from \"@clack/prompts\";\nimport color from \"picocolors\";\n\nimport { buildParsedArgsFromCli, runCreateCommand } from \"./commands/create.js\";\nimport { printJsonError } from \"./core/json-output.js\";\n\nasync function main(): Promise<void> {\n const { values, positionals } = parseArgs({\n args: process.argv.slice(2),\n options: {\n preset: { type: \"string\", short: \"p\" },\n db: { type: \"string\" },\n logger: { type: \"string\" },\n validator: { type: \"string\" },\n framework: { type: \"string\" },\n runtime: { type: \"string\" },\n y: { type: \"boolean\", short: \"y\" },\n noInstall: { type: \"boolean\" },\n json: { type: \"boolean\" },\n },\n allowPositionals: true,\n });\n\n const parsed = buildParsedArgsFromCli(\n {\n ...(values.preset !== undefined ? { preset: values.preset } : {}),\n ...(values.db !== undefined ? { db: values.db } : {}),\n ...(values.logger !== undefined ? { logger: values.logger } : {}),\n ...(values.validator !== undefined ? { validator: values.validator } : {}),\n ...(values.framework !== undefined ? { framework: values.framework } : {}),\n ...(values.runtime !== undefined ? { runtime: values.runtime } : {}),\n ...(values.y !== undefined ? { y: values.y } : {}),\n ...(values.noInstall !== undefined ? { noInstall: values.noInstall } : {}),\n ...(values.json !== undefined ? { json: values.json } : {}),\n },\n positionals,\n );\n\n if (!parsed.json) {\n console.clear();\n p.intro(color.bgCyan(color.black(\" create-taserjs \")));\n }\n\n try {\n await runCreateCommand(parsed);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n if (parsed.json) {\n printJsonError(message);\n process.exit(1);\n }\n throw error;\n }\n}\n\nmain().catch((error: unknown) => {\n console.error(error);\n process.exit(1);\n});\n"],"mappings":";;;;;;;;;;AASA,eAAe,OAAsB;CACnC,MAAM,EAAE,QAAQ,iBAAA,GAAgB,UAAA,UAAA,CAAU;EACxC,MAAM,QAAQ,KAAK,MAAM,CAAC;EAC1B,SAAS;GACP,QAAQ;IAAE,MAAM;IAAU,OAAO;GAAI;GACrC,IAAI,EAAE,MAAM,SAAS;GACrB,QAAQ,EAAE,MAAM,SAAS;GACzB,WAAW,EAAE,MAAM,SAAS;GAC5B,WAAW,EAAE,MAAM,SAAS;GAC5B,SAAS,EAAE,MAAM,SAAS;GAC1B,GAAG;IAAE,MAAM;IAAW,OAAO;GAAI;GACjC,WAAW,EAAE,MAAM,UAAU;GAC7B,MAAM,EAAE,MAAM,UAAU;EAC1B;EACA,kBAAkB;CACpB,CAAC;CAED,MAAM,SAAS,eAAA,uBACb;EACE,GAAI,OAAO,WAAW,KAAA,IAAY,EAAE,QAAQ,OAAO,OAAO,IAAI,CAAC;EAC/D,GAAI,OAAO,OAAO,KAAA,IAAY,EAAE,IAAI,OAAO,GAAG,IAAI,CAAC;EACnD,GAAI,OAAO,WAAW,KAAA,IAAY,EAAE,QAAQ,OAAO,OAAO,IAAI,CAAC;EAC/D,GAAI,OAAO,cAAc,KAAA,IAAY,EAAE,WAAW,OAAO,UAAU,IAAI,CAAC;EACxE,GAAI,OAAO,cAAc,KAAA,IAAY,EAAE,WAAW,OAAO,UAAU,IAAI,CAAC;EACxE,GAAI,OAAO,YAAY,KAAA,IAAY,EAAE,SAAS,OAAO,QAAQ,IAAI,CAAC;EAClE,GAAI,OAAO,MAAM,KAAA,IAAY,EAAE,GAAG,OAAO,EAAE,IAAI,CAAC;EAChD,GAAI,OAAO,cAAc,KAAA,IAAY,EAAE,WAAW,OAAO,UAAU,IAAI,CAAC;EACxE,GAAI,OAAO,SAAS,KAAA,IAAY,EAAE,MAAM,OAAO,KAAK,IAAI,CAAC;CAC3D,GACA,WACF;CAEA,IAAI,CAAC,OAAO,MAAM;EAChB,QAAQ,MAAM;EACd,eAAE,MAAM,WAAA,QAAM,OAAO,WAAA,QAAM,MAAM,kBAAkB,CAAC,CAAC;CACvD;CAEA,IAAI;EACF,MAAM,eAAA,iBAAiB,MAAM;CAC/B,SAAS,OAAO;EACd,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;EACrE,IAAI,OAAO,MAAM;GACf,oBAAA,eAAe,OAAO;GACtB,QAAQ,KAAK,CAAC;EAChB;EACA,MAAM;CACR;AACF;AAEA,KAAK,CAAC,CAAC,OAAO,UAAmB;CAC/B,QAAQ,MAAM,KAAK;CACnB,QAAQ,KAAK,CAAC;AAChB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.cjs","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 scripts: {\n dev: \"vite\",\n build: \"vite build\",\n typecheck: \"tsc --noEmit -p tsconfig.json\",\n ...scripts,\n },\n };\n\n return `${JSON.stringify(pkg, null, 2)}\\n`;\n}\n\nexport function tsconfigTemplate(): string {\n return `${JSON.stringify(\n {\n compilerOptions: {\n target: \"ES2022\",\n module: \"NodeNext\",\n strict: true,\n skipLibCheck: true,\n verbatimModuleSyntax: true,\n isolatedModules: true,\n noEmit: true,\n },\n include: [\"src\", \".taser/types/**/*.d.ts\"],\n },\n null,\n 2,\n )}\\n`;\n}\n\nexport function gitignoreTemplate(): string {\n return `node_modules\ndist\n.output\n.taser\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 { cors } from '@taserjs/router/cors'\nimport { t } from '@taserjs/router'\n\nexport default t.layout('
|
|
1
|
+
{"version":3,"file":"base.cjs","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 scripts: {\n dev: \"vite\",\n build: \"vite build\",\n typecheck: \"tsc --noEmit -p tsconfig.json\",\n ...scripts,\n },\n };\n\n return `${JSON.stringify(pkg, null, 2)}\\n`;\n}\n\nexport function tsconfigTemplate(): string {\n return `${JSON.stringify(\n {\n compilerOptions: {\n target: \"ES2022\",\n module: \"NodeNext\",\n strict: true,\n skipLibCheck: true,\n verbatimModuleSyntax: true,\n isolatedModules: true,\n noEmit: true,\n },\n include: [\"src\", \".taser/types/**/*.d.ts\"],\n },\n null,\n 2,\n )}\\n`;\n}\n\nexport function gitignoreTemplate(): string {\n return `node_modules\ndist\n.output\n.taser\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 { cors } from '@taserjs/router/cors'\nimport { t } from '@taserjs/router'\n\nexport default t.layout('/*')\n .use(cors())\n`;\n}\n\nexport function indexRouteTemplate(): string {\n return `import { t } from '@taserjs/router'\nimport { json } from '@taserjs/router/reply'\n\nexport default t.get('/').handler((_ctx) => {\n return 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)\" : \"(_ctx)\";\n\n return `import { t } from '@taserjs/router'\nimport { json } from '@taserjs/router/reply'\n\nexport default t.get('/health').handler(${ctxArg} => {\n${body} return json({ ok: true })\n})\n`;\n}\n"],"mappings":";AAGA,SAAgB,oBACd,aACA,UAAkC,CAAC,GAC3B;CACR,MAAM,MAAM;EACV,MAAM;EACN,SAAS;EACT,SAAS;EACT,MAAM;EACN,SAAS;GACP,KAAK;GACL,OAAO;GACP,WAAW;GACX,GAAG;EACL;CACF;CAEA,OAAO,GAAG,KAAK,UAAU,KAAK,MAAM,CAAC,EAAE;AACzC;AAEA,SAAgB,mBAA2B;CACzC,OAAO,GAAG,KAAK,UACb;EACE,iBAAiB;GACf,QAAQ;GACR,QAAQ;GACR,QAAQ;GACR,cAAc;GACd,sBAAsB;GACtB,iBAAiB;GACjB,QAAQ;EACV;EACA,SAAS,CAAC,OAAO,wBAAwB;CAC3C,GACA,MACA,CACF,EAAE;AACJ;AAEA,SAAgB,oBAA4B;CAC1C,OAAO;;;;;;;;;;AAUT;AAEA,SAAgB,gBAAgB,UAAiC;CAC/D,MAAM,UAAU,SAAS,KACtB,YAAY,YAAY,QAAQ,YAAY,WAAW,QAAQ,WAAW,EAC7E;CAEA,MAAM,WACJ,SAAS,SAAS,IACd,SAAS,KAAK,YAAY,OAAO,QAAQ,IAAI,IAAI,QAAQ,YAAY,IAAI,CAAC,CAAC,KAAK,IAAI,IACpF;CAEN,MAAM,YAAY,SAAS,SAAS,IAAI,qBAAqB,SAAS,WAAW;CAIjF,OAAO,GAFa,QAAQ,SAAS,IAAI,GAAG,QAAQ,KAAK,IAAI,EAAE,QAAQ,GAEjD;;;EAGtB,UAAU;;;;;;AAMZ;AAEA,SAAgB,qBAA6B;CAC3C,OAAO;;;;;;AAMT;AAEA,SAAgB,qBAA6B;CAC3C,OAAO;;;;;;;AAOT;AAEA,SAAgB,oBAAoB,KAA8B;CAChE,MAAM,QAAkB,CAAC;CAEzB,IAAI,IAAI,QACN,MAAM,KAAK,mCAAmC;CAGhD,IAAI,IAAI,IACN,MAAM,KAAK,4CAA4C;CAGzD,MAAM,OAAO,MAAM,SAAS,IAAI,GAAG,MAAM,KAAK,IAAI,EAAE,MAAM;CAG1D,OAAO;;;0CAFQ,MAAM,SAAS,IAAI,UAAU,SAKG;EAC/C,KAAK;;;AAGP"}
|
package/dist/esm/cli.js
CHANGED
package/dist/esm/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","names":[],"sources":["../../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { parseArgs } from \"node:util\";\n\nimport * as p from \"@clack/prompts\";\nimport color from \"picocolors\";\n\nimport { buildParsedArgsFromCli, runCreateCommand } from \"./commands/create.js\";\nimport { printJsonError } from \"./core/json-output.js\";\n\nasync function main(): Promise<void> {\n const { values, positionals } = parseArgs({\n args: process.argv.slice(2),\n options: {\n preset: { type: \"string\", short: \"p\" },\n db: { type: \"string\" },\n logger: { type: \"string\" },\n validator: { type: \"string\" },\n framework: { type: \"string\" },\n runtime: { type: \"string\" },\n y: { type: \"boolean\", short: \"y\" },\n noInstall: { type: \"boolean\" },\n json: { type: \"boolean\" },\n },\n allowPositionals: true,\n });\n\n const parsed = buildParsedArgsFromCli(\n {\n ...(values.preset !== undefined ? { preset: values.preset } : {}),\n ...(values.db !== undefined ? { db: values.db } : {}),\n ...(values.logger !== undefined ? { logger: values.logger } : {}),\n ...(values.validator !== undefined ? { validator: values.validator } : {}),\n ...(values.framework !== undefined ? { framework: values.framework } : {}),\n ...(values.runtime !== undefined ? { runtime: values.runtime } : {}),\n ...(values.y !== undefined ? { y: values.y } : {}),\n ...(values.noInstall !== undefined ? { noInstall: values.noInstall } : {}),\n ...(values.json !== undefined ? { json: values.json } : {}),\n },\n positionals,\n );\n\n if (!parsed.json) {\n console.clear();\n p.intro(color.bgCyan(color.black(\" create-
|
|
1
|
+
{"version":3,"file":"cli.js","names":[],"sources":["../../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { parseArgs } from \"node:util\";\n\nimport * as p from \"@clack/prompts\";\nimport color from \"picocolors\";\n\nimport { buildParsedArgsFromCli, runCreateCommand } from \"./commands/create.js\";\nimport { printJsonError } from \"./core/json-output.js\";\n\nasync function main(): Promise<void> {\n const { values, positionals } = parseArgs({\n args: process.argv.slice(2),\n options: {\n preset: { type: \"string\", short: \"p\" },\n db: { type: \"string\" },\n logger: { type: \"string\" },\n validator: { type: \"string\" },\n framework: { type: \"string\" },\n runtime: { type: \"string\" },\n y: { type: \"boolean\", short: \"y\" },\n noInstall: { type: \"boolean\" },\n json: { type: \"boolean\" },\n },\n allowPositionals: true,\n });\n\n const parsed = buildParsedArgsFromCli(\n {\n ...(values.preset !== undefined ? { preset: values.preset } : {}),\n ...(values.db !== undefined ? { db: values.db } : {}),\n ...(values.logger !== undefined ? { logger: values.logger } : {}),\n ...(values.validator !== undefined ? { validator: values.validator } : {}),\n ...(values.framework !== undefined ? { framework: values.framework } : {}),\n ...(values.runtime !== undefined ? { runtime: values.runtime } : {}),\n ...(values.y !== undefined ? { y: values.y } : {}),\n ...(values.noInstall !== undefined ? { noInstall: values.noInstall } : {}),\n ...(values.json !== undefined ? { json: values.json } : {}),\n },\n positionals,\n );\n\n if (!parsed.json) {\n console.clear();\n p.intro(color.bgCyan(color.black(\" create-taserjs \")));\n }\n\n try {\n await runCreateCommand(parsed);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n if (parsed.json) {\n printJsonError(message);\n process.exit(1);\n }\n throw error;\n }\n}\n\nmain().catch((error: unknown) => {\n console.error(error);\n process.exit(1);\n});\n"],"mappings":";;;;;;;AASA,eAAe,OAAsB;CACnC,MAAM,EAAE,QAAQ,gBAAgB,UAAU;EACxC,MAAM,QAAQ,KAAK,MAAM,CAAC;EAC1B,SAAS;GACP,QAAQ;IAAE,MAAM;IAAU,OAAO;GAAI;GACrC,IAAI,EAAE,MAAM,SAAS;GACrB,QAAQ,EAAE,MAAM,SAAS;GACzB,WAAW,EAAE,MAAM,SAAS;GAC5B,WAAW,EAAE,MAAM,SAAS;GAC5B,SAAS,EAAE,MAAM,SAAS;GAC1B,GAAG;IAAE,MAAM;IAAW,OAAO;GAAI;GACjC,WAAW,EAAE,MAAM,UAAU;GAC7B,MAAM,EAAE,MAAM,UAAU;EAC1B;EACA,kBAAkB;CACpB,CAAC;CAED,MAAM,SAAS,uBACb;EACE,GAAI,OAAO,WAAW,KAAA,IAAY,EAAE,QAAQ,OAAO,OAAO,IAAI,CAAC;EAC/D,GAAI,OAAO,OAAO,KAAA,IAAY,EAAE,IAAI,OAAO,GAAG,IAAI,CAAC;EACnD,GAAI,OAAO,WAAW,KAAA,IAAY,EAAE,QAAQ,OAAO,OAAO,IAAI,CAAC;EAC/D,GAAI,OAAO,cAAc,KAAA,IAAY,EAAE,WAAW,OAAO,UAAU,IAAI,CAAC;EACxE,GAAI,OAAO,cAAc,KAAA,IAAY,EAAE,WAAW,OAAO,UAAU,IAAI,CAAC;EACxE,GAAI,OAAO,YAAY,KAAA,IAAY,EAAE,SAAS,OAAO,QAAQ,IAAI,CAAC;EAClE,GAAI,OAAO,MAAM,KAAA,IAAY,EAAE,GAAG,OAAO,EAAE,IAAI,CAAC;EAChD,GAAI,OAAO,cAAc,KAAA,IAAY,EAAE,WAAW,OAAO,UAAU,IAAI,CAAC;EACxE,GAAI,OAAO,SAAS,KAAA,IAAY,EAAE,MAAM,OAAO,KAAK,IAAI,CAAC;CAC3D,GACA,WACF;CAEA,IAAI,CAAC,OAAO,MAAM;EAChB,QAAQ,MAAM;EACd,EAAE,MAAM,MAAM,OAAO,MAAM,MAAM,kBAAkB,CAAC,CAAC;CACvD;CAEA,IAAI;EACF,MAAM,iBAAiB,MAAM;CAC/B,SAAS,OAAO;EACd,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;EACrE,IAAI,OAAO,MAAM;GACf,eAAe,OAAO;GACtB,QAAQ,KAAK,CAAC;EAChB;EACA,MAAM;CACR;AACF;AAEA,KAAK,CAAC,CAAC,OAAO,UAAmB;CAC/B,QAAQ,MAAM,KAAK;CACnB,QAAQ,KAAK,CAAC;AAChB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
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 scripts: {\n dev: \"vite\",\n build: \"vite build\",\n typecheck: \"tsc --noEmit -p tsconfig.json\",\n ...scripts,\n },\n };\n\n return `${JSON.stringify(pkg, null, 2)}\\n`;\n}\n\nexport function tsconfigTemplate(): string {\n return `${JSON.stringify(\n {\n compilerOptions: {\n target: \"ES2022\",\n module: \"NodeNext\",\n strict: true,\n skipLibCheck: true,\n verbatimModuleSyntax: true,\n isolatedModules: true,\n noEmit: true,\n },\n include: [\"src\", \".taser/types/**/*.d.ts\"],\n },\n null,\n 2,\n )}\\n`;\n}\n\nexport function gitignoreTemplate(): string {\n return `node_modules\ndist\n.output\n.taser\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 { cors } from '@taserjs/router/cors'\nimport { t } from '@taserjs/router'\n\nexport default t.layout('
|
|
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 scripts: {\n dev: \"vite\",\n build: \"vite build\",\n typecheck: \"tsc --noEmit -p tsconfig.json\",\n ...scripts,\n },\n };\n\n return `${JSON.stringify(pkg, null, 2)}\\n`;\n}\n\nexport function tsconfigTemplate(): string {\n return `${JSON.stringify(\n {\n compilerOptions: {\n target: \"ES2022\",\n module: \"NodeNext\",\n strict: true,\n skipLibCheck: true,\n verbatimModuleSyntax: true,\n isolatedModules: true,\n noEmit: true,\n },\n include: [\"src\", \".taser/types/**/*.d.ts\"],\n },\n null,\n 2,\n )}\\n`;\n}\n\nexport function gitignoreTemplate(): string {\n return `node_modules\ndist\n.output\n.taser\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 { cors } from '@taserjs/router/cors'\nimport { t } from '@taserjs/router'\n\nexport default t.layout('/*')\n .use(cors())\n`;\n}\n\nexport function indexRouteTemplate(): string {\n return `import { t } from '@taserjs/router'\nimport { json } from '@taserjs/router/reply'\n\nexport default t.get('/').handler((_ctx) => {\n return 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)\" : \"(_ctx)\";\n\n return `import { t } from '@taserjs/router'\nimport { json } from '@taserjs/router/reply'\n\nexport default t.get('/health').handler(${ctxArg} => {\n${body} return json({ ok: true })\n})\n`;\n}\n"],"mappings":";AAGA,SAAgB,oBACd,aACA,UAAkC,CAAC,GAC3B;CACR,MAAM,MAAM;EACV,MAAM;EACN,SAAS;EACT,SAAS;EACT,MAAM;EACN,SAAS;GACP,KAAK;GACL,OAAO;GACP,WAAW;GACX,GAAG;EACL;CACF;CAEA,OAAO,GAAG,KAAK,UAAU,KAAK,MAAM,CAAC,EAAE;AACzC;AAEA,SAAgB,mBAA2B;CACzC,OAAO,GAAG,KAAK,UACb;EACE,iBAAiB;GACf,QAAQ;GACR,QAAQ;GACR,QAAQ;GACR,cAAc;GACd,sBAAsB;GACtB,iBAAiB;GACjB,QAAQ;EACV;EACA,SAAS,CAAC,OAAO,wBAAwB;CAC3C,GACA,MACA,CACF,EAAE;AACJ;AAEA,SAAgB,oBAA4B;CAC1C,OAAO;;;;;;;;;;AAUT;AAEA,SAAgB,gBAAgB,UAAiC;CAC/D,MAAM,UAAU,SAAS,KACtB,YAAY,YAAY,QAAQ,YAAY,WAAW,QAAQ,WAAW,EAC7E;CAEA,MAAM,WACJ,SAAS,SAAS,IACd,SAAS,KAAK,YAAY,OAAO,QAAQ,IAAI,IAAI,QAAQ,YAAY,IAAI,CAAC,CAAC,KAAK,IAAI,IACpF;CAEN,MAAM,YAAY,SAAS,SAAS,IAAI,qBAAqB,SAAS,WAAW;CAIjF,OAAO,GAFa,QAAQ,SAAS,IAAI,GAAG,QAAQ,KAAK,IAAI,EAAE,QAAQ,GAEjD;;;EAGtB,UAAU;;;;;;AAMZ;AAEA,SAAgB,qBAA6B;CAC3C,OAAO;;;;;;AAMT;AAEA,SAAgB,qBAA6B;CAC3C,OAAO;;;;;;;AAOT;AAEA,SAAgB,oBAAoB,KAA8B;CAChE,MAAM,QAAkB,CAAC;CAEzB,IAAI,IAAI,QACN,MAAM,KAAK,mCAAmC;CAGhD,IAAI,IAAI,IACN,MAAM,KAAK,4CAA4C;CAGzD,MAAM,OAAO,MAAM,SAAS,IAAI,GAAG,MAAM,KAAK,IAAI,EAAE,MAAM;CAG1D,OAAO;;;0CAFQ,MAAM,SAAS,IAAI,UAAU,SAKG;EAC/C,KAAK;;;AAGP"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-taserjs",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"description": "Scaffold a new Taser application",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"typescript": "^5.9.3",
|
|
33
33
|
"vite": "^8.1.5",
|
|
34
34
|
"vitest": "^4.1.10",
|
|
35
|
-
"@taserjs/router-generator": "0.1.
|
|
35
|
+
"@taserjs/router-generator": "0.1.10"
|
|
36
36
|
},
|
|
37
37
|
"engines": {
|
|
38
38
|
"node": ">=20.19"
|
package/src/cli.ts
CHANGED
package/src/templates/base.ts
CHANGED