@codacy/verity-cli 0.27.0-experimental.1106a16 → 0.27.0-experimental.e0a2105
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/verity.js +6 -27
- package/package.json +1 -1
package/bin/verity.js
CHANGED
|
@@ -10479,9 +10479,6 @@ var GITHUB_DEVICE_CODE_URL = "https://github.com/login/device/code";
|
|
|
10479
10479
|
var GITHUB_ACCESS_TOKEN_URL = "https://github.com/login/oauth/access_token";
|
|
10480
10480
|
var GITHUB_APP_SLUG = "verity-auth";
|
|
10481
10481
|
var GITHUB_APP_INSTALL_URL = `https://github.com/apps/${GITHUB_APP_SLUG}/installations/new`;
|
|
10482
|
-
function githubAppInstallUrl(accountId) {
|
|
10483
|
-
return accountId != null ? `https://github.com/apps/${GITHUB_APP_SLUG}/installations/new/permissions?target_id=${accountId}` : GITHUB_APP_INSTALL_URL;
|
|
10484
|
-
}
|
|
10485
10482
|
|
|
10486
10483
|
// src/lib/auth.ts
|
|
10487
10484
|
async function resolveToken(flagToken) {
|
|
@@ -10758,22 +10755,6 @@ var readline = __toESM(require("node:readline/promises"));
|
|
|
10758
10755
|
// src/lib/provider-auth.ts
|
|
10759
10756
|
var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
10760
10757
|
var form = (fields) => new URLSearchParams(fields).toString();
|
|
10761
|
-
async function githubAccountId(owner) {
|
|
10762
|
-
try {
|
|
10763
|
-
const res = await fetch(`https://api.github.com/users/${encodeURIComponent(owner)}`, {
|
|
10764
|
-
headers: {
|
|
10765
|
-
Accept: "application/vnd.github+json",
|
|
10766
|
-
"X-GitHub-Api-Version": "2022-11-28",
|
|
10767
|
-
"User-Agent": "verity-cli"
|
|
10768
|
-
}
|
|
10769
|
-
});
|
|
10770
|
-
if (!res.ok) return null;
|
|
10771
|
-
const body = await res.json();
|
|
10772
|
-
return typeof body.id === "number" ? body.id : null;
|
|
10773
|
-
} catch {
|
|
10774
|
-
return null;
|
|
10775
|
-
}
|
|
10776
|
-
}
|
|
10777
10758
|
async function githubCanSeeRepo(owner, repo, token) {
|
|
10778
10759
|
let res;
|
|
10779
10760
|
try {
|
|
@@ -11121,11 +11102,11 @@ async function waitForEnter(prompt) {
|
|
|
11121
11102
|
rl.close();
|
|
11122
11103
|
}
|
|
11123
11104
|
}
|
|
11124
|
-
async function ensureAppInstalled(owner, repo, token
|
|
11105
|
+
async function ensureAppInstalled(owner, repo, token) {
|
|
11125
11106
|
const notInstalledError = {
|
|
11126
11107
|
ok: false,
|
|
11127
11108
|
error: `The Verity GitHub App can't see ${owner}/${repo}. Install it on "${owner}" and grant access to this repository, then re-run:
|
|
11128
|
-
${
|
|
11109
|
+
${GITHUB_APP_INSTALL_URL}`
|
|
11129
11110
|
};
|
|
11130
11111
|
const maxAttempts = 3;
|
|
11131
11112
|
for (let attempt = 1; ; attempt++) {
|
|
@@ -11135,7 +11116,7 @@ async function ensureAppInstalled(owner, repo, token, installUrl) {
|
|
|
11135
11116
|
if (!isInteractive() || attempt >= maxAttempts) return notInstalledError;
|
|
11136
11117
|
printWarn(`The Verity GitHub App can't see ${owner}/${repo} yet.`);
|
|
11137
11118
|
printInfo(`Install it on "${owner}" (grant access to this repo):`);
|
|
11138
|
-
printInfo(` ${
|
|
11119
|
+
printInfo(` ${GITHUB_APP_INSTALL_URL}`);
|
|
11139
11120
|
await waitForEnter("Press Enter once installed to retry\u2026 ");
|
|
11140
11121
|
}
|
|
11141
11122
|
}
|
|
@@ -11148,13 +11129,11 @@ async function registerProject(opts) {
|
|
|
11148
11129
|
return { ok: false, error: `Provider '${parsed.provider}' is not supported yet \u2014 GitHub only for now.` };
|
|
11149
11130
|
}
|
|
11150
11131
|
const usingTokenOverride = Boolean(process.env.VERITY_PROVIDER_TOKEN);
|
|
11151
|
-
const ownerId = usingTokenOverride ? null : await githubAccountId(parsed.owner);
|
|
11152
|
-
const installUrl = githubAppInstallUrl(ownerId);
|
|
11153
11132
|
if (!usingTokenOverride && isInteractive()) {
|
|
11154
11133
|
printInfo("");
|
|
11155
11134
|
printInfo(`Verity uses a read-only GitHub App to verify write access to ${parsed.owner}/${parsed.repo}.`);
|
|
11156
11135
|
printInfo(`Install it on "${parsed.owner}" (grant access to this repo) if you haven't already:`);
|
|
11157
|
-
printInfo(` ${
|
|
11136
|
+
printInfo(` ${GITHUB_APP_INSTALL_URL}`);
|
|
11158
11137
|
await waitForEnter("Press Enter to continue to GitHub authorization\u2026 ");
|
|
11159
11138
|
}
|
|
11160
11139
|
const providerAuth = await githubDeviceFlow();
|
|
@@ -11163,7 +11142,7 @@ async function registerProject(opts) {
|
|
|
11163
11142
|
}
|
|
11164
11143
|
const providerToken = providerAuth.data;
|
|
11165
11144
|
if (!usingTokenOverride) {
|
|
11166
|
-
const installed = await ensureAppInstalled(parsed.owner, parsed.repo, providerToken
|
|
11145
|
+
const installed = await ensureAppInstalled(parsed.owner, parsed.repo, providerToken);
|
|
11167
11146
|
if (!installed.ok) {
|
|
11168
11147
|
return { ok: false, error: installed.error };
|
|
11169
11148
|
}
|
|
@@ -17167,7 +17146,7 @@ function registerTelemetryCommands(program2) {
|
|
|
17167
17146
|
}
|
|
17168
17147
|
|
|
17169
17148
|
// src/cli.ts
|
|
17170
|
-
program.name("verity").description("CLI for Verity quality gate service").version("0.27.0-experimental.
|
|
17149
|
+
program.name("verity").description("CLI for Verity quality gate service").version("0.27.0-experimental.e0a2105").option("--token <token>", "Override authentication token").option("--service-url <url>", "Override service URL").option("--verbose", "Log HTTP requests/responses to stderr");
|
|
17171
17150
|
registerAuthCommands(program);
|
|
17172
17151
|
registerHooksCommands(program);
|
|
17173
17152
|
registerIntentCommands(program);
|