@codacy/gate-cli 0.14.2 → 0.14.3
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/bin/gate.js +27 -7
- package/package.json +1 -1
package/bin/gate.js
CHANGED
|
@@ -10627,7 +10627,18 @@ function rotateIfNeeded(file) {
|
|
|
10627
10627
|
|
|
10628
10628
|
// src/lib/api-client.ts
|
|
10629
10629
|
async function apiRequest(options) {
|
|
10630
|
-
const {
|
|
10630
|
+
const {
|
|
10631
|
+
method,
|
|
10632
|
+
path,
|
|
10633
|
+
serviceUrl,
|
|
10634
|
+
token,
|
|
10635
|
+
body,
|
|
10636
|
+
verbose,
|
|
10637
|
+
timeout = 9e4,
|
|
10638
|
+
cmd = "unknown",
|
|
10639
|
+
retry = false,
|
|
10640
|
+
encodeBody = false
|
|
10641
|
+
} = options;
|
|
10631
10642
|
const url = `${serviceUrl}${path}`;
|
|
10632
10643
|
const headers = {
|
|
10633
10644
|
"Content-Type": "application/json"
|
|
@@ -10636,13 +10647,20 @@ async function apiRequest(options) {
|
|
|
10636
10647
|
headers["Authorization"] = `Bearer ${token}`;
|
|
10637
10648
|
}
|
|
10638
10649
|
printVerbose(`${method} ${url}`, verbose);
|
|
10639
|
-
|
|
10640
|
-
if (body) {
|
|
10650
|
+
let serializedBody;
|
|
10651
|
+
if (body !== void 0 && body !== null) {
|
|
10652
|
+
const innerJson = JSON.stringify(body);
|
|
10653
|
+
if (encodeBody) {
|
|
10654
|
+
const payload = Buffer.from(innerJson, "utf8").toString("base64");
|
|
10655
|
+
serializedBody = JSON.stringify({ encoding: "base64", payload });
|
|
10656
|
+
} else {
|
|
10657
|
+
serializedBody = innerJson;
|
|
10658
|
+
}
|
|
10641
10659
|
printVerbose(`Body: ${serializedBody.slice(0, 500)}`, verbose);
|
|
10642
10660
|
}
|
|
10643
10661
|
const startedAt = Date.now();
|
|
10644
10662
|
const bodyBytes = serializedBody ? Buffer.byteLength(serializedBody) : 0;
|
|
10645
|
-
const logBase = { cmd, method, url, body_bytes: bodyBytes, retry };
|
|
10663
|
+
const logBase = { cmd, method, url, body_bytes: bodyBytes, retry, encoded: encodeBody };
|
|
10646
10664
|
let response;
|
|
10647
10665
|
try {
|
|
10648
10666
|
response = await fetch(url, {
|
|
@@ -12540,7 +12558,8 @@ async function runAnalyze(opts, globals) {
|
|
|
12540
12558
|
body: requestBody,
|
|
12541
12559
|
verbose: globals.verbose,
|
|
12542
12560
|
timeout: ANALYZE_TIMEOUT_MS,
|
|
12543
|
-
cmd: "analyze"
|
|
12561
|
+
cmd: "analyze",
|
|
12562
|
+
encodeBody: true
|
|
12544
12563
|
});
|
|
12545
12564
|
if (!result.ok && (result.category === "network" || result.category === "timeout")) {
|
|
12546
12565
|
logEvent("analyze_warm_retry", { first_error: result.error, category: result.category });
|
|
@@ -12562,7 +12581,8 @@ async function runAnalyze(opts, globals) {
|
|
|
12562
12581
|
verbose: globals.verbose,
|
|
12563
12582
|
timeout: ANALYZE_TIMEOUT_MS,
|
|
12564
12583
|
cmd: "analyze",
|
|
12565
|
-
retry: true
|
|
12584
|
+
retry: true,
|
|
12585
|
+
encodeBody: true
|
|
12566
12586
|
});
|
|
12567
12587
|
}
|
|
12568
12588
|
if (!result.ok) {
|
|
@@ -12928,7 +12948,7 @@ function registerInitCommand(program2) {
|
|
|
12928
12948
|
}
|
|
12929
12949
|
|
|
12930
12950
|
// src/cli.ts
|
|
12931
|
-
program.name("gate").description("CLI for GATE.md quality gate service").version("0.14.
|
|
12951
|
+
program.name("gate").description("CLI for GATE.md quality gate service").version("0.14.3").option("--token <token>", "Override authentication token").option("--service-url <url>", "Override service URL").option("--verbose", "Log HTTP requests/responses to stderr");
|
|
12932
12952
|
registerAuthCommands(program);
|
|
12933
12953
|
registerHooksCommands(program);
|
|
12934
12954
|
registerIntentCommands(program);
|