UNPKG

convex

Version:

Client for the Convex Cloud

87 lines (86 loc) 3.54 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 codegen_exports = {}; __export(codegen_exports, { codegen: () => codegen }); module.exports = __toCommonJS(codegen_exports); var import_commander = require("commander"); var import_config = require("./lib/config.js"); var import_chalk = __toESM(require("chalk")); var import_utils = require("./lib/utils.js"); var import_codegen = require("./lib/codegen"); var import_context = require("./lib/context.js"); const codegen = new import_commander.Command("codegen").description( "Generate TypeScript code in `convex/_generated/` based on the current contents of `convex/`." ).option( "--dry-run", "Print out the generated configuration to stdout instead of writing to convex directory" ).addOption(new import_commander.Option("--debug").hideHelp()).addOption( new import_commander.Option( "--typecheck <mode>", `Whether to check TypeScript files with \`tsc --noEmit\`.` ).choices(["enable", "try", "disable"]).default("try") ).option( "--init", "Also write the default convex/README.md and convex/tsconfig.json, otherwise only written during convex init." ).addOption( new import_commander.Option( "--commonjs", "Generate CommonJS modules (CJS) instead of ECMAScript modules, the default. Bundlers typically take care of this conversion while bundling, so this setting is generally only useful for projects which do not use a bundler, typically Node.js projects. Convex functions can be written with either syntax." ).hideHelp() ).action(async (options) => { const ctx = import_context.oneoffContext; const { projectConfig, configPath } = await (0, import_config.readProjectConfig)(ctx); await (0, import_utils.ensureHasConvexDependency)(ctx, "codegen"); if (options.init) { await (0, import_codegen.doInitCodegen)( ctx, (0, import_utils.functionsDir)(configPath, projectConfig), false, options.dryRun, options.debug ); } if (options.typecheck !== "disable") { console.error( import_chalk.default.gray( "Running TypeScript typecheck, add --typecheck=disable to disable." ) ); } await (0, import_codegen.doCodegen)({ ctx, projectConfig, configPath, deploymentType: "dev", typeCheckMode: options.typecheck, dryRun: options.dryRun, debug: options.debug, commonjs: options.commonjs }); import_chalk.default.green("Codegen finished."); }); //# sourceMappingURL=codegen.js.map