UNPKG

convex

Version:

Client for the Convex Cloud

108 lines (107 loc) 4.63 kB
"use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var deploy_exports = {}; __export(deploy_exports, { deploy: () => deploy }); module.exports = __toCommonJS(deploy_exports); var import_chalk = __toESM(require("chalk")); var import_commander = require("commander"); var import_inquirer = __toESM(require("inquirer")); var import_api = require("./lib/api"); var import_config = require("./lib/config"); var import_context = require("./lib/context"); var import_push = require("./lib/push"); const deploy = new import_commander.Command("deploy").description( "Deploy your Convex functions to this project's production deployment" ).option("-v, --verbose", "Show full listing of changes").option( "--dry-run", "Print out the generated configuration without deploying to your production deployment" ).addOption( new import_commander.Option( "--typecheck <mode>", `Whether to check TypeScript files with \`tsc --noEmit\` before deploying.` ).choices(["enable", "try", "disable"]).default("try") ).addOption( new import_commander.Option( "--codegen <mode>", "Whether to regenerate code in `convex/_generated/` before pushing." ).choices(["enable", "disable"]).default("enable") ).option("-y, --yes", "Skip confirmation prompt.").addOption(new import_commander.Option("--debug-bundle-path <path>").hideHelp()).addOption(new import_commander.Option("--debug").hideHelp()).addOption(new import_commander.Option("--admin-key <adminKey>").hideHelp()).addOption(new import_commander.Option("--url <url>").hideHelp()).action(async (cmdOptions) => { const ctx = import_context.oneoffContext; const projectConfig = (await (0, import_config.readProjectConfig)(ctx)).projectConfig; let adminKey = cmdOptions.adminKey; const url = cmdOptions.url ?? projectConfig.prodUrl; if (process.env.CONVEX_DEPLOY_KEY) { adminKey = process.env.CONVEX_DEPLOY_KEY; } const buildEnvironmentExpectsConvexDeployKey = process.env.VERCEL ? "Vercel" : process.env.NETLIFY ? "Netlify" : false; if (!adminKey) { if (buildEnvironmentExpectsConvexDeployKey) { console.error( import_chalk.default.yellow( `${buildEnvironmentExpectsConvexDeployKey} build environment detected but CONVEX_DEPLOY_KEY is not set. Set this environment variable to deploy from this environment.` ) ); await ctx.fatalError(1); } adminKey = (await (0, import_api.getUrlAndAdminKey)( ctx, projectConfig.project, projectConfig.team, "prod" )).adminKey; if (!cmdOptions.yes) { const confirmed = (await import_inquirer.default.prompt([ { type: "confirm", name: "confirmed", message: "About to deploy Convex functions to production. This will update `convex/_generated/clientConfig.js` to reference your production deployment.\n\nOkay to proceed?" } ])).confirmed; if (!confirmed) { await ctx.fatalError(1); } } } const options = { adminKey, verbose: !!cmdOptions.verbose, dryRun: !!cmdOptions.dryRun, typecheck: cmdOptions.typecheck, debug: !!cmdOptions.debug, debugBundlePath: cmdOptions.debugBundlePath, codegen: cmdOptions.codegen === "enable", deploymentType: "prod", url }; await (0, import_push.runPush)(import_context.oneoffContext, options); console.log( import_chalk.default.green( `${options.dryRun ? "Would have deployed" : "Deployed"} Convex functions to this project's production deployment successfully!` ) ); }); //# sourceMappingURL=deploy.js.map