convex 1.36.0 → 1.36.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -4
- package/dist/browser.bundle.js +1 -1
- package/dist/browser.bundle.js.map +1 -1
- package/dist/cjs/cli/envDefault.js +130 -41
- package/dist/cjs/cli/envDefault.js.map +3 -3
- package/dist/cjs/cli/lib/command.js +1 -1
- package/dist/cjs/cli/lib/command.js.map +1 -1
- package/dist/cjs/cli/lib/login.js +51 -0
- package/dist/cjs/cli/lib/login.js.map +3 -3
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs-types/cli/envDefault.d.ts +2 -2
- package/dist/cjs-types/cli/envDefault.d.ts.map +1 -1
- package/dist/cjs-types/cli/envDefault.test.d.ts +2 -0
- package/dist/cjs-types/cli/envDefault.test.d.ts.map +1 -0
- package/dist/cjs-types/cli/lib/login.d.ts.map +1 -1
- package/dist/cjs-types/index.d.ts +1 -1
- package/dist/cli.bundle.cjs +186 -48
- package/dist/cli.bundle.cjs.map +4 -4
- package/dist/esm/cli/envDefault.js +131 -42
- package/dist/esm/cli/envDefault.js.map +3 -3
- package/dist/esm/cli/lib/command.js +1 -1
- package/dist/esm/cli/lib/command.js.map +1 -1
- package/dist/esm/cli/lib/login.js +52 -0
- package/dist/esm/cli/lib/login.js.map +3 -3
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm-types/cli/envDefault.d.ts +2 -2
- package/dist/esm-types/cli/envDefault.d.ts.map +1 -1
- package/dist/esm-types/cli/envDefault.test.d.ts +2 -0
- package/dist/esm-types/cli/envDefault.test.d.ts.map +1 -0
- package/dist/esm-types/cli/lib/login.d.ts.map +1 -1
- package/dist/esm-types/index.d.ts +1 -1
- package/dist/react.bundle.js +1 -1
- package/dist/react.bundle.js.map +1 -1
- package/package.json +4 -4
- package/src/cli/envDefault.test.ts +495 -0
- package/src/cli/envDefault.ts +222 -107
- package/src/cli/lib/command.ts +1 -1
- package/src/cli/lib/login.ts +67 -0
- package/src/index.ts +1 -1
package/dist/cjs/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["export const version = \"1.36.
|
|
4
|
+
"sourcesContent": ["export const version = \"1.36.1\";\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,UAAU;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Command } from "@commander-js/extra-typings";
|
|
2
2
|
import { EnvVarBackend } from "./lib/env.js";
|
|
3
|
-
import { DeploymentType } from "./lib/api.js";
|
|
3
|
+
import { CloudDeploymentType, DeploymentType } from "./lib/api.js";
|
|
4
4
|
import { Context } from "../bundler/context.js";
|
|
5
5
|
export declare const envDefault: Command<[], {}, {}>;
|
|
6
6
|
export declare function resolveDefaultEnvBackend(ctx: Context, deploymentFields: {
|
|
7
7
|
deploymentName: string;
|
|
8
8
|
deploymentType: DeploymentType;
|
|
9
|
-
} | null): Promise<EnvVarBackend>;
|
|
9
|
+
} | null, dtypeOverride?: CloudDeploymentType): Promise<EnvVarBackend>;
|
|
10
10
|
//# sourceMappingURL=envDefault.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"envDefault.d.ts","sourceRoot":"","sources":["../../../src/cli/envDefault.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"envDefault.d.ts","sourceRoot":"","sources":["../../../src/cli/envDefault.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAU,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAKL,aAAa,EACd,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,mBAAmB,EAEnB,cAAc,EAEf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,OAAO,EAAiB,MAAM,uBAAuB,CAAC;AA2H/D,eAAO,MAAM,UAAU,qBAcF,CAAC;AAqGtB,wBAAsB,wBAAwB,CAC5C,GAAG,EAAE,OAAO,EACZ,gBAAgB,EAAE;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,cAAc,CAAC;CAChC,GAAG,IAAI,EACR,aAAa,CAAC,EAAE,mBAAmB,GAClC,OAAO,CAAC,aAAa,CAAC,CAwBxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"envDefault.test.d.ts","sourceRoot":"","sources":["../../../src/cli/envDefault.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../../src/cli/lib/login.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../../src/cli/lib/login.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAiCnD,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,OAAO,EACZ,YAAY,EAAE,OAAO,GACpB,OAAO,CAAC,OAAO,CAAC,CAqClB;AA0LD,wBAAsB,YAAY,CAChC,GAAG,EAAE,OAAO,EACZ,EACE,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,SAAS,EACT,IAAI,EACJ,YAAY,EACZ,eAAe,EACf,UAAU,EAAE,kBAAkB,EAC9B,WAAW,EACX,MAAM,EACN,cAAc,GACf,GAAE;IACD,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,kBAAkB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,oBAAoB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1C,oBAAoB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1C,mBAAmB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;IAElD,IAAI,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAE3B,YAAY,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACnC,eAAe,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACtC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC7B,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC,sBAmIP;AAoID,wBAAsB,cAAc,CAClC,GAAG,EAAE,OAAO,EACZ,OAAO,CAAC,EAAE;IACR,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,kBAAkB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,oBAAoB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1C,oBAAoB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3C,iBAeF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "1.36.
|
|
1
|
+
export declare const version = "1.36.1";
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/cli.bundle.cjs
CHANGED
|
@@ -18183,7 +18183,7 @@ var require_context = __commonJS({
|
|
|
18183
18183
|
};
|
|
18184
18184
|
});
|
|
18185
18185
|
var nodeContextIntegration = core.defineIntegration(_nodeContextIntegration);
|
|
18186
|
-
var
|
|
18186
|
+
var Context12 = core.convertIntegrationFnToClass(INTEGRATION_NAME, nodeContextIntegration);
|
|
18187
18187
|
function _updateContext(contexts) {
|
|
18188
18188
|
if (_optionalChain([contexts, "optionalAccess", (_11) => _11.app, "optionalAccess", (_12) => _12.app_memory])) {
|
|
18189
18189
|
contexts.app.app_memory = process.memoryUsage().rss;
|
|
@@ -18393,7 +18393,7 @@ var require_context = __commonJS({
|
|
|
18393
18393
|
return void 0;
|
|
18394
18394
|
}
|
|
18395
18395
|
}
|
|
18396
|
-
exports2.Context =
|
|
18396
|
+
exports2.Context = Context12;
|
|
18397
18397
|
exports2.getDeviceContext = getDeviceContext;
|
|
18398
18398
|
exports2.nodeContextIntegration = nodeContextIntegration;
|
|
18399
18399
|
exports2.readDirAsync = readDirAsync;
|
|
@@ -28695,7 +28695,7 @@ var version;
|
|
|
28695
28695
|
var init_index = __esm({
|
|
28696
28696
|
"src/index.ts"() {
|
|
28697
28697
|
"use strict";
|
|
28698
|
-
version = "1.36.
|
|
28698
|
+
version = "1.36.1";
|
|
28699
28699
|
}
|
|
28700
28700
|
});
|
|
28701
28701
|
|
|
@@ -78784,9 +78784,9 @@ var require_balanced_match = __commonJS({
|
|
|
78784
78784
|
}
|
|
78785
78785
|
});
|
|
78786
78786
|
|
|
78787
|
-
// ../common/temp/node_modules/.pnpm/brace-expansion@1.1.
|
|
78787
|
+
// ../common/temp/node_modules/.pnpm/brace-expansion@1.1.13/node_modules/brace-expansion/index.js
|
|
78788
78788
|
var require_brace_expansion = __commonJS({
|
|
78789
|
-
"../common/temp/node_modules/.pnpm/brace-expansion@1.1.
|
|
78789
|
+
"../common/temp/node_modules/.pnpm/brace-expansion@1.1.13/node_modules/brace-expansion/index.js"(exports2, module2) {
|
|
78790
78790
|
var concatMap = require_concat_map();
|
|
78791
78791
|
var balanced = require_balanced_match();
|
|
78792
78792
|
module2.exports = expandTop;
|
|
@@ -78881,7 +78881,7 @@ var require_brace_expansion = __commonJS({
|
|
|
78881
78881
|
var x = numeric(n[0]);
|
|
78882
78882
|
var y = numeric(n[1]);
|
|
78883
78883
|
var width = Math.max(n[0].length, n[1].length);
|
|
78884
|
-
var incr = n.length == 3 ? Math.abs(numeric(n[2])) : 1;
|
|
78884
|
+
var incr = n.length == 3 ? Math.max(Math.abs(numeric(n[2])), 1) : 1;
|
|
78885
78885
|
var test = lte;
|
|
78886
78886
|
var reverse = y < x;
|
|
78887
78887
|
if (reverse) {
|
|
@@ -133408,6 +133408,57 @@ async function performLogin(ctx, {
|
|
|
133408
133408
|
printedMessage: null
|
|
133409
133409
|
});
|
|
133410
133410
|
}
|
|
133411
|
+
if (vercel) {
|
|
133412
|
+
await promptJoinVercelTeams(ctx);
|
|
133413
|
+
}
|
|
133414
|
+
}
|
|
133415
|
+
async function promptJoinVercelTeams(ctx) {
|
|
133416
|
+
const fetch2 = bigBrainFetch(ctx);
|
|
133417
|
+
let teams;
|
|
133418
|
+
try {
|
|
133419
|
+
const res = await fetch2(
|
|
133420
|
+
new URL("vercel/potential_teams", `${provisionHost}/`)
|
|
133421
|
+
);
|
|
133422
|
+
if (!res.ok) {
|
|
133423
|
+
logVerbose(
|
|
133424
|
+
`vercel/potential_teams returned ${res.status}; skipping team-join prompt`
|
|
133425
|
+
);
|
|
133426
|
+
return;
|
|
133427
|
+
}
|
|
133428
|
+
teams = await res.json();
|
|
133429
|
+
} catch (err) {
|
|
133430
|
+
logVerbose(`Failed to fetch potential Vercel teams: ${String(err)}`);
|
|
133431
|
+
return;
|
|
133432
|
+
}
|
|
133433
|
+
if (teams.length === 0) return;
|
|
133434
|
+
for (const [index, team] of teams.entries()) {
|
|
133435
|
+
const displayName = team.teamName.replace(/ \(Vercel\)$/, "");
|
|
133436
|
+
const counter = teams.length > 1 ? `[${index + 1}/${teams.length}] ` : "";
|
|
133437
|
+
const lines = [
|
|
133438
|
+
chalkStderr.bold(`${counter}You've been invited to join ${displayName}`) + ` (${team.planName}) through the Vercel marketplace.`
|
|
133439
|
+
];
|
|
133440
|
+
if (team.pricingNotice) {
|
|
133441
|
+
lines.push(chalkStderr.yellow(team.pricingNotice));
|
|
133442
|
+
}
|
|
133443
|
+
lines.push(`Join "${displayName}"?`);
|
|
133444
|
+
const join = await promptYesNo(ctx, {
|
|
133445
|
+
message: `${lines.join("\n")}`,
|
|
133446
|
+
default: true
|
|
133447
|
+
});
|
|
133448
|
+
if (!join) continue;
|
|
133449
|
+
try {
|
|
133450
|
+
await fetch2(
|
|
133451
|
+
new URL(
|
|
133452
|
+
`vercel/potential_teams/${team.teamId}/join`,
|
|
133453
|
+
`${provisionHost}/`
|
|
133454
|
+
),
|
|
133455
|
+
{ method: "POST" }
|
|
133456
|
+
);
|
|
133457
|
+
logFinishedStep(`Joined ${displayName}`);
|
|
133458
|
+
} catch (err) {
|
|
133459
|
+
logFailure(`Failed to join ${displayName}: ${String(err)}`);
|
|
133460
|
+
}
|
|
133461
|
+
}
|
|
133411
133462
|
}
|
|
133412
133463
|
async function optins(ctx, acceptOptIns) {
|
|
133413
133464
|
const bbAuth = ctx.bigBrainAuth();
|
|
@@ -134192,7 +134243,7 @@ Command.prototype.addDeploymentSelectionOptions = function(action, options) {
|
|
|
134192
134243
|
).addOption(
|
|
134193
134244
|
new Option(
|
|
134194
134245
|
"--deployment <deployment>",
|
|
134195
|
-
action + " a specific deployment. Accepts:\n\u2022 a deployment name (e.g. joyful-capybara-123)\u2022 a deployment reference (e.g. dev/james, staging)\n\u2022 `dev` (for your personal dev deployment)\n\u2022 `prod` (for your project\u2019s default production deployment)\n\u2022 `local` (for your local dev deployment).\nYou can also select deployments in other projects with `project-slug:reference` or `team-slug:project-slug:reference`."
|
|
134246
|
+
action + " a specific deployment. Accepts:\n\u2022 a deployment name (e.g. joyful-capybara-123)\n\u2022 a deployment reference (e.g. dev/james, staging)\n\u2022 `dev` (for your personal dev deployment)\n\u2022 `prod` (for your project\u2019s default production deployment)\n\u2022 `local` (for your local dev deployment).\nYou can also select deployments in other projects with `project-slug:reference` or `team-slug:project-slug:reference`."
|
|
134196
134247
|
).conflicts(["--prod", "--preview-name", "--deployment-name", "--url"])
|
|
134197
134248
|
).addOption(
|
|
134198
134249
|
new Option(
|
|
@@ -136259,22 +136310,33 @@ function defaultEnvBackend(ctx, projectId, dtype) {
|
|
|
136259
136310
|
|
|
136260
136311
|
// src/cli/envDefault.ts
|
|
136261
136312
|
init_api3();
|
|
136262
|
-
|
|
136263
|
-
|
|
136264
|
-
|
|
136265
|
-
|
|
136266
|
-
|
|
136267
|
-
)
|
|
136268
|
-
|
|
136269
|
-
|
|
136270
|
-
|
|
136313
|
+
function addEnvDefaultOptions(cmd) {
|
|
136314
|
+
return cmd.addOption(
|
|
136315
|
+
new Option(
|
|
136316
|
+
"--type <type>",
|
|
136317
|
+
"Manage default env vars for the given deployment type instead of inferring from the current deployment."
|
|
136318
|
+
)
|
|
136319
|
+
).addOption(
|
|
136320
|
+
new Option(
|
|
136321
|
+
"--project <project>",
|
|
136322
|
+
"Select a project manually. Accepts `team-slug:project-slug` or just `project-slug` (team inferred from your current project). Requires --type."
|
|
136323
|
+
)
|
|
136324
|
+
);
|
|
136325
|
+
}
|
|
136326
|
+
var envDefaultSet = addEnvDefaultOptions(
|
|
136327
|
+
new Command("set").usage("[options] <name> <value>").arguments("[name] [value]").summary("Set a default variable").description(
|
|
136328
|
+
"Set default environment variables for your project's deployment type.\n\n npx convex env default set NAME 'value'\n npx convex env default set NAME # omit a value to set one interactively\n npx convex env default set NAME --from-file value.txt\n npx convex env default set --from-file .env.defaults\nWhen setting multiple values, it will refuse all changes if any variables are already set to different values by default. Pass --force to overwrite the provided values.\nThe deployment type is determined by the current deployment (local maps to dev), or by --type if provided.\n"
|
|
136329
|
+
).option(
|
|
136330
|
+
"--from-file <file>",
|
|
136331
|
+
"Read environment variables from a .env file. Without --force, fails if any existing variable has a different value."
|
|
136332
|
+
).option(
|
|
136333
|
+
"--force",
|
|
136334
|
+
"When setting multiple variables, overwrite existing environment variable values instead of failing on mismatch."
|
|
136335
|
+
).configureHelp({ showGlobalOptions: true }).allowExcessArguments(false)
|
|
136336
|
+
).action(async (name, value, cmdOptions, cmd) => {
|
|
136271
136337
|
const options = cmd.optsWithGlobals();
|
|
136272
|
-
const { ctx,
|
|
136338
|
+
const { ctx, backend } = await resolveEnvDefaultBackend(options);
|
|
136273
136339
|
await ensureHasConvexDependency(ctx, "env default set");
|
|
136274
|
-
const backend = await resolveDefaultEnvBackend(
|
|
136275
|
-
ctx,
|
|
136276
|
-
deployment2.deploymentFields
|
|
136277
|
-
);
|
|
136278
136340
|
const didAnything = await envSet(ctx, backend, name, value, cmdOptions);
|
|
136279
136341
|
if (didAnything === false) {
|
|
136280
136342
|
cmd.outputHelp({ error: true });
|
|
@@ -136285,46 +136347,122 @@ var envDefaultSet = new Command("set").usage("[options] <name> <value>").argumen
|
|
|
136285
136347
|
});
|
|
136286
136348
|
}
|
|
136287
136349
|
});
|
|
136288
|
-
var envDefaultGet =
|
|
136289
|
-
"Print a default variable's value
|
|
136290
|
-
|
|
136350
|
+
var envDefaultGet = addEnvDefaultOptions(
|
|
136351
|
+
new Command("get").arguments("<name>").summary("Print a default variable's value").description(
|
|
136352
|
+
"Print a default variable's value: `npx convex env default get NAME`\nThe deployment type is determined by the current deployment (local maps to dev), or by --type if provided."
|
|
136353
|
+
).configureHelp({ showGlobalOptions: true }).allowExcessArguments(false)
|
|
136354
|
+
).action(async (envVarName, _options2, cmd) => {
|
|
136291
136355
|
const options = cmd.optsWithGlobals();
|
|
136292
|
-
const { ctx,
|
|
136356
|
+
const { ctx, backend } = await resolveEnvDefaultBackend(options);
|
|
136293
136357
|
await ensureHasConvexDependency(ctx, "env default get");
|
|
136294
|
-
const backend = await resolveDefaultEnvBackend(
|
|
136295
|
-
ctx,
|
|
136296
|
-
deployment2.deploymentFields
|
|
136297
|
-
);
|
|
136298
136358
|
await envGet(ctx, backend, envVarName);
|
|
136299
136359
|
});
|
|
136300
|
-
var envDefaultRemove =
|
|
136301
|
-
"Unset a default variable
|
|
136302
|
-
|
|
136360
|
+
var envDefaultRemove = addEnvDefaultOptions(
|
|
136361
|
+
new Command("remove").alias("rm").alias("unset").arguments("<name>").summary("Unset a default variable").description(
|
|
136362
|
+
"Unset a default variable: `npx convex env default remove NAME`\nIf the variable doesn't exist, the command doesn't do anything and succeeds.\nThe deployment type is determined by the current deployment (local maps to dev), or by --type if provided."
|
|
136363
|
+
).configureHelp({ showGlobalOptions: true }).allowExcessArguments(false)
|
|
136364
|
+
).action(async (name, _options2, cmd) => {
|
|
136303
136365
|
const options = cmd.optsWithGlobals();
|
|
136304
|
-
const { ctx,
|
|
136366
|
+
const { ctx, backend } = await resolveEnvDefaultBackend(options);
|
|
136305
136367
|
await ensureHasConvexDependency(ctx, "env default remove");
|
|
136306
|
-
const backend = await resolveDefaultEnvBackend(
|
|
136307
|
-
ctx,
|
|
136308
|
-
deployment2.deploymentFields
|
|
136309
|
-
);
|
|
136310
136368
|
await envRemove(ctx, backend, name);
|
|
136311
136369
|
});
|
|
136312
|
-
var envDefaultList =
|
|
136313
|
-
"List all default variables
|
|
136314
|
-
|
|
136370
|
+
var envDefaultList = addEnvDefaultOptions(
|
|
136371
|
+
new Command("list").summary("List all default variables").description(
|
|
136372
|
+
"List all default variables: `npx convex env default list`\nThe deployment type is determined by the current deployment (local maps to dev), or by --type if provided."
|
|
136373
|
+
).configureHelp({ showGlobalOptions: true }).allowExcessArguments(false)
|
|
136374
|
+
).action(async (_options2, cmd) => {
|
|
136315
136375
|
const options = cmd.optsWithGlobals();
|
|
136316
|
-
const { ctx,
|
|
136376
|
+
const { ctx, backend } = await resolveEnvDefaultBackend(options);
|
|
136317
136377
|
await ensureHasConvexDependency(ctx, "env default list");
|
|
136318
|
-
const backend = await resolveDefaultEnvBackend(
|
|
136319
|
-
ctx,
|
|
136320
|
-
deployment2.deploymentFields
|
|
136321
|
-
);
|
|
136322
136378
|
await envList(ctx, backend);
|
|
136323
136379
|
});
|
|
136324
136380
|
var envDefault = new Command("default").summary("Manage project-level default environment variables").description(
|
|
136325
|
-
"Manage default environment variables for your project.\n\nThe default environment variables read and written to by this command are the ones for the deployment type of the current deployment (i.e. dev in most cases).\n\n Set a default variable: `npx convex env default set NAME 'value'`\n Unset a default variable: `npx convex env default remove NAME`\n List all default variables: `npx convex env default list`\n Print a default variable's value: `npx convex env default get NAME`\n\n"
|
|
136381
|
+
"Manage default environment variables for your project.\n\nThe default environment variables read and written to by this command are the ones for the deployment type of the current deployment (i.e. dev in most cases), unless --type is provided.\n\n Set a default variable: `npx convex env default set NAME 'value'`\n Unset a default variable: `npx convex env default remove NAME`\n List all default variables: `npx convex env default list`\n Print a default variable's value: `npx convex env default get NAME`\n\n"
|
|
136326
136382
|
).addCommand(envDefaultSet).addCommand(envDefaultGet).addCommand(envDefaultRemove).addCommand(envDefaultList).helpCommand(false);
|
|
136327
|
-
async function
|
|
136383
|
+
async function resolveEnvDefaultBackend(options) {
|
|
136384
|
+
const dtypeOverride = normalizeTypeOption(options.type);
|
|
136385
|
+
if (options.project !== void 0) {
|
|
136386
|
+
const parsedProject = parseProjectOption(options.project);
|
|
136387
|
+
if (parsedProject === null) {
|
|
136388
|
+
const ctx3 = await oneoffContext(options);
|
|
136389
|
+
return await ctx3.crash({
|
|
136390
|
+
exitCode: 1,
|
|
136391
|
+
errorType: "fatal",
|
|
136392
|
+
printedMessage: "error: --project must be `team-slug:project-slug` or `project-slug`."
|
|
136393
|
+
});
|
|
136394
|
+
}
|
|
136395
|
+
if (dtypeOverride === void 0) {
|
|
136396
|
+
const ctx3 = await oneoffContext(options);
|
|
136397
|
+
return await ctx3.crash({
|
|
136398
|
+
exitCode: 1,
|
|
136399
|
+
errorType: "fatal",
|
|
136400
|
+
printedMessage: "error: --project requires --type to also be set."
|
|
136401
|
+
});
|
|
136402
|
+
}
|
|
136403
|
+
let ctx2;
|
|
136404
|
+
let resolved;
|
|
136405
|
+
if (parsedProject.kind === "teamAndProject") {
|
|
136406
|
+
ctx2 = await oneoffContext(options);
|
|
136407
|
+
resolved = {
|
|
136408
|
+
teamSlug: parsedProject.teamSlug,
|
|
136409
|
+
projectSlug: parsedProject.projectSlug
|
|
136410
|
+
};
|
|
136411
|
+
} else {
|
|
136412
|
+
const selected = await selectEnvDeployment(options);
|
|
136413
|
+
ctx2 = selected.ctx;
|
|
136414
|
+
if (selected.deployment.deploymentFields === null) {
|
|
136415
|
+
return await ctx2.crash({
|
|
136416
|
+
exitCode: 1,
|
|
136417
|
+
errorType: "fatal",
|
|
136418
|
+
printedMessage: "error: --project <project-slug> requires a current cloud deployment to infer the team from. Use `team-slug:project-slug` to specify the team explicitly."
|
|
136419
|
+
});
|
|
136420
|
+
}
|
|
136421
|
+
const { team } = await fetchTeamAndProject(
|
|
136422
|
+
ctx2,
|
|
136423
|
+
selected.deployment.deploymentFields.deploymentName
|
|
136424
|
+
);
|
|
136425
|
+
resolved = { teamSlug: team, projectSlug: parsedProject.projectSlug };
|
|
136426
|
+
}
|
|
136427
|
+
const details = await getProjectDetails(ctx2, {
|
|
136428
|
+
kind: "teamAndProjectSlugs",
|
|
136429
|
+
teamSlug: resolved.teamSlug,
|
|
136430
|
+
projectSlug: resolved.projectSlug
|
|
136431
|
+
});
|
|
136432
|
+
return {
|
|
136433
|
+
ctx: ctx2,
|
|
136434
|
+
backend: defaultEnvBackend(ctx2, details.id, dtypeOverride)
|
|
136435
|
+
};
|
|
136436
|
+
}
|
|
136437
|
+
const { ctx, deployment: deployment2 } = await selectEnvDeployment(options);
|
|
136438
|
+
const backend = await resolveDefaultEnvBackend(
|
|
136439
|
+
ctx,
|
|
136440
|
+
deployment2.deploymentFields,
|
|
136441
|
+
dtypeOverride
|
|
136442
|
+
);
|
|
136443
|
+
return { ctx, backend };
|
|
136444
|
+
}
|
|
136445
|
+
function normalizeTypeOption(type) {
|
|
136446
|
+
if (type === void 0) return void 0;
|
|
136447
|
+
if (type === "development") return "dev";
|
|
136448
|
+
if (type === "production") return "prod";
|
|
136449
|
+
return type;
|
|
136450
|
+
}
|
|
136451
|
+
function parseProjectOption(value) {
|
|
136452
|
+
const parts = value.split(":");
|
|
136453
|
+
if (parts.length === 1 && parts[0].length > 0) {
|
|
136454
|
+
return { kind: "projectOnly", projectSlug: parts[0] };
|
|
136455
|
+
}
|
|
136456
|
+
if (parts.length === 2 && parts[0].length > 0 && parts[1].length > 0) {
|
|
136457
|
+
return {
|
|
136458
|
+
kind: "teamAndProject",
|
|
136459
|
+
teamSlug: parts[0],
|
|
136460
|
+
projectSlug: parts[1]
|
|
136461
|
+
};
|
|
136462
|
+
}
|
|
136463
|
+
return null;
|
|
136464
|
+
}
|
|
136465
|
+
async function resolveDefaultEnvBackend(ctx, deploymentFields, dtypeOverride) {
|
|
136328
136466
|
if (deploymentFields === null) {
|
|
136329
136467
|
return await ctx.crash({
|
|
136330
136468
|
exitCode: 1,
|
|
@@ -136339,7 +136477,7 @@ async function resolveDefaultEnvBackend(ctx, deploymentFields) {
|
|
|
136339
136477
|
printedMessage: "Default environment variables are not available for anonymous deployments."
|
|
136340
136478
|
});
|
|
136341
136479
|
}
|
|
136342
|
-
const dtype = resolveDefaultEnvDtype(deploymentFields.deploymentType);
|
|
136480
|
+
const dtype = dtypeOverride ?? resolveDefaultEnvDtype(deploymentFields.deploymentType);
|
|
136343
136481
|
const { projectId } = await fetchTeamAndProject(
|
|
136344
136482
|
ctx,
|
|
136345
136483
|
deploymentFields.deploymentName
|