@codacy/verity-cli 0.27.0-experimental.8f12b5a → 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 +15 -30
- 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 {
|
|
@@ -11122,23 +11103,20 @@ async function waitForEnter(prompt) {
|
|
|
11122
11103
|
}
|
|
11123
11104
|
}
|
|
11124
11105
|
async function ensureAppInstalled(owner, repo, token) {
|
|
11125
|
-
|
|
11106
|
+
const notInstalledError = {
|
|
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
|
+
};
|
|
11126
11111
|
const maxAttempts = 3;
|
|
11127
11112
|
for (let attempt = 1; ; attempt++) {
|
|
11128
11113
|
const visible = await githubCanSeeRepo(owner, repo, token);
|
|
11129
11114
|
if (!visible.ok) return { ok: true, data: void 0 };
|
|
11130
11115
|
if (visible.data) return { ok: true, data: void 0 };
|
|
11131
|
-
if (
|
|
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
|
-
}
|
|
11116
|
+
if (!isInteractive() || attempt >= maxAttempts) return notInstalledError;
|
|
11139
11117
|
printWarn(`The Verity GitHub App can't see ${owner}/${repo} yet.`);
|
|
11140
11118
|
printInfo(`Install it on "${owner}" (grant access to this repo):`);
|
|
11141
|
-
printInfo(` ${
|
|
11119
|
+
printInfo(` ${GITHUB_APP_INSTALL_URL}`);
|
|
11142
11120
|
await waitForEnter("Press Enter once installed to retry\u2026 ");
|
|
11143
11121
|
}
|
|
11144
11122
|
}
|
|
@@ -11151,6 +11129,13 @@ async function registerProject(opts) {
|
|
|
11151
11129
|
return { ok: false, error: `Provider '${parsed.provider}' is not supported yet \u2014 GitHub only for now.` };
|
|
11152
11130
|
}
|
|
11153
11131
|
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
|
+
}
|
|
11154
11139
|
const providerAuth = await githubDeviceFlow();
|
|
11155
11140
|
if (!providerAuth.ok) {
|
|
11156
11141
|
return { ok: false, error: providerAuth.error };
|
|
@@ -17161,7 +17146,7 @@ function registerTelemetryCommands(program2) {
|
|
|
17161
17146
|
}
|
|
17162
17147
|
|
|
17163
17148
|
// src/cli.ts
|
|
17164
|
-
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");
|
|
17165
17150
|
registerAuthCommands(program);
|
|
17166
17151
|
registerHooksCommands(program);
|
|
17167
17152
|
registerIntentCommands(program);
|