UNPKG

sanity

Version:

Sanity is a real-time content infrastructure with a scalable, hosted backend featuring a Graph Oriented Query Language (GROQ), asset pipelines and fast edge caches

53 lines (52 loc) 1.91 kB
"use strict"; var _internal = require("./_internal.js"), helpers = require("./helpers.js"); const debug = _internal.debug.extend("undeploy"); async function undeployAppAction(_, context) { const { apiClient, chalk, output, prompt, cliConfig } = context, client = apiClient({ requireUser: !0, requireProject: !1 }).withConfig({ apiVersion: "v2024-08-01" }); let spinner = output.spinner("Checking application info").start(); const appId = cliConfig && "app" in cliConfig ? cliConfig.app?.id : void 0; if (!appId) { spinner.fail(), output.print("No application ID provided."), output.print("Please set id in `app` in sanity.cli.js or sanity.cli.ts."), output.print("Nothing to undeploy."); return; } const userApplication = await helpers.getUserApplication({ client, appId }); if (spinner.succeed(), !userApplication) { spinner.fail(), output.print("Application with the given ID does not exist."), output.print("Nothing to undeploy."); return; } if (output.print(""), !!await prompt.single({ type: "confirm", default: !1, message: `This will undeploy ${chalk.yellow(userApplication.id)} and make it unavailable for your users. The hostname will be available for anyone to claim. Are you ${chalk.red("sure")} you want to undeploy?`.trim() })) { spinner = output.spinner("Undeploying application").start(); try { await helpers.deleteUserApplication({ client, applicationId: userApplication.id, appType: "coreApp" }), spinner.succeed(); } catch (err) { throw spinner.fail(), debug("Error undeploying application", err), err; } output.print(`Application undeploy scheduled. It might take a few minutes before ${chalk.yellow(userApplication.id)} is unavailable.`); } } exports.default = undeployAppAction; //# sourceMappingURL=undeployAction.js.map