@metacall/deploy
Version:
Tool for deploying into MetaCall FaaS platform.
40 lines (39 loc) • 1.98 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.plan = exports.planFetch = void 0;
const args_1 = __importDefault(require("./cli/args"));
const messages_1 = require("./cli/messages");
const selection_1 = require("./cli/selection");
const deploy_1 = require("./deploy");
// TODO: We should cache the plan and ask for it only once
const planFetch = async (api) => {
const availPlans = await api.listSubscriptions();
if (!Object.keys(availPlans).length) {
const deployedAppsCount = (await api.listSubscriptionsDeploys()).length;
if (!deployedAppsCount) {
(0, messages_1.info)('There are no active plans associated with your account. Please purchase a new plan at https://dashboard.metacall.io.');
return process.exit(deploy_1.ErrorCode.Ok);
}
else {
(0, messages_1.info)('Every plan on your account has apps installed on it. A new plan can be purchased at https://dashboard.metacall.io.');
(0, messages_1.warn)('Use the --force flag when wiring the preceding command if you still wished to deploy.');
(0, messages_1.warn)("Be aware that the application will only be deployed using --force flag if the application's directory, and plan all match.");
return process.exit(deploy_1.ErrorCode.Ok);
}
}
return availPlans;
};
exports.planFetch = planFetch;
const plan = async (api) => {
const availPlans = Object.keys(await (0, exports.planFetch)(api));
let plan = args_1.default['plan'] && availPlans.includes(args_1.default['plan']) && args_1.default['plan'];
plan =
plan || availPlans.length === 1
? availPlans[0]
: await (0, selection_1.planSelection)('Please select plan from the list', availPlans);
return plan;
};
exports.plan = plan;