@concavejs/cli 0.0.1-alpha.8 → 0.0.1-alpha.9

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.js CHANGED
@@ -3921,7 +3921,7 @@ ${file}:${line}:${column}: ERROR: ${pluginText}${e.text}`;
3921
3921
  }
3922
3922
  var fs8 = __require("fs");
3923
3923
  var os = __require("os");
3924
- var path10 = __require("path");
3924
+ var path11 = __require("path");
3925
3925
  var ESBUILD_BINARY_PATH = process.env.ESBUILD_BINARY_PATH || ESBUILD_BINARY_PATH;
3926
3926
  var isValidBinaryPath = (x) => !!x && x !== "/usr/bin/esbuild";
3927
3927
  var packageDarwin_arm64 = "@esbuild/darwin-arm64";
@@ -3979,19 +3979,19 @@ ${file}:${line}:${column}: ERROR: ${pluginText}${e.text}`;
3979
3979
  }
3980
3980
  function pkgForSomeOtherPlatform() {
3981
3981
  const libMainJS = __require.resolve("esbuild");
3982
- const nodeModulesDirectory = path10.dirname(path10.dirname(path10.dirname(libMainJS)));
3983
- if (path10.basename(nodeModulesDirectory) === "node_modules") {
3982
+ const nodeModulesDirectory = path11.dirname(path11.dirname(path11.dirname(libMainJS)));
3983
+ if (path11.basename(nodeModulesDirectory) === "node_modules") {
3984
3984
  for (const unixKey in knownUnixlikePackages) {
3985
3985
  try {
3986
3986
  const pkg = knownUnixlikePackages[unixKey];
3987
- if (fs8.existsSync(path10.join(nodeModulesDirectory, pkg)))
3987
+ if (fs8.existsSync(path11.join(nodeModulesDirectory, pkg)))
3988
3988
  return pkg;
3989
3989
  } catch {}
3990
3990
  }
3991
3991
  for (const windowsKey in knownWindowsPackages) {
3992
3992
  try {
3993
3993
  const pkg = knownWindowsPackages[windowsKey];
3994
- if (fs8.existsSync(path10.join(nodeModulesDirectory, pkg)))
3994
+ if (fs8.existsSync(path11.join(nodeModulesDirectory, pkg)))
3995
3995
  return pkg;
3996
3996
  } catch {}
3997
3997
  }
@@ -3999,8 +3999,8 @@ ${file}:${line}:${column}: ERROR: ${pluginText}${e.text}`;
3999
3999
  return null;
4000
4000
  }
4001
4001
  function downloadedBinPath(pkg, subpath) {
4002
- const esbuildLibDir = path10.dirname(__require.resolve("esbuild"));
4003
- return path10.join(esbuildLibDir, `downloaded-${pkg.replace("/", "-")}-${path10.basename(subpath)}`);
4002
+ const esbuildLibDir = path11.dirname(__require.resolve("esbuild"));
4003
+ return path11.join(esbuildLibDir, `downloaded-${pkg.replace("/", "-")}-${path11.basename(subpath)}`);
4004
4004
  }
4005
4005
  function generateBinPath() {
4006
4006
  if (isValidBinaryPath(ESBUILD_BINARY_PATH)) {
@@ -4089,9 +4089,9 @@ for your current platform.`);
4089
4089
  } catch (e) {}
4090
4090
  if (pnpapi) {
4091
4091
  const root = pnpapi.getPackageInformation(pnpapi.topLevel).packageLocation;
4092
- const binTargetPath = path10.join(root, "node_modules", ".cache", "esbuild", `pnpapi-${pkg.replace("/", "-")}-${"0.24.2"}-${path10.basename(subpath)}`);
4092
+ const binTargetPath = path11.join(root, "node_modules", ".cache", "esbuild", `pnpapi-${pkg.replace("/", "-")}-${"0.24.2"}-${path11.basename(subpath)}`);
4093
4093
  if (!fs8.existsSync(binTargetPath)) {
4094
- fs8.mkdirSync(path10.dirname(binTargetPath), { recursive: true });
4094
+ fs8.mkdirSync(path11.dirname(binTargetPath), { recursive: true });
4095
4095
  fs8.copyFileSync(binPath, binTargetPath);
4096
4096
  fs8.chmodSync(binTargetPath, 493);
4097
4097
  }
@@ -5017,6 +5017,7 @@ for (const { componentPath, loader } of componentLoaders) {
5017
5017
  const runtime = defineConcaveRuntime(${runtimeOptions});
5018
5018
  export const ConcaveDO = runtime.ConcaveDO;
5019
5019
  export const SyncDO = runtime.SyncDO;
5020
+ export const SyncCoordinatorDO = runtime.SyncCoordinatorDO;
5020
5021
  export { UdfExecutorRpc };
5021
5022
  export default runtime.worker;
5022
5023
  `;
@@ -5484,7 +5485,7 @@ function getProjectName(state, projectRoot) {
5484
5485
  // src/cli/deploy/cloudflare.ts
5485
5486
  var import_picocolors2 = __toESM(require_picocolors(), 1);
5486
5487
  import { promises as fs7 } from "node:fs";
5487
- import path9 from "node:path";
5488
+ import path10 from "node:path";
5488
5489
 
5489
5490
  // src/cli/artifacts.ts
5490
5491
  import { cp, copyFile, mkdir, readFile, rm, stat, writeFile } from "node:fs/promises";
@@ -5595,7 +5596,147 @@ async function copyIfDifferent(source, destination) {
5595
5596
  }
5596
5597
 
5597
5598
  // src/cli/deploy/resources.ts
5598
- import { spawn } from "node:child_process";
5599
+ import {
5600
+ spawn
5601
+ } from "node:child_process";
5602
+
5603
+ // src/cli/deploy/wrangler-launcher.ts
5604
+ import { accessSync, constants as fsConstants } from "node:fs";
5605
+ import path8 from "node:path";
5606
+ var WRANGLER_LAUNCHERS = [
5607
+ { command: "wrangler", argsPrefix: [], description: "wrangler" },
5608
+ { command: "bunx", argsPrefix: ["wrangler"], description: "bunx wrangler" },
5609
+ { command: "npx", argsPrefix: ["wrangler"], description: "npx wrangler" },
5610
+ { command: "npm", argsPrefix: ["exec", "--", "wrangler"], description: "npm exec -- wrangler" },
5611
+ { command: "pnpm", argsPrefix: ["exec", "wrangler"], description: "pnpm exec wrangler" }
5612
+ ];
5613
+ var WRANGLER_BIN_NOT_FOUND_MESSAGE = "Wrangler CLI is not available. Install it with `bun add -d wrangler` or `npm install -D wrangler`, or install `wrangler` globally.";
5614
+
5615
+ class WranglerNotFoundError extends Error {
5616
+ constructor(message = WRANGLER_BIN_NOT_FOUND_MESSAGE) {
5617
+ super(message);
5618
+ this.name = "WranglerNotFoundError";
5619
+ }
5620
+ }
5621
+ function resolveWranglerLauncher(options = {}) {
5622
+ const cwd = options.cwd || process.cwd();
5623
+ const env = options.env || process.env;
5624
+ const localBin = findLocalWranglerBin(cwd);
5625
+ if (localBin) {
5626
+ return {
5627
+ command: localBin,
5628
+ argsPrefix: [],
5629
+ description: "local node_modules/.bin/wrangler"
5630
+ };
5631
+ }
5632
+ for (const launcher of WRANGLER_LAUNCHERS) {
5633
+ if (isCommandAvailable(launcher.command, env)) {
5634
+ return launcher;
5635
+ }
5636
+ }
5637
+ const attempted = WRANGLER_LAUNCHERS.map((launcher) => launcher.description).join(", ");
5638
+ throw new WranglerNotFoundError(`${WRANGLER_BIN_NOT_FOUND_MESSAGE} Tried: ${attempted}.`);
5639
+ }
5640
+ function findLocalWranglerBin(cwd) {
5641
+ const candidates = process.platform === "win32" ? ["wrangler.cmd", "wrangler.exe", "wrangler"] : ["wrangler"];
5642
+ for (const dir of walkUpDirectories(cwd)) {
5643
+ const binDir = path8.join(dir, "node_modules", ".bin");
5644
+ for (const candidate of candidates) {
5645
+ const fullPath = path8.join(binDir, candidate);
5646
+ if (isExecutable(fullPath)) {
5647
+ return fullPath;
5648
+ }
5649
+ }
5650
+ }
5651
+ return null;
5652
+ }
5653
+ function isCommandAvailable(command, env) {
5654
+ return resolveOnPath(command, env) !== null;
5655
+ }
5656
+ function resolveOnPath(command, env) {
5657
+ if (hasPathSeparator(command)) {
5658
+ return isExecutable(command) ? command : null;
5659
+ }
5660
+ const pathValue = getEnvVar(env, "PATH") || "";
5661
+ const pathEntries = pathValue.split(path8.delimiter).filter((entry) => entry.length > 0);
5662
+ const commandNames = getCommandNamesForPlatform(command, env);
5663
+ for (const entry of pathEntries) {
5664
+ for (const commandName of commandNames) {
5665
+ const candidate = path8.join(entry, commandName);
5666
+ if (isExecutable(candidate)) {
5667
+ return candidate;
5668
+ }
5669
+ }
5670
+ }
5671
+ return null;
5672
+ }
5673
+ function getCommandNamesForPlatform(command, env) {
5674
+ if (process.platform !== "win32") {
5675
+ return [command];
5676
+ }
5677
+ if (path8.extname(command)) {
5678
+ return [command];
5679
+ }
5680
+ const pathExt = getEnvVar(env, "PATHEXT") || ".COM;.EXE;.BAT;.CMD";
5681
+ const extensions = pathExt.split(";").map((ext) => ext.trim()).filter((ext) => ext.length > 0);
5682
+ return [command, ...extensions.map((ext) => `${command}${ext}`)];
5683
+ }
5684
+ function hasPathSeparator(command) {
5685
+ return command.includes("/") || command.includes("\\");
5686
+ }
5687
+ function walkUpDirectories(startDir) {
5688
+ const directories = [];
5689
+ let current = path8.resolve(startDir);
5690
+ while (true) {
5691
+ directories.push(current);
5692
+ const parent = path8.dirname(current);
5693
+ if (parent === current) {
5694
+ break;
5695
+ }
5696
+ current = parent;
5697
+ }
5698
+ return directories;
5699
+ }
5700
+ function getEnvVar(env, key) {
5701
+ const direct = env[key];
5702
+ if (typeof direct === "string") {
5703
+ return direct;
5704
+ }
5705
+ const lowerKey = key.toLowerCase();
5706
+ for (const [envKey, envValue] of Object.entries(env)) {
5707
+ if (envKey.toLowerCase() === lowerKey && typeof envValue === "string") {
5708
+ return envValue;
5709
+ }
5710
+ }
5711
+ return;
5712
+ }
5713
+ function isExecutable(filePath) {
5714
+ try {
5715
+ const mode = process.platform === "win32" ? fsConstants.F_OK : fsConstants.X_OK;
5716
+ accessSync(filePath, mode);
5717
+ return true;
5718
+ } catch {
5719
+ return false;
5720
+ }
5721
+ }
5722
+
5723
+ // src/cli/deploy/resources.ts
5724
+ function spawnWrangler(args, options) {
5725
+ const cwd = typeof options.cwd === "string" ? options.cwd : process.cwd();
5726
+ const env = options.env || process.env;
5727
+ const launcher = resolveWranglerLauncher({ cwd, env });
5728
+ return spawn(launcher.command, [...launcher.argsPrefix, ...args], {
5729
+ cwd,
5730
+ env,
5731
+ stdio: options.stdio
5732
+ });
5733
+ }
5734
+ function toWranglerRunError(prefix, error) {
5735
+ if (error.code === "ENOENT") {
5736
+ return new WranglerNotFoundError;
5737
+ }
5738
+ return new Error(`${prefix}: ${error.message}`);
5739
+ }
5599
5740
  async function runWrangler(args, options = {}) {
5600
5741
  return new Promise((resolve, reject) => {
5601
5742
  const chunks = [];
@@ -5607,11 +5748,17 @@ async function runWrangler(args, options = {}) {
5607
5748
  if (options.accountId) {
5608
5749
  env.CLOUDFLARE_ACCOUNT_ID = options.accountId;
5609
5750
  }
5610
- const proc = spawn("npx", ["wrangler", ...args], {
5611
- cwd: options.cwd || process.cwd(),
5612
- stdio: ["pipe", "pipe", "pipe"],
5613
- env
5614
- });
5751
+ let proc;
5752
+ try {
5753
+ proc = spawnWrangler(args, {
5754
+ cwd: options.cwd || process.cwd(),
5755
+ stdio: ["pipe", "pipe", "pipe"],
5756
+ env
5757
+ });
5758
+ } catch (error) {
5759
+ reject(error instanceof Error ? error : new Error(String(error)));
5760
+ return;
5761
+ }
5615
5762
  proc.stdout.on("data", (chunk) => chunks.push(chunk));
5616
5763
  proc.stderr.on("data", (chunk) => errorChunks.push(chunk));
5617
5764
  proc.on("close", (code) => {
@@ -5629,16 +5776,22 @@ ${stderr}`);
5629
5776
  }
5630
5777
  });
