@codacy/verity-cli 0.28.1-experimental.4d4616e → 0.28.1-experimental.4da2503
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 +40 -8
- package/package.json +1 -1
package/bin/verity.js
CHANGED
|
@@ -10636,14 +10636,14 @@ async function readGlobalCredential(remote) {
|
|
|
10636
10636
|
const parsed = parseCredentialLine(line);
|
|
10637
10637
|
if (parsed && parsed.remote === key) last = parsed.rec;
|
|
10638
10638
|
}
|
|
10639
|
-
if (last) return last;
|
|
10639
|
+
if (last) return { ...last, keyed: true };
|
|
10640
10640
|
}
|
|
10641
10641
|
let plain = null;
|
|
10642
10642
|
for (const line of lines) {
|
|
10643
10643
|
const parsed = parseCredentialLine(line);
|
|
10644
10644
|
if (parsed && parsed.remote === "") plain = parsed.rec;
|
|
10645
10645
|
}
|
|
10646
|
-
return plain;
|
|
10646
|
+
return plain ? { ...plain, keyed: false } : null;
|
|
10647
10647
|
}
|
|
10648
10648
|
async function upsertGlobalCredential(remote, rec) {
|
|
10649
10649
|
const path = globalCredentialsPath();
|
|
@@ -11218,7 +11218,13 @@ async function resolveToken(flagToken) {
|
|
|
11218
11218
|
if (rec) {
|
|
11219
11219
|
return {
|
|
11220
11220
|
ok: true,
|
|
11221
|
-
data: {
|
|
11221
|
+
data: {
|
|
11222
|
+
token: rec.token,
|
|
11223
|
+
source: "global",
|
|
11224
|
+
userId: rec.userId,
|
|
11225
|
+
email: rec.email,
|
|
11226
|
+
keyed: rec.keyed
|
|
11227
|
+
}
|
|
11222
11228
|
};
|
|
11223
11229
|
}
|
|
11224
11230
|
const local = await readLegacyLocalCredential();
|
|
@@ -11250,6 +11256,16 @@ function reverifyNudge(who) {
|
|
|
11250
11256
|
}
|
|
11251
11257
|
return null;
|
|
11252
11258
|
}
|
|
11259
|
+
function isLegacyPerRepoCredential(auth2) {
|
|
11260
|
+
return auth2.source === "local" || auth2.source === "global" && auth2.keyed === true;
|
|
11261
|
+
}
|
|
11262
|
+
async function shouldUpgradeOnLogin(auth2) {
|
|
11263
|
+
if (!isLegacyPerRepoCredential(auth2)) return false;
|
|
11264
|
+
if (auth2.userId == null) return true;
|
|
11265
|
+
const bare = await readGlobalCredential("");
|
|
11266
|
+
if (bare?.userId == null) return true;
|
|
11267
|
+
return bare.userId === auth2.userId;
|
|
11268
|
+
}
|
|
11253
11269
|
function authDenialRemedy(error) {
|
|
11254
11270
|
if (error.startsWith("STALE_VERIFICATION")) {
|
|
11255
11271
|
return {
|
|
@@ -11680,13 +11696,19 @@ function registerLoginCommand(program2) {
|
|
|
11680
11696
|
const who = await whoami(existing.data.token, serviceUrl, globals.verbose);
|
|
11681
11697
|
if (who.ok && who.data.logged_in) {
|
|
11682
11698
|
const nudge = reverifyNudge(who.data);
|
|
11683
|
-
|
|
11699
|
+
const upgrade = await shouldUpgradeOnLogin(existing.data);
|
|
11700
|
+
if (!nudge && !upgrade) {
|
|
11684
11701
|
printInfo(`Already logged in as ${who.data.email ?? `user #${who.data.user_id}`}. \u2713`);
|
|
11685
11702
|
printInfo(" Re-authenticate with: verity login --force");
|
|
11686
11703
|
return;
|
|
11687
11704
|
}
|
|
11688
|
-
|
|
11689
|
-
|
|
11705
|
+
if (nudge) {
|
|
11706
|
+
printWarn(nudge);
|
|
11707
|
+
printInfo("Re-verifying your repository access\u2026");
|
|
11708
|
+
} else {
|
|
11709
|
+
printInfo("You are signed in with a per-repository token (the old format).");
|
|
11710
|
+
printInfo(" Upgrading to a single login that covers every repository you can write to\u2026");
|
|
11711
|
+
}
|
|
11690
11712
|
} else if (who.ok && who.data.anonymous) {
|
|
11691
11713
|
printInfo("You have an anonymous token (the gate runs, but nothing is saved). Logging you in\u2026");
|
|
11692
11714
|
} else if (!who.ok) {
|
|
@@ -11737,14 +11759,24 @@ function registerLoginCommand(program2) {
|
|
|
11737
11759
|
const rec = await readGlobalCredential(remote);
|
|
11738
11760
|
if (rec && rec.token !== out.token) {
|
|
11739
11761
|
const otherBackend = rec.serviceUrl != null && rec.serviceUrl !== out.serviceUrl;
|
|
11762
|
+
const otherIdentity = rec.userId != null && out.userId != null && rec.userId !== out.userId;
|
|
11740
11763
|
if (otherBackend) {
|
|
11741
11764
|
printWarn(` Note: this repository is pinned to a different Verity service (${rec.serviceUrl})`);
|
|
11742
11765
|
printWarn(" by its own credential line, which takes precedence here \u2014 this login does not");
|
|
11743
11766
|
printWarn(" change that. To move the repository, remove its line from ~/.verity/credentials.");
|
|
11767
|
+
printWarn(' Until that line is removed, "verity login" here cannot fast-path and will run');
|
|
11768
|
+
printWarn(" the full GitHub flow every time.");
|
|
11769
|
+
} else if (otherIdentity) {
|
|
11770
|
+
printWarn(" Note: this repository uses a different account's credential, which takes");
|
|
11771
|
+
printWarn(' precedence here \u2014 this login leaves it in place, and "verity login" in this');
|
|
11772
|
+
printWarn(" repository will report that account. Remove its line from ~/.verity/credentials");
|
|
11773
|
+
printWarn(" only if you want this repository on the login you just completed.");
|
|
11744
11774
|
} else {
|
|
11745
11775
|
const kind = rec.userId != null ? "superseded per-repository" : "anonymous project-specific";
|
|
11746
11776
|
printWarn(` Note: this repository has a ${kind} credential that takes`);
|
|
11747
11777
|
printWarn(" precedence here. Remove its line from ~/.verity/credentials to use your login.");
|
|
11778
|
+
printWarn(' Until then, "verity login" in this repository re-runs the full GitHub flow');
|
|
11779
|
+
printWarn(" every time.");
|
|
11748
11780
|
}
|
|
11749
11781
|
}
|
|
11750
11782
|
}
|
|
@@ -16564,7 +16596,7 @@ function resolveTaskContext(opts) {
|
|
|
16564
16596
|
// src/lib/cli-version.ts
|
|
16565
16597
|
function cliVersion() {
|
|
16566
16598
|
try {
|
|
16567
|
-
return true ? "0.28.1-experimental.
|
|
16599
|
+
return true ? "0.28.1-experimental.4da2503" : "dev";
|
|
16568
16600
|
} catch {
|
|
16569
16601
|
return "dev";
|
|
16570
16602
|
}
|
|
@@ -20672,7 +20704,7 @@ function registerTelemetryCommands(program2) {
|
|
|
20672
20704
|
}
|
|
20673
20705
|
|
|
20674
20706
|
// src/cli.ts
|
|
20675
|
-
program.name("verity").description("CLI for Verity quality gate service").version("0.28.1-experimental.
|
|
20707
|
+
program.name("verity").description("CLI for Verity quality gate service").version("0.28.1-experimental.4da2503").option("--token <token>", "Override authentication token").option("--service-url <url>", "Override service URL").option("--verbose", "Log HTTP requests/responses to stderr").hook("preAction", async () => {
|
|
20676
20708
|
try {
|
|
20677
20709
|
await foldLegacyLocalCredential();
|
|
20678
20710
|
} catch {
|