create-kubojs 0.5.0 → 0.5.1

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, g as setTelemetrySource, i as SchemaNameSchema, l as create, m as getSchemaResult, s as add, u as createBtsCli, v as getLatestCLIVersion } from "./src-QAuuh4xm.mjs";
2
+ import { _ as types_exports, g as setTelemetrySource, i as SchemaNameSchema, l as create, m as getSchemaResult, s as add, u as createBtsCli, v as getLatestCLIVersion } from "./src-DdCJmpnU.mjs";
3
3
  import z from "zod";
4
4
  import { format } from "node:util";
5
5
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.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, 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-QAuuh4xm.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, 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-DdCJmpnU.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 };
@@ -21,6 +21,7 @@ import { writeSelected, writeTree } from "@kubojs/template-generator/fs-writer";
21
21
  import { ConfirmPrompt, GroupMultiSelectPrompt, MultiSelectPrompt, SelectPrompt, TextPrompt, isCancel as isCancel$1, isCancel as isCancel$2 } from "@clack/core";
22
22
  import { createJiti } from "jiti";
23
23
  import { parse } from "jsonc-parser";
24
+ import { randomUUID } from "node:crypto";
24
25
  import os from "node:os";
25
26
  import { format } from "oxfmt";
26
27
  import { Generator, configSchema } from "@tanstack/router-generator";
@@ -4182,7 +4183,58 @@ async function getProjectName(initialName) {
4182
4183
  return projectPath;
4183
4184
  }
4184
4185
  //#endregion
4186
+ //#region src/utils/telemetry.ts
4187
+ const TRUTHY = new Set([
4188
+ "1",
4189
+ "true",
4190
+ "yes"
4191
+ ]);
4192
+ function isTruthy(value) {
4193
+ return value !== void 0 && TRUTHY.has(value.toLowerCase());
4194
+ }
4195
+ /**
4196
+ * Returns true if telemetry/analytics should be enabled, false otherwise.
4197
+ *
4198
+ * Opt-out, checked in order:
4199
+ * - `KUBO_TELEMETRY_DISABLED=1` disables.
4200
+ * - `DO_NOT_TRACK=1` disables (https://consoledonottrack.com).
4201
+ * - Legacy `BTS_TELEMETRY_DISABLED=1` disables; legacy `BTS_TELEMETRY=0` disables.
4202
+ * - Otherwise enabled.
4203
+ */
4204
+ function isTelemetryEnabled(env = process.env) {
4205
+ if (isTruthy(env.KUBO_TELEMETRY_DISABLED)) return false;
4206
+ if (isTruthy(env.DO_NOT_TRACK)) return false;
4207
+ if (env.BTS_TELEMETRY_DISABLED !== void 0) return env.BTS_TELEMETRY_DISABLED !== "1";
4208
+ if (env.BTS_TELEMETRY !== void 0) return env.BTS_TELEMETRY === "1";
4209
+ return true;
4210
+ }
4211
+ /** Coding agents we can recognize from the environment they set for child processes. */
4212
+ const AGENT_ENV_MARKERS = [
4213
+ ["claude-code", "CLAUDECODE"],
4214
+ ["cursor", "CURSOR_AGENT"],
4215
+ ["cursor", "CURSOR_TRACE_ID"],
4216
+ ["codex", "CODEX_SANDBOX"],
4217
+ ["codex", "CODEX_MANAGED_BY_NPM"],
4218
+ ["gemini-cli", "GEMINI_CLI"],
4219
+ ["opencode", "OPENCODE"],
4220
+ ["amp", "AMP_CURRENT_THREAD_ID"],
4221
+ ["cline", "CLINE_ACTIVE"],
4222
+ ["replit", "REPL_ID"]
4223
+ ];
4224
+ function detectAgent(env = process.env) {
4225
+ const match = AGENT_ENV_MARKERS.find(([, envVar]) => Boolean(env[envVar]));
4226
+ if (match) return match[0];
4227
+ return env.AI_AGENT ? "other" : void 0;
4228
+ }
4229
+ function isCI(env = process.env) {
4230
+ return isTruthy(env.CI) || Boolean(env.GITHUB_ACTIONS || env.GITLAB_CI || env.BUILDKITE || env.CIRCLECI);
4231
+ }
4232
+ //#endregion
4185
4233
  //#region src/utils/analytics.ts
4234
+ const CONVEX_INGEST_URL = "https://moonlit-seal-677.convex.site/api/analytics/ingest";
4235
+ const SEND_TIMEOUT_MS = 2e3;
4236
+ const TELEMETRY_FILE = "telemetry.json";
4237
+ const TELEMETRY_DOCS_URL = "https://kubojs.dev/docs/analytics";
4186
4238
  let telemetrySource = "cli";
4187
4239
  /** Set once per process by entry points that are not the interactive terminal (e.g. MCP). */
