@pnpm/deps.github-actions 1100.0.1 → 1100.1.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/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @pnpm/deps.github-actions
2
2
 
3
+ ## 1100.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Added a new setting, `update.githubActionsServer`, for specifying the base URL of the GitHub server that hosts the repositories of the GitHub Actions referenced by the workflow files (for example, a GitHub Enterprise Server). When the setting is not defined, the URL is read from the `GITHUB_SERVER_URL` environment variable, falling back to `https://github.com`. The URL must use the `https://` or `http://` protocol [#13220](https://github.com/pnpm/pnpm/issues/13220).
8
+
9
+ `pnpm outdated` and `pnpm update` no longer fail when the refs of a GitHub Action's repository cannot be read (for example, when the action's repository is private or hosted on a different GitHub server). Such actions are now skipped with a warning.
10
+
11
+ Setting `update.githubActions` to `false` now makes `pnpm outdated` and the interactive `pnpm update` skip GitHub Actions dependencies.
12
+
13
+ ### Patch Changes
14
+
15
+ - Republished every package: the tarballs published by the v11.13.1 through v11.16.0 releases were missing most of their compiled files due to a packing bug [#13164](https://github.com/pnpm/pnpm/issues/13164).
16
+
17
+ - Updated dependencies:
18
+ - @pnpm/error@1100.1.0
19
+ - @pnpm/resolving.git-resolver@1100.1.12
20
+
3
21
  ## 1100.0.1
4
22
 
5
23
  ### Patch Changes
package/lib/index.d.ts ADDED
@@ -0,0 +1,28 @@
1
+ export interface OutdatedGitHubAction {
2
+ current: string;
3
+ latest: string;
4
+ name: string;
5
+ wanted: string;
6
+ homepage: string;
7
+ }
8
+ export interface GitHubActionsOptions {
9
+ dir: string;
10
+ match?: (name: string) => boolean;
11
+ readRepoRefs?: (repo: string) => Promise<Record<string, string>>;
12
+ /**
13
+ * The base URL of the GitHub server hosting the action repositories.
14
+ * Defaults to the `GITHUB_SERVER_URL` environment variable, or
15
+ * https://github.com.
16
+ */
17
+ serverUrl?: string;
18
+ }
19
+ export interface FindOutdatedGitHubActionsOptions extends GitHubActionsOptions {
20
+ compatible?: boolean;
21
+ }
22
+ export interface UpdateGitHubActionsOptions extends GitHubActionsOptions {
23
+ latest?: boolean;
24
+ }
25
+ export declare function isGitHubActionSelector(selector: string): boolean;
26
+ export declare function normalizeGitHubActionSelector(selector: string): string;
27
+ export declare function findOutdatedGitHubActions(opts: FindOutdatedGitHubActionsOptions): Promise<OutdatedGitHubAction[]>;
28
+ export declare function updateGitHubActions(opts: UpdateGitHubActionsOptions): Promise<OutdatedGitHubAction[]>;
package/lib/index.js CHANGED
@@ -1,7 +1,8 @@
1
1
  import fs from 'node:fs/promises';
2
2
  import path from 'node:path';
3
3
  import util from 'node:util';
4
- import { PnpmError } from '@pnpm/error';
4
+ import { PnpmError, redactAndSanitize } from '@pnpm/error';
5
+ import { globalWarn } from '@pnpm/logger';
5
6
  import { getRepoRefs } from '@pnpm/resolving.git-resolver';
6
7
  import { isSubdir } from 'is-subdir';
7
8
  import pLimit from 'p-limit';
@@ -22,6 +23,7 @@ export function normalizeGitHubActionSelector(selector) {
22
23
  }
23
24
  export async function findOutdatedGitHubActions(opts) {
24
25
  const plans = await createUpdatePlan(opts);
26
+ const serverUrl = resolveServerUrl(opts.serverUrl);
25
27
  const target = (plan) => opts.compatible ? plan.wanted : plan.latest;
26
28
  return dedupeOutdated(plans
27
29
  .filter((plan) => semver.lt(plan.current.version, target(plan).version))
@@ -30,7 +32,7 @@ export async function findOutdatedGitHubActions(opts) {
30
32
  latest: target(plan).version.version,
31
33
  name: plan.action.name,
32
34
  wanted: plan.wanted.version.version,
33
- homepage: `https://github.com/${plan.action.repo}`,
35
+ homepage: `${serverUrl}/${plan.action.repo}`,
34
36
  })));
35
37
  }
36
38
  export async function updateGitHubActions(opts) {
@@ -63,6 +65,7 @@ export async function updateGitHubActions(opts) {
63
65
  throw workflowError('WRITE', file.path, err);
64
66
  }
65
67
  }));
