@codacy/verity-cli 0.27.0-experimental.e0a2105 → 0.27.1-experimental.f7b7eba
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 +30 -15
- package/package.json +1 -1
package/bin/verity.js
CHANGED
|
@@ -10479,6 +10479,9 @@ 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
|
+
}
|
|
10482
10485
|
|
|
10483
10486
|
// src/lib/auth.ts
|
|
10484
10487
|
async function resolveToken(flagToken) {
|
|
@@ -10755,6 +10758,22 @@ var readline = __toESM(require("node:readline/promises"));
|
|
|
10755
10758
|
// src/lib/provider-auth.ts
|
|
10756
10759
|
var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
10757
10760
|
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
|
+
}
|
|
10758
10777
|
async function githubCanSeeRepo(owner, repo, token) {
|
|
10759
10778
|
let res;
|
|
10760
10779
|
try {
|
|
@@ -11103,20 +11122,23 @@ async function waitForEnter(prompt) {
|
|
|
11103
11122
|
}
|
|
11104
11123
|
}
|
|
11105
11124
|
async function ensureAppInstalled(owner, repo, token) {
|
|
11106
|
-
|
|
11107
|
-
ok: false,
|
|
11108
|
-
error: `The Verity GitHub App can't see ${owner}/${repo}. Install it on "${owner}" and grant access to this repository, then re-run:
|
|
11109
|
-
${GITHUB_APP_INSTALL_URL}`
|
|
11110
|
-
};
|
|
11125
|
+
let installUrl = null;
|
|
11111
11126
|
const maxAttempts = 3;
|
|
11112
11127
|
for (let attempt = 1; ; attempt++) {
|
|
11113
11128
|
const visible = await githubCanSeeRepo(owner, repo, token);
|
|
11114
11129
|
if (!visible.ok) return { ok: true, data: void 0 };
|
|
11115
11130
|
if (visible.data) return { ok: true, data: void 0 };
|
|
11116
|
-
if (
|
|
11131
|
+
if (installUrl === null) installUrl = githubAppInstallUrl(await githubAccountId(owner));
|
|
11132
|
+
if (!isInteractive() || attempt >= maxAttempts) {
|
|
11133
|
+
return {
|
|
11134
|
+
ok: false,
|
|
11135
|
+
error: `The Verity GitHub App can't see ${owner}/${repo}. Install it on "${owner}" and grant access to this repository, then re-run:
|
|
11136
|
+
${installUrl}`
|
|
11137
|
+
};
|
|
11138
|
+
}
|
|
11117
11139
|
printWarn(`The Verity GitHub App can't see ${owner}/${repo} yet.`);
|
|
11118
11140
|
printInfo(`Install it on "${owner}" (grant access to this repo):`);
|
|
11119
|
-
printInfo(` ${
|
|
11141
|
+
printInfo(` ${installUrl}`);
|
|
11120
11142
|
await waitForEnter("Press Enter once installed to retry\u2026 ");
|
|
11121
11143
|
}
|
|
11122
11144
|
}
|
|
@@ -11129,13 +11151,6 @@ async function registerProject(opts) {
|
|
|
11129
11151
|
return { ok: false, error: `Provider '${parsed.provider}' is not supported yet \u2014 GitHub only for now.` };
|
|
11130
11152
|
}
|
|
11131
11153
|
const usingTokenOverride = Boolean(process.env.VERITY_PROVIDER_TOKEN);
|
|
11132
|
-
if (!usingTokenOverride && isInteractive()) {
|
|
11133
|
-
printInfo("");
|
|
11134
|
-
printInfo(`Verity uses a read-only GitHub App to verify write access to ${parsed.owner}/${parsed.repo}.`);
|
|
11135
|
-
printInfo(`Install it on "${parsed.owner}" (grant access to this repo) if you haven't already:`);
|
|
11136
|
-
printInfo(` ${GITHUB_APP_INSTALL_URL}`);
|
|
11137
|
-
await waitForEnter("Press Enter to continue to GitHub authorization\u2026 ");
|
|
11138
|
-
}
|
|
11139
11154
|
const providerAuth = await githubDeviceFlow();
|
|
11140
11155
|
if (!providerAuth.ok) {
|
|
11141
11156
|
return { ok: false, error: providerAuth.error };
|
|
@@ -17146,7 +17161,7 @@ function registerTelemetryCommands(program2) {
|
|
|
17146
17161
|
}
|
|
17147
17162
|
|
|
17148
17163
|
// src/cli.ts
|
|
17149
|
-
program.name("verity").description("CLI for Verity quality gate service").version("0.27.
|
|
17164
|
+
program.name("verity").description("CLI for Verity quality gate service").version("0.27.1-experimental.f7b7eba").option("--token <token>", "Override authentication token").option("--service-url <url>", "Override service URL").option("--verbose", "Log HTTP requests/responses to stderr");
|
|
17150
17165
|
registerAuthCommands(program);
|
|
17151
17166
|
registerHooksCommands(program);
|
|
17152
17167
|
registerIntentCommands(program);
|