5631
5778
  proc.on("error", (error) => {
5632
- reject(new Error(`Failed to run wrangler: ${error.message}`));
5779
+ reject(toWranglerRunError("Failed to run wrangler", error));
5633
5780
  });
5634
5781
  });
5635
5782
  }
5636
5783
  async function runWranglerDeploy(configPath, options = {}) {
5637
5784
  return new Promise((resolve, reject) => {
5638
- const proc = spawn("npx", ["wrangler", "deploy", "--config", configPath], {
5639
- cwd: options.cwd || process.cwd(),
5640
- stdio: "inherit"
5641
- });
5785
+ let proc;
5786
+ try {
5787
+ proc = spawnWrangler(["deploy", "--config", configPath], {
5788
+ cwd: options.cwd || process.cwd(),
5789
+ stdio: "inherit"
5790
+ });
5791
+ } catch (error) {
5792
+ reject(error instanceof Error ? error : new Error(String(error)));
5793
+ return;
5794
+ }
5642
5795
  proc.on("close", (code) => {
5643
5796
  if (code === 0) {
5644
5797
  resolve();
@@ -5647,7 +5800,7 @@ async function runWranglerDeploy(configPath, options = {}) {
5647
5800
  }
5648
5801
  });
5649
5802
  proc.on("error", (error) => {
5650
- reject(new Error(`Failed to run wrangler deploy: ${error.message}`));
5803
+ reject(toWranglerRunError("Failed to run wrangler deploy", error));
5651
5804
  });
5652
5805
  });
5653
5806
  }
@@ -5666,18 +5819,25 @@ async function checkWranglerAuth() {
5666
5819
  email: emailMatch?.[1]
5667
5820
  };
5668
5821
  } catch (error) {
5822
+ if (error instanceof WranglerNotFoundError) {
5823
+ throw error;
5824
+ }
5669
5825
  const errorText = (error.stderr || "") + (error.stdout || "");
5670
5826
  if (errorText.includes("not logged in") || errorText.includes("You are not authenticated")) {
5671
5827
  return null;
5672
5828
  }
5673
- return null;
5829
+ throw new Error(`Failed to check Cloudflare authentication: ${error.message}`);
5674
5830
  }
5675
5831
  }
5676
5832
  async function wranglerLogin() {
5677
5833
  return new Promise((resolve, reject) => {
5678
- const proc = spawn("npx", ["wrangler", "login"], {
5679
- stdio: "inherit"
5680
- });
5834
+ let proc;
5835
+ try {
5836
+ proc = spawnWrangler(["login"], { stdio: "inherit" });
5837
+ } catch (error) {
5838
+ reject(error instanceof Error ? error : new Error(String(error)));
5839
+ return;
5840
+ }
5681
5841
  proc.on("close", async (code) => {
5682
5842
  if (code === 0) {
5683
5843
  const auth = await checkWranglerAuth();
@@ -5691,7 +5851,7 @@ async function wranglerLogin() {
5691
5851
  }
5692
5852
  });
5693
5853
  proc.on("error", (error) => {
5694
- reject(new Error(`Failed to run wrangler login: ${error.message}`));
5854
+ reject(toWranglerRunError("Failed to run wrangler login", error));
5695
5855
  });
5696
5856
  });
5697
5857
  }
@@ -5791,13 +5951,19 @@ async function ensureR2Bucket(name, accountId) {
5791
5951
  }
5792
5952
  async function setWorkerSecret(workerName, secretName, secretValue) {
5793
5953
  return new Promise((resolve, reject) => {
5794
- const proc = spawn("npx", ["wrangler", "secret", "put", secretName, "--name", workerName], {
5795
- stdio: ["pipe", "pipe", "pipe"],
5796
- env: {
5797
- ...process.env,
5798
- CI: "true"
5799
- }
5800
- });
5954
+ let proc;
5955
+ try {
5956
+ proc = spawnWrangler(["secret", "put", secretName, "--name", workerName], {
5957
+ stdio: ["pipe", "pipe", "pipe"],
5958
+ env: {
5959
+ ...process.env,
5960
+ CI: "true"
5961
+ }
5962
+ });
5963
+ } catch (error) {
5964
+ reject(error instanceof Error ? error : new Error(String(error)));
5965
+ return;
5966
+ }
5801
5967
  proc.stdin.write(secretValue);
5802
5968
  proc.stdin.end();
5803
5969
  let stderr = "";
@@ -5812,7 +5978,7 @@ async function setWorkerSecret(workerName, secretName, secretValue) {
5812
5978
  }
5813
5979
  });
5814
5980
  proc.on("error", (error) => {
5815
- reject(new Error(`Failed to run wrangler secret: ${error.message}`));
5981
+ reject(toWranglerRunError("Failed to run wrangler secret", error));
5816
5982
  });
5817
5983
  });
5818
5984
  }