4188
4240
  function setTelemetrySource(source) {
@@ -4192,7 +4244,102 @@ function setTelemetrySource(source) {
4192
4244
  function markProgrammaticTelemetrySource() {
4193
4245
  if (telemetrySource === "cli") telemetrySource = "api";
4194
4246
  }
4195
- async function trackCreateEvent(event, disableAnalytics = false) {}
4247
+ function getTelemetryFilePath() {
4248
+ return path.join(envPaths("kubojs", { suffix: "" }).config, TELEMETRY_FILE);
4249
+ }
4250
+ function isTelemetryState(value) {
4251
+ return typeof value === "object" && value !== null && "installId" in value && typeof value.installId === "string" && "noticeShown" in value && typeof value.noticeShown === "boolean";
4252
+ }
4253
+ /**
4254
+ * Reads the anonymous install id (a random UUID, not derived from the machine or user),
4255
+ * creating it on first use. Returns undefined if the config dir is not writable.
4256
+ */
4257
+ async function loadTelemetryState() {
4258
+ const filePath = getTelemetryFilePath();
4259
+ const existing = await Result.tryPromise({
4260
+ try: async () => fs.readJson(filePath),
4261
+ catch: () => void 0
4262
+ });
4263
+ if (existing.isOk() && isTelemetryState(existing.value)) return existing.value;
4264
+ const state = {
4265
+ installId: randomUUID(),
4266
+ noticeShown: false
4267
+ };
4268
+ return (await Result.tryPromise({
4269
+ try: async () => {
4270
+ await fs.ensureDir(path.dirname(filePath));
4271
+ await fs.writeJson(filePath, state, { spaces: 2 });
4272
+ },
4273
+ catch: () => void 0
4274
+ })).isOk() ? state : void 0;
4275
+ }
4276
+ async function markNoticeShown(state) {
4277
+ await Result.tryPromise({
4278
+ try: () => fs.writeJson(getTelemetryFilePath(), {
4279
+ ...state,
4280
+ noticeShown: true
4281
+ }, { spaces: 2 }),
4282
+ catch: () => void 0
4283
+ });
4284
+ }
4285
+ function showTelemetryNotice() {
4286
+ log.info(pc.dim(`kubojs collects anonymous usage data (stack choices, CLI version, OS) to guide development.
4287
+ No project names, paths or personal data. Opt out with KUBO_TELEMETRY_DISABLED=1.
4288
+ Details: ${TELEMETRY_DOCS_URL}`));
4289
+ }
4290
+ async function sendConvexEvent(payload) {
4291
+ await Result.tryPromise({
4292
+ try: () => fetch(CONVEX_INGEST_URL, {
4293
+ method: "POST",
4294
+ headers: { "Content-Type": "application/json" },
4295
+ body: JSON.stringify(payload),
4296
+ signal: AbortSignal.timeout(SEND_TIMEOUT_MS)
4297
+ }),
4298
+ catch: () => void 0
4299
+ });
4300
+ }
4301
+ function getStackPayload(config) {
4302
+ return {
4303
+ database: config.database,
4304
+ orm: config.orm,
4305
+ backend: config.backend,
4306
+ runtime: config.runtime,
4307
+ frontend: config.frontend,
4308
+ addons: config.addons,
4309
+ examples: config.examples,
4310
+ auth: config.auth,
4311
+ payments: config.payments,
4312
+ git: config.git,
4313
+ packageManager: config.packageManager,
4314
+ install: config.install,
4315
+ dbSetup: config.dbSetup,
4316
+ api: config.api,
4317
+ webDeploy: config.webDeploy,
4318
+ serverDeploy: config.serverDeploy
4319
+ };
4320
+ }
4321
+ async function trackCreateEvent(event, disableAnalytics = false) {
4322
+ if (!isTelemetryEnabled() || disableAnalytics) return;
4323
+ const state = await loadTelemetryState();
4324
+ if (state && !state.noticeShown && !isSilent()) {
4325
+ showTelemetryNotice();
4326
+ await markNoticeShown(state);
4327
+ }
4328
+ await sendConvexEvent({
4329
+ ...event.config ? getStackPayload(event.config) : {},
4330
+ install_id: state?.installId,
4331
+ source: telemetrySource,
4332
+ mode: event.mode,
4333
+ agent: detectAgent(),
4334
+ ci: isCI(),
4335
+ outcome: event.outcome,
4336
+ error_category: event.errorCategory,
4337
+ duration_ms: event.durationMs,
4338
+ cli_version: getLatestCLIVersion(),
4339
+ node_version: process.version,
4340
+ platform: process.platform
4341
+ });
4342
+ }
4196
4343
  //#endregion
4197
4344
  //#region src/utils/display-config.ts
4198
4345
  function displayConfig(config) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-kubojs",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
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",
@@ -73,8 +73,8 @@
73
73
  "dependencies": {
74
74
  "@clack/core": "^1.4.1",
75
75
  "@clack/prompts": "^1.5.1",
76
- "@kubojs/template-generator": "^0.5.0",
77
- "@kubojs/types": "^0.5.0",
76
+ "@kubojs/template-generator": "^0.5.1",
77
+ "@kubojs/types": "^0.5.1",
78
78
  "@modelcontextprotocol/sdk": "1.29.0",
79
79
  "@tanstack/router-generator": "1.167.28",
80
80
  "@trpc/server": "^11.17.0",