@pnpm/deps.github-actions 1100.0.1 → 1100.1.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/CHANGELOG.md +29 -0
- package/lib/index.d.ts +41 -0
- package/lib/index.js +38 -7
- package/package.json +9 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# @pnpm/deps.github-actions
|
|
2
2
|
|
|
3
|
+
## 1100.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Checking GitHub Actions dependencies for updates is now opt-in for every command. Neither `pnpm outdated` nor `pnpm update` reads the workflow files unless `--include-github-actions` is passed or `update.githubActions` is set to `true` in `pnpm-workspace.yaml`. Reading them runs `git ls-remote` against every referenced repository, which fails in environments where GitHub is not reachable the way pnpm assumes (a GitHub Enterprise Server, a custom certificate authority, or an offline network) [#13254](https://github.com/pnpm/pnpm/issues/13254).
|
|
8
|
+
|
|
9
|
+
`pnpm outdated` accepts the `--include-github-actions` option too.
|
|
10
|
+
|
|
11
|
+
- Updated dependencies:
|
|
12
|
+
- @pnpm/resolving.git-resolver@1100.1.13
|
|
13
|
+
|
|
14
|
+
## 1100.1.0
|
|
15
|
+
|
|
16
|
+
### Minor Changes
|
|
17
|
+
|
|
18
|
+
- 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).
|
|
19
|
+
|
|
20
|
+
`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.
|
|
21
|
+
|
|
22
|
+
Setting `update.githubActions` to `false` now makes `pnpm outdated` and the interactive `pnpm update` skip GitHub Actions dependencies.
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- 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).
|
|
27
|
+
|
|
28
|
+
- Updated dependencies:
|
|
29
|
+
- @pnpm/error@1100.1.0
|
|
30
|
+
- @pnpm/resolving.git-resolver@1100.1.12
|
|
31
|
+
|
|
3
32
|
## 1100.0.1
|
|
4
33
|
|
|
5
34
|
### Patch Changes
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
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 interface GitHubActionsOptInOptions {
|
|
26
|
+
includeGithubActions?: boolean;
|
|
27
|
+
updateConfig?: {
|
|
28
|
+
githubActions?: boolean;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* GitHub Actions dependencies are opt-in. Reading them means running
|
|
33
|
+
* `git ls-remote` against every referenced repository, so `pnpm outdated` and
|
|
34
|
+
* `pnpm update` only look at workflow files when asked to, either with
|
|
35
|
+
* `--include-github-actions` or with `update.githubActions: true`.
|
|
36
|
+
*/
|
|
37
|
+
export declare function shouldCheckGitHubActions(opts: GitHubActionsOptInOptions): boolean;
|
|
38
|
+
export declare function isGitHubActionSelector(selector: string): boolean;
|
|
39
|
+
export declare function normalizeGitHubActionSelector(selector: string): string;
|
|
40
|
+
export declare function findOutdatedGitHubActions(opts: FindOutdatedGitHubActionsOptions): Promise<OutdatedGitHubAction[]>;
|
|
41
|
+
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';
|
|
@@ -10,6 +11,15 @@ import writeFileAtomic from 'write-file-atomic';
|
|
|
10
11
|
import YAML, { isMap, isNode, isScalar, isSeq } from 'yaml';
|
|
11
12
|
const SHA_PATTERN = /^[0-9a-f]{40}$/;
|
|
12
13
|
const limitRepoReads = pLimit(8);
|
|
14
|
+
/**
|
|
15
|
+
* GitHub Actions dependencies are opt-in. Reading them means running
|
|
16
|
+
* `git ls-remote` against every referenced repository, so `pnpm outdated` and
|
|
17
|
+
* `pnpm update` only look at workflow files when asked to, either with
|
|
18
|
+
* `--include-github-actions` or with `update.githubActions: true`.
|
|
19
|
+
*/
|
|
20
|
+
export function shouldCheckGitHubActions(opts) {
|
|
21
|
+
return opts.includeGithubActions === true || opts.updateConfig?.githubActions === true;
|
|
22
|
+
}
|
|
13
23
|
export function isGitHubActionSelector(selector) {
|
|
14
24
|
const pattern = selector.startsWith('!') ? selector.slice(1) : selector;
|
|
15
25
|
return !pattern.startsWith('@') && pattern.includes('/');
|
|
@@ -22,6 +32,7 @@ export function normalizeGitHubActionSelector(selector) {
|
|
|
22
32
|
}
|
|
23
33
|
export async function findOutdatedGitHubActions(opts) {
|
|
24
34
|
const plans = await createUpdatePlan(opts);
|
|
35
|
+
const serverUrl = resolveServerUrl(opts.serverUrl);
|
|
25
36
|
const target = (plan) => opts.compatible ? plan.wanted : plan.latest;
|
|
26
37
|
return dedupeOutdated(plans
|
|
27
38
|
.filter((plan) => semver.lt(plan.current.version, target(plan).version))
|
|
@@ -30,7 +41,7 @@ export async function findOutdatedGitHubActions(opts) {
|
|
|
30
41
|
latest: target(plan).version.version,
|
|
31
42
|
name: plan.action.name,
|
|
32
43
|
wanted: plan.wanted.version.version,
|
|
33
|
-
homepage:
|
|
44
|
+
homepage: `${serverUrl}/${plan.action.repo}`,
|
|
34
45
|
})));
|
|
35
46
|
}
|
|
36
47
|
export async function updateGitHubActions(opts) {
|
|
@@ -63,6 +74,7 @@ export async function updateGitHubActions(opts) {
|
|
|
63
74
|
throw workflowError('WRITE', file.path, err);
|
|
64
75
|
}
|
|
65
76
|
}));
|
|
77
|
+
const serverUrl = resolveServerUrl(opts.serverUrl);
|
|
66
78
|
return dedupeOutdated(updates.map((plan) => {
|
|
67
79
|
const target = opts.latest ? plan.latest : plan.wanted;
|
|
68
80
|
return {
|
|
@@ -70,19 +82,30 @@ export async function updateGitHubActions(opts) {
|
|
|
70
82
|
latest: target.version.version,
|
|
71
83
|
name: plan.action.name,
|
|
72
84
|
wanted: plan.wanted.version.version,
|
|
73
|
-
homepage:
|
|
85
|
+
homepage: `${serverUrl}/${plan.action.repo}`,
|
|
74
86
|
};
|
|
75
87
|
}));
|
|
76
88
|
}
|
|
77
89
|
async function createUpdatePlan(opts) {
|
|
78
90
|
const actions = await discoverActions(opts.dir);
|
|
79
91
|
const selected = opts.match == null ? actions : actions.filter((action) => opts.match(action.name) || opts.match(action.repo));
|
|
80
|
-
const
|
|
92
|
+
const serverUrl = resolveServerUrl(opts.serverUrl);
|
|
93
|
+
const readRepoRefs = opts.readRepoRefs ?? (async (repo) => getRepoRefs(`${serverUrl}/${repo}.git`, null));
|
|
81
94
|
const refsByRepo = new Map();
|
|
82
95
|
return (await Promise.all(selected.map(async (action) => {
|
|
83
96
|
let versionsPromise = refsByRepo.get(action.repo);
|
|
84
97
|
if (versionsPromise == null) {
|
|
85
|
-
versionsPromise = limitRepoReads(() =>
|
|
98
|
+
versionsPromise = limitRepoReads(async () => {
|
|
99
|
+
try {
|
|
100
|
+
return parseRepoVersions(await readRepoRefs(action.repo));
|
|
101
|
+
}
|
|
102
|
+
catch (err) {
|
|
103
|
+
// The git error may echo a credentialed URL or raw stderr back, so
|
|
104
|
+
// it is redacted and stripped of control characters before logging.
|
|
105
|
+
globalWarn(redactAndSanitize(`Skipping the GitHub Actions from "${action.repo}": ${util.types.isNativeError(err) ? err.message : String(err)}`));
|
|
106
|
+
return [];
|
|
107
|
+
}
|
|
108
|
+
});
|
|
86
109
|
refsByRepo.set(action.repo, versionsPromise);
|
|
87
110
|
}
|
|
88
111
|
const versions = await versionsPromise;
|
|
@@ -334,8 +357,16 @@ function dedupeOutdated(actions) {
|
|
|
334
357
|
return [...new Map(actions.map((action) => [action.name, action])).values()]
|
|
335
358
|
.sort((left, right) => left.name.localeCompare(right.name));
|
|
336
359
|
}
|
|
337
|
-
|
|
338
|
-
|
|
360
|
+
function resolveServerUrl(serverUrl) {
|
|
361
|
+
let url = serverUrl || process.env.GITHUB_SERVER_URL || 'https://github.com';
|
|
362
|
+
// Only allow http(s) so the value cannot select another git transport
|
|
363
|
+
// (e.g. `ext::`, which executes an arbitrary command).
|
|
364
|
+
if (!url.startsWith('https://') && !url.startsWith('http://')) {
|
|
365
|
+
throw new PnpmError('GITHUB_ACTIONS_SERVER_PROTOCOL', `The GitHub Actions server URL must use the "https://" or "http://" protocol, but got ${JSON.stringify(url)}`);
|
|
366
|
+
}
|
|
367
|
+
while (url.endsWith('/'))
|
|
368
|
+
url = url.slice(0, -1);
|
|
369
|
+
return url;
|
|
339
370
|
}
|
|
340
371
|
function workflowError(operation, filePath, cause) {
|
|
341
372
|
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.
|
|
3
|
+
"version": "1100.1.1",
|
|
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
|
|
32
|
-
"@pnpm/resolving.git-resolver": "1100.1.
|
|
31
|
+
"@pnpm/error": "1100.1.0",
|
|
32
|
+
"@pnpm/resolving.git-resolver": "1100.1.13",
|
|
33
33
|
"is-subdir": "^2.0.0",
|
|
34
|
-
"p-limit": "^7.3.
|
|
35
|
-
"semver": "^7.8.
|
|
34
|
+
"p-limit": "^7.3.1",
|
|
35
|
+
"semver": "^7.8.5",
|
|
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.
|
|
44
|
+
"@pnpm/deps.github-actions": "1100.1.1",
|
|
42
45
|
"@types/semver": "7.7.1",
|
|
43
46
|
"@types/write-file-atomic": "^4.0.3"
|
|
44
47
|
},
|