kitcn 0.33.11 → 0.34.0
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/CHANGELOG.md +75 -0
- package/dist/aggregate/index.d.ts +1 -1
- package/dist/aggregate/index.js +2 -2
- package/dist/auth/generated/index.d.ts +1 -1
- package/dist/auth/index.d.ts +23 -6
- package/dist/auth/index.js +42 -5
- package/dist/auth/nextjs/index.d.ts +1 -1
- package/dist/auth/start/server/index.d.ts +1 -1
- package/dist/{builder-C4FTb9Ci.js → builder-Dnl9L8Bf.js} +5 -2
- package/dist/cli.mjs +344 -145
- package/dist/{customFunctions-X_B4kET8.js → customFunctions-CWs3rEjV.js} +1 -1
- package/dist/{definitions-3PX4ywR-.js → definitions-moOcjYL-.js} +2 -2
- package/dist/{extensions-Bp0XHanR.js → extensions-CKfn_Qi-.js} +1 -1
- package/dist/{generated-contract-disabled-DcgLIEHK.d.ts → generated-contract-disabled-78J7oFCT.d.ts} +1 -1
- package/dist/{index-utils-DvK7P6Q1.js → index-utils-COOY08yW.js} +1 -1
- package/dist/{local-env-tM3bdL1l.mjs → local-env-wuMk1Mo7.mjs} +291 -165
- package/dist/{middleware-0x76j2pR.js → middleware-Dggk6LBC.js} +1 -1
- package/dist/orm/aggregate-index/index.js +4 -4
- package/dist/orm/index.d.ts +2 -2
- package/dist/orm/index.js +133 -84
- package/dist/orm/migrations/index.d.ts +1 -1
- package/dist/orm/migrations/index.js +1 -1
- package/dist/plugins/index.js +1 -1
- package/dist/{procedure-caller-CZDaDjju.js → procedure-caller-B4LlPViy.js} +1 -1
- package/dist/{procedure-name-DRSOwAJY.d.ts → procedure-name-D9GF2fZG.d.ts} +2 -2
- package/dist/ratelimit/index.js +2 -2
- package/dist/{runtime-B-8HKSIE.js → runtime-BDgBpBg4.js} +1 -1
- package/dist/{schema-BF4P0ZjS.js → schema-CFklsQxQ.js} +5 -5
- package/dist/{schema-BFP_awgP.js → schema-D0l-RIbL.js} +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +2 -2
- package/dist/{symbols-DDNAddkd.js → symbols-h1M2uuSB.js} +2 -1
- package/dist/{table-d9o_n4R3.js → table-Bh9i5LCc.js} +201 -109
- package/dist/{validators-0I-Ik1EN.d.ts → validators-VXKPVvVp.d.ts} +1 -1
- package/dist/{validators-CIoUYCqO.js → validators-cPSuYAHV.js} +7 -1
- package/dist/watcher.mjs +1 -1
- package/dist/{where-clause-compiler-DNFGsYBl.d.ts → where-clause-compiler-dGV0ALDz.d.ts} +59 -59
- package/package.json +2 -2
- package/skills/kitcn/references/features/auth.md +9 -0
- package/skills/kitcn/references/setup/index.md +11 -0
package/dist/cli.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { C as Columns, D as TableName, E as RlsPolicies, O as createSystemFields, S as getRankIndexes, T as OrmSchemaExtensions, _ as loadEsbuild, a as generateMeta, b as getAggregateIndexes, c as resolveSchemaDefaultExport, f as createProjectJiti, g as loadDotenv, h as loadClackPrompts, i as resolveConfiguredBackend, l as schemaDeclaresAggregateIndexes, m as loadBabelParser, n as withLocalCodegenEnv, o as getConvexConfig, p as CRPC_BUILDER_STUB_SOURCE, r as loadCliConfig, s as collectSchemaTables, t as getLocalBackendEnvVars, u as logger, v as highlighter, w as EnableRLS, x as getIndexes, y as isColorEnabled } from "./local-env-
|
|
2
|
+
import { C as Columns, D as TableName, E as RlsPolicies, O as createSystemFields, S as getRankIndexes, T as OrmSchemaExtensions, _ as loadEsbuild, a as generateMeta, b as getAggregateIndexes, c as resolveSchemaDefaultExport, f as createProjectJiti, g as loadDotenv, h as loadClackPrompts, i as resolveConfiguredBackend, l as schemaDeclaresAggregateIndexes, m as loadBabelParser, n as withLocalCodegenEnv, o as getConvexConfig, p as CRPC_BUILDER_STUB_SOURCE, r as loadCliConfig, s as collectSchemaTables, t as getLocalBackendEnvVars, u as logger, v as highlighter, w as EnableRLS, x as getIndexes, y as isColorEnabled } from "./local-env-wuMk1Mo7.mjs";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import fs, { existsSync, readFileSync } from "node:fs";
|
|
5
|
-
import path, { basename, delimiter, dirname, extname, isAbsolute, join, posix, relative, resolve } from "node:path";
|
|
5
|
+
import path, { basename, delimiter, dirname, extname, isAbsolute, join, posix, relative, resolve, sep } from "node:path";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
7
|
import { createHash, randomBytes } from "node:crypto";
|
|
8
8
|
import { execa } from "execa";
|
|
9
|
-
import os from "node:os";
|
|
9
|
+
import os, { tmpdir } from "node:os";
|
|
10
10
|
import { createInterface } from "node:readline/promises";
|
|
11
11
|
import { diffWords, structuredPatch } from "diff";
|
|
12
12
|
import { parseEnv } from "node:util";
|
|
@@ -1745,7 +1745,17 @@ const CONVEX_OUTPUT_NOISE_LINES = [
|
|
|
1745
1745
|
/^Changelog: https:\/\/github\.com\/get-convex\/convex-js\/blob\/main\/CHANGELOG\.md#changelog$/
|
|
1746
1746
|
];
|
|
1747
1747
|
const CONVEX_OUTPUT_LINE_SPLIT_RE = /\r?\n/;
|
|
1748
|
-
const
|
|
1748
|
+
const require$2 = createRequire(import.meta.url);
|
|
1749
|
+
const convexPkg = require$2.resolve("convex/package.json");
|
|
1750
|
+
const REAL_CONVEX_CLI_PATH = join(dirname(convexPkg), "bin/main.js");
|
|
1751
|
+
const LOCAL_CONVEX_VERSION = require$2(convexPkg).version;
|
|
1752
|
+
const VERSION_MAJOR_MINOR_RE = /^(\d+)\.(\d+)/;
|
|
1753
|
+
const isConvexVersionAtLeast = (version, major, minor) => {
|
|
1754
|
+
const match = VERSION_MAJOR_MINOR_RE.exec(version);
|
|
1755
|
+
if (!match) return false;
|
|
1756
|
+
const versionMajor = Number(match[1]);
|
|
1757
|
+
return versionMajor > major || versionMajor === major && Number(match[2]) >= minor;
|
|
1758
|
+
};
|
|
1749
1759
|
const CLEARED_CONVEX_ENV = {
|
|
1750
1760
|
CONVEX_DEPLOYMENT: void 0,
|
|
1751
1761
|
CONVEX_DEPLOY_KEY: void 0,
|
|
@@ -1763,8 +1773,12 @@ const writeConvexCommandOutput = (result) => {
|
|
|
1763
1773
|
if (result.stderr) process.stderr.write(result.stderr.endsWith("\n") ? result.stderr : `${result.stderr}\n`);
|
|
1764
1774
|
};
|
|
1765
1775
|
const formatConvexCommandFailure = (args, result) => {
|
|
1776
|
+
const command = `convex ${args.map((arg, index) => {
|
|
1777
|
+
if (args[index - 1] === "--admin-key") return "<redacted>";
|
|
1778
|
+
return arg.startsWith("--admin-key=") ? "--admin-key=<redacted>" : arg;
|
|
1779
|
+
}).join(" ")} failed.`;
|
|
1766
1780
|
const output = `${result.stdout}\n${result.stderr}`.trim();
|
|
1767
|
-
return output
|
|
1781
|
+
return output ? `${command}\n${output}` : command;
|
|
1768
1782
|
};
|
|
1769
1783
|
const runLocalConvexCommand = async (args, options) => {
|
|
1770
1784
|
return normalizeConvexCommandResult(await execa("node", [REAL_CONVEX_CLI_PATH, ...args], {
|
|
@@ -2029,11 +2043,13 @@ async function pushEnv(options = {}, deps = {}) {
|
|
|
2029
2043
|
async function pullEnv(options = {}, deps = {}) {
|
|
2030
2044
|
const cwd = process.cwd();
|
|
2031
2045
|
const runCommand = deps.runCommand ?? defaultRunCommand;
|
|
2046
|
+
const convexVersion = deps.convexVersion ?? LOCAL_CONVEX_VERSION;
|
|
2032
2047
|
const targetArgs = options.targetArgs ?? [];
|
|
2033
2048
|
const commandEnv = options.commandEnv;
|
|
2034
2049
|
const result = await runConvexCommand(runCommand, cwd, [
|
|
2035
2050
|
"env",
|
|
2036
2051
|
"list",
|
|
2052
|
+
...isConvexVersionAtLeast(convexVersion, 1, 47) ? ["--include-values"] : [],
|
|
2037
2053
|
...targetArgs
|
|
2038
2054
|
], commandEnv);
|
|
2039
2055
|
if (options.outFilePath) {
|
|
@@ -2318,7 +2334,7 @@ const PLAIN_VERSION_SPEC_RE = /^[\^~]?v?\d+\.\d+(?:\.\d+)?$/;
|
|
|
2318
2334
|
const UPPER_BOUND_RE = /(?:^|\s)<={0,1}\s*v?(\d+)\.(\d+)(?:\.\d+)?/g;
|
|
2319
2335
|
const LOWER_BOUND_RE = /(?:^|\s)>={0,1}\s*v?(\d+)\.(\d+)(?:\.\d+)?/g;
|
|
2320
2336
|
const SUPPORTED_CONCAVE_CLI_VERSION = "0.0.1-alpha.14";
|
|
2321
|
-
const SUPPORTED_CONVEX_VERSION = "1.
|
|
2337
|
+
const SUPPORTED_CONVEX_VERSION = "1.51.0";
|
|
2322
2338
|
const SUPPORTED_CONVEX_MIN_VERSION = "1.42";
|
|
2323
2339
|
const SUPPORTED_CONVEX_MIN_TYPE_VERSION = "1.42.3";
|
|
2324
2340
|
const SUPPORTED_BETTER_AUTH_VERSION = "1.7.1";
|
|
@@ -3059,6 +3075,11 @@ const normalizeLockfileScaffoldPath = (value) => {
|
|
|
3059
3075
|
if (normalized.length === 0 || normalized === "." || normalized === ".." || normalized.startsWith("../") || normalized.startsWith("/")) return null;
|
|
3060
3076
|
return normalized;
|
|
3061
3077
|
};
|
|
3078
|
+
const resolveEnvHelperFilePath = (envPath, cwd = process.cwd()) => {
|
|
3079
|
+
const resolved = resolve(cwd, normalizeRelativePathOrThrow$1(envPath, "paths.env"));
|
|
3080
|
+
if (existsSync(resolved) || resolved.endsWith(".ts")) return resolved;
|
|
3081
|
+
return `${resolved}.ts`;
|
|
3082
|
+
};
|
|
3062
3083
|
|
|
3063
3084
|
//#endregion
|
|
3064
3085
|
//#region src/cli/utils/typescript-runtime.ts
|
|
@@ -3292,8 +3313,9 @@ const collectInstalledPluginKeys = (lockfile, schemaPlugins) => [...new Set([...
|
|
|
3292
3313
|
|
|
3293
3314
|
//#endregion
|
|
3294
3315
|
//#region src/cli/registry/planner.ts
|
|
3316
|
+
const CONVEX_MODULE_PATH_RE = /^[a-zA-Z0-9_./]+$/;
|
|
3317
|
+
const CONVEX_ENTRY_NAME_RE = /^[^.#][^.]*\.[cm]?[jt]sx?$/;
|
|
3295
3318
|
const DEFINE_SCHEMA_CALL_RE = /defineSchema\s*\(([\s\S]*?)\)/m;
|
|
3296
|
-
const DEFAULT_ENV_HELPER_BASENAME = "get-env.ts";
|
|
3297
3319
|
const LOCAL_CONVEX_ENV_TEMPLATE_ID = "__kitcn-local-env__";
|
|
3298
3320
|
const KITCN_CONFIG_TEMPLATE_ID = "__kitcn-config__";
|
|
3299
3321
|
const KITCN_ENV_HELPER_TEMPLATE_ID = "__kitcn-env__";
|
|
@@ -3396,14 +3418,23 @@ const resolveEnvBootstrapPlanFileDetails = (templateId) => {
|
|
|
3396
3418
|
};
|
|
3397
3419
|
};
|
|
3398
3420
|
const isPlainObject$1 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3399
|
-
const resolveDefaultEnvHelperPath = (config) =>
|
|
3400
|
-
const
|
|
3401
|
-
const
|
|
3402
|
-
|
|
3403
|
-
const resolved = resolve(process.cwd(), normalized);
|
|
3404
|
-
if (fs.existsSync(resolved) || resolved.endsWith(".ts")) return resolved;
|
|
3405
|
-
return `${resolved}.ts`;
|
|
3421
|
+
const resolveDefaultEnvHelperPath = (config, functionsDir) => {
|
|
3422
|
+
const lib = normalizeRelativePathOrThrow$1(config.paths.lib, "paths.lib");
|
|
3423
|
+
const insideFunctions = (resolve(lib) + sep).startsWith(resolve(functionsDir) + sep);
|
|
3424
|
+
return posix.join(lib, insideFunctions && config.backend !== "concave" ? "getEnv.ts" : "get-env.ts");
|
|
3406
3425
|
};
|
|
3426
|
+
const resolveConfigWritePath = (configPathArg) => resolve(process.cwd(), configPathArg ?? "kitcn.json");
|
|
3427
|
+
function validateConvexEnvHelperPath(functionsDir, envPath) {
|
|
3428
|
+
const helper = resolveEnvHelperFilePath(envPath);
|
|
3429
|
+
const root = resolve(functionsDir);
|
|
3430
|
+
let modulePath = normalizePath$2(relative(root, helper));
|
|
3431
|
+
if (!modulePath || isAbsolute(modulePath) || modulePath.startsWith("../") || CONVEX_MODULE_PATH_RE.test(modulePath)) return;
|
|
3432
|
+
for (let dir = dirname(helper); dir !== root; dir = dirname(dir)) if (fs.statSync(join(dir, "convex.config.ts"), { throwIfNoEntry: false })?.isFile()) {
|
|
3433
|
+
modulePath = normalizePath$2(relative(dir, helper));
|
|
3434
|
+
break;
|
|
3435
|
+
}
|
|
3436
|
+
if (!modulePath.startsWith("_generated/") && !modulePath.includes(" ") && CONVEX_ENTRY_NAME_RE.test(basename(modulePath)) && !CONVEX_MODULE_PATH_RE.test(modulePath)) throw new Error(`Convex cannot load the env helper at ${envPath}. Move the helper outside ${relative(process.cwd(), functionsDir)}/ or rename its module path using letters, digits, underscores, and periods. Update paths.env in the kitcn config and any imports.`);
|
|
3437
|
+
}
|
|
3407
3438
|
const resolveLocalConvexEnvFilePath = (config) => resolve(process.cwd(), normalizeRelativePathOrThrow$1(config.paths.lib, "paths.lib"), "..", ".env");
|
|
3408
3439
|
const resolveBootstrapEnvFields = (envFields) => {
|
|
3409
3440
|
const fields = [...BASE_ENV_FIELDS];
|
|
@@ -3515,8 +3546,8 @@ const renderConfigWithEnvPath = (configPath, config, envPath) => {
|
|
|
3515
3546
|
if (config.backend !== "convex" || "backend" in nextRoot) nextRoot.backend = config.backend;
|
|
3516
3547
|
return `${JSON.stringify(nextRoot, null, 2)}\n`;
|
|
3517
3548
|
};
|
|
3518
|
-
const buildEnvBootstrapFiles = (config, configPathArg, envFields) => {
|
|
3519
|
-
const envPath = config.paths.env ?? resolveDefaultEnvHelperPath(config);
|
|
3549
|
+
const buildEnvBootstrapFiles = (functionsDir, config, configPathArg, envFields) => {
|
|
3550
|
+
const envPath = config.paths.env ?? resolveDefaultEnvHelperPath(config, functionsDir);
|
|
3520
3551
|
const nextConfig = config.paths.env ? config : {
|
|
3521
3552
|
...config,
|
|
3522
3553
|
paths: {
|
|
@@ -3576,7 +3607,7 @@ const resolvePluginScaffoldRoots = (functionsDir, descriptor, config, preset = d
|
|
|
3576
3607
|
clientLibRootDir: projectContext ? resolve(process.cwd(), projectContext.libDir) : null,
|
|
3577
3608
|
crpcFilePath: join(libRoot, "crpc.ts"),
|
|
3578
3609
|
sharedApiFilePath: resolve(process.cwd(), config.paths.shared, "api.ts"),
|
|
3579
|
-
envFilePath: resolveEnvHelperFilePath(config.paths.env ?? resolveDefaultEnvHelperPath(config)),
|
|
3610
|
+
envFilePath: resolveEnvHelperFilePath(config.paths.env ?? resolveDefaultEnvHelperPath(config, functionsDir)),
|
|
3580
3611
|
projectContext
|
|
3581
3612
|
};
|
|
3582
3613
|
return {
|
|
@@ -3689,7 +3720,7 @@ const buildPluginInstallPlan = async (params) => {
|
|
|
3689
3720
|
const envBootstrap = params.includeEnvBootstrap === false ? {
|
|
3690
3721
|
config: params.config,
|
|
3691
3722
|
files: []
|
|
3692
|
-
} : buildEnvBootstrapFiles(params.config, params.configPathArg, params.descriptor.envFields ?? []);
|
|
3723
|
+
} : buildEnvBootstrapFiles(params.functionsDir, params.config, params.configPathArg, params.descriptor.envFields ?? []);
|
|
3693
3724
|
const effectiveConfig = envBootstrap.config;
|
|
3694
3725
|
const roots = resolvePluginScaffoldRoots(params.functionsDir, params.descriptor, effectiveConfig, params.preset);
|
|
3695
3726
|
const effectiveTemplates = params.descriptor.integration?.resolveTemplates?.({
|
|
@@ -10497,11 +10528,12 @@ const CONVEX_DEPLOYMENT_ENV_KEYS = [
|
|
|
10497
10528
|
"CONVEX_SELF_HOSTED_URL",
|
|
10498
10529
|
"CONVEX_SELF_HOSTED_ADMIN_KEY"
|
|
10499
10530
|
];
|
|
10500
|
-
const
|
|
10501
|
-
const
|
|
10531
|
+
const UNSUPPORTED_CODEGEN_TARGET_RE = /^--(?:prod|preview-name|deployment(?:-name)?|component|url|admin-key)(?:=|$)/;
|
|
10532
|
+
const CODEGEN_DEPLOYMENT_KEY_RE = /^(?:(?:dev|prod|preview|custom|local):)?[^:|\s]+\|.+$/;
|
|
10533
|
+
const CODEGEN_ACCOUNT_INDEPENDENT_KEY_RE = /^(?:dev|prod):.*\|/;
|
|
10534
|
+
const CONVEX_NAMED_KEY_SELECTOR_RE = /^(?:dev|prod|preview|project):[^|]+\|/;
|
|
10502
10535
|
function isLocalConvexDeploymentValue(deployment) {
|
|
10503
|
-
|
|
10504
|
-
return LOCAL_CONVEX_DEPLOYMENT_VALUES.includes(deployment) || LOCAL_CONVEX_DEPLOYMENT_PREFIXES.some((prefix) => deployment.startsWith(prefix));
|
|
10536
|
+
return Boolean(deployment?.startsWith("local:") || deployment?.split(":").at(-1)?.startsWith("anonymous-"));
|
|
10505
10537
|
}
|
|
10506
10538
|
function createBackendCommandEnv(overrides) {
|
|
10507
10539
|
const clearedDeploymentEnv = Object.fromEntries(CONVEX_DEPLOYMENT_ENV_KEYS.map((key) => [key, void 0]));
|
|
@@ -10517,15 +10549,87 @@ function getConvexDeploymentCommandEnv(env = process.env) {
|
|
|
10517
10549
|
function hasRemoteConvexDeploymentEnv(env) {
|
|
10518
10550
|
const deployment = env.CONVEX_DEPLOYMENT?.trim();
|
|
10519
10551
|
if (deployment && !isLocalConvexDeploymentValue(deployment)) return true;
|
|
10520
|
-
return Boolean(env.CONVEX_DEPLOY_KEY?.trim() || env.CONVEX_SELF_HOSTED_URL?.trim() || env.CONVEX_SELF_HOSTED_ADMIN_KEY?.trim());
|
|
10552
|
+
return Boolean(env.CONVEX_DEPLOY_KEY?.trim() || env.CONVEX_DEPLOYMENT_TOKEN?.trim() || env.CONVEX_SELF_HOSTED_URL?.trim() || env.CONVEX_SELF_HOSTED_ADMIN_KEY?.trim());
|
|
10521
10553
|
}
|
|
10522
10554
|
function readConvexTargetEnvFile(args, cwd = process.cwd()) {
|
|
10523
10555
|
const envFile = readOptionalCliFlagValue(args, "--env-file");
|
|
10524
|
-
|
|
10525
|
-
|
|
10556
|
+
return envFile ? readConvexEnvFile(resolve(cwd, envFile)) : null;
|
|
10557
|
+
}
|
|
10558
|
+
function readConvexEnvFile(envFilePath) {
|
|
10526
10559
|
if (!fs.existsSync(envFilePath)) return null;
|
|
10527
10560
|
return loadDotenv().parse(fs.readFileSync(envFilePath, "utf8"));
|
|
10528
10561
|
}
|
|
10562
|
+
function withoutConvexEnvFile(args) {
|
|
10563
|
+
return args.filter((arg, index) => arg !== "--env-file" && !arg.startsWith("--env-file=") && args[index - 1] !== "--env-file");
|
|
10564
|
+
}
|
|
10565
|
+
function explicitConvexDeploymentEnv(vars) {
|
|
10566
|
+
return Object.fromEntries([...CONVEX_DEPLOYMENT_ENV_KEYS, "CONVEX_DEPLOYMENT_TOKEN"].map((key) => [key, vars[key] ?? ""]));
|
|
10567
|
+
}
|
|
10568
|
+
function resolveConvexCodegenTarget(args) {
|
|
10569
|
+
const file = readOptionalCliFlagValue(args, "--env-file");
|
|
10570
|
+
if (file === void 0 && !args.includes("--env-file")) return;
|
|
10571
|
+
if (!file) throw new Error("Missing value for --env-file.");
|
|
10572
|
+
const nativeArgs = withoutConvexEnvFile(args);
|
|
10573
|
+
const otherTarget = nativeArgs.find((arg) => UNSUPPORTED_CODEGEN_TARGET_RE.test(arg));
|
|
10574
|
+
if (otherTarget) throw new Error(`Convex codegen cannot combine ${otherTarget.split("=")[0]} with --env-file. Select the deployment in ${file}.`);
|
|
10575
|
+
const vars = readConvexEnvFile(file);
|
|
10576
|
+
if (!vars) throw new Error(`Convex deployment env file not found: ${file}`);
|
|
10577
|
+
const key = vars.CONVEX_DEPLOY_KEY || vars.CONVEX_DEPLOYMENT_TOKEN;
|
|
10578
|
+
const url = vars.CONVEX_SELF_HOSTED_URL;
|
|
10579
|
+
const adminKey = vars.CONVEX_SELF_HOSTED_ADMIN_KEY;
|
|
10580
|
+
const usesKey = Boolean(key && key !== "<ignore_deploy_key>");
|
|
10581
|
+
if (usesKey) {
|
|
10582
|
+
if (!CODEGEN_DEPLOYMENT_KEY_RE.test(key)) throw new Error(`Use a deployment-specific key in ${file}, or remove the key and set CONVEX_DEPLOYMENT to the existing deployment name.`);
|
|
10583
|
+
} else if (vars.CONVEX_DEPLOYMENT ? url || adminKey : !(url && adminKey)) throw new Error(`Select one deployment in ${file} with CONVEX_DEPLOYMENT, a deploy key, or both CONVEX_SELF_HOSTED_URL and CONVEX_SELF_HOSTED_ADMIN_KEY.`);
|
|
10584
|
+
const account = process.env.CONVEX_ACCOUNT || vars.CONVEX_ACCOUNT;
|
|
10585
|
+
if (!account && !process.env.CONVEX_OVERRIDE_ACCESS_TOKEN && !CODEGEN_ACCOUNT_INDEPENDENT_KEY_RE.test(key ?? "") && isConvexVersionAtLeast(LOCAL_CONVEX_VERSION, 1, 50) && [".env.local", ".env"].some((path) => readConvexEnvFile(path)?.CONVEX_ACCOUNT)) {
|
|
10586
|
+
if (!usesKey && url && adminKey) return {
|
|
10587
|
+
file,
|
|
10588
|
+
args: [
|
|
10589
|
+
...nativeArgs,
|
|
10590
|
+
"--url",
|
|
10591
|
+
url,
|
|
10592
|
+
"--admin-key",
|
|
10593
|
+
adminKey
|
|
10594
|
+
],
|
|
10595
|
+
env: {}
|
|
10596
|
+
};
|
|
10597
|
+
throw new Error(`Set CONVEX_ACCOUNT in ${file} or in your shell. Convex codegen would otherwise use the account from the project's .env.local or .env.`);
|
|
10598
|
+
}
|
|
10599
|
+
return {
|
|
10600
|
+
file,
|
|
10601
|
+
args: nativeArgs,
|
|
10602
|
+
env: {
|
|
10603
|
+
...explicitConvexDeploymentEnv(vars),
|
|
10604
|
+
CONVEX_PROVISION_HOST: process.env.CONVEX_PROVISION_HOST ?? "",
|
|
10605
|
+
CONVEX_ACCOUNT: account,
|
|
10606
|
+
CONVEX_OVERRIDE_ACCESS_TOKEN: process.env.CONVEX_OVERRIDE_ACCESS_TOKEN ?? ""
|
|
10607
|
+
}
|
|
10608
|
+
};
|
|
10609
|
+
}
|
|
10610
|
+
function readDirectConvexTargetArgs(args) {
|
|
10611
|
+
const url = readOptionalCliFlagValue(args, "--url");
|
|
10612
|
+
const adminKey = readOptionalCliFlagValue(args, "--admin-key");
|
|
10613
|
+
return url === void 0 || adminKey === void 0 ? null : [
|
|
10614
|
+
"--url",
|
|
10615
|
+
url,
|
|
10616
|
+
"--admin-key",
|
|
10617
|
+
adminKey
|
|
10618
|
+
];
|
|
10619
|
+
}
|
|
10620
|
+
function resolveConvexDevChildEnv(targetArgs) {
|
|
10621
|
+
const direct = readDirectConvexTargetArgs(targetArgs);
|
|
10622
|
+
if (direct) return {
|
|
10623
|
+
CONVEX_DEPLOYMENT_TOKEN: void 0,
|
|
10624
|
+
CONVEX_SELF_HOSTED_URL: direct[1],
|
|
10625
|
+
CONVEX_SELF_HOSTED_ADMIN_KEY: direct[3]
|
|
10626
|
+
};
|
|
10627
|
+
const env = readConvexTargetEnvFile(targetArgs);
|
|
10628
|
+
return env ? {
|
|
10629
|
+
...getConvexDeploymentCommandEnv(env),
|
|
10630
|
+
CONVEX_DEPLOYMENT_TOKEN: env.CONVEX_DEPLOYMENT_TOKEN
|
|
10631
|
+
} : void 0;
|
|
10632
|
+
}
|
|
10529
10633
|
function resolveRemoteConvexDeploymentKey(env) {
|
|
10530
10634
|
if (!hasRemoteConvexDeploymentEnv(env)) return null;
|
|
10531
10635
|
const deployment = env.CONVEX_DEPLOYMENT?.trim();
|
|
@@ -11894,7 +11998,7 @@ function buildInitializationPlan(params) {
|
|
|
11894
11998
|
const functionsDirRelative = existingFunctionsDirRelative ?? "convex/functions";
|
|
11895
11999
|
const functionsDir = resolve(process.cwd(), functionsDirRelative);
|
|
11896
12000
|
const currentConfig = params.config;
|
|
11897
|
-
const envBootstrap = buildEnvBootstrapFiles(currentConfig, params.configPathArg, params.envFields ?? []);
|
|
12001
|
+
const envBootstrap = buildEnvBootstrapFiles(functionsDir, currentConfig, params.configPathArg, params.envFields ?? []);
|
|
11898
12002
|
const nextConfig = envBootstrap.config;
|
|
11899
12003
|
const crpcFilePath = getCrpcFilePath(nextConfig);
|
|
11900
12004
|
const httpFilePath = getHttpFilePath(functionsDir);
|
|
@@ -12080,14 +12184,16 @@ async function runScaffoldCommandFlow(params) {
|
|
|
12080
12184
|
config
|
|
12081
12185
|
});
|
|
12082
12186
|
if (backend === "concave" && (params.targetArgs?.length ?? 0) > 0) throw new Error("Convex deployment target flags are only supported on backend convex.");
|
|
12187
|
+
const codegenTarget = backend === "convex" ? resolveConvexCodegenTarget([...config.codegen.args, ...params.targetArgs ?? []]) : void 0;
|
|
12083
12188
|
const configWithResolvedBackend = overrideConfigBackend(config, backend);
|
|
12189
|
+
if (backend === "convex" && config.paths.env) validateConvexEnvHelperPath(resolve(resolveExistingFunctionsDirRelative() ?? "convex/functions"), config.paths.env);
|
|
12084
12190
|
const initPlan = buildInitializationPlan({
|
|
12085
12191
|
kitcnInstallSpec: resolveScaffoldInstallSpec(),
|
|
12086
12192
|
config: configWithResolvedBackend,
|
|
12087
12193
|
configPathArg: params.configPath,
|
|
12088
12194
|
template: params.template
|
|
12089
12195
|
});
|
|
12090
|
-
const applyResult = await applyPluginInstallPlanFiles(initPlan.files, {
|
|
12196
|
+
const applyResult = await applyPluginInstallPlanFiles(codegenTarget ? initPlan.files.filter((file) => file.path !== ".env.local" && file.path !== ".env" && file.templateId !== LOCAL_CONVEX_ENV_TEMPLATE_ID && resolve(file.path) !== resolve(codegenTarget.file)) : initPlan.files, {
|
|
12091
12197
|
overwrite: Boolean(params.overwrite) || params.template !== void 0,
|
|
12092
12198
|
yes: params.yes || Boolean(params.defaults),
|
|
12093
12199
|
promptAdapter: params.promptAdapter
|
|
@@ -12100,6 +12206,7 @@ async function runScaffoldCommandFlow(params) {
|
|
|
12100
12206
|
logger.warn(`⚠️ Failed to ensure .convex/ and .concave/ are ignored in .gitignore: ${error.message}`);
|
|
12101
12207
|
}
|
|
12102
12208
|
const codegenResult = await runInitializationCodegen({
|
|
12209
|
+
codegenTarget,
|
|
12103
12210
|
allowCodegenBootstrapFallback: params.allowCodegenBootstrapFallback ?? true,
|
|
12104
12211
|
config: initPlan.config,
|
|
12105
12212
|
backend,
|
|
@@ -12126,7 +12233,7 @@ async function runScaffoldCommandFlow(params) {
|
|
|
12126
12233
|
template: params.template ?? null,
|
|
12127
12234
|
codegen: codegenResult.codegen,
|
|
12128
12235
|
convexBootstrap: codegenResult.convexBootstrap,
|
|
12129
|
-
|
|
12236
|
+
needsLocalBootstrap: !codegenTarget && !codegenResult.localBootstrapUsed
|
|
12130
12237
|
};
|
|
12131
12238
|
});
|
|
12132
12239
|
}
|
|
@@ -12303,18 +12410,11 @@ function normalizeOrderedStringList(values) {
|
|
|
12303
12410
|
return [...new Set(values.filter((value) => typeof value === "string"))];
|
|
12304
12411
|
}
|
|
12305
12412
|
function readOptionalCliFlagValue(args, flag) {
|
|
12306
|
-
|
|
12413
|
+
const withEquals = `${flag}=`;
|
|
12414
|
+
for (let i = args.length - 1; i >= 0; i -= 1) {
|
|
12307
12415
|
const arg = args[i];
|
|
12308
|
-
if (arg === flag)
|
|
12309
|
-
|
|
12310
|
-
if (value) return value;
|
|
12311
|
-
continue;
|
|
12312
|
-
}
|
|
12313
|
-
const withEquals = `${flag}=`;
|
|
12314
|
-
if (arg.startsWith(withEquals)) {
|
|
12315
|
-
const value = arg.slice(withEquals.length);
|
|
12316
|
-
if (value) return value;
|
|
12317
|
-
}
|
|
12416
|
+
if (arg === flag) return args[i + 1];
|
|
12417
|
+
if (arg.startsWith(withEquals)) return arg.slice(withEquals.length);
|
|
12318
12418
|
}
|
|
12319
12419
|
}
|
|
12320
12420
|
function buildAggregateFingerprintPayload(tables) {
|
|
@@ -12418,14 +12518,26 @@ function writeAggregateFingerprintState(statePath, state) {
|
|
|
12418
12518
|
fs.renameSync(tmpPath, statePath);
|
|
12419
12519
|
}
|
|
12420
12520
|
function getAggregateBackfillDeploymentKey(args, cwd = process.cwd(), env) {
|
|
12421
|
-
|
|
12521
|
+
const directUrl = readDirectConvexTargetArgs(args)?.[1];
|
|
12522
|
+
if (directUrl !== void 0) return `url:${createHash("sha256").update(directUrl).digest("hex")}`;
|
|
12523
|
+
const envFileVars = readConvexTargetEnvFile(args, cwd);
|
|
12524
|
+
const targetEnv = envFileVars ?? env;
|
|
12525
|
+
const deployKey = targetEnv?.CONVEX_DEPLOY_KEY || targetEnv?.CONVEX_DEPLOYMENT_TOKEN;
|
|
12526
|
+
if (deployKey && deployKey !== "<ignore_deploy_key>") {
|
|
12527
|
+
const selector = CONVEX_NAMED_KEY_SELECTOR_RE.exec(deployKey)?.[0] ?? deployKey;
|
|
12528
|
+
const hash = createHash("sha256").update(selector).digest("hex");
|
|
12529
|
+
return args.includes("--prod") ? `deployment-token:${hash}:prod` : `deployment-token:${hash}`;
|
|
12530
|
+
}
|
|
12531
|
+
if (args.includes("--prod")) {
|
|
12532
|
+
const fileTarget = envFileVars && resolveRemoteConvexDeploymentKey(envFileVars);
|
|
12533
|
+
return fileTarget ? `${fileTarget}:prod` : "prod";
|
|
12534
|
+
}
|
|
12422
12535
|
const deploymentName = readOptionalCliFlagValue(args, "--deployment-name");
|
|
12423
12536
|
if (deploymentName) return `deployment:${deploymentName}`;
|
|
12424
12537
|
const previewName = readOptionalCliFlagValue(args, "--preview-name");
|
|
12425
12538
|
if (previewName) return `preview:${previewName}`;
|
|
12426
12539
|
const envKey = env ? resolveRemoteConvexDeploymentKey(env) : null;
|
|
12427
12540
|
if (envKey) return envKey;
|
|
12428
|
-
const envFileVars = readConvexTargetEnvFile(args, cwd);
|
|
12429
12541
|
if (envFileVars) {
|
|
12430
12542
|
const envFileKey = resolveRemoteConvexDeploymentKey(envFileVars);
|
|
12431
12543
|
if (envFileKey) return envFileKey;
|
|
@@ -12525,9 +12637,11 @@ async function runConfiguredCodegenDetailed(params) {
|
|
|
12525
12637
|
realConvexPath,
|
|
12526
12638
|
realConcavePath: params.realConcavePath
|
|
12527
12639
|
});
|
|
12640
|
+
if (resolvedRuntimeAdapter.publicName === "convex" && config.paths.env) validateConvexEnvHelperPath(getConvexConfig(sharedDir).functionsDir, config.paths.env);
|
|
12641
|
+
const codegenTarget = params.codegenTarget ?? (resolvedRuntimeAdapter.publicName === "convex" ? resolveConvexCodegenTarget(convexCodegenArgs) : void 0);
|
|
12528
12642
|
const targetArgs = extractBackendRunTargetArgs(resolvedRuntimeAdapter.publicName, convexCodegenArgs);
|
|
12529
|
-
const localBackendEnv = getLocalBackendEnvVars(sharedDir, resolvedRuntimeAdapter.publicName);
|
|
12530
|
-
const authEnvState = autoSyncLocalAuthEnv && resolvedRuntimeAdapter.publicName === "convex" && getAggregateBackfillDeploymentKey(targetArgs) === "local" ? resolveAuthEnvState({
|
|
12643
|
+
const localBackendEnv = codegenTarget ? void 0 : getLocalBackendEnvVars(sharedDir, resolvedRuntimeAdapter.publicName);
|
|
12644
|
+
const authEnvState = autoSyncLocalAuthEnv && !codegenTarget && resolvedRuntimeAdapter.publicName === "convex" && getAggregateBackfillDeploymentKey(targetArgs) === "local" ? resolveAuthEnvState({
|
|
12531
12645
|
cwd: process.cwd(),
|
|
12532
12646
|
sharedDir
|
|
12533
12647
|
}) : null;
|
|
@@ -12550,17 +12664,18 @@ async function runConfiguredCodegenDetailed(params) {
|
|
|
12550
12664
|
const result = await execaFn(resolvedRuntimeAdapter.command, [
|
|
12551
12665
|
...resolvedRuntimeAdapter.argsPrefix,
|
|
12552
12666
|
"codegen",
|
|
12553
|
-
...convexCodegenArgs
|
|
12667
|
+
...codegenTarget?.args ?? convexCodegenArgs
|
|
12554
12668
|
], {
|
|
12555
12669
|
stdio,
|
|
12556
12670
|
cwd: process.cwd(),
|
|
12557
12671
|
env: createBackendCommandEnv({
|
|
12558
12672
|
...localBackendEnv,
|
|
12559
|
-
...env
|
|
12673
|
+
...env,
|
|
12674
|
+
...codegenTarget?.env
|
|
12560
12675
|
}),
|
|
12561
12676
|
reject: false
|
|
12562
12677
|
});
|
|
12563
|
-
if (resolvedRuntimeAdapter.publicName === "convex" && allowLocalBootstrapFallback && result.exitCode !== 0 && LOCAL_BACKEND_NOT_RUNNING_RE.test(`${result.stdout ?? ""}\n${result.stderr ?? ""}`)) {
|
|
12678
|
+
if (resolvedRuntimeAdapter.publicName === "convex" && allowLocalBootstrapFallback && !codegenTarget && result.exitCode !== 0 && LOCAL_BACKEND_NOT_RUNNING_RE.test(`${result.stdout ?? ""}\n${result.stderr ?? ""}`)) {
|
|
12564
12679
|
const { functionsDir } = getConvexConfig(sharedDir);
|
|
12565
12680
|
if (!fs.existsSync(getGeneratedServerStubPath(functionsDir))) writeGeneratedServerStub(functionsDir);
|
|
12566
12681
|
const bootstrap = await runLocalConvexBootstrapForInit({
|
|
@@ -12648,17 +12763,37 @@ async function runConvexInitIfNeeded(params) {
|
|
|
12648
12763
|
stdout: "",
|
|
12649
12764
|
stderr: ""
|
|
12650
12765
|
};
|
|
12651
|
-
const
|
|
12766
|
+
const targetArgs = params.targetArgs ?? [];
|
|
12767
|
+
const hasEnvFile = readOptionalCliFlagValue(targetArgs, "--env-file") !== void 0;
|
|
12768
|
+
const hasDirectTarget = readDirectConvexTargetArgs(targetArgs) !== null;
|
|
12769
|
+
const targetsProd = targetArgs.includes("--prod");
|
|
12770
|
+
const supportsDevPreflight = params.convexDevVersion !== void 0 && isConvexVersionAtLeast(params.convexDevVersion, 1, 50);
|
|
12771
|
+
if (params.convexDevVersion && targetsProd && !supportsDevPreflight && !hasEnvFile && !hasDirectTarget) throw new Error("`kitcn dev --prod` requires an explicit --env-file on Convex versions before 1.50. Use a cloud deployment env file or upgrade Convex.");
|
|
12772
|
+
let commandArgs = ["init", ...targetArgs];
|
|
12773
|
+
let env = params.env;
|
|
12774
|
+
if (params.convexDevVersion && (hasEnvFile || hasDirectTarget || targetsProd)) {
|
|
12775
|
+
const fileEnv = supportsDevPreflight ? null : readConvexTargetEnvFile(targetArgs);
|
|
12776
|
+
const deploymentName = fileEnv?.CONVEX_DEPLOYMENT?.split(":").at(-1);
|
|
12777
|
+
if (fileEnv === null || targetsProd && !deploymentName?.startsWith("anonymous-") || !(fileEnv.CONVEX_DEPLOYMENT || fileEnv.CONVEX_DEPLOY_KEY || fileEnv.CONVEX_DEPLOYMENT_TOKEN || fileEnv.CONVEX_SELF_HOSTED_URL && fileEnv.CONVEX_SELF_HOSTED_ADMIN_KEY)) commandArgs = [
|
|
12778
|
+
"dev",
|
|
12779
|
+
"--once",
|
|
12780
|
+
"--skip-push",
|
|
12781
|
+
...targetArgs
|
|
12782
|
+
];
|
|
12783
|
+
else {
|
|
12784
|
+
commandArgs = ["init", ...withoutConvexEnvFile(targetArgs)];
|
|
12785
|
+
env = {
|
|
12786
|
+
...env,
|
|
12787
|
+
...explicitConvexDeploymentEnv(fileEnv)
|
|
12788
|
+
};
|
|
12789
|
+
}
|
|
12790
|
+
}
|
|
12791
|
+
const result = normalizeConvexCommandResult(await params.execaFn(params.backendAdapter.command, [...params.backendAdapter.argsPrefix, ...commandArgs], {
|
|
12652
12792
|
cwd: process.cwd(),
|
|
12653
|
-
env: createBackendCommandEnv(
|
|
12793
|
+
env: createBackendCommandEnv(env),
|
|
12654
12794
|
reject: false,
|
|
12655
12795
|
stdio: "pipe"
|
|
12656
12796
|
}));
|
|
12657
|
-
const result = await runCommand([
|
|
12658
|
-
...params.backendAdapter.argsPrefix,
|
|
12659
|
-
"init",
|
|
12660
|
-
...params.targetArgs ?? []
|
|
12661
|
-
]);
|
|
12662
12797
|
if (params.echoOutput !== false || result.exitCode !== 0) writeConvexCommandOutput(result);
|
|
12663
12798
|
return {
|
|
12664
12799
|
created: didConvexInitCreateConfiguration(`${result.stdout}\n${result.stderr}`),
|
|
@@ -12758,13 +12893,18 @@ async function runInitializationCodegen(params) {
|
|
|
12758
12893
|
});
|
|
12759
12894
|
const additionalCodegenArgs = resolveTemplateInitCodegenArgs(runtimeAdapter, params.template);
|
|
12760
12895
|
if (runtimeAdapter.publicName === "convex") {
|
|
12761
|
-
|
|
12762
|
-
|
|
12763
|
-
|
|
12764
|
-
|
|
12765
|
-
|
|
12766
|
-
|
|
12896
|
+
let created = false;
|
|
12897
|
+
if (!params.codegenTarget) {
|
|
12898
|
+
const initResult = await runConvexInitIfNeeded({
|
|
12899
|
+
execaFn: params.execaFn,
|
|
12900
|
+
backendAdapter: runtimeAdapter,
|
|
12901
|
+
targetArgs: params.targetArgs
|
|
12902
|
+
});
|
|
12903
|
+
if (initResult.exitCode !== 0) throw new Error(`Failed to configure Convex project via \`convex init\`.\n${`${initResult.stdout}\n${initResult.stderr}`.trim()}`);
|
|
12904
|
+
created = initResult.created;
|
|
12905
|
+
}
|
|
12767
12906
|
const codegen = await runConfiguredCodegenDetailed({
|
|
12907
|
+
codegenTarget: params.codegenTarget,
|
|
12768
12908
|
config: params.config,
|
|
12769
12909
|
sharedDir: params.sharedDir,
|
|
12770
12910
|
debug: params.debug,
|
|
@@ -12780,11 +12920,12 @@ async function runInitializationCodegen(params) {
|
|
|
12780
12920
|
allowLocalBootstrapFallback: false
|
|
12781
12921
|
});
|
|
12782
12922
|
if (codegen.exitCode !== 0) {
|
|
12923
|
+
if (params.codegenTarget) throw new Error(formatInitCodegenFailure(`${codegen.stdout}\n${codegen.stderr}`));
|
|
12783
12924
|
const generatedServerPath = getGeneratedServerStubPath(params.functionsDir);
|
|
12784
12925
|
if (!fs.existsSync(generatedServerPath)) writeGeneratedServerStub(params.functionsDir);
|
|
12785
12926
|
if (!params.allowCodegenBootstrapFallback) return {
|
|
12786
12927
|
codegen: "stubbed",
|
|
12787
|
-
convexBootstrap:
|
|
12928
|
+
convexBootstrap: created ? "created" : "existing",
|
|
12788
12929
|
localBootstrapUsed: false
|
|
12789
12930
|
};
|
|
12790
12931
|
await params.syncEnvFn({
|
|
@@ -12819,13 +12960,13 @@ async function runInitializationCodegen(params) {
|
|
|
12819
12960
|
}
|
|
12820
12961
|
return {
|
|
12821
12962
|
codegen: "generated",
|
|
12822
|
-
convexBootstrap:
|
|
12963
|
+
convexBootstrap: created ? "created" : "existing",
|
|
12823
12964
|
localBootstrapUsed: true
|
|
12824
12965
|
};
|
|
12825
12966
|
}
|
|
12826
12967
|
return {
|
|
12827
12968
|
codegen: "generated",
|
|
12828
|
-
convexBootstrap:
|
|
12969
|
+
convexBootstrap: created ? "created" : "existing",
|
|
12829
12970
|
localBootstrapUsed: false
|
|
12830
12971
|
};
|
|
12831
12972
|
}
|
|
@@ -13194,6 +13335,9 @@ function extractConvexRunTargetArgs(args) {
|
|
|
13194
13335
|
}
|
|
13195
13336
|
return deploymentArgs;
|
|
13196
13337
|
}
|
|
13338
|
+
function extractConvexDevTargetArgs(args) {
|
|
13339
|
+
return readDirectConvexTargetArgs(args) ?? extractConvexRunTargetArgs(args);
|
|
13340
|
+
}
|
|
13197
13341
|
function extractConcaveRunTargetArgs(args) {
|
|
13198
13342
|
const targetArgs = [];
|
|
13199
13343
|
for (let i = 0; i < args.length; i += 1) {
|
|
@@ -13619,6 +13763,7 @@ const SUPPORTED_LOCAL_CONVEX_NODE_MAJORS = new Set([
|
|
|
13619
13763
|
22,
|
|
13620
13764
|
24
|
|
13621
13765
|
]);
|
|
13766
|
+
const SUPPORTED_LOCAL_CONVEX_1_49_NODE_MAJORS = new Set([22, 24]);
|
|
13622
13767
|
const LINE_SPLIT_RE = /\r?\n/;
|
|
13623
13768
|
function sleepWithAbort(ms, signal) {
|
|
13624
13769
|
if (signal?.aborted) return Promise.resolve();
|
|
@@ -13774,8 +13919,8 @@ function applyConvexBootstrapDevArgs(args) {
|
|
|
13774
13919
|
function killProcessIfRunning(process, signal = "SIGTERM") {
|
|
13775
13920
|
if (typeof process === "object" && process !== null && "killed" in process && !process.killed && "kill" in process && typeof process.kill === "function") process.kill(signal);
|
|
13776
13921
|
}
|
|
13777
|
-
async function runLocalConvexBootstrap({ authSyncMode = "complete", config, debug, devArgs = [], execaFn, generateMetaFn, realConcavePath, realConvexPath, sharedDir, skipGenerateMeta = false, syncEnvFn, targetArgs }) {
|
|
13778
|
-
if (!debug) logger.info("
|
|
13922
|
+
async function runLocalConvexBootstrap({ authSyncMode = "complete", config, convexVersion = LOCAL_CONVEX_VERSION, debug, devArgs = [], execaFn, generateMetaFn, nodeEnvOverrides, realConcavePath, realConvexPath, sharedDir, skipGenerateMeta = false, syncEnvFn, targetArgs }) {
|
|
13923
|
+
if (!debug) logger.info("Preparing the Convex deployment...");
|
|
13779
13924
|
const backendAdapter = createBackendAdapter({
|
|
13780
13925
|
backend: "convex",
|
|
13781
13926
|
realConvexPath,
|
|
@@ -13787,17 +13932,23 @@ async function runLocalConvexBootstrap({ authSyncMode = "complete", config, debu
|
|
|
13787
13932
|
cwd: process.cwd(),
|
|
13788
13933
|
sharedDir
|
|
13789
13934
|
});
|
|
13790
|
-
const localNodeEnvOverrides = await resolveSupportedLocalNodeEnvOverrides({
|
|
13935
|
+
const localNodeEnvOverrides = nodeEnvOverrides ?? await resolveSupportedLocalNodeEnvOverrides({
|
|
13936
|
+
convexVersion,
|
|
13937
|
+
execaFn
|
|
13938
|
+
});
|
|
13939
|
+
const commandEnv = localNodeEnvOverrides.PATH ? localNodeEnvOverrides : void 0;
|
|
13791
13940
|
const convexInitResult = await runConvexInitIfNeeded({
|
|
13792
13941
|
execaFn,
|
|
13793
13942
|
backendAdapter,
|
|
13794
13943
|
echoOutput: false,
|
|
13944
|
+
convexDevVersion: convexVersion,
|
|
13795
13945
|
env: localNodeEnvOverrides,
|
|
13796
13946
|
targetArgs
|
|
13797
13947
|
});
|
|
13798
13948
|
if (convexInitResult.exitCode !== 0) return convexInitResult.exitCode;
|
|
13799
13949
|
if (fs.existsSync(localConvexEnvPath) || authEnvState.installed) await syncEnvFn({
|
|
13800
13950
|
authSyncMode: authEnvState.installed ? "prepare" : "skip",
|
|
13951
|
+
...commandEnv && { commandEnv },
|
|
13801
13952
|
force: true,
|
|
13802
13953
|
sharedDir,
|
|
13803
13954
|
silent: true,
|
|
@@ -13816,7 +13967,10 @@ async function runLocalConvexBootstrap({ authSyncMode = "complete", config, debu
|
|
|
13816
13967
|
], {
|
|
13817
13968
|
stdio: "pipe",
|
|
13818
13969
|
cwd: process.cwd(),
|
|
13819
|
-
env: createBackendCommandEnv(
|
|
13970
|
+
env: createBackendCommandEnv({
|
|
13971
|
+
...localNodeEnvOverrides,
|
|
13972
|
+
...resolveConvexDevChildEnv(targetArgs)
|
|
13973
|
+
}),
|
|
13820
13974
|
reject: false
|
|
13821
13975
|
});
|
|
13822
13976
|
const backendReadyPromise = observeDevProcessOutput(bootstrapProcess, debug ? "raw" : "filtered");
|
|
@@ -13827,6 +13981,7 @@ async function runLocalConvexBootstrap({ authSyncMode = "complete", config, debu
|
|
|
13827
13981
|
signal: abortController.signal,
|
|
13828
13982
|
runTask: () => syncEnvFn({
|
|
13829
13983
|
authSyncMode,
|
|
13984
|
+
...commandEnv && { commandEnv },
|
|
13830
13985
|
force: true,
|
|
13831
13986
|
sharedDir,
|
|
13832
13987
|
silent: true,
|
|
@@ -13844,6 +13999,7 @@ async function runLocalConvexBootstrap({ authSyncMode = "complete", config, debu
|
|
|
13844
13999
|
runTask: () => runMigrationFlow({
|
|
13845
14000
|
execaFn,
|
|
13846
14001
|
backendAdapter,
|
|
14002
|
+
env: commandEnv,
|
|
13847
14003
|
migrationConfig: config.dev.migrations,
|
|
13848
14004
|
targetArgs,
|
|
13849
14005
|
signal: abortController.signal,
|
|
@@ -13866,6 +14022,7 @@ async function runLocalConvexBootstrap({ authSyncMode = "complete", config, debu
|
|
|
13866
14022
|
execaFn,
|
|
13867
14023
|
backendAdapter,
|
|
13868
14024
|
backfillConfig: config.dev.aggregateBackfill,
|
|
14025
|
+
env: commandEnv,
|
|
13869
14026
|
mode: "resume",
|
|
13870
14027
|
targetArgs,
|
|
13871
14028
|
signal: abortController.signal,
|
|
@@ -13917,58 +14074,69 @@ function resolveConcaveLocalSiteUrl(cwd = process.cwd()) {
|
|
|
13917
14074
|
const parsed = parseEnv(fs.readFileSync(envLocalPath, "utf8"));
|
|
13918
14075
|
return parsed.NEXT_PUBLIC_SITE_URL ?? parsed.EXPO_PUBLIC_SITE_URL ?? parsed.VITE_SITE_URL ?? "http://localhost:3000";
|
|
13919
14076
|
}
|
|
13920
|
-
function resolveImplicitConvexRemoteDeploymentEnv(cwd = process.cwd()) {
|
|
14077
|
+
function resolveImplicitConvexRemoteDeploymentEnv(cwd = process.cwd(), inheritedToken) {
|
|
13921
14078
|
const envLocalPath = join(cwd, ".env.local");
|
|
13922
|
-
|
|
13923
|
-
const
|
|
13924
|
-
|
|
13925
|
-
|
|
13926
|
-
|
|
13927
|
-
CONVEX_DEPLOY_KEY: parsed.CONVEX_DEPLOY_KEY,
|
|
13928
|
-
CONVEX_SELF_HOSTED_URL: parsed.CONVEX_SELF_HOSTED_URL,
|
|
13929
|
-
CONVEX_SELF_HOSTED_ADMIN_KEY: parsed.CONVEX_SELF_HOSTED_ADMIN_KEY
|
|
14079
|
+
const parsed = fs.existsSync(envLocalPath) ? parseEnv(fs.readFileSync(envLocalPath, "utf8")) : {};
|
|
14080
|
+
const token = inheritedToken ?? parsed.CONVEX_DEPLOYMENT_TOKEN;
|
|
14081
|
+
const commandEnv = {
|
|
14082
|
+
...getConvexDeploymentCommandEnv(parsed),
|
|
14083
|
+
...token !== void 0 && { CONVEX_DEPLOYMENT_TOKEN: token }
|
|
13930
14084
|
};
|
|
13931
|
-
|
|
13932
|
-
|
|
13933
|
-
|
|
13934
|
-
|
|
13935
|
-
|
|
13936
|
-
|
|
13937
|
-
|
|
13938
|
-
|
|
13939
|
-
|
|
13940
|
-
|
|
13941
|
-
|
|
13942
|
-
break;
|
|
13943
|
-
}
|
|
13944
|
-
}
|
|
13945
|
-
if (!envFilePath) return null;
|
|
13946
|
-
const resolvedPath = resolve(cwd, envFilePath);
|
|
13947
|
-
if (!fs.existsSync(resolvedPath)) return null;
|
|
13948
|
-
const parsed = parseEnv(fs.readFileSync(resolvedPath, "utf8"));
|
|
13949
|
-
return {
|
|
13950
|
-
CONVEX_DEPLOYMENT: parsed.CONVEX_DEPLOYMENT,
|
|
13951
|
-
CONVEX_DEPLOY_KEY: parsed.CONVEX_DEPLOY_KEY,
|
|
13952
|
-
CONVEX_SELF_HOSTED_URL: parsed.CONVEX_SELF_HOSTED_URL,
|
|
13953
|
-
CONVEX_SELF_HOSTED_ADMIN_KEY: parsed.CONVEX_SELF_HOSTED_ADMIN_KEY
|
|
14085
|
+
return hasRemoteConvexDeploymentEnv(commandEnv) ? commandEnv : null;
|
|
14086
|
+
}
|
|
14087
|
+
function pinConvexDevEnvFile(devArgs, targetArgs) {
|
|
14088
|
+
const sourcePath = readOptionalCliFlagValue(targetArgs, "--env-file");
|
|
14089
|
+
if (sourcePath === void 0) return null;
|
|
14090
|
+
const { parse } = loadDotenv();
|
|
14091
|
+
const parsed = parse(fs.readFileSync(sourcePath, "utf8"));
|
|
14092
|
+
const selectors = {
|
|
14093
|
+
...getConvexDeploymentCommandEnv(parsed),
|
|
14094
|
+
CONVEX_ACCOUNT: parsed.CONVEX_ACCOUNT,
|
|
14095
|
+
CONVEX_DEPLOYMENT_TOKEN: parsed.CONVEX_DEPLOYMENT_TOKEN
|
|
13954
14096
|
};
|
|
13955
|
-
|
|
13956
|
-
|
|
13957
|
-
|
|
13958
|
-
|
|
13959
|
-
|
|
13960
|
-
|
|
13961
|
-
|
|
13962
|
-
|
|
13963
|
-
}
|
|
13964
|
-
|
|
13965
|
-
|
|
13966
|
-
|
|
13967
|
-
}
|
|
13968
|
-
|
|
13969
|
-
|
|
14097
|
+
const lines = [];
|
|
14098
|
+
for (const [key, value] of Object.entries(selectors)) {
|
|
14099
|
+
if (value === void 0) continue;
|
|
14100
|
+
const assignment = [
|
|
14101
|
+
serializeEnvValue(value),
|
|
14102
|
+
`"${value}"`,
|
|
14103
|
+
`\`${value}\``,
|
|
14104
|
+
`'${value}'`
|
|
14105
|
+
].map((quoted) => `${key}=${quoted}`).find((line) => {
|
|
14106
|
+
const entry = parse(line);
|
|
14107
|
+
return entry[key] === value && Object.keys(entry).length === 1;
|
|
14108
|
+
});
|
|
14109
|
+
if (assignment === void 0) throw new Error(`Could not preserve ${key} from the selected Convex env file.`);
|
|
14110
|
+
lines.push(assignment);
|
|
14111
|
+
}
|
|
14112
|
+
const directory = fs.mkdtempSync(join(tmpdir(), "kitcn-dev-target-"));
|
|
14113
|
+
const snapshotPath = join(directory, "target.env");
|
|
14114
|
+
const dispose = () => {
|
|
14115
|
+
process.removeListener("exit", dispose);
|
|
14116
|
+
fs.rmSync(directory, {
|
|
14117
|
+
force: true,
|
|
14118
|
+
recursive: true
|
|
14119
|
+
});
|
|
14120
|
+
};
|
|
14121
|
+
try {
|
|
14122
|
+
fs.writeFileSync(snapshotPath, `${lines.join("\n")}\n`, {
|
|
14123
|
+
mode: 384,
|
|
14124
|
+
flag: "wx"
|
|
14125
|
+
});
|
|
14126
|
+
process.once("exit", dispose);
|
|
14127
|
+
const replaceFile = (args) => args.map((arg, index) => {
|
|
14128
|
+
if (args[index - 1] === "--env-file") return snapshotPath;
|
|
14129
|
+
return arg.startsWith("--env-file=") ? `--env-file=${snapshotPath}` : arg;
|
|
14130
|
+
});
|
|
14131
|
+
return {
|
|
14132
|
+
devArgs: replaceFile(devArgs),
|
|
14133
|
+
targetArgs: replaceFile(targetArgs),
|
|
14134
|
+
dispose
|
|
14135
|
+
};
|
|
14136
|
+
} catch (error) {
|
|
14137
|
+
dispose();
|
|
14138
|
+
throw error;
|
|
13970
14139
|
}
|
|
13971
|
-
return nextArgs;
|
|
13972
14140
|
}
|
|
13973
14141
|
const resolveWatcherCommand = (currentFilename = __filename$1, currentDir = __dirname) => {
|
|
13974
14142
|
const isTs = currentFilename.endsWith(".ts");
|
|
@@ -13988,10 +14156,11 @@ function prependPathEntry(currentPath, entry) {
|
|
|
13988
14156
|
const normalizedEntry = resolve(entry);
|
|
13989
14157
|
return [entry, ...(currentPath ?? "").split(delimiter).filter((segment) => segment.length > 0).filter((segment) => resolve(segment) !== normalizedEntry)].join(delimiter);
|
|
13990
14158
|
}
|
|
13991
|
-
async function resolveSupportedLocalNodeEnvOverrides({ cwd = process.cwd(), currentNodeVersion = process.version, env, execaFn, runtimeName = process.release?.name ?? "node" }) {
|
|
14159
|
+
async function resolveSupportedLocalNodeEnvOverrides({ convexVersion = LOCAL_CONVEX_VERSION, cwd = process.cwd(), currentNodeVersion = process.version, env, execaFn, runtimeName = process.release?.name ?? "node" }) {
|
|
13992
14160
|
if (runtimeName !== "node") return {};
|
|
14161
|
+
const supportedMajors = isConvexVersionAtLeast(convexVersion, 1, 49) ? SUPPORTED_LOCAL_CONVEX_1_49_NODE_MAJORS : SUPPORTED_LOCAL_CONVEX_NODE_MAJORS;
|
|
13993
14162
|
const currentMajor = parseNodeMajor(currentNodeVersion);
|
|
13994
|
-
if (currentMajor !== null &&
|
|
14163
|
+
if (currentMajor !== null && supportedMajors.has(currentMajor)) return {};
|
|
13995
14164
|
const baseEnv = createCommandEnv(env);
|
|
13996
14165
|
const whichResult = await execaFn("which", ["-a", "node"], {
|
|
13997
14166
|
cwd,
|
|
@@ -14010,7 +14179,7 @@ async function resolveSupportedLocalNodeEnvOverrides({ cwd = process.cwd(), curr
|
|
|
14010
14179
|
});
|
|
14011
14180
|
if ((versionResult.exitCode ?? 0) !== 0) continue;
|
|
14012
14181
|
const candidateMajor = parseNodeMajor(versionResult.stdout ?? "");
|
|
14013
|
-
if (candidateMajor !== null &&
|
|
14182
|
+
if (candidateMajor !== null && supportedMajors.has(candidateMajor)) return { PATH: prependPathEntry(baseEnv.PATH, dirname(candidate)) };
|
|
14014
14183
|
}
|
|
14015
14184
|
return {};
|
|
14016
14185
|
}
|
|
@@ -14117,7 +14286,7 @@ Options:
|
|
|
14117
14286
|
--api <dir> Output directory (default from config)
|
|
14118
14287
|
--backend <convex|concave>
|
|
14119
14288
|
Backend CLI to drive
|
|
14120
|
-
--bootstrap
|
|
14289
|
+
--bootstrap Bootstrap the selected Convex deployment once and exit
|
|
14121
14290
|
--config <path> Config path override
|
|
14122
14291
|
--backfill=auto|on|off Dev aggregate backfill mode toggle
|
|
14123
14292
|
--backfill-wait Wait for aggregate backfill completion
|
|
@@ -14126,7 +14295,11 @@ Options:
|
|
|
14126
14295
|
Dev migration mode toggle
|
|
14127
14296
|
--migrations-wait Wait for migration completion
|
|
14128
14297
|
--no-migrations-wait Skip waiting for migration completion`;
|
|
14129
|
-
const handleDevCommand =
|
|
14298
|
+
const handleDevCommand = (argv, deps) => {
|
|
14299
|
+
const targetFile = {};
|
|
14300
|
+
return runDevCommand(argv, deps, targetFile).finally(() => targetFile.dispose?.());
|
|
14301
|
+
};
|
|
14302
|
+
const runDevCommand = async (argv, deps, targetFile) => {
|
|
14130
14303
|
const parsed = parseArgs(argv);
|
|
14131
14304
|
if (HELP_FLAGS$11.has(argv[0] ?? "") || HELP_FLAGS$11.has(parsed.restArgs[0] ?? "")) {
|
|
14132
14305
|
logger.write(DEV_HELP_TEXT);
|
|
@@ -14148,10 +14321,8 @@ const handleDevCommand = async (argv, deps) => {
|
|
|
14148
14321
|
const debug = parsed.debug || config.dev.debug;
|
|
14149
14322
|
assertNoRemovedDevPreRunFlag(config.dev.args);
|
|
14150
14323
|
const { bootstrap, remainingArgs: convexDevArgs } = extractDevBootstrapCliFlag([...config.dev.args, ...devCommandArgs]);
|
|
14151
|
-
const explicitConvexTargetArgs =
|
|
14152
|
-
const
|
|
14153
|
-
const implicitConvexCommandEnv = backend === "convex" && explicitConvexTargetArgs.length === 0 && explicitConvexCommandEnv === null ? resolveImplicitConvexRemoteDeploymentEnv() : null;
|
|
14154
|
-
const effectiveConvexCommandEnv = explicitConvexCommandEnv ?? implicitConvexCommandEnv;
|
|
14324
|
+
const explicitConvexTargetArgs = backend === "convex" ? extractConvexDevTargetArgs(convexDevArgs) : [];
|
|
14325
|
+
const implicitConvexCommandEnv = backend === "convex" && explicitConvexTargetArgs.length === 0 ? resolveImplicitConvexRemoteDeploymentEnv(process.cwd(), process.env.CONVEX_DEPLOYMENT_TOKEN) ?? void 0 : void 0;
|
|
14155
14326
|
const preRunFunction = config.dev.preRun;
|
|
14156
14327
|
if (bootstrap && backend !== "convex") throw new Error("`kitcn dev --bootstrap` is only supported for backend convex.");
|
|
14157
14328
|
if (preRunFunction && backend === "concave") throw new Error("`dev.preRun` is only supported for backend convex. Concave dev has no equivalent `--run` flow.");
|
|
@@ -14166,19 +14337,38 @@ const handleDevCommand = async (argv, deps) => {
|
|
|
14166
14337
|
const { functionsDir } = getConvexConfigFn(sharedDir);
|
|
14167
14338
|
const schemaPath = join(functionsDir, "schema.ts");
|
|
14168
14339
|
const concaveLocalDevContract = backend === "concave" ? resolveConcaveLocalDevContract(convexDevArgs, (deps?.resolveConcaveLocalSiteUrl ?? resolveConcaveLocalSiteUrl)(process.cwd())) : null;
|
|
14169
|
-
const
|
|
14340
|
+
const pinnedTarget = pinConvexDevEnvFile(convexDevArgs, explicitConvexTargetArgs);
|
|
14341
|
+
targetFile.dispose = pinnedTarget?.dispose;
|
|
14342
|
+
const backendDevArgs = concaveLocalDevContract?.backendArgs ?? applyConvexDevPreRunArgs(pinnedTarget?.devArgs ?? convexDevArgs, preRunFunction);
|
|
14170
14343
|
const backendOutputMode = debug || backend === "convex" && !hasDevArg(backendDevArgs, "--once") ? "raw" : "filtered";
|
|
14171
|
-
const targetArgs = concaveLocalDevContract?.targetArgs ??
|
|
14344
|
+
const targetArgs = concaveLocalDevContract?.targetArgs ?? pinnedTarget?.targetArgs ?? explicitConvexTargetArgs;
|
|
14345
|
+
const convexVersion = deps?.convexVersion ?? LOCAL_CONVEX_VERSION;
|
|
14172
14346
|
const trimSegments = resolveCodegenTrimSegments(config);
|
|
14173
|
-
const localNodeEnvOverrides = backend === "convex" ? await resolveSupportedLocalNodeEnvOverridesFn({
|
|
14174
|
-
|
|
14347
|
+
const localNodeEnvOverrides = backend === "convex" ? await resolveSupportedLocalNodeEnvOverridesFn({
|
|
14348
|
+
convexVersion,
|
|
14349
|
+
execaFn
|
|
14350
|
+
}) : {};
|
|
14351
|
+
const commandEnv = localNodeEnvOverrides.PATH ? {
|
|
14352
|
+
...implicitConvexCommandEnv,
|
|
14353
|
+
...localNodeEnvOverrides
|
|
14354
|
+
} : implicitConvexCommandEnv;
|
|
14355
|
+
if (!bootstrap && backend === "convex" && !debug && getAggregateBackfillDeploymentKey(targetArgs, process.cwd(), implicitConvexCommandEnv) === "local") logger.info("Bootstrapping local Convex...");
|
|
14175
14356
|
if (bootstrap) return runLocalConvexBootstrap({
|
|
14176
14357
|
authSyncMode: "complete",
|
|
14177
|
-
config
|
|
14358
|
+
config: {
|
|
14359
|
+
...config,
|
|
14360
|
+
dev: {
|
|
14361
|
+
...config.dev,
|
|
14362
|
+
aggregateBackfill: devBackfillConfig,
|
|
14363
|
+
migrations: devMigrationConfig
|
|
14364
|
+
}
|
|
14365
|
+
},
|
|
14366
|
+
convexVersion,
|
|
14178
14367
|
debug,
|
|
14179
14368
|
devArgs: backendDevArgs,
|
|
14180
14369
|
execaFn,
|
|
14181
14370
|
generateMetaFn,
|
|
14371
|
+
nodeEnvOverrides: localNodeEnvOverrides,
|
|
14182
14372
|
realConvexPath,
|
|
14183
14373
|
realConcavePath,
|
|
14184
14374
|
sharedDir,
|
|
@@ -14193,10 +14383,11 @@ const handleDevCommand = async (argv, deps) => {
|
|
|
14193
14383
|
const convexInitResult = await runConvexInitIfNeeded({
|
|
14194
14384
|
execaFn,
|
|
14195
14385
|
backendAdapter,
|
|
14386
|
+
convexDevVersion: convexVersion,
|
|
14196
14387
|
echoOutput: false,
|
|
14197
14388
|
env: {
|
|
14198
14389
|
...localNodeEnvOverrides,
|
|
14199
|
-
...
|
|
14390
|
+
...implicitConvexCommandEnv
|
|
14200
14391
|
},
|
|
14201
14392
|
targetArgs
|
|
14202
14393
|
});
|
|
@@ -14208,7 +14399,7 @@ const handleDevCommand = async (argv, deps) => {
|
|
|
14208
14399
|
});
|
|
14209
14400
|
if (backend === "convex" && (fs.existsSync(localConvexEnvPath) || authEnvState.installed)) await syncEnvFn({
|
|
14210
14401
|
authSyncMode: authEnvState.installed ? "prepare" : "skip",
|
|
14211
|
-
commandEnv
|
|
14402
|
+
commandEnv,
|
|
14212
14403
|
force: true,
|
|
14213
14404
|
sharedDir,
|
|
14214
14405
|
silent: true,
|
|
@@ -14248,7 +14439,8 @@ const handleDevCommand = async (argv, deps) => {
|
|
|
14248
14439
|
cwd: process.cwd(),
|
|
14249
14440
|
env: createBackendCommandEnv({
|
|
14250
14441
|
...localNodeEnvOverrides,
|
|
14251
|
-
...
|
|
14442
|
+
...implicitConvexCommandEnv,
|
|
14443
|
+
...backend === "convex" && resolveConvexDevChildEnv(targetArgs),
|
|
14252
14444
|
...concaveLocalDevContract?.backendEnv
|
|
14253
14445
|
}),
|
|
14254
14446
|
reject: false
|
|
@@ -14262,7 +14454,7 @@ const handleDevCommand = async (argv, deps) => {
|
|
|
14262
14454
|
signal: backfillAbortController.signal,
|
|
14263
14455
|
runTask: () => syncEnvFn({
|
|
14264
14456
|
authSyncMode: "complete",
|
|
14265
|
-
commandEnv
|
|
14457
|
+
commandEnv,
|
|
14266
14458
|
force: true,
|
|
14267
14459
|
sharedDir,
|
|
14268
14460
|
silent: true,
|
|
@@ -14285,7 +14477,7 @@ const handleDevCommand = async (argv, deps) => {
|
|
|
14285
14477
|
backendAdapter,
|
|
14286
14478
|
backfillConfig: devBackfillConfig,
|
|
14287
14479
|
functionsDir,
|
|
14288
|
-
env:
|
|
14480
|
+
env: commandEnv,
|
|
14289
14481
|
targetArgs,
|
|
14290
14482
|
signal: backfillAbortController.signal
|
|
14291
14483
|
}) !== 0 && !backfillAbortController.signal.aborted) logger.warn("⚠️ aggregateBackfill on schema update failed in dev (continuing without blocking).");
|
|
@@ -14313,7 +14505,7 @@ const handleDevCommand = async (argv, deps) => {
|
|
|
14313
14505
|
await authEnvSyncPromise;
|
|
14314
14506
|
await syncEnvFn({
|
|
14315
14507
|
authSyncMode: "auto",
|
|
14316
|
-
commandEnv
|
|
14508
|
+
commandEnv,
|
|
14317
14509
|
force: true,
|
|
14318
14510
|
sharedDir,
|
|
14319
14511
|
silent: true,
|
|
@@ -14341,7 +14533,7 @@ const handleDevCommand = async (argv, deps) => {
|
|
|
14341
14533
|
runTask: () => runMigrationFlow({
|
|
14342
14534
|
execaFn,
|
|
14343
14535
|
backendAdapter,
|
|
14344
|
-
env:
|
|
14536
|
+
env: commandEnv,
|
|
14345
14537
|
migrationConfig: devMigrationConfig,
|
|
14346
14538
|
targetArgs,
|
|
14347
14539
|
signal: backfillAbortController.signal,
|
|
@@ -14364,7 +14556,7 @@ const handleDevCommand = async (argv, deps) => {
|
|
|
14364
14556
|
execaFn,
|
|
14365
14557
|
backendAdapter,
|
|
14366
14558
|
backfillConfig: devBackfillConfig,
|
|
14367
|
-
env:
|
|
14559
|
+
env: commandEnv,
|
|
14368
14560
|
mode: "resume",
|
|
14369
14561
|
targetArgs,
|
|
14370
14562
|
signal: backfillAbortController.signal,
|
|
@@ -15044,6 +15236,7 @@ Options:
|
|
|
15044
15236
|
--api <dir> Output directory (default from config)
|
|
15045
15237
|
--scope <mode> Generation scope: all | auth | orm
|
|
15046
15238
|
--config <path> Config path override
|
|
15239
|
+
--env-file <path> Select an existing Convex deployment
|
|
15047
15240
|
--debug Show detailed output`;
|
|
15048
15241
|
const handleCodegenCommand = async (argv, deps = {}) => {
|
|
15049
15242
|
const parsed = parseArgs(argv);
|
|
@@ -15515,10 +15708,7 @@ Options:
|
|
|
15515
15708
|
--template, -t App template ("next", "expo", "start", or "vite") for fresh app scaffolding
|
|
15516
15709
|
--cwd Target directory (or parent when used with --name)
|
|
15517
15710
|
--name Project name when scaffolding a fresh app
|
|
15518
|
-
--
|
|
15519
|
-
--preview-name Forward to \`convex init\`
|
|
15520
|
-
--deployment-name Forward to \`convex init\`
|
|
15521
|
-
--env-file Forward to \`convex init\`
|
|
15711
|
+
--env-file <path> Select an existing Convex deployment for codegen
|
|
15522
15712
|
--yes, -y Deterministic non-interactive mode
|
|
15523
15713
|
--defaults Use default shadcn init answers
|
|
15524
15714
|
--overwrite Overwrite existing changed files without prompt
|
|
@@ -15553,7 +15743,7 @@ const handleInitCommand = async (argv, deps = {}) => {
|
|
|
15553
15743
|
realConvexPath,
|
|
15554
15744
|
realConcavePath
|
|
15555
15745
|
});
|
|
15556
|
-
if (shouldRunLocalBootstrap && result.template === null &&
|
|
15746
|
+
if (shouldRunLocalBootstrap && result.template === null && result.needsLocalBootstrap) await withWorkingDirectory(result.cwd, async () => {
|
|
15557
15747
|
const config = loadCliConfigFn(bootstrapConfigPath);
|
|
15558
15748
|
if (await runLocalBootstrapFn({
|
|
15559
15749
|
config,
|
|
@@ -15851,12 +16041,21 @@ const handleVerifyCommand = async (argv, deps) => {
|
|
|
15851
16041
|
assertNoVerifyLifecycleFlags(parsed.restArgs);
|
|
15852
16042
|
const { loadCliConfig } = resolveRunDeps(deps);
|
|
15853
16043
|
const config = loadCliConfig(parsed.configPath);
|
|
15854
|
-
|
|
16044
|
+
if (resolveConfiguredBackend({
|
|
15855
16045
|
backendArg: parsed.backend,
|
|
15856
16046
|
config
|
|
15857
|
-
});
|
|
15858
|
-
|
|
15859
|
-
|
|
16047
|
+
}) !== "convex") throw new Error("`kitcn verify` is only supported for backend convex.");
|
|
16048
|
+
const devArgs = [...config.dev.args, ...parsed.convexArgs];
|
|
16049
|
+
const configuresDeployment = devArgs.some((arg) => arg === "--configure" || arg.startsWith("--configure="));
|
|
16050
|
+
const devDeployment = readOptionalCliFlagValue(devArgs, "--dev-deployment");
|
|
16051
|
+
if (devDeployment === "cloud" || configuresDeployment && (devDeployment !== "local" || readOptionalCliFlagValue(devArgs, "--configure") !== "existing")) throw new Error("`kitcn verify` is local-only. Use an existing project with `--dev-deployment local` or remove the Convex reconfiguration flags.");
|
|
16052
|
+
const hasEnvFile = devArgs.some((arg) => arg === "--env-file" || arg.startsWith("--env-file="));
|
|
16053
|
+
const defaultEnv = {};
|
|
16054
|
+
if (!hasEnvFile) {
|
|
16055
|
+
for (const file of [".env", ".env.local"]) if (fs.existsSync(file)) Object.assign(defaultEnv, loadDotenv().parse(fs.readFileSync(file, "utf8")));
|
|
16056
|
+
if (process.env.CONVEX_DEPLOYMENT_TOKEN) defaultEnv.CONVEX_DEPLOYMENT_TOKEN = process.env.CONVEX_DEPLOYMENT_TOKEN;
|
|
16057
|
+
}
|
|
16058
|
+
if (getAggregateBackfillDeploymentKey(devArgs, process.cwd(), defaultEnv) !== "local") throw new Error("`kitcn verify` is local-only. Remove remote deployment flags like `--prod`, `--preview-name`, and `--deployment-name`.");
|
|
15860
16059
|
const devArgv = buildVerifyDevArgv(argv);
|
|
15861
16060
|
if (hasConfiguredLocalConvexDeployment()) return handleDevCommand(devArgv, deps);
|
|
15862
16061
|
return withIsolatedLocalConvexState(() => handleDevCommand(devArgv, deps));
|