@codacy/verity-cli 0.27.0-experimental.8f12b5a → 0.27.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.
- package/bin/verity.js +4 -85
- package/package.json +1 -1
package/bin/verity.js
CHANGED
|
@@ -10473,15 +10473,10 @@ var SECURITY_PATTERNS = [
|
|
|
10473
10473
|
/Dockerfile/
|
|
10474
10474
|
];
|
|
10475
10475
|
var PROD_SERVICE_URL = "https://ofcamwrjwrkazqvdchko.supabase.co/functions/v1";
|
|
10476
|
-
var DEFAULT_SERVICE_URL = "
|
|
10476
|
+
var DEFAULT_SERVICE_URL = "".length > 0 ? "" : PROD_SERVICE_URL;
|
|
10477
10477
|
var GITHUB_CLIENT_ID = "Iv23li88HxAi3ZrbYzWh";
|
|
10478
10478
|
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
|
-
var GITHUB_APP_SLUG = "verity-auth";
|
|
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
10480
|
|
|
10486
10481
|
// src/lib/auth.ts
|
|
10487
10482
|
async function resolveToken(flagToken) {
|
|
@@ -10753,48 +10748,10 @@ function analyzeRequest(options) {
|
|
|
10753
10748
|
// src/lib/register.ts
|
|
10754
10749
|
var import_promises3 = require("node:fs/promises");
|
|
10755
10750
|
var import_node_path3 = require("node:path");
|
|
10756
|
-
var readline = __toESM(require("node:readline/promises"));
|
|
10757
10751
|
|
|
10758
10752
|
// src/lib/provider-auth.ts
|
|
10759
10753
|
var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
10760
10754
|
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
|
-
async function githubCanSeeRepo(owner, repo, token) {
|
|
10778
|
-
let res;
|
|
10779
|
-
try {
|
|
10780
|
-
res = await fetch(
|
|
10781
|
-
`https://api.github.com/repos/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}`,
|
|
10782
|
-
{
|
|
10783
|
-
headers: {
|
|
10784
|
-
Authorization: `Bearer ${token}`,
|
|
10785
|
-
Accept: "application/vnd.github+json",
|
|
10786
|
-
"X-GitHub-Api-Version": "2022-11-28",
|
|
10787
|
-
"User-Agent": "verity-cli"
|
|
10788
|
-
}
|
|
10789
|
-
}
|
|
10790
|
-
);
|
|
10791
|
-
} catch (err) {
|
|
10792
|
-
return { ok: false, error: `Network error contacting GitHub: ${err.message}` };
|
|
10793
|
-
}
|
|
10794
|
-
if (res.status === 404) return { ok: true, data: false };
|
|
10795
|
-
if (res.ok) return { ok: true, data: true };
|
|
10796
|
-
return { ok: false, error: `GitHub repo lookup failed (HTTP ${res.status})` };
|
|
10797
|
-
}
|
|
10798
10755
|
async function githubDeviceFlow() {
|
|
10799
10756
|
const override = process.env.VERITY_PROVIDER_TOKEN;
|
|
10800
10757
|
if (override) return { ok: true, data: override };
|
|
@@ -11111,37 +11068,6 @@ function listTrackedFiles() {
|
|
|
11111
11068
|
}
|
|
11112
11069
|
|
|
11113
11070
|
// src/lib/register.ts
|
|
11114
|
-
var isInteractive = () => Boolean(process.stdin.isTTY && process.stdout.isTTY);
|
|
11115
|
-
async function waitForEnter(prompt) {
|
|
11116
|
-
if (!isInteractive()) return;
|
|
11117
|
-
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
11118
|
-
try {
|
|
11119
|
-
await rl.question(prompt);
|
|
11120
|
-
} finally {
|
|
11121
|
-
rl.close();
|
|
11122
|
-
}
|
|
11123
|
-
}
|
|
11124
|
-
async function ensureAppInstalled(owner, repo, token) {
|
|
11125
|
-
let installUrl = null;
|
|
11126
|
-
const maxAttempts = 3;
|
|
11127
|
-
for (let attempt = 1; ; attempt++) {
|
|
11128
|
-
const visible = await githubCanSeeRepo(owner, repo, token);
|
|
11129
|
-
if (!visible.ok) return { ok: true, data: void 0 };
|
|
11130
|
-
if (visible.data) return { ok: true, data: void 0 };
|
|
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
|
-
}
|
|
11139
|
-
printWarn(`The Verity GitHub App can't see ${owner}/${repo} yet.`);
|
|
11140
|
-
printInfo(`Install it on "${owner}" (grant access to this repo):`);
|
|
11141
|
-
printInfo(` ${installUrl}`);
|
|
11142
|
-
await waitForEnter("Press Enter once installed to retry\u2026 ");
|
|
11143
|
-
}
|
|
11144
|
-
}
|
|
11145
11071
|
async function registerProject(opts) {
|
|
11146
11072
|
const parsed = parseRemote(opts.remote);
|
|
11147
11073
|
if (!parsed) {
|
|
@@ -11150,18 +11076,11 @@ async function registerProject(opts) {
|
|
|
11150
11076
|
if (parsed.provider !== "github") {
|
|
11151
11077
|
return { ok: false, error: `Provider '${parsed.provider}' is not supported yet \u2014 GitHub only for now.` };
|
|
11152
11078
|
}
|
|
11153
|
-
const usingTokenOverride = Boolean(process.env.VERITY_PROVIDER_TOKEN);
|
|
11154
11079
|
const providerAuth = await githubDeviceFlow();
|
|
11155
11080
|
if (!providerAuth.ok) {
|
|
11156
11081
|
return { ok: false, error: providerAuth.error };
|
|
11157
11082
|
}
|
|
11158
11083
|
const providerToken = providerAuth.data;
|
|
11159
|
-
if (!usingTokenOverride) {
|
|
11160
|
-
const installed = await ensureAppInstalled(parsed.owner, parsed.repo, providerToken);
|
|
11161
|
-
if (!installed.ok) {
|
|
11162
|
-
return { ok: false, error: installed.error };
|
|
11163
|
-
}
|
|
11164
|
-
}
|
|
11165
11084
|
const result = await apiRequest({
|
|
11166
11085
|
method: "POST",
|
|
11167
11086
|
path: "/auth/register",
|
|
@@ -15928,7 +15847,7 @@ var import_node_fs24 = require("node:fs");
|
|
|
15928
15847
|
var import_promises13 = require("node:fs/promises");
|
|
15929
15848
|
var import_node_path18 = require("node:path");
|
|
15930
15849
|
var import_node_child_process9 = require("node:child_process");
|
|
15931
|
-
var
|
|
15850
|
+
var readline = __toESM(require("node:readline/promises"));
|
|
15932
15851
|
|
|
15933
15852
|
// src/commands/migrate.ts
|
|
15934
15853
|
var import_node_fs23 = require("node:fs");
|
|
@@ -16210,7 +16129,7 @@ function registerMigrateCommand(program2) {
|
|
|
16210
16129
|
// src/commands/init.ts
|
|
16211
16130
|
async function promptYes(question) {
|
|
16212
16131
|
if (!process.stdin.isTTY || !process.stdout.isTTY) return false;
|
|
16213
|
-
const rl =
|
|
16132
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
16214
16133
|
try {
|
|
16215
16134
|
const answer = (await rl.question(question)).trim().toLowerCase();
|
|
16216
16135
|
return answer === "" || answer === "y" || answer === "yes";
|
|
@@ -17161,7 +17080,7 @@ function registerTelemetryCommands(program2) {
|
|
|
17161
17080
|
}
|
|
17162
17081
|
|
|
17163
17082
|
// src/cli.ts
|
|
17164
|
-
program.name("verity").description("CLI for Verity quality gate service").version("0.27.0
|
|
17083
|
+
program.name("verity").description("CLI for Verity quality gate service").version("0.27.0").option("--token <token>", "Override authentication token").option("--service-url <url>", "Override service URL").option("--verbose", "Log HTTP requests/responses to stderr");
|
|
17165
17084
|
registerAuthCommands(program);
|
|
17166
17085
|
registerHooksCommands(program);
|
|
17167
17086
|
registerIntentCommands(program);
|