@catladder/cli 0.0.0-refactor-untangle-gitlab-api-requests-from-vorpal-57cf3cf2 → 0.0.0-reference-database-url-1befbbee
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/catenv/index.js +2146 -23675
- package/dist/bundles/cli/index.js +575 -1032
- package/dist/cli/src/apps/cli/commands/project/commandGitlabCi.d.ts +2 -5
- package/dist/cli/src/apps/cli/commands/project/commandGitlabCi.js +9 -26
- package/dist/cli/src/apps/cli/commands/project/commandGitlabCi.js.map +1 -1
- package/dist/cli/src/apps/cli/commands/project/commandSetup.js +5 -3
- package/dist/cli/src/apps/cli/commands/project/commandSetup.js.map +1 -1
- package/dist/cli/src/apps/cli/commands/project/setup/index.d.ts +1 -1
- package/dist/cli/src/apps/cli/commands/project/setup/index.js +6 -17
- package/dist/cli/src/apps/cli/commands/project/setup/index.js.map +1 -1
- package/dist/cli/src/apps/cli/commands/project/setup/setupAccessTokens.d.ts +1 -4
- package/dist/cli/src/apps/cli/commands/project/setup/setupAccessTokens.js +23 -35
- package/dist/cli/src/apps/cli/commands/project/setup/setupAccessTokens.js.map +1 -1
- package/dist/cli/src/apps/cli/commands/project/setup/setupKubernetes.d.ts +2 -5
- package/dist/cli/src/apps/cli/commands/project/setup/setupKubernetes.js +23 -38
- package/dist/cli/src/apps/cli/commands/project/setup/setupKubernetes.js.map +1 -1
- package/dist/cli/src/apps/cli/commands/project/setup/setupTopic.d.ts +1 -2
- package/dist/cli/src/apps/cli/commands/project/setup/setupTopic.js +4 -5
- package/dist/cli/src/apps/cli/commands/project/setup/setupTopic.js.map +1 -1
- package/dist/cli/src/apps/cli/commands/project/utils/autocompletions.d.ts +1 -0
- package/dist/cli/src/apps/cli/commands/project/utils/autocompletions.js +9 -1
- package/dist/cli/src/apps/cli/commands/project/utils/autocompletions.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 +11 -20
- package/dist/cli/src/apps/cli/utils/getGoogleAuthUserNumber.js.map +1 -1
- package/dist/cli/src/apps/cli/verify/index.js +5 -22
- package/dist/cli/src/apps/cli/verify/index.js.map +1 -1
- package/dist/cli/src/config/getProjectConfig.d.ts +1 -1
- package/dist/cli/src/config/getProjectConfig.js +10 -12
- package/dist/cli/src/config/getProjectConfig.js.map +1 -1
- package/dist/cli/src/git/gitProjectInformation.d.ts +1 -14
- package/dist/cli/src/git/gitProjectInformation.js +2 -29
- package/dist/cli/src/git/gitProjectInformation.js.map +1 -1
- package/dist/cli/src/utils/gitlab.d.ts +23 -17
- package/dist/cli/src/utils/gitlab.js +161 -120
- package/dist/cli/src/utils/gitlab.js.map +1 -1
- package/dist/cli/src/utils/log.d.ts +0 -15
- package/dist/cli/src/utils/log.js +1 -23
- package/dist/cli/src/utils/log.js.map +1 -1
- package/dist/cli/src/utils/preferences.d.ts +4 -0
- package/dist/cli/src/utils/preferences.js +58 -0
- package/dist/cli/src/utils/preferences.js.map +1 -0
- package/dist/pipeline/src/build/artifacts/createBuildJobArtifact.js +3 -1
- package/dist/pipeline/src/build/artifacts/createBuildJobArtifact.js.map +1 -1
- package/dist/pipeline/src/build/base/index.d.ts +2 -3
- package/dist/pipeline/src/build/base/index.js.map +1 -1
- package/dist/pipeline/src/build/cache/getAllCacheConfigsFromConfig.js +6 -4
- package/dist/pipeline/src/build/cache/getAllCacheConfigsFromConfig.js.map +1 -1
- package/dist/pipeline/src/build/custom/buildJob.d.ts +2 -2
- package/dist/pipeline/src/build/custom/buildJob.js.map +1 -1
- package/dist/pipeline/src/build/custom/index.d.ts +2 -2
- package/dist/pipeline/src/build/custom/index.js.map +1 -1
- package/dist/pipeline/src/build/custom/testJob.d.ts +2 -2
- package/dist/pipeline/src/build/custom/testJob.js.map +1 -1
- package/dist/pipeline/src/build/docker.d.ts +4 -4
- package/dist/pipeline/src/build/docker.js +1 -1
- package/dist/pipeline/src/build/docker.js.map +1 -1
- package/dist/pipeline/src/build/index.d.ts +2 -2
- package/dist/pipeline/src/build/index.js +2 -3
- package/dist/pipeline/src/build/index.js.map +1 -1
- package/dist/pipeline/src/build/node/buildJob.d.ts +5 -3
- package/dist/pipeline/src/build/node/buildJob.js.map +1 -1
- package/dist/pipeline/src/build/node/index.d.ts +4 -4
- package/dist/pipeline/src/build/node/index.js.map +1 -1
- package/dist/pipeline/src/build/node/meteor.d.ts +2 -2
- package/dist/pipeline/src/build/node/meteor.js.map +1 -1
- package/dist/pipeline/src/build/node/yarn.d.ts +1 -1
- package/dist/pipeline/src/build/node/yarn.js +3 -1
- package/dist/pipeline/src/build/node/yarn.js.map +1 -1
- package/dist/pipeline/src/build/rails/build.d.ts +2 -2
- package/dist/pipeline/src/build/rails/build.js +0 -1
- package/dist/pipeline/src/build/rails/build.js.map +1 -1
- package/dist/pipeline/src/build/rails/index.d.ts +2 -2
- package/dist/pipeline/src/build/rails/index.js.map +1 -1
- package/dist/pipeline/src/build/rails/test.js +18 -1
- package/dist/pipeline/src/build/rails/test.js.map +1 -1
- package/dist/pipeline/src/build/sbom.d.ts +2 -2
- package/dist/pipeline/src/build/sbom.js +4 -1
- package/dist/pipeline/src/build/sbom.js.map +1 -1
- package/dist/pipeline/src/build/types.d.ts +8 -0
- package/dist/pipeline/src/build/types.js.map +1 -1
- package/dist/pipeline/src/context/createComponentContext.js +17 -6
- package/dist/pipeline/src/context/createComponentContext.js.map +1 -1
- package/dist/pipeline/src/context/getLabels.js +3 -1
- package/dist/pipeline/src/context/getLabels.js.map +1 -1
- package/dist/pipeline/src/deploy/cloudRun/createJobs/cloudRunJobs.js +2 -2
- package/dist/pipeline/src/deploy/cloudRun/createJobs/cloudRunJobs.js.map +1 -1
- package/dist/pipeline/src/deploy/cloudRun/createJobs/cloudRunServices.js +32 -7
- package/dist/pipeline/src/deploy/cloudRun/createJobs/cloudRunServices.js.map +1 -1
- package/dist/pipeline/src/deploy/cloudRun/createJobs/execute/onDeploy.d.ts +1 -2
- package/dist/pipeline/src/deploy/cloudRun/createJobs/execute/onDeploy.js +3 -10
- package/dist/pipeline/src/deploy/cloudRun/createJobs/execute/onDeploy.js.map +1 -1
- package/dist/pipeline/src/deploy/cloudRun/createJobs/healthCheck.d.ts +5 -0
- package/dist/pipeline/src/deploy/cloudRun/createJobs/healthCheck.js +51 -0
- package/dist/pipeline/src/deploy/cloudRun/createJobs/healthCheck.js.map +1 -0
- package/dist/pipeline/src/deploy/cloudRun/index.js +7 -4
- package/dist/pipeline/src/deploy/cloudRun/index.js.map +1 -1
- package/dist/pipeline/src/deploy/cloudRun/utils/database.d.ts +21 -2
- package/dist/pipeline/src/deploy/cloudRun/utils/database.js +55 -6
- package/dist/pipeline/src/deploy/cloudRun/utils/database.js.map +1 -1
- package/dist/pipeline/src/deploy/cloudRun/utils/getJobOrServiceArgs.d.ts +2 -0
- package/dist/pipeline/src/deploy/cloudRun/utils/getJobOrServiceArgs.js +12 -0
- package/dist/pipeline/src/deploy/cloudRun/utils/getJobOrServiceArgs.js.map +1 -0
- package/dist/pipeline/src/deploy/kubernetes/kubeValues.d.ts +2 -2
- package/dist/pipeline/src/deploy/kubernetes/kubeValues.js +3 -1
- package/dist/pipeline/src/deploy/kubernetes/kubeValues.js.map +1 -1
- package/dist/pipeline/src/deploy/sbom.js +4 -3
- package/dist/pipeline/src/deploy/sbom.js.map +1 -1
- package/dist/pipeline/src/deploy/types/googleCloudRun.d.ts +100 -0
- package/dist/pipeline/src/deploy/types/googleCloudRun.js +16 -0
- package/dist/pipeline/src/deploy/types/googleCloudRun.js.map +1 -1
- package/dist/pipeline/src/pipeline/createJobsForComponent.js +3 -1
- package/dist/pipeline/src/pipeline/createJobsForComponent.js.map +1 -1
- package/dist/pipeline/src/types/config.d.ts +1 -1
- package/dist/pipeline/src/types/context.d.ts +6 -1
- package/dist/pipeline/src/types/context.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/apps/cli/commands/project/commandGitlabCi.ts +20 -58
- package/src/apps/cli/commands/project/commandSetup.ts +5 -3
- package/src/apps/cli/commands/project/setup/index.ts +9 -19
- package/src/apps/cli/commands/project/setup/setupAccessTokens.ts +45 -62
- package/src/apps/cli/commands/project/setup/setupKubernetes.ts +32 -53
- package/src/apps/cli/commands/project/setup/setupTopic.ts +12 -17
- package/src/apps/cli/commands/project/utils/autocompletions.ts +9 -0
- package/src/apps/cli/utils/getGoogleAuthUserNumber.ts +18 -28
- package/src/apps/cli/verify/index.ts +7 -25
- package/src/config/getProjectConfig.ts +21 -22
- package/src/git/gitProjectInformation.ts +1 -31
- package/src/utils/gitlab.ts +247 -200
- package/src/utils/log.ts +0 -26
- package/src/utils/preferences.ts +60 -0
- package/dist/cli/src/utils/gitlab-without-vorpal/FetchGitLabError.d.ts +0 -18
- package/dist/cli/src/utils/gitlab-without-vorpal/FetchGitLabError.js +0 -32
- package/dist/cli/src/utils/gitlab-without-vorpal/FetchGitLabError.js.map +0 -1
- package/dist/cli/src/utils/gitlab-without-vorpal/FetchMethod.d.ts +0 -1
- package/dist/cli/src/utils/gitlab-without-vorpal/FetchMethod.js +0 -3
- package/dist/cli/src/utils/gitlab-without-vorpal/FetchMethod.js.map +0 -1
- package/dist/cli/src/utils/gitlab-without-vorpal/GitLabApiDataOptional.d.ts +0 -14
- package/dist/cli/src/utils/gitlab-without-vorpal/GitLabApiDataOptional.js +0 -3
- package/dist/cli/src/utils/gitlab-without-vorpal/GitLabApiDataOptional.js.map +0 -1
- package/dist/cli/src/utils/gitlab-without-vorpal/GitLabTokenMissingError.d.ts +0 -4
- package/dist/cli/src/utils/gitlab-without-vorpal/GitLabTokenMissingError.js +0 -12
- package/dist/cli/src/utils/gitlab-without-vorpal/GitLabTokenMissingError.js.map +0 -1
- package/dist/cli/src/utils/gitlab-without-vorpal/fetchGitLabApi.d.ts +0 -8
- package/dist/cli/src/utils/gitlab-without-vorpal/fetchGitLabApi.js +0 -47
- package/dist/cli/src/utils/gitlab-without-vorpal/fetchGitLabApi.js.map +0 -1
- package/dist/cli/src/utils/gitlab-without-vorpal/getGitlabHostPathToken.d.ts +0 -20
- package/dist/cli/src/utils/gitlab-without-vorpal/getGitlabHostPathToken.js +0 -15
- package/dist/cli/src/utils/gitlab-without-vorpal/getGitlabHostPathToken.js.map +0 -1
- package/dist/cli/src/utils/gitlab-without-vorpal/gitLabProjectByGitPath.d.ts +0 -23
- package/dist/cli/src/utils/gitlab-without-vorpal/gitLabProjectByGitPath.js +0 -30
- package/dist/cli/src/utils/gitlab-without-vorpal/gitLabProjectByGitPath.js.map +0 -1
- package/dist/cli/src/utils/gitlab-without-vorpal/gitLabVariables.d.ts +0 -66
- package/dist/cli/src/utils/gitlab-without-vorpal/gitLabVariables.js +0 -129
- package/dist/cli/src/utils/gitlab-without-vorpal/gitLabVariables.js.map +0 -1
- package/dist/cli/src/utils/gitlab-without-vorpal/index.d.ts +0 -12
- package/dist/cli/src/utils/gitlab-without-vorpal/index.js +0 -29
- package/dist/cli/src/utils/gitlab-without-vorpal/index.js.map +0 -1
- package/dist/cli/src/utils/gitlab-without-vorpal/insertProjectTopics.d.ts +0 -5
- package/dist/cli/src/utils/gitlab-without-vorpal/insertProjectTopics.js +0 -23
- package/dist/cli/src/utils/gitlab-without-vorpal/insertProjectTopics.js.map +0 -1
- package/dist/cli/src/utils/gitlab-without-vorpal/loadGitLabToken.d.ts +0 -2
- package/dist/cli/src/utils/gitlab-without-vorpal/loadGitLabToken.js +0 -27
- package/dist/cli/src/utils/gitlab-without-vorpal/loadGitLabToken.js.map +0 -1
- package/dist/cli/src/utils/gitlab-without-vorpal/projectAccessToken.d.ts +0 -29
- package/dist/cli/src/utils/gitlab-without-vorpal/projectAccessToken.js +0 -24
- package/dist/cli/src/utils/gitlab-without-vorpal/projectAccessToken.js.map +0 -1
- package/dist/cli/src/utils/gitlab-without-vorpal/storeGitLabToken.d.ts +0 -3
- package/dist/cli/src/utils/gitlab-without-vorpal/storeGitLabToken.js +0 -19
- package/dist/cli/src/utils/gitlab-without-vorpal/storeGitLabToken.js.map +0 -1
- package/dist/cli/src/utils/preferences/CatladderPreferences.d.ts +0 -27
- package/dist/cli/src/utils/preferences/CatladderPreferences.js +0 -34
- package/dist/cli/src/utils/preferences/CatladderPreferences.js.map +0 -1
- package/dist/cli/src/utils/preferences/index.d.ts +0 -11
- package/dist/cli/src/utils/preferences/index.js +0 -79
- package/dist/cli/src/utils/preferences/index.js.map +0 -1
- package/src/utils/gitlab-without-vorpal/FetchGitLabError.ts +0 -57
- package/src/utils/gitlab-without-vorpal/FetchMethod.ts +0 -1
- package/src/utils/gitlab-without-vorpal/GitLabApiDataOptional.ts +0 -14
- package/src/utils/gitlab-without-vorpal/GitLabTokenMissingError.ts +0 -7
- package/src/utils/gitlab-without-vorpal/fetchGitLabApi.ts +0 -74
- package/src/utils/gitlab-without-vorpal/getGitlabHostPathToken.ts +0 -31
- package/src/utils/gitlab-without-vorpal/gitLabProjectByGitPath.ts +0 -57
- package/src/utils/gitlab-without-vorpal/gitLabVariables.ts +0 -290
- package/src/utils/gitlab-without-vorpal/index.ts +0 -12
- package/src/utils/gitlab-without-vorpal/insertProjectTopics.ts +0 -35
- package/src/utils/gitlab-without-vorpal/loadGitLabToken.ts +0 -29
- package/src/utils/gitlab-without-vorpal/projectAccessToken.ts +0 -86
- package/src/utils/gitlab-without-vorpal/storeGitLabToken.ts +0 -23
- package/src/utils/preferences/CatladderPreferences.ts +0 -51
- package/src/utils/preferences/index.ts +0 -103
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.loadGitLabToken = void 0;
|
|
4
|
-
const GitLabTokenMissingError_1 = require("./GitLabTokenMissingError");
|
|
5
|
-
const storeGitLabToken_1 = require("./storeGitLabToken");
|
|
6
|
-
const preferences_1 = require("../preferences");
|
|
7
|
-
const git_1 = require("../../git");
|
|
8
|
-
const loadGitLabToken = async (gitlabHost, logger = console) => {
|
|
9
|
-
var _a, _b;
|
|
10
|
-
const [preferences, host] = await Promise.all([
|
|
11
|
-
(0, preferences_1.getPreferences)(logger),
|
|
12
|
-
(0, git_1.getGitRemoteHost)(gitlabHost),
|
|
13
|
-
]);
|
|
14
|
-
if ((_a = preferences.gitlabTokens[host]) === null || _a === void 0 ? void 0 : _a.length) {
|
|
15
|
-
return preferences.gitlabTokens[host];
|
|
16
|
-
}
|
|
17
|
-
if ((_b = preferences["gitlab-personal-access-token"]) === null || _b === void 0 ? void 0 : _b.length) {
|
|
18
|
-
// Add the token to the hostname based preferences
|
|
19
|
-
return (0, storeGitLabToken_1.storeGitLabToken)({
|
|
20
|
-
token: preferences["gitlab-personal-access-token"],
|
|
21
|
-
host,
|
|
22
|
-
}, logger);
|
|
23
|
-
}
|
|
24
|
-
throw new GitLabTokenMissingError_1.GitLabTokenMissingError();
|
|
25
|
-
};
|
|
26
|
-
exports.loadGitLabToken = loadGitLabToken;
|
|
27
|
-
//# sourceMappingURL=loadGitLabToken.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"loadGitLabToken.js","sourceRoot":"","sources":["../../../../../src/utils/gitlab-without-vorpal/loadGitLabToken.ts"],"names":[],"mappings":";;;AAAA,uEAAoE;AACpE,yDAAsD;AAEtD,gDAAgD;AAChD,mCAA6C;AAEtC,MAAM,eAAe,GAAG,KAAK,EAClC,UAAmB,EACnB,SAA4B,OAAO,EACnC,EAAE;;IACF,MAAM,CAAC,WAAW,EAAE,IAAI,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QAC5C,IAAA,4BAAc,EAAC,MAAM,CAAC;QACtB,IAAA,sBAAgB,EAAC,UAAU,CAAC;KAC7B,CAAC,CAAC;IACH,IAAI,MAAA,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,0CAAE,MAAM,EAAE,CAAC;QAC3C,OAAO,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;IACD,IAAI,MAAA,WAAW,CAAC,8BAA8B,CAAC,0CAAE,MAAM,EAAE,CAAC;QACxD,kDAAkD;QAClD,OAAO,IAAA,mCAAgB,EACrB;YACE,KAAK,EAAE,WAAW,CAAC,8BAA8B,CAAC;YAClD,IAAI;SACL,EACD,MAAM,CACP,CAAC;IACJ,CAAC;IACD,MAAM,IAAI,iDAAuB,EAAE,CAAC;AACtC,CAAC,CAAC;AAtBW,QAAA,eAAe,mBAsB1B"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { LoggerCmdInstance } from "../log";
|
|
2
|
-
import type { GitLabApiDataOptional } from "./GitLabApiDataOptional";
|
|
3
|
-
export type GitLabProjectAccessToken = {
|
|
4
|
-
id: number;
|
|
5
|
-
name: string;
|
|
6
|
-
revoked: boolean;
|
|
7
|
-
created_at: Date;
|
|
8
|
-
expires_at: Date;
|
|
9
|
-
user_id: number;
|
|
10
|
-
last_used_at: Date;
|
|
11
|
-
active: boolean;
|
|
12
|
-
access_level: number;
|
|
13
|
-
scopes: string[];
|
|
14
|
-
token: string;
|
|
15
|
-
};
|
|
16
|
-
export declare const gitLabProjectAccessToken: {
|
|
17
|
-
getList: ({ projectId, path, ...existing }: {
|
|
18
|
-
projectId: string | number;
|
|
19
|
-
} & GitLabApiDataOptional, logger?: LoggerCmdInstance) => Promise<GitLabProjectAccessToken[]>;
|
|
20
|
-
rotate: ({ projectId, tokenId, data: { expires_at }, path, ...existing }: {
|
|
21
|
-
projectId: string | number;
|
|
22
|
-
tokenId: number;
|
|
23
|
-
data: Pick<GitLabProjectAccessToken, "expires_at">;
|
|
24
|
-
} & GitLabApiDataOptional, logger?: LoggerCmdInstance) => Promise<GitLabProjectAccessToken>;
|
|
25
|
-
create: ({ projectId, path, data: { expires_at, ...data }, ...existing }: {
|
|
26
|
-
projectId: string | number;
|
|
27
|
-
data: Pick<GitLabProjectAccessToken, "access_level" | "name" | "scopes" | "expires_at">;
|
|
28
|
-
} & GitLabApiDataOptional, logger?: LoggerCmdInstance) => Promise<GitLabProjectAccessToken>;
|
|
29
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.gitLabProjectAccessToken = void 0;
|
|
4
|
-
const date_fns_1 = require("date-fns");
|
|
5
|
-
const fetchGitLabApi_1 = require("./fetchGitLabApi");
|
|
6
|
-
const getProjectAccessTokens = async ({ projectId, path, ...existing }, logger = console) => (0, fetchGitLabApi_1.fetchGitLabApi)({ resourcePath: `projects/${projectId}/access_tokens`, ...existing }, logger);
|
|
7
|
-
const rotate = async ({ projectId, tokenId, data: { expires_at }, path, ...existing }, logger = console) => (0, fetchGitLabApi_1.fetchGitLabApi)({
|
|
8
|
-
resourcePath: `projects/${projectId}/access_tokens/${tokenId}/rotate`,
|
|
9
|
-
data: { expires_at: (0, date_fns_1.format)(expires_at, "yyyy-MM-dd") },
|
|
10
|
-
method: "POST",
|
|
11
|
-
...existing,
|
|
12
|
-
}, logger);
|
|
13
|
-
const create = async ({ projectId, path, data: { expires_at, ...data }, ...existing }, logger = console) => (0, fetchGitLabApi_1.fetchGitLabApi)({
|
|
14
|
-
resourcePath: `projects/${projectId}/access_tokens`,
|
|
15
|
-
data: { expires_at: (0, date_fns_1.format)(expires_at, "yyyy-MM-dd"), ...data },
|
|
16
|
-
method: "POST",
|
|
17
|
-
...existing,
|
|
18
|
-
}, logger);
|
|
19
|
-
exports.gitLabProjectAccessToken = {
|
|
20
|
-
getList: getProjectAccessTokens,
|
|
21
|
-
rotate,
|
|
22
|
-
create,
|
|
23
|
-
};
|
|
24
|
-
//# sourceMappingURL=projectAccessToken.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"projectAccessToken.js","sourceRoot":"","sources":["../../../../../src/utils/gitlab-without-vorpal/projectAccessToken.ts"],"names":[],"mappings":";;;AAAA,uCAAkC;AAElC,qDAAkD;AAiB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|
|
4
|
-
const preferences_1 = require("../preferences");
|
|
5
|
-
const GitLabTokenMissingError_1 = require("./GitLabTokenMissingError");
|
|
6
|
-
const git_1 = require("../../git");
|
|
7
|
-
const storeGitLabToken = async ({ token, host }, logger = console) => {
|
|
8
|
-
if (typeof token !== "string" || !token.length) {
|
|
9
|
-
throw new GitLabTokenMissingError_1.GitLabTokenMissingError();
|
|
10
|
-
}
|
|
11
|
-
const gitRemoteHost = await (0, git_1.getGitRemoteHost)(host);
|
|
12
|
-
await (0, preferences_1.upsertPreferences)({
|
|
13
|
-
"gitlab-personal-access-token": token,
|
|
14
|
-
gitlabTokens: { [gitRemoteHost]: token },
|
|
15
|
-
}, logger);
|
|
16
|
-
return token;
|
|
17
|
-
};
|
|
18
|
-
exports.storeGitLabToken = storeGitLabToken;
|
|
19
|
-
//# sourceMappingURL=storeGitLabToken.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"storeGitLabToken.js","sourceRoot":"","sources":["../../../../../src/utils/gitlab-without-vorpal/storeGitLabToken.ts"],"names":[],"mappings":";;;AACA,gDAAmD;AACnD,uEAAoE;AAEpE,mCAA6C;AAEtC,MAAM,gBAAgB,GAAG,KAAK,EACnC,EAAE,KAAK,EAAE,IAAI,EAAuC,EACpD,SAA4B,OAAO,EACnC,EAAE;IACF,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;QAC/C,MAAM,IAAI,iDAAuB,EAAE,CAAC;IACtC,CAAC;IACD,MAAM,aAAa,GAAG,MAAM,IAAA,sBAAgB,EAAC,IAAI,CAAC,CAAC;IACnD,MAAM,IAAA,+BAAiB,EACrB;QACE,8BAA8B,EAAE,KAAK;QACrC,YAAY,EAAE,EAAE,CAAC,aAAa,CAAC,EAAE,KAAK,EAAE;KACzC,EACD,MAAM,CACP,CAAC;IACF,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAhBW,QAAA,gBAAgB,oBAgB3B"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
declare const gitlabPersonalAccessToken = "gitlab-personal-access-token";
|
|
2
|
-
declare const googleAuthUserNumber = "googleAuthUserNumber";
|
|
3
|
-
declare const gitlabTokens = "gitlabTokens";
|
|
4
|
-
declare const gitLabProjectIds = "gitLabProjectIds";
|
|
5
|
-
export type CatladderPreferences = {
|
|
6
|
-
/**
|
|
7
|
-
* @deprecated Use the hostname based `gitlabTokens` instead.
|
|
8
|
-
*/
|
|
9
|
-
[gitlabPersonalAccessToken]: string | undefined;
|
|
10
|
-
[googleAuthUserNumber]: string | number | undefined;
|
|
11
|
-
/**
|
|
12
|
-
* GitLab tokens by GitLab instance hostname.
|
|
13
|
-
*/
|
|
14
|
-
[gitlabTokens]: {
|
|
15
|
-
[instanceHostname in string]: string;
|
|
16
|
-
};
|
|
17
|
-
[gitLabProjectIds]: {
|
|
18
|
-
[hostnameProjectPath in string]: number;
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* Merges a partial configuration object with a fallback configuration object.
|
|
23
|
-
* @param config - A partial configuration object of type `Partial<CatladderPreferences>`.
|
|
24
|
-
* @param fallback - The fallback can be passed, in order to use this function for upserting as well.
|
|
25
|
-
*/
|
|
26
|
-
export declare const mergeWithFallback: (config?: Partial<CatladderPreferences>, fallback?: CatladderPreferences) => CatladderPreferences;
|
|
27
|
-
export {};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mergeWithFallback = void 0;
|
|
4
|
-
const gitlabPersonalAccessToken = "gitlab-personal-access-token";
|
|
5
|
-
const googleAuthUserNumber = "googleAuthUserNumber";
|
|
6
|
-
const gitlabTokens = "gitlabTokens";
|
|
7
|
-
const gitLabProjectIds = "gitLabProjectIds";
|
|
8
|
-
const preferenceKeys = [
|
|
9
|
-
gitlabPersonalAccessToken,
|
|
10
|
-
googleAuthUserNumber,
|
|
11
|
-
gitlabTokens,
|
|
12
|
-
gitLabProjectIds,
|
|
13
|
-
];
|
|
14
|
-
const perfFallback = {
|
|
15
|
-
[gitlabPersonalAccessToken]: undefined,
|
|
16
|
-
[googleAuthUserNumber]: undefined,
|
|
17
|
-
[gitlabTokens]: {},
|
|
18
|
-
[gitLabProjectIds]: {},
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* Merges a partial configuration object with a fallback configuration object.
|
|
22
|
-
* @param config - A partial configuration object of type `Partial<CatladderPreferences>`.
|
|
23
|
-
* @param fallback - The fallback can be passed, in order to use this function for upserting as well.
|
|
24
|
-
*/
|
|
25
|
-
const mergeWithFallback = (config = {}, fallback = perfFallback) => preferenceKeys.reduce((acc, key) => {
|
|
26
|
-
var _a, _b;
|
|
27
|
-
return Object.assign(acc, {
|
|
28
|
-
[key]: typeof fallback[key] === "object"
|
|
29
|
-
? Object.assign(fallback[key], (_a = config[key]) !== null && _a !== void 0 ? _a : {})
|
|
30
|
-
: ((_b = config[key]) !== null && _b !== void 0 ? _b : fallback[key]),
|
|
31
|
-
});
|
|
32
|
-
}, {});
|
|
33
|
-
exports.mergeWithFallback = mergeWithFallback;
|
|
34
|
-
//# sourceMappingURL=CatladderPreferences.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CatladderPreferences.js","sourceRoot":"","sources":["../../../../../src/utils/preferences/CatladderPreferences.ts"],"names":[],"mappings":";;;AAAA,MAAM,yBAAyB,GAAG,8BAA8B,CAAC;AACjE,MAAM,oBAAoB,GAAG,sBAAsB,CAAC;AACpD,MAAM,YAAY,GAAG,cAAc,CAAC;AACpC,MAAM,gBAAgB,GAAG,kBAAkB,CAAC;AAE5C,MAAM,cAAc,GAAG;IACrB,yBAAyB;IACzB,oBAAoB;IACpB,YAAY;IACZ,gBAAgB;CACR,CAAC;AAeX,MAAM,YAAY,GAAyB;IACzC,CAAC,yBAAyB,CAAC,EAAE,SAAS;IACtC,CAAC,oBAAoB,CAAC,EAAE,SAAS;IACjC,CAAC,YAAY,CAAC,EAAE,EAAE;IAClB,CAAC,gBAAgB,CAAC,EAAE,EAAE;CACvB,CAAC;AAEF;;;;GAIG;AACI,MAAM,iBAAiB,GAAG,CAC/B,SAAwC,EAAE,EAC1C,QAAQ,GAAG,YAAY,EACD,EAAE,CACxB,cAAc,CAAC,MAAM,CACnB,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;;IACX,OAAA,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE;QACjB,CAAC,GAAG,CAAC,EACH,OAAO,QAAQ,CAAC,GAAG,CAAC,KAAK,QAAQ;YAC/B,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAA,MAAM,CAAC,GAAG,CAAC,mCAAI,EAAE,CAAC;YACjD,CAAC,CAAC,CAAC,MAAA,MAAM,CAAC,GAAG,CAAC,mCAAI,QAAQ,CAAC,GAAG,CAAC,CAAC;KACrC,CAAC,CAAA;CAAA,EACJ,EAA0B,CAC3B,CAAC;AAbS,QAAA,iBAAiB,qBAa1B"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { type CatladderPreferences } from "./CatladderPreferences";
|
|
2
|
-
import type { LoggerCmdInstance } from "../log";
|
|
3
|
-
export { type CatladderPreferences } from "./CatladderPreferences";
|
|
4
|
-
/**
|
|
5
|
-
* Load preferences from ~/.config/catladder/preferences.yml
|
|
6
|
-
*/
|
|
7
|
-
export declare const getPreferences: (logger?: LoggerCmdInstance) => Promise<CatladderPreferences>;
|
|
8
|
-
/**
|
|
9
|
-
* Add or update preference values in ~/.config/catladder/preferences.yml
|
|
10
|
-
*/
|
|
11
|
-
export declare const upsertPreferences: (preferences?: Partial<CatladderPreferences>, logger?: LoggerCmdInstance) => Promise<void>;
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.upsertPreferences = exports.getPreferences = void 0;
|
|
4
|
-
const fs_1 = require("fs");
|
|
5
|
-
const promises_1 = require("fs/promises");
|
|
6
|
-
const os_1 = require("os");
|
|
7
|
-
const posix_1 = require("path/posix");
|
|
8
|
-
const yaml_1 = require("yaml");
|
|
9
|
-
const CatladderPreferences_1 = require("./CatladderPreferences");
|
|
10
|
-
const log_1 = require("../log");
|
|
11
|
-
const legacyDir = (0, posix_1.join)((0, os_1.homedir)(), ".catladder");
|
|
12
|
-
const legacyPath = (0, posix_1.join)(legacyDir, "preferences.yml");
|
|
13
|
-
const configDir = (0, posix_1.join)((0, os_1.homedir)(), ".config/catladder");
|
|
14
|
-
const configPath = (0, posix_1.join)(configDir, "preferences.yml");
|
|
15
|
-
const legacyBackupPath = (0, posix_1.join)(configDir, "old_preferences_backup.yml");
|
|
16
|
-
const encoding = "utf-8";
|
|
17
|
-
const mode = 0o600;
|
|
18
|
-
const readPerfString = () => (0, promises_1.readFile)(configPath, { encoding });
|
|
19
|
-
const writePerfString = (str) => (0, promises_1.writeFile)(configPath, str, { encoding, mode });
|
|
20
|
-
const isConfigPath = () => (0, fs_1.existsSync)(configPath);
|
|
21
|
-
const isLegacyPath = () => (0, fs_1.existsSync)(legacyPath);
|
|
22
|
-
const createDir = () => (0, promises_1.mkdir)(configDir, { recursive: true, mode: 0o700 });
|
|
23
|
-
const copyLegacyConfig = async (target = configPath) => {
|
|
24
|
-
await (0, promises_1.cp)(legacyPath, target);
|
|
25
|
-
return (0, promises_1.chmod)(target, mode);
|
|
26
|
-
};
|
|
27
|
-
const parseConfigString = (yamlString, logger = console) => {
|
|
28
|
-
var _a;
|
|
29
|
-
try {
|
|
30
|
-
return (0, CatladderPreferences_1.mergeWithFallback)((_a = (0, yaml_1.parse)(yamlString)) !== null && _a !== void 0 ? _a : {});
|
|
31
|
-
}
|
|
32
|
-
catch (error) {
|
|
33
|
-
(0, log_1.logError)(logger, "Error when trying to parse preferences", `${error}`);
|
|
34
|
-
throw error;
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
const readPreferences = async (logger = console) => {
|
|
38
|
-
const yamlContent = await readPerfString();
|
|
39
|
-
return parseConfigString(yamlContent, logger);
|
|
40
|
-
};
|
|
41
|
-
const stringifyConfig = (config = {}, logger = console) => {
|
|
42
|
-
try {
|
|
43
|
-
const preferences = (0, CatladderPreferences_1.mergeWithFallback)(config);
|
|
44
|
-
return (0, yaml_1.stringify)(preferences);
|
|
45
|
-
}
|
|
46
|
-
catch (error) {
|
|
47
|
-
(0, log_1.logError)(logger, "Error when trying to stringify preferences", `${error}`);
|
|
48
|
-
throw error;
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
const writePreferences = async (preferences = {}, logger = console) => writePerfString(stringifyConfig(preferences, logger));
|
|
52
|
-
const ensureConfigFile = async () => {
|
|
53
|
-
if (isConfigPath()) {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
await createDir();
|
|
57
|
-
if (!isLegacyPath()) {
|
|
58
|
-
return writePreferences();
|
|
59
|
-
}
|
|
60
|
-
await copyLegacyConfig();
|
|
61
|
-
return copyLegacyConfig(legacyBackupPath);
|
|
62
|
-
};
|
|
63
|
-
/**
|
|
64
|
-
* Load preferences from ~/.config/catladder/preferences.yml
|
|
65
|
-
*/
|
|
66
|
-
const getPreferences = async (logger = console) => {
|
|
67
|
-
await ensureConfigFile();
|
|
68
|
-
return readPreferences(logger);
|
|
69
|
-
};
|
|
70
|
-
exports.getPreferences = getPreferences;
|
|
71
|
-
/**
|
|
72
|
-
* Add or update preference values in ~/.config/catladder/preferences.yml
|
|
73
|
-
*/
|
|
74
|
-
const upsertPreferences = async (preferences = {}, logger = console) => {
|
|
75
|
-
const current = await (0, exports.getPreferences)(logger);
|
|
76
|
-
return writePreferences((0, CatladderPreferences_1.mergeWithFallback)(preferences, current), logger);
|
|
77
|
-
};
|
|
78
|
-
exports.upsertPreferences = upsertPreferences;
|
|
79
|
-
//# sourceMappingURL=index.js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,CAAC,eAAe,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC;AAE3D,MAAM,gBAAgB,GAAG,KAAK,IAAI,EAAE;IAClC,IAAI,YAAY,EAAE,EAAE,CAAC;QACnB,OAAO;IACT,CAAC;IACD,MAAM,SAAS,EAAE,CAAC;IAClB,IAAI,CAAC,YAAY,EAAE,EAAE,CAAC;QACpB,OAAO,gBAAgB,EAAE,CAAC;IAC5B,CAAC;IACD,MAAM,gBAAgB,EAAE,CAAC;IACzB,OAAO,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;AAC5C,CAAC,CAAC;AAEF;;GAEG;AACI,MAAM,cAAc,GAAG,KAAK,EAAE,SAA4B,OAAO,EAAE,EAAE;IAC1E,MAAM,gBAAgB,EAAE,CAAC;IACzB,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC;AACjC,CAAC,CAAC;AAHW,QAAA,cAAc,kBAGzB;AAEF;;GAEG;AACI,MAAM,iBAAiB,GAAG,KAAK,EACpC,cAA6C,EAAE,EAC/C,SAA4B,OAAO,EACnC,EAAE;IACF,MAAM,OAAO,GAAG,MAAM,IAAA,sBAAc,EAAC,MAAM,CAAC,CAAC;IAC7C,OAAO,gBAAgB,CAAC,IAAA,wCAAiB,EAAC,WAAW,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,CAAC;AAC3E,CAAC,CAAC;AANW,QAAA,iBAAiB,qBAM5B"}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import type { Response } from "node-fetch";
|
|
2
|
-
|
|
3
|
-
import type { FetchMethod } from "./FetchMethod";
|
|
4
|
-
|
|
5
|
-
export class FetchGitLabError extends Error {
|
|
6
|
-
name = "FetchGitLabError";
|
|
7
|
-
status?: number;
|
|
8
|
-
statusText?: string;
|
|
9
|
-
contentType?: string;
|
|
10
|
-
cause?: unknown;
|
|
11
|
-
resourcePath?: string;
|
|
12
|
-
data?: any;
|
|
13
|
-
method?: FetchMethod;
|
|
14
|
-
|
|
15
|
-
constructor(
|
|
16
|
-
public response?: Response,
|
|
17
|
-
{
|
|
18
|
-
resourcePath,
|
|
19
|
-
data,
|
|
20
|
-
method,
|
|
21
|
-
cause,
|
|
22
|
-
}: {
|
|
23
|
-
resourcePath?: string;
|
|
24
|
-
data?: any;
|
|
25
|
-
method?: FetchMethod;
|
|
26
|
-
} & ErrorOptions = {},
|
|
27
|
-
extraMessage = "",
|
|
28
|
-
) {
|
|
29
|
-
const status = response?.status;
|
|
30
|
-
const statusMsg = status ? ` ${status}` : "";
|
|
31
|
-
const methodPath = [method, resourcePath].filter(Boolean).join(" ");
|
|
32
|
-
const customMsg = extraMessage?.length ? `: ${extraMessage}` : "";
|
|
33
|
-
super(
|
|
34
|
-
`GitLab API Error${statusMsg}${methodPath?.length ? ` ${methodPath}` : ""}${customMsg}`,
|
|
35
|
-
{
|
|
36
|
-
cause: Object.entries({ resourcePath, data, method, cause }).reduce(
|
|
37
|
-
(acc, [k, v]) => {
|
|
38
|
-
if (v) {
|
|
39
|
-
acc[k] = v;
|
|
40
|
-
}
|
|
41
|
-
return acc;
|
|
42
|
-
},
|
|
43
|
-
{},
|
|
44
|
-
),
|
|
45
|
-
},
|
|
46
|
-
);
|
|
47
|
-
this.cause = cause;
|
|
48
|
-
this.resourcePath = resourcePath;
|
|
49
|
-
this.data = data;
|
|
50
|
-
this.method = method;
|
|
51
|
-
if (response) {
|
|
52
|
-
this.status = status;
|
|
53
|
-
this.contentType = response.headers.get("content-type");
|
|
54
|
-
this.statusText = response.statusText;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type FetchMethod = "GET" | "PUT" | "POST" | "DELETE";
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export type GitLabApiDataOptional = {
|
|
2
|
-
/**
|
|
3
|
-
* Already present GitLab instance hostname
|
|
4
|
-
*/
|
|
5
|
-
host?: string;
|
|
6
|
-
/**
|
|
7
|
-
* Already present GitLab project path
|
|
8
|
-
*/
|
|
9
|
-
path?: string;
|
|
10
|
-
/**
|
|
11
|
-
* Already present GitLab Personal access token
|
|
12
|
-
*/
|
|
13
|
-
token?: string;
|
|
14
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export class GitLabTokenMissingError extends Error {
|
|
2
|
-
name = "GitLabTokenMissingError";
|
|
3
|
-
constructor(message = "", additional: ErrorOptions = {}) {
|
|
4
|
-
const notice = `GitLab token is missing${message?.length ? `: ${message}` : ""}`;
|
|
5
|
-
super(notice, additional);
|
|
6
|
-
}
|
|
7
|
-
}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import fetch from "node-fetch";
|
|
2
|
-
|
|
3
|
-
import type { LoggerCmdInstance } from "../log";
|
|
4
|
-
import { FetchGitLabError } from "./FetchGitLabError";
|
|
5
|
-
import type { FetchMethod } from "./FetchMethod";
|
|
6
|
-
import { GitLabTokenMissingError } from "./GitLabTokenMissingError";
|
|
7
|
-
import { loadGitLabToken } from "./loadGitLabToken";
|
|
8
|
-
import type { GitLabApiDataOptional } from "./GitLabApiDataOptional";
|
|
9
|
-
import { getGitRemoteHost } from "../../git";
|
|
10
|
-
|
|
11
|
-
export const fetchGitLabApi = async <T>(
|
|
12
|
-
{
|
|
13
|
-
resourcePath,
|
|
14
|
-
data,
|
|
15
|
-
method = "GET",
|
|
16
|
-
host,
|
|
17
|
-
token,
|
|
18
|
-
}: {
|
|
19
|
-
resourcePath: string;
|
|
20
|
-
data?: any;
|
|
21
|
-
method?: FetchMethod;
|
|
22
|
-
} & Omit<GitLabApiDataOptional, "path">,
|
|
23
|
-
logger: LoggerCmdInstance = console,
|
|
24
|
-
) => {
|
|
25
|
-
const gitRemoteHost = await getGitRemoteHost(host);
|
|
26
|
-
const gitlabToken = token || (await loadGitLabToken(gitRemoteHost, logger));
|
|
27
|
-
if (!gitlabToken?.length) {
|
|
28
|
-
throw new GitLabTokenMissingError();
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
try {
|
|
32
|
-
const result = await fetch(
|
|
33
|
-
`https://${gitRemoteHost}/api/v4/${resourcePath}`,
|
|
34
|
-
{
|
|
35
|
-
method,
|
|
36
|
-
headers: {
|
|
37
|
-
"Content-Type": "application/json",
|
|
38
|
-
"Private-Token": gitlabToken,
|
|
39
|
-
},
|
|
40
|
-
body: data ? JSON.stringify(data) : undefined,
|
|
41
|
-
},
|
|
42
|
-
);
|
|
43
|
-
const status = result.status;
|
|
44
|
-
|
|
45
|
-
if (status >= 200 && status < 400) {
|
|
46
|
-
if (result.headers.get("content-type") === "application/json") {
|
|
47
|
-
return result.json() as Promise<T>;
|
|
48
|
-
}
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
if (status === 404) {
|
|
52
|
-
throw new FetchGitLabError(
|
|
53
|
-
result,
|
|
54
|
-
{ resourcePath, data, method },
|
|
55
|
-
"not found",
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
throw new FetchGitLabError(
|
|
60
|
-
result,
|
|
61
|
-
{ resourcePath, data, method },
|
|
62
|
-
`Could not send request to gitlab api ${resourcePath}: ${status} "${result.statusText}".\nResponse: ${JSON.stringify(await result.json(), null, 2)}`,
|
|
63
|
-
);
|
|
64
|
-
} catch (error) {
|
|
65
|
-
if (error instanceof FetchGitLabError) {
|
|
66
|
-
throw error;
|
|
67
|
-
}
|
|
68
|
-
throw new FetchGitLabError(
|
|
69
|
-
undefined,
|
|
70
|
-
{ resourcePath, data, method, cause: error },
|
|
71
|
-
`Unknown error ${error}`,
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { LoggerCmdInstance } from "../log";
|
|
2
|
-
import { loadGitLabToken } from "./loadGitLabToken";
|
|
3
|
-
import type { GitLabApiDataOptional } from "./GitLabApiDataOptional";
|
|
4
|
-
import { getGitRemoteHostAndPath } from "../../git";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Lazy gather the GitLab api request data
|
|
8
|
-
*/
|
|
9
|
-
export const getGitLabHostPathToken = async (
|
|
10
|
-
{ token: inputToken, ...existing }: GitLabApiDataOptional = {},
|
|
11
|
-
logger: LoggerCmdInstance = console,
|
|
12
|
-
): Promise<{
|
|
13
|
-
/**
|
|
14
|
-
* The GitLab instance hostname
|
|
15
|
-
*/
|
|
16
|
-
host: string;
|
|
17
|
-
/**
|
|
18
|
-
* The GitLab project path
|
|
19
|
-
*/
|
|
20
|
-
path: string;
|
|
21
|
-
/**
|
|
22
|
-
* The GitLab personal access token (PAT)
|
|
23
|
-
* Note: The token may not be present in the stored preferences.
|
|
24
|
-
*/
|
|
25
|
-
token: string | undefined;
|
|
26
|
-
}> => {
|
|
27
|
-
const { gitRemotePath: path, gitRemoteHost: host } =
|
|
28
|
-
await getGitRemoteHostAndPath(existing);
|
|
29
|
-
const token = inputToken || (await loadGitLabToken(host, logger));
|
|
30
|
-
return { host, path, token: token || undefined };
|
|
31
|
-
};
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import type { LoggerCmdInstance } from "../log";
|
|
2
|
-
import { getPreferences, upsertPreferences } from "../preferences";
|
|
3
|
-
import { fetchGitLabApi } from "./fetchGitLabApi";
|
|
4
|
-
import { getGitLabHostPathToken } from "./getGitlabHostPathToken";
|
|
5
|
-
import type { GitLabApiDataOptional } from "./GitLabApiDataOptional";
|
|
6
|
-
|
|
7
|
-
export type GitLabProject = {
|
|
8
|
-
id: number;
|
|
9
|
-
web_url: string;
|
|
10
|
-
name: string;
|
|
11
|
-
name_with_namespace: string;
|
|
12
|
-
default_branch: string;
|
|
13
|
-
path: string;
|
|
14
|
-
path_with_namespace: string;
|
|
15
|
-
ssh_url_to_repo: string;
|
|
16
|
-
http_url_to_repo: string;
|
|
17
|
-
readme_url?: string;
|
|
18
|
-
build_timeout?: number;
|
|
19
|
-
container_registry_image_prefix?: string;
|
|
20
|
-
container_registry_enabled?: boolean;
|
|
21
|
-
last_activity_at?: Date;
|
|
22
|
-
created_at?: Date;
|
|
23
|
-
updated_at?: Date;
|
|
24
|
-
topics: string[];
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export const gitLabProjectByGitPath = async (
|
|
28
|
-
existing: GitLabApiDataOptional = {},
|
|
29
|
-
logger: LoggerCmdInstance = console,
|
|
30
|
-
) => {
|
|
31
|
-
const { host, path, token } = await getGitLabHostPathToken(existing, logger);
|
|
32
|
-
return fetchGitLabApi<GitLabProject>(
|
|
33
|
-
{
|
|
34
|
-
resourcePath: `projects/${encodeURIComponent(path)}`,
|
|
35
|
-
host,
|
|
36
|
-
token,
|
|
37
|
-
},
|
|
38
|
-
logger,
|
|
39
|
-
);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export const getGitLabProjectId = async (
|
|
43
|
-
existing: GitLabApiDataOptional = {},
|
|
44
|
-
logger: LoggerCmdInstance = console,
|
|
45
|
-
) => {
|
|
46
|
-
const [preferences, { host, path, token }] = await Promise.all([
|
|
47
|
-
getPreferences(logger),
|
|
48
|
-
getGitLabHostPathToken(existing, logger),
|
|
49
|
-
]);
|
|
50
|
-
const hostPathKey = `${host}/${path}`;
|
|
51
|
-
if (preferences.gitLabProjectIds[hostPathKey]) {
|
|
52
|
-
return preferences.gitLabProjectIds[hostPathKey];
|
|
53
|
-
}
|
|
54
|
-
const project = await gitLabProjectByGitPath({ token, host, path }, logger);
|
|
55
|
-
await upsertPreferences({ gitLabProjectIds: { [hostPathKey]: project.id } });
|
|
56
|
-
return project.id;
|
|
57
|
-
};
|