create-better-t-stack 3.36.4 → 3.36.5

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/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { _ as types_exports, i as SchemaNameSchema, l as create, m as getSchemaResult, s as add, u as createBtsCli, v as getLatestCLIVersion } from "./src-AlTJbWsW.mjs";
2
+ import { _ as types_exports, i as SchemaNameSchema, l as create, m as getSchemaResult, s as add, u as createBtsCli, v as getLatestCLIVersion } from "./src-DpdI3cqy.mjs";
3
3
  import z from "zod";
4
4
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
5
5
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import { C as ProjectCreationError, S as DirectoryConflictError, T as ValidationError, a as TEMPLATE_COUNT, b as CompatibilityError, c as builder, d as createVirtual, f as docs, g as sponsors, h as router, i as SchemaNameSchema, l as create, m as getSchemaResult, n as GeneratorError, o as VirtualFileSystem, p as generate, r as Result, s as add, t as EMBEDDED_TEMPLATES, u as createBtsCli, w as UserCancelledError, x as DatabaseSetupError, y as CLIError } from "./src-AlTJbWsW.mjs";
2
+ import { C as ProjectCreationError, S as DirectoryConflictError, T as ValidationError, a as TEMPLATE_COUNT, b as CompatibilityError, c as builder, d as createVirtual, f as docs, g as sponsors, h as router, i as SchemaNameSchema, l as create, m as getSchemaResult, n as GeneratorError, o as VirtualFileSystem, p as generate, r as Result, s as add, t as EMBEDDED_TEMPLATES, u as createBtsCli, w as UserCancelledError, x as DatabaseSetupError, y as CLIError } from "./src-DpdI3cqy.mjs";
3
3
  export { CLIError, CompatibilityError, DatabaseSetupError, DirectoryConflictError, EMBEDDED_TEMPLATES, GeneratorError, ProjectCreationError, Result, SchemaNameSchema, TEMPLATE_COUNT, UserCancelledError, ValidationError, VirtualFileSystem, add, builder, create, createBtsCli, createVirtual, docs, generate, getSchemaResult, router, sponsors };
