@codacy/verity-cli 0.27.0-experimental.e0a2105 → 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 -70
- package/package.json +1 -1
package/bin/verity.js
CHANGED
|
@@ -10473,12 +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
10480
|
|
|
10483
10481
|
// src/lib/auth.ts
|
|
10484
10482
|
async function resolveToken(flagToken) {
|
|
@@ -10750,32 +10748,10 @@ function analyzeRequest(options) {
|
|
|
10750
10748
|
// src/lib/register.ts
|
|
10751
10749
|
var import_promises3 = require("node:fs/promises");
|
|
10752
10750
|
var import_node_path3 = require("node:path");
|
|
10753
|
-
var readline = __toESM(require("node:readline/promises"));
|
|
10754
10751
|
|
|
10755
10752
|
// src/lib/provider-auth.ts
|
|
10756
10753
|
var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
10757
10754
|
var form = (fields) => new URLSearchParams(fields).toString();
|
|
10758
|
-
async function githubCanSeeRepo(owner, repo, token) {
|
|
10759
|
-
let res;
|
|
10760
|
-
try {
|
|
10761
|
-
res = await fetch(
|
|
10762
|
-
`https://api.github.com/repos/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}`,
|
|
10763
|
-
{
|
|
10764
|
-
headers: {
|
|
10765
|
-
Authorization: `Bearer ${token}`,
|
|
10766
|
-
Accept: "application/vnd.github+json",
|
|
10767
|
-
"X-GitHub-Api-Version": "2022-11-28",
|
|
10768
|
-
"User-Agent": "verity-cli"
|
|
10769
|
-
}
|
|
10770
|
-
}
|
|
10771
|
-
);
|
|
10772
|
-
} catch (err) {
|
|
10773
|
-
return { ok: false, error: `Network error contacting GitHub: ${err.message}` };
|
|
10774
|
-
}
|
|
10775
|
-
if (res.status === 404) return { ok: true, data: false };
|
|
10776
|
-
if (res.ok) return { ok: true, data: true };
|
|
10777
|
-
return { ok: false, error: `GitHub repo lookup failed (HTTP ${res.status})` };
|
|
10778
|
-
}
|
|
10779
10755
|
async function githubDeviceFlow() {
|
|
10780
10756
|
const override = process.env.VERITY_PROVIDER_TOKEN;
|
|
10781
10757
|
if (override) return { ok: true, data: override };
|
|
@@ -11092,34 +11068,6 @@ function listTrackedFiles() {
|
|
|
11092
11068
|
}
|
|
11093
11069
|
|
|
11094
11070
|
// src/lib/register.ts
|
|
11095
|
-
var isInteractive = () => Boolean(process.stdin.isTTY && process.stdout.isTTY);
|
|
11096
|
-
async function waitForEnter(prompt) {
|
|
11097
|
-
if (!isInteractive()) return;
|
|
11098
|
-
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
11099
|
-
try {
|
|
11100
|
-
await rl.question(prompt);
|
|
11101
|
-
} finally {
|
|
11102
|
-
rl.close();
|
|
11103
|
-
}
|
|
11104
|
-
}
|
|
11105
|
-
async function ensureAppInstalled(owner, repo, token) {
|
|
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
|
-
};
|
|
11111
|
-
const maxAttempts = 3;
|
|
11112
|
-
for (let attempt = 1; ; attempt++) {
|
|
11113
|
-
const visible = await githubCanSeeRepo(owner, repo, token);
|
|
11114
|
-
if (!visible.ok) return { ok: true, data: void 0 };
|
|
11115
|
-
if (visible.data) return { ok: true, data: void 0 };
|
|
11116
|
-
if (!isInteractive() || attempt >= maxAttempts) return notInstalledError;
|
|
11117
|
-
printWarn(`The Verity GitHub App can't see ${owner}/${repo} yet.`);
|
|
11118
|
-
printInfo(`Install it on "${owner}" (grant access to this repo):`);
|
|
11119
|
-
printInfo(` ${GITHUB_APP_INSTALL_URL}`);
|
|
11120
|
-
await waitForEnter("Press Enter once installed to retry\u2026 ");
|
|
11121
|
-
}
|
|
11122
|
-
}
|
|
11123
11071
|
async function registerProject(opts) {
|
|
11124
11072
|
const parsed = parseRemote(opts.remote);
|
|
11125
11073
|
if (!parsed) {
|
|
@@ -11128,25 +11076,11 @@ async function registerProject(opts) {
|
|
|
11128
11076
|
if (parsed.provider !== "github") {
|
|
11129
11077
|
return { ok: false, error: `Provider '${parsed.provider}' is not supported yet \u2014 GitHub only for now.` };
|
|
11130
11078
|
}
|
|
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
|
-
}
|
|
11139
11079
|
const providerAuth = await githubDeviceFlow();
|
|
11140
11080
|
if (!providerAuth.ok) {
|
|
11141
11081
|
return { ok: false, error: providerAuth.error };
|
|
11142
11082
|
}
|
|
11143
11083
|
const providerToken = providerAuth.data;
|
|
11144
|
-
if (!usingTokenOverride) {
|
|
11145
|
-
const installed = await ensureAppInstalled(parsed.owner, parsed.repo, providerToken);
|
|
11146
|
-
if (!installed.ok) {
|
|
11147
|
-
return { ok: false, error: installed.error };
|
|
11148
|
-
}
|
|
11149
|
-
}
|
|
11150
11084
|
const result = await apiRequest({
|
|
11151
11085
|
method: "POST",
|
|
11152
11086
|
path: "/auth/register",
|
|
@@ -15913,7 +15847,7 @@ var import_node_fs24 = require("node:fs");
|
|
|
15913
15847
|
var import_promises13 = require("node:fs/promises");
|
|
15914
15848
|
var import_node_path18 = require("node:path");
|
|
15915
15849
|
var import_node_child_process9 = require("node:child_process");
|
|
15916
|
-
var
|
|
15850
|
+
var readline = __toESM(require("node:readline/promises"));
|
|
15917
15851
|
|
|
15918
15852
|
// src/commands/migrate.ts
|
|
15919
15853
|
var import_node_fs23 = require("node:fs");
|
|
@@ -16195,7 +16129,7 @@ function registerMigrateCommand(program2) {
|
|
|
16195
16129
|
// src/commands/init.ts
|
|
16196
16130
|
async function promptYes(question) {
|
|
16197
16131
|
if (!process.stdin.isTTY || !process.stdout.isTTY) return false;
|
|
16198
|
-
const rl =
|
|
16132
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
16199
16133
|
try {
|
|
16200
16134
|
const answer = (await rl.question(question)).trim().toLowerCase();
|
|
16201
16135
|
return answer === "" || answer === "y" || answer === "yes";
|
|
@@ -17146,7 +17080,7 @@ function registerTelemetryCommands(program2) {
|
|
|
17146
17080
|
}
|
|
17147
17081
|
|
|
17148
17082
|
// src/cli.ts
|
|
17149
|
-
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");
|
|
17150
17084
|
registerAuthCommands(program);
|
|
17151
17085
|
registerHooksCommands(program);
|
|
17152
17086
|
registerIntentCommands(program);
|