@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.js CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_rolldown_runtime = require("./rolldown-runtime-CmQyd0Gu.js");
2
+ const require_rolldown_runtime = require("./rolldown-runtime-VH7oDXx4.js");
3
3
  const require_utils = require("./utils.js");
4
4
  let prompts = require("prompts");
5
5
  prompts = require_rolldown_runtime.__toESM(prompts);
@@ -180,10 +180,12 @@ Label.displayName = "Label";
180
180
  `;
181
181
  }
182
182
  }
183
- // ../farm-cli/src/ui-registry.ts
183
+ //#endregion
184
+ //#region ../farm-cli/src/ui-registry.ts
184
185
  /** Value written into a generated `components.json` as `registries.farm.url`. */
185
186
  const UI_REGISTRY_URL_TEMPLATE = "https://farmjs.dev/r/{name}.json";
186
- // ../farm-cli/src/ui-feature-registry.ts
187
+ //#endregion
188
+ //#region ../farm-cli/src/ui-feature-registry.ts
187
189
  async function installUIFeature(input) {
188
190
  const feature = input.definition.ui;
189
191
  if (!feature) {
@@ -1765,7 +1767,8 @@ function readObject(value) {
1765
1767
  function pushResultPath(list, filePath) {
1766
1768
  if (!list.includes(filePath)) list.push(filePath);
1767
1769
  }
1768
- // ../farm-cli/src/add-integration.ts
1770
+ //#endregion
1771
+ //#region ../farm-cli/src/add-integration.ts
1769
1772
  const PROVIDERS = [
1770
1773
  {
1771
1774
  provider: "ai",
@@ -1784,7 +1787,6 @@ const PROVIDERS = [
1784
1787
  notes: [
1785
1788
  "Use @ai-sdk/react useChat with api: \"/api/chat\" on the client.",
1786
1789
  "Replace model with any AI SDK provider model or Vercel AI Gateway model id.",
1787
- "The chat route answers only in development until authorize checks your session: every request spends your AI credits.",
1788
1790
  "No farm.config integration wiring is required for this route."
1789
1791
  ],
1790
1792
  ui: aiChatUIFeature(),
@@ -1793,10 +1795,6 @@ const PROVIDERS = [
1793
1795
  export const POST = aiChatRoute({
1794
1796
  model: "openai/gpt-4o-mini",
1795
1797
  system: "You are a helpful assistant.",
1796
- // Every request spends your AI credits. TODO: check the signed-in user, for
1797
- // example authorize: async ({ request }) => Boolean(await getSession(request)).
1798
- // Until then the route answers in development and refuses in production.
1799
- authorize: () => process.env.NODE_ENV === "development",
1800
1798
  });
1801
1799
  `
1802
1800
  },
