@catladder/cli
Version:
Panter cli tool for cloud CI/CD and DevOps
39 lines • 1.61 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getProjectNamespace = exports.hasGitlabCiFile = exports.readRootGitlabCiFile = exports.getRootGitlabCiFile = exports.getGitRoot = void 0;
const path_1 = require("path");
const getProjectConfig_1 = require("../../config/getProjectConfig");
const files_1 = require("../files");
const child_process_promise_1 = require("child-process-promise");
const getGitRoot = async () => {
try {
return (await (0, child_process_promise_1.exec)(`git rev-parse --show-toplevel`)).stdout.trim();
}
catch (e) {
// not a git repo
return null;
}
};
exports.getGitRoot = getGitRoot;
const getRootGitlabCiFile = async () => {
const gitRoot = await (0, exports.getGitRoot)();
return (0, path_1.join)(gitRoot, ".gitlab-ci.yml");
};
exports.getRootGitlabCiFile = getRootGitlabCiFile;
const readRootGitlabCiFile = async () => (0, files_1.readFileOrError)(await (0, exports.getRootGitlabCiFile)());
exports.readRootGitlabCiFile = readRootGitlabCiFile;
const hasGitlabCiFile = async () => {
const [error, file] = await (0, exports.readRootGitlabCiFile)();
if (error) {
return false;
}
return true;
};
exports.hasGitlabCiFile = hasGitlabCiFile;
const getProjectNamespace = async (envComponent) => {
const { env } = (0, getProjectConfig_1.parseChoice)(envComponent);
const config = await (0, getProjectConfig_1.getProjectConfig)();
return `${config.customerName}-${config.appName}-${env}`;
};
exports.getProjectNamespace = getProjectNamespace;
//# sourceMappingURL=index.js.map