@theholocron/cli 5.2.0 → 5.2.1
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 +22 -11
- package/dist/cli.mjs.map +1 -1
- package/package.json +5 -5
package/dist/cli.mjs
CHANGED
|
@@ -36875,6 +36875,7 @@ function cloneOrg(org) {
|
|
|
36875
36875
|
/* v8 ignore stop */
|
|
36876
36876
|
}
|
|
36877
36877
|
// src/commands/probe/references/find-references.ts
|
|
36878
|
+
const CALL = /^-?\s*uses:\s/;
|
|
36878
36879
|
/** The repository that hosts the files; its own references are the starters and shims, not callers. */
|
|
36879
36880
|
const HOST_REPO = ".github";
|
|
36880
36881
|
/** What a reference points at, from the text after the needle. */
|
|
@@ -36899,6 +36900,14 @@ function findReferences(repo, needle) {
|
|
|
36899
36900
|
});
|
|
36900
36901
|
return found;
|
|
36901
36902
|
}
|
|
36903
|
+
/**
|
|
36904
|
+
* Whether a reference is a live call: a `uses:` line in a YAML file, which is what GitHub reads. Tests, docs and specs
|
|
36905
|
+
* name the path on purpose (the legacy-path detection, a test that nothing spells it, a record of the move), so they are
|
|
36906
|
+
* references to list but not calls to wait on.
|
|
36907
|
+
*/
|
|
36908
|
+
function isCall(ref) {
|
|
36909
|
+
return /\.ya?ml$/.test(ref.file) && CALL.test(ref.text);
|
|
36910
|
+
}
|
|
36902
36911
|
// src/commands/probe/references/references-probes.ts
|
|
36903
36912
|
function scan(repos, needle) {
|
|
36904
36913
|
return {
|
|
@@ -36918,27 +36927,29 @@ function summarise(ctx, repos, found, needle, max) {
|
|
|
36918
36927
|
ctx.say({
|
|
36919
36928
|
status: "info",
|
|
36920
36929
|
label: repo.name === ".github" ? `${repo.name} (host)` : repo.name,
|
|
36921
|
-
detail: `${files} files: ${count("workflow")} workflow, ${count("action")} action, ${count("other")} other`
|
|
36930
|
+
detail: `${files} files: ${count("workflow")} workflow, ${count("action")} action, ${count("other")} other; ${own.filter(isCall).length} live calls`
|
|
36922
36931
|
});
|
|
36923
36932
|
}
|
|
36924
|
-
const outside = found.filter((ref) => ref.repo !== HOST_REPO)
|
|
36925
|
-
const
|
|
36926
|
-
|
|
36933
|
+
const outside = found.filter((ref) => ref.repo !== HOST_REPO);
|
|
36934
|
+
const calls = outside.filter(isCall).length;
|
|
36935
|
+
const inside = found.length - outside.length;
|
|
36936
|
+
const detail = `${outside.length} references in all (tests, docs and specs may name the path on purpose), ${inside} more inside ${HOST_REPO}`;
|
|
36937
|
+
if (calls > max) ctx.say({
|
|
36927
36938
|
status: "fail",
|
|
36928
|
-
label: `${
|
|
36939
|
+
label: `${calls} live calls outside ${HOST_REPO}`,
|
|
36929
36940
|
detail: `more than the ${max} allowed; ${detail}`
|
|
36930
36941
|
});
|
|
36931
36942
|
else ctx.say({
|
|
36932
36943
|
status: "ok",
|
|
36933
|
-
label: `${
|
|
36944
|
+
label: `${calls} live calls outside ${HOST_REPO}`,
|
|
36934
36945
|
detail
|
|
36935
36946
|
});
|
|
36936
36947
|
}
|
|
36937
36948
|
/**
|
|
36938
36949
|
* `ci refs` counts the references to the reusable workflows and composite actions hosted in `<org>/.github` across
|
|
36939
36950
|
* every active repository of the org. It is the exit test for removing the forwarding shims there: they can go when
|
|
36940
|
-
*
|
|
36941
|
-
* its file and line.
|
|
36951
|
+
* no live call outside `.github` is left (a `uses:` line in a YAML file; see {@link isCall}). It fails above `<max>`,
|
|
36952
|
+
* which defaults to 0, so the exit code is the test (#2915). `ci ref-list` prints each reference with its file and line.
|
|
36942
36953
|
*/
|
|
36943
36954
|
function ciProbes(org, clone = cloneOrg) {
|
|
36944
36955
|
const needle = (name) => `${name}/.github/.github/`;
|
|
@@ -36958,13 +36969,13 @@ function ciProbes(org, clone = cloneOrg) {
|
|
|
36958
36969
|
};
|
|
36959
36970
|
return {
|
|
36960
36971
|
refs: {
|
|
36961
|
-
summary: "Count references to the reusable workflows and actions hosted in the org's .github repo (arg: max).",
|
|
36972
|
+
summary: "Count references to the reusable workflows and actions hosted in the org's .github repo; fails on a live call outside it (arg: max, default 0).",
|
|
36962
36973
|
writes: false,
|
|
36963
36974
|
async run(ctx) {
|
|
36964
36975
|
const result = read(ctx);
|
|
36965
36976
|
if (!result) return;
|
|
36966
|
-
const max = ctx.args?.[0] === void 0 ?
|
|
36967
|
-
if (
|
|
36977
|
+
const max = ctx.args?.[0] === void 0 ? 0 : Number(ctx.args[0]);
|
|
36978
|
+
if (!Number.isInteger(max) || max < 0) {
|
|
36968
36979
|
ctx.say({
|
|
36969
36980
|
status: "fail",
|
|
36970
36981
|
label: `\`${ctx.args[0]}\` is not a number`,
|