@@ -2144,7 +2142,7 @@ export const autumnIntegration = autumn({
2144
2142
  "BETTER_AUTH_DATABASE_PATH"
2145
2143
  ],
2146
2144
  dependencies: {
2147
- "better-auth": "^1.6.22",
2145
+ "better-auth": "^1.5.5",
2148
2146
  "better-sqlite3": "^12.6.2"
2149
2147
  },
2150
2148
  devDependencies: { "@types/better-sqlite3": "^7.6.13" },
@@ -2174,8 +2172,7 @@ await migrations.runMigrations();
2174
2172
  {
2175
2173
  path: ".env.example",
2176
2174
  merge: "lines",
2177
- source: () => `# Generate with: openssl rand -base64 32
2178
- BETTER_AUTH_SECRET=
2175
+ source: () => `BETTER_AUTH_SECRET=replace-with-at-least-32-random-characters
2179
2176
  BETTER_AUTH_URL=http://localhost:3000
2180
2177
  BETTER_AUTH_DATABASE_PATH=better-auth.sqlite
2181
2178
  `
@@ -2218,7 +2215,7 @@ export const betterAuthIntegration = betterAuth({
2218
2215
  "AUTH_GITHUB_ID",
2219
2216
  "AUTH_GITHUB_SECRET"
2220
2217
  ],
2221
- dependencies: { "@auth/core": "^0.41.3" },
2218
+ dependencies: { "@auth/core": "0.34.3" },
2222
2219
  setupFiles: [{
2223
2220
  path: "src/lib/auth.ts",
2224
2221
  source: () => `import { Auth } from "@auth/core";
@@ -2233,8 +2230,6 @@ const config = {
2233
2230
  ],
2234
2231
  secret: process.env.AUTH_SECRET,
2235
2232
  trustHost: true,
2236
- // @farm.js/authjs serves Auth.js at /api/auth; Auth.js expects /auth otherwise.
2237
- basePath: "/api/auth",
2238
2233
  };
2239
2234
 
2240
2235
  const handler = (request: Request) => Auth(request, config);
@@ -2703,7 +2698,8 @@ function toImportPath(relativePath) {
2703
2698
  function escapeRegExp(input) {
2704
2699
  return input.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2705
2700
  }
2706
- // ../farm-cli/src/telemetry-contract.ts
2701
+ //#endregion
2702
+ //#region ../farm-cli/src/telemetry-contract.ts
2707
2703
  const FARM_CREATE_APP_TELEMETRY_COMMANDS = ["create", "list-templates"];
2708
2704
  const FARM_TELEMETRY_TEMPLATES = [
2709
2705
  "basic",
@@ -2739,7 +2735,8 @@ const FARM_TELEMETRY_PACKAGE_MANAGERS = [
2739
2735
  "yarn",
2740
2736
  "bun"
2741
2737
  ];
2742
- // ../farm-cli/src/telemetry.ts
2738
+ //#endregion
2739
+ //#region ../farm-cli/src/telemetry.ts
2743
2740
  const TELEMETRY_SCHEMA_VERSION = 1;
2744
2741
  const DEFAULT_TELEMETRY_ENDPOINT = "https://farmjs.dev/api/telemetry/v1/events";
2745
2742
  const TELEMETRY_NOTICE_URL = "https://farmjs.dev/docs/telemetry";
@@ -3065,7 +3062,8 @@ function normalizePlatform(value) {
3065
3062
  function normalizeArchitecture(value) {
3066
3063
  return value === "arm64" || value === "x64" ? value : "other";
3067
3064
  }
3068
- // src/index.ts
3065
+ //#endregion
3066
+ //#region src/index.ts
3069
3067
  const templateDetails = {
3070
3068
  basic: {
3071
3069
  title: "Basic starter",
@@ -3080,7 +3078,7 @@ const templateDetails = {
3080
3078
  auth: {
3081
3079
  title: "Auth starter",
3082
3080
  description: "Farm.js-native auth with local SQLite, secure sessions, and protected routes",
3083
- 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."]
3081
+ 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."]
3084
3082
  },
3085
3083
  "better-auth": {
3086
3084
  title: "Better Auth starter",
@@ -3353,7 +3351,7 @@ async function createApp(projectName, options = {}) {
3353
3351
  if (integrationResult) {
3354
3352
  const details = templateDetails[template].integration;
3355
3353
  require_utils.logger.info(`Open ${details.route} for the ${details.label} starter.`);
3356
- if (integrationResult.env.length) require_utils.logger.info("Copy .env.example to .env.local, add your provider credentials, and generate any empty secret with openssl rand -base64 32.");
3354
+ if (integrationResult.env.length) require_utils.logger.info("Copy .env.example to .env.local and add your provider credentials.");
3357
3355
  for (const note of integrationResult.notes) require_utils.logger.info(note);
3358
3356
  }
3359
3357
  trackFarmProjectCreated({
@@ -3484,20 +3482,14 @@ async function writeEnvironmentExample(projectPath, keys) {
3484
3482
  current = await fs_promises.default.readFile(envPath, "utf8");
3485
3483
  } catch {}
3486
3484
  const existingKeys = new Set(current.split(/\r?\n/).map((line) => line.match(/^([A-Z][A-Z0-9_]*)=/)?.[1]).filter((key) => Boolean(key)));
3487
- const additions = keys.filter((key) => !existingKeys.has(key)).flatMap((key) => environmentExampleLines(key));
3485
+ const additions = keys.filter((key) => !existingKeys.has(key)).map((key) => `${key}=${environmentExampleValue(key)}`);
3488
3486
  if (additions.length > 0) await fs_promises.default.writeFile(envPath, `${current.trimEnd()}${current.trim() ? "\n" : ""}${additions.join("\n")}\n`, "utf8");
3489
3487
  }
3490
- const GENERATED_SECRET_KEYS = /* @__PURE__ */ new Set([
3491
- "AUTH_SECRET",
3492
- "AUTH0_SECRET",
3493
- "BETTER_AUTH_SECRET",
3494
- "WORKOS_COOKIE_PASSWORD"
3495
- ]);
3496
- function environmentExampleLines(key) {
3497
- if (GENERATED_SECRET_KEYS.has(key)) return ["# Generate with: openssl rand -base64 32", `${key}=`];
3498
- if (key === "APP_BASE_URL") return [`${key}=http://localhost:3000`];
3499
- if (key === "UNKEY_BASE_URL") return [`${key}=https://api.unkey.com`];
3500
- return [`${key}=`];
3488
+ function environmentExampleValue(key) {
3489
+ if (key === "APP_BASE_URL") return "http://localhost:3000";
3490
+ if (key === "AUTH_SECRET") return "replace-with-at-least-32-random-characters";
3491
+ if (key === "UNKEY_BASE_URL") return "https://api.unkey.com";
3492
+ return "";
3501
3493
  }
3502
3494
  async function writeIntegrationHomePage(projectPath, integration, hasEnvironment) {
3503
3495
  const commandRows = [...hasEnvironment ? ["cp .env.example .env.local"] : [], "pnpm dev"].map((command, index) => ` <div className="command-row">
@@ -3537,8 +3529,8 @@ ${commandRows}
3537
3529
  await fs_promises.default.writeFile(path.default.join(projectPath, "src", "app", "page.tsx"), source, "utf8");
3538
3530
  }
3539
3531
  async function writeIntegrationReadme(projectPath, integration, env) {
3540
- const environmentSetup = env.length ? `cp .env.example .env.local\n# Add values for: ${env.join(", ")}\n# Generate secrets with: openssl rand -base64 32\n` : "";
3541
- 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`.";
3532
+ const environmentSetup = env.length ? `cp .env.example .env.local\n# Add values for: ${env.join(", ")}\n` : "";
3533
+ 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`.";
3542
3534
  const source = `# FARMJS ${integration.label} Starter
3543
3535
 
3544
3536
  ## Getting started
@@ -3631,7 +3623,8 @@ function detectPackageManager(userAgent = process.env.npm_config_user_agent) {
3631
3623
  function installDependencies(projectPath, packageManager) {
3632
3624
  return new Promise((resolve, reject) => {
3633
3625
  const isWindows = process.platform === "win32";
3634
- const child = (0, node_child_process.spawn)(packageManager.name, ["install"], {
3626
+ const command = isWindows ? `${packageManager.name}.cmd` : packageManager.name;
3627
+ const child = (0, node_child_process.spawn)(command, ["install"], {
3635
3628
  cwd: projectPath,
3636
3629
  env: process.env,
3637
3630
  stdio: "inherit",
@@ -3681,6 +3674,7 @@ async function updatePackageManagerInstructions(projectPath, packageManager) {
3681
3674
  }
3682
3675
  }));
3683
3676
  }
3677
+ //#endregion
3684
3678
  exports.createApp = createApp;
3685
3679
  exports.detectPackageManager = detectPackageManager;
3686
3680
  exports.installDependencies = installDependencies;