actions-up 1.13.0 → 1.14.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.
Files changed (71) hide show
  1. package/dist/cli/build-json-report.d.ts +57 -36
  2. package/dist/cli/build-json-report.js +22 -18
  3. package/dist/cli/index.js +137 -122
  4. package/dist/cli/merge-scan-results.js +2 -2
  5. package/dist/cli/normalize-update-mode.js +2 -2
  6. package/dist/cli/normalize-update-style.d.ts +8 -0
  7. package/dist/cli/normalize-update-style.js +6 -0
  8. package/dist/cli/print-mode-warning.js +5 -5
  9. package/dist/cli/print-skipped-warning.d.ts +4 -1
  10. package/dist/cli/print-skipped-warning.js +10 -6
  11. package/dist/cli/resolve-scan-directories.js +8 -8
  12. package/dist/cli/validate-cli-options.js +2 -2
  13. package/dist/core/api/check-updates.d.ts +2 -0
  14. package/dist/core/api/check-updates.js +120 -96
  15. package/dist/core/api/create-github-client.js +26 -26
  16. package/dist/core/api/get-all-releases.js +12 -12
  17. package/dist/core/api/get-all-tags.js +4 -4
  18. package/dist/core/api/get-compatible-update.js +6 -6
  19. package/dist/core/api/get-latest-release.js +15 -15
  20. package/dist/core/api/get-reference-type.js +5 -5
  21. package/dist/core/api/get-tag-info.js +14 -14
  22. package/dist/core/api/get-tag-sha.js +7 -7
  23. package/dist/core/api/internal-rate-limit-error.js +2 -2
  24. package/dist/core/api/make-request.js +4 -4
  25. package/dist/core/api/resolve-github-token-sync.js +7 -7
  26. package/dist/core/api/update-rate-limit-info.js +3 -6
  27. package/dist/core/ast/guards/has-range.js +2 -2
  28. package/dist/core/ast/guards/is-node.js +2 -2
  29. package/dist/core/ast/guards/is-pair.js +2 -2
  30. package/dist/core/ast/guards/is-scalar.js +2 -2
  31. package/dist/core/ast/guards/is-yaml-map.js +2 -2
  32. package/dist/core/ast/guards/is-yaml-sequence.js +2 -2
  33. package/dist/core/ast/scanners/scan-composite-action-ast.js +13 -13
  34. package/dist/core/ast/scanners/scan-workflow-ast.js +21 -21
  35. package/dist/core/ast/update/apply-updates.d.ts +1 -1
  36. package/dist/core/ast/update/apply-updates.js +35 -22
  37. package/dist/core/ast/utils/extract-uses-from-steps.js +14 -14
  38. package/dist/core/ast/utils/find-map-pair.js +6 -6
  39. package/dist/core/ast/utils/get-line-number.js +4 -4
  40. package/dist/core/constants.js +2 -2
  41. package/dist/core/filters/parse-exclude-patterns.js +2 -2
  42. package/dist/core/fs/find-yaml-files-recursive.js +9 -9
  43. package/dist/core/fs/is-yaml-file.js +2 -2
  44. package/dist/core/fs/read-yaml-document.js +6 -6
  45. package/dist/core/ignore/should-ignore.js +4 -4
  46. package/dist/core/index.js +5 -5
  47. package/dist/core/interactive/format-version.js +14 -14
  48. package/dist/core/interactive/pad-string.js +4 -4
  49. package/dist/core/interactive/prompt-update-selection.js +162 -135
  50. package/dist/core/interactive/strip-ansi.js +2 -2
  51. package/dist/core/parsing/parse-action-reference.js +2 -2
  52. package/dist/core/scan-action-file.js +6 -6
  53. package/dist/core/scan-github-actions.js +83 -83
  54. package/dist/core/scan-recursive.js +24 -24
  55. package/dist/core/scan-workflow-file.js +6 -6
  56. package/dist/core/schema/composite/is-composite-action-runs.js +2 -2
  57. package/dist/core/schema/composite/is-composite-action-structure.js +2 -2
  58. package/dist/core/schema/workflow/is-workflow-structure.js +2 -2
  59. package/dist/core/updates/resolve-target-reference.d.ts +10 -0
  60. package/dist/core/updates/resolve-target-reference.js +24 -0
  61. package/dist/core/versions/find-compatible-tag.js +16 -16
  62. package/dist/core/versions/get-update-level.js +8 -8
  63. package/dist/core/versions/is-semver-like.js +2 -2
  64. package/dist/core/versions/is-sha.js +2 -2
  65. package/dist/core/versions/normalize-version.js +4 -4
  66. package/dist/core/versions/read-inline-version-comment.js +4 -4
  67. package/dist/package.js +2 -2
  68. package/dist/types/action-update.d.ts +16 -1
  69. package/dist/types/update-style.d.ts +4 -0
  70. package/package.json +2 -2
  71. package/readme.md +24 -5
