convex
Version:
Client for the Convex Cloud
113 lines (112 loc) • 3.83 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(
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var reinit_exports = {};
__export(reinit_exports, {
reinit: () => reinit
});
module.exports = __toCommonJS(reinit_exports);
var import_chalk = __toESM(require("chalk"));
var import_ora = __toESM(require("ora"));
var import_commander = require("commander");
var import_api = require("./lib/api.js");
var import_utils = require("./lib/utils.js");
var import_config = require("./lib/config.js");
var import_context = require("./lib/context.js");
var import_codegen = require("./lib/codegen.js");
const reinit = new import_commander.Command("reinit").description(
"Reinitialize a Convex project in the local directory if you've lost your convex.json file"
).addOption(
new import_commander.Option(
"--team <team_slug>",
"The identifier of the team the project belongs to."
)
).addOption(
new import_commander.Option(
"--project <project_slug>",
"The identifier of the project you'd like to reinitialize."
)
).action(async (options) => {
const ctx = import_context.oneoffContext;
const configFn = (0, import_config.configName)();
if (ctx.fs.exists(configFn)) {
console.error(import_chalk.default.red(`File "${configFn}" already exists.`));
console.error(
"If you'd like to regenerate it, delete the file and rerun `npx convex reinit`"
);
return await ctx.fatalError(1, "fs");
}
const teamSlug = await (0, import_utils.validateOrSelectTeam)(
ctx,
options.team,
"Choose which team the project belongs to:"
);
const projectSlug = await (0, import_utils.validateOrSelectProject)(
ctx,
options.project,
teamSlug,
"Reinitialize project:",
"Choose which project to reinitialize:"
);
if (!projectSlug) {
console.log("Aborted");
return;
}
const spinner = ctx.spinner = (0, import_ora.default)({
text: `Reinitializing project ${projectSlug}...
`,
stream: process.stdout
}).start();
const { url, adminKey } = await (0, import_api.getUrlAndAdminKey)(
ctx,
projectSlug,
teamSlug,
"prod"
);
{
const { projectConfig: projectConfig2 } = await (0, import_config.pullConfig)(
ctx,
projectSlug,
teamSlug,
url,
adminKey
);
await (0, import_config.writeProjectConfig)(ctx, projectConfig2);
}
const { projectConfig, configPath } = await (0, import_config.readProjectConfig)(ctx);
await (0, import_codegen.doCodegen)({
ctx,
projectConfig,
configPath,
deploymentType: "dev",
typeCheckMode: "disable",
quiet: true
});
spinner.succeed(`Successfully reinitialized ${projectSlug}!`);
console.log(
"Configuration settings have been written to",
import_chalk.default.bold(configFn)
);
});
//# sourceMappingURL=reinit.js.map