@gitbeaker/cli 43.0.0 → 43.2.0
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/index.mjs +54 -39
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -7,31 +7,42 @@ import * as Gitbeaker from "@gitbeaker/rest";
|
|
|
7
7
|
import API_MAP from "@gitbeaker/core/map.json" with { type: "json" };
|
|
8
8
|
|
|
9
9
|
// src/utils.ts
|
|
10
|
-
import { camelize, decamelize
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
10
|
+
import { camelize, decamelize } from "xcase";
|
|
11
|
+
var NORMALIZED_EXCEPTION_TERMS = [
|
|
12
|
+
"GitLabCI",
|
|
13
|
+
"YML",
|
|
14
|
+
"GPG",
|
|
15
|
+
"SSH",
|
|
16
|
+
"IId",
|
|
17
|
+
"NPM",
|
|
18
|
+
"NuGet",
|
|
19
|
+
"DORA4",
|
|
20
|
+
"LDAP",
|
|
21
|
+
"CICD",
|
|
22
|
+
"SAML",
|
|
23
|
+
"SCIM",
|
|
24
|
+
"PyPI"
|
|
25
|
+
].reduce((prev, cur) => {
|
|
26
|
+
return { ...prev, [cur]: cur.charAt(0).toUpperCase() + cur.slice(1).toLowerCase() };
|
|
27
|
+
}, {});
|
|
28
|
+
function getCLISafeNormalizedTerm(term) {
|
|
29
|
+
if (term.length === 0) return term;
|
|
30
|
+
let normalized = term;
|
|
31
|
+
Object.entries(NORMALIZED_EXCEPTION_TERMS).filter(([k]) => term.includes(k)).forEach(([k, v]) => {
|
|
32
|
+
normalized = normalized.replace(k, v);
|
|
30
33
|
});
|
|
31
|
-
|
|
32
|
-
return
|
|
34
|
+
normalized = normalized.charAt(0).toLowerCase() + normalized.slice(1);
|
|
35
|
+
return decamelize(normalized, "-");
|
|
33
36
|
}
|
|
34
|
-
function
|
|
37
|
+
function getAPISafeNormalizedTerm(term) {
|
|
38
|
+
if (term.length === 0) return term;
|
|
39
|
+
let normalized = camelize(term.replace(/(gb|gl)-/g, ""), "-");
|
|
40
|
+
Object.entries(NORMALIZED_EXCEPTION_TERMS).filter(([, v]) => normalized.includes(v)).forEach(([k, v]) => {
|
|
41
|
+
normalized = normalized.replace(v, k);
|
|
42
|
+
});
|
|
43
|
+
return normalized;
|
|
44
|
+
}
|
|
45
|
+
function normalizeEnvVariables(env) {
|
|
35
46
|
const normalized = {};
|
|
36
47
|
const suffixes = [
|
|
37
48
|
"TOKEN",
|
|
@@ -57,11 +68,12 @@ function buildArgumentObjects(globalConfig, method, rawArgs) {
|
|
|
57
68
|
const initArgs = {};
|
|
58
69
|
Object.entries(rawArgs).forEach(([argName, value]) => {
|
|
59
70
|
if (ignoreOptions.includes(argName) || value == null) return;
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
else
|
|
71
|
+
const term = argName.replace("gl-", "gb-");
|
|
72
|
+
const normalized = getAPISafeNormalizedTerm(term);
|
|
73
|
+
if (globalConfig[term]) {
|
|
74
|
+
initArgs[normalized] = value;
|
|
75
|
+
} else if (method.args.includes(normalized)) coreArgs[normalized] = value;
|
|
76
|
+
else optionalArgs[normalized] = value;
|
|
65
77
|
});
|
|
66
78
|
return {
|
|
67
79
|
initArgs,
|
|
@@ -82,7 +94,7 @@ function getDisplayConfig(globalConfig) {
|
|
|
82
94
|
return display;
|
|
83
95
|
}
|
|
84
96
|
function getGlobalConfig(env = process.env) {
|
|
85
|
-
const normalEnv =
|
|
97
|
+
const normalEnv = normalizeEnvVariables(env);
|
|
86
98
|
return {
|
|
87
99
|
"gb-token": {
|
|
88
100
|
alias: "gl-token",
|
|
@@ -110,7 +122,7 @@ function getGlobalConfig(env = process.env) {
|
|
|
110
122
|
},
|
|
111
123
|
"gb-sudo": {
|
|
112
124
|
alias: "gl-sudo",
|
|
113
|
-
desc: "
|
|
125
|
+
desc: "Sudo query parameter - https://docs.gitlab.com/ee/api/#sudo",
|
|
114
126
|
type: "string",
|
|
115
127
|
defaultValue: normalEnv.GITBEAKER_SUDO
|
|
116
128
|
},
|
|
@@ -128,13 +140,13 @@ function getGlobalConfig(env = process.env) {
|
|
|
128
140
|
},
|
|
129
141
|
"gb-profile-token": {
|
|
130
142
|
alias: "gl-profile-token",
|
|
131
|
-
desc:
|
|
143
|
+
desc: `Requests Profiles Token - https://docs.gitlab.com/ee/administration/monitoring/performance/request_profiling.html`,
|
|
132
144
|
type: "string",
|
|
133
145
|
defaultValue: normalEnv.GITBEAKER_PROFILE_TOKEN
|
|
134
146
|
},
|
|
135
147
|
"gb-profile-mode": {
|
|
136
148
|
alias: "gl-profile-mode",
|
|
137
|
-
desc: "
|
|
149
|
+
desc: "Requests Profiles Token - https://docs.gitlab.com/ee/administration/monitoring/performance/request_profiling.html",
|
|
138
150
|
type: "string",
|
|
139
151
|
defaultValue: normalEnv.GITBEAKER_PROFILE_MODE
|
|
140
152
|
}
|
|
@@ -148,10 +160,13 @@ function getExposedAPIs(map) {
|
|
|
148
160
|
// src/cli.ts
|
|
149
161
|
function setupAPIMethods(setupArgs, methodArgs) {
|
|
150
162
|
methodArgs.forEach((name) => {
|
|
151
|
-
setupArgs.positional(
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
163
|
+
setupArgs.positional(
|
|
164
|
+
`[--${getCLISafeNormalizedTerm(name)}] <${getCLISafeNormalizedTerm(name)}>`,
|
|
165
|
+
{
|
|
166
|
+
group: "Required Options",
|
|
167
|
+
type: "string"
|
|
168
|
+
}
|
|
169
|
+
);
|
|
155
170
|
});
|
|
156
171
|
return setupArgs;
|
|
157
172
|
}
|
|
@@ -171,9 +186,9 @@ function setupAPIs(setupArgs, apiName, methods) {
|
|
|
171
186
|
...v
|
|
172
187
|
});
|
|
173
188
|
});
|
|
174
|
-
for (let i =
|
|
189
|
+
for (let i = 0; i < methods.length; i += 1) {
|
|
175
190
|
const method = methods[i];
|
|
176
|
-
setupArgs.command(
|
|
191
|
+
setupArgs.command(getCLISafeNormalizedTerm(method.name), {
|
|
177
192
|
setup: (setupMethodArgs) => setupAPIMethods(setupMethodArgs, method.args),
|
|
178
193
|
run: (args, ctx) => runAPIMethod(ctx, args, apiName, method)
|
|
179
194
|
});
|
|
@@ -206,7 +221,7 @@ cli.command("*", (argv, ctx) => {
|
|
|
206
221
|
});
|
|
207
222
|
var exposedAPIs = getExposedAPIs(API_MAP);
|
|
208
223
|
Object.entries(exposedAPIs).forEach(([apiName, methods]) => {
|
|
209
|
-
cli.command(
|
|
224
|
+
cli.command(getCLISafeNormalizedTerm(apiName), {
|
|
210
225
|
desc: `The ${apiName} API`,
|
|
211
226
|
setup: (setupArgs) => setupAPIs(setupArgs, apiName, methods)
|
|
212
227
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gitbeaker/cli",
|
|
3
|
-
"version": "43.
|
|
3
|
+
"version": "43.2.0",
|
|
4
4
|
"description": "CLI implementation of the GitLab API.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"lint:fix": "yarn lint --fix"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@gitbeaker/core": "^43.
|
|
43
|
-
"@gitbeaker/rest": "^43.
|
|
42
|
+
"@gitbeaker/core": "^43.2.0",
|
|
43
|
+
"@gitbeaker/rest": "^43.2.0",
|
|
44
44
|
"chalk": "^5.4.1",
|
|
45
45
|
"sywac": "^1.3.0",
|
|
46
46
|
"xcase": "^2.0.1"
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"tsup": "^8.5.0",
|
|
50
50
|
"typescript": "^5.8.3"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "a0c0b9d3a8b6eeb155ec0c6c3dbee45f7ab31692"
|
|
53
53
|
}
|