@farm.js/create-app 0.1.51-beta.3 → 0.1.61

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/index.mjs CHANGED
@@ -173,10 +173,12 @@ Label.displayName = "Label";
173
173
  `;
174
174
  }
175
175
  }
176
- // ../farm-cli/src/ui-registry.ts
176
+ //#endregion
177
+ //#region ../farm-cli/src/ui-registry.ts
177
178
  /** Value written into a generated `components.json` as `registries.farm.url`. */
178
179
  const UI_REGISTRY_URL_TEMPLATE = "https://farmjs.dev/r/{name}.json";
179
- // ../farm-cli/src/ui-feature-registry.ts
180
+ //#endregion
181
+ //#region ../farm-cli/src/ui-feature-registry.ts
180
182
  async function installUIFeature(input) {
181
183
  const feature = input.definition.ui;
182
184
  if (!feature) {
@@ -1758,7 +1760,8 @@ function readObject(value) {
1758
1760
  function pushResultPath(list, filePath) {
1759
1761
  if (!list.includes(filePath)) list.push(filePath);
1760
1762
  }
1761
- // ../farm-cli/src/add-integration.ts
1763
+ //#endregion
1764
+ //#region ../farm-cli/src/add-integration.ts
1762
1765
  const PROVIDERS = [
1763
1766
  {
1764
1767
  provider: "ai",
@@ -1777,7 +1780,6 @@ const PROVIDERS = [
1777
1780
  notes: [
1778
1781
  "Use @ai-sdk/react useChat with api: \"/api/chat\" on the client.",
1779
1782
  "Replace model with any AI SDK provider model or Vercel AI Gateway model id.",
1780
- "The chat route answers only in development until authorize checks your session: every request spends your AI credits.",
1781
1783
  "No farm.config integration wiring is required for this route."
1782
1784
  ],
1783
1785
  ui: aiChatUIFeature(),
@@ -1786,10 +1788,6 @@ const PROVIDERS = [
1786
1788
  export const POST = aiChatRoute({
1787
1789
  model: "openai/gpt-4o-mini",
1788
1790
  system: "You are a helpful assistant.",
1789
- // Every request spends your AI credits. TODO: check the signed-in user, for
1790
- // example authorize: async ({ request }) => Boolean(await getSession(request)).
1791
- // Until then the route answers in development and refuses in production.
1792
- authorize: () => process.env.NODE_ENV === "development",
1793
1791
  });
1794
1792
  `
1795
1793
  },