@@ -1,15 +1,15 @@
1
- import { makeRequest } from "./make-request.js";
2
- async function getReferenceType(t, n) {
1
+ import { makeRequest as e } from "./make-request.js";
2
+ async function t(t, n) {
3
3
  let { reference: r, owner: i, repo: a } = n, o = `${i}/${a}#${r}`;
4
4
  if (t.caches.refType.has(o)) return t.caches.refType.get(o) ?? null;
5
5
  try {
6
- return await makeRequest(t, `/repos/${i}/${a}/git/refs/tags/${r}`), t.caches.refType.set(o, "tag"), "tag";
6
+ return await e(t, `/repos/${i}/${a}/git/refs/tags/${r}`), t.caches.refType.set(o, "tag"), "tag";
7
7
  } catch {
8
8
  try {
9
- return await makeRequest(t, `/repos/${i}/${a}/git/refs/heads/${r}`), t.caches.refType.set(o, "branch"), "branch";
9
+ return await e(t, `/repos/${i}/${a}/git/refs/heads/${r}`), t.caches.refType.set(o, "branch"), "branch";
10
10
  } catch {
11
11
  return t.caches.refType.set(o, null), null;
12
12
  }
13
13
  }
14
14
  }
15
- export { getReferenceType };
15
+ export { t as getReferenceType };
@@ -1,15 +1,15 @@
1
- import { makeRequest } from "./make-request.js";
2
- import { GitHubRateLimitError } from "./internal-rate-limit-error.js";
3
- async function getTagInfo(n, i) {
1
+ import { makeRequest as e } from "./make-request.js";
2
+ import { GitHubRateLimitError as t } from "./internal-rate-limit-error.js";
3
+ async function n(n, i) {
4
4
  try {
5
5
  let { owner: t, repo: a, tag: o } = i, s = o.replace(/^refs\/tags\//u, ""), c = `${t}/${a}#${s}`;
6
6
  if (n.caches.tagInfo.has(c)) return n.caches.tagInfo.get(c) ?? null;
7
7
  try {
8
- let i = (await makeRequest(n, `/repos/${t}/${a}/releases/tags/${s}`)).data, o = i.published_at ? new Date(i.published_at) : null, l = i.body ?? null, u = null;
8
+ let i = (await e(n, `/repos/${t}/${a}/releases/tags/${s}`)).data, o = i.published_at ? new Date(i.published_at) : null, l = i.body ?? null, u = null;
9
9
  try {
10
- let { type: r, sha: i } = (await makeRequest(n, `/repos/${t}/${a}/git/refs/tags/${s}`)).data.object;
10
+ let { type: r, sha: i } = (await e(n, `/repos/${t}/${a}/git/refs/tags/${s}`)).data.object;
11
11
  if (i && r === "tag") try {
12
- let r = (await makeRequest(n, `/repos/${t}/${a}/git/tags/${i}`)).data;
12
+ let r = (await e(n, `/repos/${t}/${a}/git/tags/${i}`)).data;
13
13
  u = r.object.sha ?? i;
14
14
  let s = r.tagger?.date;
15
15
  !o && s && (o = new Date(s)), !l && typeof r.message == "string" && ({message: l} = r);
@@ -17,13 +17,13 @@ async function getTagInfo(n, i) {
17
17
  u = i;
18
18
  }
19
19
  else if (i && r === "commit" && (u = i, !o || !l)) try {
20
- let { message: r, author: s } = (await makeRequest(n, `/repos/${t}/${a}/git/commits/${i}`)).data;
20
+ let { message: r, author: s } = (await e(n, `/repos/${t}/${a}/git/commits/${i}`)).data;
21
21
  !l && typeof r == "string" && (l = r);
22
22
  let c = s?.date;
23
23
  !o && c && (o = new Date(c));
24
24
  } catch {}
25
25
  } catch {
26
- isLikelySha(i.target_commitish) && (u = i.target_commitish);
26
+ r(i.target_commitish) && (u = i.target_commitish);
27
27
  }
28
28
  let d = {
29
29
  tag: s,
@@ -34,13 +34,13 @@ async function getTagInfo(n, i) {
34
34
  return n.caches.tagInfo.set(c, d), d;
35
35
  } catch {
36
36
  try {
37
- let r = (await makeRequest(n, `/repos/${t}/${a}/git/refs/tags/${s}`)).data, { sha: i } = r.object, o = null, l = null;
37
+ let r = (await e(n, `/repos/${t}/${a}/git/refs/tags/${s}`)).data, { sha: i } = r.object, o = null, l = null;
38
38
  if (r.object.type === "tag") try {
39
- let r = (await makeRequest(n, `/repos/${t}/${a}/git/tags/${i}`)).data;
39
+ let r = (await e(n, `/repos/${t}/${a}/git/tags/${i}`)).data;
40
40
  i = r.object.sha ?? i, o = r.message ?? null, l = r.tagger.date ? new Date(r.tagger.date) : null;
41
41
  } catch {}
42
42
  else try {
43
- let r = (await makeRequest(n, `/repos/${t}/${a}/git/commits/${i}`)).data;
43
+ let r = (await e(n, `/repos/${t}/${a}/git/commits/${i}`)).data;
44
44
  o = r.message ?? null, l = r.author.date ? new Date(r.author.date) : null;
45
45
  } catch {}
46
46
  let u = {
@@ -56,12 +56,12 @@ async function getTagInfo(n, i) {
56
56
  }
57
57
  }
58
58
  } catch (e) {
59
- throw e instanceof Error && e.message.includes("rate limit") ? new GitHubRateLimitError(n.rateLimitReset) : e;
59
+ throw e instanceof Error && e.message.includes("rate limit") ? new t(n.rateLimitReset) : e;
60
60
  }
61
61
  }
62
- function isLikelySha(e) {
62
+ function r(e) {
63
63
  if (typeof e != "string" || e.trim() === "") return !1;
64
64
  let t = e.replace(/^v/u, "");
65
65
  return /^[0-9a-f]{7,40}$/iu.test(t);
66
66
  }
67
- export { getTagInfo };
67
+ export { n as getTagInfo };
@@ -1,20 +1,20 @@
1
- import { makeRequest } from "./make-request.js";
2
- import { GitHubRateLimitError } from "./internal-rate-limit-error.js";
3
- async function getTagSha(n, r) {
1
+ import { makeRequest as e } from "./make-request.js";
2
+ import { GitHubRateLimitError as t } from "./internal-rate-limit-error.js";
3
+ async function n(n, r) {
4
4
  let { owner: i, repo: a, tag: o } = r, s = o.replace(/^refs\/tags\//u, ""), c = `${i}/${a}#${s}`;
5
5
  if (n.caches.tagSha.has(c)) return n.caches.tagSha.get(c) ?? null;
6
6
  try {
7
- let t = (await makeRequest(n, `/repos/${i}/${a}/git/refs/tags/${s}`)).data, r = t.object.sha, o = t.object.type, l = null;
7
+ let t = (await e(n, `/repos/${i}/${a}/git/refs/tags/${s}`)).data, r = t.object.sha, o = t.object.type, l = null;
8
8
  if (r && o === "tag") try {
9
- l = (await makeRequest(n, `/repos/${i}/${a}/git/tags/${r}`)).data.object.sha ?? null;
9
+ l = (await e(n, `/repos/${i}/${a}/git/tags/${r}`)).data.object.sha ?? null;
10
10
  } catch {
11
11
  l = r;
12
12
  }
13
13
  else r && o === "commit" && (l = r);
14
14
  return n.caches.tagSha.set(c, l), l;
15
15
  } catch (e) {
16
- if (e instanceof Error && e.message.includes("rate limit")) throw new GitHubRateLimitError(n.rateLimitReset);
16
+ if (e instanceof Error && e.message.includes("rate limit")) throw new t(n.rateLimitReset);
17
17
  return n.caches.tagSha.set(c, null), null;
18
18
  }
19
19
  }
20
- export { getTagSha };
20
+ export { n as getTagSha };
@@ -1,7 +1,7 @@
1
- var GitHubRateLimitError = class extends Error {
1
+ var e = class extends Error {
2
2
  constructor(e) {
3
3
  let t = e.toLocaleTimeString();
4
4
  super(`GitHub API rate limit exceeded. Resets at ${t}`), this.name = "GitHubRateLimitError";
5
5
  }
6
6
  };
7
- export { GitHubRateLimitError };
7
+ export { e as GitHubRateLimitError };
@@ -1,5 +1,5 @@
1
- import { updateRateLimitInfo } from "./update-rate-limit-info.js";
2
- async function makeRequest(t, n, r = {}) {
1
+ import { updateRateLimitInfo as e } from "./update-rate-limit-info.js";
2
+ async function t(t, n, r = {}) {
3
3
  let i = {
4
4
  Accept: "application/vnd.github.v3+json",
5
5
  "User-Agent": "actions-up",
@@ -11,7 +11,7 @@ async function makeRequest(t, n, r = {}) {
11
11
  headers: i
12
12
  }), o = {};
13
13
  for (let [e, t] of a.headers.entries()) o[e] = t;
14
- if (updateRateLimitInfo(t, o), !a.ok) {
14
+ if (e(t, o), !a.ok) {
15
15
  let e = /* @__PURE__ */ Error(`GitHub API error: ${a.status} ${a.statusText}`);
16
16
  if (e.status = a.status, a.status === 403) {
17
17
  let t = await a.text();
@@ -24,4 +24,4 @@ async function makeRequest(t, n, r = {}) {
24
24
  data: await a.json()
25
25
  };
26
26
  }
27
- export { makeRequest };
27
+ export { t as makeRequest };
@@ -1,13 +1,13 @@
1
- import { join } from "node:path";
2
- import { execFileSync } from "node:child_process";
3
- import { readFileSync } from "node:fs";
4
- function resolveGitHubTokenSync() {
1
+ import { join as e } from "node:path";
2
+ import { execFileSync as t } from "node:child_process";
3
+ import { readFileSync as n } from "node:fs";
4
+ function r() {
5
5
  let r = process.env.GITHUB_TOKEN;
6
6
  if (r && r.trim() !== "") return r.trim();
7
7
  let i = process.env.GH_TOKEN;
8
8
  if (i && i.trim() !== "") return i.trim();
9
9
  try {
10
- let e = execFileSync("gh", ["auth", "token"], {
10
+ let e = t("gh", ["auth", "token"], {
11
11
  stdio: [
12
12
  "ignore",
13
13
  "pipe",
@@ -19,7 +19,7 @@ function resolveGitHubTokenSync() {
19
19
  if (e) return e;
20
20
  } catch {}
21
21
  try {
22
- let t = readFileSync(join(process.cwd(), ".git", "config"), "utf8"), r = t.match(/^\s*(?:github\.(?:oauth-token|token)|hub\.oauthtoken)\s*=\s*(?<token>\S[^\n\r]*)$/mu)?.groups?.token?.trim();
22
+ let t = n(e(process.cwd(), ".git", "config"), "utf8"), r = t.match(/^\s*(?:github\.(?:oauth-token|token)|hub\.oauthtoken)\s*=\s*(?<token>\S[^\n\r]*)$/mu)?.groups?.token?.trim();
23
23
  if (r) return r;
24
24
  let i = null;
25
25
  for (let e of t.split(/\r?\n/u)) {
@@ -39,4 +39,4 @@ function resolveGitHubTokenSync() {
39
39
  }
40
40
  } catch {}
41
41
  }
42
- export { resolveGitHubTokenSync };
42
+ export { r as resolveGitHubTokenSync };
@@ -1,10 +1,7 @@
1
- function updateRateLimitInfo(e, t) {
1
+ function e(e, t) {
2
2
  let n = t["x-ratelimit-remaining"];
3
3
  n !== void 0 && (e.rateLimitRemaining = typeof n == "string" ? Number.parseInt(n, 10) : n);
4
4
  let r = t["x-ratelimit-reset"];
5
- if (r !== void 0) {
6
- let t = typeof r == "string" ? Number.parseInt(r, 10) : r;
7
- e.rateLimitReset = /* @__PURE__ */ new Date(t * 1e3);
8
- }
5
+ r !== void 0 && (e.rateLimitReset = /* @__PURE__ */ new Date((typeof r == "string" ? Number.parseInt(r, 10) : r) * 1e3));
9
6
  }
10
- export { updateRateLimitInfo };
7
+ export { e as updateRateLimitInfo };
@@ -1,4 +1,4 @@
1
- function hasRange(e) {
1
+ function e(e) {
2
2
  return typeof e == "object" && !!e && "range" in e;
3
3
  }
4
- export { hasRange };
4
+ export { e as hasRange };
@@ -1,4 +1,4 @@
1
- function isNode(e) {
1
+ function e(e) {
2
2
  return typeof e == "object" && !!e && "toJSON" in e && typeof e.toJSON == "function";
3
3
  }
4
- export { isNode };
4
+ export { e as isNode };
@@ -1,4 +1,4 @@
1
- function isPair(e) {
1
+ function e(e) {
2
2
  return typeof e == "object" && !!e && "key" in e && "value" in e;
3
3
  }
4
- export { isPair };
4
+ export { e as isPair };
@@ -1,4 +1,4 @@
1
- function isScalar(e) {
1
+ function e(e) {
2
2
  return typeof e == "object" && !!e && "value" in e;
3
3
  }
4
- export { isScalar };
4
+ export { e as isScalar };
@@ -1,4 +1,4 @@
1
- function isYAMLMap(e) {
1
+ function e(e) {
2
2
  return typeof e == "object" && !!e && "items" in e && Array.isArray(e.items);
3
3
  }
4
- export { isYAMLMap };
4
+ export { e as isYAMLMap };
@@ -1,4 +1,4 @@
1
- function isYAMLSequence(e) {
1
+ function e(e) {
2
2
  return typeof e == "object" && !!e && "items" in e && Array.isArray(e.items);
3
3
  }
4
- export { isYAMLSequence };
4
+ export { e as isYAMLSequence };
@@ -1,20 +1,20 @@
1
- import { isCompositeActionStructure } from "../../schema/composite/is-composite-action-structure.js";
2
- import { isCompositeActionRuns } from "../../schema/composite/is-composite-action-runs.js";
3
- import { isYAMLMap } from "../guards/is-yaml-map.js";
4
- import { extractUsesFromSteps } from "../utils/extract-uses-from-steps.js";
5
- import { findMapPair } from "../utils/find-map-pair.js";
6
- function scanCompositeActionAst(a, o, s) {
1
+ import { isCompositeActionStructure as e } from "../../schema/composite/is-composite-action-structure.js";
2
+ import { isCompositeActionRuns as t } from "../../schema/composite/is-composite-action-runs.js";
3
+ import { isYAMLMap as n } from "../guards/is-yaml-map.js";
4
+ import { extractUsesFromSteps as r } from "../utils/extract-uses-from-steps.js";
5
+ import { findMapPair as i } from "../utils/find-map-pair.js";
6
+ function a(a, o, s) {
7
7
  let c = a.toJSON();
8
- if (!isCompositeActionStructure(c) || !a.contents || !isYAMLMap(a.contents)) return [];
9
- let l = findMapPair(a.contents, "runs");
10
- if (!l?.value || !isYAMLMap(l.value)) return [];
8
+ if (!e(c) || !a.contents || !n(a.contents)) return [];
9
+ let l = i(a.contents, "runs");
10
+ if (!l?.value || !n(l.value)) return [];
11
11
  let u = c.runs;
12
- if (!u || !isCompositeActionRuns(u) || !u.steps || !Array.isArray(u.steps)) return [];
13
- let d = findMapPair(l.value, "steps");
14
- return d?.value ? extractUsesFromSteps({
12
+ if (!u || !t(u) || !u.steps || !Array.isArray(u.steps)) return [];
13
+ let d = i(l.value, "steps");
14
+ return d?.value ? r({
15
15
  stepsNode: d.value,
16
16
  filePath: s,
17
17
  content: o
18
18
  }) : [];
19
19
  }
20
- export { scanCompositeActionAst };
20
+ export { a as scanCompositeActionAst };
@@ -1,26 +1,26 @@
1
- import { parseActionReference } from "../../parsing/parse-action-reference.js";
2
- import { getLineNumberForKey } from "../utils/get-line-number.js";
3
- import { isYAMLMap } from "../guards/is-yaml-map.js";
4
- import { isScalar } from "../guards/is-scalar.js";
5
- import { isNode } from "../guards/is-node.js";
6
- import { isPair } from "../guards/is-pair.js";
7
- import { extractUsesFromSteps } from "../utils/extract-uses-from-steps.js";
8
- import { findMapPair } from "../utils/find-map-pair.js";
9
- import { isWorkflowStructure } from "../../schema/workflow/is-workflow-structure.js";
10
- function scanWorkflowAst(l, u, d) {
11
- if (!isWorkflowStructure(l.toJSON()) || !l.contents || !isYAMLMap(l.contents)) return [];
12
- let f = findMapPair(l.contents, "jobs");
13
- if (!f?.value || !isYAMLMap(f.value)) return [];
1
+ import { parseActionReference as e } from "../../parsing/parse-action-reference.js";
2
+ import { getLineNumberForKey as t } from "../utils/get-line-number.js";
3
+ import { isYAMLMap as n } from "../guards/is-yaml-map.js";
4
+ import { isScalar as r } from "../guards/is-scalar.js";
5
+ import { isNode as i } from "../guards/is-node.js";
6
+ import { isPair as a } from "../guards/is-pair.js";
7
+ import { extractUsesFromSteps as o } from "../utils/extract-uses-from-steps.js";
8
+ import { findMapPair as s } from "../utils/find-map-pair.js";
9
+ import { isWorkflowStructure as c } from "../../schema/workflow/is-workflow-structure.js";
10
+ function l(l, u, d) {
11
+ if (!c(l.toJSON()) || !l.contents || !n(l.contents)) return [];
12
+ let f = s(l.contents, "jobs");
13
+ if (!f?.value || !n(f.value)) return [];
14
14
  let p = [];
15
15
  for (let c of f.value.items) {
16
- if (!isPair(c) || !c.value || !isNode(c.value) || !isYAMLMap(c.value)) continue;
17
- let l = isScalar(c.key) ? String(c.key.value) : void 0, f = findMapPair(c.value, "uses");
18
- if (f?.value && f.key && isScalar(f.value)) {
19
- let s = parseActionReference(String(f.value.value), d, getLineNumberForKey(u, f.key));
20
- s && (l && (s.job = l), p.push(s));
16
+ if (!a(c) || !c.value || !i(c.value) || !n(c.value)) continue;
17
+ let l = r(c.key) ? String(c.key.value) : void 0, f = s(c.value, "uses");
18
+ if (f?.value && f.key && r(f.value)) {
19
+ let n = e(String(f.value.value), d, t(u, f.key));
20
+ n && (l && (n.job = l), p.push(n));
21
21
  }
22
- let m = findMapPair(c.value, "steps");
23
- m?.value && p.push(...extractUsesFromSteps({
22
+ let m = s(c.value, "steps");
23
+ m?.value && p.push(...o({
24
24
  stepsNode: m.value,
25
25
  filePath: d,
26
26
  content: u,
@@ -29,4 +29,4 @@ function scanWorkflowAst(l, u, d) {
29
29
  }
30
30
  return p;
31
31
  }
32
- export { scanWorkflowAst };
32
+ export { l as scanWorkflowAst };
@@ -1,6 +1,6 @@
1
1
  import { ActionUpdate } from '../../../types/action-update';
2
2
  /**
3
- * Apply updates using SHA with version in comment for readability.
3
+ * Apply updates using the already-resolved target refs.
4
4
  *
5
5
  * @param updates - Array of updates to apply.
6
6
  */
@@ -1,40 +1,53 @@
1
- import { readFile, writeFile } from "node:fs/promises";
2
- async function applyUpdates(n) {
3
- let r = /* @__PURE__ */ new Map();
1
+ import { readFile as e, writeFile as t } from "node:fs/promises";
2
+ async function n(n) {
3
+ let i = /* @__PURE__ */ new Map();
4
4
  for (let e of n) {
5
5
  let { file: t } = e.action;
6
6
  if (!t) continue;
7
- let n = r.get(t) ?? [];
8
- n.push(e), r.set(t, n);
7
+ let n = i.get(t) ?? [];
8
+ n.push(e), i.set(t, n);
9
9
  }
10
- let i = [...r.entries()].map(async ([n, r]) => {
11
- let i = await readFile(n, "utf8");
12
- for (let e of r) {
13
- if (!e.latestSha) continue;
14
- function t(e) {
10
+ let a = [...i.entries()].map(async ([n, i]) => {
11
+ let a = await e(n, "utf8");
12
+ for (let e of i) {
13
+ let t = e.targetRef ?? e.latestSha, n = e.targetRefStyle ?? (e.latestSha ? "sha" : null);
14
+ if (!t || !n) continue;
15
+ function i(e) {
15
16
  return e.replaceAll(/[$()*+\-./?[\\\]^{|}]/gu, String.raw`\$&`);
16
17
  }
17
- let n = t(e.action.name), r = e.currentVersion ? t(e.currentVersion) : "";
18
- if (n.includes("\n") || n.includes("\r")) {
18
+ let o = i(e.action.name), s = e.currentVersion ? i(e.currentVersion) : "";
19
+ if (o.includes("\n") || o.includes("\r")) {
19
20
  console.error(`Invalid action name: ${e.action.name}`);
20
21
  continue;
21
22
  }
22
- if (r && (r.includes("\n") || r.includes("\r"))) {
23
+ if (s && (s.includes("\n") || s.includes("\r"))) {
23
24
  console.error(`Invalid version: ${e.currentVersion}`);
24
25
  continue;
25
26
  }
26
- if (!/^[\da-f]{40}$/iu.test(e.latestSha)) {
27
- console.error(`Invalid SHA format: ${e.latestSha}`);
27
+ if (t.includes("\n") || t.includes("\r") || t.trim() === "") {
28
+ console.error(`Invalid target ref: ${t}`);
28
29
  continue;
29
30
  }
30
- let a = String.raw`['"]?\buses\b['"]?\s*:\s*`, o = String.raw`(?:^[^\S\n]*(?:-[^\S\n]*)?|[{\[,][^\S\n]*)` + a, s = new RegExp(String.raw`(?<prefix>${o})` + String.raw`(?<quote>['"]?)` + String.raw`(?<name>${n})@${r}` + String.raw`\k<quote>` + String.raw`(?<after>[ \t\]}{,]*)` + String.raw`(?<comment>[^\S\r\n]*#[^\r\n]*)?`, "gm");
31
- i = i.replace(s, (t, ...n) => {
32
- let i = n.at(-3), a = n.at(-2), o = n.at(-1), s = a.indexOf("\n", i + t.length), c = (s === -1 ? a.slice(i + t.length) : a.slice(i + t.length, s)).trim().length > 0, l = o.after.endsWith(" ") ? "" : " ", u = c && !o.comment && r !== "" ? "" : `${l}# ${e.latestVersion}`;
33
- return `${`${o.prefix}${o.quote}${o.name}`}@${`${e.latestSha}${o.quote}${o.after}${u}`}`;
31
+ if (n === "sha" && !/^[\da-f]{40}$/iu.test(t)) {
32
+ console.error(`Invalid SHA format: ${t}`);
33
+ continue;
34
+ }
35
+ let c = String.raw`['"]?\buses\b['"]?\s*:\s*`, l = String.raw`(?:^[^\S\n]*(?:-[^\S\n]*)?|[{\[,][^\S\n]*)` + c, u = new RegExp(String.raw`(?<prefix>${l})` + String.raw`(?<quote>['"]?)` + String.raw`(?<name>${o})@${s}` + String.raw`\k<quote>` + String.raw`(?<after>[ \t\]}{,]*)` + String.raw`(?<comment>[^\S\r\n]*#[^\r\n]*)?`, "gm");
36
+ a = a.replace(u, (i, ...a) => {
37
+ let o = a.at(-3), c = a.at(-2), l = a.at(-1), u = c.indexOf("\n", o + i.length), d = (u === -1 ? c.slice(o + i.length) : c.slice(o + i.length, u)).trim().length > 0, f = l.after.endsWith(" ") ? "" : " ", p = "";
38
+ if (n === "sha") p = d && !l.comment && s !== "" ? "" : `${f}# ${e.latestVersion}`;
39
+ else if (l.comment && !r(l.comment)) {
40
+ let { comment: e } = l;
41
+ p = e;
42
+ }
43
+ return `${`${l.prefix}${l.quote}${l.name}`}@${`${t}${l.quote}${l.after}${p}`}`;
34
44
  });
35
45
  }
36
- await writeFile(n, i, "utf8");
46
+ await t(n, a, "utf8");
37
47
  });
38
- await Promise.all(i);
48
+ await Promise.all(a);
49
+ }
50
+ function r(e) {
51
+ return /^#\s*[Vv]?\d+(?:\.\d+){0,2}(?:[+-][\w\-.]+)?\s*$/u.test(e.trim());
39
52
  }
40
- export { applyUpdates };
53
+ export { n as applyUpdates };
@@ -1,23 +1,23 @@
1
- import { parseActionReference } from "../../parsing/parse-action-reference.js";
2
- import { isYAMLSequence } from "../guards/is-yaml-sequence.js";
3
- import { getLineNumberForKey } from "./get-line-number.js";
4
- import { isYAMLMap } from "../guards/is-yaml-map.js";
5
- import { isScalar } from "../guards/is-scalar.js";
6
- import { isNode } from "../guards/is-node.js";
7
- import { isPair } from "../guards/is-pair.js";
8
- function extractUsesFromSteps(s) {
1
+ import { parseActionReference as e } from "../../parsing/parse-action-reference.js";
2
+ import { isYAMLSequence as t } from "../guards/is-yaml-sequence.js";
3
+ import { getLineNumberForKey as n } from "./get-line-number.js";
4
+ import { isYAMLMap as r } from "../guards/is-yaml-map.js";
5
+ import { isScalar as i } from "../guards/is-scalar.js";
6
+ import { isNode as a } from "../guards/is-node.js";
7
+ import { isPair as o } from "../guards/is-pair.js";
8
+ function s(s) {
9
9
  let { stepsNode: c, filePath: l, content: u, jobName: d } = s;
10
- if (!isYAMLSequence(c)) return [];
10
+ if (!t(c)) return [];
11
11
  let f = [];
12
- for (let o of c.items) {
13
- if (!isYAMLMap(o) || !isNode(o)) continue;
14
- let s = o.toJSON();
12
+ for (let t of c.items) {
13
+ if (!r(t) || !a(t)) continue;
14
+ let s = t.toJSON();
15
15
  if (typeof s != "object" || !s || Array.isArray(s)) continue;
16
16
  let c = s;
17
17
  if (typeof c.uses != "string") continue;
18
- let p = o.items.find((e) => isPair(e) && isScalar(e.key) && e.key.value === "uses"), m = p?.key ? getLineNumberForKey(u, p.key) : 0, h = parseActionReference(c.uses, l, m);
18
+ let p = t.items.find((e) => o(e) && i(e.key) && e.key.value === "uses"), m = p?.key ? n(u, p.key) : 0, h = e(c.uses, l, m);
19
19
  h && (d && (h.job = d), f.push(h));
20
20
  }
21
21
  return f;
22
22
  }
23
- export { extractUsesFromSteps };
23
+ export { s as extractUsesFromSteps };
@@ -1,7 +1,7 @@
1
- import { isYAMLMap } from "../guards/is-yaml-map.js";
2
- import { isScalar } from "../guards/is-scalar.js";
3
- import { isPair } from "../guards/is-pair.js";
4
- function findMapPair(r, i) {
5
- return !isYAMLMap(r) || !Array.isArray(r.items) ? null : r.items.find((e) => isPair(e) && isScalar(e.key) && e.key.value === i) ?? null;
1
+ import { isYAMLMap as e } from "../guards/is-yaml-map.js";
2
+ import { isScalar as t } from "../guards/is-scalar.js";
3
+ import { isPair as n } from "../guards/is-pair.js";
4
+ function r(r, i) {
5
+ return !e(r) || !Array.isArray(r.items) ? null : r.items.find((e) => n(e) && t(e.key) && e.key.value === i) ?? null;
6
6
  }
7
- export { findMapPair };
7
+ export { r as findMapPair };
@@ -1,9 +1,9 @@
1
- import { hasRange } from "../guards/has-range.js";
2
- function getLineNumberForKey(t, n) {
3
- if (hasRange(n) && n.range) {
1
+ import { hasRange as e } from "../guards/has-range.js";
2
+ function t(t, n) {
3
+ if (e(n) && n.range) {
4
4
  let [e] = n.range;
5
5
  if (typeof e == "number" && Number.isFinite(e)) return t.slice(0, Math.max(0, e)).split("\n").length;
6
6
  }
7
7
  return 0;
8
8
  }
9
- export { getLineNumberForKey };
9
+ export { t as getLineNumberForKey };
@@ -1,2 +1,2 @@
1
- const GITHUB_DIRECTORY = ".github", WORKFLOWS_DIRECTORY = "workflows", ACTIONS_DIRECTORY = "actions";
2
- export { ACTIONS_DIRECTORY, GITHUB_DIRECTORY, WORKFLOWS_DIRECTORY };
1
+ var e = ".github", t = "workflows", n = "actions";
2
+ export { n as ACTIONS_DIRECTORY, e as GITHUB_DIRECTORY, t as WORKFLOWS_DIRECTORY };
@@ -1,4 +1,4 @@
1
- function parseExcludePatterns(e) {
1
+ function e(e) {
2
2
  let t = [];
3
3
  for (let n of e) {
4
4
  let e = n.trim();
@@ -20,4 +20,4 @@ function parseExcludePatterns(e) {
20
20
  }
21
21
  return t;
22
22
  }
23
- export { parseExcludePatterns };
23
+ export { e as parseExcludePatterns };
@@ -1,20 +1,20 @@
1
- import { isYamlFile } from "./is-yaml-file.js";
2
- import { join } from "node:path";
3
- import { lstat, readdir } from "node:fs/promises";
4
- async function findYamlFilesRecursive(i) {
1
+ import { isYamlFile as e } from "./is-yaml-file.js";
2
+ import { join as t } from "node:path";
3
+ import { lstat as n, readdir as r } from "node:fs/promises";
4
+ async function i(i) {
5
5
  let a = [], o = /* @__PURE__ */ new Set();
6
6
  async function s(i) {
7
- if ((await lstat(i)).isSymbolicLink() || o.has(i)) return;
7
+ if ((await n(i)).isSymbolicLink() || o.has(i)) return;
8
8
  o.add(i);
9
- let c = (await readdir(i)).map(async (r) => {
9
+ let c = (await r(i)).map(async (r) => {
10
10
  try {
11
- let o = join(i, r), c = await lstat(o);
11
+ let o = t(i, r), c = await n(o);
12
12
  if (c.isSymbolicLink()) return;
13
- c.isDirectory() ? await s(o) : c.isFile() && isYamlFile(r) && a.push(o);
13
+ c.isDirectory() ? await s(o) : c.isFile() && e(r) && a.push(o);
14
14
  } catch {}
15
15
  });
16
16
  await Promise.all(c);
17
17
  }
18
18
  return await s(i), a;
19
19
  }
20
- export { findYamlFilesRecursive };
20
+ export { i as findYamlFilesRecursive };
@@ -1,4 +1,4 @@
1
- function isYamlFile(e) {
1
+ function e(e) {
2
2
  return e.endsWith(".yml") || e.endsWith(".yaml");
3
3
  }
4
- export { isYamlFile };
4
+ export { e as isYamlFile };
@@ -1,10 +1,10 @@
1
- import { readFile } from "node:fs/promises";
2
- import { parseDocument } from "yaml";
3
- async function readYamlDocument(n) {
4
- let r = await readFile(n, "utf8");
1
+ import { readFile as e } from "node:fs/promises";
2
+ import { parseDocument as t } from "yaml";
3
+ async function n(n) {
4
+ let r = await e(n, "utf8");
5
5
  return {
6
- document: parseDocument(r),
6
+ document: t(r),
7
7
  content: r
8
8
  };
9
9
  }
10
- export { readYamlDocument };
10
+ export { n as readYamlDocument };
@@ -1,7 +1,7 @@
1
- import { readFile } from "node:fs/promises";
2
- async function shouldIgnore(t, n) {
1
+ import { readFile as e } from "node:fs/promises";
2
+ async function t(t, n) {
3
3
  if (!t) return !1;
4
- let r = (await readFile(t, "utf8")).split("\n");
4
+ let r = (await e(t, "utf8")).split("\n");
5
5
  for (let e of r) if (e.includes("actions-up-ignore-file")) return !0;
6
6
  if (!n || n <= 0) return !1;
7
7
  let i = /* @__PURE__ */ new Set(), a = !1;
@@ -11,4 +11,4 @@ async function shouldIgnore(t, n) {
11
11
  }
12
12
  return i.has(n);
13
13
  }
14
- export { shouldIgnore };
14
+ export { t as shouldIgnore };
@@ -1,5 +1,5 @@
1
- import { applyUpdates } from "./ast/update/apply-updates.js";
2
- import { checkUpdates } from "./api/check-updates.js";
3
- import { scanRecursive } from "./scan-recursive.js";
4
- import { scanGitHubActions } from "./scan-github-actions.js";
5
- export { applyUpdates, checkUpdates, scanGitHubActions, scanRecursive };
1
+ import { applyUpdates as e } from "./ast/update/apply-updates.js";
2
+ import { checkUpdates as t } from "./api/check-updates.js";
3
+ import { scanRecursive as n } from "./scan-recursive.js";
4
+ import { scanGitHubActions as r } from "./scan-github-actions.js";
5
+ export { e as applyUpdates, t as checkUpdates, r as scanGitHubActions, n as scanRecursive };