@@ -5837,7 +6003,7 @@ function getWorkerUrl(workerName, accountSubdomain) {
5837
6003
 
5838
6004
  // src/cli/deploy/secrets.ts
5839
6005
  import { promises as fs6 } from "node:fs";
5840
- import path8 from "node:path";
6006
+ import path9 from "node:path";
5841
6007
  var EXCLUDED_VARS = new Set([
5842
6008
  "NODE_ENV",
5843
6009
  "PATH",
@@ -5935,7 +6101,7 @@ async function detectEnvFiles(projectRoot) {
5935
6101
  ];
5936
6102
  const envFiles = [];
5937
6103
  for (const name of envFileNames) {
5938
- const filePath = path8.join(projectRoot, name);
6104
+ const filePath = path9.join(projectRoot, name);
5939
6105
  const envFile = await loadEnvFile(filePath);
5940
6106
  if (envFile) {
5941
6107
  envFiles.push(envFile);
@@ -6204,7 +6370,13 @@ async function runFirstTimeSetup(projectRoot, _existingState, options) {
6204
6370
  printDryRunNotice();
6205
6371
  }
6206
6372
  const spinner = createSpinner("Checking Cloudflare authentication...");
6207
- let auth = await checkWranglerAuth();
6373
+ let auth;
6374
+ try {
6375
+ auth = await checkWranglerAuth();
6376
+ } catch (error) {
6377
+ spinner.stop();
6378
+ throw error;
6379
+ }
6208
6380
  if (!auth || !auth.accountId) {
6209
6381
  spinner.stop();
6210
6382
  console.log(import_picocolors2.default.dim(` Not logged in. Opening browser to authenticate...
@@ -6414,7 +6586,7 @@ async function buildAndDeploy(projectRoot, workerName, config) {
6414
6586
  }
6415
6587
  async function generateWranglerConfig(projectRoot, workerName, config) {
6416
6588
  const concaveDir = getConcaveProjectPaths(projectRoot).concaveDir;
6417
- const configPath = path9.join(concaveDir, "wrangler.jsonc");
6589
+ const configPath = path10.join(concaveDir, "wrangler.jsonc");
6418
6590
  const wranglerConfig = {
6419
6591
  $schema: "https://json.schemastore.org/wrangler.json",
6420
6592
  name: workerName,
@@ -6463,7 +6635,7 @@ async function generateWranglerConfig(projectRoot, workerName, config) {
6463
6635
  ];
6464
6636
  }
6465
6637
  await fs7.mkdir(concaveDir, { recursive: true });
6466
- await fs7.mkdir(path9.join(concaveDir, "static"), { recursive: true });
6638
+ await fs7.mkdir(path10.join(concaveDir, "static"), { recursive: true });
6467
6639
  await fs7.writeFile(configPath, JSON.stringify(wranglerConfig, null, 2), "utf8");
6468
6640
  return configPath;
6469
6641
  }
@@ -6511,7 +6683,7 @@ async function handleSecrets(projectRoot, workerName, previousHashes, options) {
6511
6683
  var import_picocolors3 = __toESM(require_picocolors(), 1);
6512
6684
  var import_esbuild = __toESM(require_main(), 1);
6513
6685
  import { promises as fs8 } from "node:fs";
6514
- import path10 from "node:path";
6686
+ import path11 from "node:path";
6515
6687
  function componentDefinitionPlugin() {
6516
6688
  return {
6517
6689
  name: "concave-component-definition",
@@ -6543,14 +6715,14 @@ export default __componentDef;
6543
6715
  }
6544
6716
  async function deploy(projectRoot, options) {
6545
6717
  const { cloudUrl, environment = "development", verbose = false } = options;
6546
- const convexDir = path10.join(projectRoot, "convex");
6718
+ const convexDir = path11.join(projectRoot, "convex");
6547
6719
  try {
6548
6720
  await fs8.access(convexDir);
6549
6721
  } catch {
6550
6722
  throw new Error(`No convex/ directory found at ${convexDir}`);
6551
6723
  }
6552
6724
  let projectId = options.projectId;
6553
- const projectSlug = options.projectSlug || path10.basename(projectRoot);
6725
+ const projectSlug = options.projectSlug || path11.basename(projectRoot);
6554
6726
  if (!projectId) {
6555
6727
  projectId = generateProjectId(projectSlug);
6556
6728
  if (verbose) {
@@ -6616,7 +6788,7 @@ async function ensureProject(cloudUrl, projectId, projectSlug) {
6616
6788
  }
6617
6789
  }
6618
6790
  async function bundleProject(projectRoot, _verbose) {
6619
- const buildDir = path10.join(getConcaveProjectPaths(projectRoot).concaveDir, "cloud");
6791
+ const buildDir = path11.join(getConcaveProjectPaths(projectRoot).concaveDir, "cloud");
6620
6792
  try {
6621
6793
  await fs8.rm(buildDir, { recursive: true, force: true });
6622
6794
  } catch {}
@@ -6680,8 +6852,8 @@ async function getRouting(cloudUrl, projectId, environment) {
6680
6852
  method: "GET"
6681
6853
  });
6682
6854
  }
6683
- async function cloudRequest(cloudUrl, path11, init) {
6684
- const url = `${cloudUrl}${path11}`;
6855
+ async function cloudRequest(cloudUrl, path12, init) {
6856
+ const url = `${cloudUrl}${path12}`;
6685
6857
  const response = await fetch(url, {
6686
6858
  ...init,
6687
6859
  headers: {
@@ -6809,7 +6981,7 @@ var import_picocolors5 = __toESM(require_picocolors(), 1);
6809
6981
 
6810
6982
  // src/cli/url-utils.ts
6811
6983
  import { existsSync, readFileSync } from "node:fs";
6812
- import path11 from "node:path";
6984
+ import path12 from "node:path";
6813
6985
  var URL_ENV_KEYS = [
6814
6986
  "CONCAVE_URL",
6815
6987
  "CONVEX_URL",
@@ -6857,7 +7029,7 @@ function resolveBaseUrl(options, cwd = process.cwd()) {
6857
7029
  return {
6858
7030
  baseUrl: normalizeUrl(fromFiles.value),
6859
7031
  source: "environment-file",
6860
- sourceDetail: `${fromFiles.key} from ${path11.relative(cwd, fromFiles.filePath) || path11.basename(fromFiles.filePath)}`
7032
+ sourceDetail: `${fromFiles.key} from ${path12.relative(cwd, fromFiles.filePath) || path12.basename(fromFiles.filePath)}`
6861
7033
  };
6862
7034
  }
6863
7035
  const port = options.port || "3000";
@@ -6944,16 +7116,16 @@ function getUrlFromEnvFiles(cwd) {
6944
7116
  function getEnvFileCandidates(cwd) {
6945
7117
  const convexRoot = detectConvexRoot(cwd);
6946
7118
  const candidates = [
6947
- path11.join(convexRoot, ".env.local"),
6948
- path11.join(convexRoot, ".env"),
6949
- path11.join(cwd, ".env.local"),
6950
- path11.join(cwd, ".env")
7119
+ path12.join(convexRoot, ".env.local"),
7120
+ path12.join(convexRoot, ".env"),
7121
+ path12.join(cwd, ".env.local"),
7122
+ path12.join(cwd, ".env")
6951
7123
  ];
6952
7124
  return [...new Set(candidates)];
6953
7125
  }
6954
7126
  function detectConvexRoot(cwd) {
6955
- const convexJsonPath = path11.join(cwd, "convex.json");
6956
- const fallback = path11.join(cwd, "convex");
7127
+ const convexJsonPath = path12.join(cwd, "convex.json");
7128
+ const fallback = path12.join(cwd, "convex");
6957
7129
  if (!existsSync(convexJsonPath)) {
6958
7130
  return fallback;
6959
7131
  }
@@ -6966,11 +7138,11 @@ function detectConvexRoot(cwd) {
6966
7138
  if (!normalized) {
6967
7139
  return fallback;
6968
7140
  }
6969
- const root = normalized.includes("/") ? path11.posix.dirname(normalized) : normalized;
7141
+ const root = normalized.includes("/") ? path12.posix.dirname(normalized) : normalized;
6970
7142
  if (!root || root === ".") {
6971
7143
  return fallback;
6972
7144
  }
6973
- return path11.resolve(cwd, root);
7145
+ return path12.resolve(cwd, root);
6974
7146
  } catch {
6975
7147
  return fallback;
6976
7148
  }
@@ -7323,11 +7495,11 @@ function formatValue(value) {
7323
7495
  // src/cli/type-codegen.ts
7324
7496
  var import_picocolors7 = __toESM(require_picocolors(), 1);
7325
7497
  import { promises as fs9 } from "node:fs";
7326
- import path12 from "node:path";
7498
+ import path13 from "node:path";
7327
7499
  async function generateTypes(projectRoot, options = {}) {
7328
7500
  const layout = await resolveProjectLayout(projectRoot);
7329
7501
  const convexDir = layout.functionsDir;
7330
- const generatedDir = path12.join(convexDir, "_generated");
7502
+ const generatedDir = path13.join(convexDir, "_generated");
7331
7503
  try {
7332
7504
  await fs9.access(convexDir);
7333
7505
  } catch {
@@ -7356,7 +7528,7 @@ async function discoverModules(convexDir) {
7356
7528
  if (entry.name.startsWith(".") || entry.name === "_generated" || entry.name === "node_modules") {
7357
7529
  continue;
7358
7530
  }
7359
- const fullPath = path12.join(dir, entry.name);
7531
+ const fullPath = path13.join(dir, entry.name);
7360
7532
  const entryRelativePath = relativePath ? `${relativePath}/${entry.name}` : entry.name;
7361
7533
  if (entry.isDirectory()) {
7362
7534
  await walk(fullPath, entryRelativePath);
@@ -7531,7 +7703,7 @@ export type DatabaseReader = GenericDatabaseReader<DataModel>;
7531
7703
  */
7532
7704
  export type DatabaseWriter = GenericDatabaseWriter<DataModel>;
7533
7705
  `;
7534
- await fs9.writeFile(path12.join(generatedDir, "server.d.ts"), content, "utf8");
7706
+ await fs9.writeFile(path13.join(generatedDir, "server.d.ts"), content, "utf8");
7535
7707
  }
7536
7708
  async function generateServerJs(generatedDir) {
7537
7709
  const content = `/* eslint-disable */
@@ -7631,7 +7803,7 @@ export const httpAction = httpActionGeneric;
7631
7803
  */
7632
7804
  export { defineTable, defineSchema };
7633
7805
  `;
7634
- await fs9.writeFile(path12.join(generatedDir, "server.js"), content, "utf8");
7806
+ await fs9.writeFile(path13.join(generatedDir, "server.js"), content, "utf8");
7635
7807
  }
7636
7808
  async function generateDataModelTypes(generatedDir, hasSchema) {
7637
7809
  const content = `/* eslint-disable */
@@ -7695,7 +7867,7 @@ export type Id<TableName extends TableNames | SystemTableNames> =
7695
7867
  */
7696
7868
  ${hasSchema ? "export type DataModel = DataModelFromSchemaDefinition<typeof schema>;" : "export type DataModel = any;"}
7697
7869
  `;
7698
- await fs9.writeFile(path12.join(generatedDir, "dataModel.d.ts"), content, "utf8");
7870
+ await fs9.writeFile(path13.join(generatedDir, "dataModel.d.ts"), content, "utf8");
7699
7871
  }
7700
7872
  async function generateApiTypes(generatedDir, modules, _hasSchema) {
7701
7873
  const apiModules = modules.filter((m) => m.name !== "schema" && !m.name.startsWith("_") && m.name !== "http");
@@ -7753,7 +7925,7 @@ export declare const internal: FilterApi<
7753
7925
 
7754
7926
  export declare const components: AnyComponents;
7755
7927
  `;
7756
- await fs9.writeFile(path12.join(generatedDir, "api.d.ts"), content, "utf8");
7928
+ await fs9.writeFile(path13.join(generatedDir, "api.d.ts"), content, "utf8");
7757
7929
  }
7758
7930
  async function generateApiJs(generatedDir) {
7759
7931
  const content = `/* eslint-disable */
@@ -7832,13 +8004,13 @@ export const api = createApi();
7832
8004
  export const internal = createApi();
7833
8005
  export const components = createComponents();
7834
8006
  `;
7835
- await fs9.writeFile(path12.join(generatedDir, "api.js"), content, "utf8");
8007
+ await fs9.writeFile(path13.join(generatedDir, "api.js"), content, "utf8");
7836
8008
  }
7837
8009
 
7838
8010
  // src/cli/type-codegen-runtime.ts
7839
8011
  var import_picocolors8 = __toESM(require_picocolors(), 1);
7840
8012
  import { promises as fs10 } from "node:fs";
7841
- import path13 from "node:path";
8013
+ import path14 from "node:path";
7842
8014
  import { pathToFileURL as pathToFileURL3 } from "node:url";
7843
8015
 
7844
8016
  // src/cli/validator-to-typescript.ts
@@ -7955,7 +8127,7 @@ function returnsValidatorToTypeScript(returns, options = {}) {
7955
8127
  async function generateTypesWithRuntime(projectRoot, options = {}) {
7956
8128
  const layout = await resolveProjectLayout(projectRoot);
7957
8129
  const convexDir = layout.functionsDir;
7958
- const generatedDir = path13.join(convexDir, "_generated");
8130
+ const generatedDir = path14.join(convexDir, "_generated");
7959
8131
  console.log(import_picocolors8.default.cyan("\uD83D\uDD27 Generating TypeScript types (runtime analysis)"));
7960
8132
  console.log(import_picocolors8.default.dim(` Output: ${generatedDir}
7961
8133
  `));
@@ -8028,7 +8200,7 @@ async function discoverAndAnalyzeModules(convexDir, options) {
8028
8200
  const failed = [];
8029
8201
  const moduleFiles = await collectConvexModules2(convexDir);
8030
8202
  for (const filePath of moduleFiles) {
8031
- const relativePath = path13.relative(convexDir, filePath);
8203
+ const relativePath = path14.relative(convexDir, filePath);
8032
8204
  const moduleName = relativePath.replace(/\.(ts|tsx|js|jsx|mjs|cjs)$/, "").replace(/\\/g, "/");
8033
8205
  if (moduleName === "schema" || moduleName === "http" || moduleName === "crons") {
8034
8206
  continue;
@@ -8158,7 +8330,7 @@ async function collectConvexModules2(convexDir) {
8158
8330
  if (entry.name.startsWith(".") || entry.name === "_generated" || entry.name === "node_modules") {
8159
8331
  continue;
8160
8332
  }
8161
- const fullPath = path13.join(dir, entry.name);
8333
+ const fullPath = path14.join(dir, entry.name);
8162
8334
  if (entry.isDirectory()) {
8163
8335
  await walk(fullPath);
8164
8336
  } else if (isConvexSourceFile3(entry.name)) {
@@ -8339,7 +8511,7 @@ export declare const internal: FilterApi<
8339
8511
 
8340
8512
  export declare const components: AnyComponents;
8341
8513
  `;
8342
- await fs10.writeFile(path13.join(generatedDir, "api.d.ts"), content, "utf8");
8514
+ await fs10.writeFile(path14.join(generatedDir, "api.d.ts"), content, "utf8");
8343
8515
  }
8344
8516
  async function generatePackageJson(generatedDir) {
8345
8517
  const content = {
@@ -8353,7 +8525,7 @@ async function generatePackageJson(generatedDir) {
8353
8525
  "./dataModel.d.ts": "./dataModel.d.ts"
8354
8526
  }
8355
8527
  };
8356
- await fs10.writeFile(path13.join(generatedDir, "package.json"), JSON.stringify(content, null, 2), "utf8");
8528
+ await fs10.writeFile(path14.join(generatedDir, "package.json"), JSON.stringify(content, null, 2), "utf8");
8357
8529
  }
8358
8530
  async function generateServerTypes2(generatedDir, _hasSchema) {
8359
8531
  const content = `/* eslint-disable */
@@ -8395,7 +8567,7 @@ export type ActionCtx = GenericActionCtx<DataModel>;
8395
8567
  export type DatabaseReader = GenericDatabaseReader<DataModel>;
8396
8568
  export type DatabaseWriter = GenericDatabaseWriter<DataModel>;
8397
8569
  `;
8398
- await fs10.writeFile(path13.join(generatedDir, "server.d.ts"), content, "utf8");
8570
+ await fs10.writeFile(path14.join(generatedDir, "server.d.ts"), content, "utf8");
8399
8571
  }
8400
8572
  async function generateServerJs2(generatedDir) {
8401
8573
  const content = `/* eslint-disable */
@@ -8495,7 +8667,7 @@ export const httpAction = httpActionGeneric;
8495
8667
  */
8496
8668
  export { defineTable, defineSchema };
8497
8669
  `;
8498
- await fs10.writeFile(path13.join(generatedDir, "server.js"), content, "utf8");
8670
+ await fs10.writeFile(path14.join(generatedDir, "server.js"), content, "utf8");
8499
8671
  }
8500
8672
  async function generateDataModelTypes2(generatedDir, hasSchema) {
8501
8673
  const content = `/* eslint-disable */
@@ -8523,7 +8695,7 @@ export type Id<TableName extends TableNames | SystemTableNames> = GenericId<Tabl
8523
8695
 
8524
8696
  ${hasSchema ? "export type DataModel = DataModelFromSchemaDefinition<typeof schema>;" : "export type DataModel = any;"}
8525
8697
  `;
8526
- await fs10.writeFile(path13.join(generatedDir, "dataModel.d.ts"), content, "utf8");
8698
+ await fs10.writeFile(path14.join(generatedDir, "dataModel.d.ts"), content, "utf8");
8527
8699
  }
8528
8700
  async function generateApiJs2(generatedDir) {
8529
8701
  const content = `/* eslint-disable */
@@ -8602,7 +8774,7 @@ export const api = createApi();
8602
8774
  export const internal = createApi();
8603
8775
  export const components = createComponents();
8604
8776
  `;
8605
- await fs10.writeFile(path13.join(generatedDir, "api.js"), content, "utf8");
8777
+ await fs10.writeFile(path14.join(generatedDir, "api.js"), content, "utf8");
8606
8778
  }
8607
8779
 
8608
8780
  // ../../node_modules/chokidar/esm/index.js
@@ -8682,7 +8854,7 @@ class ReaddirpStream extends Readable {
8682
8854
  this._directoryFilter = normalizeFilter(opts.directoryFilter);
8683
8855
  const statMethod = opts.lstat ? lstat : stat2;
8684
8856
  if (wantBigintFsStats) {
8685
- this._stat = (path14) => statMethod(path14, { bigint: true });
8857
+ this._stat = (path15) => statMethod(path15, { bigint: true });
8686
8858
  } else {
8687
8859
  this._stat = statMethod;
8688
8860
  }
@@ -8707,8 +8879,8 @@ class ReaddirpStream extends Readable {
8707
8879
  const par = this.parent;
8708
8880
  const fil = par && par.files;
8709
8881
  if (fil && fil.length > 0) {
8710
- const { path: path14, depth } = par;
8711
- const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path14));
8882
+ const { path: path15, depth } = par;
8883
+ const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path15));
8712
8884
  const awaited = await Promise.all(slice);
8713
8885
  for (const entry of awaited) {
8714
8886
  if (!entry)
@@ -8748,20 +8920,20 @@ class ReaddirpStream extends Readable {
8748
8920
  this.reading = false;
8749
8921
  }
8750
8922
  }
8751
- async _exploreDir(path14, depth) {
8923
+ async _exploreDir(path15, depth) {
8752
8924
  let files;
8753
8925
  try {
8754
- files = await readdir(path14, this._rdOptions);
8926
+ files = await readdir(path15, this._rdOptions);
8755
8927
  } catch (error) {
8756
8928
  this._onError(error);
8757
8929
  }
8758
- return { files, depth, path: path14 };
8930
+ return { files, depth, path: path15 };
8759
8931
  }
8760
- async _formatEntry(dirent, path14) {
8932
+ async _formatEntry(dirent, path15) {
8761
8933
  let entry;
8762
8934
  const basename = this._isDirent ? dirent.name : dirent;
8763
8935
  try {
8764
- const fullPath = presolve(pjoin(path14, basename));
8936
+ const fullPath = presolve(pjoin(path15, basename));
8765
8937
  entry = { path: prelative(this._root, fullPath), fullPath, basename };
8766
8938
  entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
8767
8939
  } catch (err) {
@@ -9160,16 +9332,16 @@ var delFromSet = (main, prop, item) => {
9160
9332
  };
9161
9333
  var isEmptySet = (val) => val instanceof Set ? val.size === 0 : !val;
9162
9334
  var FsWatchInstances = new Map;
9163
- function createFsWatchInstance(path14, options, listener, errHandler, emitRaw) {
9335
+ function createFsWatchInstance(path15, options, listener, errHandler, emitRaw) {
9164
9336
  const handleEvent = (rawEvent, evPath) => {
9165
- listener(path14);
9166
- emitRaw(rawEvent, evPath, { watchedPath: path14 });
9167
- if (evPath && path14 !== evPath) {
9168
- fsWatchBroadcast(sysPath.resolve(path14, evPath), KEY_LISTENERS, sysPath.join(path14, evPath));
9337
+ listener(path15);
9338
+ emitRaw(rawEvent, evPath, { watchedPath: path15 });
9339
+ if (evPath && path15 !== evPath) {
9340
+ fsWatchBroadcast(sysPath.resolve(path15, evPath), KEY_LISTENERS, sysPath.join(path15, evPath));
9169
9341
  }
9170
9342
  };
9171
9343
  try {
9172
- return fs_watch(path14, {
9344
+ return fs_watch(path15, {
9173
9345
  persistent: options.persistent
9174
9346
  }, handleEvent);
9175
9347
  } catch (error) {
@@ -9185,12 +9357,12 @@ var fsWatchBroadcast = (fullPath, listenerType, val1, val2, val3) => {
9185
9357
  listener(val1, val2, val3);
9186
9358
  });
9187
9359
  };
9188
- var setFsWatchListener = (path14, fullPath, options, handlers) => {
9360
+ var setFsWatchListener = (path15, fullPath, options, handlers) => {
9189
9361
  const { listener, errHandler, rawEmitter } = handlers;
9190
9362
  let cont = FsWatchInstances.get(fullPath);
9191
9363
  let watcher;
9192
9364
  if (!options.persistent) {
9193
- watcher = createFsWatchInstance(path14, options, listener, errHandler, rawEmitter);
9365
+ watcher = createFsWatchInstance(path15, options, listener, errHandler, rawEmitter);
9194
9366
  if (!watcher)
9195
9367
  return;
9196
9368
  return watcher.close.bind(watcher);
@@ -9200,7 +9372,7 @@ var setFsWatchListener = (path14, fullPath, options, handlers) => {
9200
9372
  addAndConvert(cont, KEY_ERR, errHandler);
9201
9373
  addAndConvert(cont, KEY_RAW, rawEmitter);
9202
9374
  } else {
9203
- watcher = createFsWatchInstance(path14, options, fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS), errHandler, fsWatchBroadcast.bind(null, fullPath, KEY_RAW));
9375
+ watcher = createFsWatchInstance(path15, options, fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS), errHandler, fsWatchBroadcast.bind(null, fullPath, KEY_RAW));
9204
9376
  if (!watcher)
9205
9377
  return;
9206
9378
  watcher.on(EV.ERROR, async (error) => {
@@ -9209,7 +9381,7 @@ var setFsWatchListener = (path14, fullPath, options, handlers) => {
9209
9381
  cont.watcherUnusable = true;
9210
9382
  if (isWindows && error.code === "EPERM") {
9211
9383
  try {
9212
- const fd = await open(path14, "r");
9384
+ const fd = await open(path15, "r");
9213
9385
  await fd.close();
9214
9386
  broadcastErr(error);
9215
9387
  } catch (err) {}
@@ -9239,7 +9411,7 @@ var setFsWatchListener = (path14, fullPath, options, handlers) => {
9239
9411
  };
9240
9412
  };
9241
9413
  var FsWatchFileInstances = new Map;
9242
- var setFsWatchFileListener = (path14, fullPath, options, handlers) => {
9414
+ var setFsWatchFileListener = (path15, fullPath, options, handlers) => {
9243
9415
  const { listener, rawEmitter } = handlers;
9244
9416
  let cont = FsWatchFileInstances.get(fullPath);
9245
9417
  const copts = cont && cont.options;
@@ -9261,7 +9433,7 @@ var setFsWatchFileListener = (path14, fullPath, options, handlers) => {
9261
9433
  });
9262
9434
  const currmtime = curr.mtimeMs;
9263
9435
  if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
9264
- foreach(cont.listeners, (listener2) => listener2(path14, curr));
9436
+ foreach(cont.listeners, (listener2) => listener2(path15, curr));
9265
9437
  }
9266
9438
  })
9267
9439
  };
@@ -9284,13 +9456,13 @@ class NodeFsHandler {
9284
9456
  this.fsw = fsW;
9285
9457
  this._boundHandleError = (error) => fsW._handleError(error);
9286
9458
  }
9287
- _watchWithNodeFs(path14, listener) {
9459
+ _watchWithNodeFs(path15, listener) {
9288
9460
  const opts = this.fsw.options;
9289
- const directory = sysPath.dirname(path14);
9290
- const basename2 = sysPath.basename(path14);
9461
+ const directory = sysPath.dirname(path15);
9462
+ const basename2 = sysPath.basename(path15);
9291
9463
  const parent = this.fsw._getWatchedDir(directory);
9292
9464
  parent.add(basename2);
9293
- const absolutePath = sysPath.resolve(path14);
9465
+ const absolutePath = sysPath.resolve(path15);
9294
9466
  const options = {
9295
9467
  persistent: opts.persistent
9296
9468
  };
@@ -9300,12 +9472,12 @@ class NodeFsHandler {
9300
9472
  if (opts.usePolling) {
9301
9473
  const enableBin = opts.interval !== opts.binaryInterval;
9302
9474
  options.interval = enableBin && isBinaryPath(basename2) ? opts.binaryInterval : opts.interval;
9303
- closer = setFsWatchFileListener(path14, absolutePath, options, {
9475
+ closer = setFsWatchFileListener(path15, absolutePath, options, {
9304
9476
  listener,
9305
9477
  rawEmitter: this.fsw._emitRaw
9306
9478
  });
9307
9479
  } else {
9308
- closer = setFsWatchListener(path14, absolutePath, options, {
9480
+ closer = setFsWatchListener(path15, absolutePath, options, {
9309
9481
  listener,
9310
9482
  errHandler: this._boundHandleError,
9311
9483
  rawEmitter: this.fsw._emitRaw
@@ -9323,7 +9495,7 @@ class NodeFsHandler {
9323
9495
  let prevStats = stats;
9324
9496
  if (parent.has(basename2))
9325
9497
  return;
9326
- const listener = async (path14, newStats) => {
9498
+ const listener = async (path15, newStats) => {
9327
9499
  if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file, 5))
9328
9500
  return;
9329
9501
  if (!newStats || newStats.mtimeMs === 0) {
@@ -9337,11 +9509,11 @@ class NodeFsHandler {
9337
9509
  this.fsw._emit(EV.CHANGE, file, newStats2);
9338
9510
  }
9339
9511
  if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
9340
- this.fsw._closeFile(path14);
9512
+ this.fsw._closeFile(path15);
9341
9513
  prevStats = newStats2;
9342
9514
  const closer2 = this._watchWithNodeFs(file, listener);
9343
9515
  if (closer2)
9344
- this.fsw._addPathCloser(path14, closer2);
9516
+ this.fsw._addPathCloser(path15, closer2);
9345
9517
  } else {
9346
9518
  prevStats = newStats2;
9347
9519
  }
@@ -9365,7 +9537,7 @@ class NodeFsHandler {
9365
9537
  }
9366
9538
  return closer;
9367
9539
  }
9368
- async _handleSymlink(entry, directory, path14, item) {
9540
+ async _handleSymlink(entry, directory, path15, item) {
9369
9541
  if (this.fsw.closed) {
9370
9542
  return;
9371
9543
  }
@@ -9375,7 +9547,7 @@ class NodeFsHandler {
9375
9547
  this.fsw._incrReadyCount();
9376
9548
  let linkPath;
9377
9549
  try {
9378
- linkPath = await fsrealpath(path14);
9550
+ linkPath = await fsrealpath(path15);
9379
9551
  } catch (e) {
9380
9552
  this.fsw._emitReady();
9381
9553
  return true;
@@ -9385,12 +9557,12 @@ class NodeFsHandler {
9385
9557
  if (dir.has(item)) {
9386
9558
  if (this.fsw._symlinkPaths.get(full) !== linkPath) {
9387
9559
  this.fsw._symlinkPaths.set(full, linkPath);
9388
- this.fsw._emit(EV.CHANGE, path14, entry.stats);
9560
+ this.fsw._emit(EV.CHANGE, path15, entry.stats);
9389
9561
  }
9390
9562
  } else {
9391
9563
  dir.add(item);
9392
9564
  this.fsw._symlinkPaths.set(full, linkPath);
9393
- this.fsw._emit(EV.ADD, path14, entry.stats);
9565
+ this.fsw._emit(EV.ADD, path15, entry.stats);
9394
9566
  }
9395
9567
  this.fsw._emitReady();
9396
9568
  return true;
@@ -9419,9 +9591,9 @@ class NodeFsHandler {
9419
9591
  return;
9420
9592
  }
9421
9593
  const item = entry.path;
9422
- let path14 = sysPath.join(directory, item);
9594
+ let path15 = sysPath.join(directory, item);
9423
9595
  current.add(item);
9424
- if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path14, item)) {
9596
+ if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path15, item)) {
9425
9597
  return;
9426
9598
  }
9427
9599
  if (this.fsw.closed) {
@@ -9430,8 +9602,8 @@ class NodeFsHandler {
9430
9602
  }
9431
9603
  if (item === target || !target && !previous.has(item)) {
9432
9604
  this.fsw._incrReadyCount();
9433
- path14 = sysPath.join(dir, sysPath.relative(dir, path14));
9434
- this._addToNodeFs(path14, initialAdd, wh, depth + 1);
9605
+ path15 = sysPath.join(dir, sysPath.relative(dir, path15));
9606
+ this._addToNodeFs(path15, initialAdd, wh, depth + 1);
9435
9607
  }
9436
9608
  }).on(EV.ERROR, this._boundHandleError);
9437
9609
  return new Promise((resolve2, reject) => {
@@ -9480,13 +9652,13 @@ class NodeFsHandler {
9480
9652
  }
9481
9653
  return closer;
9482
9654
  }
9483
- async _addToNodeFs(path14, initialAdd, priorWh, depth, target) {
9655
+ async _addToNodeFs(path15, initialAdd, priorWh, depth, target) {
9484
9656
  const ready = this.fsw._emitReady;
9485
- if (this.fsw._isIgnored(path14) || this.fsw.closed) {
9657
+ if (this.fsw._isIgnored(path15) || this.fsw.closed) {
9486
9658
  ready();
9487
9659
  return false;
9488
9660
  }
9489
- const wh = this.fsw._getWatchHelpers(path14);
9661
+ const wh = this.fsw._getWatchHelpers(path15);
9490
9662
  if (priorWh) {
9491
9663
  wh.filterPath = (entry) => priorWh.filterPath(entry);
9492
9664
  wh.filterDir = (entry) => priorWh.filterDir(entry);
@@ -9502,8 +9674,8 @@ class NodeFsHandler {
9502
9674
  const follow = this.fsw.options.followSymlinks;
9503
9675
  let closer;
9504
9676
  if (stats.isDirectory()) {
9505
- const absPath = sysPath.resolve(path14);
9506
- const targetPath = follow ? await fsrealpath(path14) : path14;
9677
+ const absPath = sysPath.resolve(path15);
9678
+ const targetPath = follow ? await fsrealpath(path15) : path15;
9507
9679
  if (this.fsw.closed)
9508
9680
  return;
9509
9681
  closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
@@ -9513,29 +9685,29 @@ class NodeFsHandler {
9513
9685
  this.fsw._symlinkPaths.set(absPath, targetPath);
9514
9686
  }
9515
9687
  } else if (stats.isSymbolicLink()) {
9516
- const targetPath = follow ? await fsrealpath(path14) : path14;
9688
+ const targetPath = follow ? await fsrealpath(path15) : path15;
9517
9689
  if (this.fsw.closed)
9518
9690
  return;
9519
9691
  const parent = sysPath.dirname(wh.watchPath);
9520
9692
  this.fsw._getWatchedDir(parent).add(wh.watchPath);
9521
9693
  this.fsw._emit(EV.ADD, wh.watchPath, stats);
9522
- closer = await this._handleDir(parent, stats, initialAdd, depth, path14, wh, targetPath);
9694
+ closer = await this._handleDir(parent, stats, initialAdd, depth, path15, wh, targetPath);
9523
9695
  if (this.fsw.closed)
9524
9696
  return;
9525
9697
  if (targetPath !== undefined) {
9526
- this.fsw._symlinkPaths.set(sysPath.resolve(path14), targetPath);
9698
+ this.fsw._symlinkPaths.set(sysPath.resolve(path15), targetPath);
9527
9699
  }
9528
9700
  } else {
9529
9701
  closer = this._handleFile(wh.watchPath, stats, initialAdd);
9530
9702
  }
9531
9703
  ready();
9532
9704
  if (closer)
9533
- this.fsw._addPathCloser(path14, closer);
9705
+ this.fsw._addPathCloser(path15, closer);
9534
9706
  return false;
9535
9707
  } catch (error) {
9536
9708
  if (this.fsw._handleError(error)) {
9537
9709
  ready();
9538
- return path14;
9710
+ return path15;
9539
9711
  }
9540
9712
  }
9541
9713
  }
@@ -9579,26 +9751,26 @@ function createPattern(matcher) {
9579
9751
  }
9580
9752
  return () => false;
9581
9753
  }
9582
- function normalizePath(path14) {
9583
- if (typeof path14 !== "string")
9754
+ function normalizePath(path15) {
9755
+ if (typeof path15 !== "string")
9584
9756
  throw new Error("string expected");
9585
- path14 = sysPath2.normalize(path14);
9586
- path14 = path14.replace(/\\/g, "/");
9757
+ path15 = sysPath2.normalize(path15);
9758
+ path15 = path15.replace(/\\/g, "/");
9587
9759
  let prepend = false;
9588
- if (path14.startsWith("//"))
9760
+ if (path15.startsWith("//"))
9589
9761
  prepend = true;
9590
9762
  const DOUBLE_SLASH_RE2 = /\/\//;
9591
- while (path14.match(DOUBLE_SLASH_RE2))
9592
- path14 = path14.replace(DOUBLE_SLASH_RE2, "/");
9763
+ while (path15.match(DOUBLE_SLASH_RE2))
9764
+ path15 = path15.replace(DOUBLE_SLASH_RE2, "/");
9593
9765
  if (prepend)
9594
- path14 = "/" + path14;
9595
- return path14;
9766
+ path15 = "/" + path15;
9767
+ return path15;
9596
9768
  }
9597
9769
  function matchPatterns(patterns, testString, stats) {
9598
- const path14 = normalizePath(testString);
9770
+ const path15 = normalizePath(testString);
9599
9771
  for (let index = 0;index < patterns.length; index++) {
9600
9772
  const pattern = patterns[index];
9601
- if (pattern(path14, stats)) {
9773
+ if (pattern(path15, stats)) {
9602
9774
  return true;
9603
9775
  }
9604
9776
  }
@@ -9638,19 +9810,19 @@ var toUnix = (string) => {
9638
9810
  }
9639
9811
  return str;
9640
9812
  };
9641
- var normalizePathToUnix = (path14) => toUnix(sysPath2.normalize(toUnix(path14)));
9642
- var normalizeIgnored = (cwd = "") => (path14) => {
9643
- if (typeof path14 === "string") {
9644
- return normalizePathToUnix(sysPath2.isAbsolute(path14) ? path14 : sysPath2.join(cwd, path14));
9813
+ var normalizePathToUnix = (path15) => toUnix(sysPath2.normalize(toUnix(path15)));
9814
+ var normalizeIgnored = (cwd = "") => (path15) => {
9815
+ if (typeof path15 === "string") {
9816
+ return normalizePathToUnix(sysPath2.isAbsolute(path15) ? path15 : sysPath2.join(cwd, path15));
9645
9817
  } else {
9646
- return path14;
9818
+ return path15;
9647
9819
  }
9648
9820
  };
9649
- var getAbsolutePath = (path14, cwd) => {
9650
- if (sysPath2.isAbsolute(path14)) {
9651
- return path14;
9821
+ var getAbsolutePath = (path15, cwd) => {
9822
+ if (sysPath2.isAbsolute(path15)) {
9823
+ return path15;
9652
9824
  }
9653
- return sysPath2.join(cwd, path14);
9825
+ return sysPath2.join(cwd, path15);
9654
9826
  };
9655
9827
  var EMPTY_SET = Object.freeze(new Set);
9656
9828
 
@@ -9707,10 +9879,10 @@ var STAT_METHOD_F = "stat";
9707
9879
  var STAT_METHOD_L = "lstat";
9708
9880
 
9709
9881
  class WatchHelper {
9710
- constructor(path14, follow, fsw) {
9882
+ constructor(path15, follow, fsw) {
9711
9883
  this.fsw = fsw;
9712
- const watchPath = path14;
9713
- this.path = path14 = path14.replace(REPLACER_RE, "");
9884
+ const watchPath = path15;
9885
+ this.path = path15 = path15.replace(REPLACER_RE, "");
9714
9886
  this.watchPath = watchPath;
9715
9887
  this.fullWatchPath = sysPath2.resolve(watchPath);
9716
9888
  this.dirParts = [];
@@ -9823,20 +9995,20 @@ class FSWatcher extends EventEmitter {
9823
9995
  this._closePromise = undefined;
9824
9996
  let paths = unifyPaths(paths_);
9825
9997
  if (cwd) {
9826
- paths = paths.map((path14) => {
9827
- const absPath = getAbsolutePath(path14, cwd);
9998
+ paths = paths.map((path15) => {
9999
+ const absPath = getAbsolutePath(path15, cwd);
9828
10000
  return absPath;
9829
10001
  });
9830
10002
  }
9831
- paths.forEach((path14) => {
9832
- this._removeIgnoredPath(path14);
10003
+ paths.forEach((path15) => {
10004
+ this._removeIgnoredPath(path15);
9833
10005
  });
9834
10006
  this._userIgnored = undefined;
9835
10007
  if (!this._readyCount)
9836
10008
  this._readyCount = 0;
9837
10009
  this._readyCount += paths.length;
9838
- Promise.all(paths.map(async (path14) => {
9839
- const res = await this._nodeFsHandler._addToNodeFs(path14, !_internal, undefined, 0, _origAdd);
10010
+ Promise.all(paths.map(async (path15) => {
10011
+ const res = await this._nodeFsHandler._addToNodeFs(path15, !_internal, undefined, 0, _origAdd);
9840
10012
  if (res)
9841
10013
  this._emitReady();
9842
10014
  return res;
@@ -9855,17 +10027,17 @@ class FSWatcher extends EventEmitter {
9855
10027
  return this;
9856
10028
  const paths = unifyPaths(paths_);
9857
10029
  const { cwd } = this.options;
9858
- paths.forEach((path14) => {
9859
- if (!sysPath2.isAbsolute(path14) && !this._closers.has(path14)) {
10030
+ paths.forEach((path15) => {
10031
+ if (!sysPath2.isAbsolute(path15) && !this._closers.has(path15)) {
9860
10032
  if (cwd)
9861
- path14 = sysPath2.join(cwd, path14);
9862
- path14 = sysPath2.resolve(path14);
10033
+ path15 = sysPath2.join(cwd, path15);
10034
+ path15 = sysPath2.resolve(path15);
9863
10035
  }
9864
- this._closePath(path14);
9865
- this._addIgnoredPath(path14);
9866
- if (this._watched.has(path14)) {
10036
+ this._closePath(path15);
10037
+ this._addIgnoredPath(path15);
10038
+ if (this._watched.has(path15)) {
9867
10039
  this._addIgnoredPath({
9868
- path: path14,
10040
+ path: path15,
9869
10041
  recursive: true
9870
10042
  });
9871
10043
  }
@@ -9914,38 +10086,38 @@ class FSWatcher extends EventEmitter {
9914
10086
  if (event !== EVENTS.ERROR)
9915
10087
  this.emit(EVENTS.ALL, event, ...args);
9916
10088
  }
9917
- async _emit(event, path14, stats) {
10089
+ async _emit(event, path15, stats) {
9918
10090
  if (this.closed)
9919
10091
  return;
9920
10092
  const opts = this.options;
9921
10093
  if (isWindows)
9922
- path14 = sysPath2.normalize(path14);
10094
+ path15 = sysPath2.normalize(path15);
9923
10095
  if (opts.cwd)
9924
- path14 = sysPath2.relative(opts.cwd, path14);
9925
- const args = [path14];
10096
+ path15 = sysPath2.relative(opts.cwd, path15);
10097
+ const args = [path15];
9926
10098
  if (stats != null)
9927
10099
  args.push(stats);
9928
10100
  const awf = opts.awaitWriteFinish;
9929
10101
  let pw;
9930
- if (awf && (pw = this._pendingWrites.get(path14))) {
10102
+ if (awf && (pw = this._pendingWrites.get(path15))) {
9931
10103
  pw.lastChange = new Date;
9932
10104
  return this;
9933
10105
  }
9934
10106
  if (opts.atomic) {
9935
10107
  if (event === EVENTS.UNLINK) {
9936
- this._pendingUnlinks.set(path14, [event, ...args]);
10108
+ this._pendingUnlinks.set(path15, [event, ...args]);
9937
10109
  setTimeout(() => {
9938
- this._pendingUnlinks.forEach((entry, path15) => {
10110
+ this._pendingUnlinks.forEach((entry, path16) => {
9939
10111
  this.emit(...entry);
9940
10112
  this.emit(EVENTS.ALL, ...entry);
9941
- this._pendingUnlinks.delete(path15);
10113
+ this._pendingUnlinks.delete(path16);
9942
10114
  });
9943
10115
  }, typeof opts.atomic === "number" ? opts.atomic : 100);
9944
10116
  return this;
9945
10117
  }
9946
- if (event === EVENTS.ADD && this._pendingUnlinks.has(path14)) {
10118
+ if (event === EVENTS.ADD && this._pendingUnlinks.has(path15)) {
9947
10119
  event = EVENTS.CHANGE;
9948
- this._pendingUnlinks.delete(path14);
10120
+ this._pendingUnlinks.delete(path15);
9949
10121
  }
9950
10122
  }
9951
10123
  if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
@@ -9963,16 +10135,16 @@ class FSWatcher extends EventEmitter {
9963
10135
  this.emitWithAll(event, args);
9964
10136
  }
9965
10137
  };
9966
- this._awaitWriteFinish(path14, awf.stabilityThreshold, event, awfEmit);
10138
+ this._awaitWriteFinish(path15, awf.stabilityThreshold, event, awfEmit);
9967
10139
  return this;
9968
10140
  }
9969
10141
  if (event === EVENTS.CHANGE) {
9970
- const isThrottled = !this._throttle(EVENTS.CHANGE, path14, 50);
10142
+ const isThrottled = !this._throttle(EVENTS.CHANGE, path15, 50);
9971
10143
  if (isThrottled)
9972
10144
  return this;
9973
10145
  }
9974
10146
  if (opts.alwaysStat && stats === undefined && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
9975
- const fullPath = opts.cwd ? sysPath2.join(opts.cwd, path14) : path14;
10147
+ const fullPath = opts.cwd ? sysPath2.join(opts.cwd, path15) : path15;
9976
10148
  let stats2;
9977
10149
  try {
9978
10150
  stats2 = await stat4(fullPath);
@@ -9991,23 +10163,23 @@ class FSWatcher extends EventEmitter {
9991
10163
  }
9992
10164
  return error || this.closed;
9993
10165
  }
9994
- _throttle(actionType, path14, timeout) {
10166
+ _throttle(actionType, path15, timeout) {
9995
10167
  if (!this._throttled.has(actionType)) {
9996
10168
  this._throttled.set(actionType, new Map);
9997
10169
  }
9998
10170
  const action = this._throttled.get(actionType);
9999
10171
  if (!action)
10000
10172
  throw new Error("invalid throttle");
10001
- const actionPath = action.get(path14);
10173
+ const actionPath = action.get(path15);
10002
10174
  if (actionPath) {
10003
10175
  actionPath.count++;
10004
10176
  return false;
10005
10177
  }
10006
10178
  let timeoutObject;
10007
10179
  const clear = () => {
10008
- const item = action.get(path14);
10180
+ const item = action.get(path15);
10009
10181
  const count = item ? item.count : 0;
10010
- action.delete(path14);
10182
+ action.delete(path15);
10011
10183
  clearTimeout(timeoutObject);
10012
10184
  if (item)
10013
10185
  clearTimeout(item.timeoutObject);
@@ -10015,50 +10187,50 @@ class FSWatcher extends EventEmitter {
10015
10187
  };
10016
10188
  timeoutObject = setTimeout(clear, timeout);
10017
10189
  const thr = { timeoutObject, clear, count: 0 };
10018
- action.set(path14, thr);
10190
+ action.set(path15, thr);
10019
10191
  return thr;
10020
10192
  }
10021
10193
  _incrReadyCount() {
10022
10194
  return this._readyCount++;
10023
10195
  }
10024
- _awaitWriteFinish(path14, threshold, event, awfEmit) {
10196
+ _awaitWriteFinish(path15, threshold, event, awfEmit) {
10025
10197
  const awf = this.options.awaitWriteFinish;
10026
10198
  if (typeof awf !== "object")
10027
10199
  return;
10028
10200
  const pollInterval = awf.pollInterval;
10029
10201
  let timeoutHandler;
10030
- let fullPath = path14;
10031
- if (this.options.cwd && !sysPath2.isAbsolute(path14)) {
10032
- fullPath = sysPath2.join(this.options.cwd, path14);
10202
+ let fullPath = path15;
10203
+ if (this.options.cwd && !sysPath2.isAbsolute(path15)) {
10204
+ fullPath = sysPath2.join(this.options.cwd, path15);
10033
10205
  }
10034
10206
  const now = new Date;
10035
10207
  const writes = this._pendingWrites;
10036
10208
  function awaitWriteFinishFn(prevStat) {
10037
10209
  statcb(fullPath, (err, curStat) => {
10038
- if (err || !writes.has(path14)) {
10210
+ if (err || !writes.has(path15)) {
10039
10211
  if (err && err.code !== "ENOENT")
10040
10212
  awfEmit(err);
10041
10213
  return;
10042
10214
  }
10043
10215
  const now2 = Number(new Date);
10044
10216
  if (prevStat && curStat.size !== prevStat.size) {
10045
- writes.get(path14).lastChange = now2;
10217
+ writes.get(path15).lastChange = now2;
10046
10218
  }
10047
- const pw = writes.get(path14);
10219
+ const pw = writes.get(path15);
10048
10220
  const df = now2 - pw.lastChange;
10049
10221
  if (df >= threshold) {
10050
- writes.delete(path14);
10222
+ writes.delete(path15);
10051
10223
  awfEmit(undefined, curStat);
10052
10224
  } else {
10053
10225
  timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
10054
10226
  }
10055
10227
  });
10056
10228
  }
10057
- if (!writes.has(path14)) {
10058
- writes.set(path14, {
10229
+ if (!writes.has(path15)) {
10230
+ writes.set(path15, {
10059
10231
  lastChange: now,
10060
10232
  cancelWait: () => {
10061
- writes.delete(path14);
10233
+ writes.delete(path15);
10062
10234
  clearTimeout(timeoutHandler);
10063
10235
  return event;
10064
10236
  }
@@ -10066,8 +10238,8 @@ class FSWatcher extends EventEmitter {
10066
10238
  timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval);
10067
10239
  }
10068
10240
  }
10069
- _isIgnored(path14, stats) {
10070
- if (this.options.atomic && DOT_RE.test(path14))
10241
+ _isIgnored(path15, stats) {
10242
+ if (this.options.atomic && DOT_RE.test(path15))
10071
10243
  return true;
10072
10244
  if (!this._userIgnored) {
10073
10245
  const { cwd } = this.options;
@@ -10077,13 +10249,13 @@ class FSWatcher extends EventEmitter {
10077
10249
  const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
10078
10250
  this._userIgnored = anymatch(list, undefined);
10079
10251
  }
10080
- return this._userIgnored(path14, stats);
10252
+ return this._userIgnored(path15, stats);
10081
10253
  }
10082
- _isntIgnored(path14, stat5) {
10083
- return !this._isIgnored(path14, stat5);
10254
+ _isntIgnored(path15, stat5) {
10255
+ return !this._isIgnored(path15, stat5);
10084
10256
  }
10085
- _getWatchHelpers(path14) {
10086
- return new WatchHelper(path14, this.options.followSymlinks, this);
10257
+ _getWatchHelpers(path15) {
10258
+ return new WatchHelper(path15, this.options.followSymlinks, this);
10087
10259
  }
10088
10260
  _getWatchedDir(directory) {
10089
10261
  const dir = sysPath2.resolve(directory);
@@ -10097,57 +10269,57 @@ class FSWatcher extends EventEmitter {
10097
10269
  return Boolean(Number(stats.mode) & 256);
10098
10270
  }
10099
10271
  _remove(directory, item, isDirectory) {
10100
- const path14 = sysPath2.join(directory, item);
10101
- const fullPath = sysPath2.resolve(path14);
10102
- isDirectory = isDirectory != null ? isDirectory : this._watched.has(path14) || this._watched.has(fullPath);
10103
- if (!this._throttle("remove", path14, 100))
10272
+ const path15 = sysPath2.join(directory, item);
10273
+ const fullPath = sysPath2.resolve(path15);
10274
+ isDirectory = isDirectory != null ? isDirectory : this._watched.has(path15) || this._watched.has(fullPath);
10275
+ if (!this._throttle("remove", path15, 100))
10104
10276
  return;
10105
10277
  if (!isDirectory && this._watched.size === 1) {
10106
10278
  this.add(directory, item, true);
10107
10279
  }
10108
- const wp = this._getWatchedDir(path14);
10280
+ const wp = this._getWatchedDir(path15);
10109
10281
  const nestedDirectoryChildren = wp.getChildren();
10110
- nestedDirectoryChildren.forEach((nested) => this._remove(path14, nested));
10282
+ nestedDirectoryChildren.forEach((nested) => this._remove(path15, nested));
10111
10283
  const parent = this._getWatchedDir(directory);
10112
10284
  const wasTracked = parent.has(item);
10113
10285
  parent.remove(item);
10114
10286
  if (this._symlinkPaths.has(fullPath)) {
10115
10287
  this._symlinkPaths.delete(fullPath);
10116
10288
  }
10117
- let relPath = path14;
10289
+ let relPath = path15;
10118
10290
  if (this.options.cwd)
10119
- relPath = sysPath2.relative(this.options.cwd, path14);
10291
+ relPath = sysPath2.relative(this.options.cwd, path15);
10120
10292
  if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
10121
10293
  const event = this._pendingWrites.get(relPath).cancelWait();
10122
10294
  if (event === EVENTS.ADD)
10123
10295
  return;
10124
10296
  }
10125
- this._watched.delete(path14);
10297
+ this._watched.delete(path15);
10126
10298
  this._watched.delete(fullPath);
10127
10299
  const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
10128
- if (wasTracked && !this._isIgnored(path14))
10129
- this._emit(eventName, path14);
10130
- this._closePath(path14);
10300
+ if (wasTracked && !this._isIgnored(path15))
10301
+ this._emit(eventName, path15);
10302
+ this._closePath(path15);
10131
10303
  }
10132
- _closePath(path14) {
10133
- this._closeFile(path14);
10134
- const dir = sysPath2.dirname(path14);
10135
- this._getWatchedDir(dir).remove(sysPath2.basename(path14));
10304
+ _closePath(path15) {
10305
+ this._closeFile(path15);
10306
+ const dir = sysPath2.dirname(path15);
10307
+ this._getWatchedDir(dir).remove(sysPath2.basename(path15));
10136
10308
  }
10137
- _closeFile(path14) {
10138
- const closers = this._closers.get(path14);
10309
+ _closeFile(path15) {
10310
+ const closers = this._closers.get(path15);
10139
10311
  if (!closers)
10140
10312
  return;
10141
10313
  closers.forEach((closer) => closer());
10142
- this._closers.delete(path14);
10314
+ this._closers.delete(path15);
10143
10315
  }
10144
- _addPathCloser(path14, closer) {
10316
+ _addPathCloser(path15, closer) {
10145
10317
  if (!closer)
10146
10318
  return;
10147
- let list = this._closers.get(path14);
10319
+ let list = this._closers.get(path15);
10148
10320
  if (!list) {
10149
10321
  list = [];
10150
- this._closers.set(path14, list);
10322
+ this._closers.set(path15, list);
10151
10323
  }
10152
10324
  list.push(closer);
10153
10325
  }
@@ -10178,7 +10350,7 @@ var esm_default = { watch, FSWatcher };
10178
10350
 
10179
10351
  // src/cli/cli.ts
10180
10352
  var import_picocolors9 = __toESM(require_picocolors(), 1);
10181
- import path15 from "node:path";
10353
+ import path16 from "node:path";
10182
10354
  import { promises as fs12, existsSync as existsSync2 } from "node:fs";
10183
10355
  import { spawn as spawn2, spawnSync } from "node:child_process";
10184
10356
  import { pathToFileURL as pathToFileURL4 } from "node:url";
@@ -10187,7 +10359,7 @@ import { createRequire as createRequire3 } from "node:module";
10187
10359
  // src/cli/auth-keys.ts
10188
10360
  import * as crypto2 from "crypto";
10189
10361
  import * as fs11 from "fs/promises";
10190
- import * as path14 from "path";
10362
+ import * as path15 from "path";
10191
10363
  var AUTH_KEYS_FILENAME = "auth-keys.json";
10192
10364
  async function generateAuthKeys() {
10193
10365
  return new Promise((resolve3, reject) => {
@@ -10234,7 +10406,7 @@ function createJwksFromPublicKey(publicKeyPem, kid) {
10234
10406
  };
10235
10407
  }
10236
10408
  async function loadOrGenerateAuthKeys(dataDir) {
10237
- const keysPath = path14.join(dataDir, AUTH_KEYS_FILENAME);
10409
+ const keysPath = path15.join(dataDir, AUTH_KEYS_FILENAME);
10238
10410
  try {
10239
10411
  const data = await fs11.readFile(keysPath, "utf-8");
10240
10412
  const stored = JSON.parse(data);
@@ -10261,7 +10433,7 @@ async function loadOrGenerateAuthKeys(dataDir) {
10261
10433
  }
10262
10434
  }
10263
10435
  async function detectAuthProjectFlavor(projectRoot) {
10264
- const packageJsonPath = path14.join(projectRoot, "package.json");
10436
+ const packageJsonPath = path15.join(projectRoot, "package.json");
10265
10437
  try {
10266
10438
  const raw = await fs11.readFile(packageJsonPath, "utf-8");
10267
10439
  const parsed = JSON.parse(raw);
@@ -10303,7 +10475,7 @@ function setupAuthEnvironment(keys, siteUrl, options = {}) {
10303
10475
  setEnv("AUTH_SKIP_VERIFICATION", "true");
10304
10476
  }
10305
10477
  // package.json
10306
- var version = "0.0.1-alpha.8";
10478
+ var version = "0.0.1-alpha.9";
10307
10479
 
10308
10480
  // src/cli/cli.ts
10309
10481
  var WATCH_IGNORE_PATTERNS = [
@@ -10343,16 +10515,16 @@ function detectPreferredRuntime() {
10343
10515
  return "node";
10344
10516
  }
10345
10517
  function detectPackageManager(projectRoot) {
10346
- if (existsSync2(path15.join(projectRoot, "bun.lock")) || existsSync2(path15.join(projectRoot, "bun.lockb"))) {
10518
+ if (existsSync2(path16.join(projectRoot, "bun.lock")) || existsSync2(path16.join(projectRoot, "bun.lockb"))) {
10347
10519
  return "bun";
10348
10520
  }
10349
- if (existsSync2(path15.join(projectRoot, "pnpm-lock.yaml"))) {
10521
+ if (existsSync2(path16.join(projectRoot, "pnpm-lock.yaml"))) {
10350
10522
  return "pnpm";
10351
10523
  }
10352
- if (existsSync2(path15.join(projectRoot, "yarn.lock"))) {
10524
+ if (existsSync2(path16.join(projectRoot, "yarn.lock"))) {
10353
10525
  return "yarn";
10354
10526
  }
10355
- if (existsSync2(path15.join(projectRoot, "package-lock.json")) || existsSync2(path15.join(projectRoot, "npm-shrinkwrap.json"))) {
10527
+ if (existsSync2(path16.join(projectRoot, "package-lock.json")) || existsSync2(path16.join(projectRoot, "npm-shrinkwrap.json"))) {
10356
10528
  return "npm";
10357
10529
  }
10358
10530
  return isBunAvailable() ? "bun" : "npm";
@@ -10389,11 +10561,11 @@ function sanitizePackageName(input) {
10389
10561
  return normalized.length > 0 ? normalized : "concave-app";
10390
10562
  }
10391
10563
  function formatPathForDisplay(fromDir, targetPath) {
10392
- const relative3 = path15.relative(fromDir, targetPath);
10564
+ const relative3 = path16.relative(fromDir, targetPath);
10393
10565
  if (!relative3 || relative3 === ".") {
10394
10566
  return ".";
10395
10567
  }
10396
- if (!relative3.startsWith("..") && !path15.isAbsolute(relative3)) {
10568
+ if (!relative3.startsWith("..") && !path16.isAbsolute(relative3)) {
10397
10569
  return relative3;
10398
10570
  }
10399
10571
  return targetPath;
@@ -10403,7 +10575,7 @@ function hasConvexDependency(packageJson) {
10403
10575
  }
10404
10576
  function createDefaultPackageJson(projectRoot) {
10405
10577
  return {
10406
- name: sanitizePackageName(path15.basename(projectRoot)),
10578
+ name: sanitizePackageName(path16.basename(projectRoot)),
10407
10579
  private: true,
10408
10580
  type: "module"
10409
10581
  };
@@ -10432,7 +10604,7 @@ async function writePackageJson(packageJsonPath, packageJson) {
10432
10604
  `, "utf8");
10433
10605
  }
10434
10606
  async function ensurePackageJsonWithConvexDependency(projectRoot) {
10435
- const packageJsonPath = path15.join(projectRoot, "package.json");
10607
+ const packageJsonPath = path16.join(projectRoot, "package.json");
10436
10608
  const existing = await readPackageJson(packageJsonPath);
10437
10609
  const packageJson = existing ?? createDefaultPackageJson(projectRoot);
10438
10610
  const createdPackageJson = existing === null;
@@ -10454,7 +10626,7 @@ async function ensurePackageJsonWithConvexDependency(projectRoot) {
10454
10626
  };
10455
10627
  }
10456
10628
  async function canResolveConvexRuntime(projectRoot) {
10457
- const requireFromProject = createRequire3(path15.join(projectRoot, "__concave__.js"));
10629
+ const requireFromProject = createRequire3(path16.join(projectRoot, "__concave__.js"));
10458
10630
  try {
10459
10631
  requireFromProject.resolve("convex/values");
10460
10632
  requireFromProject.resolve("convex/server");
@@ -10479,7 +10651,7 @@ async function ensureConvexDependencyReady(projectRoot, commandName) {
10479
10651
  const packageManager = detectPackageManager(projectRoot);
10480
10652
  const addCommand = getAddConvexCommand(packageManager);
10481
10653
  const installCommand = getInstallCommand(packageManager);
10482
- const packageJsonPath = path15.join(projectRoot, "package.json");
10654
+ const packageJsonPath = path16.join(projectRoot, "package.json");
10483
10655
  const packageJson = await readPackageJson(packageJsonPath);
10484
10656
  if (!packageJson) {
10485
10657
  console.error(import_picocolors9.default.red("✗ Missing package.json"));
@@ -10533,10 +10705,10 @@ function parseDotEnv2(content) {
10533
10705
  }
10534
10706
  async function loadDevEnvironment(cwd, layout) {
10535
10707
  const candidates = [
10536
- path15.join(layout.convexRootDir, ".env.local"),
10537
- path15.join(layout.convexRootDir, ".env"),
10538
- path15.join(cwd, ".env.local"),
10539
- path15.join(cwd, ".env")
10708
+ path16.join(layout.convexRootDir, ".env.local"),
10709
+ path16.join(layout.convexRootDir, ".env"),
10710
+ path16.join(cwd, ".env.local"),
10711
+ path16.join(cwd, ".env")
10540
10712
  ];
10541
10713
  const loaded = [];
10542
10714
  for (const filePath of candidates) {
@@ -10550,7 +10722,7 @@ async function loadDevEnvironment(cwd, layout) {
10550
10722
  process.env[key] = value;
10551
10723
  }
10552
10724
  }
10553
- loaded.push(path15.relative(cwd, filePath));
10725
+ loaded.push(path16.relative(cwd, filePath));
10554
10726
  }
10555
10727
  return loaded;
10556
10728
  }
@@ -10563,11 +10735,11 @@ Examples:
10563
10735
  $ concave init my-app --force Overwrite starter files
10564
10736
  `).action(async (dir, opts) => {
10565
10737
  const cwd = process.cwd();
10566
- const projectRoot = path15.resolve(cwd, dir ?? ".");
10738
+ const projectRoot = path16.resolve(cwd, dir ?? ".");
10567
10739
  const displayRoot = formatPathForDisplay(cwd, projectRoot);
10568
10740
  const layout = await resolveProjectLayout(projectRoot);
10569
10741
  const convexDir = layout.functionsDir;
10570
- const starterPath = path15.join(convexDir, "messages.ts");
10742
+ const starterPath = path16.join(convexDir, "messages.ts");
10571
10743
  await fs12.mkdir(projectRoot, { recursive: true });
10572
10744
  await fs12.mkdir(convexDir, { recursive: true });
10573
10745
  const starterExists = existsSync2(starterPath);
@@ -10691,16 +10863,17 @@ Examples:
10691
10863
  });
10692
10864
  console.log(import_picocolors9.default.green(`✓ Generated worker entry (${result.moduleCount} module${result.moduleCount === 1 ? "" : "s"})`));
10693
10865
  const configPath = await ensureWranglerConfig(cwd);
10694
- console.log(import_picocolors9.default.green(`✓ Using config: ${path15.basename(configPath)}`));
10695
- const relativeConfigPath = path15.relative(cwd, configPath);
10696
- const wranglerArgs = ["wrangler", "dev", "--config", relativeConfigPath];
10866
+ console.log(import_picocolors9.default.green(`✓ Using config: ${path16.basename(configPath)}`));
10867
+ const relativeConfigPath = path16.relative(cwd, configPath);
10868
+ const wranglerArgs = ["dev", "--config", relativeConfigPath];
10697
10869
  if (opts.port) {
10698
10870
  wranglerArgs.push("--port", opts.port);
10699
10871
  }
10700
10872
  console.log(import_picocolors9.default.cyan(`
10701
10873
  \uD83D\uDE80 Starting wrangler dev...
10702
10874
  `));
10703
- wranglerProcess = spawn2("bunx", wranglerArgs, {
10875
+ const wranglerLauncher = resolveWranglerLauncher({ cwd });
10876
+ wranglerProcess = spawn2(wranglerLauncher.command, [...wranglerLauncher.argsPrefix, ...wranglerArgs], {
10704
10877
  cwd,
10705
10878
  stdio: "inherit"
10706
10879
  });
@@ -10723,7 +10896,7 @@ Examples:
10723
10896
  try {
10724
10897
  await generateTypes(cwd, { silent: true });
10725
10898
  } catch {}
10726
- const relPath = path15.relative(cwd, filePath);
10899
+ const relPath = path16.relative(cwd, filePath);
10727
10900
  console.log(import_picocolors9.default.dim(` Updated worker entry (${event}: ${relPath || "convex/"}, ${regenResult.moduleCount} module${regenResult.moduleCount === 1 ? "" : "s"})`));
10728
10901
  } catch (error) {
10729
10902
  console.error(import_picocolors9.default.red("✗ Failed to update worker entry:"), error.message ?? error);
@@ -10905,10 +11078,10 @@ Examples:
10905
11078
  console.log(import_picocolors9.default.green(`✓ Generated standalone entry (${result.moduleCount} module${result.moduleCount === 1 ? "" : "s"})`));
10906
11079
  if (opts.verbose) {
10907
11080
  for (const file of result.sourceFiles) {
10908
- console.log(import_picocolors9.default.dim(` ${path15.relative(cwd, file)}`));
11081
+ console.log(import_picocolors9.default.dim(` ${path16.relative(cwd, file)}`));
10909
11082
  }
10910
11083
  }
10911
- const outfile = path15.resolve(cwd, opts.outfile);
11084
+ const outfile = path16.resolve(cwd, opts.outfile);
10912
11085
  const buildArgs = ["build", "--compile", result.entryFile, "--outfile", outfile];
10913
11086
  if (opts.target) {
10914
11087
  buildArgs.push("--target", `bun-${opts.target}`);
@@ -10938,13 +11111,13 @@ Examples:
10938
11111
  sizeStr = ` (${sizeMB} MB)`;
10939
11112
  } catch {}
10940
11113
  console.log(import_picocolors9.default.green(`
10941
- ✓ Built: ${path15.relative(cwd, outfile)}${sizeStr}`));
11114
+ ✓ Built: ${path16.relative(cwd, outfile)}${sizeStr}`));
10942
11115
  if (opts.target) {
10943
11116
  console.log(import_picocolors9.default.dim(` Target: bun-${opts.target}`));
10944
11117
  }
10945
11118
  console.log(import_picocolors9.default.dim(`
10946
11119
  Run it:`));
10947
- console.log(import_picocolors9.default.dim(` ./${path15.relative(cwd, outfile)} --port 3000`));
11120
+ console.log(import_picocolors9.default.dim(` ./${path16.relative(cwd, outfile)} --port 3000`));
10948
11121
  } catch (error) {
10949
11122
  console.error(import_picocolors9.default.red("✗ Build failed:"), error.message);
10950
11123
  if (opts.verbose && error.stack) {
@@ -11026,7 +11199,7 @@ async function listFunctionSpecs(options) {
11026
11199
  const result = await response.json();
11027
11200
  const functions = result.value || result.result || [];
11028
11201
  if (options.file) {
11029
- const outPath = path15.resolve("function-spec.json");
11202
+ const outPath = path16.resolve("function-spec.json");
11030
11203
  await fs12.writeFile(outPath, JSON.stringify(functions, null, 2) + `
11031
11204
  `);
11032
11205
  console.log(import_picocolors9.default.green(`✓ Wrote ${functions.length} function specs to ${outPath}`));
@@ -11139,7 +11312,7 @@ async function runBunDevServer(cwd, opts, artifacts, layout) {
11139
11312
  console.log(import_picocolors9.default.cyan(`
11140
11313
  \uD83D\uDE80 Server ready at ${import_picocolors9.default.bold(displayUrl)}`));
11141
11314
  console.log(import_picocolors9.default.dim(` Dashboard: ${displayUrl}/_dashboard`));
11142
- console.log(import_picocolors9.default.dim(` Functions: ${path15.relative(cwd, functionsDir)}/`));
11315
+ console.log(import_picocolors9.default.dim(` Functions: ${path16.relative(cwd, functionsDir)}/`));
11143
11316
  console.log(import_picocolors9.default.dim(`
11144
11317
  Press Ctrl+C to stop
11145
11318
  `));
@@ -11180,7 +11353,7 @@ async function runBunDevServer(cwd, opts, artifacts, layout) {
11180
11353
  }
11181
11354
  reloadTimer = setTimeout(async () => {
11182
11355
  reloadTimer = undefined;
11183
- const relPath = path15.relative(cwd, filePath);
11356
+ const relPath = path16.relative(cwd, filePath);
11184
11357
  try {
11185
11358
  await generateTypes(cwd, { silent: true });
11186
11359
  } catch {}
@@ -11248,7 +11421,7 @@ async function runBunDevServerForked(cwd, opts, artifacts, layout) {
11248
11421
  } catch (error) {
11249
11422
  console.warn(import_picocolors9.default.yellow(`⚠️ Auth keys setup failed: ${error.message}`));
11250
11423
  }
11251
- const tempScriptPath = path15.join(localData.dataDir, ".bun-dev-server.js");
11424
+ const tempScriptPath = path16.join(localData.dataDir, ".bun-dev-server.js");
11252
11425
  const dashboardModulePath = artifacts.dashboardHtmlPath.replace(/\\/g, "/");
11253
11426
  const scriptContent = `import { BunServer } from "${artifacts.bunRuntime.serverEntryPath.replace(/\\/g, "/")}";
11254
11427
  import { DASHBOARD_HTML } from ${JSON.stringify(dashboardModulePath)};
@@ -11265,7 +11438,7 @@ const displayUrl = server.url.replace(/127\\.0\\.0\\.1|0\\.0\\.0\\.0/, "localhos
11265
11438
 
11266
11439
  console.log("\\n\uD83D\uDE80 Server ready at " + displayUrl);
11267
11440
  console.log(" Dashboard: " + displayUrl + "/_dashboard");
11268
- console.log(" Functions: ${path15.relative(cwd, functionsDir).replace(/\\/g, "/")}/");
11441
+ console.log(" Functions: ${path16.relative(cwd, functionsDir).replace(/\\/g, "/")}/");
11269
11442
  console.log("\\n Press Ctrl+C to stop\\n");
11270
11443
 
11271
11444
  // Handle graceful shutdown
@@ -11400,7 +11573,7 @@ process.on("SIGTERM", async () => {
11400
11573
  }
11401
11574
  reloadTimer = setTimeout(async () => {
11402
11575
  reloadTimer = undefined;
11403
- const relPath = path15.relative(cwd, filePath);
11576
+ const relPath = path16.relative(cwd, filePath);
11404
11577
  try {
11405
11578
  await generateTypes(cwd, { silent: true });
11406
11579
  } catch {}
@@ -11472,7 +11645,7 @@ function resolveTsxLoaderPath() {
11472
11645
  let tsxLoaderPath = "tsx";
11473
11646
  try {
11474
11647
  const tsxPackagePath = require2.resolve("tsx/package.json");
11475
- tsxLoaderPath = path15.join(path15.dirname(tsxPackagePath), "dist/loader.mjs");
11648
+ tsxLoaderPath = path16.join(path16.dirname(tsxPackagePath), "dist/loader.mjs");
11476
11649
  } catch {
11477
11650
  tsxLoaderPath = "tsx";
11478
11651
  }
@@ -11560,7 +11733,7 @@ async function runNodeDevServer(cwd, opts, artifacts, layout) {
11560
11733
  console.log(import_picocolors9.default.cyan(`
11561
11734
  \uD83D\uDE80 Server ready at ${import_picocolors9.default.bold(displayUrl)}`));
11562
11735
  console.log(import_picocolors9.default.dim(` Dashboard: ${displayUrl}/_dashboard`));
11563
- console.log(import_picocolors9.default.dim(` Functions: ${path15.relative(cwd, functionsDir)}/`));
11736
+ console.log(import_picocolors9.default.dim(` Functions: ${path16.relative(cwd, functionsDir)}/`));
11564
11737
  console.log(import_picocolors9.default.dim(`
11565
11738
  Press Ctrl+C to stop
11566
11739
  `));
@@ -11601,7 +11774,7 @@ async function runNodeDevServer(cwd, opts, artifacts, layout) {
11601
11774
  }
11602
11775
  reloadTimer = setTimeout(async () => {
11603
11776
  reloadTimer = undefined;
11604
- const relPath = path15.relative(cwd, filePath);
11777
+ const relPath = path16.relative(cwd, filePath);
11605
11778
  try {
11606
11779
  await generateTypes(cwd, { silent: true });
11607
11780
  } catch {}
@@ -11673,11 +11846,11 @@ async function runNodeDevServerForked(cwd, opts, artifacts, layout) {
11673
11846
  let tsxLoaderPath;
11674
11847
  try {
11675
11848
  const tsxPackagePath = require2.resolve("tsx/package.json");
11676
- tsxLoaderPath = path15.join(path15.dirname(tsxPackagePath), "dist/loader.mjs");
11849
+ tsxLoaderPath = path16.join(path16.dirname(tsxPackagePath), "dist/loader.mjs");
11677
11850
  } catch {
11678
11851
  tsxLoaderPath = "tsx";
11679
11852
  }
11680
- const tempScriptPath = path15.join(localData.dataDir, ".node-dev-server.mjs");
11853
+ const tempScriptPath = path16.join(localData.dataDir, ".node-dev-server.mjs");
11681
11854
  const nodeDashboardModulePath = artifacts.dashboardHtmlPath.replace(/\\/g, "/");
11682
11855
  const scriptContent = `import { NodeServer } from "${artifacts.nodeRuntime.serverEntryPath.replace(/\\/g, "/")}";
11683
11856
  import { DASHBOARD_HTML } from ${JSON.stringify(nodeDashboardModulePath)};
@@ -11694,7 +11867,7 @@ const displayUrl = server.url.replace(/127\\.0\\.0\\.1|0\\.0\\.0\\.0/, "localhos
11694
11867
 
11695
11868
  console.log("\\n\uD83D\uDE80 Server ready at " + displayUrl);
11696
11869
  console.log(" Dashboard: " + displayUrl + "/_dashboard");
11697
- console.log(" Functions: ${path15.relative(cwd, functionsDir).replace(/\\/g, "/")}/");
11870
+ console.log(" Functions: ${path16.relative(cwd, functionsDir).replace(/\\/g, "/")}/");
11698
11871
  console.log("\\n Press Ctrl+C to stop\\n");
11699
11872
 
11700
11873
  // Handle graceful shutdown
@@ -11830,7 +12003,7 @@ process.on("SIGTERM", async () => {
11830
12003
  }
11831
12004
  reloadTimer = setTimeout(async () => {
11832
12005
  reloadTimer = undefined;
11833
- const relPath = path15.relative(cwd, filePath);
12006
+ const relPath = path16.relative(cwd, filePath);
11834
12007
  try {
11835
12008
  await generateTypes(cwd, { silent: true });
11836
12009
  } catch {}
@@ -11854,9 +12027,9 @@ process.on("SIGTERM", async () => {
11854
12027
  }
11855
12028
  async function ensureWranglerConfig(cwd) {
11856
12029
  const userConfigs = [
11857
- path15.join(cwd, "wrangler.jsonc"),
11858
- path15.join(cwd, "wrangler.json"),
11859
- path15.join(cwd, "wrangler.toml")
12030
+ path16.join(cwd, "wrangler.jsonc"),
12031
+ path16.join(cwd, "wrangler.json"),
12032
+ path16.join(cwd, "wrangler.toml")
11860
12033
  ];
11861
12034
  for (const configPath of userConfigs) {
11862
12035
  try {
@@ -11865,8 +12038,8 @@ async function ensureWranglerConfig(cwd) {
11865
12038
  } catch {}
11866
12039
  }
11867
12040
  const concavePaths = getConcaveProjectPaths(cwd);
11868
- const generatedConfigPath = path15.join(concavePaths.concaveDir, "wrangler.jsonc");
11869
- const assetsDirectory = path15.join(concavePaths.concaveDir, "static");
12041
+ const generatedConfigPath = path16.join(concavePaths.concaveDir, "wrangler.jsonc");
12042
+ const assetsDirectory = path16.join(concavePaths.concaveDir, "static");
11870
12043
  await fs12.mkdir(assetsDirectory, { recursive: true });
11871
12044
  const config = {
11872
12045
  name: "concave-app",
@@ -11889,7 +12062,7 @@ async function ensureWranglerConfig(cwd) {
11889
12062
  }
11890
12063
  ]
11891
12064
  };
11892
- await fs12.mkdir(path15.dirname(generatedConfigPath), { recursive: true });
12065
+ await fs12.mkdir(path16.dirname(generatedConfigPath), { recursive: true });
11893
12066
  await fs12.writeFile(generatedConfigPath, JSON.stringify(config, null, 2), "utf8");
11894
12067
  return generatedConfigPath;
11895
12068
  }