@@ -2137,7 +2135,7 @@ export const autumnIntegration = autumn({
2137
2135
  "BETTER_AUTH_DATABASE_PATH"
2138
2136
  ],
2139
2137
  dependencies: {
2140
- "better-auth": "^1.6.22",
2138
+ "better-auth": "^1.5.5",
2141
2139
  "better-sqlite3": "^12.6.2"
2142
2140
  },
2143
2141
  devDependencies: { "@types/better-sqlite3": "^7.6.13" },
@@ -2167,8 +2165,7 @@ await migrations.runMigrations();
2167
2165
  {
2168
2166
  path: ".env.example",
2169
2167
  merge: "lines",
2170
- source: () => `# Generate with: openssl rand -base64 32
2171
- BETTER_AUTH_SECRET=
2168
+ source: () => `BETTER_AUTH_SECRET=replace-with-at-least-32-random-characters
2172
2169
  BETTER_AUTH_URL=http://localhost:3000
2173
2170
  BETTER_AUTH_DATABASE_PATH=better-auth.sqlite
2174
2171
  `
@@ -2211,7 +2208,7 @@ export const betterAuthIntegration = betterAuth({
2211
2208
  "AUTH_GITHUB_ID",
2212
2209
  "AUTH_GITHUB_SECRET"
2213
2210
  ],
2214
- dependencies: { "@auth/core": "^0.41.3" },
2211
+ dependencies: { "@auth/core": "0.34.3" },
2215
2212
  setupFiles: [{
2216
2213
  path: "src/lib/auth.ts",
2217
2214
  source: () => `import { Auth } from "@auth/core";
@@ -2226,8 +2223,6 @@ const config = {
2226
2223
  ],
2227
2224
  secret: process.env.AUTH_SECRET,
2228
2225
  trustHost: true,
2229
- // @farm.js/authjs serves Auth.js at /api/auth; Auth.js expects /auth otherwise.
2230
- basePath: "/api/auth",
2231
2226
  };
2232
2227
 
2233
2228
  const handler = (request: Request) => Auth(request, config);
@@ -2696,7 +2691,8 @@ function toImportPath(relativePath) {
2696
2691
  function escapeRegExp(input) {
2697
2692
  return input.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2698
2693
  }
2699
- // ../farm-cli/src/telemetry-contract.ts
2694
+ //#endregion
2695
+ //#region ../farm-cli/src/telemetry-contract.ts
2700
2696
  const FARM_CREATE_APP_TELEMETRY_COMMANDS = ["create", "list-templates"];
2701
2697
  const FARM_TELEMETRY_TEMPLATES = [
2702
2698
  "basic",
@@ -2732,7 +2728,8 @@ const FARM_TELEMETRY_PACKAGE_MANAGERS = [
2732
2728
  "yarn",
2733
2729
  "bun"
2734
2730
  ];
2735
- // ../farm-cli/src/telemetry.ts
2731
+ //#endregion
2732
+ //#region ../farm-cli/src/telemetry.ts
2736
2733
  const TELEMETRY_SCHEMA_VERSION = 1;
2737
2734
  const DEFAULT_TELEMETRY_ENDPOINT = "https://farmjs.dev/api/telemetry/v1/events";
2738
2735
  const TELEMETRY_NOTICE_URL = "https://farmjs.dev/docs/telemetry";
@@ -3058,7 +3055,8 @@ function normalizePlatform(value) {
3058
3055
  function normalizeArchitecture(value) {
3059
3056
  return value === "arm64" || value === "x64" ? value : "other";
3060
3057
  }
3061
- // src/index.ts
3058
+ //#endregion
3059
+ //#region src/index.ts
3062
3060
  const templateDetails = {
3063
3061
  basic: {
3064
3062
  title: "Basic starter",
@@ -3073,7 +3071,7 @@ const templateDetails = {
3073
3071
  auth: {
3074
3072
  title: "Auth starter",
3075
3073
  description: "Farm.js-native auth with local SQLite, secure sessions, and protected routes",
3076
- instructions: ["FARMJS Auth uses local SQLite automatically and generates a random .farm/auth-secret; no auth environment variables are needed locally.", "For production, set FARM_AUTH_URL, FARM_AUTH_SECRET, and DATABASE_URL, then run the auth:migrate script."]
3074
+ instructions: ["FARMJS Auth uses local SQLite automatically; no auth environment variables are needed locally.", "For production, set FARM_AUTH_URL, FARM_AUTH_SECRET, and DATABASE_URL, then run the auth:migrate script."]
3077
3075
  },
3078
3076
  "better-auth": {
3079
3077
  title: "Better Auth starter",
@@ -3346,7 +3344,7 @@ async function createApp(projectName, options = {}) {
3346
3344
  if (integrationResult) {
3347
3345
  const details = templateDetails[template].integration;
3348
3346
  logger.info(`Open ${details.route} for the ${details.label} starter.`);
3349
- if (integrationResult.env.length) logger.info("Copy .env.example to .env.local, add your provider credentials, and generate any empty secret with openssl rand -base64 32.");
3347
+ if (integrationResult.env.length) logger.info("Copy .env.example to .env.local and add your provider credentials.");
3350
3348
  for (const note of integrationResult.notes) logger.info(note);
3351
3349
  }
3352
3350
  trackFarmProjectCreated({
@@ -3477,20 +3475,14 @@ async function writeEnvironmentExample(projectPath, keys) {
3477
3475
  current = await fs.readFile(envPath, "utf8");
3478
3476
  } catch {}
3479
3477
  const existingKeys = new Set(current.split(/\r?\n/).map((line) => line.match(/^([A-Z][A-Z0-9_]*)=/)?.[1]).filter((key) => Boolean(key)));
3480
- const additions = keys.filter((key) => !existingKeys.has(key)).flatMap((key) => environmentExampleLines(key));
3478
+ const additions = keys.filter((key) => !existingKeys.has(key)).map((key) => `${key}=${environmentExampleValue(key)}`);
3481
3479
  if (additions.length > 0) await fs.writeFile(envPath, `${current.trimEnd()}${current.trim() ? "\n" : ""}${additions.join("\n")}\n`, "utf8");
3482
3480
  }
3483
- const GENERATED_SECRET_KEYS = /* @__PURE__ */ new Set([
3484
- "AUTH_SECRET",
3485
- "AUTH0_SECRET",
3486
- "BETTER_AUTH_SECRET",
3487
- "WORKOS_COOKIE_PASSWORD"
3488
- ]);
3489
- function environmentExampleLines(key) {
3490
- if (GENERATED_SECRET_KEYS.has(key)) return ["# Generate with: openssl rand -base64 32", `${key}=`];
3491
- if (key === "APP_BASE_URL") return [`${key}=http://localhost:3000`];
3492
- if (key === "UNKEY_BASE_URL") return [`${key}=https://api.unkey.com`];
3493
- return [`${key}=`];
3481
+ function environmentExampleValue(key) {
3482
+ if (key === "APP_BASE_URL") return "http://localhost:3000";
3483
+ if (key === "AUTH_SECRET") return "replace-with-at-least-32-random-characters";
3484
+ if (key === "UNKEY_BASE_URL") return "https://api.unkey.com";
3485
+ return "";
3494
3486
  }
3495
3487
  async function writeIntegrationHomePage(projectPath, integration, hasEnvironment) {
3496
3488
  const commandRows = [...hasEnvironment ? ["cp .env.example .env.local"] : [], "pnpm dev"].map((command, index) => ` <div className="command-row">
@@ -3530,8 +3522,8 @@ ${commandRows}
3530
3522
  await fs.writeFile(path.join(projectPath, "src", "app", "page.tsx"), source, "utf8");
3531
3523
  }
3532
3524
  async function writeIntegrationReadme(projectPath, integration, env) {
3533
- const environmentSetup = env.length ? `cp .env.example .env.local\n# Add values for: ${env.join(", ")}\n# Generate secrets with: openssl rand -base64 32\n` : "";
3534
- const wiring = integration.provider === "ai" ? "The AI route lives in `src/app/api/chat/route.ts` and its local UI lives under `src/components/farm`. Every request spends your AI credits, so the route answers only in development until its `authorize` checks a signed-in user." : "The provider wiring lives in `src/lib/integrations` and is registered from `farm.config.ts`.";
3525
+ const environmentSetup = env.length ? `cp .env.example .env.local\n# Add values for: ${env.join(", ")}\n` : "";
3526
+ const wiring = integration.provider === "ai" ? "The AI route lives in `src/app/api/chat/route.ts` and its local UI lives under `src/components/farm`." : "The provider wiring lives in `src/lib/integrations` and is registered from `farm.config.ts`.";
3535
3527
  const source = `# FARMJS ${integration.label} Starter
3536
3528
 
3537
3529
  ## Getting started
@@ -3624,7 +3616,8 @@ function detectPackageManager(userAgent = process.env.npm_config_user_agent) {
3624
3616
  function installDependencies(projectPath, packageManager) {
3625
3617
  return new Promise((resolve, reject) => {
3626
3618
  const isWindows = process.platform === "win32";
3627
- const child = spawn(packageManager.name, ["install"], {
3619
+ const command = isWindows ? `${packageManager.name}.cmd` : packageManager.name;
3620
+ const child = spawn(command, ["install"], {
3628
3621
  cwd: projectPath,
3629
3622
  env: process.env,
3630
3623
  stdio: "inherit",
@@ -3674,6 +3667,7 @@ async function updatePackageManagerInstructions(projectPath, packageManager) {
3674
3667
  }
3675
3668
  }));
3676
3669
  }
3670
+ //#endregion
3677
3671
  export { createApp, detectPackageManager, installDependencies };
3678
3672
 
3679
3673
  //# sourceMappingURL=index.mjs.map