@@ -1546,6 +1546,13 @@ function getAuthImportLine(config) {
1546
1546
  function getAuthExpression(config) {
1547
1547
  return usesCreateAuthFactory(config) ? "createAuth()" : "auth";
1548
1548
  }
1549
+ function addAiSdkEvlogTelemetry(content, loggerExpression) {
1550
+ let nextContent = addNamedImport(content, "evlog/ai", ["createAILogger", "createEvlogIntegration"]);
1551
+ if (!nextContent.includes("const ai = createAILogger(")) nextContent = nextContent.replace(/^(\s*)const model = wrapLanguageModel\({/m, (_match, indent) => `${indent}const ai = createAILogger(${loggerExpression});\n${indent}const model = wrapLanguageModel({`);
1552
+ if (!nextContent.includes("model: ai.wrap(model)")) nextContent = nextContent.replace(/(const result = streamText\({\n\s*)model,/, "$1model: ai.wrap(model),");
1553
+ if (!nextContent.includes("createEvlogIntegration(ai)")) nextContent = nextContent.replace(/^(\s*)(messages:\s*await convertToModelMessages\([^)]+\),?)/m, (_match, indent, messages) => `${indent}${messages.endsWith(",") ? messages : `${messages},`}\n${indent}telemetry: {\n${indent}\tisEnabled: true,\n${indent}\tintegrations: [createEvlogIntegration(ai)],\n${indent}},`);
1554
+ return nextContent;
1555
+ }
1549
1556
  function addEvlogBetterAuthServerSetup(content, backend, authExpression) {
1550
1557
  let nextContent = addNamedImport(content, "evlog/better-auth", ["createAuthMiddleware", "type BetterAuthInstance"]);
1551
1558
  const usesAuthFactory = authExpression.endsWith("()");
@@ -1558,15 +1565,17 @@ function addEvlogBetterAuthServerSetup(content, backend, authExpression) {
1558
1565
  return insertAfterOnce(nextContent, "app.use(evlog());", `\napp.use("*", async (c, next) => {${identifyUserSetup}\n\tawait identifyUser(c.get("log"), c.req.raw.headers, c.req.path);\n\tawait next();\n});`, "identifyUser(c.get(\"log\")");
1559
1566
  }
1560
1567
  if (backend === "express") {
1568
+ nextContent = addNamedImport(nextContent, "evlog/express", ["useLogger"]);
1561
1569
  nextContent = insertBeforeOnce(nextContent, "const app = express();", identifySnippet, "createAuthMiddleware(");
1562
- return insertAfterOnce(nextContent, "app.use(evlog());", `\napp.use(async (req, _res, next) => {${identifyUserSetup}\n\tawait identifyUser(req.log, req.headers, req.path);\n\tnext();\n});`, "identifyUser(req.log");
1570
+ return insertAfterOnce(nextContent, "app.use(evlog());", `\napp.use(async (req, _res, next) => {${identifyUserSetup}\n\tawait identifyUser(useLogger(), req.headers, req.path);\n\tnext();\n});`, "identifyUser(useLogger()");
1563
1571
  }
1564
1572
  if (backend === "fastify") {
1565
1573
  nextContent = addNamedImport(nextContent, "evlog/fastify", ["useLogger"]);
1566
1574
  nextContent = insertBeforeOnce(nextContent, "const fastify = Fastify", identifySnippet, "createAuthMiddleware(");
1567
1575
  return insertAfterOnce(nextContent, "fastify.register(evlog);", `\nfastify.addHook("preHandler", async (request) => {${identifyUserSetup}\n\tawait identifyUser(useLogger(), request.headers, request.url);\n});`, "identifyUser(useLogger()");
1568
1576
  }
1569
- nextContent = insertBeforeOnce(nextContent, "new Elysia", identifySnippet, "createAuthMiddleware(");
1577
+ const elysiaMarker = nextContent.includes("const app = new Elysia") ? "const app = new Elysia" : "new Elysia";
1578
+ nextContent = insertBeforeOnce(nextContent, elysiaMarker, identifySnippet, "createAuthMiddleware(");
1570
1579
  return insertAfterOnce(nextContent, ".use(evlog())", `\n\t.derive(async ({ request, log }) => {${identifyUserSetup.replace(/\n\t/g, "\n ")}\n\t\tawait identifyUser(log, request.headers, new URL(request.url).pathname);\n\t\treturn {};\n\t})`, "identifyUser(log");
1571
1580
  }
1572
1581
  function addEvlogServerSetup(content, backend, serviceName) {
@@ -1589,7 +1598,8 @@ function addEvlogServerSetup(content, backend, serviceName) {
1589
1598
  return insertBeforeOnce(nextContent, "fastify.register(fastifyCors", "fastify.register(evlog);\n", "fastify.register(evlog);");
1590
1599
  }
1591
1600
  let nextContent = prependMissingImports(content, ["import { initLogger } from \"evlog\";", "import { evlog } from \"evlog/elysia\";"]);
1592
- nextContent = insertBeforeOnce(nextContent, "new Elysia", initSnippet, "initLogger({");
1601
+ const elysiaMarker = nextContent.includes("const app = new Elysia") ? "const app = new Elysia" : "new Elysia";
1602
+ nextContent = insertBeforeOnce(nextContent, elysiaMarker, initSnippet, "initLogger({");
1593
1603
  for (const marker of ["new Elysia({ adapter: node() })", "new Elysia()"]) nextContent = insertAfterOnce(nextContent, marker, "\n .use(evlog())", ".use(evlog())");
1594
1604
  return nextContent;
1595
1605
  }
@@ -1671,12 +1681,27 @@ function addNextRouteWrappers(content) {
1671
1681
  return nextContent;
1672
1682
  }
1673
1683
  function addNextAiEvlogSetup(content) {
1674
- let nextContent = addNamedImport(content, "@/lib/evlog", ["withEvlog"]);
1684
+ let nextContent = addNamedImport(content, "@/lib/evlog", ["withEvlog", "useLogger"]);
1675
1685
  if (!nextContent.includes("withEvlog(async (req: Request)")) {
1676
1686
  nextContent = nextContent.replace("export async function POST(req: Request) {", "export const POST = withEvlog(async (req: Request) => {");
1677
1687
  if (nextContent.includes("export const POST = withEvlog(async (req: Request) => {")) nextContent = nextContent.replace(/\n}\s*$/, "\n});\n");
1678
1688
  }
1679
- return nextContent;
1689
+ return addAiSdkEvlogTelemetry(nextContent, "useLogger()");
1690
+ }
1691
+ function addNuxtAiEvlogSetup(content) {
1692
+ return addAiSdkEvlogTelemetry(addNamedImport(content, "evlog/nitro", ["useLogger"]), "useLogger(event)");
1693
+ }
1694
+ function addSvelteAiEvlogSetup(content) {
1695
+ return addAiSdkEvlogTelemetry(content.replace("export const POST: RequestHandler = async ({ request }) => {", "export const POST: RequestHandler = async ({ request, locals }) => {"), "locals.log");
1696
+ }
1697
+ function addTanstackStartAiEvlogSetup(content) {
1698
+ return addAiSdkEvlogTelemetry(prependMissingImports(content, ["import type { RequestLogger } from \"evlog\";", "import { useRequest } from \"nitro/context\";"]), "useRequest().context.log as RequestLogger");
1699
+ }
1700
+ function addBackendAiEvlogSetup(content, backend) {
1701
+ if (backend === "hono") return addAiSdkEvlogTelemetry(content, "c.get(\"log\")");
1702
+ if (backend === "express") return addAiSdkEvlogTelemetry(addNamedImport(content, "evlog/express", ["useLogger"]), "useLogger()");
1703
+ if (backend === "fastify") return addAiSdkEvlogTelemetry(addNamedImport(content, "evlog/fastify", ["useLogger"]), "useLogger()");
1704
+ return addAiSdkEvlogTelemetry(content, "context.log");
1680
1705
  }
1681
1706
  function addNextBetterAuthToRoute(content) {
1682
1707
  let nextContent = addNamedImport(content, "@/lib/evlog-auth", ["identifyEvlogUser"]);
@@ -1921,6 +1946,7 @@ async function setupNuxtEvlog(config, serviceName) {
1921
1946
  const authMiddlewarePath = path.join(webDir, "server/middleware/evlog-auth.ts");
1922
1947
  if (!await fs.pathExists(authMiddlewarePath)) await writeFileIfChanged(authMiddlewarePath, getNuxtEvlogAuthMiddlewareFile(config));
1923
1948
  }
1949
+ if (config.examples.includes("ai")) await updateFileIfExists(path.join(webDir, "server/api/ai.post.ts"), addNuxtAiEvlogSetup);
1924
1950
  }
1925
1951
  async function setupSvelteEvlog(config, serviceName) {
1926
1952
  const webDir = path.join(config.projectDir, "apps/web");
@@ -1933,6 +1959,7 @@ export const { handle, handleError } = createEvlogHooks();
1933
1959
  `);
1934
1960
  await updateFileIfExists(path.join(webDir, "src/app.d.ts"), addSvelteLocalsType);
1935
1961
  if (shouldIdentifyWebAuth(config)) await updateFileIfExists(path.join(webDir, "src/hooks.server.ts"), (content) => addSvelteBetterAuthEvlogSetup(content, config));
1962
+ if (config.examples.includes("ai")) await updateFileIfExists(path.join(webDir, "src/routes/api/ai/+server.ts"), addSvelteAiEvlogSetup);
1936
1963
  }
1937
1964
  async function setupTanstackStartEvlog(config, serviceName) {
1938
1965
  const webDir = path.join(config.projectDir, "apps/web");
@@ -1943,6 +1970,7 @@ async function setupTanstackStartEvlog(config, serviceName) {
1943
1970
  const authPluginPath = path.join(webDir, "server/plugins/evlog-auth.ts");
1944
1971
  if (!await fs.pathExists(authPluginPath)) await writeFileIfChanged(authPluginPath, getNitroEvlogAuthPluginFile(config));
1945
1972
  }
1973
+ if (config.examples.includes("ai")) await updateFileIfExists(path.join(webDir, "src/routes/api/ai/$.ts"), addTanstackStartAiEvlogSetup);
1946
1974
  }
1947
1975
  async function setupAstroEvlog(config, serviceName) {
1948
1976
  const webDir = path.join(config.projectDir, "apps/web");
@@ -1973,6 +2001,7 @@ async function setupEvlog(config) {
1973
2001
  const content = await fs.readFile(serverIndexPath, "utf-8");
1974
2002
  let nextContent = addEvlogServerSetup(content, config.backend, `${config.projectName}-server`);
1975
2003
  if (config.auth === "better-auth") nextContent = addEvlogBetterAuthServerSetup(nextContent, config.backend, getAuthExpression(config));
2004
+ if (config.examples.includes("ai")) nextContent = addBackendAiEvlogSetup(nextContent, config.backend);
1976
2005
  if (nextContent !== content) await fs.writeFile(serverIndexPath, nextContent);
1977
2006
  }
1978
2007
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-better-t-stack",
3
- "version": "3.36.4",
3
+ "version": "3.36.5",
4
4
  "description": "A modern CLI tool for scaffolding end-to-end type-safe TypeScript projects with best practices and customizable configurations",
5
5
  "keywords": [
6
6
  "better-auth",
@@ -69,8 +69,8 @@
69
69
  "prepublishOnly": "npm run build"
70
70
  },
71
71
  "dependencies": {
72
- "@better-t-stack/template-generator": "^3.36.4",
73
- "@better-t-stack/types": "^3.36.4",
72
+ "@better-t-stack/template-generator": "^3.36.5",
73
+ "@better-t-stack/types": "^3.36.5",
74
74
  "@clack/core": "^1.4.1",
75
75
  "@clack/prompts": "^1.5.1",
76
76
  "@modelcontextprotocol/sdk": "1.29.0",