convex
Version:
Client for the Convex Cloud
84 lines (83 loc) • 3.82 kB
JavaScript
;
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(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
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_extra_typings = require("@commander-js/extra-typings");
var import_chalk = __toESM(require("chalk"), 1);
var import_utils = require("./lib/utils.js");
var import_codegen = require("./lib/codegen.js");
var import_context = require("../bundler/context.js");
var import_config = require("./lib/config.js");
const codegen = new import_extra_typings.Command("codegen").summary("Generate backend type definitions").description(
"Generate types 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_extra_typings.Option("--debug").hideHelp()).addOption(
new import_extra_typings.Option(
"--typecheck <mode>",
`Whether to check TypeScript files with \`tsc --noEmit\`.`
).choices(["enable", "try", "disable"]).default("try")
).option(
"--init",
"Also (over-)write the default convex/README.md and convex/tsconfig.json files, otherwise only written when creating a new Convex project."
).addOption(
new import_extra_typings.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 functionsDirectoryPath = await (0, import_config.getFunctionsDirectoryPath)(ctx);
await (0, import_utils.ensureHasConvexDependency)(ctx, "codegen");
if (options.init) {
await (0, import_codegen.doInitCodegen)({
ctx,
functionsDirectoryPath,
dryRun: options.dryRun,
debug: options.debug,
overwrite: true
});
}
if (options.typecheck !== "disable") {
(0, import_context.logMessage)(ctx, import_chalk.default.gray("Running TypeScript typecheck\u2026"));
}
await (0, import_codegen.doCodegen)({
ctx,
functionsDirectoryPath,
typeCheckMode: options.typecheck,
dryRun: options.dryRun,
debug: options.debug,
generateCommonJSApi: options.commonjs
});
});
//# sourceMappingURL=codegen.js.map