@topgroup/diginext
Version:
A BUILD SERVER & CLI to deploy apps to any Kubernetes clusters.
55 lines (54 loc) • 2.45 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.deployWithReleaseSlug = exports.deployRelease = void 0;
const mongodb_1 = require("../../plugins/mongodb");
const deploy_build_v2_1 = require("./deploy-build-v2");
/**
* Deploy from a release (using V2 strategy)
*/
const deployRelease = async (release, options) => {
if (!release)
throw new Error(`[DEPLOY RELEASE] Release not found.`);
const { DB } = await Promise.resolve().then(() => __importStar(require("../../modules/api/DB")));
// find a build
const build = release.build._id
? release.build
: mongodb_1.MongoDB.isValidObjectId(release.build)
? await DB.findOne("build", { _id: release.build }, { ignorable: true })
: undefined;
if (!build)
throw new Error(`[DEPLOY RELEASE] Build not found.`);
return (0, deploy_build_v2_1.deployBuildV2)(build, options);
};
exports.deployRelease = deployRelease;
const deployWithReleaseSlug = async (releaseSlug, options) => {
const { DB } = await Promise.resolve().then(() => __importStar(require("../../modules/api/DB")));
const release = await DB.findOne("release", { slug: releaseSlug });
if (!release)
throw new Error(`[DEPLOY RELEASE] Release "${releaseSlug}" not found.`);
return (0, exports.deployRelease)(release, options);
};
exports.deployWithReleaseSlug = deployWithReleaseSlug;