@theholocron/cli 5.0.0-alpha.247 → 5.0.0-alpha.249
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/dist/cli.mjs +51 -58
- package/dist/cli.mjs.map +1 -1
- package/package.json +5 -5
package/dist/cli.mjs
CHANGED
|
@@ -9707,6 +9707,11 @@ function parseJson(raw) {
|
|
|
9707
9707
|
* it stops immediately, prints the `authUrl`, and returns — the operator
|
|
9708
9708
|
* approves it and re-runs; already-migrated packages are skipped on the next
|
|
9709
9709
|
* pass, so it's safe to resume from wherever it stopped.
|
|
9710
|
+
*
|
|
9711
|
+
* A package is skipped only when BOTH its bound file and its bound repository (compared
|
|
9712
|
+
* case-insensitively) already match: a package folded in from another repo keeps its
|
|
9713
|
+
* filename but is still bound to the old repo (#1221). `--dry-run` does the same read-only
|
|
9714
|
+
* `trust list` per package and reports what the real run would do, without revoking or creating.
|
|
9710
9715
|
*/
|
|
9711
9716
|
async function runSyncTrust(input) {
|
|
9712
9717
|
const print = input.print ?? ((line) => console.log(line));
|
|
@@ -9736,54 +9741,68 @@ async function runSyncTrust(input) {
|
|
|
9736
9741
|
packages: []
|
|
9737
9742
|
};
|
|
9738
9743
|
}
|
|
9739
|
-
|
|
9740
|
-
|
|
9744
|
+
const results = [];
|
|
9745
|
+
const needsAuth = (name, authUrl) => {
|
|
9746
|
+
print(` needs fresh 2FA — open and approve: ${authUrl}`);
|
|
9747
|
+
print(" then re-run; already-migrated packages are skipped.");
|
|
9748
|
+
results.push({
|
|
9749
|
+
name,
|
|
9750
|
+
status: "needs-auth",
|
|
9751
|
+
message: authUrl
|
|
9752
|
+
});
|
|
9753
|
+
logger.warn({
|
|
9754
|
+
package: name,
|
|
9755
|
+
authUrl
|
|
9756
|
+
}, "sync-trust: needs auth, stopping");
|
|
9741
9757
|
return {
|
|
9742
|
-
status: "
|
|
9743
|
-
message: "
|
|
9744
|
-
packages:
|
|
9758
|
+
status: "fail",
|
|
9759
|
+
message: "npm 2FA grant needed — see printed authUrl",
|
|
9760
|
+
packages: results
|
|
9745
9761
|
};
|
|
9746
|
-
}
|
|
9747
|
-
const results = [];
|
|
9762
|
+
};
|
|
9748
9763
|
for (const name of packageNames) {
|
|
9749
9764
|
print(`=== ${name} ===`);
|
|
9750
|
-
const
|
|
9765
|
+
const listResult = await exec(npm, [
|
|
9751
9766
|
...npmArgs,
|
|
9752
9767
|
"trust",
|
|
9753
9768
|
"list",
|
|
9754
9769
|
name,
|
|
9755
9770
|
"--json"
|
|
9756
|
-
], { cwd })
|
|
9757
|
-
|
|
9758
|
-
|
|
9759
|
-
|
|
9760
|
-
|
|
9771
|
+
], { cwd });
|
|
9772
|
+
const parsed = parseJson(listResult.stdout);
|
|
9773
|
+
if (isEotp(parsed)) return needsAuth(name, parsed.error?.authUrl ?? "");
|
|
9774
|
+
if (listResult.exitCode !== 0) {
|
|
9775
|
+
const message = listResult.stderr.trim() || listResult.stdout.trim() || `exit ${listResult.exitCode}`;
|
|
9776
|
+
print(` ✗ FAILED to read trust config: ${message}`);
|
|
9761
9777
|
results.push({
|
|
9762
9778
|
name,
|
|
9763
|
-
status: "needs-auth",
|
|
9764
|
-
message: authUrl
|
|
9765
|
-
});
|
|
9766
|
-
logger.warn({
|
|
9767
|
-
package: name,
|
|
9768
|
-
authUrl
|
|
9769
|
-
}, "sync-trust: needs auth, stopping");
|
|
9770
|
-
return {
|
|
9771
9779
|
status: "fail",
|
|
9772
|
-
message
|
|
9773
|
-
|
|
9774
|
-
|
|
9780
|
+
message
|
|
9781
|
+
});
|
|
9782
|
+
continue;
|
|
9775
9783
|
}
|
|
9776
|
-
const entry = parsed;
|
|
9777
|
-
|
|
9778
|
-
|
|
9784
|
+
const entry = parsed ?? {};
|
|
9785
|
+
const sameFile = entry.file === input.newFile;
|
|
9786
|
+
const sameRepo = entry.repository?.toLowerCase() === repo.toLowerCase();
|
|
9787
|
+
if (sameFile && sameRepo) {
|
|
9788
|
+
print(` already on ${repo} / ${input.newFile}, skipping`);
|
|
9779
9789
|
results.push({
|
|
9780
9790
|
name,
|
|
9781
|
-
status: "skipped"
|
|
9791
|
+
status: dryRun ? "would-skip" : "skipped"
|
|
9792
|
+
});
|
|
9793
|
+
continue;
|
|
9794
|
+
}
|
|
9795
|
+
const from = `repo=${entry.repository ?? "?"}, file=${entry.file ?? "?"}`;
|
|
9796
|
+
if (dryRun) {
|
|
9797
|
+
print(entry.id ? ` would revoke (${from}, id=${entry.id}) and create ${repo} / ${input.newFile}` : ` would create ${repo} / ${input.newFile} (no existing trust config)`);
|
|
9798
|
+
results.push({
|
|
9799
|
+
name,
|
|
9800
|
+
status: "would-sync"
|
|
9782
9801
|
});
|
|
9783
9802
|
continue;
|
|
9784
9803
|
}
|
|
9785
9804
|
if (entry.id) {
|
|
9786
|
-
print(` revoking existing trust (
|
|
9805
|
+
print(` revoking existing trust (${from}, id=${entry.id})`);
|
|
9787
9806
|
const revoke = await exec(npm, [
|
|
9788
9807
|
...npmArgs,
|
|
9789
9808
|
"trust",
|
|
@@ -9793,20 +9812,7 @@ async function runSyncTrust(input) {
|
|
|
9793
9812
|
entry.id,
|
|
9794
9813
|
"-y"
|
|
9795
9814
|
], { cwd });
|
|
9796
|
-
if (revoke.exitCode !== 0 && isEotp(parseJson(revoke.stdout)))
|
|
9797
|
-
const authUrl = parseJson(revoke.stdout).error?.authUrl ?? "";
|
|
9798
|
-
print(` needs fresh 2FA — open and approve: ${authUrl}`);
|
|
9799
|
-
results.push({
|
|
9800
|
-
name,
|
|
9801
|
-
status: "needs-auth",
|
|
9802
|
-
message: authUrl
|
|
9803
|
-
});
|
|
9804
|
-
return {
|
|
9805
|
-
status: "fail",
|
|
9806
|
-
message: "npm 2FA grant needed — see printed authUrl",
|
|
9807
|
-
packages: results
|
|
9808
|
-
};
|
|
9809
|
-
}
|
|
9815
|
+
if (revoke.exitCode !== 0 && isEotp(parseJson(revoke.stdout))) return needsAuth(name, parseJson(revoke.stdout).error?.authUrl ?? "");
|
|
9810
9816
|
} else print(" no existing trust config found");
|
|
9811
9817
|
print(` creating trust: ${input.newFile}`);
|
|
9812
9818
|
const create = await exec(npm, [
|
|
@@ -9830,20 +9836,7 @@ async function runSyncTrust(input) {
|
|
|
9830
9836
|
});
|
|
9831
9837
|
} else {
|
|
9832
9838
|
const createParsed = parseJson(create.stdout);
|
|
9833
|
-
if (isEotp(createParsed))
|
|
9834
|
-
const authUrl = createParsed.error?.authUrl ?? "";
|
|
9835
|
-
print(` needs fresh 2FA — open and approve: ${authUrl}`);
|
|
9836
|
-
results.push({
|
|
9837
|
-
name,
|
|
9838
|
-
status: "needs-auth",
|
|
9839
|
-
message: authUrl
|
|
9840
|
-
});
|
|
9841
|
-
return {
|
|
9842
|
-
status: "fail",
|
|
9843
|
-
message: "npm 2FA grant needed — see printed authUrl",
|
|
9844
|
-
packages: results
|
|
9845
|
-
};
|
|
9846
|
-
}
|
|
9839
|
+
if (isEotp(createParsed)) return needsAuth(name, createParsed.error?.authUrl ?? "");
|
|
9847
9840
|
const message = create.stderr.trim() || create.stdout.trim() || `exit ${create.exitCode}`;
|
|
9848
9841
|
print(` ✗ FAILED: ${message}`);
|
|
9849
9842
|
results.push({
|
|
@@ -9859,7 +9852,7 @@ async function runSyncTrust(input) {
|
|
|
9859
9852
|
failed: failed.length
|
|
9860
9853
|
}, "sync-trust: done");
|
|
9861
9854
|
return {
|
|
9862
|
-
status: failed.length > 0 ? "fail" : "ok",
|
|
9855
|
+
status: failed.length > 0 ? "fail" : dryRun ? "dry-run" : "ok",
|
|
9863
9856
|
...failed.length > 0 ? { message: `${failed.length} package(s) failed` } : {},
|
|
9864
9857
|
packages: results
|
|
9865
9858
|
};
|