@catladder/cli
Version:
Panter cli tool for cloud CI/CD and DevOps
38 lines (37 loc) • 1.63 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createCustomDeployJobs = void 0;
const getAllCacheConfigsFromConfig_1 = require("../../build/cache/getAllCacheConfigsFromConfig");
const yarn_1 = require("../../build/node/yarn");
const runner_1 = require("../../runner");
const base_1 = require("../base");
const types_1 = require("../types");
const createCustomDeployJobs = async context => {
var _a, _b, _c;
const deployConfig = (_a = context.deploy) === null || _a === void 0 ? void 0 : _a.config;
if (!(0, types_1.isOfDeployType)(deployConfig, "custom")) {
// should not happen
throw new Error("deploy config is not custom");
}
// FIXME: custom deploy currently assumes yarn-based project
const yarnInstall = await (0, yarn_1.getYarnInstall)(context, {
noCustomPostInstall: true
});
const result = (0, base_1.createDeployementJobs)(context, {
deploy: {
image: (_b = deployConfig.jobImage) !== null && _b !== void 0 ? _b : (0, runner_1.getRunnerImage)("jobs-default"),
cache: (0, getAllCacheConfigsFromConfig_1.getAllCacheConfigsFromConfig)(context, deployConfig),
script: [`cd ${context.build.dir}`, ...(deployConfig.requiresYarnInstall ? yarnInstall : []), ...deployConfig.script],
variables: {}
},
stop: deployConfig.stopScript ? {
image: (_c = deployConfig.jobImage) !== null && _c !== void 0 ? _c : (0, runner_1.getRunnerImage)("jobs-default"),
script: [...deployConfig.stopScript],
variables: {}
} : undefined
});
return result;
};
exports.createCustomDeployJobs = createCustomDeployJobs;