UNPKG

convex

Version:

Client for the Convex Cloud

117 lines (116 loc) 4.07 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 push_exports = {}; __export(push_exports, { runPush: () => runPush }); module.exports = __toCommonJS(push_exports); var import_chalk = __toESM(require("chalk")); var import_config = require("./config.js"); var import_utils = require("./utils.js"); var import_typecheck = require("./typecheck.js"); var import_codegen = require("./codegen"); var import_indexes = require("./indexes.js"); async function runPush(ctx, options) { const { configPath, projectConfig } = await (0, import_config.readProjectConfig)(ctx); const origin = options.url; const verbose = options.verbose || options.dryRun; await (0, import_utils.ensureHasConvexDependency)(ctx, "push"); if (!options.codegen) { console.error( import_chalk.default.gray("Skipping codegen. Remove --codegen=disable to enable.") ); const funcDir = (0, import_utils.functionsDir)(configPath, projectConfig); await (0, import_typecheck.processTypeCheckResult)( ctx, options.typecheck, () => (0, import_typecheck.typeCheckFunctions)(ctx, funcDir) ); } else { await (0, import_codegen.doCodegen)({ ctx, projectConfig, configPath, deploymentType: options.deploymentType, typeCheckMode: options.typecheck, dryRun: options.dryRun, debug: options.debug, quiet: true }); if (verbose) { console.error(import_chalk.default.green("Codegen finished.")); } } const localConfig = await (0, import_config.configFromProjectConfig)( ctx, projectConfig, configPath, verbose ); if (options.debugBundlePath) { const config = (0, import_config.configJSON)(localConfig, options.adminKey); ctx.fs.writeUtf8File(options.debugBundlePath, JSON.stringify(config)); return; } await (0, import_indexes.buildIndexes)( ctx, origin, options.adminKey, (0, import_utils.functionsDir)(configPath, localConfig.projectConfig), options.dryRun ); const remoteConfig = await (0, import_config.pullConfig)( ctx, localConfig.projectConfig.project, localConfig.projectConfig.team, origin, options.adminKey ); const diff = (0, import_config.diffConfig)(remoteConfig, localConfig); if (diff == "") { if (verbose) { const msg = localConfig.modules.length == 0 ? `No functions found in ${localConfig.projectConfig.functions}` : "Config already synced"; console.log( import_chalk.default.gray( `${options.dryRun ? "Command would skip function push" : "Function push skipped"}: ${msg}.` ) ); } return; } if (verbose) { console.log( import_chalk.default.bold( `Remote config ${options.dryRun ? "would" : "will"} be overwritten with the following changes:` ) ); console.log(diff); } if (options.dryRun) { return; } await (0, import_config.pushConfig)(ctx, localConfig, options.adminKey, options.url); } //# sourceMappingURL=push.js.map