@catladder/cli 0.0.0-refactor-cli-add-improved-git-utilities-fba867df → 0.0.0-refactor-remove-rails-hosts-afe04cf0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundles/catci/index.js +43322 -44345
- package/dist/bundles/catenv/index.js +27561 -43984
- package/dist/bundles/cli/index.js +81346 -97135
- package/dist/cli/src/apps/catenv/catenv.js +1 -1
- package/dist/cli/src/apps/catenv/catenv.js.map +1 -1
- package/dist/cli/src/apps/cli/commands/project/setup/setupAccessTokens.d.ts +1 -2
- package/dist/cli/src/apps/cli/commands/project/setup/setupAccessTokens.js +1 -3
- package/dist/cli/src/apps/cli/commands/project/setup/setupAccessTokens.js.map +1 -1
- package/dist/cli/src/apps/cli/commands/project/setup/setupCloudRun.js +2 -4
- package/dist/cli/src/apps/cli/commands/project/setup/setupCloudRun.js.map +1 -1
- package/dist/cli/src/apps/cli/commands/project/setup/setupKubernetes.d.ts +1 -2
- package/dist/cli/src/apps/cli/commands/project/setup/setupKubernetes.js +9 -23
- package/dist/cli/src/apps/cli/commands/project/setup/setupKubernetes.js.map +1 -1
- package/dist/cli/src/apps/cli/commands/project/setup/setupTopic.js +4 -6
- package/dist/cli/src/apps/cli/commands/project/setup/setupTopic.js.map +1 -1
- package/dist/cli/src/apps/cli/utils/getGoogleAuthUserNumber.d.ts +1 -1
- package/dist/cli/src/apps/cli/utils/getGoogleAuthUserNumber.js +4 -3
- package/dist/cli/src/apps/cli/utils/getGoogleAuthUserNumber.js.map +1 -1
- package/dist/cli/src/packageInfos.js +0 -1
- package/dist/cli/src/packageInfos.js.map +1 -1
- package/dist/cli/src/utils/gitlab.d.ts +7 -10
- package/dist/cli/src/utils/gitlab.js +45 -67
- package/dist/cli/src/utils/gitlab.js.map +1 -1
- package/dist/cli/src/utils/preferences/index.d.ts +3 -0
- package/dist/cli/src/utils/preferences/index.js +35 -0
- package/dist/cli/src/utils/preferences/index.js.map +1 -0
- package/dist/pipeline/src/build/cache/createJobCache.js +2 -2
- package/dist/pipeline/src/build/cache/createJobCache.js.map +1 -1
- package/dist/pipeline/src/build/sbom.js +2 -2
- package/dist/pipeline/src/build/sbom.js.map +1 -1
- package/dist/pipeline/src/build/types.d.ts +3 -3
- package/dist/pipeline/src/config/readConfig.js +0 -1
- package/dist/pipeline/src/config/readConfig.js.map +1 -1
- package/dist/pipeline/src/context/createComponentContext.js +1 -1
- package/dist/pipeline/src/context/createComponentContext.js.map +1 -1
- package/dist/pipeline/src/context/getEnvironmentVariables.d.ts +1 -1
- package/dist/pipeline/src/context/getEnvironmentVariables.js +1 -5
- package/dist/pipeline/src/context/getEnvironmentVariables.js.map +1 -1
- package/dist/pipeline/src/deploy/base/deploy.js +3 -3
- package/dist/pipeline/src/deploy/base/deploy.js.map +1 -1
- package/dist/pipeline/src/deploy/cloudRun/createJobs/cloudRunServices.js +1 -1
- package/dist/pipeline/src/deploy/cloudRun/createJobs/cloudRunServices.js.map +1 -1
- package/dist/pipeline/src/deploy/types/index.d.ts +3 -3
- package/dist/pipeline/src/pipeline/createMainPipeline.js +13 -7
- package/dist/pipeline/src/pipeline/createMainPipeline.js.map +1 -1
- package/dist/pipeline/src/pipeline/generatePipelineFiles.d.ts +7 -40
- package/dist/pipeline/src/pipeline/generatePipelineFiles.js +69 -42
- package/dist/pipeline/src/pipeline/generatePipelineFiles.js.map +1 -1
- package/dist/pipeline/src/pipeline/gitlab/createGitlabJobs.d.ts +6 -4
- package/dist/pipeline/src/pipeline/gitlab/gitlabReleaseJobs.d.ts +0 -2
- package/dist/pipeline/src/pipeline/gitlab/gitlabReleaseJobs.js +2 -4
- package/dist/pipeline/src/pipeline/gitlab/gitlabReleaseJobs.js.map +1 -1
- package/dist/pipeline/src/pipeline/index.d.ts +0 -1
- package/dist/pipeline/src/pipeline/index.js +0 -1
- package/dist/pipeline/src/pipeline/index.js.map +1 -1
- package/dist/pipeline/src/types/config.d.ts +3 -3
- package/dist/pipeline/src/types/gitlab-types.d.ts +2 -1
- package/dist/pipeline/src/types/pipeline.d.ts +0 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +14 -13
- package/src/apps/catenv/catenv.ts +1 -1
- package/src/apps/cli/commands/project/setup/setupAccessTokens.ts +1 -11
- package/src/apps/cli/commands/project/setup/setupCloudRun.ts +2 -4
- package/src/apps/cli/commands/project/setup/setupKubernetes.ts +27 -30
- package/src/apps/cli/commands/project/setup/setupTopic.ts +11 -6
- package/src/apps/cli/utils/getGoogleAuthUserNumber.ts +4 -6
- package/src/packageInfos.ts +0 -1
- package/src/utils/gitlab.ts +101 -99
- package/src/utils/preferences/index.ts +36 -0
- package/dist/cli/src/git/getGitConfigVars.d.ts +0 -4
- package/dist/cli/src/git/getGitConfigVars.js +0 -14
- package/dist/cli/src/git/getGitConfigVars.js.map +0 -1
- package/dist/cli/src/git/getGitRemoteHostAndPath.d.ts +0 -9
- package/dist/cli/src/git/getGitRemoteHostAndPath.js +0 -23
- package/dist/cli/src/git/getGitRemoteHostAndPath.js.map +0 -1
- package/dist/cli/src/git/getProjectRootPath.d.ts +0 -1
- package/dist/cli/src/git/getProjectRootPath.js +0 -10
- package/dist/cli/src/git/getProjectRootPath.js.map +0 -1
- package/dist/cli/src/git/gitConfig.d.ts +0 -23
- package/dist/cli/src/git/gitConfig.js +0 -60
- package/dist/cli/src/git/gitConfig.js.map +0 -1
- package/dist/cli/src/git/index.d.ts +0 -4
- package/dist/cli/src/git/index.js +0 -21
- package/dist/cli/src/git/index.js.map +0 -1
- package/dist/cli/src/gitlab/apiClient.d.ts +0 -5
- package/dist/cli/src/gitlab/apiClient.js +0 -21
- package/dist/cli/src/gitlab/apiClient.js.map +0 -1
- package/dist/cli/src/gitlab/getGitlabProjectId.d.ts +0 -4
- package/dist/cli/src/gitlab/getGitlabProjectId.js +0 -29
- package/dist/cli/src/gitlab/getGitlabProjectId.js.map +0 -1
- package/dist/cli/src/gitlab/gitlabToken.d.ts +0 -10
- package/dist/cli/src/gitlab/gitlabToken.js +0 -42
- package/dist/cli/src/gitlab/gitlabToken.js.map +0 -1
- package/dist/cli/src/gitlab/index.d.ts +0 -3
- package/dist/cli/src/gitlab/index.js +0 -20
- package/dist/cli/src/gitlab/index.js.map +0 -1
- package/dist/cli/src/utils/preferences.d.ts +0 -15
- package/dist/cli/src/utils/preferences.js +0 -61
- package/dist/cli/src/utils/preferences.js.map +0 -1
- package/dist/cli/src/utils/projectPreferences.d.ts +0 -5
- package/dist/cli/src/utils/projectPreferences.js +0 -54
- package/dist/cli/src/utils/projectPreferences.js.map +0 -1
- package/dist/pipeline/src/pipeline/createChildPipeline.d.ts +0 -3
- package/dist/pipeline/src/pipeline/createChildPipeline.js +0 -30
- package/dist/pipeline/src/pipeline/createChildPipeline.js.map +0 -1
- package/dist/pipeline/src/pipeline/gitlab/getPipelineTriggerForGitlabChildPipeline.d.ts +0 -1
- package/dist/pipeline/src/pipeline/gitlab/getPipelineTriggerForGitlabChildPipeline.js +0 -32
- package/dist/pipeline/src/pipeline/gitlab/getPipelineTriggerForGitlabChildPipeline.js.map +0 -1
- package/src/git/getGitConfigVars.ts +0 -11
- package/src/git/getGitRemoteHostAndPath.ts +0 -28
- package/src/git/getProjectRootPath.ts +0 -6
- package/src/git/gitConfig.ts +0 -86
- package/src/git/index.ts +0 -4
- package/src/gitlab/apiClient.ts +0 -23
- package/src/gitlab/getGitlabProjectId.ts +0 -32
- package/src/gitlab/gitlabToken.ts +0 -52
- package/src/gitlab/index.ts +0 -3
- package/src/utils/preferences.ts +0 -85
- package/src/utils/projectPreferences.ts +0 -78
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getProjectRootPath = void 0;
|
|
4
|
-
const child_process_promise_1 = require("child-process-promise");
|
|
5
|
-
async function getProjectRootPath() {
|
|
6
|
-
const execResult = await (0, child_process_promise_1.exec)(`git rev-parse --show-toplevel`);
|
|
7
|
-
return execResult.stdout.trim();
|
|
8
|
-
}
|
|
9
|
-
exports.getProjectRootPath = getProjectRootPath;
|
|
10
|
-
//# sourceMappingURL=getProjectRootPath.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getProjectRootPath.js","sourceRoot":"","sources":["../../../../src/git/getProjectRootPath.ts"],"names":[],"mappings":";;;AAAA,iEAA6C;AAEtC,KAAK,UAAU,kBAAkB;IACtC,MAAM,UAAU,GAAG,MAAM,IAAA,4BAAI,EAAC,+BAA+B,CAAC,CAAC;IAC/D,OAAO,UAAU,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;AAClC,CAAC;AAHD,gDAGC"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
declare const scopes: readonly ["global", "local", "system", "worktree"];
|
|
2
|
-
type LocationScope = (typeof scopes)[number];
|
|
3
|
-
type LocationOption = {
|
|
4
|
-
location?: LocationScope;
|
|
5
|
-
};
|
|
6
|
-
export declare function gitConfigGet(key: string, options?: LocationOption): Promise<string>;
|
|
7
|
-
type CommentOption = {
|
|
8
|
-
comment?: string;
|
|
9
|
-
};
|
|
10
|
-
export declare function gitConfigSet(key: string, value: string, options?: LocationOption & CommentOption): Promise<{
|
|
11
|
-
stdout: string;
|
|
12
|
-
}>;
|
|
13
|
-
type ByScope = {
|
|
14
|
-
[scope in LocationScope]?: Record<string, string>;
|
|
15
|
-
};
|
|
16
|
-
export declare function gitConfigList({ byScope, location, }?: {
|
|
17
|
-
/**
|
|
18
|
-
* Returns the config values by location scope.
|
|
19
|
-
* Only has an effect if the location is set.
|
|
20
|
-
*/
|
|
21
|
-
byScope?: boolean;
|
|
22
|
-
} & LocationOption): Promise<Record<string, string> | ByScope>;
|
|
23
|
-
export {};
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.gitConfigList = exports.gitConfigSet = exports.gitConfigGet = void 0;
|
|
4
|
-
const child_process_promise_1 = require("child-process-promise");
|
|
5
|
-
const scopes = ["global", "local", "system", "worktree"];
|
|
6
|
-
async function gitConfigGet(key, options = {}) {
|
|
7
|
-
const optArgs = [options.location ? `--${options.location}` : undefined]
|
|
8
|
-
.filter(Boolean)
|
|
9
|
-
.join(" ");
|
|
10
|
-
const execResult = await (0, child_process_promise_1.exec)(`git config get ${optArgs} ${key}`);
|
|
11
|
-
return execResult.stdout.trim();
|
|
12
|
-
}
|
|
13
|
-
exports.gitConfigGet = gitConfigGet;
|
|
14
|
-
function gitConfigSet(key, value, options = {}) {
|
|
15
|
-
const optArgs = [
|
|
16
|
-
options.location ? `--${options.location}` : undefined,
|
|
17
|
-
options.comment ? `--comment=${options.comment}` : undefined,
|
|
18
|
-
]
|
|
19
|
-
.filter(Boolean)
|
|
20
|
-
.join(" ");
|
|
21
|
-
return (0, child_process_promise_1.exec)(`git config set ${optArgs} ${key} ${value}`);
|
|
22
|
-
}
|
|
23
|
-
exports.gitConfigSet = gitConfigSet;
|
|
24
|
-
const reduceScopelessConfigList = (configList) => configList.reduce((acc, line) => {
|
|
25
|
-
const [key, value] = line.split("=");
|
|
26
|
-
if (!(key === null || key === void 0 ? void 0 : key.length)) {
|
|
27
|
-
return acc;
|
|
28
|
-
}
|
|
29
|
-
return { ...acc, [key]: value };
|
|
30
|
-
}, {});
|
|
31
|
-
const reduceScopedConfigList = (configList) => configList.reduce((acc, line) => {
|
|
32
|
-
const [scopeSplit, key_val] = line.split("\t");
|
|
33
|
-
const scope = scopeSplit.trim();
|
|
34
|
-
if (!(key_val === null || key_val === void 0 ? void 0 : key_val.length) || !(scope === null || scope === void 0 ? void 0 : scope.length)) {
|
|
35
|
-
return acc;
|
|
36
|
-
}
|
|
37
|
-
const [key, value] = key_val.split("=");
|
|
38
|
-
if (!(key === null || key === void 0 ? void 0 : key.length)) {
|
|
39
|
-
return acc;
|
|
40
|
-
}
|
|
41
|
-
acc[scope] = acc[scope] || {};
|
|
42
|
-
acc[scope][key] = value;
|
|
43
|
-
return acc;
|
|
44
|
-
}, {});
|
|
45
|
-
async function gitConfigList({ byScope = false, location, } = {}) {
|
|
46
|
-
const showScope = !location && byScope;
|
|
47
|
-
const optArgs = [
|
|
48
|
-
location ? `--${location}` : undefined,
|
|
49
|
-
showScope ? "--show-scope" : undefined,
|
|
50
|
-
]
|
|
51
|
-
.filter(Boolean)
|
|
52
|
-
.join(" ");
|
|
53
|
-
const configListOutput = await (0, child_process_promise_1.exec)(`git config list ${optArgs}`);
|
|
54
|
-
const configList = configListOutput.stdout.trim().split("\n");
|
|
55
|
-
return showScope
|
|
56
|
-
? reduceScopedConfigList(configList)
|
|
57
|
-
: reduceScopelessConfigList(configList);
|
|
58
|
-
}
|
|
59
|
-
exports.gitConfigList = gitConfigList;
|
|
60
|
-
//# sourceMappingURL=gitConfig.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"gitConfig.js","sourceRoot":"","sources":["../../../../src/git/gitConfig.ts"],"names":[],"mappings":";;;AAAA,iEAA6C;AAE7C,MAAM,MAAM,GAAG,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,CAAU,CAAC;AAO3D,KAAK,UAAU,YAAY,CAAC,GAAW,EAAE,UAA0B,EAAE;IAC1E,MAAM,OAAO,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;SACrE,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,GAAG,CAAC,CAAC;IACb,MAAM,UAAU,GAAG,MAAM,IAAA,4BAAI,EAAC,kBAAkB,OAAO,IAAI,GAAG,EAAE,CAAC,CAAC;IAClE,OAAO,UAAU,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;AAClC,CAAC;AAND,oCAMC;AAID,SAAgB,YAAY,CAC1B,GAAW,EACX,KAAa,EACb,UAA0C,EA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inding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./getGitConfigVars"), exports);
|
|
18
|
-
__exportStar(require("./getGitRemoteHostAndPath"), exports);
|
|
19
|
-
__exportStar(require("./getProjectRootPath"), exports);
|
|
20
|
-
__exportStar(require("./gitConfig"), exports);
|
|
21
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/git/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,4DAA0C;AAC1C,uDAAqC;AACrC,8CAA4B"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.gitlabApiClient = void 0;
|
|
4
|
-
const rest_1 = require("@gitbeaker/rest");
|
|
5
|
-
const gitlabToken_1 = require("./gitlabToken");
|
|
6
|
-
const gitlabApiClient = async ({ gitlabHost, } = {}) => {
|
|
7
|
-
const { token, gitRemoteHost } = await (0, gitlabToken_1.getGitlabToken)(gitlabHost);
|
|
8
|
-
if (typeof token !== "string") {
|
|
9
|
-
throw new Error("Gitlab personal access token is missing!");
|
|
10
|
-
}
|
|
11
|
-
if (!gitRemoteHost) {
|
|
12
|
-
throw new Error("no gitlab host found");
|
|
13
|
-
}
|
|
14
|
-
return new rest_1.Gitlab({
|
|
15
|
-
token,
|
|
16
|
-
host: `https://${gitRemoteHost}`,
|
|
17
|
-
camelize: false,
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
exports.gitlabApiClient = gitlabApiClient;
|
|
21
|
-
//# sourceMappingURL=apiClient.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"apiClient.js","sourceRoot":"","sources":["../../../../src/gitlab/apiClient.ts"],"names":[],"mappings":";;;AAAA,0CAAyC;AACzC,+CAA+C;AAIxC,MAAM,eAAe,GAAG,KAAK,EAAE,EACpC,UAAU,MAGR,EAAE,EAA6B,EAAE;IACnC,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,GAAG,MAAM,IAAA,4BAAc,EAAC,UAAU,CAAC,CAAC;IAClE,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC9D,CAAC;IACD,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,IAAI,aAAM,CAAC;QAChB,KAAK;QACL,IAAI,EAAE,WAAW,aAAa,EAAE;QAChC,QAAQ,EAAE,KAAK;KAChB,CAAC,CAAC;AACL,CAAC,CAAC;AAjBW,QAAA,eAAe,mBAiB1B"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { ProjectSchema } from "@gitbeaker/rest";
|
|
2
|
-
import type { GitlabRestClient } from "./apiClient";
|
|
3
|
-
export declare const getGitlabProjectInfo: (existingInstance?: GitlabRestClient) => Promise<ProjectSchema>;
|
|
4
|
-
export declare const getGitlabProjectId: () => Promise<number>;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getGitlabProjectId = exports.getGitlabProjectInfo = void 0;
|
|
4
|
-
const getGitRemoteHostAndPath_1 = require("../git/getGitRemoteHostAndPath");
|
|
5
|
-
const apiClient_1 = require("./apiClient");
|
|
6
|
-
const projectPreferences_1 = require("../utils/projectPreferences");
|
|
7
|
-
const getGitlabProjectInfo = async (existingInstance) => {
|
|
8
|
-
const api = existingInstance !== null && existingInstance !== void 0 ? existingInstance : (await (0, apiClient_1.gitlabApiClient)());
|
|
9
|
-
const { gitRemotePath } = await (0, getGitRemoteHostAndPath_1.getGitRemoteHostAndPath)();
|
|
10
|
-
const projectInfo = await api.Projects.show(gitRemotePath, {
|
|
11
|
-
statistics: false,
|
|
12
|
-
withCustomAttributes: false,
|
|
13
|
-
license: false,
|
|
14
|
-
});
|
|
15
|
-
// write unawaited intentionally
|
|
16
|
-
(0, projectPreferences_1.upsertProjectPerferences)({ gitlabProjectId: projectInfo.id });
|
|
17
|
-
return projectInfo;
|
|
18
|
-
};
|
|
19
|
-
exports.getGitlabProjectInfo = getGitlabProjectInfo;
|
|
20
|
-
const getGitlabProjectId = async () => {
|
|
21
|
-
const { gitlabProjectId } = await (0, projectPreferences_1.getProjectPreferences)();
|
|
22
|
-
if (gitlabProjectId) {
|
|
23
|
-
return gitlabProjectId;
|
|
24
|
-
}
|
|
25
|
-
const projectInfo = await (0, exports.getGitlabProjectInfo)();
|
|
26
|
-
return projectInfo.id;
|
|
27
|
-
};
|
|
28
|
-
exports.getGitlabProjectId = getGitlabProjectId;
|
|
29
|
-
//# sourceMappingURL=getGitlabProjectId.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getGitlabProjectId.js","sourceRoot":"","sources":["../../../../src/gitlab/getGitlabProjectId.ts"],"names":[],"mappings":";;;AACA,4EAAyE;AAEzE,2CAA8C;AAC9C,oEAGqC;AAE9B,MAAM,oBAAoB,GAAG,KAAK,EACvC,gBAAmC,EACX,EAAE;IAC1B,MAAM,GAAG,GAAG,gBAAgB,aAAhB,gBAAgB,cAAhB,gBAAgB,GAAI,CAAC,MAAM,IAAA,2BAAe,GAAE,CAAC,CAAC;IAC1D,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,IAAA,iDAAuB,GAAE,CAAC;IAC1D,MAAM,WAAW,GAAG,MAAM,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,aAAa,EAAE;QACzD,UAAU,EAAE,KAAK;QACjB,oBAAoB,EAAE,KAAK;QAC3B,OAAO,EAAE,KAAK;KACf,CAAC,CAAC;IACH,gCAAgC;IAChC,IAAA,6CAAwB,EAAC,EAAE,eAAe,EAAE,WAAW,CAAC,EAAE,EAAE,CAAC,CAAC;IAC9D,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC;AAbW,QAAA,oBAAoB,wBAa/B;AAEK,MAAM,kBAAkB,GAAG,KAAK,IAAqB,EAAE;IAC5D,MAAM,EAAE,eAAe,EAAE,GAAG,MAAM,IAAA,0CAAqB,GAAE,CAAC;IAC1D,IAAI,eAAe,EAAE,CAAC;QACpB,OAAO,eAAe,CAAC;IACzB,CAAC;IACD,MAAM,WAAW,GAAG,MAAM,IAAA,4BAAoB,GAAE,CAAC;IACjD,OAAO,WAAW,CAAC,EAAE,CAAC;AACxB,CAAC,CAAC;AAPW,QAAA,kBAAkB,sBAO7B"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare function getGitlabToken(hostname?: string): Promise<{
|
|
2
|
-
token: string;
|
|
3
|
-
gitRemoteHost: string;
|
|
4
|
-
}>;
|
|
5
|
-
export declare function setGitlabToken(token: string, { hostname, currentTokens, }?: {
|
|
6
|
-
hostname?: string;
|
|
7
|
-
currentTokens?: {
|
|
8
|
-
[host in string]?: string;
|
|
9
|
-
};
|
|
10
|
-
}): Promise<string>;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setGitlabToken = exports.getGitlabToken = void 0;
|
|
4
|
-
const git_1 = require("../git");
|
|
5
|
-
const preferences_1 = require("../utils/preferences");
|
|
6
|
-
async function getGitlabToken(hostname) {
|
|
7
|
-
var _a, _b, _c, _d;
|
|
8
|
-
const [{ gitRemoteHost }, preferences] = await Promise.all([
|
|
9
|
-
(hostname === null || hostname === void 0 ? void 0 : hostname.length)
|
|
10
|
-
? Promise.resolve({ gitRemoteHost: hostname })
|
|
11
|
-
: (0, git_1.getGitRemoteHostAndPath)(),
|
|
12
|
-
(0, preferences_1.getPreferences)(),
|
|
13
|
-
]);
|
|
14
|
-
const gitlabTokens = (_a = preferences.gitlabTokens) !== null && _a !== void 0 ? _a : {};
|
|
15
|
-
const currentPerferencesToken = gitlabTokens[gitRemoteHost];
|
|
16
|
-
const token = (_b = currentPerferencesToken !== null && currentPerferencesToken !== void 0 ? currentPerferencesToken : preferences["gitlab-personal-access-token"]) !== null && _b !== void 0 ? _b : process.env.GITLAB_TOKEN;
|
|
17
|
-
if ((((_c = preferences["gitlab-personal-access-token"]) === null || _c === void 0 ? void 0 : _c.length) ||
|
|
18
|
-
((_d = process.env.GITLAB_TOKEN) === null || _d === void 0 ? void 0 : _d.length)) &&
|
|
19
|
-
!(currentPerferencesToken === null || currentPerferencesToken === void 0 ? void 0 : currentPerferencesToken.length)) {
|
|
20
|
-
await setGitlabToken(token, {
|
|
21
|
-
hostname: gitRemoteHost,
|
|
22
|
-
currentTokens: gitlabTokens,
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
return { token, gitRemoteHost };
|
|
26
|
-
}
|
|
27
|
-
exports.getGitlabToken = getGitlabToken;
|
|
28
|
-
async function setGitlabToken(token, { hostname, currentTokens, } = {}) {
|
|
29
|
-
const [{ gitRemoteHost }, storedTokens] = await Promise.all([
|
|
30
|
-
(hostname === null || hostname === void 0 ? void 0 : hostname.length)
|
|
31
|
-
? Promise.resolve({ gitRemoteHost: hostname })
|
|
32
|
-
: (0, git_1.getGitRemoteHostAndPath)(),
|
|
33
|
-
currentTokens
|
|
34
|
-
? Promise.resolve(currentTokens)
|
|
35
|
-
: (0, preferences_1.getPreference)("gitlabTokens"),
|
|
36
|
-
]);
|
|
37
|
-
const gitlabTokens = { ...(storedTokens !== null && storedTokens !== void 0 ? storedTokens : {}), [gitRemoteHost]: token };
|
|
38
|
-
await (0, preferences_1.setPreference)("gitlabTokens", gitlabTokens);
|
|
39
|
-
return gitlabTokens[gitRemoteHost];
|
|
40
|
-
}
|
|
41
|
-
exports.setGitlabToken = setGitlabToken;
|
|
42
|
-
//# sourceMappingURL=gitlabToken.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"gitlabToken.js","sourceRoot":"","sources":["../../../../src/gitlab/gitlabToken.ts"],"names":[],"mappings":";;;AAAA,gCAAiD;AACjD,sDAI8B;AAEvB,KAAK,UAAU,cAAc,CAAC,QAAiB;;IACpD,MAAM,CAAC,EAAE,aAAa,EAAE,EAAE,WAAW,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QACzD,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,MAAM;YACd,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAC;YAC9C,CAAC,CAAC,IAAA,6BAAuB,GAAE;QAC7B,IAAA,4BAAc,GAAE;KACjB,CAAC,CAAC;IACH,MAAM,YAAY,GAAG,MAAA,WAAW,CAAC,YAAY,mCAAI,EAAE,CAAC;IACpD,MAAM,uBAAuB,GAAG,YAAY,CAAC,aAAa,CAAC,CAAC;IAC5D,MAAM,KAAK,GACT,MAAA,uBAAuB,aAAvB,uBAAuB,cAAvB,uBAAuB,GACvB,WAAW,CAAC,8BAA8B,CAAC,mCAC3C,OAAO,CAAC,GAAG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";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./apiClient"), exports);
|
|
18
|
-
__exportStar(require("./getGitlabProjectId"), exports);
|
|
19
|
-
__exportStar(require("./gitlabToken"), exports);
|
|
20
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/gitlab/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,uDAAqC;AACrC,gDAA8B"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export type CatladderCliPreferences = {
|
|
2
|
-
"gitlab-personal-access-token": string | null;
|
|
3
|
-
googleAuthUserNumber: number | null;
|
|
4
|
-
gitlabTokens: {
|
|
5
|
-
[hostname in string]?: string;
|
|
6
|
-
};
|
|
7
|
-
};
|
|
8
|
-
type PreferenceKey = keyof CatladderCliPreferences;
|
|
9
|
-
export declare const getPreferences: () => Promise<CatladderCliPreferences>;
|
|
10
|
-
export declare const hasPreference: (key: PreferenceKey) => Promise<boolean>;
|
|
11
|
-
export declare const getPreference: <K extends keyof CatladderCliPreferences>(key: K) => Promise<CatladderCliPreferences[K] | null>;
|
|
12
|
-
export declare const setPreference: (key: PreferenceKey, value: string | number | {
|
|
13
|
-
[x: string]: string;
|
|
14
|
-
}) => Promise<void>;
|
|
15
|
-
export {};
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setPreference = exports.getPreference = exports.hasPreference = exports.getPreferences = void 0;
|
|
4
|
-
const promises_1 = require("fs/promises");
|
|
5
|
-
const fs_1 = require("fs");
|
|
6
|
-
const os_1 = require("os");
|
|
7
|
-
const yaml_1 = require("yaml");
|
|
8
|
-
const path_1 = require("path");
|
|
9
|
-
const directory = (0, path_1.join)((0, os_1.homedir)(), ".catladder");
|
|
10
|
-
const file = (0, path_1.join)(directory, "preferences.yml");
|
|
11
|
-
const perfKeys = [
|
|
12
|
-
"gitlab-personal-access-token",
|
|
13
|
-
"googleAuthUserNumber",
|
|
14
|
-
"gitlabTokens",
|
|
15
|
-
];
|
|
16
|
-
const fallbackValues = {
|
|
17
|
-
"gitlab-personal-access-token": null,
|
|
18
|
-
gitlabTokens: {},
|
|
19
|
-
googleAuthUserNumber: null,
|
|
20
|
-
};
|
|
21
|
-
const perferencesWithParsed = (parsed) => perfKeys.reduce((acc, key) => { var _a; return Object.assign(acc, { [key]: (_a = parsed[key]) !== null && _a !== void 0 ? _a : fallbackValues[key] }); }, {});
|
|
22
|
-
const encoding = "utf-8";
|
|
23
|
-
const readPreferences = () => (0, promises_1.readFile)(file, { encoding });
|
|
24
|
-
const writePreferences = (preferences) => (0, promises_1.writeFile)(file, (0, yaml_1.stringify)(preferences), { encoding, mode: 0o600 });
|
|
25
|
-
const ensureDir = async () => (0, fs_1.existsSync)(directory)
|
|
26
|
-
? directory
|
|
27
|
-
: (0, promises_1.mkdir)(directory, { recursive: true, mode: 0o700 });
|
|
28
|
-
const ensureFile = async () => {
|
|
29
|
-
if ((0, fs_1.existsSync)(file)) {
|
|
30
|
-
return file;
|
|
31
|
-
}
|
|
32
|
-
await ensureDir();
|
|
33
|
-
return writePreferences(perferencesWithParsed({}));
|
|
34
|
-
};
|
|
35
|
-
const getPreferences = async () => {
|
|
36
|
-
var _a;
|
|
37
|
-
await ensureFile();
|
|
38
|
-
const fileString = await readPreferences();
|
|
39
|
-
const fileParsed = (_a = (0, yaml_1.parse)(fileString || "---\nnull")) !== null && _a !== void 0 ? _a : {};
|
|
40
|
-
return perferencesWithParsed(fileParsed);
|
|
41
|
-
};
|
|
42
|
-
exports.getPreferences = getPreferences;
|
|
43
|
-
const hasPreference = async (key) => {
|
|
44
|
-
const preferences = await (0, exports.getPreferences)();
|
|
45
|
-
return preferences[key] !== null && preferences[key] !== undefined;
|
|
46
|
-
};
|
|
47
|
-
exports.hasPreference = hasPreference;
|
|
48
|
-
const getPreference = async (key) => {
|
|
49
|
-
const preferences = await (0, exports.getPreferences)();
|
|
50
|
-
if (key in preferences) {
|
|
51
|
-
return preferences[key];
|
|
52
|
-
}
|
|
53
|
-
return null;
|
|
54
|
-
};
|
|
55
|
-
exports.getPreference = getPreference;
|
|
56
|
-
const setPreference = async (key, value) => {
|
|
57
|
-
const preferences = await (0, exports.getPreferences)();
|
|
58
|
-
return writePreferences({ ...preferences, [key]: value });
|
|
59
|
-
};
|
|
60
|
-
exports.setPreference = setPreference;
|
|
61
|
-
//# sourceMappingURL=preferences.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"preferences.js","sourceRoot":"","sources":["../../../../src/utils/preferences.ts"],"names":[],"mappings":";;;AAAA,0CAAyD;AACzD,2BAAgC;AAChC,2BAA6B;AAC7B,+BAAwC;AACxC,+BAA4B;AAE5B,MAAM,SAAS,GAAG,IAAA,WAAI,EAAC,IAAA,YAAO,GAAE,EAAE,YAAY,CAAC,CAAC;AAChD,MAAM,IAAI,GAAG,IAAA,WAAI,EAAC,SAAS,EAA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ladderCliProjectPreferences = {
|
|
2
|
-
gitlabProjectId?: number | null;
|
|
3
|
-
};
|
|
4
|
-
export declare const getProjectPreferences: (givenFilePath?: string) => Promise<CatladderCliProjectPreferences>;
|
|
5
|
-
export declare const upsertProjectPerferences: (newPerfs?: Partial<CatladderCliProjectPreferences>, givenFilePath?: string) => Promise<void>;
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.upsertProjectPerferences = exports.getProjectPreferences = void 0;
|
|
4
|
-
const promises_1 = require("fs/promises");
|
|
5
|
-
const fs_1 = require("fs");
|
|
6
|
-
const path_1 = require("path");
|
|
7
|
-
const git_1 = require("../git");
|
|
8
|
-
const directory = ".catladder";
|
|
9
|
-
const file = "preferences.json";
|
|
10
|
-
const perfKeys = [
|
|
11
|
-
"gitlabProjectId",
|
|
12
|
-
];
|
|
13
|
-
const fallbackValues = {
|
|
14
|
-
gitlabProjectId: null,
|
|
15
|
-
};
|
|
16
|
-
const perferencesWithParsed = (parsed) => perfKeys.reduce((acc, key) => { var _a, _b; return Object.assign(acc, { [key]: (_b = (_a = parsed[key]) !== null && _a !== void 0 ? _a : fallbackValues[key]) !== null && _b !== void 0 ? _b : null }); }, {});
|
|
17
|
-
const encoding = "utf-8";
|
|
18
|
-
const readPreferences = (filePath) => (0, promises_1.readFile)(filePath, { encoding });
|
|
19
|
-
const writePreferences = (filePath, preferences) => (0, promises_1.writeFile)(filePath, JSON.stringify(preferences, null, 2), {
|
|
20
|
-
encoding,
|
|
21
|
-
mode: 0o600,
|
|
22
|
-
});
|
|
23
|
-
const ensureDir = async (dirPath) => (0, fs_1.existsSync)(dirPath)
|
|
24
|
-
? dirPath
|
|
25
|
-
: (0, promises_1.mkdir)(dirPath, { recursive: true, mode: 0o700 });
|
|
26
|
-
const ensureFile = async (givenFilePath) => {
|
|
27
|
-
if ((givenFilePath === null || givenFilePath === void 0 ? void 0 : givenFilePath.length) && (0, fs_1.existsSync)(givenFilePath)) {
|
|
28
|
-
return givenFilePath;
|
|
29
|
-
}
|
|
30
|
-
const rootPath = await (0, git_1.getProjectRootPath)();
|
|
31
|
-
const dirPath = (0, path_1.join)(rootPath, directory);
|
|
32
|
-
const filePath = (0, path_1.join)(dirPath, file);
|
|
33
|
-
if ((0, fs_1.existsSync)(filePath)) {
|
|
34
|
-
return filePath;
|
|
35
|
-
}
|
|
36
|
-
await ensureDir(dirPath);
|
|
37
|
-
await writePreferences(filePath, perferencesWithParsed({}));
|
|
38
|
-
return filePath;
|
|
39
|
-
};
|
|
40
|
-
const getProjectPreferences = async (givenFilePath) => {
|
|
41
|
-
var _a;
|
|
42
|
-
const filePath = await ensureFile(givenFilePath);
|
|
43
|
-
const fileString = await readPreferences(filePath);
|
|
44
|
-
const fileParsed = (_a = JSON.parse(fileString || "null")) !== null && _a !== void 0 ? _a : {};
|
|
45
|
-
return perferencesWithParsed(fileParsed);
|
|
46
|
-
};
|
|
47
|
-
exports.getProjectPreferences = getProjectPreferences;
|
|
48
|
-
const upsertProjectPerferences = async (newPerfs = {}, givenFilePath) => {
|
|
49
|
-
const filePath = await ensureFile(givenFilePath);
|
|
50
|
-
const currentPerfs = await (0, exports.getProjectPreferences)(filePath);
|
|
51
|
-
return writePreferences(filePath, { ...currentPerfs, ...newPerfs });
|
|
52
|
-
};
|
|
53
|
-
exports.upsertProjectPerferences = upsertProjectPerferences;
|
|
54
|
-
//# sourceMappingURL=projectPreferences.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"projectPreferences.js","sourceRoot":"","sources":["../../../../src/utils/projectPreferences.ts"],"names":[],"mappings":";;;AAAA,0CAAyD;AACzD,2BAAgC;AAChC,+BAA4B;AAC5B,gCAA4C;AAE5C,MAAM,SAAS,GAAG,YAAY,CAAC;AAC/B,MAAM,IAAI,GAAG,kBAAkB,CAAC;AAMhC,MAAM,QAAQ,GAAG;IACf,iBAAiB;CACiC,CAAC;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ports, "__esModule", { value: true });
|
|
3
|
-
exports.createChildPipeline = void 0;
|
|
4
|
-
const rules_1 = require("../rules");
|
|
5
|
-
const createAllJobs_1 = require("./createAllJobs");
|
|
6
|
-
const getPipelineStages_1 = require("./getPipelineStages");
|
|
7
|
-
const createGitlabJobs_1 = require("./gitlab/createGitlabJobs");
|
|
8
|
-
const createGitlabPipeline_1 = require("./gitlab/createGitlabPipeline");
|
|
9
|
-
const createChildPipeline = async (pipelineType, trigger, config) => {
|
|
10
|
-
const jobs = await (0, createAllJobs_1.createAllJobs)({
|
|
11
|
-
config,
|
|
12
|
-
trigger,
|
|
13
|
-
pipelineType,
|
|
14
|
-
});
|
|
15
|
-
const stages = (0, getPipelineStages_1.getPipelineStages)(config);
|
|
16
|
-
if (pipelineType === "gitlab") {
|
|
17
|
-
const gitlabJobs = await (0, createGitlabJobs_1.createGitlabJobs)(jobs);
|
|
18
|
-
return (0, createGitlabPipeline_1.createGitlabPipelineWithDefaults)({
|
|
19
|
-
workflow: {
|
|
20
|
-
rules: rules_1.RULES_ALWAYS,
|
|
21
|
-
},
|
|
22
|
-
stages,
|
|
23
|
-
jobs: Object.fromEntries(gitlabJobs.map(({ gitlabJob, name }) => [name, gitlabJob])),
|
|
24
|
-
variables: config.runnerVariables,
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
throw new Error(`${pipelineType} is not supported`);
|
|
28
|
-
};
|
|
29
|
-
exports.createChildPipeline = createChildPipeline;
|
|
30
|
-
//# sourceMappingURL=createChildPipeline.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createChildPipeline.js","sourceRoot":"","sources":["../../../../../pipeline/src/pipeline/createChildPipeline.ts"],"names":[],"mappings":";;;AAAA,oCAAwC;AAIxC,mDAAgD;AAChD,2DAAwD;AACxD,gEAA6D;AAC7D,wEAAiF;AAE1E,MAAM,mBAAmB,GAAG,KAAK,EACtC,YAAe,EACf,OAAwB,EACxB,MAAc,EACQ,EAAE;IACxB,MAAM,IAAI,GAAG,MAAM,IAAA,6BAAa,EAAC;QAC/B,MAAM;QACN,OAAO;QACP,YAAY;KACb,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,IAAA,qCAAiB,EAAC,MAAM,CAAC,CAAC;IAEzC,IAAI,YAAY,KAAK,QAAQ,EAAE,CAAC;QAC9B,MAAM,UAAU,GAAG,MAAM,IAAA,mCAAgB,EAAC,IAAI,CAAC,CAAC;QAChD,OAAO,IAAA,uDAAgC,EAAC;YACtC,QAAQ,EAAE;gBACR,KAAK,EAAE,oBAAY;aACpB;YACD,MAAM;YACN,IAAI,EAAE,MAAM,CAAC,WAAW,CACtB,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAC3D;YACD,SAAS,EAAE,MAAM,CAAC,eAAe;SAClC,CAAgB,CAAC;IACpB,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,GAAG,YAAY,mBAAmB,CAAC,CAAC;AACtD,CAAC,CAAC;AA3BW,QAAA,mBAAmB,uBA2B9B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function getPipelineTriggerForGitlabChildPipeline(): "mainBranch" | "mr" | "taggedRelease";
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getPipelineTriggerForGitlabChildPipeline = void 0;
|
|
4
|
-
const constants_1 = require("../../constants");
|
|
5
|
-
function getPipelineTriggerForGitlabChildPipeline() {
|
|
6
|
-
const { CI_MERGE_REQUEST_ID, CI_COMMIT_TAG, CI_COMMIT_BRANCH, CI_DEFAULT_BRANCH, } = process.env;
|
|
7
|
-
const isDefaultBranch = Boolean(CI_DEFAULT_BRANCH) && CI_COMMIT_BRANCH === CI_DEFAULT_BRANCH;
|
|
8
|
-
const isHotfixBranch = CI_COMMIT_BRANCH
|
|
9
|
-
? /^[0-9]+\.([0-9]+|x)\.x$/.test(CI_COMMIT_BRANCH)
|
|
10
|
-
: false;
|
|
11
|
-
const isMergeRequest = Boolean(CI_MERGE_REQUEST_ID);
|
|
12
|
-
const isTaggedRelease = Boolean(CI_COMMIT_TAG);
|
|
13
|
-
console.info(`catladder version ${constants_1.PIPELINE_IMAGE_TAG}`);
|
|
14
|
-
const trigger = isMergeRequest || isHotfixBranch
|
|
15
|
-
? "mr"
|
|
16
|
-
: isDefaultBranch
|
|
17
|
-
? "mainBranch"
|
|
18
|
-
: isTaggedRelease
|
|
19
|
-
? "taggedRelease"
|
|
20
|
-
: null;
|
|
21
|
-
if (!trigger) {
|
|
22
|
-
throw new Error("no matching trigger: " +
|
|
23
|
-
JSON.stringify({
|
|
24
|
-
isMergeRequest,
|
|
25
|
-
isDefaultBranch,
|
|
26
|
-
isTaggedRelease,
|
|
27
|
-
}, null, 2));
|
|
28
|
-
}
|
|
29
|
-
return trigger;
|
|
30
|
-
}
|
|
31
|
-
exports.getPipelineTriggerForGitlabChildPipeline = getPipelineTriggerForGitlabChildPipeline;
|
|
32
|
-
//# sourceMappingURL=getPipelineTriggerForGitlabChildPipeline.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getPipelineTriggerForGitlabChildPipeline.js","sourceRoot":"","sources":["../../../../../../pipeline/src/pipeline/gitlab/getPipelineTriggerForGitlabChildPipeline.ts"],"names":[],"mappings":";;;AACA,+CAAqD;AAErD,SAAgB,wCAAwC;IACtD,MAAM,EACJ,mBAAmB,EACnB,aAAa,EACb,gBAAgB,EAChB,iBAAiB,GAClB,GAAG,OAAO,CAAC,GAAG,CAAC;IAEhB,MAAM,eAAe,GACnB,OAAO,CAAC,iBAAiB,CAAC,IAAI,gBAAgB,KAAK,iBAAiB,CAAC;IACvE,MAAM,cAAc,GAAG,gBAAgB;QACrC,CAAC,CAAC,yBAAyB,CAAC,IAAI,CAAC,gBAAgB,CAAC;QAClD,CAAC,CAAC,KAAK,CAAC;IACV,MAAM,cAAc,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACpD,MAAM,eAAe,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IAE/C,OAAO,CAAC,IAAI,CAAC,qBAAqB,8BAAkB,EAAE,CAAC,CAAC;IAExD,MAAM,OAAO,GACX,cAAc,IAAI,cAAc;QAC9B,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,eAAe;YACf,CAAC,CAAC,YAAY;YACd,CAAC,CAAC,eAAe;gBACf,CAAC,CAAC,eAAe;gBACjB,CAAC,CAAC,IAAI,CAAC;IAEf,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,uBAAuB;YACrB,IAAI,CAAC,SAAS,CACZ;gBACE,cAAc;gBACd,eAAe;gBACf,eAAe;aAChB,EACD,IAAI,EACJ,CAAC,CACF,CACJ,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AA1CD,4FA0CC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { getGitRemoteHostAndPath } from "./getGitRemoteHostAndPath";
|
|
2
|
-
import { getProjectRootPath } from "./getProjectRootPath";
|
|
3
|
-
|
|
4
|
-
export const getGitConfigVars = async () => {
|
|
5
|
-
const [{ gitRemoteHost: GIT_REMOTE_HOST }, PROJECT_ROOT_PATH] =
|
|
6
|
-
await Promise.all([getGitRemoteHostAndPath(), getProjectRootPath()]);
|
|
7
|
-
return {
|
|
8
|
-
PROJECT_ROOT_PATH,
|
|
9
|
-
GIT_REMOTE_HOST,
|
|
10
|
-
};
|
|
11
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { gitConfigGet } from "./gitConfig";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Gets the git remote host and path from cat-cli config or else from the git config.
|
|
5
|
-
*
|
|
6
|
-
* Writes the values to the cat-cli config file.
|
|
7
|
-
*/
|
|
8
|
-
export async function getGitRemoteHostAndPath(): Promise<{
|
|
9
|
-
gitRemoteHost: string;
|
|
10
|
-
gitRemotePath: string;
|
|
11
|
-
}> {
|
|
12
|
-
const gitRemoteOriginUrl = await gitConfigGet("remote.origin.url");
|
|
13
|
-
const match = gitRemoteOriginUrl.match(
|
|
14
|
-
/(https:\/\/|git@)([^:/]+)[:/]([^.]*)(\.git)?/,
|
|
15
|
-
);
|
|
16
|
-
if (!match || !match.length) {
|
|
17
|
-
throw new Error(
|
|
18
|
-
`Could not find gitlab instance url from git! ${gitRemoteOriginUrl}`,
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
const [, , gitRemoteHost, gitRemotePath] = match;
|
|
22
|
-
if (!gitRemoteHost?.length || !gitRemotePath?.length) {
|
|
23
|
-
throw new Error(
|
|
24
|
-
`Could not get gitlab hostname and project path from git config! ${gitRemoteOriginUrl}`,
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
return { gitRemoteHost, gitRemotePath };
|
|
28
|
-
}
|