@gitbeaker/cli 43.0.0 → 43.1.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.
Files changed (2) hide show
  1. package/dist/index.mjs +30 -29
  2. package/package.json +4 -4
package/dist/index.mjs CHANGED
@@ -7,29 +7,30 @@ 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, depascalize } from "xcase";
11
- function param(value) {
12
- let cleaned = value;
13
- const exceptions = [
14
- "GitLabCI",
15
- "YML",
16
- "GPG",
17
- "SSH",
18
- "IId",
19
- "NPM",
20
- "NuGet",
21
- "DORA4",
22
- "LDAP",
23
- "CICD",
24
- "SAML",
25
- "SCIM",
26
- "PyPI"
27
- ];
28
- exceptions.filter((e) => value.includes(e)).forEach((ex) => {
29
- cleaned = cleaned.replace(ex, ex.charAt(0).toUpperCase() + ex.slice(1).toLowerCase());
10
+ import { camelize, depascalize } 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 normalizeTerm(value) {
29
+ let normalized = value;
30
+ Object.keys(NORMALIZED_EXCEPTION_TERMS).filter((e) => value.includes(e)).forEach((ex) => {
31
+ normalized = normalized.replace(ex, NORMALIZED_EXCEPTION_TERMS[ex]);
30
32
  });
31
- const decamelized = decamelize(cleaned, "-");
32
- return decamelized !== cleaned ? decamelized : depascalize(cleaned, "-");
33
+ return depascalize(normalized, "-");
33
34
  }
34
35
  function normalizeEnviromentVariables(env) {
35
36
  const normalized = {};
@@ -110,7 +111,7 @@ function getGlobalConfig(env = process.env) {
110
111
  },
111
112
  "gb-sudo": {
112
113
  alias: "gl-sudo",
113
- desc: "[Sudo](https://docs.gitlab.com/ee/api/#sudo) query parameter",
114
+ desc: "Sudo query parameter - https://docs.gitlab.com/ee/api/#sudo",
114
115
  type: "string",
115
116
  defaultValue: normalEnv.GITBEAKER_SUDO
116
117
  },
@@ -128,13 +129,13 @@ function getGlobalConfig(env = process.env) {
128
129
  },
129
130
  "gb-profile-token": {
130
131
  alias: "gl-profile-token",
131
- desc: "[Requests Profiles Token](https://docs.gitlab.com/ee/administration/monitoring/performance/request_profiling.html)",
132
+ desc: `Requests Profiles Token - https://docs.gitlab.com/ee/administration/monitoring/performance/request_profiling.html`,
132
133
  type: "string",
133
134
  defaultValue: normalEnv.GITBEAKER_PROFILE_TOKEN
134
135
  },
135
136
  "gb-profile-mode": {
136
137
  alias: "gl-profile-mode",
137
- desc: "[Requests Profiles Token](https://docs.gitlab.com/ee/administration/monitoring/performance/request_profiling.html)",
138
+ desc: "Requests Profiles Token - https://docs.gitlab.com/ee/administration/monitoring/performance/request_profiling.html",
138
139
  type: "string",
139
140
  defaultValue: normalEnv.GITBEAKER_PROFILE_MODE
140
141
  }
@@ -148,7 +149,7 @@ function getExposedAPIs(map) {
148
149
  // src/cli.ts
149
150
  function setupAPIMethods(setupArgs, methodArgs) {
150
151
  methodArgs.forEach((name) => {
151
- setupArgs.positional(`[--${param(name)}] <${param(name)}>`, {
152
+ setupArgs.positional(`[--${normalizeTerm(name)}] <${normalizeTerm(name)}>`, {
152
153
  group: "Required Options",
153
154
  type: "string"
154
155
  });
@@ -171,9 +172,9 @@ function setupAPIs(setupArgs, apiName, methods) {
171
172
  ...v
172
173
  });
173
174
  });
174
- for (let i = 1; i < methods.length; i += 1) {
175
+ for (let i = 0; i < methods.length; i += 1) {
175
176
  const method = methods[i];
176
- setupArgs.command(param(method.name), {
177
+ setupArgs.command(normalizeTerm(method.name), {
177
178
  setup: (setupMethodArgs) => setupAPIMethods(setupMethodArgs, method.args),
178
179
  run: (args, ctx) => runAPIMethod(ctx, args, apiName, method)
179
180
  });
@@ -206,7 +207,7 @@ cli.command("*", (argv, ctx) => {
206
207
  });
207
208
  var exposedAPIs = getExposedAPIs(API_MAP);
208
209
  Object.entries(exposedAPIs).forEach(([apiName, methods]) => {
209
- cli.command(param(apiName), {
210
+ cli.command(normalizeTerm(apiName), {
210
211
  desc: `The ${apiName} API`,
211
212
  setup: (setupArgs) => setupAPIs(setupArgs, apiName, methods)
212
213
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitbeaker/cli",
3
- "version": "43.0.0",
3
+ "version": "43.1.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.0.0",
43
- "@gitbeaker/rest": "^43.0.0",
42
+ "@gitbeaker/core": "^43.1.0",
43
+ "@gitbeaker/rest": "^43.1.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": "2ae1422a257c0dfe21da6bbfd0f9fd63ea510e85"
52
+ "gitHead": "095f01fd08b131e05910667511276bcafae9888c"
53
53
  }