68
+ const serverUrl = resolveServerUrl(opts.serverUrl);
66
69
  return dedupeOutdated(updates.map((plan) => {
67
70
  const target = opts.latest ? plan.latest : plan.wanted;
68
71
  return {
@@ -70,19 +73,30 @@ export async function updateGitHubActions(opts) {
70
73
  latest: target.version.version,
71
74
  name: plan.action.name,
72
75
  wanted: plan.wanted.version.version,
73
- homepage: `https://github.com/${plan.action.repo}`,
76
+ homepage: `${serverUrl}/${plan.action.repo}`,
74
77
  };
75
78
  }));
76
79
  }
77
80
  async function createUpdatePlan(opts) {
78
81
  const actions = await discoverActions(opts.dir);
79
82
  const selected = opts.match == null ? actions : actions.filter((action) => opts.match(action.name) || opts.match(action.repo));
80
- const readRepoRefs = opts.readRepoRefs ?? readRefsWithGit;
83
+ const serverUrl = resolveServerUrl(opts.serverUrl);
84
+ const readRepoRefs = opts.readRepoRefs ?? (async (repo) => getRepoRefs(`${serverUrl}/${repo}.git`, null));
81
85
  const refsByRepo = new Map();
82
86
  return (await Promise.all(selected.map(async (action) => {
83
87
  let versionsPromise = refsByRepo.get(action.repo);
84
88
  if (versionsPromise == null) {
85
- versionsPromise = limitRepoReads(() => readRepoRefs(action.repo).then(parseRepoVersions));
89
+ versionsPromise = limitRepoReads(async () => {
90
+ try {
91
+ return parseRepoVersions(await readRepoRefs(action.repo));
92
+ }
93
+ catch (err) {
94
+ // The git error may echo a credentialed URL or raw stderr back, so
95
+ // it is redacted and stripped of control characters before logging.
96
+ globalWarn(redactAndSanitize(`Skipping the GitHub Actions from "${action.repo}": ${util.types.isNativeError(err) ? err.message : String(err)}`));
97
+ return [];
98
+ }
99
+ });
86
100
  refsByRepo.set(action.repo, versionsPromise);
87
101
  }
88
102
  const versions = await versionsPromise;
@@ -334,8 +348,16 @@ function dedupeOutdated(actions) {
334
348
  return [...new Map(actions.map((action) => [action.name, action])).values()]
335
349
  .sort((left, right) => left.name.localeCompare(right.name));
336
350
  }
337
- async function readRefsWithGit(repo) {
338
- return getRepoRefs(`https://github.com/${repo}.git`, null);
351
+ function resolveServerUrl(serverUrl) {
352
+ let url = serverUrl || process.env.GITHUB_SERVER_URL || 'https://github.com';
353
+ // Only allow http(s) so the value cannot select another git transport
354
+ // (e.g. `ext::`, which executes an arbitrary command).
355
+ if (!url.startsWith('https://') && !url.startsWith('http://')) {
356
+ throw new PnpmError('GITHUB_ACTIONS_SERVER_PROTOCOL', `The GitHub Actions server URL must use the "https://" or "http://" protocol, but got ${JSON.stringify(url)}`);
357
+ }
358
+ while (url.endsWith('/'))
359
+ url = url.slice(0, -1);
360
+ return url;
339
361
  }
340
362
  function workflowError(operation, filePath, cause) {
341
363
  const detail = util.types.isNativeError(cause) ? cause.message : String(cause);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnpm/deps.github-actions",
3
- "version": "1100.0.1",
3
+ "version": "1100.1.0",
4
4
  "description": "Discover and update GitHub Actions dependencies",
5
5
  "keywords": [
6
6
  "pnpm",
@@ -28,17 +28,20 @@
28
28
  "!*.map"
29
29
  ],
30
30
  "dependencies": {
31
- "@pnpm/error": "1100.0.1",
32
- "@pnpm/resolving.git-resolver": "1100.1.11",
31
+ "@pnpm/error": "1100.1.0",
32
+ "@pnpm/resolving.git-resolver": "1100.1.12",
33
33
  "is-subdir": "^2.0.0",
34
34
  "p-limit": "^7.3.0",
35
35
  "semver": "^7.8.4",
36
36
  "write-file-atomic": "^7.0.1",
37
37
  "yaml": "^2.9.0"
38
38
  },
39
+ "peerDependencies": {
40
+ "@pnpm/logger": "^1100.0.0"
41
+ },
39
42
  "devDependencies": {
40
43
  "@jest/globals": "30.4.1",
41
- "@pnpm/deps.github-actions": "1100.0.1",
44
+ "@pnpm/deps.github-actions": "1100.1.0",
42
45
  "@types/semver": "7.7.1",
43
46
  "@types/write-file-atomic": "^4.0.3"
44
47
  },