UNPKG

convex

Version:

Client for the Convex Cloud

92 lines (91 loc) 3.48 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"), 1); 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( "--readme", "Also write the default convex/README.md, otherwise only written during convex init." ).option( "--tsconfig", "Also write the default convex/tsconfig.json, otherwise only written during convex init." ).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.readme) { (0, import_codegen.doReadmeCodegen)( ctx, (0, import_utils.functionsDir)(configPath, projectConfig), options.dryRun, options.debug ); } if (options.tsconfig) { (0, import_codegen.doTsconfigCodegen)( ctx, (0, import_utils.functionsDir)(configPath, projectConfig), (0, import_utils.convexPackageFromFunctions)(configPath, projectConfig), 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 }); import_chalk.default.green("Codegen finished."); }); //# sourceMappingURL=codegen.js.map