Compare commits
466 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
f4a67bbeca | |
|
|
0355742c94 | |
|
|
ad1b57eb81 | |
|
|
670825a89d | |
|
|
48b55a011b | |
|
|
ab72c7e7eb | |
|
|
53b83947a5 | |
|
|
54045abd5d | |
|
|
c882bffdbd | |
|
|
774c1d6296 | |
|
|
efcb663fc6 | |
|
|
d02c89dce7 | |
|
|
6044e13b5d | |
|
|
8e494633d0 | |
|
|
621ac41091 | |
|
|
2951748f4c | |
|
|
21ddc7bc1f | |
|
|
65d868f8d4 | |
|
|
395ad32622 | |
|
|
a4d2e2bbca | |
|
|
b9b25d45f7 | |
|
|
633bb92bc0 | |
|
|
dda4788290 | |
|
|
2028fbc5c2 | |
|
|
13427813f7 | |
|
|
89d709d423 | |
|
|
cd2651c462 | |
|
|
a0853c2454 | |
|
|
b7234cc9fe | |
|
|
d7a11313b5 | |
|
|
5e2628c959 | |
|
|
65beceff8e | |
|
|
7e24a656e1 | |
|
|
08f58d1471 | |
|
|
49933ea528 | |
|
|
e3ce749e20 | |
|
|
40337cb8f7 | |
|
|
1ccdddc9b8 | |
|
|
cdca7365b2 | |
|
|
22c0e7494f | |
|
|
a7c2d9473e | |
|
|
802632921f | |
|
|
1d0ff469b7 | |
|
|
574f09a9fa | |
|
|
260f8702db | |
|
|
111c4beff8 | |
|
|
0bc26deefe | |
|
|
8f9cc178b6 | |
|
|
5eef37b631 | |
|
|
fbeca22fb2 | |
|
|
48b90677b6 | |
|
|
39370e3970 | |
|
|
abb238b131 | |
|
|
aca7b64a59 | |
|
|
88de2a3d99 | |
|
|
0a44ba7841 | |
|
|
d6ebc7b438 | |
|
|
97ca147735 | |
|
|
aa363ded8f | |
|
|
1c7b2db920 | |
|
|
26961cf329 | |
|
|
1e60f620b9 | |
|
|
eff380dfbc | |
|
|
c2ac33f2c6 | |
|
|
25b062c917 | |
|
|
60edb5dd54 | |
|
|
d86ebcd40b | |
|
|
b39b52d121 | |
|
|
7247617371 | |
|
|
f3ec4ca66f | |
|
|
ec97f37504 | |
|
|
5ef044f9d0 | |
|
|
c45882a6ea | |
|
|
ee36e8b5c0 | |
|
|
8f152de45c | |
|
|
23755b521f | |
|
|
54534a2a9b | |
|
|
1a4442cacd | |
|
|
6e9e44895f | |
|
|
e52912ef25 | |
|
|
ac16ae42d7 | |
|
|
5a8d9111e3 | |
|
|
9e956a555c | |
|
|
7da2a7eb0c | |
|
|
2a017f350d | |
|
|
72c43c2d8f | |
|
|
d3ace34546 | |
|
|
acbf0586b1 | |
|
|
f1744b62b7 | |
|
|
2651591c72 | |
|
|
5e21ff4d9b | |
|
|
bea5baf987 | |
|
|
d82f92a0eb | |
|
|
ca2d4e0cdd | |
|
|
c7a93deeac | |
|
|
34050076a5 | |
|
|
f8aa08ed8e | |
|
|
e2d34eacc8 | |
|
|
ef9c88b169 | |
|
|
ea800d4ebc | |
|
|
cb95c398f6 | |
|
|
69b2dd252e | |
|
|
e33196f742 | |
|
|
c6722d36aa | |
|
|
8170e22e8f | |
|
|
698d50532e | |
|
|
869f4dd0c7 | |
|
|
10efafcbcf | |
|
|
7d16907b89 | |
|
|
d0d39bda2f | |
|
|
15a2477e08 | |
|
|
7598dbcd6e | |
|
|
a9893b0cfb | |
|
|
5b32c9063c | |
|
|
d98fa11138 | |
|
|
9d255ef245 | |
|
|
e828f9b7f3 | |
|
|
a4fcaaf314 | |
|
|
10f5623502 | |
|
|
fcd18100cc | |
|
|
962678f22c | |
|
|
7c29869aec | |
|
|
ae9f0f7448 | |
|
|
3dbcda8bc2 | |
|
|
f38519bb96 | |
|
|
9227cda3f0 | |
|
|
64ed1c7eab | |
|
|
92a57f4a93 | |
|
|
99e61d697a | |
|
|
3e8819f8f2 | |
|
|
8cd2fb28b8 | |
|
|
c406543918 | |
|
|
92a07fe466 | |
|
|
217387cf3e | |
|
|
2db3663870 | |
|
|
bbe2ac79a1 | |
|
|
f5ab623822 | |
|
|
ca97bf7f80 | |
|
|
fe4d514f1a | |
|
|
8151ea11a4 | |
|
|
772ffdda26 | |
|
|
da188081b1 | |
|
|
377c6dae40 | |
|
|
b28830cbe2 | |
|
|
676975d9aa | |
|
|
d1b197b965 | |
|
|
069a4f8926 | |
|
|
e77eaaccd3 | |
|
|
a69d45adcd | |
|
|
3ae886ede4 | |
|
|
41acaa2e85 | |
|
|
2349c84f5c | |
|
|
6bc15ab23c | |
|
|
9b8fcdc725 | |
|
|
00e1b6691b | |
|
|
16352bb09b | |
|
|
788c6ccbd0 | |
|
|
8c91899e58 | |
|
|
c81d8ad96d | |
|
|
c96ab56c5b | |
|
|
969bd26639 | |
|
|
9f3a02bbd1 | |
|
|
4cffe5c52b | |
|
|
0efefb3c0b | |
|
|
1e6f2cd312 | |
|
|
30f0e7dc5a | |
|
|
c8f0d10585 | |
|
|
b4b18e5317 | |
|
|
9efe00a002 | |
|
|
35ba06beb7 | |
|
|
9fc76ff685 | |
|
|
dc62cc63a8 | |
|
|
d04c34e7d9 | |
|
|
32f78d9bfa | |
|
|
e954e15431 | |
|
|
792255d078 | |
|
|
089aa7ea91 | |
|
|
094c36e88e | |
|
|
5bbf7221ae | |
|
|
dbb54d08f2 | |
|
|
3a1b76e782 | |
|
|
94f88d78c4 | |
|
|
348e008008 | |
|
|
d79e93a91d | |
|
|
5d6bb1273a | |
|
|
0d3aa68dd3 | |
|
|
18090dee77 | |
|
|
bb59d50268 | |
|
|
5b579f1638 | |
|
|
9f20343a3a | |
|
|
dee2a9689c | |
|
|
57cec77d94 | |
|
|
5a01179c35 | |
|
|
2a814b57e1 | |
|
|
2fddd8803e | |
|
|
ad8542ca5e | |
|
|
3d11add771 | |
|
|
072a2e3b10 | |
|
|
28ad38fe06 | |
|
|
48de4c13f6 | |
|
|
aab7cc882a | |
|
|
5b949b50c3 | |
|
|
09ba51f18e | |
|
|
b3ca1ac971 | |
|
|
78faa555e1 | |
|
|
0f15a51ed6 | |
|
|
460f88643a | |
|
|
d8b0944270 | |
|
|
0ad06209dd | |
|
|
adeb189fd8 | |
|
|
0d7418813c | |
|
|
3ac35dad40 | |
|
|
4096f07b51 | |
|
|
1c48dc5a9e | |
|
|
d86a20eb78 | |
|
|
8211e009a7 | |
|
|
dbfbe9b6da | |
|
|
9aa86428fe | |
|
|
f40b60859d | |
|
|
a03d9f05e4 | |
|
|
1a4ff5493d | |
|
|
7d610f0c26 | |
|
|
bcb9f31327 | |
|
|
73ea510762 | |
|
|
eaead3517c | |
|
|
24301fe9fb | |
|
|
11c7f932ce | |
|
|
f1702f8f38 | |
|
|
1196f2ae1b | |
|
|
c22fc3c628 | |
|
|
cdcc53e14f | |
|
|
b287e177c9 | |
|
|
eeb10cff27 | |
|
|
dbb64ac1d1 | |
|
|
82496765f3 | |
|
|
ed1a46e9f2 | |
|
|
daff393d43 | |
|
|
b14573ddb9 | |
|
|
7569de03e7 | |
|
|
b20a2561b9 | |
|
|
ea3459bb45 | |
|
|
141334fcd1 | |
|
|
808c8f917f | |
|
|
fd1b409bc3 | |
|
|
9a03ebd9cc | |
|
|
45e544a71a | |
|
|
8c66f89aef | |
|
|
3601f2a33e | |
|
|
4d62fafc05 | |
|
|
17f8bd9264 | |
|
|
b067f78ed3 | |
|
|
0bd06765ef | |
|
|
25184c4485 | |
|
|
337fdf2194 | |
|
|
86bf502a33 | |
|
|
146c4d84a5 | |
|
|
56337c4255 | |
|
|
76d3665dc0 | |
|
|
5b52f097d3 | |
|
|
75716637dc | |
|
|
546fd45825 | |
|
|
bacd6b4b3a | |
|
|
bed538bd04 | |
|
|
f3e93d1b9d | |
|
|
ed960c9656 | |
|
|
77f43a4400 | |
|
|
9ced9a43a2 | |
|
|
3e90744edf | |
|
|
28df918a56 | |
|
|
f099707f6e | |
|
|
f658dc5bd7 | |
|
|
5e2e068714 | |
|
|
7a0f7a9962 | |
|
|
7b558676dd | |
|
|
1f8c6b94b2 | |
|
|
9a74eb4e64 | |
|
|
04c56d2f95 | |
|
|
d08cf22211 | |
|
|
360ab8b75b | |
|
|
fd4bd829f2 | |
|
|
a4b8ed2f4e | |
|
|
270253e841 | |
|
|
d1178716db | |
|
|
041bafb672 | |
|
|
996306e892 | |
|
|
85d4122530 | |
|
|
928244ce45 | |
|
|
25316bbc1f | |
|
|
76a4cff9ae | |
|
|
a869e7cc2d | |
|
|
a0cdab1110 | |
|
|
4d0182af5e | |
|
|
896ee80599 | |
|
|
d21ecc7c5b | |
|
|
d6e3b5539e | |
|
|
db716f881a | |
|
|
c24389f79e | |
|
|
004fb83876 | |
|
|
180b77fed2 | |
|
|
9f31dbbbc4 | |
|
|
aa759c6c94 | |
|
|
0ae03de2b7 | |
|
|
4bc87b8e10 | |
|
|
b96348a4e9 | |
|
|
3af302a4f2 | |
|
|
f452812b44 | |
|
|
f43d8a1f27 | |
|
|
e93556ca66 | |
|
|
0453e516eb | |
|
|
399982b368 | |
|
|
d278e78bdd | |
|
|
fdbc93ea6e | |
|
|
f24e78e0f6 | |
|
|
3c1fbef7d3 | |
|
|
5aa72c249a | |
|
|
d9aab2aba4 | |
|
|
162ddf7c40 | |
|
|
38d90ce44d | |
|
|
e1e1d4c853 | |
|
|
40f85c8c97 | |
|
|
e215578cb0 | |
|
|
9af89732f0 | |
|
|
cfe70f9fe8 | |
|
|
b259ba49fe | |
|
|
55e10498cf | |
|
|
bcb4cecf9b | |
|
|
72922790cb | |
|
|
48042628a6 | |
|
|
8624ddbdce | |
|
|
282049a5b1 | |
|
|
87a21fa69e | |
|
|
e79375d669 | |
|
|
57b9c8c424 | |
|
|
4bef829942 | |
|
|
9b447f0b81 | |
|
|
d36a3314a5 | |
|
|
c2dfe2df98 | |
|
|
f2b87bb2c2 | |
|
|
d9ce83b637 | |
|
|
56c3db9dda | |
|
|
92722aec8c | |
|
|
c62861c1e7 | |
|
|
36d2ce149e | |
|
|
bcdcde00c0 | |
|
|
0ec4841e4b | |
|
|
e761a7024e | |
|
|
c8c6442c74 | |
|
|
fa68745dc0 | |
|
|
c8889b24a3 | |
|
|
88d5bfde31 | |
|
|
1088324e41 | |
|
|
05f3e9f4fa | |
|
|
3d0d4edb10 | |
|
|
5929471019 | |
|
|
1bf30534fd | |
|
|
ae26aaf1b5 | |
|
|
5fddb2d510 | |
|
|
8c35c6c880 | |
|
|
24265e14d4 | |
|
|
5c355be170 | |
|
|
46071b5c7a | |
|
|
05f0551dbd | |
|
|
23bdee16bc | |
|
|
4257181919 | |
|
|
7f4d5225d8 | |
|
|
68fafecfa4 | |
|
|
c46424eee2 | |
|
|
1d846de8c0 | |
|
|
d06286dee6 | |
|
|
d8c1b596a6 | |
|
|
2bfa943ffb | |
|
|
6c8a6e529a | |
|
|
27082cecf3 | |
|
|
05e7d6cc23 | |
|
|
d6fea3c137 | |
|
|
4667755142 | |
|
|
2bbfc7698a | |
|
|
5984462aaa | |
|
|
aabe026707 | |
|
|
b7cfa22539 | |
|
|
70b9252472 | |
|
|
7d147e85af | |
|
|
66dfac5328 | |
|
|
312bbeecfd | |
|
|
26a6dcb73b | |
|
|
f4215cc0e0 | |
|
|
14e150d2b1 | |
|
|
5da2d61209 | |
|
|
a600caf7cc | |
|
|
8dde5bc004 | |
|
|
c6fd00ceb9 | |
|
|
2f532cef8f | |
|
|
c211e95e60 | |
|
|
99d584aa06 | |
|
|
2a5c060ce2 | |
|
|
2801f51f90 | |
|
|
0a161fe2f9 | |
|
|
63fffe4411 | |
|
|
a83bf51129 | |
|
|
922f2f9468 | |
|
|
7a3669aa8a | |
|
|
66f3e9f7ce | |
|
|
82271389a6 | |
|
|
2e40994c28 | |
|
|
c7e4d38541 | |
|
|
3eb4bc9d68 | |
|
|
bf47decdc2 | |
|
|
6afbfca452 | |
|
|
3e84c3523b | |
|
|
6668516d2a | |
|
|
f27ebaf08b | |
|
|
42d59fbc36 | |
|
|
2d8887128d | |
|
|
0635b31a61 | |
|
|
59e61b8951 | |
|
|
321b6ccb03 | |
|
|
1ae8f4b1fd | |
|
|
0e2f9cde8b | |
|
|
e434342e4e | |
|
|
7c6182c745 | |
|
|
a47b2f66c6 | |
|
|
89ea387bde | |
|
|
44c9c18728 | |
|
|
e715d9a456 | |
|
|
b1f2e78536 | |
|
|
55897e37f3 | |
|
|
46903d1fb1 | |
|
|
28505ad4d3 | |
|
|
2d53d29868 | |
|
|
1e163ded31 | |
|
|
ffde538781 | |
|
|
0cc027b656 | |
|
|
339aa41a8d | |
|
|
641e88986e | |
|
|
e99a7e62b2 | |
|
|
0dc69b3a71 | |
|
|
52eb8a7524 | |
|
|
83c9f7a7df | |
|
|
ada4b782b3 | |
|
|
1c5c1375b3 | |
|
|
6b7f6c9fa6 | |
|
|
d123f10543 | |
|
|
9a99bb3e35 | |
|
|
93313caf82 | |
|
|
43d44139c7 | |
|
|
6ecfd2dcb2 | |
|
|
466ce3c2f0 | |
|
|
f499b0c1ab | |
|
|
e565252a9d | |
|
|
c35dd24c52 | |
|
|
4fd9403fe5 | |
|
|
ca2e28376a | |
|
|
7a3ce83626 | |
|
|
57adacb752 | |
|
|
7af5963081 | |
|
|
1ba3bc7e28 | |
|
|
d43864199a | |
|
|
3d792c1dbd | |
|
|
a0c716db3e | |
|
|
1c24df3126 | |
|
|
dd2e8a486f | |
|
|
d963e800e3 | |
|
|
27212a1fbb | |
|
|
78148dae50 | |
|
|
0675b87d74 | |
|
|
213c968cb9 |
|
|
@ -0,0 +1,6 @@
|
||||||
|
# Ignore list
|
||||||
|
/*
|
||||||
|
|
||||||
|
# Do not ignore these folders:
|
||||||
|
!__tests__/
|
||||||
|
!src/
|
||||||
|
|
@ -0,0 +1,51 @@
|
||||||
|
// This is a reusable configuration file copied from https://github.com/actions/reusable-workflows/tree/main/reusable-configurations. Please don't make changes to this file as it's the subject of an automatic update.
|
||||||
|
module.exports = {
|
||||||
|
extends: [
|
||||||
|
'eslint:recommended',
|
||||||
|
'plugin:@typescript-eslint/recommended',
|
||||||
|
'plugin:eslint-plugin-jest/recommended',
|
||||||
|
'eslint-config-prettier'
|
||||||
|
],
|
||||||
|
parser: '@typescript-eslint/parser',
|
||||||
|
plugins: ['@typescript-eslint', 'eslint-plugin-node', 'eslint-plugin-jest'],
|
||||||
|
rules: {
|
||||||
|
'@typescript-eslint/no-require-imports': 'error',
|
||||||
|
'@typescript-eslint/no-non-null-assertion': 'off',
|
||||||
|
'@typescript-eslint/no-explicit-any': 'off',
|
||||||
|
'@typescript-eslint/no-empty-function': 'off',
|
||||||
|
'@typescript-eslint/ban-ts-comment': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
'ts-ignore': 'allow-with-description'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'no-console': 'error',
|
||||||
|
'yoda': 'error',
|
||||||
|
'prefer-const': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
destructuring: 'all'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'no-control-regex': 'off',
|
||||||
|
'no-constant-condition': ['error', {checkLoops: false}],
|
||||||
|
'node/no-extraneous-import': 'error'
|
||||||
|
},
|
||||||
|
overrides: [
|
||||||
|
{
|
||||||
|
files: ['**/*{test,spec}.ts'],
|
||||||
|
rules: {
|
||||||
|
'@typescript-eslint/no-unused-vars': 'off',
|
||||||
|
'jest/no-standalone-expect': 'off',
|
||||||
|
'jest/no-conditional-expect': 'off',
|
||||||
|
'no-console': 'off',
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
env: {
|
||||||
|
node: true,
|
||||||
|
es6: true,
|
||||||
|
'jest/globals': true
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
* text=auto eol=lf
|
||||||
|
.licenses/** -diff linguist-generated=true
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
---
|
||||||
|
name: Bug report
|
||||||
|
about: Create a bug report
|
||||||
|
title: ''
|
||||||
|
labels: bug, needs triage
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
<!--- Please direct any generic questions related to actions to our support community forum at https://github.community/c/code-to-cloud/github-actions/41 --->
|
||||||
|
<!--- Before opening up a new bug report, please make sure to check for similar existing issues -->
|
||||||
|
|
||||||
|
**Description:**
|
||||||
|
A clear and concise description of what the bug is.
|
||||||
|
|
||||||
|
**Action version:**
|
||||||
|
Specify the action version
|
||||||
|
|
||||||
|
**Platform:**
|
||||||
|
- [ ] Ubuntu
|
||||||
|
- [ ] macOS
|
||||||
|
- [ ] Windows
|
||||||
|
|
||||||
|
**Runner type:**
|
||||||
|
- [ ] Hosted
|
||||||
|
- [ ] Self-hosted
|
||||||
|
|
||||||
|
**Tools version:**
|
||||||
|
<!--- Please specify versions of node and package manager (npm, yarn, pnpm and etc)-->
|
||||||
|
|
||||||
|
**Repro steps:**
|
||||||
|
A description with steps to reproduce the issue. If you have a public example or repo to share, please provide the link.
|
||||||
|
|
||||||
|
**Expected behavior:**
|
||||||
|
A description of what you expected to happen.
|
||||||
|
|
||||||
|
**Actual behavior:**
|
||||||
|
A description of what is actually happening.
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
blank_issues_enabled: false
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
---
|
||||||
|
name: Feature request
|
||||||
|
about: Suggest an idea for this project
|
||||||
|
title: ''
|
||||||
|
labels: feature request, needs triage
|
||||||
|
assignees: ''
|
||||||
|
---
|
||||||
|
<!--- Please direct any generic questions related to actions to our support community forum at https://github.community/c/code-to-cloud/github-actions/41 --->
|
||||||
|
<!--- Before opening up a new feature request, please make sure to check for similar existing issues and pull requests -->
|
||||||
|
|
||||||
|
**Description:**
|
||||||
|
Describe your proposal.
|
||||||
|
|
||||||
|
**Justification:**
|
||||||
|
Justification or a use case for your proposal.
|
||||||
|
|
||||||
|
**Are you willing to submit a PR?**
|
||||||
|
<!--- We accept contributions! -->
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
# To get started with Dependabot version updates, you'll need to specify which
|
||||||
|
# package ecosystems to update and where the package manifests are located.
|
||||||
|
# Please see the documentation for all configuration options:
|
||||||
|
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
|
||||||
|
|
||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
# Enable version updates for npm
|
||||||
|
- package-ecosystem: 'npm'
|
||||||
|
# Look for `package.json` and `lock` files in the `root` directory
|
||||||
|
directory: '/'
|
||||||
|
# Check the npm registry for updates every day (weekdays)
|
||||||
|
schedule:
|
||||||
|
interval: 'weekly'
|
||||||
|
|
||||||
|
# Enable version updates for GitHub Actions
|
||||||
|
- package-ecosystem: 'github-actions'
|
||||||
|
# Workflow files stored in the default location of `.github/workflows`
|
||||||
|
# You don't need to specify `/.github/workflows` for `directory`. You can use `directory: "/"`.
|
||||||
|
directory: '/'
|
||||||
|
schedule:
|
||||||
|
interval: 'weekly'
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
"owner": "eslint-compact",
|
"owner": "eslint-compact",
|
||||||
"pattern": [
|
"pattern": [
|
||||||
{
|
{
|
||||||
"regexp": "^(.+):\\sline\\s(\\d+),\\scol\\s(\\d+),\\s(Error|Warning|Info)\\s-\\s(.+)\\s\\((.+)\\)$",
|
"regexp": "^(.+):\\sline\\s(\\d+),\\scol\\s(\\d+),\\s([Ee]rror|[Ww]arning|[Ii]nfo)\\s-\\s(.+)\\s\\((.+)\\)$",
|
||||||
"file": 1,
|
"file": 1,
|
||||||
"line": 2,
|
"line": 2,
|
||||||
"column": 3,
|
"column": 3,
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
"owner": "eslint-stylish",
|
"owner": "eslint-stylish",
|
||||||
"pattern": [
|
"pattern": [
|
||||||
{
|
{
|
||||||
"regexp": "^([^\\s].*)$",
|
"regexp": "^\\s*([^\\s].*)$",
|
||||||
"file": 1
|
"file": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
**Description:**
|
||||||
|
Describe your changes.
|
||||||
|
|
||||||
|
**Related issue:**
|
||||||
|
Add link to the related issue.
|
||||||
|
|
||||||
|
**Check list:**
|
||||||
|
- [ ] Mark if documentation changes are required.
|
||||||
|
- [ ] Mark if tests were added or updated to cover the changes.
|
||||||
|
|
@ -4,14 +4,15 @@
|
||||||
"owner": "tsc",
|
"owner": "tsc",
|
||||||
"pattern": [
|
"pattern": [
|
||||||
{
|
{
|
||||||
"regexp": "^(?:\\s+\\d+\\>)?([^\\s].*)\\((\\d+|\\d+,\\d+|\\d+,\\d+,\\d+,\\d+)\\)\\s*:\\s+(error|warning|info)\\s+(\\w{1,2}\\d+)\\s*:\\s*(.*)$",
|
"regexp": "^([^\\s].*)[\\(:](\\d+)[,:](\\d+)(?:\\):\\s+|\\s+-\\s+)(error|warning|info)\\s+TS(\\d+)\\s*:\\s*(.*)$",
|
||||||
"file": 1,
|
"file": 1,
|
||||||
"location": 2,
|
"line": 2,
|
||||||
"severity": 3,
|
"column": 3,
|
||||||
"code": 4,
|
"severity": 4,
|
||||||
"message": 5
|
"code": 5,
|
||||||
|
"message": 6
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
name: Basic validation
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
paths-ignore:
|
||||||
|
- '**.md'
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- releases/*
|
||||||
|
paths-ignore:
|
||||||
|
- '**.md'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
call-basic-validation:
|
||||||
|
name: Basic validation
|
||||||
|
uses: actions/reusable-workflows/.github/workflows/basic-validation.yml@main
|
||||||
|
with:
|
||||||
|
node-version: '24.x'
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
name: Check dist
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
paths-ignore:
|
||||||
|
- '**.md'
|
||||||
|
pull_request:
|
||||||
|
paths-ignore:
|
||||||
|
- '**.md'
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
call-check-dist:
|
||||||
|
name: Check dist/
|
||||||
|
uses: actions/reusable-workflows/.github/workflows/check-dist.yml@main
|
||||||
|
with:
|
||||||
|
node-version: '24.x'
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
name: CodeQL analysis
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
pull_request:
|
||||||
|
branches: [main]
|
||||||
|
schedule:
|
||||||
|
- cron: '0 3 * * 0'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
call-codeQL-analysis:
|
||||||
|
name: CodeQL analysis
|
||||||
|
uses: actions/reusable-workflows/.github/workflows/codeql-analysis.yml@main
|
||||||
|
|
@ -0,0 +1,304 @@
|
||||||
|
name: e2e-cache
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
paths-ignore:
|
||||||
|
- '**.md'
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- releases/*
|
||||||
|
paths-ignore:
|
||||||
|
- '**.md'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
node-npm-depencies-caching:
|
||||||
|
name: Test npm (Node ${{ matrix.node-version}}, ${{ matrix.os }})
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
|
||||||
|
node-version: [20, 22, 24]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- name: Clean global cache
|
||||||
|
run: npm cache clean --force
|
||||||
|
- name: Setup Node
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
node-version: ${{ matrix.node-version }}
|
||||||
|
cache: 'npm'
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm install
|
||||||
|
- name: Verify node and npm
|
||||||
|
run: __tests__/verify-node.sh "${{ matrix.node-version }}"
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
node-pnpm-depencies-caching:
|
||||||
|
name: Test pnpm (Node ${{ matrix.node-version}}, ${{ matrix.os }})
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
|
||||||
|
node-version: [20, 22, 24]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- name: Install pnpm
|
||||||
|
uses: pnpm/action-setup@v4
|
||||||
|
with:
|
||||||
|
version: 6.10.0
|
||||||
|
- name: Generate pnpm file
|
||||||
|
run: pnpm install
|
||||||
|
- name: Remove dependencies
|
||||||
|
shell: pwsh
|
||||||
|
run: Remove-Item node_modules -Force -Recurse
|
||||||
|
- name: Clean global cache
|
||||||
|
run: rm -rf ~/.pnpm-store
|
||||||
|
shell: bash
|
||||||
|
- name: Setup Node
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
node-version: ${{ matrix.node-version }}
|
||||||
|
cache: 'pnpm'
|
||||||
|
- name: Install dependencies
|
||||||
|
run: pnpm install
|
||||||
|
- name: Verify node and pnpm
|
||||||
|
run: __tests__/verify-node.sh "${{ matrix.node-version }}"
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
node-yarn1-depencies-caching:
|
||||||
|
name: Test yarn 1 (Node ${{ matrix.node-version}}, ${{ matrix.os }})
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
|
||||||
|
node-version: [20, 22, 24]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- name: Yarn version
|
||||||
|
run: yarn --version
|
||||||
|
- name: Generate yarn file
|
||||||
|
run: yarn install --ignore-engines
|
||||||
|
- name: Remove dependencies
|
||||||
|
shell: pwsh
|
||||||
|
run: Remove-Item node_modules -Force -Recurse
|
||||||
|
- name: Clean global cache
|
||||||
|
run: yarn cache clean
|
||||||
|
- name: Setup Node
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
node-version: ${{ matrix.node-version }}
|
||||||
|
cache: 'yarn'
|
||||||
|
- name: Install dependencies
|
||||||
|
run: yarn install --ignore-engines
|
||||||
|
- name: Verify node and yarn
|
||||||
|
run: __tests__/verify-node.sh "${{ matrix.node-version }}"
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
node-yarn3-depencies-caching:
|
||||||
|
name: Test yarn 3 (Node ${{ matrix.node-version}}, ${{ matrix.os }})
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
env:
|
||||||
|
YARN_ENABLE_IMMUTABLE_INSTALLS: false
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
|
||||||
|
node-version: [20, 22, 24]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- name: Update yarn
|
||||||
|
run: yarn set version 3.6.4
|
||||||
|
- name: Yarn version
|
||||||
|
run: yarn --version
|
||||||
|
- name: Generate simple .yarnrc.yml
|
||||||
|
run: |
|
||||||
|
echo "nodeLinker: node-modules" >> .yarnrc.yml
|
||||||
|
- name: Generate yarn file
|
||||||
|
run: yarn install
|
||||||
|
- name: Remove dependencies
|
||||||
|
shell: pwsh
|
||||||
|
run: Remove-Item node_modules -Force -Recurse
|
||||||
|
- name: Clean global cache
|
||||||
|
run: yarn cache clean --all
|
||||||
|
- name: Setup Node
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
node-version: ${{ matrix.node-version }}
|
||||||
|
cache: 'yarn'
|
||||||
|
- name: Install dependencies
|
||||||
|
run: yarn install
|
||||||
|
- name: Verify node and yarn
|
||||||
|
run: __tests__/verify-node.sh "${{ matrix.node-version }}"
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
yarn-subprojects:
|
||||||
|
name: Test yarn subprojects
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
node-version: [20, 22, 24]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
|
||||||
|
- name: prepare sub-projects
|
||||||
|
run: __tests__/prepare-yarn-subprojects.sh yarn1
|
||||||
|
|
||||||
|
# expect
|
||||||
|
# - no errors
|
||||||
|
# - log
|
||||||
|
# ##[debug]Cache Paths:
|
||||||
|
# ##[debug]["sub2/.yarn/cache","sub3/.yarn/cache","../../../.cache/yarn/v6"]
|
||||||
|
- name: Setup Node
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
node-version: ${{ matrix.node-version }}
|
||||||
|
cache: 'yarn'
|
||||||
|
cache-dependency-path: |
|
||||||
|
**/*.lock
|
||||||
|
yarn.lock
|
||||||
|
|
||||||
|
yarn-subprojects-berry-local:
|
||||||
|
name: Test yarn subprojects all locally managed
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
node-version: [20, 22, 24]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
|
||||||
|
- name: prepare sub-projects
|
||||||
|
run: __tests__/prepare-yarn-subprojects.sh keepcache keepcache
|
||||||
|
|
||||||
|
# expect
|
||||||
|
# - no errors
|
||||||
|
# - log
|
||||||
|
# ##[info]All dependencies are managed locally by yarn3, the previous cache can be used
|
||||||
|
# ##[debug]["node-cache-Linux-yarn-401024703386272f1a950c9f014cbb1bb79a7a5b6e1fb00e8b90d06734af41ee","node-cache-Linux-yarn"]
|
||||||
|
- name: Setup Node
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
node-version: ${{ matrix.node-version }}
|
||||||
|
cache: 'yarn'
|
||||||
|
cache-dependency-path: |
|
||||||
|
sub2/*.lock
|
||||||
|
sub3/*.lock
|
||||||
|
|
||||||
|
yarn-subprojects-berry-global:
|
||||||
|
name: Test yarn subprojects some locally managed
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
node-version: [20, 22, 24]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
|
||||||
|
- name: prepare sub-projects
|
||||||
|
run: __tests__/prepare-yarn-subprojects.sh global
|
||||||
|
|
||||||
|
# expect
|
||||||
|
# - no errors
|
||||||
|
# - log must
|
||||||
|
# ##[debug]"/home/runner/work/setup-node-test/setup-node-test/sub2" dependencies are managed by yarn 3 locally
|
||||||
|
# ##[debug]"/home/runner/work/setup-node-test/setup-node-test/sub3" dependencies are not managed by yarn 3 locally
|
||||||
|
- name: Setup Node
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
node-version: ${{ matrix.node-version }}
|
||||||
|
cache: 'yarn'
|
||||||
|
cache-dependency-path: |
|
||||||
|
sub2/*.lock
|
||||||
|
sub3/*.lock
|
||||||
|
|
||||||
|
yarn-subprojects-berry-git:
|
||||||
|
name: Test yarn subprojects managed by git
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
node-version: [20, 22, 24]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
|
||||||
|
- name: prepare sub-projects
|
||||||
|
run: /bin/bash __tests__/prepare-yarn-subprojects.sh keepcache
|
||||||
|
|
||||||
|
# expect
|
||||||
|
# - no errors
|
||||||
|
# - log
|
||||||
|
# [debug]"/home/runner/work/setup-node-test/setup-node-test/sub2" has .yarn/cache - dependencies are kept in the repository
|
||||||
|
# [debug]"/home/runner/work/setup-node-test/setup-node-test/sub3" has .yarn/cache - dependencies are kept in the repository
|
||||||
|
# [debug]["node-cache-Linux-yarn-401024703386272f1a950c9f014cbb1bb79a7a5b6e1fb00e8b90d06734af41ee"]
|
||||||
|
- name: Setup Node
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
node-version: ${{ matrix.node-version }}
|
||||||
|
cache: 'yarn'
|
||||||
|
cache-dependency-path: |
|
||||||
|
sub2/*.lock
|
||||||
|
sub3/*.lock
|
||||||
|
|
||||||
|
node-npm-packageManager-auto-cache:
|
||||||
|
name: Test auto cache with top-level packageManager
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
|
||||||
|
node-version: [20, 22, 24]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- name: Create package.json with packageManager field
|
||||||
|
run: |
|
||||||
|
echo '{ "name": "test-project", "version": "1.0.0", "packageManager": "npm@8.0.0" }' > package.json
|
||||||
|
- name: Clean global cache
|
||||||
|
run: npm cache clean --force
|
||||||
|
- name: Setup Node with caching enabled
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
node-version: ${{ matrix.node-version }}
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm install
|
||||||
|
- name: Verify node and npm
|
||||||
|
run: __tests__/verify-node.sh "${{ matrix.node-version }}"
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
node-npm-devEngines-auto-cache:
|
||||||
|
name: Test auto cache with devEngines.packageManager
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
|
||||||
|
node-version: [20, 22, 24]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- name: Create package.json with devEngines field
|
||||||
|
run: |
|
||||||
|
echo '{
|
||||||
|
"name": "test-project",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"devEngines": {
|
||||||
|
"packageManager": {
|
||||||
|
"name": "npm",
|
||||||
|
"onFail": "error"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}' > package.json
|
||||||
|
- name: Clean global cache
|
||||||
|
run: npm cache clean --force
|
||||||
|
- name: Setup Node with caching enabled
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
node-version: ${{ matrix.node-version }}
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm install
|
||||||
|
- name: Verify node and npm
|
||||||
|
run: __tests__/verify-node.sh "${{ matrix.node-version }}"
|
||||||
|
shell: bash
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
name: Licensed
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
call-licensed:
|
||||||
|
name: Licensed
|
||||||
|
uses: actions/reusable-workflows/.github/workflows/licensed.yml@main
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
name: proxy
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
paths-ignore:
|
||||||
|
- '**.md'
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- releases/*
|
||||||
|
paths-ignore:
|
||||||
|
- '**.md'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test-proxy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ubuntu:latest
|
||||||
|
options: --dns 127.0.0.1
|
||||||
|
services:
|
||||||
|
squid-proxy:
|
||||||
|
image: ubuntu/squid:latest
|
||||||
|
ports:
|
||||||
|
- 3128:3128
|
||||||
|
env:
|
||||||
|
https_proxy: http://squid-proxy:3128
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- name: Clear tool cache
|
||||||
|
run: rm -rf $RUNNER_TOOL_CACHE/*
|
||||||
|
- name: Setup node 24
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
node-version: 24.x
|
||||||
|
- name: Verify node and npm
|
||||||
|
run: __tests__/verify-node.sh 24
|
||||||
|
|
||||||
|
test-bypass-proxy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
https_proxy: http://no-such-proxy:3128
|
||||||
|
no_proxy: api.github.com,github.com,nodejs.org,registry.npmjs.org,*.s3.amazonaws.com,s3.amazonaws.com
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- name: Clear tool cache
|
||||||
|
run: rm -rf $RUNNER_TOOL_CACHE/*
|
||||||
|
- name: Setup node 24
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
node-version: 24
|
||||||
|
- name: Verify node and npm
|
||||||
|
run: __tests__/verify-node.sh 24
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
name: 'Publish Immutable Action Version'
|
||||||
|
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [published]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
publish:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
id-token: write
|
||||||
|
packages: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checking out
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
- name: Publish
|
||||||
|
id: publish
|
||||||
|
uses: actions/publish-immutable-action@v0.0.4
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
name: Release new action version
|
||||||
|
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [released]
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
TAG_NAME:
|
||||||
|
description: 'Tag name that the major tag will point to'
|
||||||
|
required: true
|
||||||
|
|
||||||
|
env:
|
||||||
|
TAG_NAME: ${{ github.event.inputs.TAG_NAME || github.event.release.tag_name }}
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
update_tag:
|
||||||
|
name: Update the major tag to include the ${{ github.event.inputs.TAG_NAME || github.event.release.tag_name }} changes
|
||||||
|
environment:
|
||||||
|
name: releaseNewActionVersion
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Update the ${{ env.TAG_NAME }} tag
|
||||||
|
uses: actions/publish-action@v0.4.0
|
||||||
|
with:
|
||||||
|
source-tag: ${{ env.TAG_NAME }}
|
||||||
|
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
name: Update configuration files
|
||||||
|
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
- cron: '0 3 * * 0'
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
call-update-configuration-files:
|
||||||
|
name: Update configuration files
|
||||||
|
uses: actions/reusable-workflows/.github/workflows/update-config-files.yml@main
|
||||||
|
|
@ -0,0 +1,292 @@
|
||||||
|
name: versions
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
paths-ignore:
|
||||||
|
- '**.md'
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- releases/*
|
||||||
|
paths-ignore:
|
||||||
|
- '**.md'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
local-cache:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
|
||||||
|
node-version: [20, 22, 24]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- name: Setup Node
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
node-version: ${{ matrix.node-version }}
|
||||||
|
- name: Verify node and npm
|
||||||
|
run: __tests__/verify-node.sh "${{ matrix.node-version }}"
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
lts-syntax:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, windows-latest, macos-latest-large]
|
||||||
|
node-version: [lts/dubnium, lts/erbium, lts/fermium, lts/*, lts/-1]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- name: Setup Node
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
node-version: ${{ matrix.node-version }}
|
||||||
|
check-latest: true
|
||||||
|
- if: runner.os != 'Windows' && runner.os != 'macOS'
|
||||||
|
name: Verify node and npm
|
||||||
|
run: |
|
||||||
|
. "$NVM_DIR/nvm.sh"
|
||||||
|
[[ $(nvm version-remote "${{ matrix.node-version }}") =~ ^v([^.]+) ]]
|
||||||
|
__tests__/verify-node.sh "${BASH_REMATCH[1]}"
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
v8-canary-syntax:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
|
||||||
|
node-version:
|
||||||
|
[
|
||||||
|
'20-v8-canary',
|
||||||
|
'20.0.0-v8-canary',
|
||||||
|
'20.0.0-v8-canary20221101e50e45c9f8'
|
||||||
|
]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- name: Setup Node
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
node-version: ${{ matrix.node-version }}
|
||||||
|
- name: Verify node and npm
|
||||||
|
run: |
|
||||||
|
canaryVersion="${{ matrix.node-version }}"
|
||||||
|
majorVersion=$(echo $canaryVersion | cut -d- -f1)
|
||||||
|
__tests__/verify-node.sh "$majorVersion"
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
nightly-syntax:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
|
||||||
|
node-version: [20-nightly, 25-nightly, 24.0.0-nightly]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- name: Setup Node
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
node-version: ${{ matrix.node-version }}
|
||||||
|
- name: Verify node and npm
|
||||||
|
run: |
|
||||||
|
nightlyVersion="${{ matrix.node-version }}"
|
||||||
|
majorVersion=$(echo $nightlyVersion | cut -d- -f1)
|
||||||
|
__tests__/verify-node.sh "$majorVersion"
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
rc-syntax:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
|
||||||
|
node-version: [20.0.0-rc.1, 22.14.0-rc.1, 24.0.0-rc.4]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- name: Setup Node
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
node-version: ${{ matrix.node-version }}
|
||||||
|
- name: Verify node and npm
|
||||||
|
run: |
|
||||||
|
rcVersion="${{ matrix.node-version }}"
|
||||||
|
majorVersion=$(echo $rcVersion | cut -d- -f1)
|
||||||
|
__tests__/verify-node.sh "$majorVersion"
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
manifest:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
|
||||||
|
node-version: [20.10.0, 22.0.0, 24.9.0]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- name: Setup Node
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
node-version: ${{ matrix.node-version }}
|
||||||
|
- name: Verify node and npm
|
||||||
|
run: __tests__/verify-node.sh "${{ matrix.node-version }}"
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
check-latest:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
|
||||||
|
node-version: [20, 22, 24]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- name: Setup Node and check latest
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
node-version: ${{ matrix.node-version }}
|
||||||
|
check-latest: true
|
||||||
|
- name: Verify node and npm
|
||||||
|
run: __tests__/verify-node.sh "${{ matrix.node-version }}"
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
version-file:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
|
||||||
|
node-version-file:
|
||||||
|
[.nvmrc, .tool-versions, .tool-versions-node, package.json]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- name: Setup node from node version file
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
node-version-file: '__tests__/data/${{ matrix.node-version-file }}'
|
||||||
|
- name: Verify node
|
||||||
|
run: __tests__/verify-node.sh 24
|
||||||
|
|
||||||
|
version-file-dev-engines:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- name: Setup node from node version file
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
node-version-file: '__tests__/data/package-dev-engines.json'
|
||||||
|
- name: Verify node
|
||||||
|
run: __tests__/verify-node.sh 20
|
||||||
|
|
||||||
|
version-file-volta:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- name: Setup node from node version file
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
node-version-file: '__tests__/data/package-volta.json'
|
||||||
|
- name: Verify node
|
||||||
|
run: __tests__/verify-node.sh 24
|
||||||
|
|
||||||
|
version-file-volta-extends:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- name: Setup node from node version file
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
node-version-file: '__tests__/data/package-volta-extends.json'
|
||||||
|
- name: Verify node
|
||||||
|
run: __tests__/verify-node.sh 24
|
||||||
|
|
||||||
|
node-dist:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
|
||||||
|
node-version: [21, 23]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- name: Setup Node from dist
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
node-version: ${{ matrix.node-version }}
|
||||||
|
- name: Verify node and npm
|
||||||
|
run: __tests__/verify-node.sh "${{ matrix.node-version }}"
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
old-versions:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, windows-latest, macos-latest-large]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
# test old versions which didn't have npm and layout different
|
||||||
|
- name: Setup node 0.12.18 from dist
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
node-version: 0.12.18
|
||||||
|
- name: Verify node
|
||||||
|
run: __tests__/verify-node.sh 0.12.18 SKIP_NPM
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
arch:
|
||||||
|
runs-on: windows-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- name: Setup node 20 x86 from dist
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
node-version: '20'
|
||||||
|
architecture: 'x86'
|
||||||
|
- name: Verify node
|
||||||
|
run: __tests__/verify-arch.sh "ia32"
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
node-latest-aliases:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
|
||||||
|
node-version: [current, latest, node]
|
||||||
|
steps:
|
||||||
|
- name: Get node version
|
||||||
|
run: |
|
||||||
|
latestNodeVersion=$(curl https://nodejs.org/dist/index.json | jq -r '. [0].version')
|
||||||
|
echo "LATEST_NODE_VERSION=$latestNodeVersion" >> $GITHUB_OUTPUT
|
||||||
|
id: version
|
||||||
|
shell: bash
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- name: Setup Node
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
node-version: ${{ matrix.node-version }}
|
||||||
|
- name: Retrieve version after install
|
||||||
|
run: |
|
||||||
|
updatedVersion=$(echo $(node --version))
|
||||||
|
echo "NODE_VERSION_UPDATED=$updatedVersion" >> $GITHUB_OUTPUT
|
||||||
|
id: updatedVersion
|
||||||
|
shell: bash
|
||||||
|
- name: Compare versions
|
||||||
|
if: ${{ steps.version.outputs.LATEST_NODE_VERSION != steps.updatedVersion.outputs.NODE_VERSION_UPDATED}}
|
||||||
|
run: |
|
||||||
|
echo "Latest node version failed to download."
|
||||||
|
exit 1
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
name: Main workflow
|
|
||||||
on: [push]
|
|
||||||
jobs:
|
|
||||||
run:
|
|
||||||
name: Run
|
|
||||||
runs-on: ${{ matrix.operating-system }}
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
operating-system: [ubuntu-latest, windows-latest]
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@master
|
|
||||||
|
|
||||||
- name: Set Node.js 10.x
|
|
||||||
uses: actions/setup-node@master
|
|
||||||
with:
|
|
||||||
version: 10.x
|
|
||||||
|
|
||||||
- name: npm install
|
|
||||||
run: npm install
|
|
||||||
|
|
||||||
- name: Lint
|
|
||||||
run: npm run format-check
|
|
||||||
|
|
||||||
- name: npm test
|
|
||||||
run: npm test
|
|
||||||
|
|
@ -1,2 +1,110 @@
|
||||||
!node_modules/
|
node_modules/
|
||||||
|
lib/
|
||||||
__tests__/runner/*
|
__tests__/runner/*
|
||||||
|
|
||||||
|
validate/temp
|
||||||
|
validate/node
|
||||||
|
|
||||||
|
# Rest of the file pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
|
||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
|
||||||
|
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||||
|
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||||
|
|
||||||
|
# Runtime data
|
||||||
|
pids
|
||||||
|
*.pid
|
||||||
|
*.seed
|
||||||
|
*.pid.lock
|
||||||
|
|
||||||
|
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||||
|
lib-cov
|
||||||
|
|
||||||
|
# Coverage directory used by tools like istanbul
|
||||||
|
coverage
|
||||||
|
*.lcov
|
||||||
|
|
||||||
|
# nyc test coverage
|
||||||
|
.nyc_output
|
||||||
|
|
||||||
|
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||||
|
.grunt
|
||||||
|
|
||||||
|
# Bower dependency directory (https://bower.io/)
|
||||||
|
bower_components
|
||||||
|
|
||||||
|
# node-waf configuration
|
||||||
|
.lock-wscript
|
||||||
|
|
||||||
|
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||||
|
build/Release
|
||||||
|
|
||||||
|
# Dependency directories
|
||||||
|
jspm_packages/
|
||||||
|
|
||||||
|
# TypeScript v1 declaration files
|
||||||
|
typings/
|
||||||
|
|
||||||
|
# TypeScript cache
|
||||||
|
*.tsbuildinfo
|
||||||
|
|
||||||
|
# Optional npm cache directory
|
||||||
|
.npm
|
||||||
|
|
||||||
|
# Optional eslint cache
|
||||||
|
.eslintcache
|
||||||
|
|
||||||
|
# Optional REPL history
|
||||||
|
.node_repl_history
|
||||||
|
|
||||||
|
# Output of 'npm pack'
|
||||||
|
*.tgz
|
||||||
|
|
||||||
|
# Yarn Integrity file
|
||||||
|
.yarn-integrity
|
||||||
|
|
||||||
|
# dotenv environment variables file
|
||||||
|
.env
|
||||||
|
.env.test
|
||||||
|
|
||||||
|
# parcel-bundler cache (https://parceljs.org/)
|
||||||
|
.cache
|
||||||
|
|
||||||
|
# next.js build output
|
||||||
|
.next
|
||||||
|
|
||||||
|
# nuxt.js build output
|
||||||
|
.nuxt
|
||||||
|
|
||||||
|
# vuepress build output
|
||||||
|
.vuepress/dist
|
||||||
|
|
||||||
|
# Serverless directories
|
||||||
|
.serverless/
|
||||||
|
|
||||||
|
# FuseBox cache
|
||||||
|
.fusebox/
|
||||||
|
|
||||||
|
# DynamoDB Local files
|
||||||
|
.dynamodb/
|
||||||
|
|
||||||
|
# Ignore everything inside fixture package-manager folders
|
||||||
|
__tests__/data/npm/**
|
||||||
|
__tests__/data/pnpm/**
|
||||||
|
__tests__/data/yarn/**
|
||||||
|
|
||||||
|
# Keep only fixture manifests + lockfiles
|
||||||
|
!__tests__/data/npm/package.json
|
||||||
|
!__tests__/data/npm/package-lock.json
|
||||||
|
|
||||||
|
!__tests__/data/pnpm/package.json
|
||||||
|
!__tests__/data/pnpm/pnpm-lock.yaml
|
||||||
|
|
||||||
|
!__tests__/data/yarn/package.json
|
||||||
|
!__tests__/data/yarn/yarn.lock
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
sources:
|
||||||
|
npm: true
|
||||||
|
|
||||||
|
allowed:
|
||||||
|
- apache-2.0
|
||||||
|
- 0bsd
|
||||||
|
- bsd-2-clause
|
||||||
|
- bsd-3-clause
|
||||||
|
- isc
|
||||||
|
- mit
|
||||||
|
- cc0-1.0
|
||||||
|
- unlicense
|
||||||
|
|
||||||
|
reviewed:
|
||||||
|
npm:
|
||||||
|
- "@actions/http-client"
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,7 @@
|
||||||
|
# Ignore list
|
||||||
|
/*
|
||||||
|
|
||||||
|
# Do not ignore these folders:
|
||||||
|
!__tests__/
|
||||||
|
!.github/
|
||||||
|
!src/
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
// This is a reusable configuration file copied from https://github.com/actions/reusable-workflows/tree/main/reusable-configurations. Please don't make changes to this file as it's the subject of an automatic update.
|
||||||
|
module.exports = {
|
||||||
|
printWidth: 80,
|
||||||
|
tabWidth: 2,
|
||||||
|
useTabs: false,
|
||||||
|
semi: true,
|
||||||
|
singleQuote: true,
|
||||||
|
trailingComma: 'none',
|
||||||
|
bracketSpacing: false,
|
||||||
|
arrowParens: 'avoid'
|
||||||
|
};
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
{
|
|
||||||
"printWidth": 80,
|
|
||||||
"tabWidth": 2,
|
|
||||||
"useTabs": false,
|
|
||||||
"semi": true,
|
|
||||||
"singleQuote": true,
|
|
||||||
"trailingComma": "none",
|
|
||||||
"bracketSpacing": false,
|
|
||||||
"arrowParens": "avoid",
|
|
||||||
"parser": "typescript"
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
{
|
||||||
|
// Use IntelliSense to learn about possible attributes.
|
||||||
|
// Hover to view descriptions of existing attributes.
|
||||||
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Debug Jest Tests on Nix",
|
||||||
|
"type": "node",
|
||||||
|
"request": "launch",
|
||||||
|
"runtimeArgs": [
|
||||||
|
"--inspect-brk",
|
||||||
|
"${workspaceRoot}/node_modules/.bin/jest",
|
||||||
|
"--runInBand"
|
||||||
|
],
|
||||||
|
"console": "integratedTerminal",
|
||||||
|
"internalConsoleOptions": "neverOpen",
|
||||||
|
"port": 9229
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
* @actions/setup-actions-team
|
||||||
|
|
@ -0,0 +1,76 @@
|
||||||
|
# Contributor Covenant Code of Conduct
|
||||||
|
|
||||||
|
## Our Pledge
|
||||||
|
|
||||||
|
In the interest of fostering an open and welcoming environment, we as
|
||||||
|
contributors and maintainers pledge to make participation in our project and
|
||||||
|
our community a harassment-free experience for everyone, regardless of age, body
|
||||||
|
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
||||||
|
level of experience, education, socio-economic status, nationality, personal
|
||||||
|
appearance, race, religion, or sexual identity and orientation.
|
||||||
|
|
||||||
|
## Our Standards
|
||||||
|
|
||||||
|
Examples of behavior that contributes to creating a positive environment
|
||||||
|
include:
|
||||||
|
|
||||||
|
* Using welcoming and inclusive language
|
||||||
|
* Being respectful of differing viewpoints and experiences
|
||||||
|
* Gracefully accepting constructive criticism
|
||||||
|
* Focusing on what is best for the community
|
||||||
|
* Showing empathy towards other community members
|
||||||
|
|
||||||
|
Examples of unacceptable behavior by participants include:
|
||||||
|
|
||||||
|
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||||
|
advances
|
||||||
|
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||||
|
* Public or private harassment
|
||||||
|
* Publishing others' private information, such as a physical or electronic
|
||||||
|
address, without explicit permission
|
||||||
|
* Other conduct which could reasonably be considered inappropriate in a
|
||||||
|
professional setting
|
||||||
|
|
||||||
|
## Our Responsibilities
|
||||||
|
|
||||||
|
Project maintainers are responsible for clarifying the standards of acceptable
|
||||||
|
behavior and are expected to take appropriate and fair corrective action in
|
||||||
|
response to any instances of unacceptable behavior.
|
||||||
|
|
||||||
|
Project maintainers have the right and responsibility to remove, edit, or
|
||||||
|
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||||
|
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||||
|
permanently any contributor for other behaviors that they deem inappropriate,
|
||||||
|
threatening, offensive, or harmful.
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
|
||||||
|
This Code of Conduct applies within all project spaces, and it also applies when
|
||||||
|
an individual is representing the project or its community in public spaces.
|
||||||
|
Examples of representing a project or community include using an official
|
||||||
|
project e-mail address, posting via an official social media account, or acting
|
||||||
|
as an appointed representative at an online or offline event. Representation of
|
||||||
|
a project may be further defined and clarified by project maintainers.
|
||||||
|
|
||||||
|
## Enforcement
|
||||||
|
|
||||||
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||||
|
reported by contacting the project team at opensource@github.com. All
|
||||||
|
complaints will be reviewed and investigated and will result in a response that
|
||||||
|
is deemed necessary and appropriate to the circumstances. The project team is
|
||||||
|
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||||
|
Further details of specific enforcement policies may be posted separately.
|
||||||
|
|
||||||
|
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||||
|
faith may face temporary or permanent repercussions as determined by other
|
||||||
|
members of the project's leadership.
|
||||||
|
|
||||||
|
## Attribution
|
||||||
|
|
||||||
|
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||||
|
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
||||||
|
|
||||||
|
[homepage]: https://www.contributor-covenant.org
|
||||||
|
|
||||||
|
For answers to common questions about this code of conduct, see
|
||||||
|
https://www.contributor-covenant.org/faq
|
||||||
264
README.md
264
README.md
|
|
@ -1,48 +1,274 @@
|
||||||
# setup-node
|
# setup-node
|
||||||
|
|
||||||
This action sets by node environment for use in actions by:
|
[](https://github.com/actions/setup-node/actions/workflows/basic-validation.yml)
|
||||||
|
[](https://github.com/actions/setup-node/actions/workflows/versions.yml)
|
||||||
|
[](https://github.com/actions/setup-node/actions/workflows/e2e-cache.yml)
|
||||||
|
[](https://github.com/actions/setup-node/actions/workflows/proxy.yml)
|
||||||
|
|
||||||
- optionally downloading and caching a version of node - npm by version spec and add to PATH
|
This action provides the following functionality for GitHub Actions users:
|
||||||
- registering problem matchers for error output
|
|
||||||
|
|
||||||
# Usage
|
- Optionally downloading and caching distribution of the requested Node.js version, and adding it to the PATH
|
||||||
|
- Optionally caching npm/yarn/pnpm dependencies
|
||||||
|
- Registering problem matchers for error output
|
||||||
|
- Configuring authentication for GPR or npm
|
||||||
|
|
||||||
|
## Breaking changes in V6
|
||||||
|
|
||||||
|
- Caching is now automatically enabled for npm projects when either the `devEngines.packageManager` field or the top-level `packageManager` field in `package.json` is set to `npm`. For other package managers, such as Yarn and pnpm, caching is disabled by default and must be configured manually using the `cache` input.
|
||||||
|
|
||||||
|
- The `always-auth` input has been removed, as it is deprecated and will no longer be supported in future npm releases. To ensure your workflows continue to run without warnings or errors, please remove any references to `always-auth` from your configuration.
|
||||||
|
|
||||||
|
## Breaking changes in V5
|
||||||
|
|
||||||
|
- Enabled caching by default with package manager detection if no cache input is provided.
|
||||||
|
> For workflows with elevated privileges or access to sensitive information, we recommend disabling automatic caching by setting `package-manager-cache: false` when caching is not needed for secure operation.
|
||||||
|
|
||||||
|
- Upgraded action from node20 to node24.
|
||||||
|
> Make sure your runner is on version v2.327.1 or later to ensure compatibility with this release. [See Release Notes](https://github.com/actions/runner/releases/tag/v2.327.1)
|
||||||
|
|
||||||
|
For more details, see the full release notes on the [releases page](https://github.com/actions/setup-node/releases/v5.0.0)
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
See [action.yml](action.yml)
|
See [action.yml](action.yml)
|
||||||
|
|
||||||
Basic:
|
<!-- start usage -->
|
||||||
|
```yaml
|
||||||
|
- uses: actions/setup-node@v6
|
||||||
|
with:
|
||||||
|
# Version Spec of the version to use in SemVer notation.
|
||||||
|
# It also admits such aliases as lts/*, latest, nightly and canary builds
|
||||||
|
# Examples: 12.x, 10.15.1, >=10.15.0, lts/Hydrogen, 16-nightly, latest, node
|
||||||
|
node-version: ''
|
||||||
|
|
||||||
|
# File containing the version Spec of the version to use. Examples: package.json, .nvmrc, .node-version, .tool-versions.
|
||||||
|
# If node-version and node-version-file are both provided the action will use version from node-version.
|
||||||
|
node-version-file: ''
|
||||||
|
|
||||||
|
# Set this option if you want the action to check for the latest available version
|
||||||
|
# that satisfies the version spec.
|
||||||
|
# It will only get affect for lts Nodejs versions (12.x, >=10.15.0, lts/Hydrogen).
|
||||||
|
# Default: false
|
||||||
|
check-latest: false
|
||||||
|
|
||||||
|
# Target architecture for Node to use. Examples: x86, x64. Will use system architecture by default.
|
||||||
|
# Default: ''. The action use system architecture by default
|
||||||
|
architecture: ''
|
||||||
|
|
||||||
|
# Used to pull node distributions from https://github.com/actions/node-versions.
|
||||||
|
# Since there's a default, this is typically not supplied by the user.
|
||||||
|
# When running this action on github.com, the default value is sufficient.
|
||||||
|
# When running on GHES, you can pass a personal access token for github.com if you are experiencing rate limiting.
|
||||||
|
#
|
||||||
|
# We recommend using a service account with the least permissions necessary. Also
|
||||||
|
# when generating a new PAT, select the least scopes necessary.
|
||||||
|
#
|
||||||
|
# [Learn more about creating and using encrypted secrets](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets)
|
||||||
|
#
|
||||||
|
# Default: ${{ github.server_url == 'https://github.com' && github.token || '' }}
|
||||||
|
token: ''
|
||||||
|
|
||||||
|
# Used to specify a package manager for caching in the default directory. Supported values: npm, yarn, pnpm.
|
||||||
|
# Package manager should be pre-installed
|
||||||
|
# Default: ''
|
||||||
|
cache: ''
|
||||||
|
|
||||||
|
# Controls automatic caching for npm. By default, caching for npm is enabled if either the devEngines.packageManager field or the top-level packageManager field in package.json specifies npm and no explicit cache input is provided.
|
||||||
|
# To disable automatic caching for npm, set package-manager-cache to false.
|
||||||
|
# default: true
|
||||||
|
package-manager-cache: true
|
||||||
|
|
||||||
|
# Used to specify the path to a dependency file: package-lock.json, yarn.lock, etc.
|
||||||
|
# It will generate hash from the target file for primary key. It works only If cache is specified.
|
||||||
|
# Supports wildcards or a list of file names for caching multiple dependencies.
|
||||||
|
# Default: ''
|
||||||
|
cache-dependency-path: ''
|
||||||
|
|
||||||
|
# Optional registry to set up for auth. Will set the registry in a project level .npmrc and .yarnrc file,
|
||||||
|
# and set up auth to read in from env.NODE_AUTH_TOKEN.
|
||||||
|
# Default: ''
|
||||||
|
registry-url: ''
|
||||||
|
|
||||||
|
# Optional scope for authenticating against scoped registries.
|
||||||
|
# Will fall back to the repository owner when using the GitHub Packages registry (https://npm.pkg.github.com/).
|
||||||
|
# Default: ''
|
||||||
|
scope: ''
|
||||||
|
|
||||||
|
# Optional mirror to download binaries from.
|
||||||
|
# Artifacts need to match the official Node.js
|
||||||
|
# Example:
|
||||||
|
# V8 Canary Build: <mirror_url>/download/v8-canary
|
||||||
|
# RC Build: <mirror_url>/download/rc
|
||||||
|
# Official: Build <mirror_url>/dist
|
||||||
|
# Nightly build: <mirror_url>/download/nightly
|
||||||
|
# Default: ''
|
||||||
|
mirror: ''
|
||||||
|
|
||||||
|
# Optional mirror token.
|
||||||
|
# The token will be used as a bearer token in the Authorization header
|
||||||
|
# Default: ''
|
||||||
|
mirror-token: ''
|
||||||
|
```
|
||||||
|
<!-- end usage -->
|
||||||
|
|
||||||
|
**Basic:**
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@master
|
- uses: actions/checkout@v6
|
||||||
- uses: actions/setup-node@v1
|
- uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
version: '10.x'
|
node-version: 24
|
||||||
- run: npm install
|
- run: npm ci
|
||||||
- run: npm test
|
- run: npm test
|
||||||
```
|
```
|
||||||
|
|
||||||
Matrix Testing:
|
The `node-version` input is optional. If not supplied, the node version from PATH will be used. However, it is recommended to always specify Node.js version and not rely on the system one.
|
||||||
|
|
||||||
|
The action will first check the local cache for a semver match. If unable to find a specific version in the cache, the action will attempt to download a version of Node.js. It will pull LTS versions from [node-versions releases](https://github.com/actions/node-versions/releases) and on miss or failure will fall back to the previous behavior of downloading directly from [node dist](https://nodejs.org/dist/).
|
||||||
|
|
||||||
|
For information regarding locally cached versions of Node.js on GitHub hosted runners, check out [GitHub Actions Runner Images](https://github.com/actions/runner-images).
|
||||||
|
|
||||||
|
### Supported version syntax
|
||||||
|
|
||||||
|
The `node-version` input supports the Semantic Versioning Specification, for more detailed examples please refer to [the semver package documentation](https://github.com/npm/node-semver).
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
- Major versions: `22`, `24`
|
||||||
|
- More specific versions: `20.19`, `22.17.1` , `24.8.0`
|
||||||
|
- NVM LTS syntax: `lts/iron`, `lts/jod`, `lts/*`, `lts/-n`
|
||||||
|
- Latest release: `*` or `latest`/`current`/`node`
|
||||||
|
|
||||||
|
**Note:** Like the other values, `*` will get the latest [locally-cached Node.js version](https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2204-Readme.md#nodejs), or the latest version from [actions/node-versions](https://github.com/actions/node-versions/blob/main/versions-manifest.json), depending on the [`check-latest`](docs/advanced-usage.md#check-latest-version) input.
|
||||||
|
|
||||||
|
`current`/`latest`/`node` always resolve to the latest [dist version](https://nodejs.org/dist/index.json).
|
||||||
|
That version is then downloaded from actions/node-versions if possible, or directly from Node.js if not.
|
||||||
|
Since it will not be cached always, there is possibility of hitting rate limit when downloading from dist
|
||||||
|
|
||||||
|
### Checking in lockfiles
|
||||||
|
|
||||||
|
It's **strongly recommended** to commit the lockfile of your package manager for security and performance reasons. For more information consult the "Working with lockfiles" section of the [Advanced usage](docs/advanced-usage.md#working-with-lockfiles) guide.
|
||||||
|
|
||||||
|
## Caching global packages data
|
||||||
|
|
||||||
|
The action has a built-in functionality for caching and restoring dependencies. It uses [actions/cache](https://github.com/actions/cache) under the hood for caching global packages data but requires less configuration settings. Supported package managers are `npm`, `yarn`, `pnpm` (v6.10+). The `cache` input is optional.
|
||||||
|
|
||||||
|
The action defaults to search for the dependency file (`package-lock.json`, `npm-shrinkwrap.json` or `yarn.lock`) in the repository root, and uses its hash as a part of the cache key. Use `cache-dependency-path` for cases when multiple dependency files are used, or they are located in different subdirectories.
|
||||||
|
|
||||||
|
**Note:** The action does not cache `node_modules`
|
||||||
|
|
||||||
|
See the examples of using cache for `yarn`/`pnpm` and `cache-dependency-path` input in the [Advanced usage](docs/advanced-usage.md#caching-packages-data) guide.
|
||||||
|
|
||||||
|
**Caching npm dependencies:**
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- uses: actions/setup-node@v6
|
||||||
|
with:
|
||||||
|
node-version: 24
|
||||||
|
cache: 'npm'
|
||||||
|
- run: npm ci
|
||||||
|
- run: npm test
|
||||||
|
```
|
||||||
|
|
||||||
|
**Caching npm dependencies in monorepos:**
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- uses: actions/setup-node@v6
|
||||||
|
with:
|
||||||
|
node-version: 24
|
||||||
|
cache: 'npm'
|
||||||
|
cache-dependency-path: subdir/package-lock.json
|
||||||
|
- run: npm ci
|
||||||
|
- run: npm test
|
||||||
|
```
|
||||||
|
|
||||||
|
Caching for npm dependencies is automatically enabled when your `package.json` contains either `devEngines.packageManager` field or top-level `packageManager` field set to `npm`, and no explicit cache input is provided.
|
||||||
|
|
||||||
|
This behavior is controlled by the `package-manager-cache` input, which defaults to `true`. To turn off automatic caching, set `package-manager-cache` to `false`.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- uses: actions/setup-node@v6
|
||||||
|
with:
|
||||||
|
package-manager-cache: false
|
||||||
|
- run: npm ci
|
||||||
|
```
|
||||||
|
> If your `package.json` file does not include a `packageManager` field set to `npm`, caching will be disabled unless you explicitly enable it. For workflows with elevated privileges or access to sensitive information, we recommend disabling automatic caching for npm by setting `package-manager-cache: false` when caching is not required for secure operation.
|
||||||
|
|
||||||
|
## Matrix Testing
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-16.04
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
node: [ '10', '8' ]
|
node: [ 20, 22, 24 ]
|
||||||
name: Node ${{ matrix.node }} sample
|
name: Node ${{ matrix.node }} sample
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@master
|
- uses: actions/checkout@v6
|
||||||
- name: Setup node
|
- name: Setup node
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
version: ${{ matrix.node }}
|
node-version: ${{ matrix.node }}
|
||||||
- run: npm install
|
- run: npm ci
|
||||||
- run: npm test
|
- run: npm test
|
||||||
```
|
```
|
||||||
|
|
||||||
# License
|
## Using `setup-node` on GHES
|
||||||
|
|
||||||
|
`setup-node` comes pre-installed on the appliance with GHES if Actions is enabled. When dynamically downloading Nodejs distributions, `setup-node` downloads distributions from [`actions/node-versions`](https://github.com/actions/node-versions) on github.com (outside of the appliance). These calls to `actions/node-versions` are made via unauthenticated requests, which are limited to [60 requests per hour per IP](https://docs.github.com/en/rest/overview/resources-in-the-rest-api#rate-limiting). If more requests are made within the time frame, then you will start to see rate-limit errors during downloading that looks like: `##[error]API rate limit exceeded for...`. After that error the action will try to download versions directly from the official site, but it also can have rate limit so it's better to put token.
|
||||||
|
|
||||||
|
To get a higher rate limit, you can [generate a personal access token on github.com](https://github.com/settings/tokens/new) and pass it as the `token` input for the action:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
uses: actions/setup-node@v6
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GH_DOTCOM_TOKEN }}
|
||||||
|
node-version: 24
|
||||||
|
```
|
||||||
|
|
||||||
|
If the runner is not able to access github.com, any Nodejs versions requested during a workflow run must come from the runner's tool cache. See "[Setting up the tool cache on self-hosted runners without internet access](https://docs.github.com/en/enterprise-server@3.2/admin/github-actions/managing-access-to-actions-from-githubcom/setting-up-the-tool-cache-on-self-hosted-runners-without-internet-access)" for more information.
|
||||||
|
|
||||||
|
## Advanced usage
|
||||||
|
|
||||||
|
- [Check latest version](docs/advanced-usage.md#check-latest-version)
|
||||||
|
- [Using a node version file](docs/advanced-usage.md#node-version-file)
|
||||||
|
- [Using different architectures](docs/advanced-usage.md#architecture)
|
||||||
|
- [Using v8 canary versions](docs/advanced-usage.md#v8-canary-versions)
|
||||||
|
- [Using nightly versions](docs/advanced-usage.md#nightly-versions)
|
||||||
|
- [Using rc versions](docs/advanced-usage.md#rc-versions)
|
||||||
|
- [Caching packages data](docs/advanced-usage.md#caching-packages-data)
|
||||||
|
- [Using multiple operating systems and architectures](docs/advanced-usage.md#multiple-operating-systems-and-architectures)
|
||||||
|
- [Publishing to npmjs and GPR with npm](docs/advanced-usage.md#publish-to-npmjs-and-gpr-with-npm)
|
||||||
|
- [Publishing to npmjs and GPR with yarn](docs/advanced-usage.md#publish-to-npmjs-and-gpr-with-yarn)
|
||||||
|
- [Using private packages](docs/advanced-usage.md#use-private-packages)
|
||||||
|
- [Publishing to npm with Trusted Publisher (OIDC)](docs/advanced-usage.md#publishing-to-npm-with-trusted-publisher-oidc)
|
||||||
|
- [Using private mirror](docs/advanced-usage.md#use-private-mirror)
|
||||||
|
|
||||||
|
## Recommended permissions
|
||||||
|
|
||||||
|
When using the `setup-node` action in your GitHub Actions workflow, it is recommended to set the following permissions to ensure proper functionality:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
permissions:
|
||||||
|
contents: read # access to check out code and install dependencies
|
||||||
|
```
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
The scripts and documentation in this project are released under the [MIT License](LICENSE)
|
The scripts and documentation in this project are released under the [MIT License](LICENSE)
|
||||||
|
|
||||||
# Contributions
|
## Contributions
|
||||||
|
|
||||||
Contributions are welcome! See [Contributor's Guide](docs/contributors.md)
|
Contributions are welcome! See [Contributor's Guide](docs/contributors.md)
|
||||||
|
|
||||||
|
## Code of Conduct
|
||||||
|
|
||||||
|
:wave: Be nice. See [our code of conduct](CODE_OF_CONDUCT.md)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
Files located in data directory are used only for testing purposes.
|
||||||
|
|
||||||
|
|
||||||
|
## Here the list of files in the data directory
|
||||||
|
- `.nvmrc`, `.tools-versions` and `package.json` are used to test node-version-file logic
|
||||||
|
- `package-lock.json`, `pnpm-lock.yaml` and `yarn.lock` are used to test cache logic
|
||||||
|
- `versions-manifest.json` is used for unit testing to check downloading Node.js versions from the node-versions repository.
|
||||||
|
- `node-dist-index.json` is used for unit testing to check downloading Node.js versions from the official site. The file was constructed from https://nodejs.org/dist/index.json
|
||||||
|
- `node-rc-index.json` is used for unit testing to check downloading Node.js rc versions from the official site. The file was constructed from https://nodejs.org/download/rc/index.json
|
||||||
|
- `node-nightly-index.json` is used for unit testing to check downloading Node.js nightly builds from the official site. The file was constructed from https://nodejs.org/download/nightly/index.json
|
||||||
|
|
@ -0,0 +1,221 @@
|
||||||
|
import os from 'os';
|
||||||
|
import fs from 'fs';
|
||||||
|
import * as path from 'path';
|
||||||
|
import * as core from '@actions/core';
|
||||||
|
import * as io from '@actions/io';
|
||||||
|
import * as auth from '../src/authutil';
|
||||||
|
import * as cacheUtils from '../src/cache-utils';
|
||||||
|
|
||||||
|
let rcFile: string;
|
||||||
|
|
||||||
|
describe('authutil tests', () => {
|
||||||
|
const _runnerDir = path.join(__dirname, 'runner');
|
||||||
|
|
||||||
|
let cnSpy: jest.SpyInstance;
|
||||||
|
let logSpy: jest.SpyInstance;
|
||||||
|
let dbgSpy: jest.SpyInstance;
|
||||||
|
|
||||||
|
beforeAll(async () => {
|
||||||
|
const randPath = path.join(Math.random().toString(36).substring(7));
|
||||||
|
console.log('::stop-commands::stoptoken'); // Disable executing of runner commands when running tests in actions
|
||||||
|
process.env['GITHUB_ENV'] = ''; // Stub out Environment file functionality so we can verify it writes to standard out (toolkit is backwards compatible)
|
||||||
|
const tempDir = path.join(_runnerDir, randPath, 'temp');
|
||||||
|
await io.rmRF(tempDir);
|
||||||
|
await io.mkdirP(tempDir);
|
||||||
|
process.env['GITHUB_REPOSITORY'] = 'OwnerName/repo';
|
||||||
|
process.env['RUNNER_TEMP'] = tempDir;
|
||||||
|
rcFile = path.join(tempDir, '.npmrc');
|
||||||
|
}, 100000);
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await io.rmRF(rcFile);
|
||||||
|
// if (fs.existsSync(rcFile)) {
|
||||||
|
// fs.unlinkSync(rcFile);
|
||||||
|
// }
|
||||||
|
process.env['INPUT_SCOPE'] = '';
|
||||||
|
|
||||||
|
// writes
|
||||||
|
cnSpy = jest.spyOn(process.stdout, 'write');
|
||||||
|
logSpy = jest.spyOn(console, 'log');
|
||||||
|
dbgSpy = jest.spyOn(core, 'debug');
|
||||||
|
cnSpy.mockImplementation(line => {
|
||||||
|
// uncomment to debug
|
||||||
|
// process.stderr.write('write:' + line + '\n');
|
||||||
|
});
|
||||||
|
logSpy.mockImplementation(line => {
|
||||||
|
// uncomment to debug
|
||||||
|
// process.stderr.write('log:' + line + '\n');
|
||||||
|
});
|
||||||
|
dbgSpy.mockImplementation(msg => {
|
||||||
|
// uncomment to see debug output
|
||||||
|
// process.stderr.write(msg + '\n');
|
||||||
|
});
|
||||||
|
}, 100000);
|
||||||
|
|
||||||
|
function dbg(message: string) {
|
||||||
|
process.stderr.write('dbg::' + message + '::\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
afterAll(async () => {
|
||||||
|
if (_runnerDir) {
|
||||||
|
await io.rmRF(_runnerDir);
|
||||||
|
}
|
||||||
|
console.log('::stoptoken::'); // Re-enable executing of runner commands when running tests in actions
|
||||||
|
}, 100000);
|
||||||
|
|
||||||
|
function readRcFile(rcFile: string) {
|
||||||
|
const rc = {};
|
||||||
|
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
|
||||||
|
for (const line of contents.split(os.EOL)) {
|
||||||
|
const parts = line.split('=');
|
||||||
|
if (parts.length == 2) {
|
||||||
|
rc[parts[0].trim()] = parts[1].trim();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
it('Sets up npmrc for npmjs', async () => {
|
||||||
|
await auth.configAuthentication('https://registry.npmjs.org/');
|
||||||
|
|
||||||
|
expect(fs.statSync(rcFile)).toBeDefined();
|
||||||
|
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
|
||||||
|
const rc = readRcFile(rcFile);
|
||||||
|
expect(rc['registry']).toBe('https://registry.npmjs.org/');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Appends trailing slash to registry', async () => {
|
||||||
|
await auth.configAuthentication('https://registry.npmjs.org');
|
||||||
|
|
||||||
|
expect(fs.statSync(rcFile)).toBeDefined();
|
||||||
|
const rc = readRcFile(rcFile);
|
||||||
|
expect(rc['registry']).toBe('https://registry.npmjs.org/');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Configures scoped npm registries', async () => {
|
||||||
|
process.env['INPUT_SCOPE'] = 'myScope';
|
||||||
|
await auth.configAuthentication('https://registry.npmjs.org');
|
||||||
|
|
||||||
|
expect(fs.statSync(rcFile)).toBeDefined();
|
||||||
|
const rc = readRcFile(rcFile);
|
||||||
|
expect(rc['@myscope:registry']).toBe('https://registry.npmjs.org/');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Automatically configures GPR scope', async () => {
|
||||||
|
await auth.configAuthentication('npm.pkg.github.com');
|
||||||
|
|
||||||
|
expect(fs.statSync(rcFile)).toBeDefined();
|
||||||
|
const rc = readRcFile(rcFile);
|
||||||
|
expect(rc['@ownername:registry']).toBe('npm.pkg.github.com/');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('is already set the NODE_AUTH_TOKEN export it', async () => {
|
||||||
|
process.env.NODE_AUTH_TOKEN = 'foobar';
|
||||||
|
await auth.configAuthentication('npm.pkg.github.com');
|
||||||
|
expect(fs.statSync(rcFile)).toBeDefined();
|
||||||
|
const rc = readRcFile(rcFile);
|
||||||
|
expect(rc['@ownername:registry']).toBe('npm.pkg.github.com/');
|
||||||
|
expect(process.env.NODE_AUTH_TOKEN).toEqual('foobar');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not export NODE_AUTH_TOKEN if not set in environment', async () => {
|
||||||
|
const exportSpy = jest.spyOn(core, 'exportVariable');
|
||||||
|
delete process.env.NODE_AUTH_TOKEN;
|
||||||
|
await auth.configAuthentication('https://registry.npmjs.org/');
|
||||||
|
expect(fs.statSync(rcFile)).toBeDefined();
|
||||||
|
const rc = readRcFile(rcFile);
|
||||||
|
expect(rc['registry']).toBe('https://registry.npmjs.org/');
|
||||||
|
expect(exportSpy).not.toHaveBeenCalledWith(
|
||||||
|
'NODE_AUTH_TOKEN',
|
||||||
|
expect.anything()
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should export NODE_AUTH_TOKEN if set to empty string', async () => {
|
||||||
|
const exportSpy = jest.spyOn(core, 'exportVariable');
|
||||||
|
process.env.NODE_AUTH_TOKEN = '';
|
||||||
|
await auth.configAuthentication('https://registry.npmjs.org/');
|
||||||
|
expect(fs.statSync(rcFile)).toBeDefined();
|
||||||
|
expect(exportSpy).toHaveBeenCalledWith('NODE_AUTH_TOKEN', '');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('configAuthentication should overwrite non-scoped with non-scoped', async () => {
|
||||||
|
fs.writeFileSync(rcFile, 'registry=NNN');
|
||||||
|
await auth.configAuthentication('https://registry.npmjs.org/');
|
||||||
|
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
|
||||||
|
expect(contents).toBe(
|
||||||
|
`//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}registry=https://registry.npmjs.org/`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('configAuthentication should overwrite only non-scoped', async () => {
|
||||||
|
fs.writeFileSync(rcFile, `registry=NNN${os.EOL}@myscope:registry=MMM`);
|
||||||
|
await auth.configAuthentication('https://registry.npmjs.org/');
|
||||||
|
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
|
||||||
|
expect(contents).toBe(
|
||||||
|
`@myscope:registry=MMM${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}registry=https://registry.npmjs.org/`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('configAuthentication should add non-scoped to scoped', async () => {
|
||||||
|
fs.writeFileSync(rcFile, '@myscope:registry=NNN');
|
||||||
|
await auth.configAuthentication('https://registry.npmjs.org/');
|
||||||
|
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
|
||||||
|
expect(contents).toBe(
|
||||||
|
`@myscope:registry=NNN${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}registry=https://registry.npmjs.org/`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('configAuthentication should overwrite scoped with scoped', async () => {
|
||||||
|
process.env['INPUT_SCOPE'] = 'myscope';
|
||||||
|
fs.writeFileSync(rcFile, `@myscope:registry=NNN`);
|
||||||
|
await auth.configAuthentication('https://registry.npmjs.org/');
|
||||||
|
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
|
||||||
|
expect(contents).toBe(
|
||||||
|
`//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('configAuthentication should overwrite only scoped', async () => {
|
||||||
|
process.env['INPUT_SCOPE'] = 'myscope';
|
||||||
|
fs.writeFileSync(rcFile, `registry=NNN${os.EOL}@myscope:registry=MMM`);
|
||||||
|
await auth.configAuthentication('https://registry.npmjs.org/');
|
||||||
|
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
|
||||||
|
expect(contents).toBe(
|
||||||
|
`registry=NNN${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('configAuthentication should add scoped to non-scoped', async () => {
|
||||||
|
process.env['INPUT_SCOPE'] = 'myscope';
|
||||||
|
fs.writeFileSync(rcFile, `registry=MMM`);
|
||||||
|
await auth.configAuthentication('https://registry.npmjs.org/');
|
||||||
|
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
|
||||||
|
expect(contents).toBe(
|
||||||
|
`registry=MMM${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('configAuthentication should overwrite only one scoped', async () => {
|
||||||
|
process.env['INPUT_SCOPE'] = 'myscope';
|
||||||
|
fs.writeFileSync(
|
||||||
|
rcFile,
|
||||||
|
`@otherscope:registry=NNN${os.EOL}@myscope:registry=MMM`
|
||||||
|
);
|
||||||
|
await auth.configAuthentication('https://registry.npmjs.org/');
|
||||||
|
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
|
||||||
|
expect(contents).toBe(
|
||||||
|
`@otherscope:registry=NNN${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('configAuthentication should add scoped to another scoped', async () => {
|
||||||
|
process.env['INPUT_SCOPE'] = 'myscope';
|
||||||
|
fs.writeFileSync(rcFile, `@otherscope:registry=MMM`);
|
||||||
|
await auth.configAuthentication('https://registry.npmjs.org/');
|
||||||
|
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
|
||||||
|
expect(contents).toBe(
|
||||||
|
`@otherscope:registry=MMM${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -0,0 +1,202 @@
|
||||||
|
import * as core from '@actions/core';
|
||||||
|
import * as cache from '@actions/cache';
|
||||||
|
import * as path from 'path';
|
||||||
|
import * as glob from '@actions/glob';
|
||||||
|
import osm from 'os';
|
||||||
|
|
||||||
|
import * as utils from '../src/cache-utils';
|
||||||
|
import {restoreCache} from '../src/cache-restore';
|
||||||
|
|
||||||
|
describe('cache-restore', () => {
|
||||||
|
const packageManagers = ['yarn', 'npm', 'pnpm'] as const;
|
||||||
|
type PackageManager = (typeof packageManagers)[number];
|
||||||
|
|
||||||
|
const setWorkspaceFor = (pm: PackageManager) => {
|
||||||
|
process.env['GITHUB_WORKSPACE'] = path.join(__dirname, 'data', pm);
|
||||||
|
};
|
||||||
|
const originalGithubWorkspace = process.env['GITHUB_WORKSPACE'];
|
||||||
|
if (!process.env.RUNNER_OS) {
|
||||||
|
process.env.RUNNER_OS = 'Linux';
|
||||||
|
}
|
||||||
|
const platform = process.env.RUNNER_OS;
|
||||||
|
const arch = 'arm64';
|
||||||
|
const commonPath = '/some/random/path';
|
||||||
|
const npmCachePath = `${commonPath}/npm`;
|
||||||
|
const pnpmCachePath = `${commonPath}/pnpm`;
|
||||||
|
const yarn1CachePath = `${commonPath}/yarn1`;
|
||||||
|
const yarn2CachePath = `${commonPath}/yarn2`;
|
||||||
|
const yarnFileHash =
|
||||||
|
'b8a0bae5243251f7c07dd52d1f78ff78281dfefaded700a176261b6b54fa245b';
|
||||||
|
const npmFileHash =
|
||||||
|
'abf7c9b306a3149dcfba4673e2362755503bcceaab46f0e4e6fee0ade493e20c';
|
||||||
|
const pnpmFileHash =
|
||||||
|
'26309058093e84713f38869c50cf1cee9b08155ede874ec1b44ce3fca8c68c70';
|
||||||
|
const cachesObject: Record<string, string> = {
|
||||||
|
[npmCachePath]: npmFileHash,
|
||||||
|
[pnpmCachePath]: pnpmFileHash,
|
||||||
|
[yarn1CachePath]: yarnFileHash,
|
||||||
|
[yarn2CachePath]: yarnFileHash
|
||||||
|
};
|
||||||
|
|
||||||
|
function findCacheFolder(command: string) {
|
||||||
|
switch (command) {
|
||||||
|
case 'npm config get cache':
|
||||||
|
return npmCachePath;
|
||||||
|
case 'pnpm store path --silent':
|
||||||
|
return pnpmCachePath;
|
||||||
|
case 'yarn cache dir':
|
||||||
|
return yarn1CachePath;
|
||||||
|
case 'yarn config get cacheFolder':
|
||||||
|
return yarn2CachePath;
|
||||||
|
default:
|
||||||
|
return 'packge/not/found';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let saveStateSpy: jest.SpyInstance;
|
||||||
|
let infoSpy: jest.SpyInstance;
|
||||||
|
let debugSpy: jest.SpyInstance;
|
||||||
|
let setOutputSpy: jest.SpyInstance;
|
||||||
|
let getCommandOutputSpy: jest.SpyInstance;
|
||||||
|
let restoreCacheSpy: jest.SpyInstance;
|
||||||
|
let hashFilesSpy: jest.SpyInstance;
|
||||||
|
let archSpy: jest.SpyInstance;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
// core
|
||||||
|
infoSpy = jest.spyOn(core, 'info');
|
||||||
|
infoSpy.mockImplementation(() => undefined);
|
||||||
|
|
||||||
|
debugSpy = jest.spyOn(core, 'debug');
|
||||||
|
debugSpy.mockImplementation(() => undefined);
|
||||||
|
|
||||||
|
setOutputSpy = jest.spyOn(core, 'setOutput');
|
||||||
|
setOutputSpy.mockImplementation(() => undefined);
|
||||||
|
|
||||||
|
saveStateSpy = jest.spyOn(core, 'saveState');
|
||||||
|
saveStateSpy.mockImplementation(() => undefined);
|
||||||
|
|
||||||
|
// glob
|
||||||
|
hashFilesSpy = jest.spyOn(glob, 'hashFiles');
|
||||||
|
hashFilesSpy.mockImplementation((pattern: string) => {
|
||||||
|
if (pattern.includes('package-lock.json')) {
|
||||||
|
return npmFileHash;
|
||||||
|
} else if (pattern.includes('pnpm-lock.yaml')) {
|
||||||
|
return pnpmFileHash;
|
||||||
|
} else if (pattern.includes('yarn.lock')) {
|
||||||
|
return yarnFileHash;
|
||||||
|
} else {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// cache
|
||||||
|
restoreCacheSpy = jest.spyOn(cache, 'restoreCache');
|
||||||
|
restoreCacheSpy.mockImplementation(
|
||||||
|
(cachePaths: Array<string>, key: string) => {
|
||||||
|
if (!cachePaths || cachePaths.length === 0) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
const cachPath = cachePaths[0];
|
||||||
|
const fileHash = cachesObject[cachPath];
|
||||||
|
|
||||||
|
if (key.includes(fileHash)) {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// cache-utils
|
||||||
|
getCommandOutputSpy = jest.spyOn(utils, 'getCommandOutput');
|
||||||
|
|
||||||
|
// os
|
||||||
|
archSpy = jest.spyOn(osm, 'arch');
|
||||||
|
archSpy.mockImplementation(() => arch);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Validate provided package manager', () => {
|
||||||
|
it.each([['npm7'], ['npm6'], ['pnpm6'], ['yarn1'], ['yarn2'], ['random']])(
|
||||||
|
'Throw an error because %s is not supported',
|
||||||
|
async packageManager => {
|
||||||
|
await expect(restoreCache(packageManager, '')).rejects.toThrow(
|
||||||
|
`Caching for '${packageManager}' is not supported`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Restore dependencies', () => {
|
||||||
|
it.each([
|
||||||
|
['yarn', '2.1.2', yarnFileHash],
|
||||||
|
['yarn', '1.2.3', yarnFileHash],
|
||||||
|
['npm', '', npmFileHash],
|
||||||
|
['pnpm', '', pnpmFileHash]
|
||||||
|
] as const)(
|
||||||
|
'restored dependencies for %s',
|
||||||
|
async (packageManager, toolVersion, fileHash) => {
|
||||||
|
// Set workspace to the appropriate fixture folder
|
||||||
|
setWorkspaceFor(packageManager);
|
||||||
|
getCommandOutputSpy.mockImplementation((command: string) => {
|
||||||
|
if (command.includes('version')) {
|
||||||
|
return toolVersion;
|
||||||
|
} else {
|
||||||
|
return findCacheFolder(command);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
await restoreCache(packageManager, '');
|
||||||
|
expect(hashFilesSpy).toHaveBeenCalled();
|
||||||
|
expect(infoSpy).toHaveBeenCalledWith(
|
||||||
|
`Cache restored from key: node-cache-${platform}-${arch}-${packageManager}-${fileHash}`
|
||||||
|
);
|
||||||
|
expect(infoSpy).not.toHaveBeenCalledWith(
|
||||||
|
`${packageManager} cache is not found`
|
||||||
|
);
|
||||||
|
expect(setOutputSpy).toHaveBeenCalledWith('cache-hit', true);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Dependencies changed', () => {
|
||||||
|
it.each([
|
||||||
|
['yarn', '2.1.2', yarnFileHash],
|
||||||
|
['yarn', '1.2.3', yarnFileHash],
|
||||||
|
['npm', '', npmFileHash],
|
||||||
|
['pnpm', '', pnpmFileHash]
|
||||||
|
] as const)(
|
||||||
|
'dependencies are changed %s',
|
||||||
|
async (packageManager, toolVersion, fileHash) => {
|
||||||
|
// Set workspace to the appropriate fixture folder
|
||||||
|
setWorkspaceFor(packageManager);
|
||||||
|
getCommandOutputSpy.mockImplementation((command: string) => {
|
||||||
|
if (command.includes('version')) {
|
||||||
|
return toolVersion;
|
||||||
|
} else {
|
||||||
|
return findCacheFolder(command);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
restoreCacheSpy.mockImplementationOnce(() => undefined);
|
||||||
|
await restoreCache(packageManager, '');
|
||||||
|
expect(hashFilesSpy).toHaveBeenCalled();
|
||||||
|
expect(infoSpy).toHaveBeenCalledWith(
|
||||||
|
`${packageManager} cache is not found`
|
||||||
|
);
|
||||||
|
expect(setOutputSpy).toHaveBeenCalledWith('cache-hit', false);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
if (originalGithubWorkspace === undefined) {
|
||||||
|
delete process.env['GITHUB_WORKSPACE'];
|
||||||
|
} else {
|
||||||
|
process.env['GITHUB_WORKSPACE'] = originalGithubWorkspace;
|
||||||
|
}
|
||||||
|
jest.resetAllMocks();
|
||||||
|
jest.clearAllMocks();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -0,0 +1,392 @@
|
||||||
|
import * as core from '@actions/core';
|
||||||
|
import * as cache from '@actions/cache';
|
||||||
|
import * as glob from '@actions/glob';
|
||||||
|
import fs from 'fs';
|
||||||
|
import path from 'path';
|
||||||
|
|
||||||
|
import * as utils from '../src/cache-utils';
|
||||||
|
import {run} from '../src/cache-save';
|
||||||
|
import {State} from '../src/constants';
|
||||||
|
|
||||||
|
describe('run', () => {
|
||||||
|
const yarnFileHash =
|
||||||
|
'b8a0bae5243251f7c07dd52d1f78ff78281dfefaded700a176261b6b54fa245b';
|
||||||
|
const npmFileHash =
|
||||||
|
'abf7c9b306a3149dcfba4673e2362755503bcceaab46f0e4e6fee0ade493e20c';
|
||||||
|
const pnpmFileHash =
|
||||||
|
'26309058093e84713f38869c50cf1cee9b08155ede874ec1b44ce3fca8c68c70';
|
||||||
|
const commonPath = '/some/random/path';
|
||||||
|
process.env['GITHUB_WORKSPACE'] = path.join(__dirname, 'data');
|
||||||
|
|
||||||
|
const inputs = {} as any;
|
||||||
|
|
||||||
|
let getInputSpy: jest.SpyInstance;
|
||||||
|
let infoSpy: jest.SpyInstance;
|
||||||
|
let warningSpy: jest.SpyInstance;
|
||||||
|
let debugSpy: jest.SpyInstance;
|
||||||
|
let setFailedSpy: jest.SpyInstance;
|
||||||
|
let getStateSpy: jest.SpyInstance;
|
||||||
|
let saveCacheSpy: jest.SpyInstance;
|
||||||
|
let getCommandOutputSpy: jest.SpyInstance;
|
||||||
|
let hashFilesSpy: jest.SpyInstance;
|
||||||
|
let existsSpy: jest.SpyInstance;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
getInputSpy = jest.spyOn(core, 'getInput');
|
||||||
|
getInputSpy.mockImplementation((name: string) => inputs[name]);
|
||||||
|
|
||||||
|
infoSpy = jest.spyOn(core, 'info');
|
||||||
|
infoSpy.mockImplementation(() => undefined);
|
||||||
|
|
||||||
|
warningSpy = jest.spyOn(core, 'warning');
|
||||||
|
warningSpy.mockImplementation(() => undefined);
|
||||||
|
|
||||||
|
setFailedSpy = jest.spyOn(core, 'setFailed');
|
||||||
|
setFailedSpy.mockImplementation(() => undefined);
|
||||||
|
|
||||||
|
debugSpy = jest.spyOn(core, 'debug');
|
||||||
|
debugSpy.mockImplementation(() => undefined);
|
||||||
|
|
||||||
|
getStateSpy = jest.spyOn(core, 'getState');
|
||||||
|
|
||||||
|
// cache
|
||||||
|
saveCacheSpy = jest.spyOn(cache, 'saveCache');
|
||||||
|
saveCacheSpy.mockImplementation(() => undefined);
|
||||||
|
|
||||||
|
// glob
|
||||||
|
hashFilesSpy = jest.spyOn(glob, 'hashFiles');
|
||||||
|
hashFilesSpy.mockImplementation((pattern: string) => {
|
||||||
|
if (pattern.includes('package-lock.json')) {
|
||||||
|
return npmFileHash;
|
||||||
|
} else if (pattern.includes('yarn.lock')) {
|
||||||
|
return yarnFileHash;
|
||||||
|
} else {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
existsSpy = jest.spyOn(fs, 'existsSync');
|
||||||
|
existsSpy.mockImplementation(() => true);
|
||||||
|
|
||||||
|
// utils
|
||||||
|
getCommandOutputSpy = jest.spyOn(utils, 'getCommandOutput');
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
existsSpy.mockRestore();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Package manager validation', () => {
|
||||||
|
it('Package manager is not provided, skip caching', async () => {
|
||||||
|
inputs['cache'] = '';
|
||||||
|
|
||||||
|
await run();
|
||||||
|
|
||||||
|
expect(setFailedSpy).not.toHaveBeenCalled();
|
||||||
|
expect(infoSpy).not.toHaveBeenCalled();
|
||||||
|
expect(saveCacheSpy).not.toHaveBeenCalled();
|
||||||
|
expect(debugSpy).toHaveBeenLastCalledWith(
|
||||||
|
"Caching for '' is not supported"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Package manager is not valid, skip caching', async () => {
|
||||||
|
inputs['cache'] = 'yarn3';
|
||||||
|
getStateSpy.mockImplementation(key =>
|
||||||
|
key === State.CachePackageManager ? inputs['cache'] : ''
|
||||||
|
);
|
||||||
|
|
||||||
|
await run();
|
||||||
|
|
||||||
|
expect(setFailedSpy).not.toHaveBeenCalled();
|
||||||
|
expect(infoSpy).not.toHaveBeenCalled();
|
||||||
|
expect(saveCacheSpy).not.toHaveBeenCalled();
|
||||||
|
expect(debugSpy).toHaveBeenLastCalledWith(
|
||||||
|
"Caching for 'yarn3' is not supported"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Validate unchanged cache is not saved', () => {
|
||||||
|
it('should not save cache for yarn1', async () => {
|
||||||
|
inputs['cache'] = 'yarn';
|
||||||
|
getStateSpy.mockImplementation(key =>
|
||||||
|
key === State.CachePackageManager
|
||||||
|
? inputs['cache']
|
||||||
|
: key === State.CachePrimaryKey || key === State.CacheMatchedKey
|
||||||
|
? yarnFileHash
|
||||||
|
: key === State.CachePaths
|
||||||
|
? '["/foo/bar"]'
|
||||||
|
: 'not expected'
|
||||||
|
);
|
||||||
|
|
||||||
|
await run();
|
||||||
|
|
||||||
|
expect(getInputSpy).not.toHaveBeenCalled();
|
||||||
|
expect(getStateSpy).toHaveBeenCalledTimes(4);
|
||||||
|
expect(getCommandOutputSpy).toHaveBeenCalledTimes(0);
|
||||||
|
expect(debugSpy).toHaveBeenCalledTimes(0);
|
||||||
|
expect(infoSpy).toHaveBeenCalledWith(
|
||||||
|
`Cache hit occurred on the primary key ${yarnFileHash}, not saving cache.`
|
||||||
|
);
|
||||||
|
expect(setFailedSpy).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not save cache for yarn2', async () => {
|
||||||
|
inputs['cache'] = 'yarn';
|
||||||
|
getStateSpy.mockImplementation(key =>
|
||||||
|
key === State.CachePackageManager
|
||||||
|
? inputs['cache']
|
||||||
|
: key === State.CachePrimaryKey || key === State.CacheMatchedKey
|
||||||
|
? yarnFileHash
|
||||||
|
: key === State.CachePaths
|
||||||
|
? '["/foo/bar"]'
|
||||||
|
: 'not expected'
|
||||||
|
);
|
||||||
|
|
||||||
|
await run();
|
||||||
|
|
||||||
|
expect(getInputSpy).not.toHaveBeenCalled();
|
||||||
|
expect(getStateSpy).toHaveBeenCalledTimes(4);
|
||||||
|
expect(getCommandOutputSpy).toHaveBeenCalledTimes(0);
|
||||||
|
expect(debugSpy).toHaveBeenCalledTimes(0);
|
||||||
|
expect(infoSpy).toHaveBeenCalledWith(
|
||||||
|
`Cache hit occurred on the primary key ${yarnFileHash}, not saving cache.`
|
||||||
|
);
|
||||||
|
expect(setFailedSpy).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not save cache for npm', async () => {
|
||||||
|
inputs['cache'] = 'npm';
|
||||||
|
getStateSpy.mockImplementation(key =>
|
||||||
|
key === State.CachePackageManager
|
||||||
|
? inputs['cache']
|
||||||
|
: key === State.CachePrimaryKey || key === State.CacheMatchedKey
|
||||||
|
? yarnFileHash
|
||||||
|
: key === State.CachePaths
|
||||||
|
? '["/foo/bar"]'
|
||||||
|
: 'not expected'
|
||||||
|
);
|
||||||
|
getCommandOutputSpy.mockImplementationOnce(() => `${commonPath}/npm`);
|
||||||
|
|
||||||
|
await run();
|
||||||
|
|
||||||
|
expect(getInputSpy).not.toHaveBeenCalled();
|
||||||
|
expect(getStateSpy).toHaveBeenCalledTimes(4);
|
||||||
|
expect(getCommandOutputSpy).toHaveBeenCalledTimes(0);
|
||||||
|
expect(debugSpy).toHaveBeenCalledTimes(0);
|
||||||
|
expect(setFailedSpy).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not save cache for pnpm', async () => {
|
||||||
|
inputs['cache'] = 'pnpm';
|
||||||
|
getStateSpy.mockImplementation(key =>
|
||||||
|
key === State.CachePackageManager
|
||||||
|
? inputs['cache']
|
||||||
|
: key === State.CachePrimaryKey || key === State.CacheMatchedKey
|
||||||
|
? yarnFileHash
|
||||||
|
: key === State.CachePaths
|
||||||
|
? '["/foo/bar"]'
|
||||||
|
: 'not expected'
|
||||||
|
);
|
||||||
|
|
||||||
|
await run();
|
||||||
|
|
||||||
|
expect(getInputSpy).not.toHaveBeenCalled();
|
||||||
|
expect(getStateSpy).toHaveBeenCalledTimes(4);
|
||||||
|
expect(getCommandOutputSpy).toHaveBeenCalledTimes(0);
|
||||||
|
expect(debugSpy).toHaveBeenCalledTimes(0);
|
||||||
|
expect(setFailedSpy).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('action saves the cache', () => {
|
||||||
|
it('saves cache from yarn 1', async () => {
|
||||||
|
inputs['cache'] = 'yarn';
|
||||||
|
getStateSpy.mockImplementation((key: string) =>
|
||||||
|
key === State.CachePackageManager
|
||||||
|
? inputs['cache']
|
||||||
|
: key === State.CacheMatchedKey
|
||||||
|
? yarnFileHash
|
||||||
|
: key === State.CachePrimaryKey
|
||||||
|
? npmFileHash
|
||||||
|
: key === State.CachePaths
|
||||||
|
? '["/foo/bar"]'
|
||||||
|
: 'not expected'
|
||||||
|
);
|
||||||
|
|
||||||
|
await run();
|
||||||
|
|
||||||
|
expect(getInputSpy).not.toHaveBeenCalled();
|
||||||
|
expect(getStateSpy).toHaveBeenCalledTimes(4);
|
||||||
|
expect(getCommandOutputSpy).toHaveBeenCalledTimes(0);
|
||||||
|
expect(debugSpy).toHaveBeenCalledTimes(0);
|
||||||
|
expect(infoSpy).not.toHaveBeenCalledWith(
|
||||||
|
`Cache hit occurred on the primary key ${yarnFileHash}, not saving cache.`
|
||||||
|
);
|
||||||
|
expect(saveCacheSpy).toHaveBeenCalled();
|
||||||
|
expect(infoSpy).toHaveBeenLastCalledWith(
|
||||||
|
`Cache saved with the key: ${npmFileHash}`
|
||||||
|
);
|
||||||
|
expect(setFailedSpy).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('saves cache from yarn 2', async () => {
|
||||||
|
inputs['cache'] = 'yarn';
|
||||||
|
getStateSpy.mockImplementation((key: string) =>
|
||||||
|
key === State.CachePackageManager
|
||||||
|
? inputs['cache']
|
||||||
|
: key === State.CacheMatchedKey
|
||||||
|
? yarnFileHash
|
||||||
|
: key === State.CachePrimaryKey
|
||||||
|
? npmFileHash
|
||||||
|
: key === State.CachePaths
|
||||||
|
? '["/foo/bar"]'
|
||||||
|
: 'not expected'
|
||||||
|
);
|
||||||
|
|
||||||
|
await run();
|
||||||
|
|
||||||
|
expect(getInputSpy).not.toHaveBeenCalled();
|
||||||
|
expect(getStateSpy).toHaveBeenCalledTimes(4);
|
||||||
|
expect(getCommandOutputSpy).toHaveBeenCalledTimes(0);
|
||||||
|
expect(debugSpy).toHaveBeenCalledTimes(0);
|
||||||
|
expect(infoSpy).not.toHaveBeenCalledWith(
|
||||||
|
`Cache hit occurred on the primary key ${yarnFileHash}, not saving cache.`
|
||||||
|
);
|
||||||
|
expect(saveCacheSpy).toHaveBeenCalled();
|
||||||
|
expect(infoSpy).toHaveBeenLastCalledWith(
|
||||||
|
`Cache saved with the key: ${npmFileHash}`
|
||||||
|
);
|
||||||
|
expect(setFailedSpy).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('saves cache from npm', async () => {
|
||||||
|
inputs['cache'] = 'npm';
|
||||||
|
getStateSpy.mockImplementation((key: string) =>
|
||||||
|
key === State.CachePackageManager
|
||||||
|
? inputs['cache']
|
||||||
|
: key === State.CacheMatchedKey
|
||||||
|
? npmFileHash
|
||||||
|
: key === State.CachePrimaryKey
|
||||||
|
? yarnFileHash
|
||||||
|
: key === State.CachePaths
|
||||||
|
? '["/foo/bar"]'
|
||||||
|
: 'not expected'
|
||||||
|
);
|
||||||
|
|
||||||
|
await run();
|
||||||
|
|
||||||
|
expect(getInputSpy).not.toHaveBeenCalled();
|
||||||
|
expect(getStateSpy).toHaveBeenCalledTimes(4);
|
||||||
|
expect(getCommandOutputSpy).toHaveBeenCalledTimes(0);
|
||||||
|
expect(debugSpy).toHaveBeenCalledTimes(0);
|
||||||
|
expect(infoSpy).not.toHaveBeenCalledWith(
|
||||||
|
`Cache hit occurred on the primary key ${npmFileHash}, not saving cache.`
|
||||||
|
);
|
||||||
|
expect(saveCacheSpy).toHaveBeenCalled();
|
||||||
|
expect(infoSpy).toHaveBeenLastCalledWith(
|
||||||
|
`Cache saved with the key: ${yarnFileHash}`
|
||||||
|
);
|
||||||
|
expect(setFailedSpy).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('saves cache from pnpm', async () => {
|
||||||
|
inputs['cache'] = 'pnpm';
|
||||||
|
getStateSpy.mockImplementation((key: string) =>
|
||||||
|
key === State.CachePackageManager
|
||||||
|
? inputs['cache']
|
||||||
|
: key === State.CacheMatchedKey
|
||||||
|
? pnpmFileHash
|
||||||
|
: key === State.CachePrimaryKey
|
||||||
|
? npmFileHash
|
||||||
|
: key === State.CachePaths
|
||||||
|
? '["/foo/bar"]'
|
||||||
|
: 'not expected'
|
||||||
|
);
|
||||||
|
|
||||||
|
await run();
|
||||||
|
|
||||||
|
expect(getInputSpy).not.toHaveBeenCalled();
|
||||||
|
expect(getStateSpy).toHaveBeenCalledTimes(4);
|
||||||
|
expect(getCommandOutputSpy).toHaveBeenCalledTimes(0);
|
||||||
|
expect(debugSpy).toHaveBeenCalledTimes(0);
|
||||||
|
expect(infoSpy).not.toHaveBeenCalledWith(
|
||||||
|
`Cache hit occurred on the primary key ${pnpmFileHash}, not saving cache.`
|
||||||
|
);
|
||||||
|
expect(saveCacheSpy).toHaveBeenCalled();
|
||||||
|
expect(infoSpy).toHaveBeenLastCalledWith(
|
||||||
|
`Cache saved with the key: ${npmFileHash}`
|
||||||
|
);
|
||||||
|
expect(setFailedSpy).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('save with -1 cacheId , should not fail workflow', async () => {
|
||||||
|
inputs['cache'] = 'npm';
|
||||||
|
getStateSpy.mockImplementation((key: string) =>
|
||||||
|
key === State.CachePackageManager
|
||||||
|
? inputs['cache']
|
||||||
|
: key === State.CacheMatchedKey
|
||||||
|
? npmFileHash
|
||||||
|
: key === State.CachePrimaryKey
|
||||||
|
? yarnFileHash
|
||||||
|
: key === State.CachePaths
|
||||||
|
? '["/foo/bar"]'
|
||||||
|
: 'not expected'
|
||||||
|
);
|
||||||
|
saveCacheSpy.mockImplementation(() => {
|
||||||
|
return -1;
|
||||||
|
});
|
||||||
|
|
||||||
|
await run();
|
||||||
|
|
||||||
|
expect(getInputSpy).not.toHaveBeenCalled();
|
||||||
|
expect(getStateSpy).toHaveBeenCalledTimes(4);
|
||||||
|
expect(getCommandOutputSpy).toHaveBeenCalledTimes(0);
|
||||||
|
expect(debugSpy).toHaveBeenCalledTimes(0);
|
||||||
|
expect(infoSpy).not.toHaveBeenCalledWith(
|
||||||
|
`Cache hit occurred on the primary key ${npmFileHash}, not saving cache.`
|
||||||
|
);
|
||||||
|
expect(saveCacheSpy).toHaveBeenCalled();
|
||||||
|
expect(infoSpy).not.toHaveBeenLastCalledWith(
|
||||||
|
`Cache saved with the key: ${yarnFileHash}`
|
||||||
|
);
|
||||||
|
expect(setFailedSpy).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('saves with error from toolkit, should fail workflow', async () => {
|
||||||
|
inputs['cache'] = 'npm';
|
||||||
|
getStateSpy.mockImplementation((key: string) =>
|
||||||
|
key === State.CachePackageManager
|
||||||
|
? inputs['cache']
|
||||||
|
: key === State.CacheMatchedKey
|
||||||
|
? npmFileHash
|
||||||
|
: key === State.CachePrimaryKey
|
||||||
|
? yarnFileHash
|
||||||
|
: key === State.CachePaths
|
||||||
|
? '["/foo/bar"]'
|
||||||
|
: 'not expected'
|
||||||
|
);
|
||||||
|
saveCacheSpy.mockImplementation(() => {
|
||||||
|
throw new cache.ValidationError('Validation failed');
|
||||||
|
});
|
||||||
|
|
||||||
|
await run();
|
||||||
|
|
||||||
|
expect(getInputSpy).not.toHaveBeenCalled();
|
||||||
|
expect(getStateSpy).toHaveBeenCalledTimes(4);
|
||||||
|
expect(getCommandOutputSpy).toHaveBeenCalledTimes(0);
|
||||||
|
expect(debugSpy).toHaveBeenCalledTimes(0);
|
||||||
|
expect(infoSpy).not.toHaveBeenCalledWith(
|
||||||
|
`Cache hit occurred on the primary key ${npmFileHash}, not saving cache.`
|
||||||
|
);
|
||||||
|
expect(saveCacheSpy).toHaveBeenCalled();
|
||||||
|
expect(setFailedSpy).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
jest.resetAllMocks();
|
||||||
|
jest.clearAllMocks();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -0,0 +1,401 @@
|
||||||
|
import * as core from '@actions/core';
|
||||||
|
import * as cache from '@actions/cache';
|
||||||
|
import path from 'path';
|
||||||
|
import * as utils from '../src/cache-utils';
|
||||||
|
import {
|
||||||
|
PackageManagerInfo,
|
||||||
|
isCacheFeatureAvailable,
|
||||||
|
supportedPackageManagers,
|
||||||
|
isGhes,
|
||||||
|
resetProjectDirectoriesMemoized
|
||||||
|
} from '../src/cache-utils';
|
||||||
|
import fs from 'fs';
|
||||||
|
import * as cacheUtils from '../src/cache-utils';
|
||||||
|
import * as glob from '@actions/glob';
|
||||||
|
import {Globber} from '@actions/glob';
|
||||||
|
import {MockGlobber} from './mock/glob-mock';
|
||||||
|
|
||||||
|
describe('cache-utils', () => {
|
||||||
|
const versionYarn1 = '1.2.3';
|
||||||
|
|
||||||
|
let debugSpy: jest.SpyInstance;
|
||||||
|
let getCommandOutputSpy: jest.SpyInstance;
|
||||||
|
let isFeatureAvailable: jest.SpyInstance;
|
||||||
|
let info: jest.SpyInstance;
|
||||||
|
let warningSpy: jest.SpyInstance;
|
||||||
|
let fsRealPathSyncSpy: jest.SpyInstance;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
console.log('::stop-commands::stoptoken');
|
||||||
|
process.env['GITHUB_WORKSPACE'] = path.join(__dirname, 'data');
|
||||||
|
debugSpy = jest.spyOn(core, 'debug');
|
||||||
|
debugSpy.mockImplementation(msg => {});
|
||||||
|
|
||||||
|
info = jest.spyOn(core, 'info');
|
||||||
|
warningSpy = jest.spyOn(core, 'warning');
|
||||||
|
|
||||||
|
isFeatureAvailable = jest.spyOn(cache, 'isFeatureAvailable');
|
||||||
|
|
||||||
|
getCommandOutputSpy = jest.spyOn(utils, 'getCommandOutput');
|
||||||
|
|
||||||
|
fsRealPathSyncSpy = jest.spyOn(fs, 'realpathSync');
|
||||||
|
fsRealPathSyncSpy.mockImplementation(dirName => {
|
||||||
|
return dirName;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
jest.resetAllMocks();
|
||||||
|
jest.clearAllMocks();
|
||||||
|
//jest.restoreAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(async () => {
|
||||||
|
console.log('::stoptoken::');
|
||||||
|
jest.restoreAllMocks();
|
||||||
|
}, 100000);
|
||||||
|
|
||||||
|
describe('getPackageManagerInfo', () => {
|
||||||
|
it.each<[string, PackageManagerInfo | null]>([
|
||||||
|
['npm', utils.supportedPackageManagers.npm],
|
||||||
|
['pnpm', utils.supportedPackageManagers.pnpm],
|
||||||
|
['yarn', utils.supportedPackageManagers.yarn],
|
||||||
|
['yarn1', null],
|
||||||
|
['yarn2', null],
|
||||||
|
['npm7', null]
|
||||||
|
])('getPackageManagerInfo for %s is %o', async (packageManager, result) => {
|
||||||
|
getCommandOutputSpy.mockImplementationOnce(() => versionYarn1);
|
||||||
|
await expect(utils.getPackageManagerInfo(packageManager)).resolves.toBe(
|
||||||
|
result
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('isCacheFeatureAvailable for GHES is false', () => {
|
||||||
|
isFeatureAvailable.mockImplementation(() => false);
|
||||||
|
process.env['GITHUB_SERVER_URL'] = 'https://www.test.com';
|
||||||
|
|
||||||
|
expect(isCacheFeatureAvailable()).toBeFalsy();
|
||||||
|
expect(warningSpy).toHaveBeenCalledWith(
|
||||||
|
'Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('isCacheFeatureAvailable for GHES has an interhal error', () => {
|
||||||
|
isFeatureAvailable.mockImplementation(() => false);
|
||||||
|
process.env['GITHUB_SERVER_URL'] = '';
|
||||||
|
isCacheFeatureAvailable();
|
||||||
|
expect(warningSpy).toHaveBeenCalledWith(
|
||||||
|
'The runner was not able to contact the cache service. Caching will be skipped'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('isCacheFeatureAvailable for GHES is available', () => {
|
||||||
|
isFeatureAvailable.mockImplementation(() => true);
|
||||||
|
|
||||||
|
expect(isCacheFeatureAvailable()).toStrictEqual(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
process.env['GITHUB_SERVER_URL'] = '';
|
||||||
|
jest.resetAllMocks();
|
||||||
|
jest.clearAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('getCacheDirectoriesPaths', () => {
|
||||||
|
let existsSpy: jest.SpyInstance;
|
||||||
|
let lstatSpy: jest.SpyInstance;
|
||||||
|
let globCreateSpy: jest.SpyInstance;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
existsSpy = jest.spyOn(fs, 'existsSync');
|
||||||
|
existsSpy.mockImplementation(() => true);
|
||||||
|
|
||||||
|
lstatSpy = jest.spyOn(fs, 'lstatSync');
|
||||||
|
lstatSpy.mockImplementation(arg => ({
|
||||||
|
isDirectory: () => true
|
||||||
|
}));
|
||||||
|
|
||||||
|
globCreateSpy = jest.spyOn(glob, 'create');
|
||||||
|
|
||||||
|
globCreateSpy.mockImplementation(
|
||||||
|
(pattern: string): Promise<Globber> =>
|
||||||
|
MockGlobber.create(['/foo', '/bar'])
|
||||||
|
);
|
||||||
|
|
||||||
|
resetProjectDirectoriesMemoized();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
existsSpy.mockRestore();
|
||||||
|
lstatSpy.mockRestore();
|
||||||
|
globCreateSpy.mockRestore();
|
||||||
|
});
|
||||||
|
|
||||||
|
it.each([
|
||||||
|
[supportedPackageManagers.npm, ''],
|
||||||
|
[supportedPackageManagers.npm, '/dir/file.lock'],
|
||||||
|
[supportedPackageManagers.npm, '/**/file.lock'],
|
||||||
|
[supportedPackageManagers.pnpm, ''],
|
||||||
|
[supportedPackageManagers.pnpm, '/dir/file.lock'],
|
||||||
|
[supportedPackageManagers.pnpm, '/**/file.lock']
|
||||||
|
])(
|
||||||
|
'getCacheDirectoriesPaths should return one dir for non yarn',
|
||||||
|
async (packageManagerInfo, cacheDependency) => {
|
||||||
|
getCommandOutputSpy.mockImplementation(() => 'foo');
|
||||||
|
|
||||||
|
const dirs = await cacheUtils.getCacheDirectories(
|
||||||
|
packageManagerInfo,
|
||||||
|
cacheDependency
|
||||||
|
);
|
||||||
|
expect(dirs).toEqual(['foo']);
|
||||||
|
// to do not call for a version
|
||||||
|
// call once for get cache folder
|
||||||
|
expect(getCommandOutputSpy).toHaveBeenCalledTimes(1);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
it('getCacheDirectoriesPaths should return one dir for yarn without cacheDependency', async () => {
|
||||||
|
getCommandOutputSpy.mockImplementation(() => 'foo');
|
||||||
|
|
||||||
|
const dirs = await cacheUtils.getCacheDirectories(
|
||||||
|
supportedPackageManagers.yarn,
|
||||||
|
''
|
||||||
|
);
|
||||||
|
expect(dirs).toEqual(['foo']);
|
||||||
|
});
|
||||||
|
|
||||||
|
it.each([
|
||||||
|
[supportedPackageManagers.npm, ''],
|
||||||
|
[supportedPackageManagers.npm, '/dir/file.lock'],
|
||||||
|
[supportedPackageManagers.npm, '/**/file.lock'],
|
||||||
|
[supportedPackageManagers.pnpm, ''],
|
||||||
|
[supportedPackageManagers.pnpm, '/dir/file.lock'],
|
||||||
|
[supportedPackageManagers.pnpm, '/**/file.lock'],
|
||||||
|
[supportedPackageManagers.yarn, ''],
|
||||||
|
[supportedPackageManagers.yarn, '/dir/file.lock'],
|
||||||
|
[supportedPackageManagers.yarn, '/**/file.lock']
|
||||||
|
])(
|
||||||
|
'getCacheDirectoriesPaths should throw for getCommandOutput returning empty',
|
||||||
|
async (packageManagerInfo, cacheDependency) => {
|
||||||
|
getCommandOutputSpy.mockImplementation((command: string) =>
|
||||||
|
// return empty string to indicate getCacheFolderPath failed
|
||||||
|
// --version still works
|
||||||
|
command.includes('version') ? '1.' : ''
|
||||||
|
);
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
cacheUtils.getCacheDirectories(packageManagerInfo, cacheDependency)
|
||||||
|
).rejects.toThrow(); //'Could not get cache folder path for /dir');
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
it.each([
|
||||||
|
[supportedPackageManagers.yarn, '/dir/file.lock'],
|
||||||
|
[supportedPackageManagers.yarn, '/**/file.lock']
|
||||||
|
])(
|
||||||
|
'getCacheDirectoriesPaths should nothrow in case of having not directories',
|
||||||
|
async (packageManagerInfo, cacheDependency) => {
|
||||||
|
lstatSpy.mockImplementation(arg => ({
|
||||||
|
isDirectory: () => false
|
||||||
|
}));
|
||||||
|
|
||||||
|
await cacheUtils.getCacheDirectories(
|
||||||
|
packageManagerInfo,
|
||||||
|
cacheDependency
|
||||||
|
);
|
||||||
|
expect(warningSpy).toHaveBeenCalledTimes(1);
|
||||||
|
expect(warningSpy).toHaveBeenCalledWith(
|
||||||
|
`No existing directories found containing cache-dependency-path="${cacheDependency}"`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
it.each(['1.1.1', '2.2.2'])(
|
||||||
|
'getCacheDirectoriesPaths yarn v%s should return one dir without cacheDependency',
|
||||||
|
async version => {
|
||||||
|
getCommandOutputSpy.mockImplementationOnce(() => version);
|
||||||
|
getCommandOutputSpy.mockImplementationOnce(() => `foo${version}`);
|
||||||
|
|
||||||
|
const dirs = await cacheUtils.getCacheDirectories(
|
||||||
|
supportedPackageManagers.yarn,
|
||||||
|
''
|
||||||
|
);
|
||||||
|
expect(dirs).toEqual([`foo${version}`]);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
it.each(['1.1.1', '2.2.2'])(
|
||||||
|
'getCacheDirectoriesPaths yarn v%s should return 2 dirs with globbed cacheDependency',
|
||||||
|
async version => {
|
||||||
|
let dirNo = 1;
|
||||||
|
getCommandOutputSpy.mockImplementation((command: string) =>
|
||||||
|
command.includes('version') ? version : `file_${version}_${dirNo++}`
|
||||||
|
);
|
||||||
|
globCreateSpy.mockImplementation(
|
||||||
|
(pattern: string): Promise<Globber> =>
|
||||||
|
MockGlobber.create(['/tmp/dir1/file', '/tmp/dir2/file'])
|
||||||
|
);
|
||||||
|
|
||||||
|
const dirs = await cacheUtils.getCacheDirectories(
|
||||||
|
supportedPackageManagers.yarn,
|
||||||
|
'/tmp/**/file'
|
||||||
|
);
|
||||||
|
expect(dirs).toEqual([`file_${version}_1`, `file_${version}_2`]);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
it.each(['1.1.1', '2.2.2'])(
|
||||||
|
'getCacheDirectoriesPaths yarn v%s should return 2 dirs with globbed cacheDependency expanding to duplicates',
|
||||||
|
async version => {
|
||||||
|
let dirNo = 1;
|
||||||
|
getCommandOutputSpy.mockImplementation((command: string) =>
|
||||||
|
command.includes('version') ? version : `file_${version}_${dirNo++}`
|
||||||
|
);
|
||||||
|
globCreateSpy.mockImplementation(
|
||||||
|
(pattern: string): Promise<Globber> =>
|
||||||
|
MockGlobber.create([
|
||||||
|
'/tmp/dir1/file',
|
||||||
|
'/tmp/dir2/file',
|
||||||
|
'/tmp/dir1/file'
|
||||||
|
])
|
||||||
|
);
|
||||||
|
|
||||||
|
const dirs = await cacheUtils.getCacheDirectories(
|
||||||
|
supportedPackageManagers.yarn,
|
||||||
|
'/tmp/**/file'
|
||||||
|
);
|
||||||
|
expect(dirs).toEqual([`file_${version}_1`, `file_${version}_2`]);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
it.each(['1.1.1', '2.2.2'])(
|
||||||
|
'getCacheDirectoriesPaths yarn v%s should return 2 uniq dirs despite duplicate cache directories',
|
||||||
|
async version => {
|
||||||
|
let dirNo = 1;
|
||||||
|
getCommandOutputSpy.mockImplementation((command: string) =>
|
||||||
|
command.includes('version')
|
||||||
|
? version
|
||||||
|
: `file_${version}_${dirNo++ % 2}`
|
||||||
|
);
|
||||||
|
globCreateSpy.mockImplementation(
|
||||||
|
(pattern: string): Promise<Globber> =>
|
||||||
|
MockGlobber.create([
|
||||||
|
'/tmp/dir1/file',
|
||||||
|
'/tmp/dir2/file',
|
||||||
|
'/tmp/dir3/file'
|
||||||
|
])
|
||||||
|
);
|
||||||
|
|
||||||
|
const dirs = await cacheUtils.getCacheDirectories(
|
||||||
|
supportedPackageManagers.yarn,
|
||||||
|
'/tmp/**/file'
|
||||||
|
);
|
||||||
|
expect(dirs).toEqual([`file_${version}_1`, `file_${version}_0`]);
|
||||||
|
expect(getCommandOutputSpy).toHaveBeenCalledTimes(6);
|
||||||
|
expect(getCommandOutputSpy).toHaveBeenCalledWith(
|
||||||
|
'yarn --version',
|
||||||
|
'/tmp/dir1'
|
||||||
|
);
|
||||||
|
expect(getCommandOutputSpy).toHaveBeenCalledWith(
|
||||||
|
'yarn --version',
|
||||||
|
'/tmp/dir2'
|
||||||
|
);
|
||||||
|
expect(getCommandOutputSpy).toHaveBeenCalledWith(
|
||||||
|
'yarn --version',
|
||||||
|
'/tmp/dir3'
|
||||||
|
);
|
||||||
|
expect(getCommandOutputSpy).toHaveBeenCalledWith(
|
||||||
|
version.startsWith('1.')
|
||||||
|
? 'yarn cache dir'
|
||||||
|
: 'yarn config get cacheFolder',
|
||||||
|
'/tmp/dir1'
|
||||||
|
);
|
||||||
|
expect(getCommandOutputSpy).toHaveBeenCalledWith(
|
||||||
|
version.startsWith('1.')
|
||||||
|
? 'yarn cache dir'
|
||||||
|
: 'yarn config get cacheFolder',
|
||||||
|
'/tmp/dir2'
|
||||||
|
);
|
||||||
|
expect(getCommandOutputSpy).toHaveBeenCalledWith(
|
||||||
|
version.startsWith('1.')
|
||||||
|
? 'yarn cache dir'
|
||||||
|
: 'yarn config get cacheFolder',
|
||||||
|
'/tmp/dir3'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
it.each(['1.1.1', '2.2.2'])(
|
||||||
|
'getCacheDirectoriesPaths yarn v%s should return 4 dirs with multiple globs',
|
||||||
|
async version => {
|
||||||
|
// simulate wrong indents
|
||||||
|
const cacheDependencyPath = `/tmp/dir1/file
|
||||||
|
/tmp/dir2/file
|
||||||
|
/tmp/**/file
|
||||||
|
`;
|
||||||
|
globCreateSpy.mockImplementation(
|
||||||
|
(pattern: string): Promise<Globber> =>
|
||||||
|
MockGlobber.create([
|
||||||
|
'/tmp/dir1/file',
|
||||||
|
'/tmp/dir2/file',
|
||||||
|
'/tmp/dir3/file',
|
||||||
|
'/tmp/dir4/file'
|
||||||
|
])
|
||||||
|
);
|
||||||
|
let dirNo = 1;
|
||||||
|
getCommandOutputSpy.mockImplementation((command: string) =>
|
||||||
|
command.includes('version') ? version : `file_${version}_${dirNo++}`
|
||||||
|
);
|
||||||
|
const dirs = await cacheUtils.getCacheDirectories(
|
||||||
|
supportedPackageManagers.yarn,
|
||||||
|
cacheDependencyPath
|
||||||
|
);
|
||||||
|
expect(dirs).toEqual([
|
||||||
|
`file_${version}_1`,
|
||||||
|
`file_${version}_2`,
|
||||||
|
`file_${version}_3`,
|
||||||
|
`file_${version}_4`
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('isGhes', () => {
|
||||||
|
const pristineEnv = process.env;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.resetModules();
|
||||||
|
process.env = {...pristineEnv};
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(() => {
|
||||||
|
process.env = pristineEnv;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns false when the GITHUB_SERVER_URL environment variable is not defined', () => {
|
||||||
|
delete process.env['GITHUB_SERVER_URL'];
|
||||||
|
expect(isGhes()).toBeFalsy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns false when the GITHUB_SERVER_URL environment variable is set to github.com', () => {
|
||||||
|
process.env['GITHUB_SERVER_URL'] = 'https://github.com';
|
||||||
|
expect(isGhes()).toBeFalsy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns false when the GITHUB_SERVER_URL environment variable is set to a GitHub Enterprise Cloud-style URL', () => {
|
||||||
|
process.env['GITHUB_SERVER_URL'] = 'https://contoso.ghe.com';
|
||||||
|
expect(isGhes()).toBeFalsy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns false when the GITHUB_SERVER_URL environment variable has a .localhost suffix', () => {
|
||||||
|
process.env['GITHUB_SERVER_URL'] = 'https://mock-github.localhost';
|
||||||
|
expect(isGhes()).toBeFalsy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns true when the GITHUB_SERVER_URL environment variable is set to some other URL', () => {
|
||||||
|
process.env['GITHUB_SERVER_URL'] = 'https://src.onpremise.fabrikam.com';
|
||||||
|
expect(isGhes()).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -0,0 +1,591 @@
|
||||||
|
import * as core from '@actions/core';
|
||||||
|
import * as io from '@actions/io';
|
||||||
|
import * as tc from '@actions/tool-cache';
|
||||||
|
import * as httpm from '@actions/http-client';
|
||||||
|
import * as exec from '@actions/exec';
|
||||||
|
import * as cache from '@actions/cache';
|
||||||
|
import fs from 'fs';
|
||||||
|
import cp from 'child_process';
|
||||||
|
import osm from 'os';
|
||||||
|
import path from 'path';
|
||||||
|
import * as main from '../src/main';
|
||||||
|
import * as auth from '../src/authutil';
|
||||||
|
import {INodeVersion} from '../src/distributions/base-models';
|
||||||
|
|
||||||
|
import nodeTestManifest from './data/versions-manifest.json';
|
||||||
|
import nodeTestDist from './data/node-dist-index.json';
|
||||||
|
import nodeTestDistNightly from './data/node-nightly-index.json';
|
||||||
|
import nodeTestDistRc from './data/node-rc-index.json';
|
||||||
|
import nodeV8CanaryTestDist from './data/v8-canary-dist-index.json';
|
||||||
|
|
||||||
|
describe('setup-node', () => {
|
||||||
|
let inputs = {} as any;
|
||||||
|
let os = {} as any;
|
||||||
|
|
||||||
|
let inSpy: jest.SpyInstance;
|
||||||
|
let findSpy: jest.SpyInstance;
|
||||||
|
let findAllVersionsSpy: jest.SpyInstance;
|
||||||
|
let cnSpy: jest.SpyInstance;
|
||||||
|
let logSpy: jest.SpyInstance;
|
||||||
|
let warningSpy: jest.SpyInstance;
|
||||||
|
let getManifestSpy: jest.SpyInstance;
|
||||||
|
let getDistSpy: jest.SpyInstance;
|
||||||
|
let platSpy: jest.SpyInstance;
|
||||||
|
let archSpy: jest.SpyInstance;
|
||||||
|
let dlSpy: jest.SpyInstance;
|
||||||
|
let exSpy: jest.SpyInstance;
|
||||||
|
let cacheSpy: jest.SpyInstance;
|
||||||
|
let dbgSpy: jest.SpyInstance;
|
||||||
|
let whichSpy: jest.SpyInstance;
|
||||||
|
let existsSpy: jest.SpyInstance;
|
||||||
|
let readFileSyncSpy: jest.SpyInstance;
|
||||||
|
let mkdirpSpy: jest.SpyInstance;
|
||||||
|
let execSpy: jest.SpyInstance;
|
||||||
|
let authSpy: jest.SpyInstance;
|
||||||
|
let parseNodeVersionSpy: jest.SpyInstance;
|
||||||
|
let isCacheActionAvailable: jest.SpyInstance;
|
||||||
|
let getExecOutputSpy: jest.SpyInstance;
|
||||||
|
let getJsonSpy: jest.SpyInstance;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
// @actions/core
|
||||||
|
console.log('::stop-commands::stoptoken'); // Disable executing of runner commands when running tests in actions
|
||||||
|
process.env['GITHUB_PATH'] = ''; // Stub out ENV file functionality so we can verify it writes to standard out
|
||||||
|
process.env['GITHUB_OUTPUT'] = ''; // Stub out ENV file functionality so we can verify it writes to standard out
|
||||||
|
inputs = {};
|
||||||
|
inSpy = jest.spyOn(core, 'getInput');
|
||||||
|
inSpy.mockImplementation(name => inputs[name]);
|
||||||
|
|
||||||
|
// node
|
||||||
|
os = {};
|
||||||
|
platSpy = jest.spyOn(osm, 'platform');
|
||||||
|
platSpy.mockImplementation(() => os['platform']);
|
||||||
|
archSpy = jest.spyOn(osm, 'arch');
|
||||||
|
archSpy.mockImplementation(() => os['arch']);
|
||||||
|
execSpy = jest.spyOn(cp, 'execSync');
|
||||||
|
|
||||||
|
// @actions/tool-cache
|
||||||
|
findSpy = jest.spyOn(tc, 'find');
|
||||||
|
findAllVersionsSpy = jest.spyOn(tc, 'findAllVersions');
|
||||||
|
dlSpy = jest.spyOn(tc, 'downloadTool');
|
||||||
|
exSpy = jest.spyOn(tc, 'extractTar');
|
||||||
|
cacheSpy = jest.spyOn(tc, 'cacheDir');
|
||||||
|
getManifestSpy = jest.spyOn(tc, 'getManifestFromRepo');
|
||||||
|
|
||||||
|
// http-client
|
||||||
|
getJsonSpy = jest.spyOn(httpm.HttpClient.prototype, 'getJson');
|
||||||
|
|
||||||
|
// io
|
||||||
|
whichSpy = jest.spyOn(io, 'which');
|
||||||
|
existsSpy = jest.spyOn(fs, 'existsSync');
|
||||||
|
mkdirpSpy = jest.spyOn(io, 'mkdirP');
|
||||||
|
|
||||||
|
// @actions/tool-cache
|
||||||
|
isCacheActionAvailable = jest.spyOn(cache, 'isFeatureAvailable');
|
||||||
|
|
||||||
|
// disable authentication portion for installer tests
|
||||||
|
authSpy = jest.spyOn(auth, 'configAuthentication');
|
||||||
|
authSpy.mockImplementation(() => {});
|
||||||
|
|
||||||
|
// gets
|
||||||
|
getManifestSpy.mockImplementation(
|
||||||
|
() => <tc.IToolRelease[]>nodeTestManifest
|
||||||
|
);
|
||||||
|
|
||||||
|
getJsonSpy.mockImplementation(url => {
|
||||||
|
let res: any;
|
||||||
|
if (url.includes('/rc')) {
|
||||||
|
res = <INodeVersion[]>nodeTestDistRc;
|
||||||
|
} else if (url.includes('/nightly')) {
|
||||||
|
res = <INodeVersion[]>nodeTestDistNightly;
|
||||||
|
} else if (url.includes('/v8-canary')) {
|
||||||
|
res = <INodeVersion[]>nodeV8CanaryTestDist;
|
||||||
|
} else {
|
||||||
|
res = <INodeVersion[]>nodeTestDist;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {result: res};
|
||||||
|
});
|
||||||
|
|
||||||
|
// writes
|
||||||
|
cnSpy = jest.spyOn(process.stdout, 'write');
|
||||||
|
logSpy = jest.spyOn(core, 'info');
|
||||||
|
dbgSpy = jest.spyOn(core, 'debug');
|
||||||
|
warningSpy = jest.spyOn(core, 'warning');
|
||||||
|
cnSpy.mockImplementation(line => {
|
||||||
|
// uncomment to debug
|
||||||
|
// process.stderr.write('write:' + line + '\n');
|
||||||
|
});
|
||||||
|
logSpy.mockImplementation(line => {
|
||||||
|
// uncomment to debug
|
||||||
|
// process.stderr.write('log:' + line + '\n');
|
||||||
|
});
|
||||||
|
dbgSpy.mockImplementation(msg => {
|
||||||
|
// uncomment to see debug output
|
||||||
|
// process.stderr.write(msg + '\n');
|
||||||
|
});
|
||||||
|
warningSpy.mockImplementation(msg => {
|
||||||
|
// uncomment to debug
|
||||||
|
// process.stderr.write('log:' + msg + '\n');
|
||||||
|
});
|
||||||
|
|
||||||
|
// @actions/exec
|
||||||
|
getExecOutputSpy = jest.spyOn(exec, 'getExecOutput');
|
||||||
|
getExecOutputSpy.mockImplementation(() => 'v16.15.0');
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
jest.resetAllMocks();
|
||||||
|
jest.clearAllMocks();
|
||||||
|
//jest.restoreAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(async () => {
|
||||||
|
console.log('::stoptoken::'); // Re-enable executing of runner commands when running tests in actions
|
||||||
|
jest.restoreAllMocks();
|
||||||
|
}, 100000);
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// Found in cache tests
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
|
it('finds version in cache with stable true', async () => {
|
||||||
|
inputs['node-version'] = '20-v8-canary';
|
||||||
|
os['arch'] = 'x64';
|
||||||
|
inputs.stable = 'true';
|
||||||
|
|
||||||
|
const toolPath = path.normalize(
|
||||||
|
'/cache/node/20.0.0-v8-canary20221103f7e2421e91/x64'
|
||||||
|
);
|
||||||
|
findSpy.mockImplementation(() => toolPath);
|
||||||
|
findAllVersionsSpy.mockImplementation(() => [
|
||||||
|
'20.0.0-v8-canary20221103f7e2421e91',
|
||||||
|
'20.0.0-v8-canary20221030fefe1c0879',
|
||||||
|
'19.0.0-v8-canary202210172ec229fc56',
|
||||||
|
'20.0.0-v8-canary2022102310ff1e5a8d'
|
||||||
|
]);
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
expect(findSpy).toHaveBeenCalledWith(
|
||||||
|
'node',
|
||||||
|
'20.0.0-v8-canary20221103f7e2421e91',
|
||||||
|
'x64'
|
||||||
|
);
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('finds version in cache and adds it to the path', async () => {
|
||||||
|
inputs['node-version'] = '20-v8-canary';
|
||||||
|
os['arch'] = 'x64';
|
||||||
|
|
||||||
|
inSpy.mockImplementation(name => inputs[name]);
|
||||||
|
|
||||||
|
const toolPath = path.normalize(
|
||||||
|
'/cache/node/20.0.0-v8-canary20221103f7e2421e91/x64'
|
||||||
|
);
|
||||||
|
findSpy.mockImplementation(() => toolPath);
|
||||||
|
findAllVersionsSpy.mockImplementation(() => [
|
||||||
|
'20.0.0-v8-canary20221103f7e2421e91',
|
||||||
|
'20.0.0-v8-canary20221030fefe1c0879',
|
||||||
|
'19.0.0-v8-canary202210172ec229fc56',
|
||||||
|
'20.0.0-v8-canary2022102310ff1e5a8d'
|
||||||
|
]);
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
const expPath = path.join(toolPath, 'bin');
|
||||||
|
expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('handles unhandled find error and reports error', async () => {
|
||||||
|
os.platform = 'linux';
|
||||||
|
const errMsg = 'unhandled error message';
|
||||||
|
inputs['node-version'] = '20.0.0-v8-canary20221103f7e2421e91';
|
||||||
|
|
||||||
|
findSpy.mockImplementation(() => {
|
||||||
|
throw new Error(errMsg);
|
||||||
|
});
|
||||||
|
findAllVersionsSpy.mockImplementation(() => [
|
||||||
|
'20.0.0-v8-canary20221103f7e2421e91',
|
||||||
|
'20.0.0-v8-canary20221030fefe1c0879',
|
||||||
|
'19.0.0-v8-canary202210172ec229fc56',
|
||||||
|
'20.0.0-v8-canary2022102310ff1e5a8d'
|
||||||
|
]);
|
||||||
|
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
expect(cnSpy).toHaveBeenCalledWith('::error::' + errMsg + osm.EOL);
|
||||||
|
});
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// Manifest tests
|
||||||
|
//--------------------------------------------------
|
||||||
|
it('falls back to a version from node dist', async () => {
|
||||||
|
os.platform = 'linux';
|
||||||
|
os.arch = 'x64';
|
||||||
|
|
||||||
|
// a version which is not in the manifest but is in node dist
|
||||||
|
const versionSpec = '11.15.0';
|
||||||
|
|
||||||
|
inputs['node-version'] = versionSpec;
|
||||||
|
inputs['token'] = 'faketoken';
|
||||||
|
|
||||||
|
// ... but not in the local cache
|
||||||
|
findSpy.mockImplementation(() => '');
|
||||||
|
|
||||||
|
dlSpy.mockImplementation(async () => '/some/temp/path');
|
||||||
|
const toolPath = path.normalize('/cache/node/11.11.0/x64');
|
||||||
|
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
||||||
|
cacheSpy.mockImplementation(async () => toolPath);
|
||||||
|
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
const expPath = path.join(toolPath, 'bin');
|
||||||
|
|
||||||
|
expect(dlSpy).toHaveBeenCalled();
|
||||||
|
expect(exSpy).toHaveBeenCalled();
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
'Not found in manifest. Falling back to download directly from Node'
|
||||||
|
);
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
`Attempting to download ${versionSpec}...`
|
||||||
|
);
|
||||||
|
expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does not find a version that does not exist', async () => {
|
||||||
|
os.platform = 'linux';
|
||||||
|
os.arch = 'x64';
|
||||||
|
|
||||||
|
const versionSpec = '23.0.0-v8-canary20221103f7e2421e91';
|
||||||
|
inputs['node-version'] = versionSpec;
|
||||||
|
|
||||||
|
findSpy.mockImplementation(() => '');
|
||||||
|
findAllVersionsSpy.mockImplementation(() => [
|
||||||
|
'20.0.0-v8-canary20221103f7e2421e91',
|
||||||
|
'20.0.0-v8-canary20221030fefe1c0879',
|
||||||
|
'19.0.0-v8-canary202210172ec229fc56',
|
||||||
|
'20.0.0-v8-canary2022102310ff1e5a8d'
|
||||||
|
]);
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
expect(cnSpy).toHaveBeenCalledWith(
|
||||||
|
`::error::Unable to find Node version '${versionSpec}' for platform ${os.platform} and architecture ${os.arch}.${osm.EOL}`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('reports a failed download', async () => {
|
||||||
|
const errMsg = 'unhandled download message';
|
||||||
|
os.platform = 'linux';
|
||||||
|
os.arch = 'x64';
|
||||||
|
|
||||||
|
// a version which is in the manifest
|
||||||
|
const versionSpec = '19.0.0-v8-canary';
|
||||||
|
|
||||||
|
inputs['node-version'] = versionSpec;
|
||||||
|
inputs['token'] = 'faketoken';
|
||||||
|
|
||||||
|
findSpy.mockImplementation(() => '');
|
||||||
|
findAllVersionsSpy.mockImplementation(() => [
|
||||||
|
'20.0.0-v8-canary20221103f7e2421e91',
|
||||||
|
'20.0.0-v8-canary20221030fefe1c0879',
|
||||||
|
'20.0.0-v8-canary2022102310ff1e5a8d'
|
||||||
|
]);
|
||||||
|
dlSpy.mockImplementation(() => {
|
||||||
|
throw new Error(errMsg);
|
||||||
|
});
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
expect(cnSpy).toHaveBeenCalledWith(`::error::${errMsg}${osm.EOL}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('acquires specified architecture of node', async () => {
|
||||||
|
for (const {arch, version, osSpec} of [
|
||||||
|
{
|
||||||
|
arch: 'x86',
|
||||||
|
version: '20.0.0-v8-canary20221022e83bcb6c41',
|
||||||
|
osSpec: 'win32'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arch: 'x86',
|
||||||
|
version: '20.0.0-v8-canary20221103f7e2421e91',
|
||||||
|
osSpec: 'win32'
|
||||||
|
}
|
||||||
|
]) {
|
||||||
|
os.platform = osSpec;
|
||||||
|
os.arch = arch;
|
||||||
|
const fileExtension = os.platform === 'win32' ? '7z' : 'tar.gz';
|
||||||
|
const platform = {
|
||||||
|
linux: 'linux',
|
||||||
|
darwin: 'darwin',
|
||||||
|
win32: 'win'
|
||||||
|
}[os.platform];
|
||||||
|
|
||||||
|
inputs['node-version'] = version;
|
||||||
|
inputs['architecture'] = arch;
|
||||||
|
inputs['token'] = 'faketoken';
|
||||||
|
|
||||||
|
const expectedUrl = `https://nodejs.org/download/v8-canary/v${version}/node-v${version}-${platform}-${arch}.${fileExtension}`;
|
||||||
|
|
||||||
|
// ... but not in the local cache
|
||||||
|
findSpy.mockImplementation(() => '');
|
||||||
|
findAllVersionsSpy.mockImplementation(() => []);
|
||||||
|
|
||||||
|
dlSpy.mockImplementation(async () => '/some/temp/path');
|
||||||
|
const toolPath = path.normalize(`/cache/node/${version}/${arch}`);
|
||||||
|
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
||||||
|
cacheSpy.mockImplementation(async () => toolPath);
|
||||||
|
|
||||||
|
await main.run();
|
||||||
|
expect(dlSpy).toHaveBeenCalled();
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
`Acquiring ${version} - ${arch} from ${expectedUrl}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}, 100000);
|
||||||
|
|
||||||
|
describe('nightly versions', () => {
|
||||||
|
it.each([
|
||||||
|
[
|
||||||
|
'20.0.0-v8-canary',
|
||||||
|
'20.0.0-v8-canary20221103f7e2421e91',
|
||||||
|
'https://nodejs.org/download/v8-canary/v20.0.0-v8-canary20221103f7e2421e91/node-v20.0.0-v8-canary20221103f7e2421e91-linux-x64.tar.gz'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'20-v8-canary',
|
||||||
|
'20.0.0-v8-canary20221103f7e2421e91',
|
||||||
|
'https://nodejs.org/download/v8-canary/v20.0.0-v8-canary20221103f7e2421e91/node-v20.0.0-v8-canary20221103f7e2421e91-linux-x64.tar.gz'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'19.0.0-v8-canary',
|
||||||
|
'19.0.0-v8-canary202210187d6960f23f',
|
||||||
|
'https://nodejs.org/download/v8-canary/v19.0.0-v8-canary202210187d6960f23f/node-v19.0.0-v8-canary202210187d6960f23f-linux-x64.tar.gz'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'19-v8-canary',
|
||||||
|
'19.0.0-v8-canary202210187d6960f23f',
|
||||||
|
'https://nodejs.org/download/v8-canary/v19.0.0-v8-canary202210187d6960f23f/node-v19.0.0-v8-canary202210187d6960f23f-linux-x64.tar.gz'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'19.0.0-v8-canary202210187d6960f23f',
|
||||||
|
'19.0.0-v8-canary202210187d6960f23f',
|
||||||
|
'https://nodejs.org/download/v8-canary/v19.0.0-v8-canary202210187d6960f23f/node-v19.0.0-v8-canary202210187d6960f23f-linux-x64.tar.gz'
|
||||||
|
]
|
||||||
|
])(
|
||||||
|
'finds the versions in the index.json and installs it',
|
||||||
|
async (input, expectedVersion, expectedUrl) => {
|
||||||
|
const toolPath = path.normalize(`/cache/node/${expectedVersion}/x64`);
|
||||||
|
|
||||||
|
findSpy.mockImplementation(() => '');
|
||||||
|
findAllVersionsSpy.mockImplementation(() => []);
|
||||||
|
dlSpy.mockImplementation(async () => '/some/temp/path');
|
||||||
|
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
||||||
|
cacheSpy.mockImplementation(async () => toolPath);
|
||||||
|
|
||||||
|
inputs['node-version'] = input;
|
||||||
|
os['arch'] = 'x64';
|
||||||
|
os['platform'] = 'linux';
|
||||||
|
// act
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
// assert
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
`Acquiring ${expectedVersion} - ${os.arch} from ${expectedUrl}`
|
||||||
|
);
|
||||||
|
expect(logSpy).toHaveBeenCalledWith('Extracting ...');
|
||||||
|
expect(logSpy).toHaveBeenCalledWith('Adding to the cache ...');
|
||||||
|
expect(cnSpy).toHaveBeenCalledWith(
|
||||||
|
`::add-path::${path.join(toolPath, 'bin')}${osm.EOL}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
it.each([
|
||||||
|
[
|
||||||
|
'20.0.0-v8-canary20221103f7e2421e91',
|
||||||
|
'20.0.0-v8-canary20221103f7e2421e91'
|
||||||
|
],
|
||||||
|
['20.0.0-v8-canary', '20.0.0-v8-canary20221103f7e2421e91'],
|
||||||
|
['20-v8-canary', '20.0.0-v8-canary20221103f7e2421e91']
|
||||||
|
])(
|
||||||
|
'finds the %s version in the hostedToolcache',
|
||||||
|
async (input, expectedVersion) => {
|
||||||
|
const toolPath = path.normalize(`/cache/node/${expectedVersion}/x64`);
|
||||||
|
findSpy.mockReturnValue(toolPath);
|
||||||
|
findAllVersionsSpy.mockReturnValue([
|
||||||
|
'20.0.0-v8-canary20221103f7e2421e91',
|
||||||
|
'20.0.0-v8-canary20221030fefe1c0879',
|
||||||
|
'19.0.0-v8-canary202210172ec229fc56',
|
||||||
|
'20.0.0-v8-canary2022102310ff1e5a8d'
|
||||||
|
]);
|
||||||
|
|
||||||
|
inputs['node-version'] = input;
|
||||||
|
os['arch'] = 'x64';
|
||||||
|
os['platform'] = 'linux';
|
||||||
|
|
||||||
|
// act
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
// assert
|
||||||
|
expect(findAllVersionsSpy).toHaveBeenCalled();
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`);
|
||||||
|
expect(cnSpy).toHaveBeenCalledWith(
|
||||||
|
`::add-path::${path.join(toolPath, 'bin')}${osm.EOL}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
it.each([
|
||||||
|
[
|
||||||
|
'20.0.0-v8-canary',
|
||||||
|
'20.0.0-v8-canary20221103f7e2421e91',
|
||||||
|
'20.0.0-v8-canary20221030fefe1c0879',
|
||||||
|
'https://nodejs.org/download/v8-canary/v20.0.0-v8-canary20221103f7e2421e91/node-v20.0.0-v8-canary20221103f7e2421e91-linux-x64.tar.gz'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'20-v8-canary',
|
||||||
|
'20.0.0-v8-canary20221103f7e2421e91',
|
||||||
|
'20.0.0-v8-canary20221030fefe1c0879',
|
||||||
|
'https://nodejs.org/download/v8-canary/v20.0.0-v8-canary20221103f7e2421e91/node-v20.0.0-v8-canary20221103f7e2421e91-linux-x64.tar.gz'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'19.0.0-v8-canary',
|
||||||
|
'19.0.0-v8-canary202210187d6960f23f',
|
||||||
|
'19.0.0-v8-canary202210172ec229fc56',
|
||||||
|
'https://nodejs.org/download/v8-canary/v19.0.0-v8-canary202210187d6960f23f/node-v19.0.0-v8-canary202210187d6960f23f-linux-x64.tar.gz'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'19-v8-canary',
|
||||||
|
'19.0.0-v8-canary202210187d6960f23f',
|
||||||
|
'19.0.0-v8-canary202210172ec229fc56',
|
||||||
|
'https://nodejs.org/download/v8-canary/v19.0.0-v8-canary202210187d6960f23f/node-v19.0.0-v8-canary202210187d6960f23f-linux-x64.tar.gz'
|
||||||
|
]
|
||||||
|
])(
|
||||||
|
'get %s version from dist if check-latest is true',
|
||||||
|
async (input, expectedVersion, foundVersion, expectedUrl) => {
|
||||||
|
const foundToolPath = path.normalize(`/cache/node/${foundVersion}/x64`);
|
||||||
|
const toolPath = path.normalize(`/cache/node/${expectedVersion}/x64`);
|
||||||
|
|
||||||
|
inputs['node-version'] = input;
|
||||||
|
inputs['check-latest'] = 'true';
|
||||||
|
os['arch'] = 'x64';
|
||||||
|
os['platform'] = 'linux';
|
||||||
|
|
||||||
|
findSpy.mockReturnValue(foundToolPath);
|
||||||
|
findAllVersionsSpy.mockReturnValue([
|
||||||
|
'20.0.0-v8-canary20221030fefe1c0879',
|
||||||
|
'19.0.0-v8-canary202210172ec229fc56',
|
||||||
|
'20.0.0-v8-canary2022102310ff1e5a8d'
|
||||||
|
]);
|
||||||
|
dlSpy.mockImplementation(async () => '/some/temp/path');
|
||||||
|
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
||||||
|
cacheSpy.mockImplementation(async () => toolPath);
|
||||||
|
|
||||||
|
// act
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
// assert
|
||||||
|
expect(findAllVersionsSpy).toHaveBeenCalled();
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
`Acquiring ${expectedVersion} - ${os.arch} from ${expectedUrl}`
|
||||||
|
);
|
||||||
|
expect(logSpy).toHaveBeenCalledWith('Extracting ...');
|
||||||
|
expect(logSpy).toHaveBeenCalledWith('Adding to the cache ...');
|
||||||
|
expect(cnSpy).toHaveBeenCalledWith(
|
||||||
|
`::add-path::${path.join(toolPath, 'bin')}${osm.EOL}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
it.each([
|
||||||
|
[
|
||||||
|
'20.0.0-v8-canary',
|
||||||
|
'20.0.0-v8-canary20221103f7e2421e91',
|
||||||
|
'20.0.0-v8-canary20221030fefe1c0879',
|
||||||
|
'https://my_mirror.org/download/v8-canary/v20.0.0-v8-canary20221103f7e2421e91/node-v20.0.0-v8-canary20221103f7e2421e91-linux-x64.tar.gz'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'20-v8-canary',
|
||||||
|
'20.0.0-v8-canary20221103f7e2421e91',
|
||||||
|
'20.0.0-v8-canary20221030fefe1c0879',
|
||||||
|
'https://my_mirror.org/download/v8-canary/v20.0.0-v8-canary20221103f7e2421e91/node-v20.0.0-v8-canary20221103f7e2421e91-linux-x64.tar.gz'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'19.0.0-v8-canary',
|
||||||
|
'19.0.0-v8-canary202210187d6960f23f',
|
||||||
|
'19.0.0-v8-canary202210172ec229fc56',
|
||||||
|
'https://my_mirror.org/download/v8-canary/v19.0.0-v8-canary202210187d6960f23f/node-v19.0.0-v8-canary202210187d6960f23f-linux-x64.tar.gz'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'19-v8-canary',
|
||||||
|
'19.0.0-v8-canary202210187d6960f23f',
|
||||||
|
'19.0.0-v8-canary202210172ec229fc56',
|
||||||
|
'https://my_mirror.org/download/v8-canary/v19.0.0-v8-canary202210187d6960f23f/node-v19.0.0-v8-canary202210187d6960f23f-linux-x64.tar.gz'
|
||||||
|
]
|
||||||
|
])(
|
||||||
|
'get %s version from dist if check-latest is true',
|
||||||
|
async (input, expectedVersion, foundVersion, expectedUrl) => {
|
||||||
|
const foundToolPath = path.normalize(`/cache/node/${foundVersion}/x64`);
|
||||||
|
const toolPath = path.normalize(`/cache/node/${expectedVersion}/x64`);
|
||||||
|
|
||||||
|
inputs['node-version'] = input;
|
||||||
|
inputs['check-latest'] = 'true';
|
||||||
|
os['arch'] = 'x64';
|
||||||
|
os['platform'] = 'linux';
|
||||||
|
inputs['mirror'] = 'https://my_mirror.org';
|
||||||
|
inputs['mirror-token'] = 'faketoken';
|
||||||
|
|
||||||
|
findSpy.mockReturnValue(foundToolPath);
|
||||||
|
findAllVersionsSpy.mockReturnValue([
|
||||||
|
'20.0.0-v8-canary20221030fefe1c0879',
|
||||||
|
'19.0.0-v8-canary202210172ec229fc56',
|
||||||
|
'20.0.0-v8-canary2022102310ff1e5a8d'
|
||||||
|
]);
|
||||||
|
dlSpy.mockImplementation(async () => '/some/temp/path');
|
||||||
|
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
||||||
|
cacheSpy.mockImplementation(async () => toolPath);
|
||||||
|
|
||||||
|
// act
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
// assert
|
||||||
|
expect(findAllVersionsSpy).toHaveBeenCalled();
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
`Acquiring ${expectedVersion} - ${os.arch} from ${expectedUrl}`
|
||||||
|
);
|
||||||
|
expect(logSpy).toHaveBeenCalledWith('Extracting ...');
|
||||||
|
expect(logSpy).toHaveBeenCalledWith('Adding to the cache ...');
|
||||||
|
expect(cnSpy).toHaveBeenCalledWith(
|
||||||
|
`::add-path::${path.join(toolPath, 'bin')}${osm.EOL}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('setup-node v8 canary tests', () => {
|
||||||
|
it('v8 canary setup node flow with cached', async () => {
|
||||||
|
const versionSpec = 'v20-v8-canary';
|
||||||
|
|
||||||
|
inputs['node-version'] = versionSpec;
|
||||||
|
inputs['token'] = 'faketoken';
|
||||||
|
|
||||||
|
os.platform = 'linux';
|
||||||
|
os.arch = 'x64';
|
||||||
|
|
||||||
|
const versionExpected = 'v20.0.0-v8-canary20221103f7e2421e91';
|
||||||
|
findAllVersionsSpy.mockImplementation(() => [versionExpected]);
|
||||||
|
|
||||||
|
const toolPath = path.normalize(`/cache/node/${versionExpected}/x64`);
|
||||||
|
findSpy.mockImplementation(version => toolPath);
|
||||||
|
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
expect(cnSpy).toHaveBeenCalledWith(
|
||||||
|
`::add-path::${toolPath}${path.sep}bin${osm.EOL}`
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(dlSpy).not.toHaveBeenCalled();
|
||||||
|
expect(exSpy).not.toHaveBeenCalled();
|
||||||
|
expect(cacheSpy).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
v24
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
nodejs 24.0.0
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
node 24.0.0
|
||||||
|
|
@ -0,0 +1,770 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"version": "v14.1.0",
|
||||||
|
"date": "2020-04-29",
|
||||||
|
"files": [
|
||||||
|
"aix-ppc64",
|
||||||
|
"headers",
|
||||||
|
"linux-arm64",
|
||||||
|
"linux-armv7l",
|
||||||
|
"linux-ppc64le",
|
||||||
|
"linux-s390x",
|
||||||
|
"linux-x64",
|
||||||
|
"osx-x64-pkg",
|
||||||
|
"osx-x64-tar",
|
||||||
|
"src",
|
||||||
|
"win-x64-7z",
|
||||||
|
"win-x64-exe",
|
||||||
|
"win-x64-msi",
|
||||||
|
"win-x64-zip",
|
||||||
|
"win-x86-7z",
|
||||||
|
"win-x86-exe",
|
||||||
|
"win-x86-msi",
|
||||||
|
"win-x86-zip"
|
||||||
|
],
|
||||||
|
"npm": "6.14.4",
|
||||||
|
"v8": "8.1.307.31",
|
||||||
|
"uv": "1.37.0",
|
||||||
|
"zlib": "1.2.11",
|
||||||
|
"openssl": "1.1.1g",
|
||||||
|
"modules": "83",
|
||||||
|
"lts": false,
|
||||||
|
"security": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "v14.0.0",
|
||||||
|
"date": "2020-04-21",
|
||||||
|
"files": [
|
||||||
|
"aix-ppc64",
|
||||||
|
"headers",
|
||||||
|
"linux-arm64",
|
||||||
|
"linux-armv7l",
|
||||||
|
"linux-ppc64le",
|
||||||
|
"linux-s390x",
|
||||||
|
"linux-x64",
|
||||||
|
"osx-x64-pkg",
|
||||||
|
"osx-x64-tar",
|
||||||
|
"src",
|
||||||
|
"win-x64-7z",
|
||||||
|
"win-x64-exe",
|
||||||
|
"win-x64-msi",
|
||||||
|
"win-x64-zip",
|
||||||
|
"win-x86-7z",
|
||||||
|
"win-x86-exe",
|
||||||
|
"win-x86-msi",
|
||||||
|
"win-x86-zip"
|
||||||
|
],
|
||||||
|
"npm": "6.14.4",
|
||||||
|
"v8": "8.1.307.30",
|
||||||
|
"uv": "1.37.0",
|
||||||
|
"zlib": "1.2.11",
|
||||||
|
"openssl": "1.1.1f",
|
||||||
|
"modules": "83",
|
||||||
|
"lts": false,
|
||||||
|
"security": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "v13.14.0",
|
||||||
|
"date": "2020-04-28",
|
||||||
|
"files": [
|
||||||
|
"aix-ppc64",
|
||||||
|
"headers",
|
||||||
|
"linux-arm64",
|
||||||
|
"linux-armv7l",
|
||||||
|
"linux-ppc64le",
|
||||||
|
"linux-s390x",
|
||||||
|
"linux-x64",
|
||||||
|
"osx-x64-pkg",
|
||||||
|
"osx-x64-tar",
|
||||||
|
"src",
|
||||||
|
"sunos-x64",
|
||||||
|
"win-x64-7z",
|
||||||
|
"win-x64-exe",
|
||||||
|
"win-x64-msi",
|
||||||
|
"win-x64-zip",
|
||||||
|
"win-x86-7z",
|
||||||
|
"win-x86-exe",
|
||||||
|
"win-x86-msi",
|
||||||
|
"win-x86-zip"
|
||||||
|
],
|
||||||
|
"npm": "6.14.4",
|
||||||
|
"v8": "7.9.317.25",
|
||||||
|
"uv": "1.37.0",
|
||||||
|
"zlib": "1.2.11",
|
||||||
|
"openssl": "1.1.1g",
|
||||||
|
"modules": "79",
|
||||||
|
"lts": false,
|
||||||
|
"security": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "v13.13.0",
|
||||||
|
"date": "2020-04-14",
|
||||||
|
"files": [
|
||||||
|
"aix-ppc64",
|
||||||
|
"headers",
|
||||||
|
"linux-arm64",
|
||||||
|
"linux-armv7l",
|
||||||
|
"linux-ppc64le",
|
||||||
|
"linux-s390x",
|
||||||
|
"linux-x64",
|
||||||
|
"osx-x64-pkg",
|
||||||
|
"osx-x64-tar",
|
||||||
|
"src",
|
||||||
|
"sunos-x64",
|
||||||
|
"win-x64-7z",
|
||||||
|
"win-x64-exe",
|
||||||
|
"win-x64-msi",
|
||||||
|
"win-x64-zip",
|
||||||
|
"win-x86-7z",
|
||||||
|
"win-x86-exe",
|
||||||
|
"win-x86-msi",
|
||||||
|
"win-x86-zip"
|
||||||
|
],
|
||||||
|
"npm": "6.14.4",
|
||||||
|
"v8": "7.9.317.25",
|
||||||
|
"uv": "1.35.0",
|
||||||
|
"zlib": "1.2.11",
|
||||||
|
"openssl": "1.1.1f",
|
||||||
|
"modules": "79",
|
||||||
|
"lts": false,
|
||||||
|
"security": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "v12.16.3",
|
||||||
|
"date": "2020-04-28",
|
||||||
|
"files": [
|
||||||
|
"aix-ppc64",
|
||||||
|
"headers",
|
||||||
|
"linux-arm64",
|
||||||
|
"linux-armv7l",
|
||||||
|
"linux-ppc64le",
|
||||||
|
"linux-s390x",
|
||||||
|
"linux-x64",
|
||||||
|
"osx-x64-pkg",
|
||||||
|
"osx-x64-tar",
|
||||||
|
"src",
|
||||||
|
"sunos-x64",
|
||||||
|
"win-x64-7z",
|
||||||
|
"win-x64-exe",
|
||||||
|
"win-x64-msi",
|
||||||
|
"win-x64-zip",
|
||||||
|
"win-x86-7z",
|
||||||
|
"win-x86-exe",
|
||||||
|
"win-x86-msi",
|
||||||
|
"win-x86-zip"
|
||||||
|
],
|
||||||
|
"npm": "6.14.4",
|
||||||
|
"v8": "7.8.279.23",
|
||||||
|
"uv": "1.34.2",
|
||||||
|
"zlib": "1.2.11",
|
||||||
|
"openssl": "1.1.1g",
|
||||||
|
"modules": "72",
|
||||||
|
"lts": "Erbium",
|
||||||
|
"security": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "v12.16.2",
|
||||||
|
"date": "2020-04-08",
|
||||||
|
"files": [
|
||||||
|
"aix-ppc64",
|
||||||
|
"headers",
|
||||||
|
"linux-arm64",
|
||||||
|
"linux-armv7l",
|
||||||
|
"linux-ppc64le",
|
||||||
|
"linux-s390x",
|
||||||
|
"linux-x64",
|
||||||
|
"osx-x64-pkg",
|
||||||
|
"osx-x64-tar",
|
||||||
|
"src",
|
||||||
|
"sunos-x64",
|
||||||
|
"win-x64-7z",
|
||||||
|
"win-x64-exe",
|
||||||
|
"win-x64-msi",
|
||||||
|
"win-x64-zip",
|
||||||
|
"win-x86-7z",
|
||||||
|
"win-x86-exe",
|
||||||
|
"win-x86-msi",
|
||||||
|
"win-x86-zip"
|
||||||
|
],
|
||||||
|
"npm": "6.14.4",
|
||||||
|
"v8": "7.8.279.23",
|
||||||
|
"uv": "1.34.2",
|
||||||
|
"zlib": "1.2.11",
|
||||||
|
"openssl": "1.1.1e",
|
||||||
|
"modules": "72",
|
||||||
|
"lts": "Erbium",
|
||||||
|
"security": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "v12.1.0",
|
||||||
|
"date": "2019-04-29",
|
||||||
|
"files": [
|
||||||
|
"aix-ppc64",
|
||||||
|
"headers",
|
||||||
|
"linux-arm64",
|
||||||
|
"linux-armv7l",
|
||||||
|
"linux-ppc64le",
|
||||||
|
"linux-s390x",
|
||||||
|
"linux-x64",
|
||||||
|
"osx-x64-pkg",
|
||||||
|
"osx-x64-tar",
|
||||||
|
"src",
|
||||||
|
"sunos-x64",
|
||||||
|
"win-x64-7z",
|
||||||
|
"win-x64-exe",
|
||||||
|
"win-x64-msi",
|
||||||
|
"win-x64-zip",
|
||||||
|
"win-x86-7z",
|
||||||
|
"win-x86-exe",
|
||||||
|
"win-x86-msi",
|
||||||
|
"win-x86-zip"
|
||||||
|
],
|
||||||
|
"npm": "6.9.0",
|
||||||
|
"v8": "7.4.288.21",
|
||||||
|
"uv": "1.28.0",
|
||||||
|
"zlib": "1.2.11",
|
||||||
|
"openssl": "1.1.1b",
|
||||||
|
"modules": "72",
|
||||||
|
"lts": false,
|
||||||
|
"security": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "v11.15.0",
|
||||||
|
"date": "2019-04-30",
|
||||||
|
"files": [
|
||||||
|
"aix-ppc64",
|
||||||
|
"headers",
|
||||||
|
"linux-arm64",
|
||||||
|
"linux-armv6l",
|
||||||
|
"linux-armv7l",
|
||||||
|
"linux-ppc64le",
|
||||||
|
"linux-s390x",
|
||||||
|
"linux-x64",
|
||||||
|
"osx-x64-pkg",
|
||||||
|
"osx-x64-tar",
|
||||||
|
"src",
|
||||||
|
"sunos-x64",
|
||||||
|
"win-x64-7z",
|
||||||
|
"win-x64-exe",
|
||||||
|
"win-x64-msi",
|
||||||
|
"win-x64-zip",
|
||||||
|
"win-x86-7z",
|
||||||
|
"win-x86-exe",
|
||||||
|
"win-x86-msi",
|
||||||
|
"win-x86-zip"
|
||||||
|
],
|
||||||
|
"npm": "6.7.0",
|
||||||
|
"v8": "7.0.276.38",
|
||||||
|
"uv": "1.27.0",
|
||||||
|
"zlib": "1.2.11",
|
||||||
|
"openssl": "1.1.1b",
|
||||||
|
"modules": "67",
|
||||||
|
"lts": false,
|
||||||
|
"security": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "v10.20.1",
|
||||||
|
"date": "2020-04-10",
|
||||||
|
"files": [
|
||||||
|
"aix-ppc64",
|
||||||
|
"headers",
|
||||||
|
"linux-arm64",
|
||||||
|
"linux-armv6l",
|
||||||
|
"linux-armv7l",
|
||||||
|
"linux-ppc64le",
|
||||||
|
"linux-s390x",
|
||||||
|
"linux-x64",
|
||||||
|
"osx-x64-pkg",
|
||||||
|
"osx-x64-tar",
|
||||||
|
"src",
|
||||||
|
"sunos-x64",
|
||||||
|
"win-x64-7z",
|
||||||
|
"win-x64-exe",
|
||||||
|
"win-x64-msi",
|
||||||
|
"win-x64-zip",
|
||||||
|
"win-x86-7z",
|
||||||
|
"win-x86-exe",
|
||||||
|
"win-x86-msi",
|
||||||
|
"win-x86-zip"
|
||||||
|
],
|
||||||
|
"npm": "6.14.4",
|
||||||
|
"v8": "6.8.275.32",
|
||||||
|
"uv": "1.34.2",
|
||||||
|
"zlib": "1.2.11",
|
||||||
|
"openssl": "1.1.1e",
|
||||||
|
"modules": "64",
|
||||||
|
"lts": "Dubnium",
|
||||||
|
"security": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "v10.20.0",
|
||||||
|
"date": "2020-03-24",
|
||||||
|
"files": [
|
||||||
|
"aix-ppc64",
|
||||||
|
"headers",
|
||||||
|
"linux-arm64",
|
||||||
|
"linux-armv6l",
|
||||||
|
"linux-armv7l",
|
||||||
|
"linux-ppc64le",
|
||||||
|
"linux-s390x",
|
||||||
|
"linux-x64",
|
||||||
|
"osx-x64-pkg",
|
||||||
|
"osx-x64-tar",
|
||||||
|
"src",
|
||||||
|
"sunos-x64",
|
||||||
|
"win-x64-7z",
|
||||||
|
"win-x64-exe",
|
||||||
|
"win-x64-msi",
|
||||||
|
"win-x64-zip",
|
||||||
|
"win-x86-7z",
|
||||||
|
"win-x86-exe",
|
||||||
|
"win-x86-msi",
|
||||||
|
"win-x86-zip"
|
||||||
|
],
|
||||||
|
"npm": "6.14.4",
|
||||||
|
"v8": "6.8.275.32",
|
||||||
|
"uv": "1.34.2",
|
||||||
|
"zlib": "1.2.11",
|
||||||
|
"openssl": "1.1.1e",
|
||||||
|
"modules": "64",
|
||||||
|
"lts": "Dubnium",
|
||||||
|
"security": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "v9.11.2",
|
||||||
|
"date": "2018-06-12",
|
||||||
|
"files": [
|
||||||
|
"aix-ppc64",
|
||||||
|
"headers",
|
||||||
|
"linux-arm64",
|
||||||
|
"linux-armv6l",
|
||||||
|
"linux-armv7l",
|
||||||
|
"linux-ppc64le",
|
||||||
|
"linux-s390x",
|
||||||
|
"linux-x64",
|
||||||
|
"linux-x86",
|
||||||
|
"osx-x64-pkg",
|
||||||
|
"osx-x64-tar",
|
||||||
|
"src",
|
||||||
|
"sunos-x64",
|
||||||
|
"sunos-x86",
|
||||||
|
"win-x64-7z",
|
||||||
|
"win-x64-exe",
|
||||||
|
"win-x64-msi",
|
||||||
|
"win-x64-zip",
|
||||||
|
"win-x86-7z",
|
||||||
|
"win-x86-exe",
|
||||||
|
"win-x86-msi",
|
||||||
|
"win-x86-zip"
|
||||||
|
],
|
||||||
|
"npm": "5.6.0",
|
||||||
|
"v8": "6.2.414.46",
|
||||||
|
"uv": "1.19.2",
|
||||||
|
"zlib": "1.2.11",
|
||||||
|
"openssl": "1.0.2o",
|
||||||
|
"modules": "59",
|
||||||
|
"lts": false,
|
||||||
|
"security": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "v9.11.1",
|
||||||
|
"date": "2018-04-05",
|
||||||
|
"files": [
|
||||||
|
"aix-ppc64",
|
||||||
|
"headers",
|
||||||
|
"linux-arm64",
|
||||||
|
"linux-armv6l",
|
||||||
|
"linux-armv7l",
|
||||||
|
"linux-ppc64le",
|
||||||
|
"linux-s390x",
|
||||||
|
"linux-x64",
|
||||||
|
"linux-x86",
|
||||||
|
"osx-x64-pkg",
|
||||||
|
"osx-x64-tar",
|
||||||
|
"src",
|
||||||
|
"sunos-x64",
|
||||||
|
"sunos-x86",
|
||||||
|
"win-x64-7z",
|
||||||
|
"win-x64-exe",
|
||||||
|
"win-x64-msi",
|
||||||
|
"win-x64-zip",
|
||||||
|
"win-x86-7z",
|
||||||
|
"win-x86-exe",
|
||||||
|
"win-x86-msi",
|
||||||
|
"win-x86-zip"
|
||||||
|
],
|
||||||
|
"npm": "5.6.0",
|
||||||
|
"v8": "6.2.414.46",
|
||||||
|
"uv": "1.19.2",
|
||||||
|
"zlib": "1.2.11",
|
||||||
|
"openssl": "1.0.2o",
|
||||||
|
"modules": "59",
|
||||||
|
"lts": false,
|
||||||
|
"security": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "v8.17.0",
|
||||||
|
"date": "2019-12-17",
|
||||||
|
"files": [
|
||||||
|
"aix-ppc64",
|
||||||
|
"headers",
|
||||||
|
"linux-arm64",
|
||||||
|
"linux-armv6l",
|
||||||
|
"linux-armv7l",
|
||||||
|
"linux-ppc64le",
|
||||||
|
"linux-s390x",
|
||||||
|
"linux-x64",
|
||||||
|
"linux-x86",
|
||||||
|
"osx-x64-pkg",
|
||||||
|
"osx-x64-tar",
|
||||||
|
"src",
|
||||||
|
"sunos-x64",
|
||||||
|
"sunos-x86",
|
||||||
|
"win-x64-7z",
|
||||||
|
"win-x64-exe",
|
||||||
|
"win-x64-msi",
|
||||||
|
"win-x64-zip",
|
||||||
|
"win-x86-7z",
|
||||||
|
"win-x86-exe",
|
||||||
|
"win-x86-msi",
|
||||||
|
"win-x86-zip"
|
||||||
|
],
|
||||||
|
"npm": "6.13.4",
|
||||||
|
"v8": "6.2.414.78",
|
||||||
|
"uv": "1.23.2",
|
||||||
|
"zlib": "1.2.11",
|
||||||
|
"openssl": "1.0.2s",
|
||||||
|
"modules": "57",
|
||||||
|
"lts": "Carbon",
|
||||||
|
"security": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "v8.16.2",
|
||||||
|
"date": "2019-10-08",
|
||||||
|
"files": [
|
||||||
|
"aix-ppc64",
|
||||||
|
"headers",
|
||||||
|
"linux-arm64",
|
||||||
|
"linux-armv6l",
|
||||||
|
"linux-armv7l",
|
||||||
|
"linux-ppc64le",
|
||||||
|
"linux-s390x",
|
||||||
|
"linux-x64",
|
||||||
|
"linux-x86",
|
||||||
|
"osx-x64-pkg",
|
||||||
|
"osx-x64-tar",
|
||||||
|
"src",
|
||||||
|
"sunos-x64",
|
||||||
|
"sunos-x86",
|
||||||
|
"win-x64-7z",
|
||||||
|
"win-x64-exe",
|
||||||
|
"win-x64-msi",
|
||||||
|
"win-x64-zip",
|
||||||
|
"win-x86-7z",
|
||||||
|
"win-x86-exe",
|
||||||
|
"win-x86-msi",
|
||||||
|
"win-x86-zip"
|
||||||
|
],
|
||||||
|
"npm": "6.4.1",
|
||||||
|
"v8": "6.2.414.78",
|
||||||
|
"uv": "1.23.2",
|
||||||
|
"zlib": "1.2.11",
|
||||||
|
"openssl": "1.0.2s",
|
||||||
|
"modules": "57",
|
||||||
|
"lts": "Carbon",
|
||||||
|
"security": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "v7.10.1",
|
||||||
|
"date": "2017-07-11",
|
||||||
|
"files": [
|
||||||
|
"aix-ppc64",
|
||||||
|
"headers",
|
||||||
|
"linux-arm64",
|
||||||
|
"linux-armv6l",
|
||||||
|
"linux-armv7l",
|
||||||
|
"linux-ppc64le",
|
||||||
|
"linux-s390x",
|
||||||
|
"linux-x64",
|
||||||
|
"linux-x86",
|
||||||
|
"osx-x64-pkg",
|
||||||
|
"osx-x64-tar",
|
||||||
|
"src",
|
||||||
|
"sunos-x64",
|
||||||
|
"sunos-x86",
|
||||||
|
"win-x64-7z",
|
||||||
|
"win-x64-exe",
|
||||||
|
"win-x64-msi",
|
||||||
|
"win-x64-zip",
|
||||||
|
"win-x86-7z",
|
||||||
|
"win-x86-exe",
|
||||||
|
"win-x86-msi",
|
||||||
|
"win-x86-zip"
|
||||||
|
],
|
||||||
|
"npm": "4.2.0",
|
||||||
|
"v8": "5.5.372.43",
|
||||||
|
"uv": "1.11.0",
|
||||||
|
"zlib": "1.2.11",
|
||||||
|
"openssl": "1.0.2k",
|
||||||
|
"modules": "51",
|
||||||
|
"lts": false,
|
||||||
|
"security": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "v7.10.0",
|
||||||
|
"date": "2017-05-02",
|
||||||
|
"files": [
|
||||||
|
"aix-ppc64",
|
||||||
|
"headers",
|
||||||
|
"linux-arm64",
|
||||||
|
"linux-armv6l",
|
||||||
|
"linux-armv7l",
|
||||||
|
"linux-ppc64le",
|
||||||
|
"linux-s390x",
|
||||||
|
"linux-x64",
|
||||||
|
"linux-x86",
|
||||||
|
"osx-x64-pkg",
|
||||||
|
"osx-x64-tar",
|
||||||
|
"src",
|
||||||
|
"sunos-x64",
|
||||||
|
"sunos-x86",
|
||||||
|
"win-x64-7z",
|
||||||
|
"win-x64-exe",
|
||||||
|
"win-x64-msi",
|
||||||
|
"win-x64-zip",
|
||||||
|
"win-x86-7z",
|
||||||
|
"win-x86-exe",
|
||||||
|
"win-x86-msi",
|
||||||
|
"win-x86-zip"
|
||||||
|
],
|
||||||
|
"npm": "4.2.0",
|
||||||
|
"v8": "5.5.372.43",
|
||||||
|
"uv": "1.11.0",
|
||||||
|
"zlib": "1.2.11",
|
||||||
|
"openssl": "1.0.2k",
|
||||||
|
"modules": "51",
|
||||||
|
"lts": false,
|
||||||
|
"security": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "v6.17.1",
|
||||||
|
"date": "2019-04-03",
|
||||||
|
"files": [
|
||||||
|
"aix-ppc64",
|
||||||
|
"headers",
|
||||||
|
"linux-arm64",
|
||||||
|
"linux-armv6l",
|
||||||
|
"linux-armv7l",
|
||||||
|
"linux-ppc64le",
|
||||||
|
"linux-s390x",
|
||||||
|
"linux-x64",
|
||||||
|
"linux-x86",
|
||||||
|
"osx-x64-pkg",
|
||||||
|
"osx-x64-tar",
|
||||||
|
"src",
|
||||||
|
"sunos-x64",
|
||||||
|
"sunos-x86",
|
||||||
|
"win-x64-7z",
|
||||||
|
"win-x64-exe",
|
||||||
|
"win-x64-msi",
|
||||||
|
"win-x64-zip",
|
||||||
|
"win-x86-7z",
|
||||||
|
"win-x86-exe",
|
||||||
|
"win-x86-msi",
|
||||||
|
"win-x86-zip"
|
||||||
|
],
|
||||||
|
"npm": "3.10.10",
|
||||||
|
"v8": "5.1.281.111",
|
||||||
|
"uv": "1.16.1",
|
||||||
|
"zlib": "1.2.11",
|
||||||
|
"openssl": "1.0.2r",
|
||||||
|
"modules": "48",
|
||||||
|
"lts": "Boron",
|
||||||
|
"security": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "v6.17.0",
|
||||||
|
"date": "2019-02-28",
|
||||||
|
"files": [
|
||||||
|
"aix-ppc64",
|
||||||
|
"headers",
|
||||||
|
"linux-arm64",
|
||||||
|
"linux-armv6l",
|
||||||
|
"linux-armv7l",
|
||||||
|
"linux-ppc64le",
|
||||||
|
"linux-s390x",
|
||||||
|
"linux-x64",
|
||||||
|
"linux-x86",
|
||||||
|
"osx-x64-pkg",
|
||||||
|
"osx-x64-tar",
|
||||||
|
"src",
|
||||||
|
"sunos-x64",
|
||||||
|
"sunos-x86",
|
||||||
|
"win-x64-7z",
|
||||||
|
"win-x64-exe",
|
||||||
|
"win-x64-msi",
|
||||||
|
"win-x64-zip",
|
||||||
|
"win-x86-7z",
|
||||||
|
"win-x86-exe",
|
||||||
|
"win-x86-msi",
|
||||||
|
"win-x86-zip"
|
||||||
|
],
|
||||||
|
"npm": "3.10.10",
|
||||||
|
"v8": "5.1.281.111",
|
||||||
|
"uv": "1.16.1",
|
||||||
|
"zlib": "1.2.11",
|
||||||
|
"openssl": "1.0.2r",
|
||||||
|
"modules": "48",
|
||||||
|
"lts": "Boron",
|
||||||
|
"security": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "v5.12.0",
|
||||||
|
"date": "2016-06-23",
|
||||||
|
"files": [
|
||||||
|
"headers",
|
||||||
|
"linux-arm64",
|
||||||
|
"linux-armv6l",
|
||||||
|
"linux-armv7l",
|
||||||
|
"linux-ppc64le",
|
||||||
|
"linux-x64",
|
||||||
|
"linux-x86",
|
||||||
|
"osx-x64-pkg",
|
||||||
|
"osx-x64-tar",
|
||||||
|
"src",
|
||||||
|
"sunos-x64",
|
||||||
|
"sunos-x86",
|
||||||
|
"win-x64-exe",
|
||||||
|
"win-x64-msi",
|
||||||
|
"win-x86-exe",
|
||||||
|
"win-x86-msi"
|
||||||
|
],
|
||||||
|
"npm": "3.8.6",
|
||||||
|
"v8": "4.6.85.32",
|
||||||
|
"uv": "1.8.0",
|
||||||
|
"zlib": "1.2.8",
|
||||||
|
"openssl": "1.0.2h",
|
||||||
|
"modules": "47",
|
||||||
|
"lts": false,
|
||||||
|
"security": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "v4.9.1",
|
||||||
|
"date": "2018-03-29",
|
||||||
|
"files": [
|
||||||
|
"headers",
|
||||||
|
"linux-arm64",
|
||||||
|
"linux-armv6l",
|
||||||
|
"linux-armv7l",
|
||||||
|
"linux-ppc64le",
|
||||||
|
"linux-x64",
|
||||||
|
"linux-x86",
|
||||||
|
"osx-x64-pkg",
|
||||||
|
"osx-x64-tar",
|
||||||
|
"src",
|
||||||
|
"sunos-x64",
|
||||||
|
"sunos-x86",
|
||||||
|
"win-x64-7z",
|
||||||
|
"win-x64-exe",
|
||||||
|
"win-x64-msi",
|
||||||
|
"win-x64-zip",
|
||||||
|
"win-x86-7z",
|
||||||
|
"win-x86-exe",
|
||||||
|
"win-x86-msi",
|
||||||
|
"win-x86-zip"
|
||||||
|
],
|
||||||
|
"npm": "2.15.11",
|
||||||
|
"v8": "4.5.103.53",
|
||||||
|
"uv": "1.9.1",
|
||||||
|
"zlib": "1.2.11",
|
||||||
|
"openssl": "1.0.2o",
|
||||||
|
"modules": "46",
|
||||||
|
"lts": "Argon",
|
||||||
|
"security": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "v4.9.0",
|
||||||
|
"date": "2018-03-28",
|
||||||
|
"files": [
|
||||||
|
"headers",
|
||||||
|
"linux-arm64",
|
||||||
|
"linux-armv6l",
|
||||||
|
"linux-armv7l",
|
||||||
|
"linux-ppc64le",
|
||||||
|
"linux-x64",
|
||||||
|
"linux-x86",
|
||||||
|
"osx-x64-pkg",
|
||||||
|
"osx-x64-tar",
|
||||||
|
"src",
|
||||||
|
"sunos-x64",
|
||||||
|
"sunos-x86",
|
||||||
|
"win-x64-7z",
|
||||||
|
"win-x64-exe",
|
||||||
|
"win-x64-msi",
|
||||||
|
"win-x64-zip",
|
||||||
|
"win-x86-7z",
|
||||||
|
"win-x86-exe",
|
||||||
|
"win-x86-msi",
|
||||||
|
"win-x86-zip"
|
||||||
|
],
|
||||||
|
"npm": "2.15.11",
|
||||||
|
"v8": "4.5.103.53",
|
||||||
|
"uv": "1.9.1",
|
||||||
|
"zlib": "1.2.11",
|
||||||
|
"openssl": "1.0.2o",
|
||||||
|
"modules": "46",
|
||||||
|
"lts": "Argon",
|
||||||
|
"security": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "v0.12.18",
|
||||||
|
"date": "2017-02-22",
|
||||||
|
"files": [
|
||||||
|
"headers",
|
||||||
|
"linux-x64",
|
||||||
|
"linux-x86",
|
||||||
|
"osx-x64-pkg",
|
||||||
|
"osx-x64-tar",
|
||||||
|
"osx-x86-tar",
|
||||||
|
"src",
|
||||||
|
"sunos-x86",
|
||||||
|
"win-x64-exe",
|
||||||
|
"win-x86-exe",
|
||||||
|
"win-x86-msi"
|
||||||
|
],
|
||||||
|
"npm": "2.15.11",
|
||||||
|
"v8": "3.28.71.20",
|
||||||
|
"uv": "1.6.1",
|
||||||
|
"zlib": "1.2.8",
|
||||||
|
"openssl": "1.0.1u",
|
||||||
|
"modules": "14",
|
||||||
|
"lts": false,
|
||||||
|
"security": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "v0.12.17",
|
||||||
|
"date": "2016-10-18",
|
||||||
|
"files": [
|
||||||
|
"headers",
|
||||||
|
"linux-x64",
|
||||||
|
"linux-x86",
|
||||||
|
"osx-x64-pkg",
|
||||||
|
"osx-x64-tar",
|
||||||
|
"osx-x86-tar",
|
||||||
|
"src",
|
||||||
|
"sunos-x64",
|
||||||
|
"sunos-x86",
|
||||||
|
"win-x64-exe",
|
||||||
|
"win-x86-exe",
|
||||||
|
"win-x86-msi"
|
||||||
|
],
|
||||||
|
"npm": "2.15.1",
|
||||||
|
"v8": "3.28.71.19",
|
||||||
|
"uv": "1.6.1",
|
||||||
|
"zlib": "1.2.8",
|
||||||
|
"openssl": "1.0.1u",
|
||||||
|
"modules": "14",
|
||||||
|
"lts": false,
|
||||||
|
"security": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
[
|
||||||
|
{"version":"v20.0.0-nightly2022101987cdf7d412","date":"2022-10-19","files":["aix-ppc64","headers","linux-arm64","linux-armv7l","linux-ppc64le","linux-s390x","linux-x64","osx-arm64-tar","osx-x64-pkg","osx-x64-tar","src","win-x64-7z","win-x64-exe","win-x64-msi","win-x64-zip","win-x86-7z","win-x86-exe","win-x86-msi","win-x86-zip"],"npm":"8.19.2","v8":"10.7.193.16","uv":"1.43.0","zlib":"1.2.11","openssl":"3.0.5+quic","modules":"111","lts":false,"security":false},
|
||||||
|
{"version":"v19.0.0-nightly202210182672219b78","date":"2022-10-18","files":["aix-ppc64","headers","linux-arm64","linux-armv7l","linux-ppc64le","linux-s390x","linux-x64","osx-arm64-tar","osx-x64-pkg","osx-x64-tar","src","win-x64-7z","win-x64-exe","win-x64-msi","win-x64-zip","win-x86-7z","win-x86-exe","win-x86-msi","win-x86-zip"],"npm":"8.19.2","v8":"10.7.193.13","uv":"1.43.0","zlib":"1.2.11","openssl":"3.0.5+quic","modules":"111","lts":false,"security":false},
|
||||||
|
|
||||||
|
|
||||||
|
{"version":"v19.0.0-nightly202204201fe5d56403","date":"2022-04-20","files":["aix-ppc64","headers","linux-arm64","linux-armv7l","linux-ppc64le","linux-s390x","linux-x64","osx-arm64-tar","osx-x64-tar","src","win-x64-7z","win-x64-exe","win-x64-msi","win-x64-zip"],"npm":"8.7.0","v8":"10.1.124.8","uv":"1.43.0","zlib":"1.2.11","openssl":"3.0.2+quic","modules":"108","lts":false,"security":false},
|
||||||
|
{"version":"v18.0.0-nightly20220419bde889bd4e","date":"2022-04-19","files":["aix-ppc64","headers","linux-arm64","linux-armv7l","linux-ppc64le","linux-s390x","linux-x64","osx-arm64-tar","osx-x64-pkg","osx-x64-tar","src","win-x64-7z","win-x64-exe","win-x64-msi","win-x64-zip"],"npm":"8.7.0","v8":"10.1.124.8","uv":"1.43.0","zlib":"1.2.11","openssl":"3.0.2+quic","modules":"108","lts":false,"security":false},
|
||||||
|
{"version":"v18.0.0-nightly202204180699150267","date":"2022-04-18","files":["aix-ppc64","headers","linux-arm64","linux-armv7l","linux-ppc64le","linux-s390x","linux-x64","osx-arm64-tar","osx-x64-pkg","osx-x64-tar","src","win-x64-7z","win-x64-exe","win-x64-msi","win-x64-zip"],"npm":"8.7.0","v8":"10.1.124.8","uv":"1.43.0","zlib":"1.2.11","openssl":"3.0.2+quic","modules":"108","lts":false,"security":false},
|
||||||
|
|
||||||
|
{"version":"v18.0.0-nightly202110204cb3e06ed8","date":"2021-10-20","files":["aix-ppc64","headers","linux-arm64","linux-armv7l","linux-ppc64le","linux-s390x","linux-x64","osx-arm64-tar","osx-x64-pkg","osx-x64-tar","src","win-x64-7z","win-x64-exe","win-x64-msi","win-x64-zip","win-x86-7z","win-x86-exe","win-x86-msi","win-x86-zip"],"npm":"8.1.0","v8":"9.5.172.21","uv":"1.42.0","zlib":"1.2.11","openssl":"3.0.0+quic","modules":"102","lts":false,"security":false},
|
||||||
|
{"version":"v17.5.0-nightly20220209e43808936a","date":"2022-02-09","files":["aix-ppc64","headers","linux-arm64","linux-armv7l","linux-ppc64le","linux-s390x","linux-x64","osx-arm64-tar","osx-x64-pkg","osx-x64-tar","src","win-x64-7z","win-x64-exe","win-x64-msi","win-x64-zip","win-x86-7z","win-x86-exe","win-x86-msi","win-x86-zip"],"npm":"8.4.1","v8":"9.6.180.15","uv":"1.43.0","zlib":"1.2.11","openssl":"3.0.1+quic","modules":"102","lts":false,"security":false},
|
||||||
|
{"version":"v17.0.0-nightly202110193f11666dc7","date":"2021-10-19","files":["aix-ppc64","headers","linux-arm64","linux-armv7l","linux-ppc64le","linux-s390x","linux-x64","osx-arm64-tar","osx-x64-pkg","osx-x64-tar","src","win-x64-7z","win-x64-exe","win-x64-msi","win-x64-zip","win-x86-7z","win-x86-exe","win-x86-msi","win-x86-zip"],"npm":"8.1.0","v8":"9.5.172.21","uv":"1.42.0","zlib":"1.2.11","openssl":"3.0.0+quic","modules":"102","lts":false,"security":false},
|
||||||
|
{"version":"v17.0.0-nightly20211018c0a70203de","date":"2021-10-18","files":["aix-ppc64","headers","linux-arm64","linux-armv7l","linux-ppc64le","linux-s390x","linux-x64","osx-arm64-tar","osx-x64-pkg","osx-x64-tar","src","win-x64-7z","win-x64-exe","win-x64-msi","win-x64-zip","win-x86-7z","win-x86-exe","win-x86-msi","win-x86-zip"],"npm":"8.0.0","v8":"9.5.172.21","uv":"1.42.0","zlib":"1.2.11","openssl":"3.0.0+quic","modules":"102","lts":false,"security":false},
|
||||||
|
|
||||||
|
{"version":"v16.0.0-nightly20210420a0261d231c","date":"2021-04-20","files":["aix-ppc64","headers","linux-arm64","linux-armv7l","linux-ppc64le","linux-s390x","linux-x64","osx-arm64-tar","osx-x64-pkg","osx-x64-tar","src","win-x64-7z","win-x64-exe","win-x64-msi","win-x64-zip","win-x86-7z","win-x86-exe","win-x86-msi","win-x86-zip"],"npm":"7.10.0","v8":"9.0.257.17","uv":"1.41.0","zlib":"1.2.11","openssl":"1.1.1k+quic","modules":"93","lts":false,"security":false},
|
||||||
|
{"version":"v16.0.0-nightly20210417bc31dc0e0f","date":"2021-04-17","files":["aix-ppc64","headers","linux-arm64","linux-ppc64le","linux-s390x","linux-x64","osx-arm64-tar","osx-x64-pkg","osx-x64-tar","src","win-x64-7z","win-x64-exe","win-x64-msi","win-x64-zip","win-x86-7z","win-x86-exe","win-x86-msi","win-x86-zip"],"npm":"7.10.0","v8":"9.0.257.17","uv":"1.41.0","zlib":"1.2.11","openssl":"1.1.1k+quic","modules":"93","lts":false,"security":false},
|
||||||
|
{"version":"v16.0.0-nightly20210416d3162da8dd","date":"2021-04-16","files":["aix-ppc64","headers","linux-arm64","linux-ppc64le","linux-s390x","linux-x64","osx-arm64-tar","osx-x64-pkg","osx-x64-tar","src","win-x64-7z","win-x64-exe","win-x64-msi","win-x64-zip","win-x86-7z","win-x86-exe","win-x86-msi","win-x86-zip"],"npm":"7.9.0","v8":"9.0.257.17","uv":"1.41.0","zlib":"1.2.11","openssl":"1.1.1k+quic","modules":"93","lts":false,"security":false},
|
||||||
|
{"version":"v16.0.0-nightly20210415c3a5e15ebe","date":"2021-04-15","files":["aix-ppc64","headers","linux-arm64","linux-ppc64le","linux-s390x","linux-x64","osx-arm64-tar","osx-x64-pkg","osx-x64-tar","src","win-x64-7z","win-x64-exe","win-x64-msi","win-x64-zip","win-x86-7z","win-x86-exe","win-x86-msi","win-x86-zip"],"npm":"7.9.0","v8":"9.0.257.17","uv":"1.41.0","zlib":"1.2.11","openssl":"1.1.1k+quic","modules":"93","lts":false,"security":false},
|
||||||
|
|
||||||
|
|
||||||
|
{"version":"v15.0.0-nightly2020102011f1ad939f","date":"2020-10-20","files":["aix-ppc64","headers","linux-arm64","linux-armv7l","linux-ppc64le","linux-s390x","linux-x64","osx-x64-pkg","osx-x64-tar","src","win-x64-7z","win-x64-exe","win-x64-msi","win-x64-zip","win-x86-7z","win-x86-exe","win-x86-msi","win-x86-zip"],"npm":"7.0.2","v8":"8.6.395.16","uv":"1.40.0","zlib":"1.2.11","openssl":"1.1.1g","modules":"88","lts":false,"security":false},
|
||||||
|
{"version":"v15.0.0-nightly20201019c55f661551","date":"2020-10-19","files":["aix-ppc64","headers","linux-arm64","linux-armv7l","linux-ppc64le","linux-s390x","linux-x64","osx-x64-pkg","osx-x64-tar","src","win-x64-7z","win-x64-exe","win-x64-msi","win-x64-zip","win-x86-7z","win-x86-exe","win-x86-msi","win-x86-zip"],"npm":"7.0.2","v8":"8.6.395.16","uv":"1.40.0","zlib":"1.2.11","openssl":"1.1.1g","modules":"88","lts":false,"security":false},
|
||||||
|
{"version":"v14.0.0-nightly20200421c3554307c6","date":"2020-04-21","files":["aix-ppc64","headers","linux-arm64","linux-armv7l","linux-ppc64le","linux-s390x","linux-x64","osx-x64-pkg","osx-x64-tar","src","win-x64-7z","win-x64-exe","win-x64-msi","win-x64-zip","win-x86-7z","win-x86-exe","win-x86-msi","win-x86-zip"],"npm":"6.14.4","v8":"8.1.307.30","uv":"1.37.0","zlib":"1.2.11","openssl":"1.1.1f","modules":"83","lts":false,"security":false},
|
||||||
|
{"version":"v14.0.0-nightly202004204af0598134","date":"2020-04-20","files":["aix-ppc64","headers","linux-arm64","linux-armv7l","linux-ppc64le","linux-s390x","linux-x64","osx-x64-pkg","osx-x64-tar","src","win-x64-7z","win-x64-exe","win-x64-msi","win-x64-zip","win-x86-7z","win-x86-exe","win-x86-msi","win-x86-zip"],"npm":"6.14.4","v8":"8.1.307.26","uv":"1.37.0","zlib":"1.2.11","openssl":"1.1.1f","modules":"83","lts":false,"security":false},
|
||||||
|
|
||||||
|
{"version":"v13.13.1-nightly20200415947ddec091","date":"2020-04-15","files":["aix-ppc64","headers","linux-arm64","linux-armv7l","linux-ppc64le","linux-s390x","linux-x64","osx-x64-pkg","osx-x64-tar","src","sunos-x64","win-x64-7z","win-x64-exe","win-x64-msi","win-x64-zip","win-x86-7z","win-x86-exe","win-x86-msi","win-x86-zip"],"npm":"6.14.4","v8":"7.9.317.25","uv":"1.35.0","zlib":"1.2.11","openssl":"1.1.1f","modules":"79","lts":false,"security":false},
|
||||||
|
{"version":"v13.11.1-nightly2020032628e298f219","date":"2020-03-26","files":["aix-ppc64","headers","linux-arm64","linux-armv7l","linux-ppc64le","linux-s390x","linux-x64","osx-x64-pkg","osx-x64-tar","src","sunos-x64","win-x64-7z","win-x64-exe","win-x64-msi","win-x64-zip","win-x86-7z","win-x86-exe","win-x86-msi","win-x86-zip"],"npm":"6.14.3","v8":"7.9.317.25","uv":"1.35.0","zlib":"1.2.11","openssl":"1.1.1e","modules":"79","lts":false,"security":false},
|
||||||
|
|
||||||
|
{"version":"v13.10.2-nightly202003056122620832","date":"2020-03-05","files":["aix-ppc64","headers","linux-arm64","linux-armv7l","linux-ppc64le","linux-s390x","linux-x64","osx-x64-pkg","osx-x64-tar","src","sunos-x64","win-x64-7z","win-x64-exe","win-x64-msi","win-x64-zip","win-x86-7z","win-x86-exe","win-x86-msi","win-x86-zip"],"npm":"6.13.7","v8":"7.9.317.25","uv":"1.34.2","zlib":"1.2.11","openssl":"1.1.1d","modules":"79","lts":false,"security":false},
|
||||||
|
{"version":"v13.9.1-nightly202003041bca7b6c70","date":"2020-03-04","files":["aix-ppc64","headers","linux-arm64","linux-armv7l","linux-ppc64le","linux-s390x","linux-x64","osx-x64-pkg","osx-x64-tar","src","sunos-x64","win-x64-7z","win-x64-exe","win-x64-msi","win-x64-zip","win-x86-7z","win-x86-exe","win-x86-msi","win-x86-zip"],"npm":"6.13.7","v8":"7.9.317.25","uv":"1.34.2","zlib":"1.2.11","openssl":"1.1.1d","modules":"79","lts":false,"security":false},
|
||||||
|
{"version":"v13.0.0-nightly201908175e3b4d6ed9","date":"2019-08-17","files":["aix-ppc64","headers","linux-arm64","linux-armv7l","linux-ppc64le","linux-s390x","linux-x64","osx-x64-pkg","osx-x64-tar","src","sunos-x64","win-x64-7z","win-x64-exe","win-x64-msi","win-x64-zip","win-x86-7z","win-x86-exe","win-x86-msi","win-x86-zip"],"npm":"6.10.2","v8":"7.6.303.28","uv":"1.31.0","zlib":"1.2.11","openssl":"1.1.1c","modules":"77","lts":false,"security":true},
|
||||||
|
{"version":"v13.0.0-nightly2019081671b5ce5885","date":"2019-08-16","files":["aix-ppc64","headers","linux-arm64","linux-armv7l","linux-ppc64le","linux-s390x","linux-x64","osx-x64-pkg","osx-x64-tar","src","sunos-x64","win-x64-7z","win-x64-exe","win-x64-msi","win-x64-zip","win-x86-7z","win-x86-exe","win-x86-msi","win-x86-zip"],"npm":"6.10.2","v8":"7.6.303.28","uv":"1.31.0","zlib":"1.2.11","openssl":"1.1.1c","modules":"77","lts":false,"security":true},
|
||||||
|
{"version":"v13.0.0-nightly2019072962a809fa54","date":"2019-07-29","files":["aix-ppc64","headers","linux-arm64","linux-armv7l","linux-ppc64le","linux-s390x","linux-x64","osx-x64-pkg","osx-x64-tar","src","sunos-x64","win-x64-7z","win-x64-exe","win-x64-msi","win-x64-zip","win-x86-7z","win-x86-exe","win-x86-msi","win-x86-zip"],"npm":"6.10.0","v8":"7.5.288.22","uv":"1.30.1","zlib":"1.2.11","openssl":"1.1.1c","modules":"74","lts":false,"security":false}
|
||||||
|
|
||||||
|
]
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
[
|
||||||
|
{"version":"v19.0.0-rc.2","date":"2022-10-14","files":["aix-ppc64","headers","linux-arm64","linux-armv7l","linux-ppc64le","linux-s390x","linux-x64","osx-arm64-tar","osx-x64-pkg","osx-x64-tar","src","win-x64-7z","win-x64-exe","win-x64-msi","win-x64-zip","win-x86-7z","win-x86-exe","win-x86-msi","win-x86-zip"],"v8":"","uv":"","zlib":null,"openssl":null,"modules":null,"lts":false,"security":false},
|
||||||
|
{"version":"v19.0.0-rc.1","date":"2022-10-04","files":["aix-ppc64","headers","linux-arm64","linux-armv7l","linux-ppc64le","linux-s390x","linux-x64","osx-arm64-tar","osx-x64-pkg","osx-x64-tar","src","win-x64-7z","win-x64-exe","win-x64-msi","win-x64-zip","win-x86-7z","win-x86-exe","win-x86-msi","win-x86-zip"],"v8":"","uv":"","zlib":null,"openssl":null,"modules":null,"lts":false,"security":false},
|
||||||
|
{"version":"v17.0.0-rc.1","date":"2021-10-05","files":["aix-ppc64","headers","linux-arm64","linux-armv7l","linux-ppc64le","linux-s390x","linux-x64","osx-arm64-tar","osx-x64-pkg","osx-x64-tar","src","win-x64-7z","win-x64-exe","win-x64-msi","win-x64-zip","win-x86-7z","win-x86-exe","win-x86-msi","win-x86-zip"],"v8":"","uv":"","zlib":null,"openssl":null,"modules":null,"lts":false,"security":false},
|
||||||
|
{"version":"v17.0.0-rc.0","date":"2021-09-21","files":["aix-ppc64","headers","linux-arm64","linux-armv7l","linux-ppc64le","linux-s390x","linux-x64","osx-arm64-tar","osx-x64-pkg","osx-x64-tar","src","win-x64-7z","win-x64-exe","win-x64-msi","win-x64-zip","win-x86-7z","win-x86-exe","win-x86-msi","win-x86-zip"],"v8":"","uv":"","zlib":null,"openssl":null,"modules":null,"lts":false,"security":false},
|
||||||
|
{"version":"v16.17.0-rc.1","date":"2022-08-06","files":["aix-ppc64","headers","linux-arm64","linux-armv7l","linux-ppc64le","linux-s390x","linux-x64","osx-arm64-tar","osx-x64-pkg","osx-x64-tar","src","win-x64-7z","win-x64-exe","win-x64-msi","win-x64-zip","win-x86-7z","win-x86-exe","win-x86-msi","win-x86-zip"],"v8":"","uv":"","zlib":null,"openssl":null,"modules":null,"lts":false,"security":false},
|
||||||
|
{"version":"v16.0.0-rc.2","date":"2021-04-07","files":["headers","linux-arm64","linux-ppc64le","linux-x64","osx-x64-pkg","osx-x64-tar","src"],"v8":"","uv":"","zlib":null,"openssl":null,"modules":null,"lts":false,"security":false},
|
||||||
|
{"version":"v16.0.0-rc.1","date":"2021-03-30","files":["aix-ppc64","headers","linux-arm64","linux-armv7l","linux-ppc64le","linux-s390x","linux-x64","osx-x64-pkg","osx-x64-tar","src","win-x64-7z","win-x64-exe","win-x64-msi","win-x64-zip","win-x86-7z","win-x86-exe","win-x86-msi","win-x86-zip"],"v8":"","uv":"","zlib":null,"openssl":null,"modules":null,"lts":false,"security":false},
|
||||||
|
{"version":"v16.0.0-rc.0","date":"2021-03-19","files":["aix-ppc64","headers","linux-arm64","linux-armv7l","linux-ppc64le","linux-s390x","linux-x64","osx-x64-pkg","osx-x64-tar","src","win-x64-7z","win-x64-exe","win-x64-msi","win-x64-zip","win-x86-7z","win-x86-exe","win-x86-msi","win-x86-zip"],"v8":"","uv":"","zlib":null,"openssl":null,"modules":null,"lts":false,"security":false},
|
||||||
|
{"version":"v14.19.0-rc.0","date":"2022-01-25","files":["aix-ppc64","headers","linux-arm64","linux-armv7l","linux-ppc64le","linux-s390x","linux-x64","osx-x64-pkg","osx-x64-tar","src","win-x64-7z","win-x64-exe","win-x64-msi","win-x64-zip","win-x86-7z","win-x86-exe","win-x86-msi","win-x86-zip"],"v8":"","uv":"","zlib":null,"openssl":null,"modules":null,"lts":false,"security":false},
|
||||||
|
{"version":"v14.18.0-rc.0","date":"2021-09-08","files":["aix-ppc64","headers","linux-arm64","linux-armv7l","linux-ppc64le","linux-s390x","linux-x64","osx-x64-pkg","osx-x64-tar","src","win-x64-7z","win-x64-exe","win-x64-msi","win-x64-zip","win-x86-7z","win-x86-exe","win-x86-msi","win-x86-zip"],"v8":"","uv":"","zlib":null,"openssl":null,"modules":null,"lts":false,"security":false},
|
||||||
|
{"version":"v14.17.4-rc.0","date":"2021-07-20","files":["aix-ppc64","headers","linux-arm64","linux-armv7l","linux-ppc64le","linux-s390x","linux-x64","osx-x64-pkg","osx-x64-tar","src","win-x64-7z","win-x64-exe","win-x64-msi","win-x64-zip","win-x86-7z","win-x86-exe","win-x86-msi","win-x86-zip"],"v8":"","uv":"","zlib":null,"openssl":null,"modules":null,"lts":false,"security":false},
|
||||||
|
{"version":"v14.17.1-rc.0","date":"2021-06-11","files":["aix-ppc64","headers","linux-arm64","linux-armv7l","linux-ppc64le","linux-s390x","linux-x64","osx-x64-pkg","osx-x64-tar","src","win-x64-7z","win-x64-exe","win-x64-msi","win-x64-zip","win-x86-7z","win-x86-exe","win-x86-msi","win-x86-zip"],"v8":"","uv":"","zlib":null,"openssl":null,"modules":null,"lts":false,"security":false},
|
||||||
|
{"version":"v14.16.0-rc.0","date":"2021-02-22","files":["aix-ppc64","headers","linux-arm64","linux-armv7l","linux-ppc64le","linux-s390x","linux-x64","osx-x64-pkg","osx-x64-tar","src","win-x64-7z","win-x64-exe","win-x64-msi","win-x64-zip","win-x86-7z","win-x86-exe","win-x86-msi","win-x86-zip"],"v8":"","uv":"","zlib":null,"openssl":null,"modules":null,"lts":false,"security":false},
|
||||||
|
{"version":"v14.15.5-rc.1","date":"2021-02-08","files":["aix-ppc64","headers","linux-arm64","linux-armv7l","linux-ppc64le","linux-s390x","linux-x64","osx-x64-pkg","osx-x64-tar","src","win-x64-7z","win-x64-exe","win-x64-msi","win-x64-zip","win-x86-7z","win-x86-exe","win-x86-msi","win-x86-zip"],"v8":"","uv":"","zlib":null,"openssl":null,"modules":null,"lts":false,"security":false},
|
||||||
|
{"version":"v14.15.5-rc.0","date":"2021-01-27","files":["headers","linux-arm64","linux-armv7l","linux-ppc64le","linux-s390x","linux-x64","osx-x64-pkg","osx-x64-tar","src","win-x64-7z","win-x64-exe","win-x64-msi","win-x64-zip","win-x86-7z","win-x86-exe","win-x86-msi","win-x86-zip"],"v8":"","uv":"","zlib":null,"openssl":null,"modules":null,"lts":false,"security":false},
|
||||||
|
{"version":"v14.15.2-rc.0","date":"2020-12-14","files":["headers","linux-arm64","linux-armv7l","linux-ppc64le","linux-s390x","linux-x64","osx-x64-tar","src","win-x64-7z","win-x64-exe","win-x64-msi","win-x64-zip","win-x86-7z","win-x86-exe","win-x86-msi","win-x86-zip"],"v8":"","uv":"","zlib":null,"openssl":null,"modules":null,"lts":false,"security":false},
|
||||||
|
{"version":"v14.7.0-rc.1","date":"2020-07-29","files":["aix-ppc64","headers","linux-arm64","linux-armv7l","linux-ppc64le","linux-s390x","linux-x64","osx-x64-pkg","osx-x64-tar","src","win-x64-7z","win-x64-exe","win-x64-msi","win-x64-zip","win-x86-7z","win-x86-exe","win-x86-msi","win-x86-zip"],"v8":"","uv":"","zlib":null,"openssl":null,"modules":null,"lts":false,"security":false},
|
||||||
|
{"version":"v13.11.0-rc.1","date":"2020-03-11","files":["headers","linux-arm64","linux-armv7l","linux-ppc64le","linux-x64","osx-x64-pkg","osx-x64-tar","src","sunos-x64","win-x64-7z","win-x64-exe","win-x64-msi","win-x64-zip","win-x86-7z","win-x86-exe","win-x86-msi","win-x86-zip"],"v8":"","uv":"","zlib":null,"openssl":null,"modules":null,"lts":false,"security":false},
|
||||||
|
{"version":"v13.11.0-rc.0","date":"2020-03-10","files":["headers","linux-arm64","linux-armv7l","linux-ppc64le","linux-x64","osx-x64-pkg","src","sunos-x64","win-x64-7z","win-x64-exe","win-x64-msi","win-x64-zip"],"v8":"","uv":"","zlib":null,"openssl":null,"modules":null,"lts":false,"security":false},
|
||||||
|
{"version":"v13.10.1-rc.0","date":"2020-03-04","files":["aix-ppc64","headers","linux-arm64","linux-armv7l","linux-ppc64le","linux-s390x","linux-x64","osx-x64-pkg","osx-x64-tar","src","sunos-x64","win-x64-7z","win-x64-exe","win-x64-msi","win-x64-zip"],"v8":"","uv":"","zlib":null,"openssl":null,"modules":null,"lts":false,"security":false},
|
||||||
|
{"version":"v13.4.0-rc.0","date":"2019-12-13","files":["aix-ppc64","headers","linux-arm64","linux-armv7l","linux-ppc64le","linux-s390x","linux-x64","osx-x64-pkg","osx-x64-tar","src","sunos-x64","win-x64-7z","win-x64-exe","win-x64-msi","win-x64-zip","win-x86-7z","win-x86-exe","win-x86-msi","win-x86-zip"],"v8":"","uv":"","zlib":null,"openssl":null,"modules":null,"lts":false,"security":false},
|
||||||
|
{"version":"v13.0.1-rc.0","date":"2019-10-23","files":["aix-ppc64","headers","linux-arm64","linux-armv7l","linux-ppc64le","linux-s390x","linux-x64","osx-x64-pkg","osx-x64-tar","src","sunos-x64","win-x64-7z","win-x64-exe","win-x64-msi","win-x64-zip","win-x86-7z","win-x86-exe","win-x86-msi","win-x86-zip"],"v8":"","uv":"","zlib":null,"openssl":null,"modules":null,"lts":false,"security":false},
|
||||||
|
{"version":"v13.0.0-rc.3","date":"2019-10-21","files":["aix-ppc64","headers","linux-arm64","linux-armv7l","linux-ppc64le","linux-s390x","linux-x64","osx-x64-pkg","osx-x64-tar","src","sunos-x64","win-x64-7z","win-x64-exe","win-x64-msi","win-x64-zip","win-x86-7z","win-x86-exe","win-x86-msi","win-x86-zip"],"v8":"","uv":"","zlib":null,"openssl":null,"modules":null,"lts":false,"security":false},
|
||||||
|
{"version":"v13.0.0-rc.2","date":"2019-10-15","files":["headers","linux-arm64","linux-armv7l","linux-ppc64le","linux-s390x","linux-x64","osx-x64-pkg","osx-x64-tar","src","sunos-x64","win-x64-7z","win-x64-exe","win-x64-msi","win-x64-zip","win-x86-7z","win-x86-exe","win-x86-msi","win-x86-zip"],"v8":"","uv":"","zlib":null,"openssl":null,"modules":null,"lts":false,"security":false},
|
||||||
|
{"version":"v13.0.0-rc.1","date":"2019-10-01","files":["aix-ppc64","headers","linux-arm64","linux-armv7l","linux-ppc64le","linux-s390x","linux-x64","osx-x64-pkg","osx-x64-tar","src","sunos-x64","win-x64-7z","win-x64-exe","win-x64-msi","win-x64-zip","win-x86-7z","win-x86-exe","win-x86-msi","win-x86-zip"],"v8":"","uv":"","zlib":null,"openssl":null,"modules":null,"lts":false,"security":false},
|
||||||
|
{"version":"v13.0.0-rc.0","date":"2019-09-25","files":["aix-ppc64","headers","linux-arm64","linux-armv7l","linux-ppc64le","linux-s390x","linux-x64","osx-x64-pkg","osx-x64-tar","src","sunos-x64","win-x64-7z","win-x64-exe","win-x64-msi","win-x64-zip","win-x86-7z","win-x86-exe","win-x86-msi","win-x86-zip"],"v8":"","uv":"","zlib":null,"openssl":null,"modules":null,"lts":false,"security":false}
|
||||||
|
]
|
||||||
|
|
@ -0,0 +1,109 @@
|
||||||
|
{
|
||||||
|
"name": "npm-fixture",
|
||||||
|
"lockfileVersion": 3,
|
||||||
|
"requires": true,
|
||||||
|
"packages": {
|
||||||
|
"": {
|
||||||
|
"name": "npm-fixture",
|
||||||
|
"dependencies": {
|
||||||
|
"accepts": "^1.3.8",
|
||||||
|
"array-flatten": "^3.0.0",
|
||||||
|
"bytes": "^3.1.2",
|
||||||
|
"content-disposition": "^0.5.4"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^24.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/accepts": {
|
||||||
|
"version": "1.3.8",
|
||||||
|
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz",
|
||||||
|
"integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"mime-types": "~2.1.34",
|
||||||
|
"negotiator": "0.6.3"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 0.6"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/accepts/node_modules/mime-db": {
|
||||||
|
"version": "1.52.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
|
||||||
|
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 0.6"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/accepts/node_modules/mime-types": {
|
||||||
|
"version": "2.1.35",
|
||||||
|
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
|
||||||
|
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"mime-db": "1.52.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 0.6"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/array-flatten": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-3.0.0.tgz",
|
||||||
|
"integrity": "sha512-zPMVc3ZYlGLNk4mpK1NzP2wg0ml9t7fUgDsayR5Y5rSzxQilzR9FGu/EH2jQOcKSAeAfWeylyW8juy3OkWRvNA==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/bytes": {
|
||||||
|
"version": "3.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
|
||||||
|
"integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 0.8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/content-disposition": {
|
||||||
|
"version": "0.5.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz",
|
||||||
|
"integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"safe-buffer": "5.2.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 0.6"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/negotiator": {
|
||||||
|
"version": "0.6.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz",
|
||||||
|
"integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 0.6"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/safe-buffer": {
|
||||||
|
"version": "5.2.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
|
||||||
|
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/feross"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "patreon",
|
||||||
|
"url": "https://www.patreon.com/feross"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "consulting",
|
||||||
|
"url": "https://feross.org/support"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"license": "MIT"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"name": "npm-fixture",
|
||||||
|
"engines": {
|
||||||
|
"node": "^24.0.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"accepts": "^1.3.8",
|
||||||
|
"array-flatten": "^3.0.0",
|
||||||
|
"bytes": "^3.1.2",
|
||||||
|
"content-disposition": "^0.5.4"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"engines": {
|
||||||
|
"node": "^19"
|
||||||
|
},
|
||||||
|
"devEngines": {
|
||||||
|
"runtime": {
|
||||||
|
"name": "node",
|
||||||
|
"version": "^20"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"volta": {
|
||||||
|
"extends": "./package-volta.json"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"engines": {
|
||||||
|
"node": "^14.0.0"
|
||||||
|
},
|
||||||
|
"volta": {
|
||||||
|
"node": "24.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"engines": {
|
||||||
|
"node": "^24.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"name": "pnpm-fixture",
|
||||||
|
"engines": {
|
||||||
|
"node": "^24.0.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"accepts": "^1.3.8",
|
||||||
|
"array-flatten": "^3.0.0",
|
||||||
|
"bytes": "^3.1.2",
|
||||||
|
"content-disposition": "^0.5.4"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,100 @@
|
||||||
|
lockfileVersion: '9.0'
|
||||||
|
|
||||||
|
settings:
|
||||||
|
autoInstallPeers: true
|
||||||
|
excludeLinksFromLockfile: false
|
||||||
|
|
||||||
|
importers:
|
||||||
|
.:
|
||||||
|
dependencies:
|
||||||
|
accepts:
|
||||||
|
specifier: ^1.3.8
|
||||||
|
version: 1.3.8
|
||||||
|
array-flatten:
|
||||||
|
specifier: ^3.0.0
|
||||||
|
version: 3.0.0
|
||||||
|
bytes:
|
||||||
|
specifier: ^3.1.2
|
||||||
|
version: 3.1.2
|
||||||
|
content-disposition:
|
||||||
|
specifier: ^0.5.4
|
||||||
|
version: 0.5.4
|
||||||
|
|
||||||
|
packages:
|
||||||
|
accepts@1.3.8:
|
||||||
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==
|
||||||
|
}
|
||||||
|
engines: {node: '>= 0.6'}
|
||||||
|
|
||||||
|
array-flatten@3.0.0:
|
||||||
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-zPMVc3ZYlGLNk4mpK1NzP2wg0ml9t7fUgDsayR5Y5rSzxQilzR9FGu/EH2jQOcKSAeAfWeylyW8juy3OkWRvNA==
|
||||||
|
}
|
||||||
|
|
||||||
|
bytes@3.1.2:
|
||||||
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==
|
||||||
|
}
|
||||||
|
engines: {node: '>= 0.8'}
|
||||||
|
|
||||||
|
content-disposition@0.5.4:
|
||||||
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==
|
||||||
|
}
|
||||||
|
engines: {node: '>= 0.6'}
|
||||||
|
|
||||||
|
mime-db@1.52.0:
|
||||||
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==
|
||||||
|
}
|
||||||
|
engines: {node: '>= 0.6'}
|
||||||
|
|
||||||
|
mime-types@2.1.35:
|
||||||
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==
|
||||||
|
}
|
||||||
|
engines: {node: '>= 0.6'}
|
||||||
|
|
||||||
|
negotiator@0.6.3:
|
||||||
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==
|
||||||
|
}
|
||||||
|
engines: {node: '>= 0.6'}
|
||||||
|
|
||||||
|
safe-buffer@5.2.1:
|
||||||
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==
|
||||||
|
}
|
||||||
|
|
||||||
|
snapshots:
|
||||||
|
accepts@1.3.8:
|
||||||
|
dependencies:
|
||||||
|
mime-types: 2.1.35
|
||||||
|
negotiator: 0.6.3
|
||||||
|
|
||||||
|
array-flatten@3.0.0: {}
|
||||||
|
|
||||||
|
bytes@3.1.2: {}
|
||||||
|
|
||||||
|
content-disposition@0.5.4:
|
||||||
|
dependencies:
|
||||||
|
safe-buffer: 5.2.1
|
||||||
|
|
||||||
|
mime-db@1.52.0: {}
|
||||||
|
|
||||||
|
mime-types@2.1.35:
|
||||||
|
dependencies:
|
||||||
|
mime-db: 1.52.0
|
||||||
|
|
||||||
|
negotiator@0.6.3: {}
|
||||||
|
|
||||||
|
safe-buffer@5.2.1: {}
|
||||||
|
|
@ -0,0 +1,537 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"version": "v20.0.0-v8-canary20221103f7e2421e91",
|
||||||
|
"date": "2022-11-03",
|
||||||
|
"files": [
|
||||||
|
"headers",
|
||||||
|
"linux-arm64",
|
||||||
|
"linux-armv7l",
|
||||||
|
"linux-ppc64le",
|
||||||
|
"linux-s390x",
|
||||||
|
"linux-x64",
|
||||||
|
"osx-arm64-tar",
|
||||||
|
"osx-x64-pkg",
|
||||||
|
"osx-x64-tar",
|
||||||
|
"src",
|
||||||
|
"win-x64-7z",
|
||||||
|
"win-x64-exe",
|
||||||
|
"win-x64-msi",
|
||||||
|
"win-x64-zip",
|
||||||
|
"win-x86-7z",
|
||||||
|
"win-x86-exe",
|
||||||
|
"win-x86-msi",
|
||||||
|
"win-x86-zip"
|
||||||
|
],
|
||||||
|
"npm": "8.19.2",
|
||||||
|
"v8": "10.9.138.0",
|
||||||
|
"uv": "1.43.0",
|
||||||
|
"zlib": "1.2.11",
|
||||||
|
"openssl": "3.0.5+quic",
|
||||||
|
"modules": "112",
|
||||||
|
"lts": false,
|
||||||
|
"security": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "v20.0.0-v8-canary202211026bf85d0fb4",
|
||||||
|
"date": "2022-11-02",
|
||||||
|
"files": [
|
||||||
|
"headers",
|
||||||
|
"linux-arm64",
|
||||||
|
"linux-armv7l",
|
||||||
|
"linux-ppc64le",
|
||||||
|
"linux-s390x",
|
||||||
|
"linux-x64",
|
||||||
|
"osx-arm64-tar",
|
||||||
|
"osx-x64-pkg",
|
||||||
|
"osx-x64-tar",
|
||||||
|
"src",
|
||||||
|
"win-x64-7z",
|
||||||
|
"win-x64-exe",
|
||||||
|
"win-x64-msi",
|
||||||
|
"win-x64-zip",
|
||||||
|
"win-x86-7z",
|
||||||
|
"win-x86-exe",
|
||||||
|
"win-x86-msi",
|
||||||
|
"win-x86-zip"
|
||||||
|
],
|
||||||
|
"npm": "8.19.2",
|
||||||
|
"v8": "10.9.130.0",
|
||||||
|
"uv": "1.43.0",
|
||||||
|
"zlib": "1.2.11",
|
||||||
|
"openssl": "3.0.5+quic",
|
||||||
|
"modules": "112",
|
||||||
|
"lts": false,
|
||||||
|
"security": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "v20.0.0-v8-canary20221101e50e45c9f8",
|
||||||
|
"date": "2022-11-01",
|
||||||
|
"files": [
|
||||||
|
"headers",
|
||||||
|
"linux-arm64",
|
||||||
|
"linux-armv7l",
|
||||||
|
"linux-ppc64le",
|
||||||
|
"linux-s390x",
|
||||||
|
"linux-x64",
|
||||||
|
"osx-arm64-tar",
|
||||||
|
"osx-x64-tar",
|
||||||
|
"src",
|
||||||
|
"win-x64-7z",
|
||||||
|
"win-x64-exe",
|
||||||
|
"win-x64-msi",
|
||||||
|
"win-x64-zip",
|
||||||
|
"win-x86-7z",
|
||||||
|
"win-x86-exe",
|
||||||
|
"win-x86-msi",
|
||||||
|
"win-x86-zip"
|
||||||
|
],
|
||||||
|
"npm": "8.19.2",
|
||||||
|
"v8": "10.9.129.0",
|
||||||
|
"uv": "1.43.0",
|
||||||
|
"zlib": "1.2.11",
|
||||||
|
"openssl": "3.0.5+quic",
|
||||||
|
"modules": "112",
|
||||||
|
"lts": false,
|
||||||
|
"security": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "v20.0.0-v8-canary202210311b1e675ad0",
|
||||||
|
"date": "2022-10-31",
|
||||||
|
"files": [
|
||||||
|
"headers",
|
||||||
|
"linux-arm64",
|
||||||
|
"linux-armv7l",
|
||||||
|
"linux-ppc64le",
|
||||||
|
"linux-s390x",
|
||||||
|
"linux-x64",
|
||||||
|
"osx-arm64-tar",
|
||||||
|
"osx-x64-tar",
|
||||||
|
"src",
|
||||||
|
"win-x64-7z",
|
||||||
|
"win-x64-exe",
|
||||||
|
"win-x64-msi",
|
||||||
|
"win-x64-zip",
|
||||||
|
"win-x86-7z",
|
||||||
|
"win-x86-exe",
|
||||||
|
"win-x86-msi",
|
||||||
|
"win-x86-zip"
|
||||||
|
],
|
||||||
|
"npm": "8.19.2",
|
||||||
|
"v8": "10.9.125.0",
|
||||||
|
"uv": "1.43.0",
|
||||||
|
"zlib": "1.2.11",
|
||||||
|
"openssl": "3.0.5+quic",
|
||||||
|
"modules": "112",
|
||||||
|
"lts": false,
|
||||||
|
"security": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "v20.0.0-v8-canary20221030fefe1c0879",
|
||||||
|
"date": "2022-10-30",
|
||||||
|
"files": [
|
||||||
|
"headers",
|
||||||
|
"linux-arm64",
|
||||||
|
"linux-armv7l",
|
||||||
|
"linux-ppc64le",
|
||||||
|
"linux-s390x",
|
||||||
|
"linux-x64",
|
||||||
|
"osx-arm64-tar",
|
||||||
|
"osx-x64-pkg",
|
||||||
|
"osx-x64-tar",
|
||||||
|
"src",
|
||||||
|
"win-x64-7z",
|
||||||
|
"win-x64-exe",
|
||||||
|
"win-x64-msi",
|
||||||
|
"win-x64-zip",
|
||||||
|
"win-x86-7z",
|
||||||
|
"win-x86-exe",
|
||||||
|
"win-x86-msi",
|
||||||
|
"win-x86-zip"
|
||||||
|
],
|
||||||
|
"npm": "8.19.2",
|
||||||
|
"v8": "10.9.125.0",
|
||||||
|
"uv": "1.43.0",
|
||||||
|
"zlib": "1.2.11",
|
||||||
|
"openssl": "3.0.5+quic",
|
||||||
|
"modules": "112",
|
||||||
|
"lts": false,
|
||||||
|
"security": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "v20.0.0-v8-canary202210293881e51ba2",
|
||||||
|
"date": "2022-10-29",
|
||||||
|
"files": [
|
||||||
|
"headers",
|
||||||
|
"linux-arm64",
|
||||||
|
"linux-armv7l",
|
||||||
|
"linux-ppc64le",
|
||||||
|
"linux-s390x",
|
||||||
|
"linux-x64",
|
||||||
|
"osx-arm64-tar",
|
||||||
|
"osx-x64-pkg",
|
||||||
|
"osx-x64-tar",
|
||||||
|
"src",
|
||||||
|
"win-x64-7z",
|
||||||
|
"win-x64-exe",
|
||||||
|
"win-x64-msi",
|
||||||
|
"win-x64-zip",
|
||||||
|
"win-x86-7z",
|
||||||
|
"win-x86-exe",
|
||||||
|
"win-x86-msi",
|
||||||
|
"win-x86-zip"
|
||||||
|
],
|
||||||
|
"npm": "8.19.2",
|
||||||
|
"v8": "10.9.122.0",
|
||||||
|
"uv": "1.43.0",
|
||||||
|
"zlib": "1.2.11",
|
||||||
|
"openssl": "3.0.5+quic",
|
||||||
|
"modules": "112",
|
||||||
|
"lts": false,
|
||||||
|
"security": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "v20.0.0-v8-canary202210286fe49d2a49",
|
||||||
|
"date": "2022-10-28",
|
||||||
|
"files": [
|
||||||
|
"osx-arm64-tar",
|
||||||
|
"osx-x64-pkg",
|
||||||
|
"osx-x64-tar",
|
||||||
|
"win-x64-7z",
|
||||||
|
"win-x64-exe",
|
||||||
|
"win-x64-msi",
|
||||||
|
"win-x64-zip",
|
||||||
|
"win-x86-7z",
|
||||||
|
"win-x86-exe",
|
||||||
|
"win-x86-msi",
|
||||||
|
"win-x86-zip"
|
||||||
|
],
|
||||||
|
"npm": "8.19.2",
|
||||||
|
"v8": "10.9.112.0",
|
||||||
|
"uv": "1.43.0",
|
||||||
|
"zlib": "1.2.11",
|
||||||
|
"openssl": "3.0.5+quic",
|
||||||
|
"modules": "112",
|
||||||
|
"lts": false,
|
||||||
|
"security": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "v20.0.0-v8-canary20221027c470b3108c",
|
||||||
|
"date": "2022-10-27",
|
||||||
|
"files": [
|
||||||
|
"headers",
|
||||||
|
"linux-arm64",
|
||||||
|
"linux-armv7l",
|
||||||
|
"linux-ppc64le",
|
||||||
|
"linux-s390x",
|
||||||
|
"linux-x64",
|
||||||
|
"osx-arm64-tar",
|
||||||
|
"osx-x64-pkg",
|
||||||
|
"osx-x64-tar",
|
||||||
|
"src",
|
||||||
|
"win-x64-7z",
|
||||||
|
"win-x64-exe",
|
||||||
|
"win-x64-msi",
|
||||||
|
"win-x64-zip",
|
||||||
|
"win-x86-7z",
|
||||||
|
"win-x86-exe",
|
||||||
|
"win-x86-msi",
|
||||||
|
"win-x86-zip"
|
||||||
|
],
|
||||||
|
"npm": "8.19.2",
|
||||||
|
"v8": "10.9.101.0",
|
||||||
|
"uv": "1.43.0",
|
||||||
|
"zlib": "1.2.11",
|
||||||
|
"openssl": "3.0.5+quic",
|
||||||
|
"modules": "112",
|
||||||
|
"lts": false,
|
||||||
|
"security": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "v20.0.0-v8-canary20221026c24f7d1e4a",
|
||||||
|
"date": "2022-10-26",
|
||||||
|
"files": [
|
||||||
|
"headers",
|
||||||
|
"linux-arm64",
|
||||||
|
"linux-armv7l",
|
||||||
|
"linux-ppc64le",
|
||||||
|
"linux-s390x",
|
||||||
|
"linux-x64",
|
||||||
|
"osx-arm64-tar",
|
||||||
|
"osx-x64-pkg",
|
||||||
|
"osx-x64-tar",
|
||||||
|
"src",
|
||||||
|
"win-x64-7z",
|
||||||
|
"win-x64-exe",
|
||||||
|
"win-x64-msi",
|
||||||
|
"win-x64-zip",
|
||||||
|
"win-x86-7z",
|
||||||
|
"win-x86-exe",
|
||||||
|
"win-x86-msi",
|
||||||
|
"win-x86-zip"
|
||||||
|
],
|
||||||
|
"npm": "8.19.2",
|
||||||
|
"v8": "10.9.88.0",
|
||||||
|
"uv": "1.43.0",
|
||||||
|
"zlib": "1.2.11",
|
||||||
|
"openssl": "3.0.5+quic",
|
||||||
|
"modules": "112",
|
||||||
|
"lts": false,
|
||||||
|
"security": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "v20.0.0-v8-canary20221025b063237e20",
|
||||||
|
"date": "2022-10-25",
|
||||||
|
"files": [
|
||||||
|
"headers",
|
||||||
|
"linux-arm64",
|
||||||
|
"linux-armv7l",
|
||||||
|
"linux-ppc64le",
|
||||||
|
"linux-x64",
|
||||||
|
"osx-arm64-tar",
|
||||||
|
"osx-x64-pkg",
|
||||||
|
"osx-x64-tar",
|
||||||
|
"src",
|
||||||
|
"win-x64-7z",
|
||||||
|
"win-x64-exe",
|
||||||
|
"win-x64-msi",
|
||||||
|
"win-x64-zip",
|
||||||
|
"win-x86-7z",
|
||||||
|
"win-x86-exe",
|
||||||
|
"win-x86-msi",
|
||||||
|
"win-x86-zip"
|
||||||
|
],
|
||||||
|
"npm": "8.19.2",
|
||||||
|
"v8": "10.9.73.0",
|
||||||
|
"uv": "1.43.0",
|
||||||
|
"zlib": "1.2.11",
|
||||||
|
"openssl": "3.0.5+quic",
|
||||||
|
"modules": "112",
|
||||||
|
"lts": false,
|
||||||
|
"security": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "v20.0.0-v8-canary2022102454996f930f",
|
||||||
|
"date": "2022-10-24",
|
||||||
|
"files": [
|
||||||
|
"headers",
|
||||||
|
"linux-arm64",
|
||||||
|
"linux-armv7l",
|
||||||
|
"linux-ppc64le",
|
||||||
|
"linux-x64",
|
||||||
|
"osx-arm64-tar",
|
||||||
|
"osx-x64-pkg",
|
||||||
|
"osx-x64-tar",
|
||||||
|
"src",
|
||||||
|
"win-x64-7z",
|
||||||
|
"win-x64-exe",
|
||||||
|
"win-x64-msi",
|
||||||
|
"win-x64-zip",
|
||||||
|
"win-x86-7z",
|
||||||
|
"win-x86-exe",
|
||||||
|
"win-x86-msi",
|
||||||
|
"win-x86-zip"
|
||||||
|
],
|
||||||
|
"npm": "8.19.2",
|
||||||
|
"v8": "10.9.61.0",
|
||||||
|
"uv": "1.43.0",
|
||||||
|
"zlib": "1.2.11",
|
||||||
|
"openssl": "3.0.5+quic",
|
||||||
|
"modules": "112",
|
||||||
|
"lts": false,
|
||||||
|
"security": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "v20.0.0-v8-canary2022102310ff1e5a8d",
|
||||||
|
"date": "2022-10-23",
|
||||||
|
"files": [
|
||||||
|
"headers",
|
||||||
|
"linux-arm64",
|
||||||
|
"linux-armv7l",
|
||||||
|
"linux-ppc64le",
|
||||||
|
"linux-x64",
|
||||||
|
"osx-arm64-tar",
|
||||||
|
"osx-x64-tar",
|
||||||
|
"src",
|
||||||
|
"win-x64-7z",
|
||||||
|
"win-x64-exe",
|
||||||
|
"win-x64-msi",
|
||||||
|
"win-x64-zip",
|
||||||
|
"win-x86-7z",
|
||||||
|
"win-x86-exe",
|
||||||
|
"win-x86-msi",
|
||||||
|
"win-x86-zip"
|
||||||
|
],
|
||||||
|
"npm": "8.19.2",
|
||||||
|
"v8": "10.9.61.0",
|
||||||
|
"uv": "1.43.0",
|
||||||
|
"zlib": "1.2.11",
|
||||||
|
"openssl": "3.0.5+quic",
|
||||||
|
"modules": "112",
|
||||||
|
"lts": false,
|
||||||
|
"security": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "v20.0.0-v8-canary20221022e83bcb6c41",
|
||||||
|
"date": "2022-10-22",
|
||||||
|
"files": [
|
||||||
|
"headers",
|
||||||
|
"linux-arm64",
|
||||||
|
"linux-armv7l",
|
||||||
|
"linux-x64",
|
||||||
|
"osx-arm64-tar",
|
||||||
|
"osx-x64-tar",
|
||||||
|
"src",
|
||||||
|
"win-x64-7z",
|
||||||
|
"win-x64-exe",
|
||||||
|
"win-x64-msi",
|
||||||
|
"win-x64-zip",
|
||||||
|
"win-x86-7z",
|
||||||
|
"win-x86-exe",
|
||||||
|
"win-x86-msi",
|
||||||
|
"win-x86-zip"
|
||||||
|
],
|
||||||
|
"npm": "8.19.2",
|
||||||
|
"v8": "10.9.60.0",
|
||||||
|
"uv": "1.43.0",
|
||||||
|
"zlib": "1.2.11",
|
||||||
|
"openssl": "3.0.5+quic",
|
||||||
|
"modules": "112",
|
||||||
|
"lts": false,
|
||||||
|
"security": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "v20.0.0-v8-canary20221021f6d5f347fa",
|
||||||
|
"date": "2022-10-21",
|
||||||
|
"files": [
|
||||||
|
"headers",
|
||||||
|
"linux-arm64",
|
||||||
|
"linux-armv7l",
|
||||||
|
"linux-x64",
|
||||||
|
"osx-arm64-tar",
|
||||||
|
"osx-x64-tar",
|
||||||
|
"src",
|
||||||
|
"win-x64-7z",
|
||||||
|
"win-x64-exe",
|
||||||
|
"win-x64-msi",
|
||||||
|
"win-x64-zip"
|
||||||
|
],
|
||||||
|
"npm": "8.19.2",
|
||||||
|
"v8": "10.9.48.0",
|
||||||
|
"uv": "1.43.0",
|
||||||
|
"zlib": "1.2.11",
|
||||||
|
"openssl": "3.0.5+quic",
|
||||||
|
"modules": "112",
|
||||||
|
"lts": false,
|
||||||
|
"security": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "v20.0.0-v8-canary20221020f78c149307",
|
||||||
|
"date": "2022-10-20",
|
||||||
|
"files": [
|
||||||
|
"headers",
|
||||||
|
"linux-arm64",
|
||||||
|
"linux-armv7l",
|
||||||
|
"linux-x64",
|
||||||
|
"osx-arm64-tar",
|
||||||
|
"osx-x64-pkg",
|
||||||
|
"osx-x64-tar",
|
||||||
|
"src",
|
||||||
|
"win-x64-7z",
|
||||||
|
"win-x64-exe",
|
||||||
|
"win-x64-msi",
|
||||||
|
"win-x64-zip"
|
||||||
|
],
|
||||||
|
"npm": "8.19.2",
|
||||||
|
"v8": "10.9.38.0",
|
||||||
|
"uv": "1.43.0",
|
||||||
|
"zlib": "1.2.11",
|
||||||
|
"openssl": "3.0.5+quic",
|
||||||
|
"modules": "112",
|
||||||
|
"lts": false,
|
||||||
|
"security": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "v20.0.0-v8-canary20221019d52c76f76e",
|
||||||
|
"date": "2022-10-19",
|
||||||
|
"files": [
|
||||||
|
"aix-ppc64",
|
||||||
|
"headers",
|
||||||
|
"linux-arm64",
|
||||||
|
"linux-armv7l",
|
||||||
|
"linux-ppc64le",
|
||||||
|
"linux-x64",
|
||||||
|
"osx-arm64-tar",
|
||||||
|
"osx-x64-pkg",
|
||||||
|
"osx-x64-tar",
|
||||||
|
"src",
|
||||||
|
"win-x64-7z",
|
||||||
|
"win-x64-exe",
|
||||||
|
"win-x64-msi",
|
||||||
|
"win-x64-zip"
|
||||||
|
],
|
||||||
|
"npm": "8.19.2",
|
||||||
|
"v8": "10.9.27.0",
|
||||||
|
"uv": "1.43.0",
|
||||||
|
"zlib": "1.2.11",
|
||||||
|
"openssl": "3.0.5+quic",
|
||||||
|
"modules": "112",
|
||||||
|
"lts": false,
|
||||||
|
"security": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "v19.0.0-v8-canary202210187d6960f23f",
|
||||||
|
"date": "2022-10-18",
|
||||||
|
"files": [
|
||||||
|
"aix-ppc64",
|
||||||
|
"headers",
|
||||||
|
"linux-arm64",
|
||||||
|
"linux-armv7l",
|
||||||
|
"linux-ppc64le",
|
||||||
|
"linux-s390x",
|
||||||
|
"linux-x64",
|
||||||
|
"osx-arm64-tar",
|
||||||
|
"osx-x64-tar",
|
||||||
|
"src",
|
||||||
|
"win-x64-7z",
|
||||||
|
"win-x64-exe",
|
||||||
|
"win-x64-msi",
|
||||||
|
"win-x64-zip"
|
||||||
|
],
|
||||||
|
"npm": "8.19.2",
|
||||||
|
"v8": "10.9.12.0",
|
||||||
|
"uv": "1.43.0",
|
||||||
|
"zlib": "1.2.11",
|
||||||
|
"openssl": "3.0.5+quic",
|
||||||
|
"modules": "112",
|
||||||
|
"lts": false,
|
||||||
|
"security": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "v19.0.0-v8-canary202210172ec229fc56",
|
||||||
|
"date": "2022-10-17",
|
||||||
|
"files": [
|
||||||
|
"aix-ppc64",
|
||||||
|
"headers",
|
||||||
|
"linux-arm64",
|
||||||
|
"linux-armv7l",
|
||||||
|
"linux-ppc64le",
|
||||||
|
"linux-s390x",
|
||||||
|
"linux-x64",
|
||||||
|
"osx-arm64-tar",
|
||||||
|
"osx-x64-tar",
|
||||||
|
"src",
|
||||||
|
"win-x64-7z",
|
||||||
|
"win-x64-exe",
|
||||||
|
"win-x64-msi",
|
||||||
|
"win-x64-zip"
|
||||||
|
],
|
||||||
|
"npm": "8.19.2",
|
||||||
|
"v8": "10.9.6.0",
|
||||||
|
"uv": "1.43.0",
|
||||||
|
"zlib": "1.2.11",
|
||||||
|
"openssl": "3.0.5+quic",
|
||||||
|
"modules": "112",
|
||||||
|
"lts": false,
|
||||||
|
"security": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
@ -0,0 +1,183 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"version": "14.0.0",
|
||||||
|
"stable": true,
|
||||||
|
"lts": "Fermium",
|
||||||
|
"release_url": "https://github.com/actions/node-versions/releases/tag/14.0.0-20200507.99",
|
||||||
|
"files": [
|
||||||
|
{
|
||||||
|
"filename": "node-14.0.0-darwin-x64.tar.gz",
|
||||||
|
"arch": "x64",
|
||||||
|
"platform": "darwin",
|
||||||
|
"download_url": "https://github.com/actions/node-versions/releases/download/14.0.0-20200507.99/node-14.0.0-darwin-x64.tar.gz"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename": "node-14.0.0-linux-x64.tar.gz",
|
||||||
|
"arch": "x64",
|
||||||
|
"platform": "linux",
|
||||||
|
"download_url": "https://github.com/actions/node-versions/releases/download/14.0.0-20200507.99/node-14.0.0-linux-x64.tar.gz"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename": "node-14.0.0-win32-x64.7z",
|
||||||
|
"arch": "x64",
|
||||||
|
"platform": "win32",
|
||||||
|
"download_url": "https://github.com/actions/node-versions/releases/download/14.0.0-20200507.99/node-14.0.0-win32-x64.7z"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "13.13.0",
|
||||||
|
"stable": true,
|
||||||
|
"release_url": "https://github.com/actions/node-versions/releases/tag/13.13.0-20200507.97",
|
||||||
|
"files": [
|
||||||
|
{
|
||||||
|
"filename": "node-13.13.0-darwin-x64.tar.gz",
|
||||||
|
"arch": "x64",
|
||||||
|
"platform": "darwin",
|
||||||
|
"download_url": "https://github.com/actions/node-versions/releases/download/13.13.0-20200507.97/node-13.13.0-darwin-x64.tar.gz"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename": "node-13.13.0-linux-x64.tar.gz",
|
||||||
|
"arch": "x64",
|
||||||
|
"platform": "linux",
|
||||||
|
"download_url": "https://github.com/actions/node-versions/releases/download/13.13.0-20200507.97/node-13.13.0-linux-x64.tar.gz"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename": "node-13.13.0-win32-x64.7z",
|
||||||
|
"arch": "x64",
|
||||||
|
"platform": "win32",
|
||||||
|
"download_url": "https://github.com/actions/node-versions/releases/download/13.13.0-20200507.97/node-13.13.0-win32-x64.7z"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "12.16.2",
|
||||||
|
"stable": true,
|
||||||
|
"lts": "Erbium",
|
||||||
|
"release_url": "https://github.com/actions/node-versions/releases/tag/12.16.2-20200507.95",
|
||||||
|
"files": [
|
||||||
|
{
|
||||||
|
"filename": "node-12.16.2-darwin-x64.tar.gz",
|
||||||
|
"arch": "x64",
|
||||||
|
"platform": "darwin",
|
||||||
|
"download_url": "https://github.com/actions/node-versions/releases/download/12.16.2-20200507.95/node-12.16.2-darwin-x64.tar.gz"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename": "node-12.16.2-linux-x64.tar.gz",
|
||||||
|
"arch": "x64",
|
||||||
|
"platform": "linux",
|
||||||
|
"download_url": "https://github.com/actions/node-versions/releases/download/12.16.2-20200507.95/node-12.16.2-linux-x64.tar.gz"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename": "node-12.16.2-win32-x64.7z",
|
||||||
|
"arch": "x64",
|
||||||
|
"platform": "win32",
|
||||||
|
"download_url": "https://github.com/actions/node-versions/releases/download/12.16.2-20200507.95/node-12.16.2-win32-x64.7z"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "12.0.0",
|
||||||
|
"stable": true,
|
||||||
|
"lts": "Erbium",
|
||||||
|
"release_url": "https://github.com/actions/node-versions/releases/tag/12.0.0-20200507.71",
|
||||||
|
"files": [
|
||||||
|
{
|
||||||
|
"filename": "node-12.0.0-darwin-x64.tar.gz",
|
||||||
|
"arch": "x64",
|
||||||
|
"platform": "darwin",
|
||||||
|
"download_url": "https://github.com/actions/node-versions/releases/download/12.0.0-20200507.71/node-12.0.0-darwin-x64.tar.gz"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename": "node-12.0.0-linux-x64.tar.gz",
|
||||||
|
"arch": "x64",
|
||||||
|
"platform": "linux",
|
||||||
|
"download_url": "https://github.com/actions/node-versions/releases/download/12.0.0-20200507.71/node-12.0.0-linux-x64.tar.gz"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename": "node-12.0.0-win32-x64.7z",
|
||||||
|
"arch": "x64",
|
||||||
|
"platform": "win32",
|
||||||
|
"download_url": "https://github.com/actions/node-versions/releases/download/12.0.0-20200507.71/node-12.0.0-win32-x64.7z"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "10.20.1",
|
||||||
|
"stable": true,
|
||||||
|
"lts": "Dubnium",
|
||||||
|
"release_url": "https://github.com/actions/node-versions/releases/tag/10.20.1-20200507.70",
|
||||||
|
"files": [
|
||||||
|
{
|
||||||
|
"filename": "node-10.20.1-darwin-x64.tar.gz",
|
||||||
|
"arch": "x64",
|
||||||
|
"platform": "darwin",
|
||||||
|
"download_url": "https://github.com/actions/node-versions/releases/download/10.20.1-20200507.70/node-10.20.1-darwin-x64.tar.gz"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename": "node-10.20.1-linux-x64.tar.gz",
|
||||||
|
"arch": "x64",
|
||||||
|
"platform": "linux",
|
||||||
|
"download_url": "https://github.com/actions/node-versions/releases/download/10.20.1-20200507.70/node-10.20.1-linux-x64.tar.gz"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename": "node-10.20.1-win32-x64.7z",
|
||||||
|
"arch": "x64",
|
||||||
|
"platform": "win32",
|
||||||
|
"download_url": "https://github.com/actions/node-versions/releases/download/10.20.1-20200507.70/node-10.20.1-win32-x64.7z"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "8.17.0",
|
||||||
|
"stable": true,
|
||||||
|
"lts": "Carbon",
|
||||||
|
"release_url": "https://github.com/actions/node-versions/releases/tag/8.17.0-20200507.37",
|
||||||
|
"files": [
|
||||||
|
{
|
||||||
|
"filename": "node-8.17.0-darwin-x64.tar.gz",
|
||||||
|
"arch": "x64",
|
||||||
|
"platform": "darwin",
|
||||||
|
"download_url": "https://github.com/actions/node-versions/releases/download/8.17.0-20200507.37/node-8.17.0-darwin-x64.tar.gz"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename": "node-8.17.0-linux-x64.tar.gz",
|
||||||
|
"arch": "x64",
|
||||||
|
"platform": "linux",
|
||||||
|
"download_url": "https://github.com/actions/node-versions/releases/download/8.17.0-20200507.37/node-8.17.0-linux-x64.tar.gz"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename": "node-8.17.0-win32-x64.7z",
|
||||||
|
"arch": "x64",
|
||||||
|
"platform": "win32",
|
||||||
|
"download_url": "https://github.com/actions/node-versions/releases/download/8.17.0-20200507.37/node-8.17.0-win32-x64.7z"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"version": "6.17.1",
|
||||||
|
"stable": true,
|
||||||
|
"lts": "Boron",
|
||||||
|
"release_url": "https://github.com/actions/node-versions/releases/tag/6.17.1-20200529.2",
|
||||||
|
"files": [
|
||||||
|
{
|
||||||
|
"filename": "node-6.17.1-darwin-x64.tar.gz",
|
||||||
|
"arch": "x64",
|
||||||
|
"platform": "darwin",
|
||||||
|
"download_url": "https://github.com/actions/node-versions/releases/download/6.17.1-20200529.2/node-6.17.1-darwin-x64.tar.gz"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename": "node-6.17.1-linux-x64.tar.gz",
|
||||||
|
"arch": "x64",
|
||||||
|
"platform": "linux",
|
||||||
|
"download_url": "https://github.com/actions/node-versions/releases/download/6.17.1-20200529.2/node-6.17.1-linux-x64.tar.gz"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename": "node-6.17.1-win32-x64.7z",
|
||||||
|
"arch": "x64",
|
||||||
|
"platform": "win32",
|
||||||
|
"download_url": "https://github.com/actions/node-versions/releases/download/6.17.1-20200529.2/node-6.17.1-win32-x64.7z"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"name": "yarn-fixture",
|
||||||
|
"engines": {
|
||||||
|
"node": "^24.0.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"accepts": "^1.3.8",
|
||||||
|
"array-flatten": "^3.0.0",
|
||||||
|
"bytes": "^3.1.2",
|
||||||
|
"content-disposition": "^0.5.4"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||||
|
# yarn lockfile v1
|
||||||
|
|
||||||
|
|
||||||
|
accepts@^1.3.8:
|
||||||
|
version "1.3.8"
|
||||||
|
resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.8.tgz#0bf0be125b67014adcb0b0921e62db7bffe16b2e"
|
||||||
|
integrity sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==
|
||||||
|
dependencies:
|
||||||
|
mime-types "~2.1.34"
|
||||||
|
negotiator "0.6.3"
|
||||||
|
|
||||||
|
array-flatten@^3.0.0:
|
||||||
|
version "3.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-3.0.0.tgz#6428ca2ee52c7b823192ec600fa3ed2f157cd541"
|
||||||
|
integrity sha512-zPMVc3ZYlGLNk4mpK1NzP2wg0ml9t7fUgDsayR5Y5rSzxQilzR9FGu/EH2jQOcKSAeAfWeylyW8juy3OkWRvNA==
|
||||||
|
|
||||||
|
bytes@^3.1.2:
|
||||||
|
version "3.1.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.1.2.tgz#8b0beeb98605adf1b128fa4386403c009e0221a5"
|
||||||
|
integrity sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==
|
||||||
|
|
||||||
|
content-disposition@^0.5.4:
|
||||||
|
version "0.5.4"
|
||||||
|
resolved "https://registry.yarnpkg.com/content-disposition/-/content-disposition-0.5.4.tgz#8b82b4efac82512a02bb0b1dcec9d2c5e8eb5bfe"
|
||||||
|
integrity sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==
|
||||||
|
dependencies:
|
||||||
|
safe-buffer "5.2.1"
|
||||||
|
|
||||||
|
mime-db@1.52.0:
|
||||||
|
version "1.52.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70"
|
||||||
|
integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==
|
||||||
|
|
||||||
|
mime-types@~2.1.34:
|
||||||
|
version "2.1.35"
|
||||||
|
resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a"
|
||||||
|
integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==
|
||||||
|
dependencies:
|
||||||
|
mime-db "1.52.0"
|
||||||
|
|
||||||
|
negotiator@0.6.3:
|
||||||
|
version "0.6.3"
|
||||||
|
resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.3.tgz#58e323a72fedc0d6f9cd4d31fe49f51479590ccd"
|
||||||
|
integrity sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==
|
||||||
|
|
||||||
|
safe-buffer@5.2.1:
|
||||||
|
version "5.2.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6"
|
||||||
|
integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==
|
||||||
|
|
@ -1,132 +0,0 @@
|
||||||
import io = require('@actions/io');
|
|
||||||
import fs = require('fs');
|
|
||||||
import os = require('os');
|
|
||||||
import path = require('path');
|
|
||||||
|
|
||||||
const toolDir = path.join(
|
|
||||||
process.cwd(),
|
|
||||||
'runner',
|
|
||||||
path.join(
|
|
||||||
Math.random()
|
|
||||||
.toString(36)
|
|
||||||
.substring(7)
|
|
||||||
),
|
|
||||||
'tools'
|
|
||||||
);
|
|
||||||
const tempDir = path.join(
|
|
||||||
process.cwd(),
|
|
||||||
'runner',
|
|
||||||
path.join(
|
|
||||||
Math.random()
|
|
||||||
.toString(36)
|
|
||||||
.substring(7)
|
|
||||||
),
|
|
||||||
'temp'
|
|
||||||
);
|
|
||||||
|
|
||||||
process.env['RUNNER_TOOL_CACHE'] = toolDir;
|
|
||||||
process.env['RUNNER_TEMP'] = tempDir;
|
|
||||||
import * as installer from '../src/installer';
|
|
||||||
|
|
||||||
const IS_WINDOWS = process.platform === 'win32';
|
|
||||||
|
|
||||||
describe('installer tests', () => {
|
|
||||||
beforeAll(async () => {
|
|
||||||
await io.rmRF(toolDir);
|
|
||||||
await io.rmRF(tempDir);
|
|
||||||
}, 100000);
|
|
||||||
|
|
||||||
afterAll(async () => {
|
|
||||||
try {
|
|
||||||
await io.rmRF(toolDir);
|
|
||||||
await io.rmRF(tempDir);
|
|
||||||
} catch {
|
|
||||||
console.log('Failed to remove test directories');
|
|
||||||
}
|
|
||||||
}, 100000);
|
|
||||||
|
|
||||||
it('Acquires version of node if no matching version is installed', async () => {
|
|
||||||
await installer.getNode('10.16.0');
|
|
||||||
const nodeDir = path.join(toolDir, 'node', '10.16.0', os.arch());
|
|
||||||
|
|
||||||
expect(fs.existsSync(`${nodeDir}.complete`)).toBe(true);
|
|
||||||
if (IS_WINDOWS) {
|
|
||||||
expect(fs.existsSync(path.join(nodeDir, 'node.exe'))).toBe(true);
|
|
||||||
} else {
|
|
||||||
expect(fs.existsSync(path.join(nodeDir, 'bin', 'node'))).toBe(true);
|
|
||||||
}
|
|
||||||
}, 100000);
|
|
||||||
|
|
||||||
if (IS_WINDOWS) {
|
|
||||||
it('Falls back to backup location if first one doesnt contain correct version', async () => {
|
|
||||||
await installer.getNode('5.10.1');
|
|
||||||
const nodeDir = path.join(toolDir, 'node', '5.10.1', os.arch());
|
|
||||||
|
|
||||||
expect(fs.existsSync(`${nodeDir}.complete`)).toBe(true);
|
|
||||||
expect(fs.existsSync(path.join(nodeDir, 'node.exe'))).toBe(true);
|
|
||||||
}, 100000);
|
|
||||||
|
|
||||||
it('Falls back to third location if second one doesnt contain correct version', async () => {
|
|
||||||
await installer.getNode('0.12.18');
|
|
||||||
const nodeDir = path.join(toolDir, 'node', '0.12.18', os.arch());
|
|
||||||
|
|
||||||
expect(fs.existsSync(`${nodeDir}.complete`)).toBe(true);
|
|
||||||
expect(fs.existsSync(path.join(nodeDir, 'node.exe'))).toBe(true);
|
|
||||||
}, 100000);
|
|
||||||
}
|
|
||||||
|
|
||||||
it('Throws if no location contains correct node version', async () => {
|
|
||||||
let thrown = false;
|
|
||||||
try {
|
|
||||||
await installer.getNode('1000');
|
|
||||||
} catch {
|
|
||||||
thrown = true;
|
|
||||||
}
|
|
||||||
expect(thrown).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Acquires version of node with long paths', async () => {
|
|
||||||
const toolpath = await installer.getNode('8.8.1');
|
|
||||||
const nodeDir = path.join(toolDir, 'node', '8.8.1', os.arch());
|
|
||||||
|
|
||||||
expect(fs.existsSync(`${nodeDir}.complete`)).toBe(true);
|
|
||||||
if (IS_WINDOWS) {
|
|
||||||
expect(fs.existsSync(path.join(nodeDir, 'node.exe'))).toBe(true);
|
|
||||||
} else {
|
|
||||||
expect(fs.existsSync(path.join(nodeDir, 'bin', 'node'))).toBe(true);
|
|
||||||
}
|
|
||||||
}, 100000);
|
|
||||||
|
|
||||||
it('Uses version of node installed in cache', async () => {
|
|
||||||
const nodeDir: string = path.join(toolDir, 'node', '250.0.0', os.arch());
|
|
||||||
await io.mkdirP(nodeDir);
|
|
||||||
fs.writeFileSync(`${nodeDir}.complete`, 'hello');
|
|
||||||
// This will throw if it doesn't find it in the cache (because no such version exists)
|
|
||||||
await installer.getNode('250.0.0');
|
|
||||||
return;
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Doesnt use version of node that was only partially installed in cache', async () => {
|
|
||||||
const nodeDir: string = path.join(toolDir, 'node', '251.0.0', os.arch());
|
|
||||||
await io.mkdirP(nodeDir);
|
|
||||||
let thrown = false;
|
|
||||||
try {
|
|
||||||
// This will throw if it doesn't find it in the cache (because no such version exists)
|
|
||||||
await installer.getNode('251.0.0');
|
|
||||||
} catch {
|
|
||||||
thrown = true;
|
|
||||||
}
|
|
||||||
expect(thrown).toBe(true);
|
|
||||||
return;
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Resolves semantic versions of node installed in cache', async () => {
|
|
||||||
const nodeDir: string = path.join(toolDir, 'node', '252.0.0', os.arch());
|
|
||||||
await io.mkdirP(nodeDir);
|
|
||||||
fs.writeFileSync(`${nodeDir}.complete`, 'hello');
|
|
||||||
// These will throw if it doesn't find it in the cache (because no such version exists)
|
|
||||||
await installer.getNode('252.0.0');
|
|
||||||
await installer.getNode('252');
|
|
||||||
await installer.getNode('252.0');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
@ -0,0 +1,433 @@
|
||||||
|
import * as core from '@actions/core';
|
||||||
|
import * as exec from '@actions/exec';
|
||||||
|
import * as tc from '@actions/tool-cache';
|
||||||
|
import * as cache from '@actions/cache';
|
||||||
|
import * as io from '@actions/io';
|
||||||
|
|
||||||
|
import fs from 'fs';
|
||||||
|
import path from 'path';
|
||||||
|
import osm from 'os';
|
||||||
|
|
||||||
|
import each from 'jest-each';
|
||||||
|
|
||||||
|
import * as main from '../src/main';
|
||||||
|
import * as util from '../src/util';
|
||||||
|
import OfficialBuilds from '../src/distributions/official_builds/official_builds';
|
||||||
|
|
||||||
|
describe('main tests', () => {
|
||||||
|
let inputs = {} as any;
|
||||||
|
let os = {} as any;
|
||||||
|
|
||||||
|
let infoSpy: jest.SpyInstance;
|
||||||
|
let warningSpy: jest.SpyInstance;
|
||||||
|
let saveStateSpy: jest.SpyInstance;
|
||||||
|
let inSpy: jest.SpyInstance;
|
||||||
|
let setOutputSpy: jest.SpyInstance;
|
||||||
|
let startGroupSpy: jest.SpyInstance;
|
||||||
|
let endGroupSpy: jest.SpyInstance;
|
||||||
|
|
||||||
|
let whichSpy: jest.SpyInstance;
|
||||||
|
|
||||||
|
let existsSpy: jest.SpyInstance;
|
||||||
|
|
||||||
|
let getExecOutputSpy: jest.SpyInstance;
|
||||||
|
|
||||||
|
let getNodeVersionFromFileSpy: jest.SpyInstance;
|
||||||
|
let cnSpy: jest.SpyInstance;
|
||||||
|
let findSpy: jest.SpyInstance;
|
||||||
|
let isCacheActionAvailable: jest.SpyInstance;
|
||||||
|
|
||||||
|
let setupNodeJsSpy: jest.SpyInstance;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
inputs = {};
|
||||||
|
|
||||||
|
// node
|
||||||
|
os = {};
|
||||||
|
console.log('::stop-commands::stoptoken');
|
||||||
|
process.env['GITHUB_WORKSPACE'] = path.join(__dirname, 'data');
|
||||||
|
process.env['GITHUB_PATH'] = ''; // Stub out ENV file functionality so we can verify it writes to standard out
|
||||||
|
process.env['GITHUB_OUTPUT'] = ''; // Stub out ENV file functionality so we can verify it writes to standard out
|
||||||
|
infoSpy = jest.spyOn(core, 'info');
|
||||||
|
infoSpy.mockImplementation(() => {});
|
||||||
|
setOutputSpy = jest.spyOn(core, 'setOutput');
|
||||||
|
setOutputSpy.mockImplementation(() => {});
|
||||||
|
warningSpy = jest.spyOn(core, 'warning');
|
||||||
|
warningSpy.mockImplementation(() => {});
|
||||||
|
saveStateSpy = jest.spyOn(core, 'saveState');
|
||||||
|
saveStateSpy.mockImplementation(() => {});
|
||||||
|
startGroupSpy = jest.spyOn(core, 'startGroup');
|
||||||
|
startGroupSpy.mockImplementation(() => {});
|
||||||
|
endGroupSpy = jest.spyOn(core, 'endGroup');
|
||||||
|
endGroupSpy.mockImplementation(() => {});
|
||||||
|
inSpy = jest.spyOn(core, 'getInput');
|
||||||
|
inSpy.mockImplementation(name => inputs[name]);
|
||||||
|
|
||||||
|
whichSpy = jest.spyOn(io, 'which');
|
||||||
|
|
||||||
|
getExecOutputSpy = jest.spyOn(exec, 'getExecOutput');
|
||||||
|
|
||||||
|
findSpy = jest.spyOn(tc, 'find');
|
||||||
|
|
||||||
|
isCacheActionAvailable = jest.spyOn(cache, 'isFeatureAvailable');
|
||||||
|
|
||||||
|
cnSpy = jest.spyOn(process.stdout, 'write');
|
||||||
|
cnSpy.mockImplementation(line => {
|
||||||
|
// uncomment to debug
|
||||||
|
process.stderr.write('write:' + line + '\n');
|
||||||
|
});
|
||||||
|
|
||||||
|
setupNodeJsSpy = jest.spyOn(OfficialBuilds.prototype, 'setupNodeJs');
|
||||||
|
setupNodeJsSpy.mockImplementation(() => {});
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
jest.resetAllMocks();
|
||||||
|
jest.clearAllMocks();
|
||||||
|
//jest.restoreAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(async () => {
|
||||||
|
console.log('::stoptoken::');
|
||||||
|
jest.restoreAllMocks();
|
||||||
|
}, 100000);
|
||||||
|
|
||||||
|
describe('getNodeVersionFromFile', () => {
|
||||||
|
each`
|
||||||
|
contents | expected
|
||||||
|
${'12'} | ${'12'}
|
||||||
|
${'12.3'} | ${'12.3'}
|
||||||
|
${'12.3.4'} | ${'12.3.4'}
|
||||||
|
${'v12.3.4'} | ${'12.3.4'}
|
||||||
|
${'lts/erbium'} | ${'lts/erbium'}
|
||||||
|
${'lts/*'} | ${'lts/*'}
|
||||||
|
${'nodejs 12.3.4'} | ${'12.3.4'}
|
||||||
|
${'ruby 2.3.4\nnodejs 12.3.4\npython 3.4.5'} | ${'12.3.4'}
|
||||||
|
${''} | ${''}
|
||||||
|
${'unknown format'} | ${'unknown format'}
|
||||||
|
${' 14.1.0 '} | ${'14.1.0'}
|
||||||
|
${'{}'} | ${null}
|
||||||
|
${'{"volta": {"node": ">=14.0.0 <=17.0.0"}}'} | ${'>=14.0.0 <=17.0.0'}
|
||||||
|
${'{"volta": {"extends": "./package.json"}}'} | ${'18.0.0'}
|
||||||
|
${'{"engines": {"node": "17.0.0"}}'} | ${'17.0.0'}
|
||||||
|
${'{"devEngines": {"runtime": {"name": "node", "version": "22.0.0"}}}'} | ${'22.0.0'}
|
||||||
|
${'{"devEngines": {"runtime": [{"name": "bun"}, {"name": "node", "version": "22.0.0"}]}}'} | ${'22.0.0'}
|
||||||
|
`.it('parses "$contents"', ({contents, expected}) => {
|
||||||
|
const existsSpy = jest.spyOn(fs, 'existsSync');
|
||||||
|
existsSpy.mockImplementation(() => true);
|
||||||
|
|
||||||
|
const readFileSpy = jest.spyOn(fs, 'readFileSync');
|
||||||
|
readFileSpy.mockImplementation(filePath => {
|
||||||
|
if (
|
||||||
|
typeof filePath === 'string' &&
|
||||||
|
path.basename(filePath) === 'package.json'
|
||||||
|
) {
|
||||||
|
// Special case for volta.extends
|
||||||
|
return '{"volta": {"node": "18.0.0"}}';
|
||||||
|
}
|
||||||
|
|
||||||
|
return contents;
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(util.getNodeVersionFromFile('file')).toBe(expected);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('printEnvDetailsAndSetOutput', () => {
|
||||||
|
it.each([
|
||||||
|
[{node: '12.0.2', npm: '6.3.3', yarn: '1.22.11'}],
|
||||||
|
[{node: '16.0.2', npm: '7.3.3', yarn: '2.22.11'}],
|
||||||
|
[{node: '14.0.1', npm: '8.1.0', yarn: '3.2.1'}],
|
||||||
|
[{node: '17.0.2', npm: '6.3.3', yarn: ''}]
|
||||||
|
])('Tools versions %p', async obj => {
|
||||||
|
getExecOutputSpy.mockImplementation(async command => {
|
||||||
|
if (Reflect.has(obj, command) && !obj[command]) {
|
||||||
|
return {
|
||||||
|
stdout: '',
|
||||||
|
stderr: `${command} does not exist`,
|
||||||
|
exitCode: 1
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {stdout: obj[command], stderr: '', exitCode: 0};
|
||||||
|
});
|
||||||
|
|
||||||
|
whichSpy.mockImplementation(cmd => {
|
||||||
|
return `some/${cmd}/path`;
|
||||||
|
});
|
||||||
|
|
||||||
|
await util.printEnvDetailsAndSetOutput();
|
||||||
|
|
||||||
|
expect(setOutputSpy).toHaveBeenCalledWith('node-version', obj['node']);
|
||||||
|
Object.getOwnPropertyNames(obj).forEach(name => {
|
||||||
|
if (!obj[name]) {
|
||||||
|
expect(infoSpy).toHaveBeenCalledWith(
|
||||||
|
`[warning]${name} does not exist`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
expect(infoSpy).toHaveBeenCalledWith(`${name}: ${obj[name]}`);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('node-version-file flag', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
delete inputs['node-version'];
|
||||||
|
inputs['node-version-file'] = '.nvmrc';
|
||||||
|
|
||||||
|
getNodeVersionFromFileSpy = jest.spyOn(util, 'getNodeVersionFromFile');
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
getNodeVersionFromFileSpy.mockRestore();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does not read node-version-file if node-version is provided', async () => {
|
||||||
|
// Arrange
|
||||||
|
inputs['node-version'] = '12';
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(inputs['node-version']).toBeDefined();
|
||||||
|
expect(inputs['node-version-file']).toBeDefined();
|
||||||
|
expect(getNodeVersionFromFileSpy).not.toHaveBeenCalled();
|
||||||
|
expect(warningSpy).toHaveBeenCalledWith(
|
||||||
|
'Both node-version and node-version-file inputs are specified, only node-version will be used'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does not read node-version-file if node-version-file is not provided', async () => {
|
||||||
|
// Arrange
|
||||||
|
delete inputs['node-version-file'];
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(getNodeVersionFromFileSpy).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('reads node-version-file', async () => {
|
||||||
|
// Arrange
|
||||||
|
const expectedVersionSpec = '14';
|
||||||
|
getNodeVersionFromFileSpy.mockImplementation(() => expectedVersionSpec);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(getNodeVersionFromFileSpy).toHaveBeenCalled();
|
||||||
|
expect(infoSpy).toHaveBeenCalledWith(
|
||||||
|
`Resolved ${inputs['node-version-file']} as ${expectedVersionSpec}`
|
||||||
|
);
|
||||||
|
}, 10000);
|
||||||
|
|
||||||
|
it('should throw an error if node-version-file is not accessible', async () => {
|
||||||
|
// Arrange
|
||||||
|
inputs['node-version-file'] = 'non-existing-file';
|
||||||
|
const versionFilePath = path.join(
|
||||||
|
__dirname,
|
||||||
|
'data',
|
||||||
|
inputs['node-version-file']
|
||||||
|
);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(getNodeVersionFromFileSpy).toHaveBeenCalled();
|
||||||
|
expect(cnSpy).toHaveBeenCalledWith(
|
||||||
|
`::error::The specified node version file at: ${versionFilePath} does not exist${osm.EOL}`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('cache on GHES', () => {
|
||||||
|
it('Should throw an error, because cache is not supported', async () => {
|
||||||
|
inputs['node-version'] = '12';
|
||||||
|
inputs['cache'] = 'npm';
|
||||||
|
|
||||||
|
inSpy.mockImplementation(name => inputs[name]);
|
||||||
|
|
||||||
|
const toolPath = path.normalize('/cache/node/12.16.1/x64');
|
||||||
|
findSpy.mockImplementation(() => toolPath);
|
||||||
|
|
||||||
|
// expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`);
|
||||||
|
process.env['GITHUB_SERVER_URL'] = 'https://www.test.com';
|
||||||
|
isCacheActionAvailable.mockImplementation(() => false);
|
||||||
|
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
expect(warningSpy).toHaveBeenCalledWith(
|
||||||
|
`Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should throw an internal error', async () => {
|
||||||
|
inputs['node-version'] = '12';
|
||||||
|
inputs['cache'] = 'npm';
|
||||||
|
|
||||||
|
inSpy.mockImplementation(name => inputs[name]);
|
||||||
|
|
||||||
|
const toolPath = path.normalize('/cache/node/12.16.1/x64');
|
||||||
|
findSpy.mockImplementation(() => toolPath);
|
||||||
|
|
||||||
|
// expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`);
|
||||||
|
process.env['GITHUB_SERVER_URL'] = '';
|
||||||
|
isCacheActionAvailable.mockImplementation(() => false);
|
||||||
|
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
expect(warningSpy).toHaveBeenCalledWith(
|
||||||
|
'The runner was not able to contact the cache service. Caching will be skipped'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('cache feature tests', () => {
|
||||||
|
it('Should enable caching when packageManager is npm and cache input is not provided', async () => {
|
||||||
|
inputs['package-manager-cache'] = 'true';
|
||||||
|
inputs['cache'] = '';
|
||||||
|
isCacheActionAvailable.mockImplementation(() => true);
|
||||||
|
|
||||||
|
inSpy.mockImplementation(name => inputs[name]);
|
||||||
|
const readFileSpy = jest.spyOn(fs, 'readFileSync');
|
||||||
|
readFileSpy.mockImplementation(() =>
|
||||||
|
JSON.stringify({
|
||||||
|
packageManager: 'npm@10.8.2'
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
expect(saveStateSpy).toHaveBeenCalledWith(expect.anything(), 'npm');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should enable caching when devEngines.packageManager.name is "npm" and cache input is not provided', async () => {
|
||||||
|
inputs['package-manager-cache'] = 'true';
|
||||||
|
inputs['cache'] = '';
|
||||||
|
isCacheActionAvailable.mockImplementation(() => true);
|
||||||
|
|
||||||
|
inSpy.mockImplementation(name => inputs[name]);
|
||||||
|
const readFileSpy = jest.spyOn(fs, 'readFileSync');
|
||||||
|
readFileSpy.mockImplementation(() =>
|
||||||
|
JSON.stringify({
|
||||||
|
devEngines: {
|
||||||
|
packageManager: {name: 'npm'}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
expect(saveStateSpy).toHaveBeenCalledWith(expect.anything(), 'npm');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should enable caching when devEngines.packageManager is array and one entry has name "npm"', async () => {
|
||||||
|
inputs['package-manager-cache'] = 'true';
|
||||||
|
inputs['cache'] = '';
|
||||||
|
isCacheActionAvailable.mockImplementation(() => true);
|
||||||
|
|
||||||
|
inSpy.mockImplementation(name => inputs[name]);
|
||||||
|
const readFileSpy = jest.spyOn(fs, 'readFileSync');
|
||||||
|
readFileSpy.mockImplementation(() =>
|
||||||
|
JSON.stringify({
|
||||||
|
devEngines: {
|
||||||
|
packageManager: [{name: 'pnpm'}, {name: 'npm'}]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
expect(saveStateSpy).toHaveBeenCalledWith(expect.anything(), 'npm');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should not enable caching if packageManager is "pnpm@8.0.0" and cache input is not provided', async () => {
|
||||||
|
inputs['package-manager-cache'] = 'true';
|
||||||
|
inputs['cache'] = '';
|
||||||
|
inSpy.mockImplementation(name => inputs[name]);
|
||||||
|
const readFileSpy = jest.spyOn(fs, 'readFileSync');
|
||||||
|
readFileSpy.mockImplementation(() =>
|
||||||
|
JSON.stringify({
|
||||||
|
packageManager: 'pnpm@8.0.0'
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
expect(saveStateSpy).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should not enable caching if devEngines.packageManager.name is "pnpm"', async () => {
|
||||||
|
inputs['package-manager-cache'] = 'true';
|
||||||
|
inputs['cache'] = '';
|
||||||
|
inSpy.mockImplementation(name => inputs[name]);
|
||||||
|
const readFileSpy = jest.spyOn(fs, 'readFileSync');
|
||||||
|
readFileSpy.mockImplementation(() =>
|
||||||
|
JSON.stringify({
|
||||||
|
devEngines: {
|
||||||
|
packageManager: {name: 'pnpm'}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
expect(saveStateSpy).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should not enable caching if devEngines.packageManager is array without "npm"', async () => {
|
||||||
|
inputs['package-manager-cache'] = 'true';
|
||||||
|
inputs['cache'] = '';
|
||||||
|
inSpy.mockImplementation(name => inputs[name]);
|
||||||
|
const readFileSpy = jest.spyOn(fs, 'readFileSync');
|
||||||
|
readFileSpy.mockImplementation(() =>
|
||||||
|
JSON.stringify({
|
||||||
|
devEngines: {
|
||||||
|
packageManager: [{name: 'pnpm'}, {name: 'yarn'}]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
expect(saveStateSpy).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should not enable caching if packageManager field is missing in package.json and cache input is not provided', async () => {
|
||||||
|
inputs['package-manager-cache'] = 'true';
|
||||||
|
inputs['cache'] = '';
|
||||||
|
inSpy.mockImplementation(name => inputs[name]);
|
||||||
|
const readFileSpy = jest.spyOn(fs, 'readFileSync');
|
||||||
|
readFileSpy.mockImplementation(() =>
|
||||||
|
JSON.stringify({
|
||||||
|
// packageManager field is not present
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
expect(saveStateSpy).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should skip caching when package-manager-cache is false', async () => {
|
||||||
|
inputs['package-manager-cache'] = 'false';
|
||||||
|
inputs['cache'] = '';
|
||||||
|
inSpy.mockImplementation(name => inputs[name]);
|
||||||
|
await main.run();
|
||||||
|
expect(saveStateSpy).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should enable caching with cache input explicitly provided', async () => {
|
||||||
|
inputs['package-manager-cache'] = 'true';
|
||||||
|
inputs['cache'] = 'npm';
|
||||||
|
inSpy.mockImplementation(name => inputs[name]);
|
||||||
|
isCacheActionAvailable.mockImplementation(() => true);
|
||||||
|
await main.run();
|
||||||
|
expect(saveStateSpy).toHaveBeenCalledWith(expect.anything(), 'npm');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
import {MockGlobber} from './glob-mock';
|
||||||
|
|
||||||
|
describe('mocked globber tests', () => {
|
||||||
|
it('globber should return generator', async () => {
|
||||||
|
const globber = new MockGlobber(['aaa', 'bbb', 'ccc']);
|
||||||
|
const generator = globber.globGenerator();
|
||||||
|
const result: string[] = [];
|
||||||
|
for await (const itemPath of generator) {
|
||||||
|
result.push(itemPath);
|
||||||
|
}
|
||||||
|
expect(result).toEqual(['aaa', 'bbb', 'ccc']);
|
||||||
|
});
|
||||||
|
it('globber should return glob', async () => {
|
||||||
|
const globber = new MockGlobber(['aaa', 'bbb', 'ccc']);
|
||||||
|
const result: string[] = await globber.glob();
|
||||||
|
expect(result).toEqual(['aaa', 'bbb', 'ccc']);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
import {Globber} from '@actions/glob';
|
||||||
|
|
||||||
|
export class MockGlobber implements Globber {
|
||||||
|
private readonly expected: string[];
|
||||||
|
constructor(expected: string[]) {
|
||||||
|
this.expected = expected;
|
||||||
|
}
|
||||||
|
getSearchPaths(): string[] {
|
||||||
|
return this.expected.slice();
|
||||||
|
}
|
||||||
|
|
||||||
|
async glob(): Promise<string[]> {
|
||||||
|
const result: string[] = [];
|
||||||
|
for await (const itemPath of this.globGenerator()) {
|
||||||
|
result.push(itemPath);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
async *globGenerator(): AsyncGenerator<string, void> {
|
||||||
|
for (const e of this.expected) {
|
||||||
|
yield e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static async create(expected: string[]): Promise<MockGlobber> {
|
||||||
|
return new MockGlobber(expected);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,650 @@
|
||||||
|
import * as core from '@actions/core';
|
||||||
|
import * as io from '@actions/io';
|
||||||
|
import * as tc from '@actions/tool-cache';
|
||||||
|
import * as httpm from '@actions/http-client';
|
||||||
|
import * as exec from '@actions/exec';
|
||||||
|
import * as cache from '@actions/cache';
|
||||||
|
import fs from 'fs';
|
||||||
|
import cp from 'child_process';
|
||||||
|
import osm from 'os';
|
||||||
|
import path from 'path';
|
||||||
|
import * as main from '../src/main';
|
||||||
|
import * as auth from '../src/authutil';
|
||||||
|
import {INodeVersion} from '../src/distributions/base-models';
|
||||||
|
|
||||||
|
import nodeTestManifest from './data/versions-manifest.json';
|
||||||
|
import nodeTestDist from './data/node-dist-index.json';
|
||||||
|
import nodeTestDistNightly from './data/node-nightly-index.json';
|
||||||
|
import nodeTestDistRc from './data/node-rc-index.json';
|
||||||
|
import nodeV8CanaryTestDist from './data/v8-canary-dist-index.json';
|
||||||
|
|
||||||
|
describe('setup-node', () => {
|
||||||
|
let inputs = {} as any;
|
||||||
|
let os = {} as any;
|
||||||
|
|
||||||
|
let inSpy: jest.SpyInstance;
|
||||||
|
let findSpy: jest.SpyInstance;
|
||||||
|
let findAllVersionsSpy: jest.SpyInstance;
|
||||||
|
let cnSpy: jest.SpyInstance;
|
||||||
|
let logSpy: jest.SpyInstance;
|
||||||
|
let warningSpy: jest.SpyInstance;
|
||||||
|
let getManifestSpy: jest.SpyInstance;
|
||||||
|
let getDistSpy: jest.SpyInstance;
|
||||||
|
let platSpy: jest.SpyInstance;
|
||||||
|
let archSpy: jest.SpyInstance;
|
||||||
|
let dlSpy: jest.SpyInstance;
|
||||||
|
let exSpy: jest.SpyInstance;
|
||||||
|
let cacheSpy: jest.SpyInstance;
|
||||||
|
let dbgSpy: jest.SpyInstance;
|
||||||
|
let whichSpy: jest.SpyInstance;
|
||||||
|
let existsSpy: jest.SpyInstance;
|
||||||
|
let mkdirpSpy: jest.SpyInstance;
|
||||||
|
let cpSpy: jest.SpyInstance;
|
||||||
|
let execSpy: jest.SpyInstance;
|
||||||
|
let authSpy: jest.SpyInstance;
|
||||||
|
let parseNodeVersionSpy: jest.SpyInstance;
|
||||||
|
let isCacheActionAvailable: jest.SpyInstance;
|
||||||
|
let getExecOutputSpy: jest.SpyInstance;
|
||||||
|
let getJsonSpy: jest.SpyInstance;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
// @actions/core
|
||||||
|
console.log('::stop-commands::stoptoken'); // Disable executing of runner commands when running tests in actions
|
||||||
|
process.env['GITHUB_PATH'] = ''; // Stub out ENV file functionality so we can verify it writes to standard out
|
||||||
|
process.env['GITHUB_OUTPUT'] = ''; // Stub out ENV file functionality so we can verify it writes to standard out
|
||||||
|
process.env['RUNNER_TEMP'] = '/runner_temp';
|
||||||
|
inputs = {};
|
||||||
|
inSpy = jest.spyOn(core, 'getInput');
|
||||||
|
inSpy.mockImplementation(name => inputs[name]);
|
||||||
|
|
||||||
|
// node
|
||||||
|
os = {};
|
||||||
|
platSpy = jest.spyOn(osm, 'platform');
|
||||||
|
platSpy.mockImplementation(() => os['platform']);
|
||||||
|
archSpy = jest.spyOn(osm, 'arch');
|
||||||
|
archSpy.mockImplementation(() => os['arch']);
|
||||||
|
execSpy = jest.spyOn(cp, 'execSync');
|
||||||
|
|
||||||
|
// @actions/tool-cache
|
||||||
|
findSpy = jest.spyOn(tc, 'find');
|
||||||
|
findAllVersionsSpy = jest.spyOn(tc, 'findAllVersions');
|
||||||
|
dlSpy = jest.spyOn(tc, 'downloadTool');
|
||||||
|
exSpy = jest.spyOn(tc, 'extractTar');
|
||||||
|
cacheSpy = jest.spyOn(tc, 'cacheDir');
|
||||||
|
getManifestSpy = jest.spyOn(tc, 'getManifestFromRepo');
|
||||||
|
|
||||||
|
// http-client
|
||||||
|
getJsonSpy = jest.spyOn(httpm.HttpClient.prototype, 'getJson');
|
||||||
|
|
||||||
|
// io
|
||||||
|
whichSpy = jest.spyOn(io, 'which');
|
||||||
|
existsSpy = jest.spyOn(fs, 'existsSync');
|
||||||
|
mkdirpSpy = jest.spyOn(io, 'mkdirP');
|
||||||
|
cpSpy = jest.spyOn(io, 'cp');
|
||||||
|
|
||||||
|
// @actions/tool-cache
|
||||||
|
isCacheActionAvailable = jest.spyOn(cache, 'isFeatureAvailable');
|
||||||
|
|
||||||
|
// disable authentication portion for installer tests
|
||||||
|
authSpy = jest.spyOn(auth, 'configAuthentication');
|
||||||
|
authSpy.mockImplementation(() => {});
|
||||||
|
|
||||||
|
getJsonSpy.mockImplementation(url => {
|
||||||
|
let res: any;
|
||||||
|
if (url.includes('/rc')) {
|
||||||
|
res = <INodeVersion[]>nodeTestDistRc;
|
||||||
|
} else if (url.includes('/nightly')) {
|
||||||
|
res = <INodeVersion[]>nodeTestDistNightly;
|
||||||
|
} else if (url.includes('/v8-canary')) {
|
||||||
|
res = <INodeVersion[]>nodeV8CanaryTestDist;
|
||||||
|
} else {
|
||||||
|
res = <INodeVersion[]>nodeTestDist;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {result: res};
|
||||||
|
});
|
||||||
|
|
||||||
|
// writes
|
||||||
|
cnSpy = jest.spyOn(process.stdout, 'write');
|
||||||
|
logSpy = jest.spyOn(core, 'info');
|
||||||
|
dbgSpy = jest.spyOn(core, 'debug');
|
||||||
|
warningSpy = jest.spyOn(core, 'warning');
|
||||||
|
cnSpy.mockImplementation(line => {
|
||||||
|
// uncomment to debug
|
||||||
|
// process.stderr.write('write:' + line + '\n');
|
||||||
|
});
|
||||||
|
logSpy.mockImplementation(line => {
|
||||||
|
// uncomment to debug
|
||||||
|
// process.stderr.write('log:' + line + '\n');
|
||||||
|
});
|
||||||
|
dbgSpy.mockImplementation(msg => {
|
||||||
|
// uncomment to see debug output
|
||||||
|
// process.stderr.write(msg + '\n');
|
||||||
|
});
|
||||||
|
warningSpy.mockImplementation(msg => {
|
||||||
|
// uncomment to debug
|
||||||
|
// process.stderr.write('log:' + msg + '\n');
|
||||||
|
});
|
||||||
|
|
||||||
|
// @actions/exec
|
||||||
|
getExecOutputSpy = jest.spyOn(exec, 'getExecOutput');
|
||||||
|
getExecOutputSpy.mockImplementation(() => 'v16.15.0');
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
jest.resetAllMocks();
|
||||||
|
jest.clearAllMocks();
|
||||||
|
//jest.restoreAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(async () => {
|
||||||
|
console.log('::stoptoken::'); // Re-enable executing of runner commands when running tests in actions
|
||||||
|
jest.restoreAllMocks();
|
||||||
|
}, 100000);
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// Found in cache tests
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
|
it('finds version in cache with stable true', async () => {
|
||||||
|
inputs['node-version'] = '16-nightly';
|
||||||
|
os['arch'] = 'x64';
|
||||||
|
inputs.stable = 'true';
|
||||||
|
|
||||||
|
const toolPath = path.normalize(
|
||||||
|
'/cache/node/16.0.0-nightly20210417bc31dc0e0f/x64'
|
||||||
|
);
|
||||||
|
findSpy.mockImplementation(() => toolPath);
|
||||||
|
findAllVersionsSpy.mockImplementation(() => [
|
||||||
|
'12.0.1',
|
||||||
|
'16.0.0-nightly20210415c3a5e15ebe',
|
||||||
|
'16.0.0-nightly20210417bc31dc0e0f',
|
||||||
|
'16.1.3'
|
||||||
|
]);
|
||||||
|
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
expect(findSpy).toHaveBeenCalledWith(
|
||||||
|
'node',
|
||||||
|
'16.0.0-nightly20210417bc31dc0e0f',
|
||||||
|
'x64'
|
||||||
|
);
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('finds version in cache with stable false', async () => {
|
||||||
|
inputs['node-version'] = '16.0.0-nightly20210415c3a5e15ebe';
|
||||||
|
os['arch'] = 'x64';
|
||||||
|
inputs.stable = 'false';
|
||||||
|
|
||||||
|
const toolPath = path.normalize(
|
||||||
|
'/cache/node/16.0.0-nightly20210415c3a5e15ebe/x64'
|
||||||
|
);
|
||||||
|
findSpy.mockImplementation(() => toolPath);
|
||||||
|
findAllVersionsSpy.mockImplementation(() => [
|
||||||
|
'12.0.1',
|
||||||
|
'16.0.0-nightly20210415c3a5e15ebe',
|
||||||
|
'16.0.0-nightly20210417bc31dc0e0f',
|
||||||
|
'16.1.3'
|
||||||
|
]);
|
||||||
|
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
expect(findSpy).toHaveBeenCalledWith(
|
||||||
|
'node',
|
||||||
|
'16.0.0-nightly20210415c3a5e15ebe',
|
||||||
|
'x64'
|
||||||
|
);
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('finds version in cache and adds it to the path', async () => {
|
||||||
|
inputs['node-version'] = '16-nightly';
|
||||||
|
os['arch'] = 'x64';
|
||||||
|
|
||||||
|
inSpy.mockImplementation(name => inputs[name]);
|
||||||
|
|
||||||
|
const toolPath = path.normalize(
|
||||||
|
'/cache/node/16.0.0-nightly20210417bc31dc0e0f/x64'
|
||||||
|
);
|
||||||
|
findSpy.mockImplementation(() => toolPath);
|
||||||
|
findAllVersionsSpy.mockImplementation(() => [
|
||||||
|
'12.0.1',
|
||||||
|
'16.0.0-nightly20210415c3a5e15ebe',
|
||||||
|
'16.0.0-nightly20210417bc31dc0e0f',
|
||||||
|
'16.1.3'
|
||||||
|
]);
|
||||||
|
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
expect(findSpy).toHaveBeenCalledWith(
|
||||||
|
'node',
|
||||||
|
'16.0.0-nightly20210417bc31dc0e0f',
|
||||||
|
'x64'
|
||||||
|
);
|
||||||
|
|
||||||
|
const expPath = path.join(toolPath, 'bin');
|
||||||
|
expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('handles unhandled find error and reports error', async () => {
|
||||||
|
const errMsg = 'unhandled error message';
|
||||||
|
inputs['node-version'] = '16.0.0-nightly20210417bc31dc0e0f';
|
||||||
|
|
||||||
|
findAllVersionsSpy.mockImplementation(() => [
|
||||||
|
'12.0.1',
|
||||||
|
'16.0.0-nightly20210415c3a5e15ebe',
|
||||||
|
'16.0.0-nightly20210417bc31dc0e0f',
|
||||||
|
'16.1.3'
|
||||||
|
]);
|
||||||
|
|
||||||
|
findSpy.mockImplementation(() => {
|
||||||
|
throw new Error(errMsg);
|
||||||
|
});
|
||||||
|
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
expect(cnSpy).toHaveBeenCalledWith('::error::' + errMsg + osm.EOL);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('falls back to a version from node dist', async () => {
|
||||||
|
os.platform = 'linux';
|
||||||
|
os.arch = 'x64';
|
||||||
|
|
||||||
|
// a version which is not in the manifest but is in node dist
|
||||||
|
const versionSpec = '13.13.1-nightly20200415947ddec091';
|
||||||
|
|
||||||
|
inputs['node-version'] = versionSpec;
|
||||||
|
inputs['token'] = 'faketoken';
|
||||||
|
|
||||||
|
// ... but not in the local cache
|
||||||
|
findSpy.mockImplementation(() => '');
|
||||||
|
findAllVersionsSpy.mockImplementation(() => []);
|
||||||
|
|
||||||
|
dlSpy.mockImplementation(async () => '/some/temp/path');
|
||||||
|
const toolPath = path.normalize(
|
||||||
|
'/cache/node/13.13.1-nightly20200415947ddec091/x64'
|
||||||
|
);
|
||||||
|
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
||||||
|
cacheSpy.mockImplementation(async () => toolPath);
|
||||||
|
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
const expPath = path.join(toolPath, 'bin');
|
||||||
|
|
||||||
|
expect(dlSpy).toHaveBeenCalled();
|
||||||
|
expect(exSpy).toHaveBeenCalled();
|
||||||
|
expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('windows: falls back to exe version if not in manifest and not in node dist', async () => {
|
||||||
|
os.platform = 'win32';
|
||||||
|
os.arch = 'x64';
|
||||||
|
|
||||||
|
// a version which is not in the manifest but is in node dist
|
||||||
|
const versionSpec = '13.13.1-nightly20200415947ddec091';
|
||||||
|
|
||||||
|
const workingUrls = [
|
||||||
|
`https://nodejs.org/download/nightly/v${versionSpec}/win-x64/node.exe`,
|
||||||
|
`https://nodejs.org/download/nightly/v${versionSpec}/win-x64/node.lib`
|
||||||
|
];
|
||||||
|
|
||||||
|
inputs['node-version'] = versionSpec;
|
||||||
|
inputs['token'] = 'faketoken';
|
||||||
|
|
||||||
|
// ... but not in the local cache
|
||||||
|
findSpy.mockImplementation(() => '');
|
||||||
|
findAllVersionsSpy.mockImplementation(() => []);
|
||||||
|
|
||||||
|
dlSpy.mockImplementation(async url => {
|
||||||
|
if (workingUrls.includes(url)) {
|
||||||
|
return '/some/temp/path';
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new tc.HTTPError(404);
|
||||||
|
});
|
||||||
|
const toolPath = path.normalize(
|
||||||
|
'/cache/node/13.13.1-nightly20200415947ddec091/x64'
|
||||||
|
);
|
||||||
|
cacheSpy.mockImplementation(async () => toolPath);
|
||||||
|
mkdirpSpy.mockImplementation(async () => {});
|
||||||
|
cpSpy.mockImplementation(async () => {});
|
||||||
|
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
workingUrls.forEach(url => {
|
||||||
|
expect(dlSpy).toHaveBeenCalledWith(url, undefined, undefined);
|
||||||
|
});
|
||||||
|
expect(cnSpy).toHaveBeenCalledWith(`::add-path::${toolPath}${osm.EOL}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('linux: does not fall back to exe version if not in manifest and not in node dist', async () => {
|
||||||
|
os.platform = 'linux';
|
||||||
|
os.arch = 'x64';
|
||||||
|
|
||||||
|
// a version which is not in the manifest but is in node dist
|
||||||
|
const versionSpec = '13.13.1-nightly20200415947ddec091';
|
||||||
|
|
||||||
|
const workingUrls = [
|
||||||
|
`https://nodejs.org/download/nightly/v${versionSpec}/win-x64/node.exe`,
|
||||||
|
`https://nodejs.org/download/nightly/v${versionSpec}/win-x64/node.lib`
|
||||||
|
];
|
||||||
|
|
||||||
|
inputs['node-version'] = versionSpec;
|
||||||
|
inputs['token'] = 'faketoken';
|
||||||
|
|
||||||
|
// ... but not in the local cache
|
||||||
|
findSpy.mockImplementation(() => '');
|
||||||
|
findAllVersionsSpy.mockImplementation(() => []);
|
||||||
|
|
||||||
|
dlSpy.mockImplementation(async url => {
|
||||||
|
if (workingUrls.includes(url)) {
|
||||||
|
return '/some/temp/path';
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new tc.HTTPError(404);
|
||||||
|
});
|
||||||
|
const toolPath = path.normalize(
|
||||||
|
'/cache/node/13.13.1-nightly20200415947ddec091/x64'
|
||||||
|
);
|
||||||
|
cacheSpy.mockImplementation(async () => toolPath);
|
||||||
|
mkdirpSpy.mockImplementation(async () => {});
|
||||||
|
cpSpy.mockImplementation(async () => {});
|
||||||
|
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
workingUrls.forEach(url => {
|
||||||
|
expect(dlSpy).not.toHaveBeenCalledWith(url);
|
||||||
|
});
|
||||||
|
expect(cnSpy).toHaveBeenCalledWith(
|
||||||
|
`::error::Unexpected HTTP response: 404${osm.EOL}`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does not find a version that does not exist', async () => {
|
||||||
|
os.platform = 'linux';
|
||||||
|
os.arch = 'x64';
|
||||||
|
|
||||||
|
const versionSpec = '10.13.1-nightly20200415947ddec091';
|
||||||
|
inputs['node-version'] = versionSpec;
|
||||||
|
|
||||||
|
findSpy.mockImplementation(() => '');
|
||||||
|
findAllVersionsSpy.mockImplementation(() => []);
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
expect(cnSpy).toHaveBeenCalledWith(
|
||||||
|
`::error::Unable to find Node version '${versionSpec}' for platform ${os.platform} and architecture ${os.arch}.${osm.EOL}`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('reports a failed download', async () => {
|
||||||
|
const errMsg = 'unhandled download message';
|
||||||
|
os.platform = 'linux';
|
||||||
|
os.arch = 'x64';
|
||||||
|
|
||||||
|
// a version which is in the manifest
|
||||||
|
const versionSpec = '18.0.0-nightly202204180699150267';
|
||||||
|
|
||||||
|
inputs['node-version'] = versionSpec;
|
||||||
|
inputs['token'] = 'faketoken';
|
||||||
|
|
||||||
|
findSpy.mockImplementation(() => '');
|
||||||
|
findAllVersionsSpy.mockImplementation(() => []);
|
||||||
|
|
||||||
|
dlSpy.mockImplementation(() => {
|
||||||
|
throw new Error(errMsg);
|
||||||
|
});
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
expect(cnSpy).toHaveBeenCalledWith(`::error::${errMsg}${osm.EOL}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('acquires specified architecture of node', async () => {
|
||||||
|
for (const {arch, version, osSpec} of [
|
||||||
|
{
|
||||||
|
arch: 'x86',
|
||||||
|
version: '18.0.0-nightly202110204cb3e06ed8',
|
||||||
|
osSpec: 'win32'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arch: 'x86',
|
||||||
|
version: '20.0.0-nightly2022101987cdf7d412',
|
||||||
|
osSpec: 'win32'
|
||||||
|
}
|
||||||
|
]) {
|
||||||
|
os.platform = osSpec;
|
||||||
|
os.arch = arch;
|
||||||
|
const fileExtension = os.platform === 'win32' ? '7z' : 'tar.gz';
|
||||||
|
const platform = {
|
||||||
|
linux: 'linux',
|
||||||
|
darwin: 'darwin',
|
||||||
|
win32: 'win'
|
||||||
|
}[os.platform];
|
||||||
|
|
||||||
|
inputs['node-version'] = version;
|
||||||
|
inputs['architecture'] = arch;
|
||||||
|
inputs['token'] = 'faketoken';
|
||||||
|
|
||||||
|
const expectedUrl = `https://nodejs.org/download/nightly/v${version}/node-v${version}-${platform}-${arch}.${fileExtension}`;
|
||||||
|
|
||||||
|
// ... but not in the local cache
|
||||||
|
findSpy.mockImplementation(() => '');
|
||||||
|
findAllVersionsSpy.mockImplementation(() => []);
|
||||||
|
|
||||||
|
dlSpy.mockImplementation(async () => '/some/temp/path');
|
||||||
|
const toolPath = path.normalize(`/cache/node/${version}/${arch}`);
|
||||||
|
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
||||||
|
cacheSpy.mockImplementation(async () => toolPath);
|
||||||
|
|
||||||
|
await main.run();
|
||||||
|
expect(dlSpy).toHaveBeenCalled();
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
`Acquiring ${version} - ${arch} from ${expectedUrl}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}, 100000);
|
||||||
|
|
||||||
|
it('acquires specified architecture of node from mirror', async () => {
|
||||||
|
for (const {arch, version, osSpec} of [
|
||||||
|
{
|
||||||
|
arch: 'x86',
|
||||||
|
version: '18.0.0-nightly202110204cb3e06ed8',
|
||||||
|
osSpec: 'win32'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
arch: 'x86',
|
||||||
|
version: '20.0.0-nightly2022101987cdf7d412',
|
||||||
|
osSpec: 'win32'
|
||||||
|
}
|
||||||
|
]) {
|
||||||
|
os.platform = osSpec;
|
||||||
|
os.arch = arch;
|
||||||
|
const fileExtension = os.platform === 'win32' ? '7z' : 'tar.gz';
|
||||||
|
const platform = {
|
||||||
|
linux: 'linux',
|
||||||
|
darwin: 'darwin',
|
||||||
|
win32: 'win'
|
||||||
|
}[os.platform];
|
||||||
|
|
||||||
|
inputs['node-version'] = version;
|
||||||
|
inputs['architecture'] = arch;
|
||||||
|
inputs['token'] = 'faketoken';
|
||||||
|
inputs['mirror'] = 'https://my-mirror.org';
|
||||||
|
inputs['mirror-token'] = 'my-mirror-token';
|
||||||
|
|
||||||
|
const expectedUrl = `https://my-mirror.org/download/nightly/v${version}/node-v${version}-${platform}-${arch}.${fileExtension}`;
|
||||||
|
|
||||||
|
// ... but not in the local cache
|
||||||
|
findSpy.mockImplementation(() => '');
|
||||||
|
findAllVersionsSpy.mockImplementation(() => []);
|
||||||
|
|
||||||
|
dlSpy.mockImplementation(async () => '/some/temp/path');
|
||||||
|
const toolPath = path.normalize(`/cache/node/${version}/${arch}`);
|
||||||
|
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
||||||
|
cacheSpy.mockImplementation(async () => toolPath);
|
||||||
|
|
||||||
|
await main.run();
|
||||||
|
expect(dlSpy).toHaveBeenCalled();
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
`Acquiring ${version} - ${arch} from ${expectedUrl}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}, 100000);
|
||||||
|
|
||||||
|
describe('nightly versions', () => {
|
||||||
|
it.each([
|
||||||
|
[
|
||||||
|
'17.5.0-nightly',
|
||||||
|
'17.5.0-nightly20220209e43808936a',
|
||||||
|
'https://nodejs.org/download/nightly/v17.5.0-nightly20220209e43808936a/node-v17.5.0-nightly20220209e43808936a-linux-x64.tar.gz'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'17-nightly',
|
||||||
|
'17.5.0-nightly20220209e43808936a',
|
||||||
|
'https://nodejs.org/download/nightly/v17.5.0-nightly20220209e43808936a/node-v17.5.0-nightly20220209e43808936a-linux-x64.tar.gz'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'18.0.0-nightly',
|
||||||
|
'18.0.0-nightly20220419bde889bd4e',
|
||||||
|
'https://nodejs.org/download/nightly/v18.0.0-nightly20220419bde889bd4e/node-v18.0.0-nightly20220419bde889bd4e-linux-x64.tar.gz'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'18-nightly',
|
||||||
|
'18.0.0-nightly20220419bde889bd4e',
|
||||||
|
'https://nodejs.org/download/nightly/v18.0.0-nightly20220419bde889bd4e/node-v18.0.0-nightly20220419bde889bd4e-linux-x64.tar.gz'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'20.0.0-nightly',
|
||||||
|
'20.0.0-nightly2022101987cdf7d412',
|
||||||
|
'https://nodejs.org/download/nightly/v20.0.0-nightly2022101987cdf7d412/node-v20.0.0-nightly2022101987cdf7d412-linux-x64.tar.gz'
|
||||||
|
]
|
||||||
|
])(
|
||||||
|
'finds the versions in the index.json and installs it',
|
||||||
|
async (input, expectedVersion, expectedUrl) => {
|
||||||
|
const toolPath = path.normalize(`/cache/node/${expectedVersion}/x64`);
|
||||||
|
|
||||||
|
findSpy.mockImplementation(() => '');
|
||||||
|
findAllVersionsSpy.mockImplementation(() => []);
|
||||||
|
dlSpy.mockImplementation(async () => '/some/temp/path');
|
||||||
|
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
||||||
|
cacheSpy.mockImplementation(async () => toolPath);
|
||||||
|
|
||||||
|
inputs['node-version'] = input;
|
||||||
|
os['arch'] = 'x64';
|
||||||
|
os['platform'] = 'linux';
|
||||||
|
// act
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
// assert
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
`Acquiring ${expectedVersion} - ${os.arch} from ${expectedUrl}`
|
||||||
|
);
|
||||||
|
expect(logSpy).toHaveBeenCalledWith('Extracting ...');
|
||||||
|
expect(logSpy).toHaveBeenCalledWith('Adding to the cache ...');
|
||||||
|
expect(cnSpy).toHaveBeenCalledWith(
|
||||||
|
`::add-path::${path.join(toolPath, 'bin')}${osm.EOL}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
it.each([
|
||||||
|
['17.5.0-nightly', '17.5.0-nightly20220209e43808936a'],
|
||||||
|
['17-nightly', '17.5.0-nightly20220209e43808936a'],
|
||||||
|
['20.0.0-nightly', '20.0.0-nightly2022101987cdf7d412']
|
||||||
|
])(
|
||||||
|
'finds the %s version in the hostedToolcache',
|
||||||
|
async (input, expectedVersion) => {
|
||||||
|
const toolPath = path.normalize(`/cache/node/${expectedVersion}/x64`);
|
||||||
|
findSpy.mockReturnValue(toolPath);
|
||||||
|
findAllVersionsSpy.mockReturnValue([
|
||||||
|
'17.5.0-nightly20220209e43808936a',
|
||||||
|
'17.5.0-nightly20220209e43808935a',
|
||||||
|
'20.0.0-nightly2022101987cdf7d412',
|
||||||
|
'20.0.0-nightly2022101987cdf7d411'
|
||||||
|
]);
|
||||||
|
|
||||||
|
inputs['node-version'] = input;
|
||||||
|
os['arch'] = 'x64';
|
||||||
|
os['platform'] = 'linux';
|
||||||
|
|
||||||
|
// act
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
// assert
|
||||||
|
expect(findAllVersionsSpy).toHaveBeenCalled();
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`);
|
||||||
|
expect(cnSpy).toHaveBeenCalledWith(
|
||||||
|
`::add-path::${path.join(toolPath, 'bin')}${osm.EOL}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
it.each([
|
||||||
|
[
|
||||||
|
'17.5.0-nightly',
|
||||||
|
'17.5.0-nightly20220209e43808936a',
|
||||||
|
'17.0.0-nightly202110193f11666dc7',
|
||||||
|
'https://nodejs.org/download/nightly/v17.5.0-nightly20220209e43808936a/node-v17.5.0-nightly20220209e43808936a-linux-x64.tar.gz'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'17-nightly',
|
||||||
|
'17.5.0-nightly20220209e43808936a',
|
||||||
|
'17.0.0-nightly202110193f11666dc7',
|
||||||
|
'https://nodejs.org/download/nightly/v17.5.0-nightly20220209e43808936a/node-v17.5.0-nightly20220209e43808936a-linux-x64.tar.gz'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'18.0.0-nightly',
|
||||||
|
'18.0.0-nightly20220419bde889bd4e',
|
||||||
|
'18.0.0-nightly202204180699150267',
|
||||||
|
'https://nodejs.org/download/nightly/v18.0.0-nightly20220419bde889bd4e/node-v18.0.0-nightly20220419bde889bd4e-linux-x64.tar.gz'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'18-nightly',
|
||||||
|
'18.0.0-nightly20220419bde889bd4e',
|
||||||
|
'18.0.0-nightly202204180699150267',
|
||||||
|
'https://nodejs.org/download/nightly/v18.0.0-nightly20220419bde889bd4e/node-v18.0.0-nightly20220419bde889bd4e-linux-x64.tar.gz'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'20.0.0-nightly',
|
||||||
|
'20.0.0-nightly2022101987cdf7d412',
|
||||||
|
'20.0.0-nightly2022101987cdf7d411',
|
||||||
|
'https://nodejs.org/download/nightly/v20.0.0-nightly2022101987cdf7d412/node-v20.0.0-nightly2022101987cdf7d412-linux-x64.tar.gz'
|
||||||
|
]
|
||||||
|
])(
|
||||||
|
'get %s version from dist if check-latest is true',
|
||||||
|
async (input, expectedVersion, foundVersion, expectedUrl) => {
|
||||||
|
const foundToolPath = path.normalize(`/cache/node/${foundVersion}/x64`);
|
||||||
|
const toolPath = path.normalize(`/cache/node/${expectedVersion}/x64`);
|
||||||
|
|
||||||
|
inputs['node-version'] = input;
|
||||||
|
inputs['check-latest'] = 'true';
|
||||||
|
os['arch'] = 'x64';
|
||||||
|
os['platform'] = 'linux';
|
||||||
|
|
||||||
|
findSpy.mockReturnValue(foundToolPath);
|
||||||
|
findAllVersionsSpy.mockReturnValue([
|
||||||
|
'17.0.0-nightly202110193f11666dc7',
|
||||||
|
'18.0.0-nightly202204180699150267',
|
||||||
|
'20.0.0-nightly2022101987cdf7d411'
|
||||||
|
]);
|
||||||
|
dlSpy.mockImplementation(async () => '/some/temp/path');
|
||||||
|
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
||||||
|
cacheSpy.mockImplementation(async () => toolPath);
|
||||||
|
|
||||||
|
// act
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
// assert
|
||||||
|
expect(findAllVersionsSpy).toHaveBeenCalled();
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
`Acquiring ${expectedVersion} - ${os.arch} from ${expectedUrl}`
|
||||||
|
);
|
||||||
|
expect(logSpy).toHaveBeenCalledWith('Extracting ...');
|
||||||
|
expect(logSpy).toHaveBeenCalledWith('Adding to the cache ...');
|
||||||
|
expect(cnSpy).toHaveBeenCalledWith(
|
||||||
|
`::add-path::${path.join(toolPath, 'bin')}${osm.EOL}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -0,0 +1,901 @@
|
||||||
|
import * as core from '@actions/core';
|
||||||
|
import * as io from '@actions/io';
|
||||||
|
import * as tc from '@actions/tool-cache';
|
||||||
|
import * as httpm from '@actions/http-client';
|
||||||
|
import * as exec from '@actions/exec';
|
||||||
|
import * as cache from '@actions/cache';
|
||||||
|
import fs from 'fs';
|
||||||
|
import cp from 'child_process';
|
||||||
|
import osm from 'os';
|
||||||
|
import path from 'path';
|
||||||
|
import * as main from '../src/main';
|
||||||
|
import * as auth from '../src/authutil';
|
||||||
|
import OfficialBuilds from '../src/distributions/official_builds/official_builds';
|
||||||
|
import {INodeVersion} from '../src/distributions/base-models';
|
||||||
|
|
||||||
|
import nodeTestManifest from './data/versions-manifest.json';
|
||||||
|
import nodeTestDist from './data/node-dist-index.json';
|
||||||
|
import nodeTestDistNightly from './data/node-nightly-index.json';
|
||||||
|
import nodeTestDistRc from './data/node-rc-index.json';
|
||||||
|
import nodeV8CanaryTestDist from './data/v8-canary-dist-index.json';
|
||||||
|
|
||||||
|
describe('setup-node', () => {
|
||||||
|
let build: OfficialBuilds;
|
||||||
|
let inputs = {} as any;
|
||||||
|
let os = {} as any;
|
||||||
|
|
||||||
|
let inSpy: jest.SpyInstance;
|
||||||
|
let findSpy: jest.SpyInstance;
|
||||||
|
let findAllVersionsSpy: jest.SpyInstance;
|
||||||
|
let cnSpy: jest.SpyInstance;
|
||||||
|
let logSpy: jest.SpyInstance;
|
||||||
|
let warningSpy: jest.SpyInstance;
|
||||||
|
let getManifestSpy: jest.SpyInstance;
|
||||||
|
let platSpy: jest.SpyInstance;
|
||||||
|
let archSpy: jest.SpyInstance;
|
||||||
|
let dlSpy: jest.SpyInstance;
|
||||||
|
let exSpy: jest.SpyInstance;
|
||||||
|
let cacheSpy: jest.SpyInstance;
|
||||||
|
let dbgSpy: jest.SpyInstance;
|
||||||
|
let whichSpy: jest.SpyInstance;
|
||||||
|
let existsSpy: jest.SpyInstance;
|
||||||
|
let readFileSyncSpy: jest.SpyInstance;
|
||||||
|
let mkdirpSpy: jest.SpyInstance;
|
||||||
|
let execSpy: jest.SpyInstance;
|
||||||
|
let authSpy: jest.SpyInstance;
|
||||||
|
let isCacheActionAvailable: jest.SpyInstance;
|
||||||
|
let getExecOutputSpy: jest.SpyInstance;
|
||||||
|
let getJsonSpy: jest.SpyInstance;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
// @actions/core
|
||||||
|
console.log('::stop-commands::stoptoken'); // Disable executing of runner commands when running tests in actions
|
||||||
|
process.env['GITHUB_PATH'] = ''; // Stub out ENV file functionality so we can verify it writes to standard out
|
||||||
|
process.env['GITHUB_OUTPUT'] = ''; // Stub out ENV file functionality so we can verify it writes to standard out
|
||||||
|
inputs = {};
|
||||||
|
inSpy = jest.spyOn(core, 'getInput');
|
||||||
|
inSpy.mockImplementation(name => inputs[name]);
|
||||||
|
|
||||||
|
// node
|
||||||
|
os = {};
|
||||||
|
platSpy = jest.spyOn(osm, 'platform');
|
||||||
|
platSpy.mockImplementation(() => os['platform']);
|
||||||
|
archSpy = jest.spyOn(osm, 'arch');
|
||||||
|
archSpy.mockImplementation(() => os['arch']);
|
||||||
|
execSpy = jest.spyOn(cp, 'execSync');
|
||||||
|
|
||||||
|
// @actions/tool-cache
|
||||||
|
findSpy = jest.spyOn(tc, 'find');
|
||||||
|
findAllVersionsSpy = jest.spyOn(tc, 'findAllVersions');
|
||||||
|
dlSpy = jest.spyOn(tc, 'downloadTool');
|
||||||
|
exSpy = jest.spyOn(tc, 'extractTar');
|
||||||
|
cacheSpy = jest.spyOn(tc, 'cacheDir');
|
||||||
|
getManifestSpy = jest.spyOn(tc, 'getManifestFromRepo');
|
||||||
|
|
||||||
|
// http-client
|
||||||
|
getJsonSpy = jest.spyOn(httpm.HttpClient.prototype, 'getJson');
|
||||||
|
|
||||||
|
// io
|
||||||
|
whichSpy = jest.spyOn(io, 'which');
|
||||||
|
existsSpy = jest.spyOn(fs, 'existsSync');
|
||||||
|
mkdirpSpy = jest.spyOn(io, 'mkdirP');
|
||||||
|
|
||||||
|
// @actions/tool-cache
|
||||||
|
isCacheActionAvailable = jest.spyOn(cache, 'isFeatureAvailable');
|
||||||
|
|
||||||
|
// disable authentication portion for installer tests
|
||||||
|
authSpy = jest.spyOn(auth, 'configAuthentication');
|
||||||
|
authSpy.mockImplementation(() => {});
|
||||||
|
|
||||||
|
// gets
|
||||||
|
getManifestSpy.mockImplementation(
|
||||||
|
() => <tc.IToolRelease[]>nodeTestManifest
|
||||||
|
);
|
||||||
|
|
||||||
|
getJsonSpy.mockImplementation(url => {
|
||||||
|
let res: any;
|
||||||
|
if (url.includes('/rc')) {
|
||||||
|
res = <INodeVersion[]>nodeTestDistRc;
|
||||||
|
} else if (url.includes('/nightly')) {
|
||||||
|
res = <INodeVersion[]>nodeTestDistNightly;
|
||||||
|
} else {
|
||||||
|
res = <INodeVersion[]>nodeTestDist;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {result: res};
|
||||||
|
});
|
||||||
|
|
||||||
|
// writes
|
||||||
|
cnSpy = jest.spyOn(process.stdout, 'write');
|
||||||
|
logSpy = jest.spyOn(core, 'info');
|
||||||
|
dbgSpy = jest.spyOn(core, 'debug');
|
||||||
|
warningSpy = jest.spyOn(core, 'warning');
|
||||||
|
cnSpy.mockImplementation(line => {
|
||||||
|
// uncomment to debug
|
||||||
|
process.stderr.write('write:' + line + '\n');
|
||||||
|
});
|
||||||
|
logSpy.mockImplementation(line => {
|
||||||
|
// uncomment to debug
|
||||||
|
process.stderr.write('log:' + line + '\n');
|
||||||
|
});
|
||||||
|
dbgSpy.mockImplementation(msg => {
|
||||||
|
// uncomment to see debug output
|
||||||
|
// process.stderr.write(msg + '\n');
|
||||||
|
});
|
||||||
|
warningSpy.mockImplementation(msg => {
|
||||||
|
// uncomment to debug
|
||||||
|
// process.stderr.write('log:' + msg + '\n');
|
||||||
|
});
|
||||||
|
|
||||||
|
// @actions/exec
|
||||||
|
getExecOutputSpy = jest.spyOn(exec, 'getExecOutput');
|
||||||
|
getExecOutputSpy.mockImplementation(() => 'v16.15.0');
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
jest.resetAllMocks();
|
||||||
|
jest.clearAllMocks();
|
||||||
|
//jest.restoreAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(async () => {
|
||||||
|
console.log('::stoptoken::'); // Re-enable executing of runner commands when running tests in actions
|
||||||
|
jest.restoreAllMocks();
|
||||||
|
}, 100000);
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// Manifest find tests
|
||||||
|
//--------------------------------------------------
|
||||||
|
it.each([
|
||||||
|
['12.16.2', 'darwin', '12.16.2', 'Erbium'],
|
||||||
|
['12', 'linux', '12.16.2', 'Erbium'],
|
||||||
|
['10', 'win32', '10.20.1', 'Dubnium'],
|
||||||
|
['*', 'linux', '14.0.0', 'Fermium']
|
||||||
|
])(
|
||||||
|
'can find %s from manifest on %s',
|
||||||
|
async (versionSpec, platform, expectedVersion, expectedLts) => {
|
||||||
|
os.platform = platform;
|
||||||
|
os.arch = 'x64';
|
||||||
|
const versions: tc.IToolRelease[] | null = await tc.getManifestFromRepo(
|
||||||
|
'actions',
|
||||||
|
'node-versions',
|
||||||
|
'mocktoken'
|
||||||
|
);
|
||||||
|
expect(versions).toBeDefined();
|
||||||
|
const match = await tc.findFromManifest(versionSpec, true, versions);
|
||||||
|
expect(match).toBeDefined();
|
||||||
|
expect(match?.version).toBe(expectedVersion);
|
||||||
|
expect((match as any).lts).toBe(expectedLts);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// Found in cache tests
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
|
it('finds version in cache with stable true', async () => {
|
||||||
|
inputs['node-version'] = '12';
|
||||||
|
inputs.stable = 'true';
|
||||||
|
|
||||||
|
const toolPath = path.normalize('/cache/node/12.16.1/x64');
|
||||||
|
findSpy.mockImplementation(() => toolPath);
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('finds version in cache with stable not supplied', async () => {
|
||||||
|
inputs['node-version'] = '12';
|
||||||
|
|
||||||
|
inSpy.mockImplementation(name => inputs[name]);
|
||||||
|
|
||||||
|
const toolPath = path.normalize('/cache/node/12.16.1/x64');
|
||||||
|
findSpy.mockImplementation(() => toolPath);
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('finds version in cache and adds it to the path', async () => {
|
||||||
|
inputs['node-version'] = '12';
|
||||||
|
|
||||||
|
inSpy.mockImplementation(name => inputs[name]);
|
||||||
|
|
||||||
|
const toolPath = path.normalize('/cache/node/12.16.1/x64');
|
||||||
|
findSpy.mockImplementation(() => toolPath);
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
const expPath = path.join(toolPath, 'bin');
|
||||||
|
expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('handles unhandled find error and reports error', async () => {
|
||||||
|
const errMsg = 'unhandled error message';
|
||||||
|
inputs['node-version'] = '12';
|
||||||
|
|
||||||
|
findSpy.mockImplementation(() => {
|
||||||
|
throw new Error(errMsg);
|
||||||
|
});
|
||||||
|
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
expect(cnSpy).toHaveBeenCalledWith('::error::' + errMsg + osm.EOL);
|
||||||
|
});
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// Manifest tests
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
|
it('downloads a version from a manifest match', async () => {
|
||||||
|
os.platform = 'linux';
|
||||||
|
os.arch = 'x64';
|
||||||
|
|
||||||
|
// a version which is in the manifest
|
||||||
|
const versionSpec = '12.16.2';
|
||||||
|
const resolvedVersion = versionSpec;
|
||||||
|
|
||||||
|
inputs['node-version'] = versionSpec;
|
||||||
|
inputs['token'] = 'faketoken';
|
||||||
|
|
||||||
|
const expectedUrl =
|
||||||
|
'https://github.com/actions/node-versions/releases/download/12.16.2-20200507.95/node-12.16.2-linux-x64.tar.gz';
|
||||||
|
|
||||||
|
// ... but not in the local cache
|
||||||
|
findSpy.mockImplementation(() => '');
|
||||||
|
|
||||||
|
dlSpy.mockImplementation(async () => '/some/temp/path');
|
||||||
|
const toolPath = path.normalize('/cache/node/12.16.2/x64');
|
||||||
|
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
||||||
|
cacheSpy.mockImplementation(async () => toolPath);
|
||||||
|
whichSpy.mockImplementation(cmd => {
|
||||||
|
return `some/${cmd}/path`;
|
||||||
|
});
|
||||||
|
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
const expPath = path.join(toolPath, 'bin');
|
||||||
|
|
||||||
|
expect(getExecOutputSpy).toHaveBeenCalledWith(
|
||||||
|
'node',
|
||||||
|
['--version'],
|
||||||
|
expect.anything()
|
||||||
|
);
|
||||||
|
expect(getExecOutputSpy).toHaveBeenCalledWith(
|
||||||
|
'npm',
|
||||||
|
['--version'],
|
||||||
|
expect.anything()
|
||||||
|
);
|
||||||
|
expect(getExecOutputSpy).toHaveBeenCalledWith(
|
||||||
|
'yarn',
|
||||||
|
['--version'],
|
||||||
|
expect.anything()
|
||||||
|
);
|
||||||
|
expect(dlSpy).toHaveBeenCalled();
|
||||||
|
expect(exSpy).toHaveBeenCalled();
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
`Acquiring ${resolvedVersion} - ${os.arch} from ${expectedUrl}`
|
||||||
|
);
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
`Attempting to download ${versionSpec}...`
|
||||||
|
);
|
||||||
|
expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('falls back to a version from node dist from mirror', async () => {
|
||||||
|
os.platform = 'linux';
|
||||||
|
os.arch = 'x64';
|
||||||
|
|
||||||
|
// a version which is not in the manifest but is in node dist
|
||||||
|
const versionSpec = '11.15.0';
|
||||||
|
const mirror = 'https://my_mirror_url';
|
||||||
|
inputs['node-version'] = versionSpec;
|
||||||
|
inputs['token'] = 'faketoken';
|
||||||
|
inputs['mirror'] = mirror;
|
||||||
|
inputs['mirror-token'] = 'faketoken';
|
||||||
|
|
||||||
|
// ... but not in the local cache
|
||||||
|
findSpy.mockImplementation(() => '');
|
||||||
|
|
||||||
|
dlSpy.mockImplementation(async () => '/some/temp/path');
|
||||||
|
const toolPath = path.normalize('/cache/node/11.15.0/x64');
|
||||||
|
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
||||||
|
cacheSpy.mockImplementation(async () => toolPath);
|
||||||
|
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
const expPath = path.join(toolPath, 'bin');
|
||||||
|
|
||||||
|
expect(getManifestSpy).toHaveBeenCalled();
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
`Attempting to download ${versionSpec}...`
|
||||||
|
);
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
`Not found in manifest. Falling back to download directly from ${mirror}`
|
||||||
|
);
|
||||||
|
expect(dlSpy).toHaveBeenCalled();
|
||||||
|
expect(exSpy).toHaveBeenCalled();
|
||||||
|
expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('falls back to a version from node dist', async () => {
|
||||||
|
os.platform = 'linux';
|
||||||
|
os.arch = 'x64';
|
||||||
|
|
||||||
|
// a version which is not in the manifest but is in node dist
|
||||||
|
const versionSpec = '11.15.0';
|
||||||
|
|
||||||
|
inputs['node-version'] = versionSpec;
|
||||||
|
inputs['token'] = 'faketoken';
|
||||||
|
|
||||||
|
// ... but not in the local cache
|
||||||
|
findSpy.mockImplementation(() => '');
|
||||||
|
|
||||||
|
dlSpy.mockImplementation(async () => '/some/temp/path');
|
||||||
|
const toolPath = path.normalize('/cache/node/11.15.0/x64');
|
||||||
|
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
||||||
|
cacheSpy.mockImplementation(async () => toolPath);
|
||||||
|
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
const expPath = path.join(toolPath, 'bin');
|
||||||
|
|
||||||
|
expect(getManifestSpy).toHaveBeenCalled();
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
`Attempting to download ${versionSpec}...`
|
||||||
|
);
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
'Not found in manifest. Falling back to download directly from Node'
|
||||||
|
);
|
||||||
|
expect(dlSpy).toHaveBeenCalled();
|
||||||
|
expect(exSpy).toHaveBeenCalled();
|
||||||
|
expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does not find a version that does not exist', async () => {
|
||||||
|
os.platform = 'linux';
|
||||||
|
os.arch = 'x64';
|
||||||
|
|
||||||
|
const versionSpec = '9.99.9';
|
||||||
|
inputs['node-version'] = versionSpec;
|
||||||
|
|
||||||
|
findSpy.mockImplementation(() => '');
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
'Not found in manifest. Falling back to download directly from Node'
|
||||||
|
);
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
`Attempting to download ${versionSpec}...`
|
||||||
|
);
|
||||||
|
expect(cnSpy).toHaveBeenCalledWith(
|
||||||
|
`::error::Unable to find Node version '${versionSpec}' for platform ${os.platform} and architecture ${os.arch}.${osm.EOL}`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('reports a failed download', async () => {
|
||||||
|
const errMsg = 'unhandled download message';
|
||||||
|
os.platform = 'linux';
|
||||||
|
os.arch = 'x64';
|
||||||
|
|
||||||
|
// a version which is in the manifest
|
||||||
|
const versionSpec = '12.16.2';
|
||||||
|
const resolvedVersion = versionSpec;
|
||||||
|
|
||||||
|
inputs['node-version'] = versionSpec;
|
||||||
|
inputs['token'] = 'faketoken';
|
||||||
|
|
||||||
|
findSpy.mockImplementation(() => '');
|
||||||
|
dlSpy.mockImplementation(() => {
|
||||||
|
throw new Error(errMsg);
|
||||||
|
});
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
expect(cnSpy).toHaveBeenCalledWith(`::error::${errMsg}${osm.EOL}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('reports when download failed but version exists', async () => {
|
||||||
|
os.platform = 'linux';
|
||||||
|
os.arch = 'x64';
|
||||||
|
|
||||||
|
// a version which is not in the manifest but is in node dist
|
||||||
|
const versionSpec = '11.15.0';
|
||||||
|
|
||||||
|
inputs['node-version'] = versionSpec;
|
||||||
|
inputs['token'] = 'faketoken';
|
||||||
|
|
||||||
|
// ... but not in the local cache
|
||||||
|
findSpy.mockImplementation(() => '');
|
||||||
|
|
||||||
|
dlSpy.mockImplementationOnce(async () => {
|
||||||
|
throw new tc.HTTPError(404);
|
||||||
|
});
|
||||||
|
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
expect(getManifestSpy).toHaveBeenCalled();
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
`Attempting to download ${versionSpec}...`
|
||||||
|
);
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
'Not found in manifest. Falling back to download directly from Node'
|
||||||
|
);
|
||||||
|
expect(dlSpy).toHaveBeenCalled();
|
||||||
|
expect(warningSpy).toHaveBeenCalledWith(
|
||||||
|
`Node version ${versionSpec} for platform ${os.platform} and architecture ${os.arch} was found but failed to download. ` +
|
||||||
|
'This usually happens when downloadable binaries are not fully updated at https://nodejs.org/. ' +
|
||||||
|
'To resolve this issue you may either fall back to the older version or try again later.'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('acquires specified architecture of node', async () => {
|
||||||
|
for (const {arch, version, osSpec} of [
|
||||||
|
{arch: 'x86', version: '12.16.2', osSpec: 'win32'},
|
||||||
|
{arch: 'x86', version: '14.0.0', osSpec: 'win32'}
|
||||||
|
]) {
|
||||||
|
os.platform = osSpec;
|
||||||
|
os.arch = arch;
|
||||||
|
const fileExtension = os.platform === 'win32' ? '7z' : 'tar.gz';
|
||||||
|
const platform = {
|
||||||
|
linux: 'linux',
|
||||||
|
darwin: 'darwin',
|
||||||
|
win32: 'win'
|
||||||
|
}[os.platform];
|
||||||
|
|
||||||
|
inputs['node-version'] = version;
|
||||||
|
inputs['architecture'] = arch;
|
||||||
|
inputs['token'] = 'faketoken';
|
||||||
|
|
||||||
|
const expectedUrl =
|
||||||
|
arch === 'x64'
|
||||||
|
? `https://github.com/actions/node-versions/releases/download/${version}/node-${version}-${platform}-${arch}.zip`
|
||||||
|
: `https://nodejs.org/dist/v${version}/node-v${version}-${platform}-${arch}.${fileExtension}`;
|
||||||
|
|
||||||
|
// ... but not in the local cache
|
||||||
|
findSpy.mockImplementation(() => '');
|
||||||
|
|
||||||
|
dlSpy.mockImplementation(async () => '/some/temp/path');
|
||||||
|
const toolPath = path.normalize(`/cache/node/${version}/${arch}`);
|
||||||
|
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
||||||
|
cacheSpy.mockImplementation(async () => toolPath);
|
||||||
|
|
||||||
|
await main.run();
|
||||||
|
expect(dlSpy).toHaveBeenCalled();
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
`Acquiring ${version} - ${arch} from ${expectedUrl}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}, 100000);
|
||||||
|
|
||||||
|
describe('check-latest flag', () => {
|
||||||
|
it('use local version and dont check manifest if check-latest is not specified', async () => {
|
||||||
|
os.platform = 'linux';
|
||||||
|
os.arch = 'x64';
|
||||||
|
|
||||||
|
inputs['node-version'] = '12';
|
||||||
|
inputs['check-latest'] = 'false';
|
||||||
|
|
||||||
|
const toolPath = path.normalize('/cache/node/12.16.1/x64');
|
||||||
|
findSpy.mockReturnValue(toolPath);
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`);
|
||||||
|
expect(logSpy).not.toHaveBeenCalledWith(
|
||||||
|
'Attempt to resolve the latest version from manifest...'
|
||||||
|
);
|
||||||
|
expect(dbgSpy).not.toHaveBeenCalledWith('No manifest cached');
|
||||||
|
expect(dbgSpy).not.toHaveBeenCalledWith(
|
||||||
|
'Getting manifest from actions/node-versions@main'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('check latest version and resolve it from local cache', async () => {
|
||||||
|
os.platform = 'linux';
|
||||||
|
os.arch = 'x64';
|
||||||
|
|
||||||
|
inputs['node-version'] = '12';
|
||||||
|
inputs['check-latest'] = 'true';
|
||||||
|
|
||||||
|
const toolPath = path.normalize('/cache/node/12.16.2/x64');
|
||||||
|
findSpy.mockReturnValue(toolPath);
|
||||||
|
dlSpy.mockImplementation(async () => '/some/temp/path');
|
||||||
|
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
||||||
|
cacheSpy.mockImplementation(async () => toolPath);
|
||||||
|
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
'Attempt to resolve the latest version from manifest...'
|
||||||
|
);
|
||||||
|
expect(dbgSpy).toHaveBeenCalledWith('No manifest cached');
|
||||||
|
expect(dbgSpy).toHaveBeenCalledWith(
|
||||||
|
'Getting manifest from actions/node-versions@main'
|
||||||
|
);
|
||||||
|
expect(logSpy).toHaveBeenCalledWith("Resolved as '12.16.2'");
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('check latest version and install it from manifest', async () => {
|
||||||
|
os.platform = 'linux';
|
||||||
|
os.arch = 'x64';
|
||||||
|
|
||||||
|
inputs['node-version'] = '12';
|
||||||
|
inputs['check-latest'] = 'true';
|
||||||
|
|
||||||
|
findSpy.mockImplementation(() => '');
|
||||||
|
dlSpy.mockImplementation(async () => '/some/temp/path');
|
||||||
|
const toolPath = path.normalize('/cache/node/12.16.2/x64');
|
||||||
|
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
||||||
|
cacheSpy.mockImplementation(async () => toolPath);
|
||||||
|
const expectedUrl =
|
||||||
|
'https://github.com/actions/node-versions/releases/download/12.16.2-20200507.95/node-12.16.2-linux-x64.tar.gz';
|
||||||
|
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
'Attempt to resolve the latest version from manifest...'
|
||||||
|
);
|
||||||
|
expect(dbgSpy).toHaveBeenCalledWith('No manifest cached');
|
||||||
|
expect(dbgSpy).toHaveBeenCalledWith(
|
||||||
|
'Getting manifest from actions/node-versions@main'
|
||||||
|
);
|
||||||
|
expect(logSpy).toHaveBeenCalledWith("Resolved as '12.16.2'");
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
`Acquiring 12.16.2 - ${os.arch} from ${expectedUrl}`
|
||||||
|
);
|
||||||
|
expect(logSpy).toHaveBeenCalledWith('Extracting ...');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('fallback to dist if version if not found in manifest', async () => {
|
||||||
|
os.platform = 'linux';
|
||||||
|
os.arch = 'x64';
|
||||||
|
|
||||||
|
// a version which is not in the manifest but is in node dist
|
||||||
|
const versionSpec = '11';
|
||||||
|
|
||||||
|
inputs['node-version'] = versionSpec;
|
||||||
|
inputs['check-latest'] = 'true';
|
||||||
|
inputs['token'] = 'faketoken';
|
||||||
|
|
||||||
|
// ... but not in the local cache
|
||||||
|
findSpy.mockImplementation(() => '');
|
||||||
|
|
||||||
|
dlSpy.mockImplementation(async () => '/some/temp/path');
|
||||||
|
const toolPath = path.normalize('/cache/node/11.11.0/x64');
|
||||||
|
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
||||||
|
cacheSpy.mockImplementation(async () => toolPath);
|
||||||
|
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
const expPath = path.join(toolPath, 'bin');
|
||||||
|
|
||||||
|
expect(dlSpy).toHaveBeenCalled();
|
||||||
|
expect(exSpy).toHaveBeenCalled();
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
'Attempt to resolve the latest version from manifest...'
|
||||||
|
);
|
||||||
|
expect(dbgSpy).toHaveBeenCalledWith('No manifest cached');
|
||||||
|
expect(dbgSpy).toHaveBeenCalledWith(
|
||||||
|
'Getting manifest from actions/node-versions@main'
|
||||||
|
);
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
`Failed to resolve version ${versionSpec} from manifest`
|
||||||
|
);
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
`Attempting to download ${versionSpec}...`
|
||||||
|
);
|
||||||
|
expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('fallback to dist if manifest is not available', async () => {
|
||||||
|
os.platform = 'linux';
|
||||||
|
os.arch = 'x64';
|
||||||
|
|
||||||
|
// a version which is not in the manifest but is in node dist
|
||||||
|
const versionSpec = '12';
|
||||||
|
|
||||||
|
inputs['node-version'] = versionSpec;
|
||||||
|
inputs['check-latest'] = 'true';
|
||||||
|
inputs['token'] = 'faketoken';
|
||||||
|
|
||||||
|
// ... but not in the local cache
|
||||||
|
findSpy.mockImplementation(() => '');
|
||||||
|
getManifestSpy.mockImplementation(() => {
|
||||||
|
throw new Error('Unable to download manifest');
|
||||||
|
});
|
||||||
|
|
||||||
|
dlSpy.mockImplementation(async () => '/some/temp/path');
|
||||||
|
const toolPath = path.normalize('/cache/node/12.11.0/x64');
|
||||||
|
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
||||||
|
cacheSpy.mockImplementation(async () => toolPath);
|
||||||
|
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
const expPath = path.join(toolPath, 'bin');
|
||||||
|
|
||||||
|
expect(dlSpy).toHaveBeenCalled();
|
||||||
|
expect(exSpy).toHaveBeenCalled();
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
'Attempt to resolve the latest version from manifest...'
|
||||||
|
);
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
'Unable to resolve version from manifest...'
|
||||||
|
);
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
`Failed to resolve version ${versionSpec} from manifest`
|
||||||
|
);
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
`Attempting to download ${versionSpec}...`
|
||||||
|
);
|
||||||
|
expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('LTS version', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
os.platform = 'linux';
|
||||||
|
os.arch = 'x64';
|
||||||
|
inputs.stable = 'true';
|
||||||
|
});
|
||||||
|
|
||||||
|
it.each([
|
||||||
|
['erbium', '12.16.2'],
|
||||||
|
['*', '14.0.0'],
|
||||||
|
['-1', '12.16.2']
|
||||||
|
])(
|
||||||
|
'find latest LTS version and resolve it from local cache (lts/%s)',
|
||||||
|
async (lts, expectedVersion) => {
|
||||||
|
// arrange
|
||||||
|
inputs['node-version'] = `lts/${lts}`;
|
||||||
|
|
||||||
|
const toolPath = path.normalize(`/cache/node/${expectedVersion}/x64`);
|
||||||
|
findSpy.mockReturnValue(toolPath);
|
||||||
|
|
||||||
|
// act
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
// assert
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
'Attempt to resolve LTS alias from manifest...'
|
||||||
|
);
|
||||||
|
expect(dbgSpy).toHaveBeenCalledWith(
|
||||||
|
'Getting manifest from actions/node-versions@main'
|
||||||
|
);
|
||||||
|
expect(dbgSpy).not.toHaveBeenCalledWith('No manifest cached');
|
||||||
|
expect(dbgSpy).toHaveBeenCalledWith(
|
||||||
|
`LTS alias '${lts}' for Node version 'lts/${lts}'`
|
||||||
|
);
|
||||||
|
expect(dbgSpy).toHaveBeenCalledWith(
|
||||||
|
`Found LTS release '${expectedVersion}' for Node version 'lts/${lts}'`
|
||||||
|
);
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`);
|
||||||
|
expect(cnSpy).toHaveBeenCalledWith(
|
||||||
|
`::add-path::${path.join(toolPath, 'bin')}${osm.EOL}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
it.each([
|
||||||
|
[
|
||||||
|
'erbium',
|
||||||
|
'12.16.2',
|
||||||
|
'https://github.com/actions/node-versions/releases/download/12.16.2-20200507.95/node-12.16.2-linux-x64.tar.gz'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'*',
|
||||||
|
'14.0.0',
|
||||||
|
'https://github.com/actions/node-versions/releases/download/14.0.0-20200507.99/node-14.0.0-linux-x64.tar.gz'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'-1',
|
||||||
|
'12.16.2',
|
||||||
|
'https://github.com/actions/node-versions/releases/download/12.16.2-20200507.95/node-12.16.2-linux-x64.tar.gz'
|
||||||
|
]
|
||||||
|
])(
|
||||||
|
'find latest LTS version and install it from manifest (lts/%s)',
|
||||||
|
async (lts, expectedVersion, expectedUrl) => {
|
||||||
|
// arrange
|
||||||
|
inputs['node-version'] = `lts/${lts}`;
|
||||||
|
|
||||||
|
const toolPath = path.normalize(`/cache/node/${expectedVersion}/x64`);
|
||||||
|
findSpy.mockImplementation(() => '');
|
||||||
|
dlSpy.mockImplementation(async () => '/some/temp/path');
|
||||||
|
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
||||||
|
cacheSpy.mockImplementation(async () => toolPath);
|
||||||
|
const expectedMajor = expectedVersion.split('.')[0];
|
||||||
|
|
||||||
|
// act
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
// assert
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
'Attempt to resolve LTS alias from manifest...'
|
||||||
|
);
|
||||||
|
expect(dbgSpy).toHaveBeenCalledWith(
|
||||||
|
'Getting manifest from actions/node-versions@main'
|
||||||
|
);
|
||||||
|
expect(dbgSpy).not.toHaveBeenCalledWith('No manifest cached');
|
||||||
|
expect(dbgSpy).toHaveBeenCalledWith(
|
||||||
|
`LTS alias '${lts}' for Node version 'lts/${lts}'`
|
||||||
|
);
|
||||||
|
expect(dbgSpy).toHaveBeenCalledWith(
|
||||||
|
`Found LTS release '${expectedVersion}' for Node version 'lts/${lts}'`
|
||||||
|
);
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
`Attempting to download ${expectedMajor}...`
|
||||||
|
);
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
`Acquiring ${expectedVersion} - ${os.arch} from ${expectedUrl}`
|
||||||
|
);
|
||||||
|
expect(logSpy).toHaveBeenCalledWith('Extracting ...');
|
||||||
|
expect(logSpy).toHaveBeenCalledWith('Adding to the cache ...');
|
||||||
|
expect(cnSpy).toHaveBeenCalledWith(
|
||||||
|
`::add-path::${path.join(toolPath, 'bin')}${osm.EOL}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
it('fail with unable to parse LTS alias (lts/)', async () => {
|
||||||
|
// arrange
|
||||||
|
inputs['node-version'] = 'lts/';
|
||||||
|
|
||||||
|
findSpy.mockImplementation(() => '');
|
||||||
|
|
||||||
|
// act
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
// assert
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
'Attempt to resolve LTS alias from manifest...'
|
||||||
|
);
|
||||||
|
expect(dbgSpy).toHaveBeenCalledWith(
|
||||||
|
'Getting manifest from actions/node-versions@main'
|
||||||
|
);
|
||||||
|
expect(cnSpy).toHaveBeenCalledWith(
|
||||||
|
`::error::Unable to parse LTS alias for Node version 'lts/'${osm.EOL}`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('fail to find LTS version (lts/unknown)', async () => {
|
||||||
|
// arrange
|
||||||
|
inputs['node-version'] = 'lts/unknown';
|
||||||
|
|
||||||
|
findSpy.mockImplementation(() => '');
|
||||||
|
|
||||||
|
// act
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
// assert
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
'Attempt to resolve LTS alias from manifest...'
|
||||||
|
);
|
||||||
|
expect(dbgSpy).toHaveBeenCalledWith(
|
||||||
|
'Getting manifest from actions/node-versions@main'
|
||||||
|
);
|
||||||
|
expect(dbgSpy).toHaveBeenCalledWith(
|
||||||
|
`LTS alias 'unknown' for Node version 'lts/unknown'`
|
||||||
|
);
|
||||||
|
expect(cnSpy).toHaveBeenCalledWith(
|
||||||
|
`::error::Unable to find LTS release 'unknown' for Node version 'lts/unknown'.${osm.EOL}`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('fail if manifest is not available', async () => {
|
||||||
|
// arrange
|
||||||
|
inputs['node-version'] = 'lts/erbium';
|
||||||
|
|
||||||
|
// ... but not in the local cache
|
||||||
|
findSpy.mockImplementation(() => '');
|
||||||
|
getManifestSpy.mockImplementation(() => {
|
||||||
|
throw new Error('Unable to download manifest');
|
||||||
|
});
|
||||||
|
|
||||||
|
// act
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
// assert
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
'Attempt to resolve LTS alias from manifest...'
|
||||||
|
);
|
||||||
|
expect(dbgSpy).toHaveBeenCalledWith(
|
||||||
|
'Getting manifest from actions/node-versions@main'
|
||||||
|
);
|
||||||
|
expect(cnSpy).toHaveBeenCalledWith(
|
||||||
|
`::error::Unable to download manifest${osm.EOL}`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('latest alias syntax', () => {
|
||||||
|
it.each(['latest', 'current', 'node'])(
|
||||||
|
'download the %s version if alias is provided',
|
||||||
|
async inputVersion => {
|
||||||
|
// Arrange
|
||||||
|
inputs['node-version'] = inputVersion;
|
||||||
|
|
||||||
|
os.platform = 'darwin';
|
||||||
|
os.arch = 'x64';
|
||||||
|
|
||||||
|
findSpy.mockImplementation(() => '');
|
||||||
|
getManifestSpy.mockImplementation(() => {
|
||||||
|
throw new Error('Unable to download manifest');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
// assert
|
||||||
|
expect(logSpy).toHaveBeenCalledWith('Unable to download manifest');
|
||||||
|
|
||||||
|
expect(logSpy).toHaveBeenCalledWith('getting latest node version...');
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('latest alias syntax from cache', () => {
|
||||||
|
it.each(['latest', 'current', 'node'])(
|
||||||
|
'download the %s version if alias is provided',
|
||||||
|
async inputVersion => {
|
||||||
|
// Arrange
|
||||||
|
inputs['node-version'] = inputVersion;
|
||||||
|
const expectedVersion = nodeTestDist[0];
|
||||||
|
|
||||||
|
os.platform = 'darwin';
|
||||||
|
os.arch = 'x64';
|
||||||
|
|
||||||
|
const toolPath = path.normalize(
|
||||||
|
`/cache/node/${expectedVersion.version}/x64`
|
||||||
|
);
|
||||||
|
findSpy.mockImplementation(() => toolPath);
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
// assert
|
||||||
|
|
||||||
|
expect(logSpy).toHaveBeenCalledWith('getting latest node version...');
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('acquires specified architecture of node from mirror', async () => {
|
||||||
|
for (const {arch, version, osSpec} of [
|
||||||
|
{arch: 'x86', version: '12.16.2', osSpec: 'win32'},
|
||||||
|
{arch: 'x86', version: '14.0.0', osSpec: 'win32'}
|
||||||
|
]) {
|
||||||
|
os.platform = osSpec;
|
||||||
|
os.arch = arch;
|
||||||
|
const fileExtension = os.platform === 'win32' ? '7z' : 'tar.gz';
|
||||||
|
const platform = {
|
||||||
|
linux: 'linux',
|
||||||
|
darwin: 'darwin',
|
||||||
|
win32: 'win'
|
||||||
|
}[os.platform];
|
||||||
|
|
||||||
|
inputs['node-version'] = version;
|
||||||
|
inputs['architecture'] = arch;
|
||||||
|
inputs['token'] = 'faketoken';
|
||||||
|
inputs['mirror'] = 'https://my_mirror_url';
|
||||||
|
inputs['mirror-token'] = 'faketoken';
|
||||||
|
|
||||||
|
const expectedUrl =
|
||||||
|
arch === 'x64'
|
||||||
|
? `https://github.com/actions/node-versions/releases/download/${version}/node-${version}-${platform}-${arch}.zip`
|
||||||
|
: `https://my_mirror_url/dist/v${version}/node-v${version}-${platform}-${arch}.${fileExtension}`;
|
||||||
|
|
||||||
|
// ... but not in the local cache
|
||||||
|
findSpy.mockImplementation(() => '');
|
||||||
|
|
||||||
|
dlSpy.mockImplementation(async () => '/some/temp/path');
|
||||||
|
const toolPath = path.normalize(`/cache/node/${version}/${arch}`);
|
||||||
|
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
||||||
|
cacheSpy.mockImplementation(async () => toolPath);
|
||||||
|
|
||||||
|
await main.run();
|
||||||
|
expect(dlSpy).toHaveBeenCalled();
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
`Acquiring ${version} - ${arch} from ${expectedUrl}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}, 100000);
|
||||||
|
});
|
||||||
|
|
@ -0,0 +1,59 @@
|
||||||
|
#!/bin/sh -e
|
||||||
|
export YARN_ENABLE_IMMUTABLE_INSTALLS=false
|
||||||
|
rm package.json
|
||||||
|
rm package-lock.json
|
||||||
|
echo "create yarn2 project in the sub2"
|
||||||
|
mkdir sub2
|
||||||
|
cd sub2
|
||||||
|
cat <<EOT >package.json
|
||||||
|
{
|
||||||
|
"name": "subproject",
|
||||||
|
"dependencies": {
|
||||||
|
"random": "^3.0.6",
|
||||||
|
"uuid": "^9.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EOT
|
||||||
|
yarn set version 2.4.3
|
||||||
|
yarn install
|
||||||
|
|
||||||
|
echo "create yarn3 project in the sub3"
|
||||||
|
cd ..
|
||||||
|
mkdir sub3
|
||||||
|
cd sub3
|
||||||
|
cat <<EOT >package.json
|
||||||
|
{
|
||||||
|
"name": "subproject",
|
||||||
|
"dependencies": {
|
||||||
|
"random": "^3.0.6",
|
||||||
|
"uuid": "^9.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EOT
|
||||||
|
yarn set version 3.5.1
|
||||||
|
yarn install
|
||||||
|
if [ x$1 = 'xglobal' ];then
|
||||||
|
echo enableGlobalCache
|
||||||
|
echo 'enableGlobalCache: true' >> .yarnrc.yml
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd ..
|
||||||
|
if [ x$1 != 'xkeepcache' -a x$2 != 'xkeepcache' ]; then
|
||||||
|
rm -rf sub2/.yarn/cache
|
||||||
|
rm -rf sub3/.yarn/cache
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ x$1 = 'xyarn1' ];then
|
||||||
|
echo "create yarn1 project in the root"
|
||||||
|
cat <<EOT >package.json
|
||||||
|
{
|
||||||
|
"name": "subproject",
|
||||||
|
"dependencies": {
|
||||||
|
"random": "^3.0.6",
|
||||||
|
"uuid": "^9.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EOT
|
||||||
|
yarn set version 1.22.19
|
||||||
|
yarn install
|
||||||
|
fi
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
import tscMatcher from '../.github/tsc.json';
|
||||||
|
|
||||||
|
describe('problem matcher tests', () => {
|
||||||
|
it('tsc: matches TypeScript "pretty" error message', () => {
|
||||||
|
const [
|
||||||
|
{
|
||||||
|
pattern: [{regexp}]
|
||||||
|
}
|
||||||
|
] = tscMatcher.problemMatcher;
|
||||||
|
const exampleErrorMessage =
|
||||||
|
"lib/index.js:23:42 - error TS2345: Argument of type 'A' is not assignable to parameter of type 'B'.";
|
||||||
|
|
||||||
|
const match = exampleErrorMessage.match(new RegExp(regexp));
|
||||||
|
expect(match).not.toBeNull();
|
||||||
|
expect(match![1]).toEqual('lib/index.js');
|
||||||
|
expect(match![2]).toEqual('23');
|
||||||
|
expect(match![3]).toEqual('42');
|
||||||
|
expect(match![4]).toEqual('error');
|
||||||
|
expect(match![5]).toEqual('2345');
|
||||||
|
expect(match![6]).toEqual(
|
||||||
|
"Argument of type 'A' is not assignable to parameter of type 'B'."
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('tsc: matches TypeScript error message from log file', () => {
|
||||||
|
const [
|
||||||
|
{
|
||||||
|
pattern: [{regexp}]
|
||||||
|
}
|
||||||
|
] = tscMatcher.problemMatcher;
|
||||||
|
const exampleErrorMessage =
|
||||||
|
"lib/index.js(23,42): error TS2345: Argument of type 'A' is not assignable to parameter of type 'B'.";
|
||||||
|
|
||||||
|
const match = exampleErrorMessage.match(new RegExp(regexp));
|
||||||
|
expect(match).not.toBeNull();
|
||||||
|
expect(match![1]).toEqual('lib/index.js');
|
||||||
|
expect(match![2]).toEqual('23');
|
||||||
|
expect(match![3]).toEqual('42');
|
||||||
|
expect(match![4]).toEqual('error');
|
||||||
|
expect(match![5]).toEqual('2345');
|
||||||
|
expect(match![6]).toEqual(
|
||||||
|
"Argument of type 'A' is not assignable to parameter of type 'B'."
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -0,0 +1,399 @@
|
||||||
|
import * as core from '@actions/core';
|
||||||
|
import * as io from '@actions/io';
|
||||||
|
import * as tc from '@actions/tool-cache';
|
||||||
|
import * as httpm from '@actions/http-client';
|
||||||
|
import * as exec from '@actions/exec';
|
||||||
|
import * as cache from '@actions/cache';
|
||||||
|
import fs from 'fs';
|
||||||
|
import cp from 'child_process';
|
||||||
|
import osm from 'os';
|
||||||
|
import path from 'path';
|
||||||
|
import * as main from '../src/main';
|
||||||
|
import * as auth from '../src/authutil';
|
||||||
|
import {INodeVersion} from '../src/distributions/base-models';
|
||||||
|
|
||||||
|
import nodeTestDist from './data/node-dist-index.json';
|
||||||
|
import nodeTestDistNightly from './data/node-nightly-index.json';
|
||||||
|
import nodeTestDistRc from './data/node-rc-index.json';
|
||||||
|
import nodeV8CanaryTestDist from './data/v8-canary-dist-index.json';
|
||||||
|
|
||||||
|
describe('setup-node', () => {
|
||||||
|
let inputs = {} as any;
|
||||||
|
let os = {} as any;
|
||||||
|
|
||||||
|
let inSpy: jest.SpyInstance;
|
||||||
|
let findSpy: jest.SpyInstance;
|
||||||
|
let findAllVersionsSpy: jest.SpyInstance;
|
||||||
|
let cnSpy: jest.SpyInstance;
|
||||||
|
let logSpy: jest.SpyInstance;
|
||||||
|
let warningSpy: jest.SpyInstance;
|
||||||
|
let platSpy: jest.SpyInstance;
|
||||||
|
let archSpy: jest.SpyInstance;
|
||||||
|
let dlSpy: jest.SpyInstance;
|
||||||
|
let exSpy: jest.SpyInstance;
|
||||||
|
let cacheSpy: jest.SpyInstance;
|
||||||
|
let dbgSpy: jest.SpyInstance;
|
||||||
|
let whichSpy: jest.SpyInstance;
|
||||||
|
let existsSpy: jest.SpyInstance;
|
||||||
|
let mkdirpSpy: jest.SpyInstance;
|
||||||
|
let execSpy: jest.SpyInstance;
|
||||||
|
let authSpy: jest.SpyInstance;
|
||||||
|
let isCacheActionAvailable: jest.SpyInstance;
|
||||||
|
let getExecOutputSpy: jest.SpyInstance;
|
||||||
|
let getJsonSpy: jest.SpyInstance;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
// @actions/core
|
||||||
|
console.log('::stop-commands::stoptoken'); // Disable executing of runner commands when running tests in actions
|
||||||
|
process.env['GITHUB_PATH'] = ''; // Stub out ENV file functionality so we can verify it writes to standard out
|
||||||
|
process.env['GITHUB_OUTPUT'] = ''; // Stub out ENV file functionality so we can verify it writes to standard out
|
||||||
|
inputs = {};
|
||||||
|
inSpy = jest.spyOn(core, 'getInput');
|
||||||
|
inSpy.mockImplementation(name => inputs[name]);
|
||||||
|
|
||||||
|
// node
|
||||||
|
os = {};
|
||||||
|
platSpy = jest.spyOn(osm, 'platform');
|
||||||
|
platSpy.mockImplementation(() => os['platform']);
|
||||||
|
archSpy = jest.spyOn(osm, 'arch');
|
||||||
|
archSpy.mockImplementation(() => os['arch']);
|
||||||
|
execSpy = jest.spyOn(cp, 'execSync');
|
||||||
|
|
||||||
|
// @actions/tool-cache
|
||||||
|
findSpy = jest.spyOn(tc, 'find');
|
||||||
|
findAllVersionsSpy = jest.spyOn(tc, 'findAllVersions');
|
||||||
|
dlSpy = jest.spyOn(tc, 'downloadTool');
|
||||||
|
exSpy = jest.spyOn(tc, 'extractTar');
|
||||||
|
cacheSpy = jest.spyOn(tc, 'cacheDir');
|
||||||
|
// getDistSpy = jest.spyOn(im, 'getVersionsFromDist');
|
||||||
|
|
||||||
|
// http-client
|
||||||
|
getJsonSpy = jest.spyOn(httpm.HttpClient.prototype, 'getJson');
|
||||||
|
|
||||||
|
// io
|
||||||
|
whichSpy = jest.spyOn(io, 'which');
|
||||||
|
existsSpy = jest.spyOn(fs, 'existsSync');
|
||||||
|
mkdirpSpy = jest.spyOn(io, 'mkdirP');
|
||||||
|
|
||||||
|
// @actions/tool-cache
|
||||||
|
isCacheActionAvailable = jest.spyOn(cache, 'isFeatureAvailable');
|
||||||
|
isCacheActionAvailable.mockImplementation(() => false);
|
||||||
|
|
||||||
|
// disable authentication portion for installer tests
|
||||||
|
authSpy = jest.spyOn(auth, 'configAuthentication');
|
||||||
|
authSpy.mockImplementation(() => {});
|
||||||
|
|
||||||
|
getJsonSpy.mockImplementation(url => {
|
||||||
|
let res: any;
|
||||||
|
if (url.includes('/rc')) {
|
||||||
|
res = <INodeVersion[]>nodeTestDistRc;
|
||||||
|
} else if (url.includes('/nightly')) {
|
||||||
|
res = <INodeVersion[]>nodeTestDistNightly;
|
||||||
|
} else {
|
||||||
|
res = <INodeVersion[]>nodeTestDist;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {result: res};
|
||||||
|
});
|
||||||
|
|
||||||
|
// writes
|
||||||
|
cnSpy = jest.spyOn(process.stdout, 'write');
|
||||||
|
logSpy = jest.spyOn(core, 'info');
|
||||||
|
dbgSpy = jest.spyOn(core, 'debug');
|
||||||
|
warningSpy = jest.spyOn(core, 'warning');
|
||||||
|
cnSpy.mockImplementation(line => {
|
||||||
|
// uncomment to debug
|
||||||
|
// process.stderr.write('write:' + line + '\n');
|
||||||
|
});
|
||||||
|
logSpy.mockImplementation(line => {
|
||||||
|
// uncomment to debug
|
||||||
|
// process.stderr.write('log:' + line + '\n');
|
||||||
|
});
|
||||||
|
dbgSpy.mockImplementation(msg => {
|
||||||
|
// uncomment to see debug output
|
||||||
|
// process.stderr.write(msg + '\n');
|
||||||
|
});
|
||||||
|
warningSpy.mockImplementation(msg => {
|
||||||
|
// uncomment to debug
|
||||||
|
// process.stderr.write('log:' + msg + '\n');
|
||||||
|
});
|
||||||
|
|
||||||
|
// @actions/exec
|
||||||
|
getExecOutputSpy = jest.spyOn(exec, 'getExecOutput');
|
||||||
|
getExecOutputSpy.mockImplementation(() => 'v16.15.0-rc.1');
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
jest.resetAllMocks();
|
||||||
|
jest.clearAllMocks();
|
||||||
|
//jest.restoreAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(async () => {
|
||||||
|
console.log('::stoptoken::'); // Re-enable executing of runner commands when running tests in actions
|
||||||
|
jest.restoreAllMocks();
|
||||||
|
}, 100000);
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// Found in cache tests
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
|
it('finds version in cache with stable true', async () => {
|
||||||
|
inputs['node-version'] = '12.0.0-rc.1';
|
||||||
|
inputs.stable = 'true';
|
||||||
|
|
||||||
|
const toolPath = path.normalize('/cache/node/12.0.0-rc.1/x64');
|
||||||
|
findSpy.mockImplementation(() => toolPath);
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('finds version in cache with stable not supplied', async () => {
|
||||||
|
inputs['node-version'] = '12.0.0-rc.1';
|
||||||
|
|
||||||
|
inSpy.mockImplementation(name => inputs[name]);
|
||||||
|
|
||||||
|
const toolPath = path.normalize('/cache/node/12.0.0-rc.1/x64');
|
||||||
|
findSpy.mockImplementation(() => toolPath);
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('finds version in cache and adds it to the path', async () => {
|
||||||
|
inputs['node-version'] = '12.0.0-rc.1';
|
||||||
|
|
||||||
|
inSpy.mockImplementation(name => inputs[name]);
|
||||||
|
|
||||||
|
const toolPath = path.normalize('/cache/node/12.0.0-rc.1/x64');
|
||||||
|
findSpy.mockImplementation(() => toolPath);
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
const expPath = path.join(toolPath, 'bin');
|
||||||
|
expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('handles unhandled find error and reports error', async () => {
|
||||||
|
const errMsg = 'unhandled error message';
|
||||||
|
inputs['node-version'] = '12.0.0-rc.1';
|
||||||
|
|
||||||
|
findSpy.mockImplementation(() => {
|
||||||
|
throw new Error(errMsg);
|
||||||
|
});
|
||||||
|
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
expect(cnSpy).toHaveBeenCalledWith('::error::' + errMsg + osm.EOL);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('falls back to a version from node dist', async () => {
|
||||||
|
os.platform = 'linux';
|
||||||
|
os.arch = 'x64';
|
||||||
|
|
||||||
|
const versionSpec = '13.0.0-rc.0';
|
||||||
|
|
||||||
|
inputs['node-version'] = versionSpec;
|
||||||
|
inputs['token'] = 'faketoken';
|
||||||
|
|
||||||
|
// ... but not in the local cache
|
||||||
|
findSpy.mockImplementation(() => '');
|
||||||
|
|
||||||
|
dlSpy.mockImplementation(async () => '/some/temp/path');
|
||||||
|
const toolPath = path.normalize('/cache/node/13.0.0-rc.0/x64');
|
||||||
|
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
||||||
|
cacheSpy.mockImplementation(async () => toolPath);
|
||||||
|
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
const expPath = path.join(toolPath, 'bin');
|
||||||
|
|
||||||
|
expect(dlSpy).toHaveBeenCalled();
|
||||||
|
expect(exSpy).toHaveBeenCalled();
|
||||||
|
expect(logSpy).toHaveBeenCalledWith('Extracting ...');
|
||||||
|
expect(logSpy).toHaveBeenCalledWith('Done');
|
||||||
|
expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does not find a version that does not exist', async () => {
|
||||||
|
os.platform = 'linux';
|
||||||
|
os.arch = 'x64';
|
||||||
|
|
||||||
|
const versionSpec = '9.99.9-rc.1';
|
||||||
|
inputs['node-version'] = versionSpec;
|
||||||
|
|
||||||
|
findSpy.mockImplementation(() => '');
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
expect(cnSpy).toHaveBeenCalledWith(
|
||||||
|
`::error::Unable to find Node version '${versionSpec}' for platform ${os.platform} and architecture ${os.arch}.${osm.EOL}`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('reports a failed download', async () => {
|
||||||
|
const errMsg = 'unhandled download message';
|
||||||
|
os.platform = 'linux';
|
||||||
|
os.arch = 'x64';
|
||||||
|
|
||||||
|
const versionSpec = '14.7.0-rc.1';
|
||||||
|
|
||||||
|
inputs['node-version'] = versionSpec;
|
||||||
|
inputs['token'] = 'faketoken';
|
||||||
|
|
||||||
|
findSpy.mockImplementation(() => '');
|
||||||
|
findAllVersionsSpy.mockImplementation(() => []);
|
||||||
|
dlSpy.mockImplementation(() => {
|
||||||
|
throw new Error(errMsg);
|
||||||
|
});
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
expect(cnSpy).toHaveBeenCalledWith(`::error::${errMsg}${osm.EOL}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('acquires specified architecture of node', async () => {
|
||||||
|
for (const {arch, version, osSpec} of [
|
||||||
|
{arch: 'x86', version: '13.4.0-rc.0', osSpec: 'win32'},
|
||||||
|
{arch: 'x86', version: '14.15.5-rc.0', osSpec: 'win32'}
|
||||||
|
]) {
|
||||||
|
os.platform = osSpec;
|
||||||
|
os.arch = arch;
|
||||||
|
const fileExtension = os.platform === 'win32' ? '7z' : 'tar.gz';
|
||||||
|
const platform = {
|
||||||
|
linux: 'linux',
|
||||||
|
darwin: 'darwin',
|
||||||
|
win32: 'win'
|
||||||
|
}[os.platform];
|
||||||
|
|
||||||
|
inputs['node-version'] = version;
|
||||||
|
inputs['architecture'] = arch;
|
||||||
|
inputs['token'] = 'faketoken';
|
||||||
|
|
||||||
|
const expectedUrl = `https://nodejs.org/download/rc/v${version}/node-v${version}-${platform}-${arch}.${fileExtension}`;
|
||||||
|
|
||||||
|
// ... but not in the local cache
|
||||||
|
findSpy.mockImplementation(() => '');
|
||||||
|
findAllVersionsSpy.mockImplementation(() => []);
|
||||||
|
|
||||||
|
dlSpy.mockImplementation(async () => '/some/temp/path');
|
||||||
|
const toolPath = path.normalize(`/cache/node/${version}/${arch}`);
|
||||||
|
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
||||||
|
cacheSpy.mockImplementation(async () => toolPath);
|
||||||
|
|
||||||
|
await main.run();
|
||||||
|
expect(dlSpy).toHaveBeenCalled();
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(
|
||||||
|
`Acquiring ${version} - ${arch} from ${expectedUrl}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}, 100000);
|
||||||
|
|
||||||
|
describe('rc versions', () => {
|
||||||
|
it.each([
|
||||||
|
[
|
||||||
|
'13.10.1-rc.0',
|
||||||
|
'13.10.1-rc.0',
|
||||||
|
'https://nodejs.org/download/rc/v13.10.1-rc.0/node-v13.10.1-rc.0-linux-x64.tar.gz'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'14.15.5-rc.1',
|
||||||
|
'14.15.5-rc.1',
|
||||||
|
'https://nodejs.org/download/rc/v14.15.5-rc.1/node-v14.15.5-rc.1-linux-x64.tar.gz'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'16.17.0-rc.1',
|
||||||
|
'16.17.0-rc.1',
|
||||||
|
'https://nodejs.org/download/rc/v16.17.0-rc.1/node-v16.17.0-rc.1-linux-x64.tar.gz'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'17.0.0-rc.1',
|
||||||
|
'17.0.0-rc.1',
|
||||||
|
'https://nodejs.org/download/rc/v17.0.0-rc.1/node-v17.0.0-rc.1-linux-x64.tar.gz'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'19.0.0-rc.2',
|
||||||
|
'19.0.0-rc.2',
|
||||||
|
'https://nodejs.org/download/rc/v19.0.0-rc.2/node-v19.0.0-rc.2-linux-x64.tar.gz'
|
||||||
|
]
|
||||||
|
])(
|
||||||
|
'finds the versions in the index.json and installs it',
|
||||||
|
async (input, expectedVersion, expectedUrl) => {
|
||||||
|
const toolPath = path.normalize(`/cache/node/${expectedVersion}/x64`);
|
||||||
|
|
||||||
|
findSpy.mockImplementation(() => '');
|
||||||
|
findAllVersionsSpy.mockImplementation(() => []);
|
||||||
|
dlSpy.mockImplementation(async () => '/some/temp/path');
|
||||||
|
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
||||||
|
cacheSpy.mockImplementation(async () => toolPath);
|
||||||
|
|
||||||
|
inputs['node-version'] = input;
|
||||||
|
os['arch'] = 'x64';
|
||||||
|
os['platform'] = 'linux';
|
||||||
|
// act
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
// assert
|
||||||
|
expect(logSpy).toHaveBeenCalledWith('Extracting ...');
|
||||||
|
expect(logSpy).toHaveBeenCalledWith('Adding to the cache ...');
|
||||||
|
expect(cnSpy).toHaveBeenCalledWith(
|
||||||
|
`::add-path::${path.join(toolPath, 'bin')}${osm.EOL}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
it.each([
|
||||||
|
['13.10.1-rc.0', '13.10.1-rc.0'],
|
||||||
|
['14.15.5-rc.1', '14.15.5-rc.1'],
|
||||||
|
['16.17.0-rc.1', '16.17.0-rc.1'],
|
||||||
|
['17.0.0-rc.1', '17.0.0-rc.1']
|
||||||
|
])(
|
||||||
|
'finds the %s version in the hostedToolcache',
|
||||||
|
async (input, expectedVersion) => {
|
||||||
|
const toolPath = path.normalize(`/cache/node/${expectedVersion}/x64`);
|
||||||
|
findSpy.mockImplementation((_, version) =>
|
||||||
|
path.normalize(`/cache/node/${version}/x64`)
|
||||||
|
);
|
||||||
|
findAllVersionsSpy.mockReturnValue([
|
||||||
|
'2.2.2-rc.2',
|
||||||
|
'1.1.1-rc.1',
|
||||||
|
'99.1.1',
|
||||||
|
expectedVersion,
|
||||||
|
'88.1.1',
|
||||||
|
'3.3.3-rc.3'
|
||||||
|
]);
|
||||||
|
|
||||||
|
inputs['node-version'] = input;
|
||||||
|
os['arch'] = 'x64';
|
||||||
|
os['platform'] = 'linux';
|
||||||
|
|
||||||
|
// act
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
// assert
|
||||||
|
expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`);
|
||||||
|
expect(cnSpy).toHaveBeenCalledWith(
|
||||||
|
`::add-path::${path.join(toolPath, 'bin')}${osm.EOL}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
it('throws an error if version is not found', async () => {
|
||||||
|
const versionSpec = '19.0.0-rc.3';
|
||||||
|
|
||||||
|
findSpy.mockImplementation(() => '');
|
||||||
|
findAllVersionsSpy.mockImplementation(() => []);
|
||||||
|
dlSpy.mockImplementation(async () => '/some/temp/path');
|
||||||
|
exSpy.mockImplementation(async () => '/some/other/temp/path');
|
||||||
|
|
||||||
|
inputs['node-version'] = versionSpec;
|
||||||
|
os['arch'] = 'x64';
|
||||||
|
os['platform'] = 'linux';
|
||||||
|
// act
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
// assert
|
||||||
|
expect(cnSpy).toHaveBeenCalledWith(
|
||||||
|
`::error::Unable to find Node version '${versionSpec}' for platform ${os.platform} and architecture ${os.arch}.${osm.EOL}`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
if [ -n "$1" ]; then
|
||||||
|
architecture="$(node -e 'console.log(process.arch)')"
|
||||||
|
if [ -z "$(echo $architecture | grep --fixed-strings $1)" ]; then
|
||||||
|
echo "Unexpected architecture"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Skip testing architecture"
|
||||||
|
fi
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
echo "Must supply node version argument"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
node_version="$(node --version)"
|
||||||
|
echo "Found node version '$node_version'"
|
||||||
|
|
||||||
|
# Extract the major version from the node version (remove the 'v' prefix)
|
||||||
|
actual_major_version=$(echo $node_version | sed -E 's/^v([0-9]+)\..*/\1/')
|
||||||
|
expected_major_version=$(echo $1 | sed -E 's/^([0-9]+)\..*/\1/') # Extract major version from argument
|
||||||
|
|
||||||
|
if [ "$actual_major_version" != "$expected_major_version" ]; then
|
||||||
|
echo "Expected Node.js $expected_major_version.x.x but found $node_version"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$2" ]; then
|
||||||
|
echo "Testing npm install"
|
||||||
|
mkdir -p test-npm-install
|
||||||
|
cd test-npm-install
|
||||||
|
npm init -y || exit 1
|
||||||
|
npm install @actions/core || exit 1
|
||||||
|
else
|
||||||
|
echo "Skip testing npm"
|
||||||
|
fi
|
||||||
49
action.yml
49
action.yml
|
|
@ -1,10 +1,43 @@
|
||||||
name: 'Setup Node.js for use with actions'
|
name: 'Setup Node.js environment'
|
||||||
description: 'Setup a Node.js environment and add it to the PATH, additionally providing proxy support'
|
description: 'Setup a Node.js environment by adding problem matchers and optionally downloading and adding it to the PATH.'
|
||||||
author: 'GitHub'
|
author: 'GitHub'
|
||||||
inputs:
|
inputs:
|
||||||
version:
|
node-version:
|
||||||
description: 'Version Spec of the version to use. Examples: 10.x, 10.15.1, >=10.15.0, lts'
|
description: 'Version Spec of the version to use. Examples: 12.x, 10.15.1, >=10.15.0.'
|
||||||
default: '10.x'
|
node-version-file:
|
||||||
|
description: 'File containing the version Spec of the version to use. Examples: package.json, .nvmrc, .node-version, .tool-versions.'
|
||||||
|
architecture:
|
||||||
|
description: 'Target architecture for Node to use. Examples: x86, x64. Will use system architecture by default.'
|
||||||
|
check-latest:
|
||||||
|
description: 'Set this option if you want the action to check for the latest available version that satisfies the version spec.'
|
||||||
|
default: false
|
||||||
|
registry-url:
|
||||||
|
description: 'Optional registry to set up for auth. Will set the registry in a project level .npmrc and .yarnrc file, and set up auth to read in from env.NODE_AUTH_TOKEN.'
|
||||||
|
scope:
|
||||||
|
description: 'Optional scope for authenticating against scoped registries. Will fall back to the repository owner when using the GitHub Packages registry (https://npm.pkg.github.com/).'
|
||||||
|
token:
|
||||||
|
description: Used to pull node distributions from node-versions. Since there's a default, this is typically not supplied by the user. When running this action on github.com, the default value is sufficient. When running on GHES, you can pass a personal access token for github.com if you are experiencing rate limiting.
|
||||||
|
default: ${{ github.server_url == 'https://github.com' && github.token || '' }}
|
||||||
|
cache:
|
||||||
|
description: 'Used to specify a package manager for caching in the default directory. Supported values: npm, yarn, pnpm.'
|
||||||
|
package-manager-cache:
|
||||||
|
description: 'Set to false to disable automatic caching. By default, caching is enabled when either devEngines.packageManager or the top-level packageManager field in package.json specifies npm as the package manager.'
|
||||||
|
default: true
|
||||||
|
cache-dependency-path:
|
||||||
|
description: 'Used to specify the path to a dependency file: package-lock.json, yarn.lock, etc. Supports wildcards or a list of file names for caching multiple dependencies.'
|
||||||
|
mirror:
|
||||||
|
description: 'Used to specify an alternative mirror to download Node.js binaries from'
|
||||||
|
mirror-token:
|
||||||
|
description: 'The token used as Authorization header when fetching from the mirror'
|
||||||
|
# TODO: add input to control forcing to pull from cloud or dist.
|
||||||
|
# escape valve for someone having issues or needing the absolute latest which isn't cached yet
|
||||||
|
outputs:
|
||||||
|
cache-hit:
|
||||||
|
description: 'A boolean value to indicate if a cache was hit.'
|
||||||
|
node-version:
|
||||||
|
description: 'The installed node version.'
|
||||||
runs:
|
runs:
|
||||||
using: 'node12'
|
using: 'node24'
|
||||||
main: 'lib/setup-node.js'
|
main: 'dist/setup/index.js'
|
||||||
|
post: 'dist/cache-save/index.js'
|
||||||
|
post-if: success()
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,59 @@
|
||||||
|
# 0. Caching dependencies
|
||||||
|
Date: 2021-05-21
|
||||||
|
|
||||||
|
Status: Accepted
|
||||||
|
|
||||||
|
# Context
|
||||||
|
`actions/setup-node` is the 2nd most popular action in GitHub Actions. A lot of customers use it in conjunction with [actions/cache](https://github.com/actions/cache) to speed up dependencies installation.
|
||||||
|
See more examples on proper usage in [actions/cache documentation](https://github.com/actions/cache/blob/main/examples.md#node---npm).
|
||||||
|
|
||||||
|
# Goals & Anti-Goals
|
||||||
|
Integration of caching functionality into `actions/setup-node` action will bring the following benefits for action users:
|
||||||
|
- Decrease the entry threshold for using the cache for Node.js dependencies and simplify initial configuration
|
||||||
|
- Simplify YAML pipelines because no need additional steps to enable caching
|
||||||
|
- More users will use cache for Node.js so more customers will have fast builds!
|
||||||
|
|
||||||
|
We will add support for NPM and Yarn dependencies caching.
|
||||||
|
As the first stage, we won't support custom locations for `package-lock.json`, `yarn.lock` files and action will work only when files are located in repository root.
|
||||||
|
|
||||||
|
We don't pursue the goal to provide wide customization of caching in scope of `actions/setup-node` action. The purpose of this integration is covering ~90% of basic use-cases. If user needs flexible customization, we should advice them to use `actions/cache` directly.
|
||||||
|
|
||||||
|
# Decision
|
||||||
|
- Add `cache` input parameter to `actions/setup-node`. For now, input will accept the following values:
|
||||||
|
- `npm` - enable caching for npm dependencies
|
||||||
|
- `yarn` - enable caching for yarn dependencies
|
||||||
|
- `''` - disable caching (default value)
|
||||||
|
- Cache feature will be disabled by default to make sure that we don't break existing customers. We will consider enabling cache by default in next major release (`v3`)
|
||||||
|
- Action will try to search `package-lock.json` or `yarn.lock` (npm 7.x supports `yarn.lock` files) files in the repository root and throw error if no one is found
|
||||||
|
- The hash of found file will be used as cache key (the same approach like [actions/cache](https://github.com/actions/cache/blob/main/examples.md#node---npm) recommends)
|
||||||
|
- The following key cache will be used `${{ runner.os }}-npm-${{ hashFiles('<package-lock-path>') }}`
|
||||||
|
- Action will cache global cache:
|
||||||
|
- Npm (retrieved via `npm config get cache`)
|
||||||
|
- Yarn 1 (retrieved via `yarn cache dir`)
|
||||||
|
- Yarn 2 (retrieved via `yarn config get cacheFolder`)
|
||||||
|
|
||||||
|
# Example of real use-cases
|
||||||
|
Npm package manager:
|
||||||
|
```yml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-node@v2
|
||||||
|
with:
|
||||||
|
node-version: '14'
|
||||||
|
cache: npm
|
||||||
|
```
|
||||||
|
|
||||||
|
Yarn package manager:
|
||||||
|
```yml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-node@v2
|
||||||
|
with:
|
||||||
|
node-version: '14'
|
||||||
|
cache: yarn
|
||||||
|
```
|
||||||
|
|
||||||
|
# Release process
|
||||||
|
|
||||||
|
As soon as functionality is implemented, we will release minor update of action. No need to bump major version since there are no breaking changes for existing users.
|
||||||
|
After that, we will update [starter-workflows](https://github.com/actions/starter-workflows/blob/main/ci/node.js.yml) and [GitHub Action documentation](https://docs.github.com/en/actions/guides/building-and-testing-nodejs#example-caching-dependencies).
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
# 0. Support caching dependencies for mono repos
|
||||||
|
Date: 2021-07-13
|
||||||
|
|
||||||
|
Status: Proposed
|
||||||
|
|
||||||
|
## Context
|
||||||
|
Currently, `actions/setup-node` supports caching dependencies for Npm and Yarn package managers.
|
||||||
|
For the first iteration, we have decided to not support cases where `package-lock.json` / `yarn.lock` are located outside of repository root.
|
||||||
|
Current implementation searches the following file patterns in the repository root: `package-lock.json`, `yarn.lock` (in order of resolving priorities)
|
||||||
|
|
||||||
|
Obviously, it made built-in caching unusable for mono-repos and repos with complex structure.
|
||||||
|
We would like to revisit this decision and add customization for dependencies lock file location.
|
||||||
|
|
||||||
|
## Proposal
|
||||||
|
We have the following options:
|
||||||
|
1. Allow to specify directory where `package-lock.json` or `yarn.lock` are located
|
||||||
|
2. Allow to specify path to the dependencies lock file (including directory path and filename)
|
||||||
|
|
||||||
|
The second option looks more generic because it allows to:
|
||||||
|
- specify multiple dependencies files using file patterns like `**/package-lock.json` ([one of recommended approaches in actions/cache](https://github.com/actions/cache/blob/main/examples.md#macos-and-ubuntu))
|
||||||
|
- specify custom dependencies files like `src/npm-shrinkwrap.json`
|
||||||
|
- change default resolving priority if both `yarn.lock` and `package-lock.json` exist in repository
|
||||||
|
|
||||||
|
## Decision
|
||||||
|
|
||||||
|
Add `cache-dependency-path` input that will accept path (relative to repository root) to dependencies lock file.
|
||||||
|
If provided path contains wildcards, the action will search all matching files and calculate common hash like `${{ hashFiles('**/package-lock.json') }}` YAML construction does.
|
||||||
|
The hash of provided matched files will be used as a part of cache key.
|
||||||
|
|
||||||
|
Yaml examples:
|
||||||
|
```yml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-node@v2
|
||||||
|
with:
|
||||||
|
node-version: 14
|
||||||
|
cache: npm
|
||||||
|
cache-dependency-path: 'sub-project/package-lock.json'
|
||||||
|
```
|
||||||
|
```yml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-node@v2
|
||||||
|
with:
|
||||||
|
node-version: 14
|
||||||
|
cache: yarn
|
||||||
|
cache-dependency-path: 'sub-project/**/yarn.lock'
|
||||||
|
```
|
||||||
|
|
@ -0,0 +1,545 @@
|
||||||
|
## Working with lockfiles
|
||||||
|
|
||||||
|
Most supported package managers recommend that you **always** commit the lockfile, although implementations vary doing so generally provides the following benefits:
|
||||||
|
|
||||||
|
- Enables faster installation for CI and production environments, due to being able to skip package resolution.
|
||||||
|
- Describes a single representation of a dependency tree such that teammates, deployments, and continuous integration are guaranteed to install exactly the same dependencies.
|
||||||
|
- Provides a facility for users to "time-travel" to previous states of `node_modules` without having to commit the directory itself.
|
||||||
|
- Facilitates greater visibility of tree changes through readable source control diffs.
|
||||||
|
|
||||||
|
In order to get the most out of using your lockfile on continuous integration follow the conventions outlined below for your respective package manager.
|
||||||
|
|
||||||
|
### NPM
|
||||||
|
|
||||||
|
Ensure that `package-lock.json` is always committed, use `npm ci` instead of `npm install` when installing packages.
|
||||||
|
|
||||||
|
**See also:**
|
||||||
|
- [Documentation of `package-lock.json`](https://docs.npmjs.com/cli/v8/configuring-npm/package-lock-json)
|
||||||
|
- [Documentation of `npm ci`](https://docs.npmjs.com/cli/v8/commands/npm-ci)
|
||||||
|
|
||||||
|
### Yarn
|
||||||
|
|
||||||
|
To ensure that `yarn.lock` is always committed, use `yarn install --immutable` when installing packages.
|
||||||
|
|
||||||
|
**See also:**
|
||||||
|
- [Documentation of `yarn.lock`](https://classic.yarnpkg.com/en/docs/yarn-lock)
|
||||||
|
- [Documentation of `--frozen-lockfile` option](https://classic.yarnpkg.com/en/docs/cli/install#toc-yarn-install-frozen-lockfile)
|
||||||
|
- [QA - Should lockfiles be committed to the repository?](https://yarnpkg.com/getting-started/qa/#should-lockfiles-be-committed-to-the-repository)
|
||||||
|
- [Documentation of `yarn install`](https://yarnpkg.com/cli/install)
|
||||||
|
|
||||||
|
### PNPM
|
||||||
|
|
||||||
|
Ensure that `pnpm-lock.yaml` is always committed, when on CI pass `--frozen-lockfile` to `pnpm install` when installing packages.
|
||||||
|
|
||||||
|
**See also:**
|
||||||
|
- [Working with Git - Lockfiles](https://pnpm.io/git#lockfiles)
|
||||||
|
- [Documentation of `--frozen-lockfile` option](https://pnpm.io/cli/install#--frozen-lockfile)
|
||||||
|
|
||||||
|
### Running without a lockfile
|
||||||
|
|
||||||
|
If you choose not to use a lockfile, you must ensure that **caching is disabled**. The `cache` feature relies on the lockfile to generate a unique key for the cache entry.
|
||||||
|
|
||||||
|
To run without a lockfile:
|
||||||
|
1. Do not set the `cache` input.
|
||||||
|
2. If your `package.json` contains a `packageManager` field set to npm (or devEngines.packageManager), automatic caching is enabled by default. Override this by setting `package-manager-cache: false`.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- uses: actions/setup-node@v6
|
||||||
|
with:
|
||||||
|
node-version: '24'
|
||||||
|
package-manager-cache: false # Explicitly disable caching if you don't have a lockfile
|
||||||
|
- run: npm install
|
||||||
|
- run: npm test
|
||||||
|
```
|
||||||
|
|
||||||
|
## Check latest version
|
||||||
|
|
||||||
|
The `check-latest` flag defaults to `false`. When set to `false`, the action will first check the local cache for a semver match. If unable to find a specific version in the cache, the action will attempt to download a version of Node.js. It will pull LTS versions from [node-versions releases](https://github.com/actions/node-versions/releases) and on miss or failure will fall back to the previous behavior of downloading directly from [node dist](https://nodejs.org/dist/). Use the default or set `check-latest` to `false` if you prefer stability and if you want to ensure a specific version of Node.js is always used.
|
||||||
|
|
||||||
|
If `check-latest` is set to `true`, the action first checks if the cached version is the latest one. If the locally cached version is not the most up-to-date, a version of Node.js will then be downloaded. Set `check-latest` to `true` it you want the most up-to-date version of Node.js to always be used.
|
||||||
|
|
||||||
|
> Setting `check-latest` to `true` has performance implications as downloading versions of Node is slower than using cached versions.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- uses: actions/setup-node@v6
|
||||||
|
with:
|
||||||
|
node-version: '24'
|
||||||
|
check-latest: true
|
||||||
|
- run: npm ci
|
||||||
|
- run: npm test
|
||||||
|
```
|
||||||
|
|
||||||
|
## Node version file
|
||||||
|
|
||||||
|
The `node-version-file` input accepts a path to a file containing the version of Node.js to be used by a project, for example `.nvmrc`, `.node-version`, `.tool-versions`, or `package.json`. If both the `node-version` and the `node-version-file` inputs are provided then the `node-version` input is used.
|
||||||
|
See [supported version syntax](https://github.com/actions/setup-node#supported-version-syntax).
|
||||||
|
|
||||||
|
> The action will search for the node version file relative to the repository root.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- uses: actions/setup-node@v6
|
||||||
|
with:
|
||||||
|
node-version-file: '.nvmrc'
|
||||||
|
- run: npm ci
|
||||||
|
- run: npm test
|
||||||
|
```
|
||||||
|
|
||||||
|
When using the `package.json` input, the action will look in the following fields for a specified Node version:
|
||||||
|
1. It checks `volta.node` first.
|
||||||
|
2. Then it checks `devEngines.runtime` for an entry with `"name": "node"`.
|
||||||
|
3. Then it will look for `engines.node`.
|
||||||
|
4. Otherwise it tries to resolve the file defined by [`volta.extends`](https://docs.volta.sh/advanced/workspaces)
|
||||||
|
and look for `volta.node`, `devEngines.runtime`, or `engines.node` recursively.
|
||||||
|
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"engines": {
|
||||||
|
"node": "^22 || ^24"
|
||||||
|
},
|
||||||
|
"devEngines": {
|
||||||
|
"runtime": {
|
||||||
|
"name": "node",
|
||||||
|
"version": "^24.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"volta": {
|
||||||
|
"node": "24.11.1"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Architecture
|
||||||
|
|
||||||
|
You can use any of the [supported operating systems](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners), and the compatible `architecture` can be selected using `architecture`. Values are `x86`, `x64`, `arm64`, `armv6l`, `armv7l`, `ppc64le`, `s390x` (not all of the architectures are available on all platforms).
|
||||||
|
|
||||||
|
When using `architecture`, `node-version` must be provided as well.
|
||||||
|
```yaml
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: windows-latest
|
||||||
|
name: Node sample
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- uses: actions/setup-node@v6
|
||||||
|
with:
|
||||||
|
node-version: '24'
|
||||||
|
architecture: 'x64' # optional, x64 or x86. If not specified, x64 will be used by default
|
||||||
|
- run: npm ci
|
||||||
|
- run: npm test
|
||||||
|
```
|
||||||
|
|
||||||
|
## V8 Canary versions
|
||||||
|
|
||||||
|
You can specify a nightly version to download it from https://nodejs.org/download/v8-canary.
|
||||||
|
|
||||||
|
### Install v8 canary build for specific node version
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Node sample
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- uses: actions/setup-node@v6
|
||||||
|
with:
|
||||||
|
node-version: '24.0.0-v8-canary' # it will install the latest v8 canary release for node 24.0.0
|
||||||
|
- run: npm ci
|
||||||
|
- run: npm test
|
||||||
|
```
|
||||||
|
### Install v8 canary build for major node version
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Node sample
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- uses: actions/setup-node@v6
|
||||||
|
with:
|
||||||
|
node-version: '24-v8-canary' # it will install the latest v8 canary release for node 24
|
||||||
|
- run: npm ci
|
||||||
|
- run: npm test
|
||||||
|
```
|
||||||
|
|
||||||
|
### Install the exact v8 canary version
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Node sample
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- uses: actions/setup-node@v6
|
||||||
|
with:
|
||||||
|
node-version: 'v24.0.0-v8-canary2025030537242e55ac'
|
||||||
|
- run: npm ci
|
||||||
|
- run: npm test
|
||||||
|
```
|
||||||
|
|
||||||
|
## Nightly versions
|
||||||
|
|
||||||
|
You can specify a nightly version to download it from https://nodejs.org/download/nightly.
|
||||||
|
|
||||||
|
### Install the nightly build for a major version
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Node sample
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- uses: actions/setup-node@v6
|
||||||
|
with:
|
||||||
|
node-version: '24-nightly' # it will install the latest nightly release for node 24
|
||||||
|
- run: npm ci
|
||||||
|
- run: npm test
|
||||||
|
```
|
||||||
|
|
||||||
|
### Install the nightly build for a specific version
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Node sample
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- uses: actions/setup-node@v6
|
||||||
|
with:
|
||||||
|
node-version: '24.0.0-nightly' # it will install the latest nightly release for node 24.0.0
|
||||||
|
- run: npm ci
|
||||||
|
- run: npm test
|
||||||
|
```
|
||||||
|
|
||||||
|
### Install an exact nightly version
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Node sample
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- uses: actions/setup-node@v6
|
||||||
|
with:
|
||||||
|
node-version: '24.0.0-nightly202505066102159fa1'
|
||||||
|
- run: npm ci
|
||||||
|
- run: npm test
|
||||||
|
```
|
||||||
|
|
||||||
|
## RC versions
|
||||||
|
|
||||||
|
You can use specify a rc version to download it from https://nodejs.org/download/rc.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Node sample
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- uses: actions/setup-node@v6
|
||||||
|
with:
|
||||||
|
node-version: '24.0.0-rc.4'
|
||||||
|
- run: npm ci
|
||||||
|
- run: npm test
|
||||||
|
```
|
||||||
|
|
||||||
|
**Note:** Unlike nightly versions, which support version range specifiers, you must specify the exact version for a release candidate: `24.0.0-rc.4`.
|
||||||
|
|
||||||
|
## Caching packages data
|
||||||
|
The action follows [actions/cache](https://github.com/actions/cache/blob/main/examples.md#node---npm) guidelines, and caches global cache on the machine instead of `node_modules`, so cache can be reused between different Node.js versions.
|
||||||
|
|
||||||
|
**Caching yarn dependencies:**
|
||||||
|
Yarn caching handles both Yarn Classic (v1) and Yarn Berry (v2, v3, v4+).
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- uses: actions/setup-node@v6
|
||||||
|
with:
|
||||||
|
node-version: '24'
|
||||||
|
cache: 'yarn'
|
||||||
|
- run: yarn install --frozen-lockfile # optional, --immutable
|
||||||
|
- run: yarn test
|
||||||
|
```
|
||||||
|
|
||||||
|
**Caching pnpm (v6.10+) dependencies:**
|
||||||
|
```yaml
|
||||||
|
# This workflow uses actions that are not certified by GitHub.
|
||||||
|
# They are provided by a third-party and are governed by
|
||||||
|
# separate terms of service, privacy policy, and support
|
||||||
|
# documentation.
|
||||||
|
|
||||||
|
# NOTE: pnpm caching support requires pnpm version >= 6.10.0
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- uses: pnpm/action-setup@v4
|
||||||
|
with:
|
||||||
|
version: 10
|
||||||
|
- uses: actions/setup-node@v6
|
||||||
|
with:
|
||||||
|
node-version: '24'
|
||||||
|
cache: 'pnpm'
|
||||||
|
- run: pnpm install
|
||||||
|
- run: pnpm test
|
||||||
|
```
|
||||||
|
|
||||||
|
> **Note**: By default `--frozen-lockfile` option is passed starting from pnpm `6.10.x`. It will be automatically added if you run it on [CI](https://pnpm.io/cli/install#--frozen-lockfile).
|
||||||
|
> If the `pnpm-lock.yaml` file changes then pass `--frozen-lockfile` option.
|
||||||
|
|
||||||
|
|
||||||
|
**Using wildcard patterns to cache dependencies**
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- uses: actions/setup-node@v6
|
||||||
|
with:
|
||||||
|
node-version: '24'
|
||||||
|
cache: 'npm'
|
||||||
|
cache-dependency-path: '**/package-lock.json'
|
||||||
|
- run: npm ci
|
||||||
|
- run: npm test
|
||||||
|
```
|
||||||
|
|
||||||
|
**Using a list of file paths to cache dependencies**
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- uses: actions/setup-node@v6
|
||||||
|
with:
|
||||||
|
node-version: '24'
|
||||||
|
cache: 'npm'
|
||||||
|
cache-dependency-path: |
|
||||||
|
server/app/package-lock.json
|
||||||
|
frontend/app/package-lock.json
|
||||||
|
- run: npm ci
|
||||||
|
- run: npm test
|
||||||
|
```
|
||||||
|
|
||||||
|
**Restore-only cache**
|
||||||
|
|
||||||
|
You can restore caches without saving new entries, which helps reduce cache writes and storage usage in read-only cache workflows.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
# - uses: pnpm/action-setup@v6
|
||||||
|
# with:
|
||||||
|
# version: 10
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v6
|
||||||
|
with:
|
||||||
|
node-version: '24'
|
||||||
|
|
||||||
|
- name: Normalize runner architecture
|
||||||
|
shell: bash
|
||||||
|
run: echo "ARCH=$(echo '${{ runner.arch }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Output of cache path
|
||||||
|
id: cachepath
|
||||||
|
shell: bash
|
||||||
|
run: echo "path=$(npm config get cache)" >> $GITHUB_OUTPUT
|
||||||
|
# run: echo "path=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
|
||||||
|
# For yarn workflow, output of yarn cache dir (v1) or yarn config get cacheFolder (v2+)
|
||||||
|
# run: echo "path=$(yarn cache dir)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Restore Node cache
|
||||||
|
uses: actions/cache/restore@v5
|
||||||
|
with:
|
||||||
|
path: ${{ steps.cachepath.outputs.path }}
|
||||||
|
key: node-cache-${{ runner.os }}-${{ env.ARCH }}-npm-${{ hashFiles('**/package-lock.json') }}
|
||||||
|
# key: node-cache-${{ runner.os }}-${{ env.ARCH }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
||||||
|
# key: node-cache-${{ runner.os }}-${{ env.ARCH }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||||
|
|
||||||
|
- run: npm ci
|
||||||
|
# - run: yarn install --frozen-lockfile # optional, --immutable
|
||||||
|
# - run: pnpm install
|
||||||
|
```
|
||||||
|
> **Note**: Uncomment the commands relevant to your project's package manager.
|
||||||
|
|
||||||
|
> For more details related to cache scenarios, please refer [actions/cache/restore](https://github.com/actions/cache/tree/main/restore#only-restore-cache).
|
||||||
|
|
||||||
|
## Multiple operating systems and architectures
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os:
|
||||||
|
- ubuntu-latest
|
||||||
|
- macos-latest
|
||||||
|
- windows-latest
|
||||||
|
node_version:
|
||||||
|
- 20
|
||||||
|
- 22
|
||||||
|
- 24
|
||||||
|
architecture:
|
||||||
|
- x64
|
||||||
|
# an extra windows-x86 run:
|
||||||
|
include:
|
||||||
|
- os: windows-latest
|
||||||
|
node_version: 24
|
||||||
|
architecture: x86
|
||||||
|
name: Node ${{ matrix.node_version }} - ${{ matrix.architecture }} on ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- name: Setup node
|
||||||
|
uses: actions/setup-node@v6
|
||||||
|
with:
|
||||||
|
node-version: ${{ matrix.node_version }}
|
||||||
|
architecture: ${{ matrix.architecture }}
|
||||||
|
- run: npm ci
|
||||||
|
- run: npm test
|
||||||
|
```
|
||||||
|
|
||||||
|
## Publish to npmjs and GPR with npm
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- uses: actions/setup-node@v6
|
||||||
|
with:
|
||||||
|
node-version: '24.x'
|
||||||
|
registry-url: 'https://registry.npmjs.org'
|
||||||
|
- run: npm ci
|
||||||
|
- run: npm publish
|
||||||
|
env:
|
||||||
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
|
- uses: actions/setup-node@v6
|
||||||
|
with:
|
||||||
|
registry-url: 'https://npm.pkg.github.com'
|
||||||
|
- run: npm publish
|
||||||
|
env:
|
||||||
|
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Publish to npmjs and GPR with yarn
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- uses: actions/setup-node@v6
|
||||||
|
with:
|
||||||
|
node-version: '24.x'
|
||||||
|
registry-url: <registry url>
|
||||||
|
- run: yarn install --frozen-lockfile
|
||||||
|
- run: yarn publish
|
||||||
|
env:
|
||||||
|
NODE_AUTH_TOKEN: ${{ secrets.YARN_TOKEN }}
|
||||||
|
- uses: actions/setup-node@v6
|
||||||
|
with:
|
||||||
|
registry-url: 'https://npm.pkg.github.com'
|
||||||
|
- run: yarn publish
|
||||||
|
env:
|
||||||
|
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use private packages
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- uses: actions/setup-node@v6
|
||||||
|
with:
|
||||||
|
node-version: '24.x'
|
||||||
|
registry-url: 'https://registry.npmjs.org'
|
||||||
|
# Skip post-install scripts here, as a malicious
|
||||||
|
# script could steal NODE_AUTH_TOKEN.
|
||||||
|
- run: npm ci --ignore-scripts
|
||||||
|
env:
|
||||||
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
|
# `npm rebuild` will run all those post-install scripts for us.
|
||||||
|
- run: npm rebuild && npm run prepare --if-present
|
||||||
|
```
|
||||||
|
### Yarn2 configuration
|
||||||
|
Yarn2 ignores both .npmrc and .yarnrc files created by the action, so before installing dependencies from the private repo it is necessary either to create or to modify existing yarnrc.yml file with `yarn config set` commands.
|
||||||
|
|
||||||
|
Below you can find a sample "Setup .yarnrc.yml" step, that is going to allow you to configure a private GitHub registry for 'my-org' organisation.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- uses: actions/setup-node@v6
|
||||||
|
with:
|
||||||
|
node-version: '24.x'
|
||||||
|
- name: Setup .yarnrc.yml
|
||||||
|
run: |
|
||||||
|
yarn config set npmScopes.my-org.npmRegistryServer "https://npm.pkg.github.com"
|
||||||
|
yarn config set npmScopes.my-org.npmAlwaysAuth true
|
||||||
|
yarn config set npmScopes.my-org.npmAuthToken $NPM_AUTH_TOKEN
|
||||||
|
env:
|
||||||
|
NPM_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
- name: Install dependencies
|
||||||
|
run: yarn install --immutable
|
||||||
|
```
|
||||||
|
|
||||||
|
To access private GitHub Packages within the same organization, go to "Manage Actions access" in Package settings and set the repositories you want to access.
|
||||||
|
|
||||||
|
Please refer to the [Ensuring workflow access to your package - Configuring a package's access control and visibility](https://docs.github.com/en/packages/learn-github-packages/configuring-a-packages-access-control-and-visibility#ensuring-workflow-access-to-your-package) for more details.
|
||||||
|
|
||||||
|
## Publishing to npm with Trusted Publisher (OIDC)
|
||||||
|
|
||||||
|
npm supports Trusted Publishers, enabling packages to be published from GitHub Actions using OpenID Connect (OIDC) instead of long-lived npm tokens. This improves security by replacing static credentials with short-lived tokens, reducing the risk of credential leakage and simplifying authentication in CI/CD workflows.
|
||||||
|
|
||||||
|
### Requirements
|
||||||
|
|
||||||
|
Trusted publishing requires a compatible npm version:
|
||||||
|
|
||||||
|
* **npm ≥ 11.5.1 (required)**
|
||||||
|
* **Node.js 24 or newer (recommended)** — includes a compatible npm version by default
|
||||||
|
|
||||||
|
> If npm is below 11.5.1, publishing will fail even if OIDC permissions are correctly configured.
|
||||||
|
|
||||||
|
You must also configure a **Trusted Publisher** in npm for your package/scope that matches your GitHub repository and workflow (and optional environment, if used).
|
||||||
|
|
||||||
|
### Example workflow
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
id-token: write # Required for OIDC
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
|
||||||
|
- uses: actions/setup-node@v6
|
||||||
|
with:
|
||||||
|
node-version: '24'
|
||||||
|
registry-url: 'https://registry.npmjs.org'
|
||||||
|
|
||||||
|
- run: npm ci
|
||||||
|
- run: npm run build --if-present
|
||||||
|
- run: npm publish
|
||||||
|
```
|
||||||
|
|
||||||
|
> **Note**: If the Trusted Publisher configuration (GitHub owner/repo/workflow file, and optional environment) does not match the workflow run identity exactly, publishing may fail with **E404 Not Found** even if the package exists on npm.
|
||||||
|
|
||||||
|
For more details, see the [npm Trusted Publishers documentation](https://docs.npmjs.com/trusted-publishers) and the [GitHub Actions OpenID Connect (OIDC) overview](https://docs.github.com/en/actions/concepts/security/openid-connect).
|
||||||
|
|
||||||
|
## Use private mirror
|
||||||
|
|
||||||
|
It is possible to use a private mirror hosting Node.js binaries. This mirror must be a full mirror of the official Node.js distribution.
|
||||||
|
The mirror URL can be set using the `mirror` input.
|
||||||
|
It is possible to specify a token to authenticate with the mirror using the `mirror-token` input.
|
||||||
|
The token will be passed in the `Authorization` header.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- uses: actions/setup-node@v6
|
||||||
|
with:
|
||||||
|
node-version: '24.x'
|
||||||
|
mirror: 'https://nodejs.org/dist'
|
||||||
|
mirror-token: 'your-mirror-token'
|
||||||
|
```
|
||||||
|
|
@ -1,22 +1,116 @@
|
||||||
# Contributors
|
# Contributors
|
||||||
|
|
||||||
### Checkin
|
Thank you for contributing!
|
||||||
|
|
||||||
- Do checkin source (src)
|
We have prepared a short guide so that the process of making your contribution is as simple and clear as possible. Please check it out before you contribute!
|
||||||
- Do checkin build output (lib)
|
|
||||||
- Do checkin runtime node_modules
|
|
||||||
- Do not checkin devDependency node_modules (husky can help see below)
|
|
||||||
|
|
||||||
### devDependencies
|
## How can I contribute...
|
||||||
|
|
||||||
In order to handle correctly checking in node_modules without devDependencies, we run [Husky](https://github.com/typicode/husky) before each commit.
|
* [Contribute Documentation:green_book:](#contribute-documentation)
|
||||||
This step ensures that formatting and checkin rules are followed and that devDependencies are excluded. To make sure Husky runs correctly, please use the following workflow:
|
|
||||||
|
|
||||||
```
|
* [Contribute Code :computer:](#contribute-code)
|
||||||
npm install # installs all devDependencies including Husky
|
|
||||||
git add abc.ext # Add the files you've changed. This should include files in src, lib, and node_modules (see above)
|
|
||||||
git commit -m "Informative commit message" # Commit. This will run Husky
|
|
||||||
```
|
|
||||||
|
|
||||||
During the commit step, Husky will take care of formatting all files with [Prettier](https://github.com/prettier/prettier) as well as pruning out devDependencies using `npm prune --production`.
|
* [Provide Support on Issues:pencil:](#provide-support-on-issues)
|
||||||
It will also make sure these changes are appropriately included in your commit (no further work is needed)
|
|
||||||
|
* [Review Pull Requests:mag:](#review-pull-requests)
|
||||||
|
|
||||||
|
## Contribute documentation
|
||||||
|
|
||||||
|
Documentation is a super important, critical part of this project. Docs are how we keep track of what we're doing, how, and why. It's how we stay on the same page about our policies and how we tell others everything they need to be able to use this project or contribute to it.
|
||||||
|
|
||||||
|
Documentation contributions of any size are welcome! Feel free to contribute even if you're just rewording a sentence to be more clear, or fixing a spelling mistake!
|
||||||
|
|
||||||
|
**How to contribute:**
|
||||||
|
|
||||||
|
Pull requests are the easiest way to contribute changes to git repos at GitHub. They are the preferred contribution method, as they offer a convenient way of commenting and amending the proposed changes.
|
||||||
|
|
||||||
|
- Please check that no one else has already created a pull request with these or similar changes
|
||||||
|
- Use a "feature branch" for your changes. That separates the changes in the pull request from your other changes and makes it easy to edit/amend commits in the pull request
|
||||||
|
- Make sure your changes are formatted properly and consistently with the rest of the documentation
|
||||||
|
- Re-read what you wrote, and run a spellchecker on it to make sure you didn't miss anything
|
||||||
|
- If your pull request is connected to an open issue, please, leave a link to this issue in the `Related issue:` section
|
||||||
|
- If you later need to add new commits to the pull request, you can simply commit the changes to the local branch and then push them. The pull request gets automatically updated
|
||||||
|
|
||||||
|
**Once you've filed the pull request:**
|
||||||
|
|
||||||
|
- Maintainers will review your pull request
|
||||||
|
- If a maintainer requests changes, first of all, try to think about this request critically and only after that implement and request another review
|
||||||
|
- If your PR gets accepted, it will soon be merged into the main branch. But your contribution will take effect only after the release of a new version of the action and updating the major tag
|
||||||
|
> Sometimes maintainers reject pull requests and that's ok! Usually, along with rejection, we supply the reason for it. Nonetheless, we still really appreciate you taking the time to do it, and we don't take that lightly :heart:
|
||||||
|
|
||||||
|
## Contribute code
|
||||||
|
|
||||||
|
We like code commits a lot! They're super handy, and they keep the project going and doing the work it needs to do to be useful to others.
|
||||||
|
|
||||||
|
Code contributions of just about any size are acceptable!
|
||||||
|
|
||||||
|
The main difference between code contributions and documentation contributions is that contributing code requires the inclusion of relevant tests for the code being added or changed. Contributions without accompanying tests will be held off until a test is added unless the maintainers consider the specific tests to be either impossible or way too much of a burden for such a contribution.
|
||||||
|
|
||||||
|
**How to contribute:**
|
||||||
|
|
||||||
|
Pull requests are the easiest way to contribute changes to git repos at GitHub. They are the preferred contribution method, as they offer a convenient way of commenting and amending the proposed changes.
|
||||||
|
|
||||||
|
- Please check that no one else has already created a pull request with these or similar changes
|
||||||
|
- Use a "feature branch" for your changes. That separates the changes in the pull request from your other changes and makes it easy to edit/amend commits in the pull request
|
||||||
|
- **Run `pre-checkin` script to format, lint, build and test changes**
|
||||||
|
- Make sure your changes are well formatted and that all tests are passing
|
||||||
|
- If your pull request is connected to an open issue, please, leave a link to this issue in the `Related issue:` section
|
||||||
|
- If you later need to add new commits to the pull request, you can simply commit the changes to the local branch and then push them. The pull request gets automatically updated
|
||||||
|
|
||||||
|
**Learn more about how to work with the repository:**
|
||||||
|
|
||||||
|
- To implement new features or fix bugs, you need to make changes to the `.ts` files, which are located in the `src` folder
|
||||||
|
- To comply with the code style, **you need to run the `format` script**
|
||||||
|
- To lint the code, **you need to run the `lint:fix` script**
|
||||||
|
- To transpile source code to `javascript` we use [NCC](https://github.com/vercel/ncc). **It is very important to run the `build` script after making changes**, otherwise your changes will not get into the final `javascript` build
|
||||||
|
- You can also start formatting, building code, and testing with a single `pre-checkin` command
|
||||||
|
|
||||||
|
**Learn more about how to implement tests:**
|
||||||
|
|
||||||
|
Adding or changing tests is an integral part of making a change to the code.
|
||||||
|
Unit tests are in the `__tests__` folder, and end-to-end tests are in the `workflows` folder, particularly in the [versions.yml](https://github.com/actions/setup-node/blob/main/.github/workflows/versions.yml) and [e2e-cache.yml](https://github.com/actions/setup-node/blob/main/.github/workflows/e2e-cache.yml) files.
|
||||||
|
|
||||||
|
- The contributor can add various types of tests (like unit tests or end-to-end tests), which, in his opinion, will be necessary and sufficient for testing new or changed functionality
|
||||||
|
- Tests should cover a successful execution, as well as some edge cases and possible errors
|
||||||
|
- As already mentioned, pull requests without tests will be considered more carefully by maintainers. If you are sure that in this situation the tests are not needed or cannot be implemented with a commensurate effort - please add this clarification message to your pull request
|
||||||
|
|
||||||
|
**Once you've filed the pull request:**
|
||||||
|
|
||||||
|
- CI will start automatically with some checks. Wait until the end of the execution and make sure that all checks passed successfully. If some checks fail, you can open them one by one, try to find the reason for failing and make changes to your code to resolve the problem
|
||||||
|
- Maintainers will review your pull request
|
||||||
|
- If a maintainer requests changes, first of all, try to think about his request critically and only after that implement and request another review
|
||||||
|
- If your PR gets accepted, it will soon be merged into the main branch. But your contribution will take effect only after the release of a new version of the action and updating the major tag
|
||||||
|
> Sometimes maintainers reject pull requests and that's ok! Usually, along with rejection, we supply the reason for it. Nonetheless, we still really appreciate you taking the time to do it, and we don't take that lightly :heart:
|
||||||
|
|
||||||
|
## Provide support on issues
|
||||||
|
|
||||||
|
Helping out other users with their questions is an awesome way of contributing to any community. It's not uncommon for most of the issues on open source projects to be support-related questions by users trying to understand something they ran into or find their way around a known bug.
|
||||||
|
|
||||||
|
**To help other folks out with their questions:**
|
||||||
|
|
||||||
|
- Go to the [issue tracker](https://github.com/actions/setup-node/issues)
|
||||||
|
- Read through the list until you find something that you're familiar enough with to answer to
|
||||||
|
- Respond to the issue with whatever details are needed to clarify the question, or get more details about what's going on
|
||||||
|
- Once the discussion wraps up and things are clarified, ask the original issue filer (or a maintainer) to close it for you
|
||||||
|
|
||||||
|
*Some notes on picking up support issues:*
|
||||||
|
|
||||||
|
- Avoid responding to issues you don't know you can answer accurately
|
||||||
|
- Try to refer to past issues with accepted answers as much as possible. Link to them from your replies
|
||||||
|
- Be kind and patient with users. Often, folks who have run into confusing things might be upset or impatient. This is natural. If you feel uncomfortable in conversation with them, it's better to stay away or withdraw from the issue.
|
||||||
|
|
||||||
|
> If some user is violating our code of conduct [standards](https://github.com/actions/setup-node/blob/main/CODE_OF_CONDUCT.md#our-standards), refer to the [Enforcement](https://github.com/actions/setup-node/blob/main/CODE_OF_CONDUCT.md#enforcement) section of the Code of Conduct to resolve the conflict
|
||||||
|
|
||||||
|
|
||||||
|
## Review pull requests
|
||||||
|
|
||||||
|
|
||||||
|
Another great way to contribute is to review pull request. Please, be extra kind: people who submit code/doc contributions are putting themselves in a pretty vulnerable position, and have put time and care into what they've done (even if that's not obvious to you!) Please, always respond with respect, and be understanding, but don't feel like you need to sacrifice your standards for their sake, either.
|
||||||
|
|
||||||
|
**How to review:**
|
||||||
|
|
||||||
|
- Go to the [pull requests](https://github.com/actions/setup-node/pulls)
|
||||||
|
- Make sure you're familiar with the code or documentation is updated, unless it's a minor change (spellchecking, minor formatting, etc.)
|
||||||
|
- Review changes using the GitHub functionality. You can ask a clarifying question, point out an error or suggest an alternative.
|
||||||
|
> Note: You may ask for minor changes - "nitpicks", but consider whether they are real blockers to merging or not
|
||||||
|
- Submit your review, which may include comments, an approval, or a changes request
|
||||||
227
lib/installer.js
227
lib/installer.js
|
|
@ -1,227 +0,0 @@
|
||||||
"use strict";
|
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
||||||
result["default"] = mod;
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
// Load tempDirectory before it gets wiped by tool-cache
|
|
||||||
let tempDirectory = process.env['RUNNER_TEMPDIRECTORY'] || '';
|
|
||||||
const core = __importStar(require("@actions/core"));
|
|
||||||
const io = __importStar(require("@actions/io"));
|
|
||||||
const tc = __importStar(require("@actions/tool-cache"));
|
|
||||||
const restm = __importStar(require("typed-rest-client/RestClient"));
|
|
||||||
const os = __importStar(require("os"));
|
|
||||||
const path = __importStar(require("path"));
|
|
||||||
const semver = __importStar(require("semver"));
|
|
||||||
let osPlat = os.platform();
|
|
||||||
let osArch = os.arch();
|
|
||||||
if (!tempDirectory) {
|
|
||||||
let baseLocation;
|
|
||||||
if (process.platform === 'win32') {
|
|
||||||
// On windows use the USERPROFILE env variable
|
|
||||||
baseLocation = process.env['USERPROFILE'] || 'C:\\';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (process.platform === 'darwin') {
|
|
||||||
baseLocation = '/Users';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
baseLocation = '/home';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tempDirectory = path.join(baseLocation, 'actions', 'temp');
|
|
||||||
}
|
|
||||||
function getNode(versionSpec) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
// check cache
|
|
||||||
let toolPath;
|
|
||||||
toolPath = tc.find('node', versionSpec);
|
|
||||||
// If not found in cache, download
|
|
||||||
if (!toolPath) {
|
|
||||||
let version;
|
|
||||||
const c = semver.clean(versionSpec) || '';
|
|
||||||
// If explicit version
|
|
||||||
if (semver.valid(c) != null) {
|
|
||||||
// version to download
|
|
||||||
version = versionSpec;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// query nodejs.org for a matching version
|
|
||||||
version = yield queryLatestMatch(versionSpec);
|
|
||||||
if (!version) {
|
|
||||||
throw new Error(`Unable to find Node version '${versionSpec}' for platform ${osPlat} and architecture ${osArch}.`);
|
|
||||||
}
|
|
||||||
// check cache
|
|
||||||
toolPath = tc.find('node', version);
|
|
||||||
}
|
|
||||||
if (!toolPath) {
|
|
||||||
// download, extract, cache
|
|
||||||
toolPath = yield acquireNode(version);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// a tool installer initimately knows details about the layout of that tool
|
|
||||||
// for example, node binary is in the bin folder after the extract on Mac/Linux.
|
|
||||||
// layouts could change by version, by platform etc... but that's the tool installers job
|
|
||||||
//
|
|
||||||
if (osPlat != 'win32') {
|
|
||||||
toolPath = path.join(toolPath, 'bin');
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// prepend the tools path. instructs the agent to prepend for future tasks
|
|
||||||
core.addPath(toolPath);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
exports.getNode = getNode;
|
|
||||||
function queryLatestMatch(versionSpec) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
// node offers a json list of versions
|
|
||||||
let dataFileName;
|
|
||||||
switch (osPlat) {
|
|
||||||
case 'linux':
|
|
||||||
dataFileName = 'linux-' + osArch;
|
|
||||||
break;
|
|
||||||
case 'darwin':
|
|
||||||
dataFileName = 'osx-' + osArch + '-tar';
|
|
||||||
break;
|
|
||||||
case 'win32':
|
|
||||||
dataFileName = 'win-' + osArch + '-exe';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new Error(`Unexpected OS '${osPlat}'`);
|
|
||||||
}
|
|
||||||
let versions = [];
|
|
||||||
let dataUrl = 'https://nodejs.org/dist/index.json';
|
|
||||||
let rest = new restm.RestClient('vsts-node-tool');
|
|
||||||
let nodeVersions = (yield rest.get(dataUrl)).result || [];
|
|
||||||
nodeVersions.forEach((nodeVersion) => {
|
|
||||||
// ensure this version supports your os and platform
|
|
||||||
if (nodeVersion.files.indexOf(dataFileName) >= 0) {
|
|
||||||
versions.push(nodeVersion.version);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// get the latest version that matches the version spec
|
|
||||||
let version = evaluateVersions(versions, versionSpec);
|
|
||||||
return version;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
// TODO - should we just export this from @actions/tool-cache? Lifted directly from there
|
|
||||||
function evaluateVersions(versions, versionSpec) {
|
|
||||||
let version = '';
|
|
||||||
core.debug(`evaluating ${versions.length} versions`);
|
|
||||||
versions = versions.sort((a, b) => {
|
|
||||||
if (semver.gt(a, b)) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
});
|
|
||||||
for (let i = versions.length - 1; i >= 0; i--) {
|
|
||||||
const potential = versions[i];
|
|
||||||
const satisfied = semver.satisfies(potential, versionSpec);
|
|
||||||
if (satisfied) {
|
|
||||||
version = potential;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (version) {
|
|
||||||
core.debug(`matched: ${version}`);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
core.debug('match not found');
|
|
||||||
}
|
|
||||||
return version;
|
|
||||||
}
|
|
||||||
function acquireNode(version) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
//
|
|
||||||
// Download - a tool installer intimately knows how to get the tool (and construct urls)
|
|
||||||
//
|
|
||||||
version = semver.clean(version) || '';
|
|
||||||
let fileName = osPlat == 'win32'
|
|
||||||
? 'node-v' + version + '-win-' + os.arch()
|
|
||||||
: 'node-v' + version + '-' + osPlat + '-' + os.arch();
|
|
||||||
let urlFileName = osPlat == 'win32' ? fileName + '.7z' : fileName + '.tar.gz';
|
|
||||||
let downloadUrl = 'https://nodejs.org/dist/v' + version + '/' + urlFileName;
|
|
||||||
let downloadPath;
|
|
||||||
try {
|
|
||||||
downloadPath = yield tc.downloadTool(downloadUrl);
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
if (err instanceof tc.HTTPError && err.httpStatusCode == 404) {
|
|
||||||
return yield acquireNodeFromFallbackLocation(version);
|
|
||||||
}
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Extract
|
|
||||||
//
|
|
||||||
let extPath;
|
|
||||||
if (osPlat == 'win32') {
|
|
||||||
let _7zPath = path.join(__dirname, '..', 'externals', '7zr.exe');
|
|
||||||
extPath = yield tc.extract7z(downloadPath, undefined, _7zPath);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
extPath = yield tc.extractTar(downloadPath);
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Install into the local tool cache - node extracts with a root folder that matches the fileName downloaded
|
|
||||||
//
|
|
||||||
let toolRoot = path.join(extPath, fileName);
|
|
||||||
return yield tc.cacheDir(toolRoot, 'node', version);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
// For non LTS versions of Node, the files we need (for Windows) are sometimes located
|
|
||||||
// in a different folder than they normally are for other versions.
|
|
||||||
// Normally the format is similar to: https://nodejs.org/dist/v5.10.1/node-v5.10.1-win-x64.7z
|
|
||||||
// In this case, there will be two files located at:
|
|
||||||
// /dist/v5.10.1/win-x64/node.exe
|
|
||||||
// /dist/v5.10.1/win-x64/node.lib
|
|
||||||
// If this is not the structure, there may also be two files located at:
|
|
||||||
// /dist/v0.12.18/node.exe
|
|
||||||
// /dist/v0.12.18/node.lib
|
|
||||||
// This method attempts to download and cache the resources from these alternative locations.
|
|
||||||
// Note also that the files are normally zipped but in this case they are just an exe
|
|
||||||
// and lib file in a folder, not zipped.
|
|
||||||
function acquireNodeFromFallbackLocation(version) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
// Create temporary folder to download in to
|
|
||||||
let tempDownloadFolder = 'temp_' + Math.floor(Math.random() * 2000000000);
|
|
||||||
let tempDir = path.join(tempDirectory, tempDownloadFolder);
|
|
||||||
yield io.mkdirP(tempDir);
|
|
||||||
let exeUrl;
|
|
||||||
let libUrl;
|
|
||||||
try {
|
|
||||||
exeUrl = `https://nodejs.org/dist/v${version}/win-${os.arch()}/node.exe`;
|
|
||||||
libUrl = `https://nodejs.org/dist/v${version}/win-${os.arch()}/node.lib`;
|
|
||||||
const exePath = yield tc.downloadTool(exeUrl);
|
|
||||||
yield io.mv(exePath, path.join(tempDir, 'node.exe'));
|
|
||||||
const libPath = yield tc.downloadTool(libUrl);
|
|
||||||
yield io.mv(libPath, path.join(tempDir, 'node.lib'));
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
if (err instanceof tc.HTTPError && err.httpStatusCode == 404) {
|
|
||||||
exeUrl = `https://nodejs.org/dist/v${version}/node.exe`;
|
|
||||||
libUrl = `https://nodejs.org/dist/v${version}/node.lib`;
|
|
||||||
const exePath = yield tc.downloadTool(exeUrl);
|
|
||||||
yield io.mv(exePath, path.join(tempDir, 'node.exe'));
|
|
||||||
const libPath = yield tc.downloadTool(libUrl);
|
|
||||||
yield io.mv(libPath, path.join(tempDir, 'node.lib'));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return yield tc.cacheDir(tempDir, 'node', version);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
@ -1,44 +0,0 @@
|
||||||
"use strict";
|
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
||||||
result["default"] = mod;
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
const core = __importStar(require("@actions/core"));
|
|
||||||
const installer = __importStar(require("./installer"));
|
|
||||||
const path = __importStar(require("path"));
|
|
||||||
function run() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
try {
|
|
||||||
//
|
|
||||||
// Version is optional. If supplied, install / use from the tool cache
|
|
||||||
// If not supplied then task is still used to setup proxy, auth, etc...
|
|
||||||
//
|
|
||||||
const version = core.getInput('version');
|
|
||||||
if (version) {
|
|
||||||
// TODO: installer doesn't support proxy
|
|
||||||
yield installer.getNode(version);
|
|
||||||
}
|
|
||||||
// TODO: setup proxy from runner proxy config
|
|
||||||
const matchersPath = path.join(__dirname, '..', '.github');
|
|
||||||
console.log(`##[add-matcher]${path.join(matchersPath, 'tsc.json')}`);
|
|
||||||
console.log(`##[add-matcher]${path.join(matchersPath, 'eslint-stylish.json')}`);
|
|
||||||
console.log(`##[add-matcher]${path.join(matchersPath, 'eslint-compact.json')}`);
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
core.setFailed(error.message);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
run();
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
||||||
|
|
||||||
case `uname` in
|
|
||||||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if [ -x "$basedir/node" ]; then
|
|
||||||
"$basedir/node" "$basedir/../semver/bin/semver" "$@"
|
|
||||||
ret=$?
|
|
||||||
else
|
|
||||||
node "$basedir/../semver/bin/semver" "$@"
|
|
||||||
ret=$?
|
|
||||||
fi
|
|
||||||
exit $ret
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
@IF EXIST "%~dp0\node.exe" (
|
|
||||||
"%~dp0\node.exe" "%~dp0\..\semver\bin\semver" %*
|
|
||||||
) ELSE (
|
|
||||||
@SETLOCAL
|
|
||||||
@SET PATHEXT=%PATHEXT:;.JS;=;%
|
|
||||||
node "%~dp0\..\semver\bin\semver" %*
|
|
||||||
)
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
||||||
|
|
||||||
case `uname` in
|
|
||||||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if [ -x "$basedir/node" ]; then
|
|
||||||
"$basedir/node" "$basedir/../uuid/bin/uuid" "$@"
|
|
||||||
ret=$?
|
|
||||||
else
|
|
||||||
node "$basedir/../uuid/bin/uuid" "$@"
|
|
||||||
ret=$?
|
|
||||||
fi
|
|
||||||
exit $ret
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
@IF EXIST "%~dp0\node.exe" (
|
|
||||||
"%~dp0\node.exe" "%~dp0\..\uuid\bin\uuid" %*
|
|
||||||
) ELSE (
|
|
||||||
@SETLOCAL
|
|
||||||
@SET PATHEXT=%PATHEXT:;.JS;=;%
|
|
||||||
node "%~dp0\..\uuid\bin\uuid" %*
|
|
||||||
)
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
# `@actions/core`
|
|
||||||
|
|
||||||
> Core functions for setting results, logging, registering secrets and exporting variables across actions
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
See [src/core.ts](src/core.ts).
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
interface CommandProperties {
|
|
||||||
[key: string]: string;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Commands
|
|
||||||
*
|
|
||||||
* Command Format:
|
|
||||||
* ##[name key=value;key=value]message
|
|
||||||
*
|
|
||||||
* Examples:
|
|
||||||
* ##[warning]This is the user warning message
|
|
||||||
* ##[set-secret name=mypassword]definatelyNotAPassword!
|
|
||||||
*/
|
|
||||||
export declare function issueCommand(command: string, properties: CommandProperties, message: string): void;
|
|
||||||
export declare function issue(name: string, message: string): void;
|
|
||||||
export {};
|
|
||||||
|
|
@ -1,66 +0,0 @@
|
||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
const os = require("os");
|
|
||||||
/**
|
|
||||||
* Commands
|
|
||||||
*
|
|
||||||
* Command Format:
|
|
||||||
* ##[name key=value;key=value]message
|
|
||||||
*
|
|
||||||
* Examples:
|
|
||||||
* ##[warning]This is the user warning message
|
|
||||||
* ##[set-secret name=mypassword]definatelyNotAPassword!
|
|
||||||
*/
|
|
||||||
function issueCommand(command, properties, message) {
|
|
||||||
const cmd = new Command(command, properties, message);
|
|
||||||
process.stdout.write(cmd.toString() + os.EOL);
|
|
||||||
}
|
|
||||||
exports.issueCommand = issueCommand;
|
|
||||||
function issue(name, message) {
|
|
||||||
issueCommand(name, {}, message);
|
|
||||||
}
|
|
||||||
exports.issue = issue;
|
|
||||||
const CMD_PREFIX = '##[';
|
|
||||||
class Command {
|
|
||||||
constructor(command, properties, message) {
|
|
||||||
if (!command) {
|
|
||||||
command = 'missing.command';
|
|
||||||
}
|
|
||||||
this.command = command;
|
|
||||||
this.properties = properties;
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
toString() {
|
|
||||||
let cmdStr = CMD_PREFIX + this.command;
|
|
||||||
if (this.properties && Object.keys(this.properties).length > 0) {
|
|
||||||
cmdStr += ' ';
|
|
||||||
for (const key in this.properties) {
|
|
||||||
if (this.properties.hasOwnProperty(key)) {
|
|
||||||
const val = this.properties[key];
|
|
||||||
if (val) {
|
|
||||||
// safely append the val - avoid blowing up when attempting to
|
|
||||||
// call .replace() if message is not a string for some reason
|
|
||||||
cmdStr += `${key}=${escape(`${val || ''}`)};`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cmdStr += ']';
|
|
||||||
// safely append the message - avoid blowing up when attempting to
|
|
||||||
// call .replace() if message is not a string for some reason
|
|
||||||
const message = `${this.message || ''}`;
|
|
||||||
cmdStr += escapeData(message);
|
|
||||||
return cmdStr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function escapeData(s) {
|
|
||||||
return s.replace(/\r/g, '%0D').replace(/\n/g, '%0A');
|
|
||||||
}
|
|
||||||
function escape(s) {
|
|
||||||
return s
|
|
||||||
.replace(/\r/g, '%0D')
|
|
||||||
.replace(/\n/g, '%0A')
|
|
||||||
.replace(/]/g, '%5D')
|
|
||||||
.replace(/;/g, '%3B');
|
|
||||||
}
|
|
||||||
//# sourceMappingURL=command.js.map
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
{"version":3,"file":"command.js","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":";;AAAA,yBAAwB;AAQxB;;;;;;;;;GASG;AACH,SAAgB,YAAY,CAC1B,OAAe,EACf,UAA6B,EAC7B,OAAe;IAEf,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,CAAA;IACrD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAA;AAC/C,CAAC;AAPD,oCAOC;AAED,SAAgB,KAAK,CAAC,IAAY,EAAE,OAAe;IACjD,YAAY,CAAC,IAAI,EAAE,EAAE,EAAE,OAAO,CAAC,CAAA;AACjC,CAAC;AAFD,sBAEC;AAED,MAAM,UAAU,GAAG,KAAK,CAAA;AAExB,MAAM,OAAO;IAKX,YAAY,OAAe,EAAE,UAA6B,EAAE,OAAe;QACzE,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO,GAAG,iBAAiB,CAAA;SAC5B;QAED,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;IAED,QAAQ;QACN,IAAI,MAAM,GAAG,UAAU,GAAG,IAAI,CAAC,OAAO,CAAA;QAEtC,IAAI,IAAI,CAAC,UAAU,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE;YAC9D,MAAM,IAAI,GAAG,CAAA;YACb,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,UAAU,EAAE;gBACjC,IAAI,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE;oBACvC,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;oBAChC,IAAI,GAAG,EAAE;wBACP,8DAA8D;wBAC9D,6DAA6D;wBAC7D,MAAM,IAAI,GAAG,GAAG,IAAI,MAAM,CAAC,GAAG,GAAG,IAAI,EAAE,EAAE,CAAC,GAAG,CAAA;qBAC9C;iBACF;aACF;SACF;QAED,MAAM,IAAI,GAAG,CAAA;QAEb,kEAAkE;QAClE,6DAA6D;QAC7D,MAAM,OAAO,GAAG,GAAG,IAAI,CAAC,OAAO,IAAI,EAAE,EAAE,CAAA;QACvC,MAAM,IAAI,UAAU,CAAC,OAAO,CAAC,CAAA;QAE7B,OAAO,MAAM,CAAA;IACf,CAAC;CACF;AAED,SAAS,UAAU,CAAC,CAAS;IAC3B,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;AACtD,CAAC;AAED,SAAS,MAAM,CAAC,CAAS;IACvB,OAAO,CAAC;SACL,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;SACrB,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC;SACpB,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;AACzB,CAAC"}
|
|
||||||
|
|
@ -1,57 +0,0 @@
|
||||||
/**
|
|
||||||
* Interface for getInput options
|
|
||||||
*/
|
|
||||||
export interface InputOptions {
|
|
||||||
/** Optional. Whether the input is required. If required and not present, will throw. Defaults to false */
|
|
||||||
required?: boolean;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* sets env variable for this action and future actions in the job
|
|
||||||
* @param name the name of the variable to set
|
|
||||||
* @param val the value of the variable
|
|
||||||
*/
|
|
||||||
export declare function exportVariable(name: string, val: string): void;
|
|
||||||
/**
|
|
||||||
* exports the variable and registers a secret which will get masked from logs
|
|
||||||
* @param name the name of the variable to set
|
|
||||||
* @param val value of the secret
|
|
||||||
*/
|
|
||||||
export declare function exportSecret(name: string, val: string): void;
|
|
||||||
/**
|
|
||||||
* Prepends inputPath to the PATH (for this action and future actions)
|
|
||||||
* @param inputPath
|
|
||||||
*/
|
|
||||||
export declare function addPath(inputPath: string): void;
|
|
||||||
/**
|
|
||||||
* Gets the value of an input. The value is also trimmed.
|
|
||||||
*
|
|
||||||
* @param name name of the input to get
|
|
||||||
* @param options optional. See InputOptions.
|
|
||||||
* @returns string
|
|
||||||
*/
|
|
||||||
export declare function getInput(name: string, options?: InputOptions): string;
|
|
||||||
/**
|
|
||||||
* Sets the action status to neutral
|
|
||||||
*/
|
|
||||||
export declare function setNeutral(): void;
|
|
||||||
/**
|
|
||||||
* Sets the action status to failed.
|
|
||||||
* When the action exits it will be with an exit code of 1
|
|
||||||
* @param message add error issue message
|
|
||||||
*/
|
|
||||||
export declare function setFailed(message: string): void;
|
|
||||||
/**
|
|
||||||
* Writes debug message to user log
|
|
||||||
* @param message debug message
|
|
||||||
*/
|
|
||||||
export declare function debug(message: string): void;
|
|
||||||
/**
|
|
||||||
* Adds an error issue
|
|
||||||
* @param message error issue message
|
|
||||||
*/
|
|
||||||
export declare function error(message: string): void;
|
|
||||||
/**
|
|
||||||
* Adds an warning issue
|
|
||||||
* @param message warning issue message
|
|
||||||
*/
|
|
||||||
export declare function warning(message: string): void;
|
|
||||||
|
|
@ -1,100 +0,0 @@
|
||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
const exit_1 = require("@actions/exit");
|
|
||||||
const command_1 = require("./command");
|
|
||||||
const path = require("path");
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
// Variables
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* sets env variable for this action and future actions in the job
|
|
||||||
* @param name the name of the variable to set
|
|
||||||
* @param val the value of the variable
|
|
||||||
*/
|
|
||||||
function exportVariable(name, val) {
|
|
||||||
process.env[name] = val;
|
|
||||||
command_1.issueCommand('set-env', { name }, val);
|
|
||||||
}
|
|
||||||
exports.exportVariable = exportVariable;
|
|
||||||
/**
|
|
||||||
* exports the variable and registers a secret which will get masked from logs
|
|
||||||
* @param name the name of the variable to set
|
|
||||||
* @param val value of the secret
|
|
||||||
*/
|
|
||||||
function exportSecret(name, val) {
|
|
||||||
exportVariable(name, val);
|
|
||||||
command_1.issueCommand('set-secret', {}, val);
|
|
||||||
}
|
|
||||||
exports.exportSecret = exportSecret;
|
|
||||||
/**
|
|
||||||
* Prepends inputPath to the PATH (for this action and future actions)
|
|
||||||
* @param inputPath
|
|
||||||
*/
|
|
||||||
function addPath(inputPath) {
|
|
||||||
command_1.issueCommand('add-path', {}, inputPath);
|
|
||||||
process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
|
|
||||||
}
|
|
||||||
exports.addPath = addPath;
|
|
||||||
/**
|
|
||||||
* Gets the value of an input. The value is also trimmed.
|
|
||||||
*
|
|
||||||
* @param name name of the input to get
|
|
||||||
* @param options optional. See InputOptions.
|
|
||||||
* @returns string
|
|
||||||
*/
|
|
||||||
function getInput(name, options) {
|
|
||||||
const val = process.env[`INPUT_${name.replace(' ', '_').toUpperCase()}`] || '';
|
|
||||||
if (options && options.required && !val) {
|
|
||||||
throw new Error(`Input required and not supplied: ${name}`);
|
|
||||||
}
|
|
||||||
return val.trim();
|
|
||||||
}
|
|
||||||
exports.getInput = getInput;
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
// Results
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* Sets the action status to neutral
|
|
||||||
*/
|
|
||||||
function setNeutral() {
|
|
||||||
process.exitCode = exit_1.ExitCode.Neutral;
|
|
||||||
}
|
|
||||||
exports.setNeutral = setNeutral;
|
|
||||||
/**
|
|
||||||
* Sets the action status to failed.
|
|
||||||
* When the action exits it will be with an exit code of 1
|
|
||||||
* @param message add error issue message
|
|
||||||
*/
|
|
||||||
function setFailed(message) {
|
|
||||||
process.exitCode = exit_1.ExitCode.Failure;
|
|
||||||
error(message);
|
|
||||||
}
|
|
||||||
exports.setFailed = setFailed;
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
// Logging Commands
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* Writes debug message to user log
|
|
||||||
* @param message debug message
|
|
||||||
*/
|
|
||||||
function debug(message) {
|
|
||||||
command_1.issueCommand('debug', {}, message);
|
|
||||||
}
|
|
||||||
exports.debug = debug;
|
|
||||||
/**
|
|
||||||
* Adds an error issue
|
|
||||||
* @param message error issue message
|
|
||||||
*/
|
|
||||||
function error(message) {
|
|
||||||
command_1.issue('error', message);
|
|
||||||
}
|
|
||||||
exports.error = error;
|
|
||||||
/**
|
|
||||||
* Adds an warning issue
|
|
||||||
* @param message warning issue message
|
|
||||||
*/
|
|
||||||
function warning(message) {
|
|
||||||
command_1.issue('warning', message);
|
|
||||||
}
|
|
||||||
exports.warning = warning;
|
|
||||||
//# sourceMappingURL=core.js.map
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
{"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":";;AAAA,wCAAsC;AACtC,uCAA6C;AAE7C,6BAA4B;AAU5B,yEAAyE;AACzE,YAAY;AACZ,yEAAyE;AAEzE;;;;GAIG;AACH,SAAgB,cAAc,CAAC,IAAY,EAAE,GAAW;IACtD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAA;IACvB,sBAAY,CAAC,SAAS,EAAE,EAAC,IAAI,EAAC,EAAE,GAAG,CAAC,CAAA;AACtC,CAAC;AAHD,wCAGC;AAED;;;;GAIG;AACH,SAAgB,YAAY,CAAC,IAAY,EAAE,GAAW;IACpD,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;IACzB,sBAAY,CAAC,YAAY,EAAE,EAAE,EAAE,GAAG,CAAC,CAAA;AACrC,CAAC;AAHD,oCAGC;AAED;;;GAGG;AACH,SAAgB,OAAO,CAAC,SAAiB;IACvC,sBAAY,CAAC,UAAU,EAAE,EAAE,EAAE,SAAS,CAAC,CAAA;IACvC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,GAAG,SAAS,GAAG,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAA;AAC7E,CAAC;AAHD,0BAGC;AAED;;;;;;GAMG;AACH,SAAgB,QAAQ,CAAC,IAAY,EAAE,OAAsB;IAC3D,MAAM,GAAG,GACP,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,IAAI,EAAE,CAAA;IACpE,IAAI,OAAO,IAAI,OAAO,CAAC,QAAQ,IAAI,CAAC,GAAG,EAAE;QACvC,MAAM,IAAI,KAAK,CAAC,oCAAoC,IAAI,EAAE,CAAC,CAAA;KAC5D;IAED,OAAO,GAAG,CAAC,IAAI,EAAE,CAAA;AACnB,CAAC;AARD,4BAQC;AAED,yEAAyE;AACzE,UAAU;AACV,yEAAyE;AAEzE;;GAEG;AACH,SAAgB,UAAU;IACxB,OAAO,CAAC,QAAQ,GAAG,eAAQ,CAAC,OAAO,CAAA;AACrC,CAAC;AAFD,gCAEC;AAED;;;;GAIG;AACH,SAAgB,SAAS,CAAC,OAAe;IACvC,OAAO,CAAC,QAAQ,GAAG,eAAQ,CAAC,OAAO,CAAA;IACnC,KAAK,CAAC,OAAO,CAAC,CAAA;AAChB,CAAC;AAHD,8BAGC;AAED,yEAAyE;AACzE,mBAAmB;AACnB,yEAAyE;AAEzE;;;GAGG;AACH,SAAgB,KAAK,CAAC,OAAe;IACnC,sBAAY,CAAC,OAAO,EAAE,EAAE,EAAE,OAAO,CAAC,CAAA;AACpC,CAAC;AAFD,sBAEC;AAED;;;GAGG;AACH,SAAgB,KAAK,CAAC,OAAe;IACnC,eAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;AACzB,CAAC;AAFD,sBAEC;AAED;;;GAGG;AACH,SAAgB,OAAO,CAAC,OAAe;IACrC,eAAK,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;AAC3B,CAAC;AAFD,0BAEC"}
|
|
||||||
|
|
@ -1,66 +0,0 @@
|
||||||
{
|
|
||||||
"_from": "file:toolkit\\actions-core-0.0.0.tgz",
|
|
||||||
"_id": "@actions/core@0.0.0",
|
|
||||||
"_inBundle": false,
|
|
||||||
"_integrity": "sha512-58ituSV1rzBMmmsWoFDnrnsT+Wm4kD/u9NgAGbPvZ7rQHWluYtD5bDbIsjDC6rKFuhqytkxDJPsF/TWBdgc/nA==",
|
|
||||||
"_location": "/@actions/core",
|
|
||||||
"_phantomChildren": {},
|
|
||||||
"_requested": {
|
|
||||||
"type": "file",
|
|
||||||
"where": "C:\\Users\\Administrator\\Documents\\setup-node",
|
|
||||||
"raw": "@actions/core@file:toolkit/actions-core-0.0.0.tgz",
|
|
||||||
"name": "@actions/core",
|
|
||||||
"escapedName": "@actions%2fcore",
|
|
||||||
"scope": "@actions",
|
|
||||||
"rawSpec": "file:toolkit/actions-core-0.0.0.tgz",
|
|
||||||
"saveSpec": "file:toolkit\\actions-core-0.0.0.tgz",
|
|
||||||
"fetchSpec": "C:\\Users\\Administrator\\Documents\\setup-node\\toolkit\\actions-core-0.0.0.tgz"
|
|
||||||
},
|
|
||||||
"_requiredBy": [
|
|
||||||
"/",
|
|
||||||
"/@actions/tool-cache"
|
|
||||||
],
|
|
||||||
"_resolved": "C:\\Users\\Administrator\\Documents\\setup-node\\toolkit\\actions-core-0.0.0.tgz",
|
|
||||||
"_shasum": "346d90a534fa6c5021bc2e1b732574fd2c66fc35",
|
|
||||||
"_spec": "@actions/core@file:toolkit/actions-core-0.0.0.tgz",
|
|
||||||
"_where": "C:\\Users\\Administrator\\Documents\\setup-node",
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/actions/toolkit/issues"
|
|
||||||
},
|
|
||||||
"bundleDependencies": false,
|
|
||||||
"dependencies": {
|
|
||||||
"@actions/exit": "^0.0.0"
|
|
||||||
},
|
|
||||||
"deprecated": false,
|
|
||||||
"description": "Actions core lib",
|
|
||||||
"devDependencies": {
|
|
||||||
"@types/node": "^12.0.2"
|
|
||||||
},
|
|
||||||
"directories": {
|
|
||||||
"lib": "lib",
|
|
||||||
"test": "__tests__"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"lib"
|
|
||||||
],
|
|
||||||
"homepage": "https://github.com/actions/toolkit/tree/master/packages/core",
|
|
||||||
"keywords": [
|
|
||||||
"core",
|
|
||||||
"actions"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"main": "lib/core.js",
|
|
||||||
"name": "@actions/core",
|
|
||||||
"publishConfig": {
|
|
||||||
"access": "public"
|
|
||||||
},
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/actions/toolkit.git"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"test": "echo \"Error: run tests from root\" && exit 1",
|
|
||||||
"tsc": "tsc"
|
|
||||||
},
|
|
||||||
"version": "0.0.0"
|
|
||||||
}
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
# `@actions/exec`
|
|
||||||
|
|
||||||
> Functions necessary for running tools on the command line
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
See [src/exec.ts](src/exec.ts).
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
import * as im from './interfaces';
|
|
||||||
/**
|
|
||||||
* Exec a command.
|
|
||||||
* Output will be streamed to the live console.
|
|
||||||
* Returns promise with return code
|
|
||||||
*
|
|
||||||
* @param commandLine command to execute (can include additional args). Must be correctly escaped.
|
|
||||||
* @param args optional arguments for tool. Escaping is handled by the lib.
|
|
||||||
* @param options optional exec options. See ExecOptions
|
|
||||||
* @returns Promise<number> exit code
|
|
||||||
*/
|
|
||||||
export declare function exec(commandLine: string, args?: string[], options?: im.ExecOptions): Promise<number>;
|
|
||||||
|
|
@ -1,36 +0,0 @@
|
||||||
"use strict";
|
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
const tr = require("./toolrunner");
|
|
||||||
/**
|
|
||||||
* Exec a command.
|
|
||||||
* Output will be streamed to the live console.
|
|
||||||
* Returns promise with return code
|
|
||||||
*
|
|
||||||
* @param commandLine command to execute (can include additional args). Must be correctly escaped.
|
|
||||||
* @param args optional arguments for tool. Escaping is handled by the lib.
|
|
||||||
* @param options optional exec options. See ExecOptions
|
|
||||||
* @returns Promise<number> exit code
|
|
||||||
*/
|
|
||||||
function exec(commandLine, args, options) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
const commandArgs = tr.argStringToArray(commandLine);
|
|
||||||
if (commandArgs.length === 0) {
|
|
||||||
throw new Error(`Parameter 'commandLine' cannot be null or empty.`);
|
|
||||||
}
|
|
||||||
// Path to tool to execute should be first arg
|
|
||||||
const toolPath = commandArgs[0];
|
|
||||||
args = commandArgs.slice(1).concat(args || []);
|
|
||||||
const runner = new tr.ToolRunner(toolPath, args, options);
|
|
||||||
return runner.exec();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
exports.exec = exec;
|
|
||||||
//# sourceMappingURL=exec.js.map
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
{"version":3,"file":"exec.js","sourceRoot":"","sources":["../src/exec.ts"],"names":[],"mappings":";;;;;;;;;;AACA,mCAAkC;AAElC;;;;;;;;;GASG;AACH,SAAsB,IAAI,CACxB,WAAmB,EACnB,IAAe,EACf,OAAwB;;QAExB,MAAM,WAAW,GAAG,EAAE,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAA;QACpD,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE;YAC5B,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAA;SACpE;QACD,8CAA8C;QAC9C,MAAM,QAAQ,GAAG,WAAW,CAAC,CAAC,CAAC,CAAA;QAC/B,IAAI,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC,CAAA;QAC9C,MAAM,MAAM,GAAkB,IAAI,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;QACxE,OAAO,MAAM,CAAC,IAAI,EAAE,CAAA;IACtB,CAAC;CAAA;AAdD,oBAcC"}
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
/// <reference types="node" />
|
|
||||||
import * as stream from 'stream';
|
|
||||||
/**
|
|
||||||
* Interface for exec options
|
|
||||||
*/
|
|
||||||
export interface ExecOptions {
|
|
||||||
/** optional working directory. defaults to current */
|
|
||||||
cwd?: string;
|
|
||||||
/** optional envvar dictionary. defaults to current process's env */
|
|
||||||
env?: {
|
|
||||||
[key: string]: string;
|
|
||||||
};
|
|
||||||
/** optional. defaults to false */
|
|
||||||
silent?: boolean;
|
|
||||||
/** optional out stream to use. Defaults to process.stdout */
|
|
||||||
outStream?: stream.Writable;
|
|
||||||
/** optional err stream to use. Defaults to process.stderr */
|
|
||||||
errStream?: stream.Writable;
|
|
||||||
/** optional. whether to skip quoting/escaping arguments if needed. defaults to false. */
|
|
||||||
windowsVerbatimArguments?: boolean;
|
|
||||||
/** optional. whether to fail if output to stderr. defaults to false */
|
|
||||||
failOnStdErr?: boolean;
|
|
||||||
/** optional. defaults to failing on non zero. ignore will not fail leaving it up to the caller */
|
|
||||||
ignoreReturnCode?: boolean;
|
|
||||||
/** optional. How long in ms to wait for STDIO streams to close after the exit event of the process before terminating. defaults to 10000 */
|
|
||||||
delay?: number;
|
|
||||||
/** optional. Listeners for output. Callback functions that will be called on these events */
|
|
||||||
listeners?: {
|
|
||||||
stdout?: (data: Buffer) => void;
|
|
||||||
stderr?: (data: Buffer) => void;
|
|
||||||
stdline?: (data: string) => void;
|
|
||||||
errline?: (data: string) => void;
|
|
||||||
debug?: (data: string) => void;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
//# sourceMappingURL=interfaces.js.map
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":""}
|
|
||||||
|
|
@ -1,37 +0,0 @@
|
||||||
/// <reference types="node" />
|
|
||||||
import * as events from 'events';
|
|
||||||
import * as im from './interfaces';
|
|
||||||
export declare class ToolRunner extends events.EventEmitter {
|
|
||||||
constructor(toolPath: string, args?: string[], options?: im.ExecOptions);
|
|
||||||
private toolPath;
|
|
||||||
private args;
|
|
||||||
private options;
|
|
||||||
private _debug;
|
|
||||||
private _getCommandString;
|
|
||||||
private _processLineBuffer;
|
|
||||||
private _getSpawnFileName;
|
|
||||||
private _getSpawnArgs;
|
|
||||||
private _endsWith;
|
|
||||||
private _isCmdFile;
|
|
||||||
private _windowsQuoteCmdArg;
|
|
||||||
private _uvQuoteCmdArg;
|
|
||||||
private _cloneExecOptions;
|
|
||||||
private _getSpawnOptions;
|
|
||||||
/**
|
|
||||||
* Exec a tool.
|
|
||||||
* Output will be streamed to the live console.
|
|
||||||
* Returns promise with return code
|
|
||||||
*
|
|
||||||
* @param tool path to tool to exec
|
|
||||||
* @param options optional exec options. See ExecOptions
|
|
||||||
* @returns number
|
|
||||||
*/
|
|
||||||
exec(): Promise<number>;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Convert an arg string to an array of args. Handles escaping
|
|
||||||
*
|
|
||||||
* @param argString string of arguments
|
|
||||||
* @returns string[] array of arguments
|
|
||||||
*/
|
|
||||||
export declare function argStringToArray(argString: string): string[];
|
|
||||||
|
|
@ -1,573 +0,0 @@
|
||||||
"use strict";
|
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
const os = require("os");
|
|
||||||
const events = require("events");
|
|
||||||
const child = require("child_process");
|
|
||||||
/* eslint-disable @typescript-eslint/unbound-method */
|
|
||||||
const IS_WINDOWS = process.platform === 'win32';
|
|
||||||
/*
|
|
||||||
* Class for running command line tools. Handles quoting and arg parsing in a platform agnostic way.
|
|
||||||
*/
|
|
||||||
class ToolRunner extends events.EventEmitter {
|
|
||||||
constructor(toolPath, args, options) {
|
|
||||||
super();
|
|
||||||
if (!toolPath) {
|
|
||||||
throw new Error("Parameter 'toolPath' cannot be null or empty.");
|
|
||||||
}
|
|
||||||
this.toolPath = toolPath;
|
|
||||||
this.args = args || [];
|
|
||||||
this.options = options || {};
|
|
||||||
}
|
|
||||||
_debug(message) {
|
|
||||||
if (this.options.listeners && this.options.listeners.debug) {
|
|
||||||
this.options.listeners.debug(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_getCommandString(options, noPrefix) {
|
|
||||||
const toolPath = this._getSpawnFileName();
|
|
||||||
const args = this._getSpawnArgs(options);
|
|
||||||
let cmd = noPrefix ? '' : '[command]'; // omit prefix when piped to a second tool
|
|
||||||
if (IS_WINDOWS) {
|
|
||||||
// Windows + cmd file
|
|
||||||
if (this._isCmdFile()) {
|
|
||||||
cmd += toolPath;
|
|
||||||
for (const a of args) {
|
|
||||||
cmd += ` ${a}`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Windows + verbatim
|
|
||||||
else if (options.windowsVerbatimArguments) {
|
|
||||||
cmd += `"${toolPath}"`;
|
|
||||||
for (const a of args) {
|
|
||||||
cmd += ` ${a}`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Windows (regular)
|
|
||||||
else {
|
|
||||||
cmd += this._windowsQuoteCmdArg(toolPath);
|
|
||||||
for (const a of args) {
|
|
||||||
cmd += ` ${this._windowsQuoteCmdArg(a)}`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// OSX/Linux - this can likely be improved with some form of quoting.
|
|
||||||
// creating processes on Unix is fundamentally different than Windows.
|
|
||||||
// on Unix, execvp() takes an arg array.
|
|
||||||
cmd += toolPath;
|
|
||||||
for (const a of args) {
|
|
||||||
cmd += ` ${a}`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return cmd;
|
|
||||||
}
|
|
||||||
_processLineBuffer(data, strBuffer, onLine) {
|
|
||||||
try {
|
|
||||||
let s = strBuffer + data.toString();
|
|
||||||
let n = s.indexOf(os.EOL);
|
|
||||||
while (n > -1) {
|
|
||||||
const line = s.substring(0, n);
|
|
||||||
onLine(line);
|
|
||||||
// the rest of the string ...
|
|
||||||
s = s.substring(n + os.EOL.length);
|
|
||||||
n = s.indexOf(os.EOL);
|
|
||||||
}
|
|
||||||
strBuffer = s;
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
// streaming lines to console is best effort. Don't fail a build.
|
|
||||||
this._debug(`error processing line. Failed with error ${err}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_getSpawnFileName() {
|
|
||||||
if (IS_WINDOWS) {
|
|
||||||
if (this._isCmdFile()) {
|
|
||||||
return process.env['COMSPEC'] || 'cmd.exe';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return this.toolPath;
|
|
||||||
}
|
|
||||||
_getSpawnArgs(options) {
|
|
||||||
if (IS_WINDOWS) {
|
|
||||||
if (this._isCmdFile()) {
|
|
||||||
let argline = `/D /S /C "${this._windowsQuoteCmdArg(this.toolPath)}`;
|
|
||||||
for (const a of this.args) {
|
|
||||||
argline += ' ';
|
|
||||||
argline += options.windowsVerbatimArguments
|
|
||||||
? a
|
|
||||||
: this._windowsQuoteCmdArg(a);
|
|
||||||
}
|
|
||||||
argline += '"';
|
|
||||||
return [argline];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return this.args;
|
|
||||||
}
|
|
||||||
_endsWith(str, end) {
|
|
||||||
return str.endsWith(end);
|
|
||||||
}
|
|
||||||
_isCmdFile() {
|
|
||||||
const upperToolPath = this.toolPath.toUpperCase();
|
|
||||||
return (this._endsWith(upperToolPath, '.CMD') ||
|
|
||||||
this._endsWith(upperToolPath, '.BAT'));
|
|
||||||
}
|
|
||||||
_windowsQuoteCmdArg(arg) {
|
|
||||||
// for .exe, apply the normal quoting rules that libuv applies
|
|
||||||
if (!this._isCmdFile()) {
|
|
||||||
return this._uvQuoteCmdArg(arg);
|
|
||||||
}
|
|
||||||
// otherwise apply quoting rules specific to the cmd.exe command line parser.
|
|
||||||
// the libuv rules are generic and are not designed specifically for cmd.exe
|
|
||||||
// command line parser.
|
|
||||||
//
|
|
||||||
// for a detailed description of the cmd.exe command line parser, refer to
|
|
||||||
// http://stackoverflow.com/questions/4094699/how-does-the-windows-command-interpreter-cmd-exe-parse-scripts/7970912#7970912
|
|
||||||
// need quotes for empty arg
|
|
||||||
if (!arg) {
|
|
||||||
return '""';
|
|
||||||
}
|
|
||||||
// determine whether the arg needs to be quoted
|
|
||||||
const cmdSpecialChars = [
|
|
||||||
' ',
|
|
||||||
'\t',
|
|
||||||
'&',
|
|
||||||
'(',
|
|
||||||
')',
|
|
||||||
'[',
|
|
||||||
']',
|
|
||||||
'{',
|
|
||||||
'}',
|
|
||||||
'^',
|
|
||||||
'=',
|
|
||||||
';',
|
|
||||||
'!',
|
|
||||||
"'",
|
|
||||||
'+',
|
|
||||||
',',
|
|
||||||
'`',
|
|
||||||
'~',
|
|
||||||
'|',
|
|
||||||
'<',
|
|
||||||
'>',
|
|
||||||
'"'
|
|
||||||
];
|
|
||||||
let needsQuotes = false;
|
|
||||||
for (const char of arg) {
|
|
||||||
if (cmdSpecialChars.some(x => x === char)) {
|
|
||||||
needsQuotes = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// short-circuit if quotes not needed
|
|
||||||
if (!needsQuotes) {
|
|
||||||
return arg;
|
|
||||||
}
|
|
||||||
// the following quoting rules are very similar to the rules that by libuv applies.
|
|
||||||
//
|
|
||||||
// 1) wrap the string in quotes
|
|
||||||
//
|
|
||||||
// 2) double-up quotes - i.e. " => ""
|
|
||||||
//
|
|
||||||
// this is different from the libuv quoting rules. libuv replaces " with \", which unfortunately
|
|
||||||
// doesn't work well with a cmd.exe command line.
|
|
||||||
//
|
|
||||||
// note, replacing " with "" also works well if the arg is passed to a downstream .NET console app.
|
|
||||||
// for example, the command line:
|
|
||||||
// foo.exe "myarg:""my val"""
|
|
||||||
// is parsed by a .NET console app into an arg array:
|
|
||||||
// [ "myarg:\"my val\"" ]
|
|
||||||
// which is the same end result when applying libuv quoting rules. although the actual
|
|
||||||
// command line from libuv quoting rules would look like:
|
|
||||||
// foo.exe "myarg:\"my val\""
|
|
||||||
//
|
|
||||||
// 3) double-up slashes that preceed a quote,
|
|
||||||
// e.g. hello \world => "hello \world"
|
|
||||||
// hello\"world => "hello\\""world"
|
|
||||||
// hello\\"world => "hello\\\\""world"
|
|
||||||
// hello world\ => "hello world\\"
|
|
||||||
//
|
|
||||||
// technically this is not required for a cmd.exe command line, or the batch argument parser.
|
|
||||||
// the reasons for including this as a .cmd quoting rule are:
|
|
||||||
//
|
|
||||||
// a) this is optimized for the scenario where the argument is passed from the .cmd file to an
|
|
||||||
// external program. many programs (e.g. .NET console apps) rely on the slash-doubling rule.
|
|
||||||
//
|
|
||||||
// b) it's what we've been doing previously (by deferring to node default behavior) and we
|
|
||||||
// haven't heard any complaints about that aspect.
|
|
||||||
//
|
|
||||||
// note, a weakness of the quoting rules chosen here, is that % is not escaped. in fact, % cannot be
|
|
||||||
// escaped when used on the command line directly - even though within a .cmd file % can be escaped
|
|
||||||
// by using %%.
|
|
||||||
//
|
|
||||||
// the saving grace is, on the command line, %var% is left as-is if var is not defined. this contrasts
|
|
||||||
// the line parsing rules within a .cmd file, where if var is not defined it is replaced with nothing.
|
|
||||||
//
|
|
||||||
// one option that was explored was replacing % with ^% - i.e. %var% => ^%var^%. this hack would
|
|
||||||
// often work, since it is unlikely that var^ would exist, and the ^ character is removed when the
|
|
||||||
// variable is used. the problem, however, is that ^ is not removed when %* is used to pass the args
|
|
||||||
// to an external program.
|
|
||||||
//
|
|
||||||
// an unexplored potential solution for the % escaping problem, is to create a wrapper .cmd file.
|
|
||||||
// % can be escaped within a .cmd file.
|
|
||||||
let reverse = '"';
|
|
||||||
let quoteHit = true;
|
|
||||||
for (let i = arg.length; i > 0; i--) {
|
|
||||||
// walk the string in reverse
|
|
||||||
reverse += arg[i - 1];
|
|
||||||
if (quoteHit && arg[i - 1] === '\\') {
|
|
||||||
reverse += '\\'; // double the slash
|
|
||||||
}
|
|
||||||
else if (arg[i - 1] === '"') {
|
|
||||||
quoteHit = true;
|
|
||||||
reverse += '"'; // double the quote
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
quoteHit = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
reverse += '"';
|
|
||||||
return reverse
|
|
||||||
.split('')
|
|
||||||
.reverse()
|
|
||||||
.join('');
|
|
||||||
}
|
|
||||||
_uvQuoteCmdArg(arg) {
|
|
||||||
// Tool runner wraps child_process.spawn() and needs to apply the same quoting as
|
|
||||||
// Node in certain cases where the undocumented spawn option windowsVerbatimArguments
|
|
||||||
// is used.
|
|
||||||
//
|
|
||||||
// Since this function is a port of quote_cmd_arg from Node 4.x (technically, lib UV,
|
|
||||||
// see https://github.com/nodejs/node/blob/v4.x/deps/uv/src/win/process.c for details),
|
|
||||||
// pasting copyright notice from Node within this function:
|
|
||||||
//
|
|
||||||
// Copyright Joyent, Inc. and other Node contributors. All rights reserved.
|
|
||||||
//
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
// of this software and associated documentation files (the "Software"), to
|
|
||||||
// deal in the Software without restriction, including without limitation the
|
|
||||||
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
||||||
// sell copies of the Software, and to permit persons to whom the Software is
|
|
||||||
// furnished to do so, subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in
|
|
||||||
// all copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
||||||
// IN THE SOFTWARE.
|
|
||||||
if (!arg) {
|
|
||||||
// Need double quotation for empty argument
|
|
||||||
return '""';
|
|
||||||
}
|
|
||||||
if (!arg.includes(' ') && !arg.includes('\t') && !arg.includes('"')) {
|
|
||||||
// No quotation needed
|
|
||||||
return arg;
|
|
||||||
}
|
|
||||||
if (!arg.includes('"') && !arg.includes('\\')) {
|
|
||||||
// No embedded double quotes or backslashes, so I can just wrap
|
|
||||||
// quote marks around the whole thing.
|
|
||||||
return `"${arg}"`;
|
|
||||||
}
|
|
||||||
// Expected input/output:
|
|
||||||
// input : hello"world
|
|
||||||
// output: "hello\"world"
|
|
||||||
// input : hello""world
|
|
||||||
// output: "hello\"\"world"
|
|
||||||
// input : hello\world
|
|
||||||
// output: hello\world
|
|
||||||
// input : hello\\world
|
|
||||||
// output: hello\\world
|
|
||||||
// input : hello\"world
|
|
||||||
// output: "hello\\\"world"
|
|
||||||
// input : hello\\"world
|
|
||||||
// output: "hello\\\\\"world"
|
|
||||||
// input : hello world\
|
|
||||||
// output: "hello world\\" - note the comment in libuv actually reads "hello world\"
|
|
||||||
// but it appears the comment is wrong, it should be "hello world\\"
|
|
||||||
let reverse = '"';
|
|
||||||
let quoteHit = true;
|
|
||||||
for (let i = arg.length; i > 0; i--) {
|
|
||||||
// walk the string in reverse
|
|
||||||
reverse += arg[i - 1];
|
|
||||||
if (quoteHit && arg[i - 1] === '\\') {
|
|
||||||
reverse += '\\';
|
|
||||||
}
|
|
||||||
else if (arg[i - 1] === '"') {
|
|
||||||
quoteHit = true;
|
|
||||||
reverse += '\\';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
quoteHit = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
reverse += '"';
|
|
||||||
return reverse
|
|
||||||
.split('')
|
|
||||||
.reverse()
|
|
||||||
.join('');
|
|
||||||
}
|
|
||||||
_cloneExecOptions(options) {
|
|
||||||
options = options || {};
|
|
||||||
const result = {
|
|
||||||
cwd: options.cwd || process.cwd(),
|
|
||||||
env: options.env || process.env,
|
|
||||||
silent: options.silent || false,
|
|
||||||
windowsVerbatimArguments: options.windowsVerbatimArguments || false,
|
|
||||||
failOnStdErr: options.failOnStdErr || false,
|
|
||||||
ignoreReturnCode: options.ignoreReturnCode || false,
|
|
||||||
delay: options.delay || 10000
|
|
||||||
};
|
|
||||||
result.outStream = options.outStream || process.stdout;
|
|
||||||
result.errStream = options.errStream || process.stderr;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
_getSpawnOptions(options, toolPath) {
|
|
||||||
options = options || {};
|
|
||||||
const result = {};
|
|
||||||
result.cwd = options.cwd;
|
|
||||||
result.env = options.env;
|
|
||||||
result['windowsVerbatimArguments'] =
|
|
||||||
options.windowsVerbatimArguments || this._isCmdFile();
|
|
||||||
if (options.windowsVerbatimArguments) {
|
|
||||||
result.argv0 = `"${toolPath}"`;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Exec a tool.
|
|
||||||
* Output will be streamed to the live console.
|
|
||||||
* Returns promise with return code
|
|
||||||
*
|
|
||||||
* @param tool path to tool to exec
|
|
||||||
* @param options optional exec options. See ExecOptions
|
|
||||||
* @returns number
|
|
||||||
*/
|
|
||||||
exec() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
this._debug(`exec tool: ${this.toolPath}`);
|
|
||||||
this._debug('arguments:');
|
|
||||||
for (const arg of this.args) {
|
|
||||||
this._debug(` ${arg}`);
|
|
||||||
}
|
|
||||||
const optionsNonNull = this._cloneExecOptions(this.options);
|
|
||||||
if (!optionsNonNull.silent && optionsNonNull.outStream) {
|
|
||||||
optionsNonNull.outStream.write(this._getCommandString(optionsNonNull) + os.EOL);
|
|
||||||
}
|
|
||||||
const state = new ExecState(optionsNonNull, this.toolPath);
|
|
||||||
state.on('debug', (message) => {
|
|
||||||
this._debug(message);
|
|
||||||
});
|
|
||||||
const fileName = this._getSpawnFileName();
|
|
||||||
const cp = child.spawn(fileName, this._getSpawnArgs(optionsNonNull), this._getSpawnOptions(this.options, fileName));
|
|
||||||
const stdbuffer = '';
|
|
||||||
if (cp.stdout) {
|
|
||||||
cp.stdout.on('data', (data) => {
|
|
||||||
if (this.options.listeners && this.options.listeners.stdout) {
|
|
||||||
this.options.listeners.stdout(data);
|
|
||||||
}
|
|
||||||
if (!optionsNonNull.silent && optionsNonNull.outStream) {
|
|
||||||
optionsNonNull.outStream.write(data);
|
|
||||||
}
|
|
||||||
this._processLineBuffer(data, stdbuffer, (line) => {
|
|
||||||
if (this.options.listeners && this.options.listeners.stdline) {
|
|
||||||
this.options.listeners.stdline(line);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
const errbuffer = '';
|
|
||||||
if (cp.stderr) {
|
|
||||||
cp.stderr.on('data', (data) => {
|
|
||||||
state.processStderr = true;
|
|
||||||
if (this.options.listeners && this.options.listeners.stderr) {
|
|
||||||
this.options.listeners.stderr(data);
|
|
||||||
}
|
|
||||||
if (!optionsNonNull.silent &&
|
|
||||||
optionsNonNull.errStream &&
|
|
||||||
optionsNonNull.outStream) {
|
|
||||||
const s = optionsNonNull.failOnStdErr
|
|
||||||
? optionsNonNull.errStream
|
|
||||||
: optionsNonNull.outStream;
|
|
||||||
s.write(data);
|
|
||||||
}
|
|
||||||
this._processLineBuffer(data, errbuffer, (line) => {
|
|
||||||
if (this.options.listeners && this.options.listeners.errline) {
|
|
||||||
this.options.listeners.errline(line);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
cp.on('error', (err) => {
|
|
||||||
state.processError = err.message;
|
|
||||||
state.processExited = true;
|
|
||||||
state.processClosed = true;
|
|
||||||
state.CheckComplete();
|
|
||||||
});
|
|
||||||
cp.on('exit', (code) => {
|
|
||||||
state.processExitCode = code;
|
|
||||||
state.processExited = true;
|
|
||||||
this._debug(`Exit code ${code} received from tool '${this.toolPath}'`);
|
|
||||||
state.CheckComplete();
|
|
||||||
});
|
|
||||||
cp.on('close', (code) => {
|
|
||||||
state.processExitCode = code;
|
|
||||||
state.processExited = true;
|
|
||||||
state.processClosed = true;
|
|
||||||
this._debug(`STDIO streams have closed for tool '${this.toolPath}'`);
|
|
||||||
state.CheckComplete();
|
|
||||||
});
|
|
||||||
state.on('done', (error, exitCode) => {
|
|
||||||
if (stdbuffer.length > 0) {
|
|
||||||
this.emit('stdline', stdbuffer);
|
|
||||||
}
|
|
||||||
if (errbuffer.length > 0) {
|
|
||||||
this.emit('errline', errbuffer);
|
|
||||||
}
|
|
||||||
cp.removeAllListeners();
|
|
||||||
if (error) {
|
|
||||||
reject(error);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
resolve(exitCode);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.ToolRunner = ToolRunner;
|
|
||||||
/**
|
|
||||||
* Convert an arg string to an array of args. Handles escaping
|
|
||||||
*
|
|
||||||
* @param argString string of arguments
|
|
||||||
* @returns string[] array of arguments
|
|
||||||
*/
|
|
||||||
function argStringToArray(argString) {
|
|
||||||
const args = [];
|
|
||||||
let inQuotes = false;
|
|
||||||
let escaped = false;
|
|
||||||
let arg = '';
|
|
||||||
function append(c) {
|
|
||||||
// we only escape double quotes.
|
|
||||||
if (escaped && c !== '"') {
|
|
||||||
arg += '\\';
|
|
||||||
}
|
|
||||||
arg += c;
|
|
||||||
escaped = false;
|
|
||||||
}
|
|
||||||
for (let i = 0; i < argString.length; i++) {
|
|
||||||
const c = argString.charAt(i);
|
|
||||||
if (c === '"') {
|
|
||||||
if (!escaped) {
|
|
||||||
inQuotes = !inQuotes;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
append(c);
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (c === '\\' && escaped) {
|
|
||||||
append(c);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (c === '\\' && inQuotes) {
|
|
||||||
escaped = true;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (c === ' ' && !inQuotes) {
|
|
||||||
if (arg.length > 0) {
|
|
||||||
args.push(arg);
|
|
||||||
arg = '';
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
append(c);
|
|
||||||
}
|
|
||||||
if (arg.length > 0) {
|
|
||||||
args.push(arg.trim());
|
|
||||||
}
|
|
||||||
return args;
|
|
||||||
}
|
|
||||||
exports.argStringToArray = argStringToArray;
|
|
||||||
class ExecState extends events.EventEmitter {
|
|
||||||
constructor(options, toolPath) {
|
|
||||||
super();
|
|
||||||
this.processClosed = false; // tracks whether the process has exited and stdio is closed
|
|
||||||
this.processError = '';
|
|
||||||
this.processExitCode = 0;
|
|
||||||
this.processExited = false; // tracks whether the process has exited
|
|
||||||
this.processStderr = false; // tracks whether stderr was written to
|
|
||||||
this.delay = 10000; // 10 seconds
|
|
||||||
this.done = false;
|
|
||||||
this.timeout = null;
|
|
||||||
if (!toolPath) {
|
|
||||||
throw new Error('toolPath must not be empty');
|
|
||||||
}
|
|
||||||
this.options = options;
|
|
||||||
this.toolPath = toolPath;
|
|
||||||
if (options.delay) {
|
|
||||||
this.delay = options.delay;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CheckComplete() {
|
|
||||||
if (this.done) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (this.processClosed) {
|
|
||||||
this._setResult();
|
|
||||||
}
|
|
||||||
else if (this.processExited) {
|
|
||||||
this.timeout = setTimeout(ExecState.HandleTimeout, this.delay, this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_debug(message) {
|
|
||||||
this.emit('debug', message);
|
|
||||||
}
|
|
||||||
_setResult() {
|
|
||||||
// determine whether there is an error
|
|
||||||
let error;
|
|
||||||
if (this.processExited) {
|
|
||||||
if (this.processError) {
|
|
||||||
error = new Error(`There was an error when attempting to execute the process '${this.toolPath}'. This may indicate the process failed to start. Error: ${this.processError}`);
|
|
||||||
}
|
|
||||||
else if (this.processExitCode !== 0 && !this.options.ignoreReturnCode) {
|
|
||||||
error = new Error(`The process '${this.toolPath}' failed with exit code ${this.processExitCode}`);
|
|
||||||
}
|
|
||||||
else if (this.processStderr && this.options.failOnStdErr) {
|
|
||||||
error = new Error(`The process '${this.toolPath}' failed because one or more lines were written to the STDERR stream`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// clear the timeout
|
|
||||||
if (this.timeout) {
|
|
||||||
clearTimeout(this.timeout);
|
|
||||||
this.timeout = null;
|
|
||||||
}
|
|
||||||
this.done = true;
|
|
||||||
this.emit('done', error, this.processExitCode);
|
|
||||||
}
|
|
||||||
static HandleTimeout(state) {
|
|
||||||
if (state.done) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!state.processClosed && state.processExited) {
|
|
||||||
const message = `The STDIO streams did not close within ${state.delay /
|
|
||||||
1000} seconds of the exit event from process '${state.toolPath}'. This may indicate a child process inherited the STDIO streams and has not yet exited.`;
|
|
||||||
state._debug(message);
|
|
||||||
}
|
|
||||||
state._setResult();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//# sourceMappingURL=toolrunner.js.map
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -1,63 +0,0 @@
|
||||||
{
|
|
||||||
"_from": "file:toolkit\\actions-exec-0.0.0.tgz",
|
|
||||||
"_id": "@actions/exec@0.0.0",
|
|
||||||
"_inBundle": false,
|
|
||||||
"_integrity": "sha512-HHObusC4p1RElxIlrrN0sY/cweBYl+jKm3J/XWHPQZMipgJXB/dkVhUfl4KqH3Vim7oM2KjCGSfn+vTYrqVH3A==",
|
|
||||||
"_location": "/@actions/exec",
|
|
||||||
"_phantomChildren": {},
|
|
||||||
"_requested": {
|
|
||||||
"type": "file",
|
|
||||||
"where": "C:\\Users\\Administrator\\Documents\\setup-node",
|
|
||||||
"raw": "@actions/exec@file:toolkit/actions-exec-0.0.0.tgz",
|
|
||||||
"name": "@actions/exec",
|
|
||||||
"escapedName": "@actions%2fexec",
|
|
||||||
"scope": "@actions",
|
|
||||||
"rawSpec": "file:toolkit/actions-exec-0.0.0.tgz",
|
|
||||||
"saveSpec": "file:toolkit\\actions-exec-0.0.0.tgz",
|
|
||||||
"fetchSpec": "C:\\Users\\Administrator\\Documents\\setup-node\\toolkit\\actions-exec-0.0.0.tgz"
|
|
||||||
},
|
|
||||||
"_requiredBy": [
|
|
||||||
"/",
|
|
||||||
"/@actions/tool-cache"
|
|
||||||
],
|
|
||||||
"_resolved": "C:\\Users\\Administrator\\Documents\\setup-node\\toolkit\\actions-exec-0.0.0.tgz",
|
|
||||||
"_shasum": "341d868fe6c4123ded20db9c2106b7b8c16e1d73",
|
|
||||||
"_spec": "@actions/exec@file:toolkit/actions-exec-0.0.0.tgz",
|
|
||||||
"_where": "C:\\Users\\Administrator\\Documents\\setup-node",
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/actions/toolkit/issues"
|
|
||||||
},
|
|
||||||
"bundleDependencies": false,
|
|
||||||
"deprecated": false,
|
|
||||||
"description": "Actions exec lib",
|
|
||||||
"devDependencies": {
|
|
||||||
"@actions/io": "^0.0.0"
|
|
||||||
},
|
|
||||||
"directories": {
|
|
||||||
"lib": "lib",
|
|
||||||
"test": "__tests__"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"lib"
|
|
||||||
],
|
|
||||||
"homepage": "https://github.com/actions/toolkit/tree/master/packages/exec",
|
|
||||||
"keywords": [
|
|
||||||
"exec",
|
|
||||||
"actions"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"main": "lib/exec.js",
|
|
||||||
"name": "@actions/exec",
|
|
||||||
"publishConfig": {
|
|
||||||
"access": "public"
|
|
||||||
},
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/actions/toolkit.git"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"test": "echo \"Error: run tests from root\" && exit 1",
|
|
||||||
"tsc": "tsc"
|
|
||||||
},
|
|
||||||
"version": "0.0.0"
|
|
||||||
}
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
Copyright 2019 GitHub
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
# `@actions/exit`
|
|
||||||
|
|
||||||
> TODO: description
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
See [src/exit.ts](src/exit.ts).
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
/**
|
|
||||||
* The code to exit an action
|
|
||||||
*/
|
|
||||||
export declare enum ExitCode {
|
|
||||||
/**
|
|
||||||
* A code indicating that the action was successful
|
|
||||||
*/
|
|
||||||
Success = 0,
|
|
||||||
/**
|
|
||||||
* A code indicating that the action was a failure
|
|
||||||
*/
|
|
||||||
Failure = 1,
|
|
||||||
/**
|
|
||||||
* A code indicating that the action is complete, but neither succeeded nor failed
|
|
||||||
*/
|
|
||||||
Neutral = 78
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Exit the action as a success.
|
|
||||||
*/
|
|
||||||
export declare function success(): void;
|
|
||||||
/**
|
|
||||||
* Exit the action as a failure.
|
|
||||||
*/
|
|
||||||
export declare function failure(): void;
|
|
||||||
/**
|
|
||||||
* Exit the action neither a success or a failure
|
|
||||||
*/
|
|
||||||
export declare function neutral(): void;
|
|
||||||
|
|
@ -1,44 +0,0 @@
|
||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
/**
|
|
||||||
* The code to exit an action
|
|
||||||
*/
|
|
||||||
var ExitCode;
|
|
||||||
(function (ExitCode) {
|
|
||||||
/**
|
|
||||||
* A code indicating that the action was successful
|
|
||||||
*/
|
|
||||||
ExitCode[ExitCode["Success"] = 0] = "Success";
|
|
||||||
/**
|
|
||||||
* A code indicating that the action was a failure
|
|
||||||
*/
|
|
||||||
ExitCode[ExitCode["Failure"] = 1] = "Failure";
|
|
||||||
/**
|
|
||||||
* A code indicating that the action is complete, but neither succeeded nor failed
|
|
||||||
*/
|
|
||||||
ExitCode[ExitCode["Neutral"] = 78] = "Neutral";
|
|
||||||
})(ExitCode = exports.ExitCode || (exports.ExitCode = {}));
|
|
||||||
// TODO: These exit codes may not behave as expected on the new runtime, due to
|
|
||||||
// complexities of async logging and sync exiting.
|
|
||||||
/**
|
|
||||||
* Exit the action as a success.
|
|
||||||
*/
|
|
||||||
function success() {
|
|
||||||
process.exit(ExitCode.Success);
|
|
||||||
}
|
|
||||||
exports.success = success;
|
|
||||||
/**
|
|
||||||
* Exit the action as a failure.
|
|
||||||
*/
|
|
||||||
function failure() {
|
|
||||||
process.exit(ExitCode.Failure);
|
|
||||||
}
|
|
||||||
exports.failure = failure;
|
|
||||||
/**
|
|
||||||
* Exit the action neither a success or a failure
|
|
||||||
*/
|
|
||||||
function neutral() {
|
|
||||||
process.exit(ExitCode.Neutral);
|
|
||||||
}
|
|
||||||
exports.neutral = neutral;
|
|
||||||
//# sourceMappingURL=exit.js.map
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
{"version":3,"file":"exit.js","sourceRoot":"","sources":["../src/exit.ts"],"names":[],"mappings":";;AAAA;;GAEG;AACH,IAAY,QAeX;AAfD,WAAY,QAAQ;IAClB;;OAEG;IACH,6CAAW,CAAA;IAEX;;OAEG;IACH,6CAAW,CAAA;IAEX;;OAEG;IACH,8CAAY,CAAA;AACd,CAAC,EAfW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAenB;AAED,+EAA+E;AAC/E,kDAAkD;AAElD;;GAEG;AACH,SAAgB,OAAO;IACrB,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;AAChC,CAAC;AAFD,0BAEC;AAED;;GAEG;AACH,SAAgB,OAAO;IACrB,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;AAChC,CAAC;AAFD,0BAEC;AAED;;GAEG;AACH,SAAgB,OAAO;IACrB,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;AAChC,CAAC;AAFD,0BAEC"}
|
|
||||||
|
|
@ -1,61 +0,0 @@
|
||||||
{
|
|
||||||
"_from": "file:toolkit\\actions-exit-0.0.0.tgz",
|
|
||||||
"_id": "@actions/exit@0.0.0",
|
|
||||||
"_inBundle": false,
|
|
||||||
"_integrity": "sha512-vQdxFWM0/AERkC79mQ886SqPmV4joWhrSF7hiSTiJoKkE9eTjrKV5WQtp7SXv6OntrQkKX+ZjgdGpv+0rvJRCw==",
|
|
||||||
"_location": "/@actions/exit",
|
|
||||||
"_phantomChildren": {},
|
|
||||||
"_requested": {
|
|
||||||
"type": "file",
|
|
||||||
"where": "C:\\Users\\Administrator\\Documents\\setup-node",
|
|
||||||
"raw": "@actions/exit@file:toolkit/actions-exit-0.0.0.tgz",
|
|
||||||
"name": "@actions/exit",
|
|
||||||
"escapedName": "@actions%2fexit",
|
|
||||||
"scope": "@actions",
|
|
||||||
"rawSpec": "file:toolkit/actions-exit-0.0.0.tgz",
|
|
||||||
"saveSpec": "file:toolkit\\actions-exit-0.0.0.tgz",
|
|
||||||
"fetchSpec": "C:\\Users\\Administrator\\Documents\\setup-node\\toolkit\\actions-exit-0.0.0.tgz"
|
|
||||||
},
|
|
||||||
"_requiredBy": [
|
|
||||||
"/",
|
|
||||||
"/@actions/core"
|
|
||||||
],
|
|
||||||
"_resolved": "C:\\Users\\Administrator\\Documents\\setup-node\\toolkit\\actions-exit-0.0.0.tgz",
|
|
||||||
"_shasum": "d47c8c61b45750ae49fea3061e3419a547b2a48f",
|
|
||||||
"_spec": "@actions/exit@file:toolkit/actions-exit-0.0.0.tgz",
|
|
||||||
"_where": "C:\\Users\\Administrator\\Documents\\setup-node",
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/actions/toolkit/issues"
|
|
||||||
},
|
|
||||||
"bundleDependencies": false,
|
|
||||||
"deprecated": false,
|
|
||||||
"description": "Functions for safely exiting from GitHub Actions",
|
|
||||||
"directories": {
|
|
||||||
"lib": "lib",
|
|
||||||
"test": "__tests__"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"lib"
|
|
||||||
],
|
|
||||||
"homepage": "https://github.com/actions/toolkit/tree/master/packages/exit",
|
|
||||||
"keywords": [
|
|
||||||
"github",
|
|
||||||
"actions",
|
|
||||||
"toolkit"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"main": "lib/exit.js",
|
|
||||||
"name": "@actions/exit",
|
|
||||||
"publishConfig": {
|
|
||||||
"access": "public"
|
|
||||||
},
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/actions/toolkit.git"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"test": "echo \"Error: run tests from root\" && exit 1",
|
|
||||||
"tsc": "tsc"
|
|
||||||
},
|
|
||||||
"version": "0.0.0"
|
|
||||||
}
|
|
||||||
|
|
@ -1,49 +0,0 @@
|
||||||
# `@actions/io`
|
|
||||||
|
|
||||||
> Core functions for cli filesystem scenarios
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
```
|
|
||||||
/**
|
|
||||||
* Copies a file or folder.
|
|
||||||
*
|
|
||||||
* @param source source path
|
|
||||||
* @param dest destination path
|
|
||||||
* @param options optional. See CopyOptions.
|
|
||||||
*/
|
|
||||||
export function cp(source: string, dest: string, options?: CopyOptions): Promise<void>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove a path recursively with force
|
|
||||||
*
|
|
||||||
* @param path path to remove
|
|
||||||
*/
|
|
||||||
export function rmRF(path: string): Promise<void>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Make a directory. Creates the full path with folders in between
|
|
||||||
*
|
|
||||||
* @param p path to create
|
|
||||||
* @returns Promise<void>
|
|
||||||
*/
|
|
||||||
export function mkdirP(p: string): Promise<void>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Moves a path.
|
|
||||||
*
|
|
||||||
* @param source source path
|
|
||||||
* @param dest destination path
|
|
||||||
* @param options optional. See CopyOptions.
|
|
||||||
*/
|
|
||||||
export function mv(source: string, dest: string, options?: CopyOptions): Promise<void>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns path of a tool had the tool actually been invoked. Resolves via paths.
|
|
||||||
*
|
|
||||||
* @param tool name of the tool
|
|
||||||
* @param options optional. See WhichOptions.
|
|
||||||
* @returns Promise<string> path to tool
|
|
||||||
*/
|
|
||||||
export function which(tool: string, options?: WhichOptions): Promise<string>
|
|
||||||
```
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
/// <reference types="node" />
|
|
||||||
import * as fs from 'fs';
|
|
||||||
export declare const copyFile: typeof fs.promises.copyFile, lstat: typeof fs.promises.lstat, mkdir: typeof fs.promises.mkdir, readdir: typeof fs.promises.readdir, rmdir: typeof fs.promises.rmdir, stat: typeof fs.promises.stat, unlink: typeof fs.promises.unlink;
|
|
||||||
export declare const IS_WINDOWS: boolean;
|
|
||||||
export declare function exists(fsPath: string): Promise<boolean>;
|
|
||||||
export declare function isDirectory(fsPath: string, useStat?: boolean): Promise<boolean>;
|
|
||||||
/**
|
|
||||||
* On OSX/Linux, true if path starts with '/'. On Windows, true for paths like:
|
|
||||||
* \, \hello, \\hello\share, C:, and C:\hello (and corresponding alternate separator cases).
|
|
||||||
*/
|
|
||||||
export declare function isRooted(p: string): boolean;
|
|
||||||
/**
|
|
||||||
* Recursively create a directory at `fsPath`.
|
|
||||||
*
|
|
||||||
* This implementation is optimistic, meaning it attempts to create the full
|
|
||||||
* path first, and backs up the path stack from there.
|
|
||||||
*
|
|
||||||
* @param fsPath The path to create
|
|
||||||
* @param maxDepth The maximum recursion depth
|
|
||||||
* @param depth The current recursion depth
|
|
||||||
*/
|
|
||||||
export declare function mkdirP(fsPath: string, maxDepth?: number, depth?: number): Promise<void>;
|
|
||||||
/**
|
|
||||||
* Best effort attempt to determine whether a file exists and is executable.
|
|
||||||
* @param filePath file path to check
|
|
||||||
* @param extensions additional file extensions to try
|
|
||||||
* @return if file exists and is executable, returns the file path. otherwise empty string.
|
|
||||||
*/
|
|
||||||
export declare function tryGetExecutablePath(filePath: string, extensions: string[]): Promise<string>;
|
|
||||||
|
|
@ -1,194 +0,0 @@
|
||||||
"use strict";
|
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
var _a;
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
const assert_1 = require("assert");
|
|
||||||
const fs = require("fs");
|
|
||||||
const path = require("path");
|
|
||||||
_a = fs.promises, exports.copyFile = _a.copyFile, exports.lstat = _a.lstat, exports.mkdir = _a.mkdir, exports.readdir = _a.readdir, exports.rmdir = _a.rmdir, exports.stat = _a.stat, exports.unlink = _a.unlink;
|
|
||||||
exports.IS_WINDOWS = process.platform === 'win32';
|
|
||||||
function exists(fsPath) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
try {
|
|
||||||
yield exports.stat(fsPath);
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
if (err.code === 'ENOENT') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
exports.exists = exists;
|
|
||||||
function isDirectory(fsPath, useStat = false) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
const stats = useStat ? yield exports.stat(fsPath) : yield exports.lstat(fsPath);
|
|
||||||
return stats.isDirectory();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
exports.isDirectory = isDirectory;
|
|
||||||
/**
|
|
||||||
* On OSX/Linux, true if path starts with '/'. On Windows, true for paths like:
|
|
||||||
* \, \hello, \\hello\share, C:, and C:\hello (and corresponding alternate separator cases).
|
|
||||||
*/
|
|
||||||
function isRooted(p) {
|
|
||||||
p = normalizeSeparators(p);
|
|
||||||
if (!p) {
|
|
||||||
throw new Error('isRooted() parameter "p" cannot be empty');
|
|
||||||
}
|
|
||||||
if (exports.IS_WINDOWS) {
|
|
||||||
return (p.startsWith('\\') || /^[A-Z]:/i.test(p) // e.g. \ or \hello or \\hello
|
|
||||||
); // e.g. C: or C:\hello
|
|
||||||
}
|
|
||||||
return p.startsWith('/');
|
|
||||||
}
|
|
||||||
exports.isRooted = isRooted;
|
|
||||||
/**
|
|
||||||
* Recursively create a directory at `fsPath`.
|
|
||||||
*
|
|
||||||
* This implementation is optimistic, meaning it attempts to create the full
|
|
||||||
* path first, and backs up the path stack from there.
|
|
||||||
*
|
|
||||||
* @param fsPath The path to create
|
|
||||||
* @param maxDepth The maximum recursion depth
|
|
||||||
* @param depth The current recursion depth
|
|
||||||
*/
|
|
||||||
function mkdirP(fsPath, maxDepth = 1000, depth = 1) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
assert_1.ok(fsPath, 'a path argument must be provided');
|
|
||||||
fsPath = path.resolve(fsPath);
|
|
||||||
if (depth >= maxDepth)
|
|
||||||
return exports.mkdir(fsPath);
|
|
||||||
try {
|
|
||||||
yield exports.mkdir(fsPath);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
switch (err.code) {
|
|
||||||
case 'ENOENT': {
|
|
||||||
yield mkdirP(path.dirname(fsPath), maxDepth, depth + 1);
|
|
||||||
yield exports.mkdir(fsPath);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
let stats;
|
|
||||||
try {
|
|
||||||
stats = yield exports.stat(fsPath);
|
|
||||||
}
|
|
||||||
catch (err2) {
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
if (!stats.isDirectory())
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
exports.mkdirP = mkdirP;
|
|
||||||
/**
|
|
||||||
* Best effort attempt to determine whether a file exists and is executable.
|
|
||||||
* @param filePath file path to check
|
|
||||||
* @param extensions additional file extensions to try
|
|
||||||
* @return if file exists and is executable, returns the file path. otherwise empty string.
|
|
||||||
*/
|
|
||||||
function tryGetExecutablePath(filePath, extensions) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
let stats = undefined;
|
|
||||||
try {
|
|
||||||
// test file exists
|
|
||||||
stats = yield exports.stat(filePath);
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
if (err.code !== 'ENOENT') {
|
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
console.log(`Unexpected error attempting to determine if executable file exists '${filePath}': ${err}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (stats && stats.isFile()) {
|
|
||||||
if (exports.IS_WINDOWS) {
|
|
||||||
// on Windows, test for valid extension
|
|
||||||
const upperExt = path.extname(filePath).toUpperCase();
|
|
||||||
if (extensions.some(validExt => validExt.toUpperCase() === upperExt)) {
|
|
||||||
return filePath;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (isUnixExecutable(stats)) {
|
|
||||||
return filePath;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// try each extension
|
|
||||||
const originalFilePath = filePath;
|
|
||||||
for (const extension of extensions) {
|
|
||||||
filePath = originalFilePath + extension;
|
|
||||||
stats = undefined;
|
|
||||||
try {
|
|
||||||
stats = yield exports.stat(filePath);
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
if (err.code !== 'ENOENT') {
|
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
console.log(`Unexpected error attempting to determine if executable file exists '${filePath}': ${err}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (stats && stats.isFile()) {
|
|
||||||
if (exports.IS_WINDOWS) {
|
|
||||||
// preserve the case of the actual file (since an extension was appended)
|
|
||||||
try {
|
|
||||||
const directory = path.dirname(filePath);
|
|
||||||
const upperName = path.basename(filePath).toUpperCase();
|
|
||||||
for (const actualName of yield exports.readdir(directory)) {
|
|
||||||
if (upperName === actualName.toUpperCase()) {
|
|
||||||
filePath = path.join(directory, actualName);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
console.log(`Unexpected error attempting to determine the actual case of the file '${filePath}': ${err}`);
|
|
||||||
}
|
|
||||||
return filePath;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (isUnixExecutable(stats)) {
|
|
||||||
return filePath;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return '';
|
|
||||||
});
|
|
||||||
}
|
|
||||||
exports.tryGetExecutablePath = tryGetExecutablePath;
|
|
||||||
function normalizeSeparators(p) {
|
|
||||||
p = p || '';
|
|
||||||
if (exports.IS_WINDOWS) {
|
|
||||||
// convert slashes on Windows
|
|
||||||
p = p.replace(/\//g, '\\');
|
|
||||||
// remove redundant slashes
|
|
||||||
return p.replace(/\\\\+/g, '\\');
|
|
||||||
}
|
|
||||||
// remove redundant slashes
|
|
||||||
return p.replace(/\/\/+/g, '/');
|
|
||||||
}
|
|
||||||
// on Mac/Linux, test the execute bit
|
|
||||||
// R W X R W X R W X
|
|
||||||
// 256 128 64 32 16 8 4 2 1
|
|
||||||
function isUnixExecutable(stats) {
|
|
||||||
return ((stats.mode & 1) > 0 ||
|
|
||||||
((stats.mode & 8) > 0 && stats.gid === process.getgid()) ||
|
|
||||||
((stats.mode & 64) > 0 && stats.uid === process.getuid()));
|
|
||||||
}
|
|
||||||
//# sourceMappingURL=io-util.js.map
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
{"version":3,"file":"io-util.js","sourceRoot":"","sources":["../src/io-util.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,mCAAyB;AACzB,yBAAwB;AACxB,6BAA4B;AAEf,gBAQE,iMAAA;AAEF,QAAA,UAAU,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAA;AAEtD,SAAsB,MAAM,CAAC,MAAc;;QACzC,IAAI;YACF,MAAM,YAAI,CAAC,MAAM,CAAC,CAAA;SACnB;QAAC,OAAO,GAAG,EAAE;YACZ,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE;gBACzB,OAAO,KAAK,CAAA;aACb;YAED,MAAM,GAAG,CAAA;SACV;QAED,OAAO,IAAI,CAAA;IACb,CAAC;CAAA;AAZD,wBAYC;AAED,SAAsB,WAAW,CAC/B,MAAc,EACd,UAAmB,KAAK;;QAExB,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,MAAM,YAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,aAAK,CAAC,MAAM,CAAC,CAAA;QAChE,OAAO,KAAK,CAAC,WAAW,EAAE,CAAA;IAC5B,CAAC;CAAA;AAND,kCAMC;AAED;;;GAGG;AACH,SAAgB,QAAQ,CAAC,CAAS;IAChC,CAAC,GAAG,mBAAmB,CAAC,CAAC,CAAC,CAAA;IAC1B,IAAI,CAAC,CAAC,EAAE;QACN,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAA;KAC5D;IAED,IAAI,kBAAU,EAAE;QACd,OAAO,CACL,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,8BAA8B;SACxE,CAAA,CAAC,sBAAsB;KACzB;IAED,OAAO,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;AAC1B,CAAC;AAbD,4BAaC;AAED;;;;;;;;;GASG;AACH,SAAsB,MAAM,CAC1B,MAAc,EACd,WAAmB,IAAI,EACvB,QAAgB,CAAC;;QAEjB,WAAE,CAAC,MAAM,EAAE,kCAAkC,CAAC,CAAA;QAE9C,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QAE7B,IAAI,KAAK,IAAI,QAAQ;YAAE,OAAO,aAAK,CAAC,MAAM,CAAC,CAAA;QAE3C,IAAI;YACF,MAAM,aAAK,CAAC,MAAM,CAAC,CAAA;YACnB,OAAM;SACP;QAAC,OAAO,GAAG,EAAE;YACZ,QAAQ,GAAG,CAAC,IAAI,EAAE;gBAChB,KAAK,QAAQ,CAAC,CAAC;oBACb,MAAM,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,KAAK,GAAG,CAAC,CAAC,CAAA;oBACvD,MAAM,aAAK,CAAC,MAAM,CAAC,CAAA;oBACnB,OAAM;iBACP;gBACD,OAAO,CAAC,CAAC;oBACP,IAAI,KAAe,CAAA;oBAEnB,IAAI;wBACF,KAAK,GAAG,MAAM,YAAI,CAAC,MAAM,CAAC,CAAA;qBAC3B;oBAAC,OAAO,IAAI,EAAE;wBACb,MAAM,GAAG,CAAA;qBACV;oBAED,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE;wBAAE,MAAM,GAAG,CAAA;iBACpC;aACF;SACF;IACH,CAAC;CAAA;AAlCD,wBAkCC;AAED;;;;;GAKG;AACH,SAAsB,oBAAoB,CACxC,QAAgB,EAChB,UAAoB;;QAEpB,IAAI,KAAK,GAAyB,SAAS,CAAA;QAC3C,IAAI;YACF,mBAAmB;YACnB,KAAK,GAAG,MAAM,YAAI,CAAC,QAAQ,CAAC,CAAA;SAC7B;QAAC,OAAO,GAAG,EAAE;YACZ,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE;gBACzB,sCAAsC;gBACtC,OAAO,CAAC,GAAG,CACT,uEAAuE,QAAQ,MAAM,GAAG,EAAE,CAC3F,CAAA;aACF;SACF;QACD,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,EAAE,EAAE;YAC3B,IAAI,kBAAU,EAAE;gBACd,uCAAuC;gBACvC,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAA;gBACrD,IAAI,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,WAAW,EAAE,KAAK,QAAQ,CAAC,EAAE;oBACpE,OAAO,QAAQ,CAAA;iBAChB;aACF;iBAAM;gBACL,IAAI,gBAAgB,CAAC,KAAK,CAAC,EAAE;oBAC3B,OAAO,QAAQ,CAAA;iBAChB;aACF;SACF;QAED,qBAAqB;QACrB,MAAM,gBAAgB,GAAG,QAAQ,CAAA;QACjC,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE;YAClC,QAAQ,GAAG,gBAAgB,GAAG,SAAS,CAAA;YAEvC,KAAK,GAAG,SAAS,CAAA;YACjB,IAAI;gBACF,KAAK,GAAG,MAAM,YAAI,CAAC,QAAQ,CAAC,CAAA;aAC7B;YAAC,OAAO,GAAG,EAAE;gBACZ,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE;oBACzB,sCAAsC;oBACtC,OAAO,CAAC,GAAG,CACT,uEAAuE,QAAQ,MAAM,GAAG,EAAE,CAC3F,CAAA;iBACF;aACF;YAED,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,EAAE,EAAE;gBAC3B,IAAI,kBAAU,EAAE;oBACd,yEAAyE;oBACzE,IAAI;wBACF,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;wBACxC,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAA;wBACvD,KAAK,MAAM,UAAU,IAAI,MAAM,eAAO,CAAC,SAAS,CAAC,EAAE;4BACjD,IAAI,SAAS,KAAK,UAAU,CAAC,WAAW,EAAE,EAAE;gCAC1C,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAA;gCAC3C,MAAK;6BACN;yBACF;qBACF;oBAAC,OAAO,GAAG,EAAE;wBACZ,sCAAsC;wBACtC,OAAO,CAAC,GAAG,CACT,yEAAyE,QAAQ,MAAM,GAAG,EAAE,CAC7F,CAAA;qBACF;oBAED,OAAO,QAAQ,CAAA;iBAChB;qBAAM;oBACL,IAAI,gBAAgB,CAAC,KAAK,CAAC,EAAE;wBAC3B,OAAO,QAAQ,CAAA;qBAChB;iBACF;aACF;SACF;QAED,OAAO,EAAE,CAAA;IACX,CAAC;CAAA;AA5ED,oDA4EC;AAED,SAAS,mBAAmB,CAAC,CAAS;IACpC,CAAC,GAAG,CAAC,IAAI,EAAE,CAAA;IACX,IAAI,kBAAU,EAAE;QACd,6BAA6B;QAC7B,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;QAE1B,2BAA2B;QAC3B,OAAO,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;KACjC;IAED,2BAA2B;IAC3B,OAAO,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAA;AACjC,CAAC;AAED,qCAAqC;AACrC,6BAA6B;AAC7B,6BAA6B;AAC7B,SAAS,gBAAgB,CAAC,KAAe;IACvC,OAAO,CACL,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC;QACpB,CAAC,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,GAAG,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC;QACxD,CAAC,CAAC,KAAK,CAAC,IAAI,GAAG,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,GAAG,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAC1D,CAAA;AACH,CAAC"}
|
|
||||||
|
|
@ -1,48 +0,0 @@
|
||||||
/**
|
|
||||||
* Interface for cp/mv options
|
|
||||||
*/
|
|
||||||
export interface CopyOptions {
|
|
||||||
/** Optional. Whether to recursively copy all subdirectories. Defaults to false */
|
|
||||||
recursive?: boolean;
|
|
||||||
/** Optional. Whether to overwrite existing files in the destination. Defaults to true */
|
|
||||||
force?: boolean;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Copies a file or folder.
|
|
||||||
*
|
|
||||||
* @param source source path
|
|
||||||
* @param dest destination path
|
|
||||||
* @param options optional. See CopyOptions.
|
|
||||||
*/
|
|
||||||
export declare function cp(source: string, dest: string, options?: CopyOptions): Promise<void>;
|
|
||||||
/**
|
|
||||||
* Moves a path.
|
|
||||||
*
|
|
||||||
* @param source source path
|
|
||||||
* @param dest destination path
|
|
||||||
* @param options optional. See CopyOptions.
|
|
||||||
*/
|
|
||||||
export declare function mv(source: string, dest: string, options?: CopyOptions): Promise<void>;
|
|
||||||
/**
|
|
||||||
* Remove a path recursively with force
|
|
||||||
*
|
|
||||||
* @param inputPath path to remove
|
|
||||||
*/
|
|
||||||
export declare function rmRF(inputPath: string): Promise<void>;
|
|
||||||
/**
|
|
||||||
* Make a directory. Creates the full path with folders in between
|
|
||||||
* Will throw if it fails
|
|
||||||
*
|
|
||||||
* @param fsPath path to create
|
|
||||||
* @returns Promise<void>
|
|
||||||
*/
|
|
||||||
export declare function mkdirP(fsPath: string): Promise<void>;
|
|
||||||
/**
|
|
||||||
* Returns path of a tool had the tool actually been invoked. Resolves via paths.
|
|
||||||
* If you check and the tool does not exist, it will throw.
|
|
||||||
*
|
|
||||||
* @param tool name of the tool
|
|
||||||
* @param check whether to check if tool exists
|
|
||||||
* @returns Promise<string> path to tool
|
|
||||||
*/
|
|
||||||
export declare function which(tool: string, check?: boolean): Promise<string>;
|
|
||||||
|
|
@ -1,262 +0,0 @@
|
||||||
"use strict";
|
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
const childProcess = require("child_process");
|
|
||||||
const fs = require("fs");
|
|
||||||
const path = require("path");
|
|
||||||
const util_1 = require("util");
|
|
||||||
const ioUtil = require("./io-util");
|
|
||||||
const exec = util_1.promisify(childProcess.exec);
|
|
||||||
/**
|
|
||||||
* Copies a file or folder.
|
|
||||||
*
|
|
||||||
* @param source source path
|
|
||||||
* @param dest destination path
|
|
||||||
* @param options optional. See CopyOptions.
|
|
||||||
*/
|
|
||||||
function cp(source, dest, options = {}) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
yield move(source, dest, options, { deleteOriginal: false });
|
|
||||||
});
|
|
||||||
}
|
|
||||||
exports.cp = cp;
|
|
||||||
/**
|
|
||||||
* Moves a path.
|
|
||||||
*
|
|
||||||
* @param source source path
|
|
||||||
* @param dest destination path
|
|
||||||
* @param options optional. See CopyOptions.
|
|
||||||
*/
|
|
||||||
function mv(source, dest, options = {}) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
yield move(source, dest, options, { deleteOriginal: true });
|
|
||||||
});
|
|
||||||
}
|
|
||||||
exports.mv = mv;
|
|
||||||
/**
|
|
||||||
* Remove a path recursively with force
|
|
||||||
*
|
|
||||||
* @param inputPath path to remove
|
|
||||||
*/
|
|
||||||
function rmRF(inputPath) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
if (ioUtil.IS_WINDOWS) {
|
|
||||||
// Node doesn't provide a delete operation, only an unlink function. This means that if the file is being used by another
|
|
||||||
// program (e.g. antivirus), it won't be deleted. To address this, we shell out the work to rd/del.
|
|
||||||
try {
|
|
||||||
if (yield ioUtil.isDirectory(inputPath, true)) {
|
|
||||||
yield exec(`rd /s /q "${inputPath}"`);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
yield exec(`del /f /a "${inputPath}"`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
// if you try to delete a file that doesn't exist, desired result is achieved
|
|
||||||
// other errors are valid
|
|
||||||
if (err.code !== 'ENOENT')
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
// Shelling out fails to remove a symlink folder with missing source, this unlink catches that
|
|
||||||
try {
|
|
||||||
yield ioUtil.unlink(inputPath);
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
// if you try to delete a file that doesn't exist, desired result is achieved
|
|
||||||
// other errors are valid
|
|
||||||
if (err.code !== 'ENOENT')
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
let isDir = false;
|
|
||||||
try {
|
|
||||||
isDir = yield ioUtil.isDirectory(inputPath);
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
// if you try to delete a file that doesn't exist, desired result is achieved
|
|
||||||
// other errors are valid
|
|
||||||
if (err.code !== 'ENOENT')
|
|
||||||
throw err;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (isDir) {
|
|
||||||
yield exec(`rm -rf "${inputPath}"`);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
yield ioUtil.unlink(inputPath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
exports.rmRF = rmRF;
|
|
||||||
/**
|
|
||||||
* Make a directory. Creates the full path with folders in between
|
|
||||||
* Will throw if it fails
|
|
||||||
*
|
|
||||||
* @param fsPath path to create
|
|
||||||
* @returns Promise<void>
|
|
||||||
*/
|
|
||||||
function mkdirP(fsPath) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
yield ioUtil.mkdirP(fsPath);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
exports.mkdirP = mkdirP;
|
|
||||||
/**
|
|
||||||
* Returns path of a tool had the tool actually been invoked. Resolves via paths.
|
|
||||||
* If you check and the tool does not exist, it will throw.
|
|
||||||
*
|
|
||||||
* @param tool name of the tool
|
|
||||||
* @param check whether to check if tool exists
|
|
||||||
* @returns Promise<string> path to tool
|
|
||||||
*/
|
|
||||||
function which(tool, check) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
if (!tool) {
|
|
||||||
throw new Error("parameter 'tool' is required");
|
|
||||||
}
|
|
||||||
// recursive when check=true
|
|
||||||
if (check) {
|
|
||||||
const result = yield which(tool, false);
|
|
||||||
if (!result) {
|
|
||||||
if (ioUtil.IS_WINDOWS) {
|
|
||||||
throw new Error(`Unable to locate executable file: ${tool}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.`);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw new Error(`Unable to locate executable file: ${tool}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
// build the list of extensions to try
|
|
||||||
const extensions = [];
|
|
||||||
if (ioUtil.IS_WINDOWS && process.env.PATHEXT) {
|
|
||||||
for (const extension of process.env.PATHEXT.split(path.delimiter)) {
|
|
||||||
if (extension) {
|
|
||||||
extensions.push(extension);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// if it's rooted, return it if exists. otherwise return empty.
|
|
||||||
if (ioUtil.isRooted(tool)) {
|
|
||||||
const filePath = yield ioUtil.tryGetExecutablePath(tool, extensions);
|
|
||||||
if (filePath) {
|
|
||||||
return filePath;
|
|
||||||
}
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
// if any path separators, return empty
|
|
||||||
if (tool.includes('/') || (ioUtil.IS_WINDOWS && tool.includes('\\'))) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
// build the list of directories
|
|
||||||
//
|
|
||||||
// Note, technically "where" checks the current directory on Windows. From a task lib perspective,
|
|
||||||
// it feels like we should not do this. Checking the current directory seems like more of a use
|
|
||||||
// case of a shell, and the which() function exposed by the task lib should strive for consistency
|
|
||||||
// across platforms.
|
|
||||||
const directories = [];
|
|
||||||
if (process.env.PATH) {
|
|
||||||
for (const p of process.env.PATH.split(path.delimiter)) {
|
|
||||||
if (p) {
|
|
||||||
directories.push(p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// return the first match
|
|
||||||
for (const directory of directories) {
|
|
||||||
const filePath = yield ioUtil.tryGetExecutablePath(directory + path.sep + tool, extensions);
|
|
||||||
if (filePath) {
|
|
||||||
return filePath;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
throw new Error(`which failed with message ${err.message}`);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
exports.which = which;
|
|
||||||
// Copies contents of source into dest, making any necessary folders along the way.
|
|
||||||
// Deletes the original copy if deleteOriginal is true
|
|
||||||
function copyDirectoryContents(source, dest, force, deleteOriginal = false) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
if (yield ioUtil.isDirectory(source)) {
|
|
||||||
if (yield ioUtil.exists(dest)) {
|
|
||||||
if (!(yield ioUtil.isDirectory(dest))) {
|
|
||||||
throw new Error(`${dest} is not a directory`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
yield mkdirP(dest);
|
|
||||||
}
|
|
||||||
// Copy all child files, and directories recursively
|
|
||||||
const sourceChildren = yield ioUtil.readdir(source);
|
|
||||||
for (const newSource of sourceChildren) {
|
|
||||||
const newDest = path.join(dest, path.basename(newSource));
|
|
||||||
yield copyDirectoryContents(path.resolve(source, newSource), newDest, force, deleteOriginal);
|
|
||||||
}
|
|
||||||
if (deleteOriginal) {
|
|
||||||
yield ioUtil.rmdir(source);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (force) {
|
|
||||||
yield ioUtil.copyFile(source, dest);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
yield ioUtil.copyFile(source, dest, fs.constants.COPYFILE_EXCL);
|
|
||||||
}
|
|
||||||
if (deleteOriginal) {
|
|
||||||
yield ioUtil.unlink(source);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
function move(source, dest, options = {}, moveOptions) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
const { force, recursive } = readCopyOptions(options);
|
|
||||||
if (yield ioUtil.isDirectory(source)) {
|
|
||||||
if (!recursive) {
|
|
||||||
throw new Error(`non-recursive cp failed, ${source} is a directory`);
|
|
||||||
}
|
|
||||||
// If directory exists, move source inside it. Otherwise, create it and move contents of source inside.
|
|
||||||
if (yield ioUtil.exists(dest)) {
|
|
||||||
if (!(yield ioUtil.isDirectory(dest))) {
|
|
||||||
throw new Error(`${dest} is not a directory`);
|
|
||||||
}
|
|
||||||
dest = path.join(dest, path.basename(source));
|
|
||||||
}
|
|
||||||
yield copyDirectoryContents(source, dest, force, moveOptions.deleteOriginal);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if ((yield ioUtil.exists(dest)) && (yield ioUtil.isDirectory(dest))) {
|
|
||||||
dest = path.join(dest, path.basename(source));
|
|
||||||
}
|
|
||||||
if (force) {
|
|
||||||
yield ioUtil.copyFile(source, dest);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
yield ioUtil.copyFile(source, dest, fs.constants.COPYFILE_EXCL);
|
|
||||||
}
|
|
||||||
if (moveOptions.deleteOriginal) {
|
|
||||||
yield ioUtil.unlink(source);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
function readCopyOptions(options) {
|
|
||||||
const force = options.force == null ? true : options.force;
|
|
||||||
const recursive = Boolean(options.recursive);
|
|
||||||
return { force, recursive };
|
|
||||||
}
|
|
||||||
//# sourceMappingURL=io.js.map
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -1,60 +0,0 @@
|
||||||
{
|
|
||||||
"_from": "file:toolkit\\actions-io-0.0.0.tgz",
|
|
||||||
"_id": "@actions/io@0.0.0",
|
|
||||||
"_inBundle": false,
|
|
||||||
"_integrity": "sha512-BArfobXB/b6RjR4i/+P4UcdaqR2tPjEb2WzZf9GdKiSARQn7d301pKOZAqxA+0N11X07Lk46t/txeUBcrCNbeg==",
|
|
||||||
"_location": "/@actions/io",
|
|
||||||
"_phantomChildren": {},
|
|
||||||
"_requested": {
|
|
||||||
"type": "file",
|
|
||||||
"where": "C:\\Users\\Administrator\\Documents\\setup-node",
|
|
||||||
"raw": "@actions/io@file:toolkit/actions-io-0.0.0.tgz",
|
|
||||||
"name": "@actions/io",
|
|
||||||
"escapedName": "@actions%2fio",
|
|
||||||
"scope": "@actions",
|
|
||||||
"rawSpec": "file:toolkit/actions-io-0.0.0.tgz",
|
|
||||||
"saveSpec": "file:toolkit\\actions-io-0.0.0.tgz",
|
|
||||||
"fetchSpec": "C:\\Users\\Administrator\\Documents\\setup-node\\toolkit\\actions-io-0.0.0.tgz"
|
|
||||||
},
|
|
||||||
"_requiredBy": [
|
|
||||||
"/",
|
|
||||||
"/@actions/tool-cache"
|
|
||||||
],
|
|
||||||
"_resolved": "C:\\Users\\Administrator\\Documents\\setup-node\\toolkit\\actions-io-0.0.0.tgz",
|
|
||||||
"_shasum": "1e8f0faca6b39215bebacedf473e5bb0716e39bf",
|
|
||||||
"_spec": "@actions/io@file:toolkit/actions-io-0.0.0.tgz",
|
|
||||||
"_where": "C:\\Users\\Administrator\\Documents\\setup-node",
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/actions/toolkit/issues"
|
|
||||||
},
|
|
||||||
"bundleDependencies": false,
|
|
||||||
"deprecated": false,
|
|
||||||
"description": "Actions io lib",
|
|
||||||
"directories": {
|
|
||||||
"lib": "lib",
|
|
||||||
"test": "__tests__"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"lib"
|
|
||||||
],
|
|
||||||
"homepage": "https://github.com/actions/toolkit/tree/master/packages/io",
|
|
||||||
"keywords": [
|
|
||||||
"io",
|
|
||||||
"actions"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"main": "lib/io.js",
|
|
||||||
"name": "@actions/io",
|
|
||||||
"publishConfig": {
|
|
||||||
"access": "public"
|
|
||||||
},
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/actions/toolkit.git"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"test": "echo \"Error: run tests from root\" && exit 1",
|
|
||||||
"tsc": "tsc"
|
|
||||||
},
|
|
||||||
"version": "0.0.0"
|
|
||||||
}
|
|
||||||
|
|
@ -1,82 +0,0 @@
|
||||||
# `@actions/tool-cache`
|
|
||||||
|
|
||||||
> Functions necessary for downloading and caching tools.
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
#### Download
|
|
||||||
|
|
||||||
You can use this to download tools (or other files) from a download URL:
|
|
||||||
|
|
||||||
```
|
|
||||||
const tc = require('@actions/tool-cache');
|
|
||||||
|
|
||||||
const node12Path = await tc.downloadTool('http://nodejs.org/dist/v12.7.0/node-v12.7.0-linux-x64.tar.gz');
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Extract
|
|
||||||
|
|
||||||
These can then be extracted in platform specific ways:
|
|
||||||
|
|
||||||
```
|
|
||||||
const tc = require('@actions/tool-cache');
|
|
||||||
|
|
||||||
if (process.platform === 'win32') {
|
|
||||||
tc.downloadTool('http://nodejs.org/dist/v12.7.0/node-v12.7.0-win-x64.zip');
|
|
||||||
const node12ExtractedFolder = await tc.extractZip(node12Path, 'path/to/extract/to');
|
|
||||||
|
|
||||||
// Or alternately
|
|
||||||
tc.downloadTool('http://nodejs.org/dist/v12.7.0/node-v12.7.0-win-x64.7z');
|
|
||||||
const node12ExtractedFolder = await tc.extract7z(node12Path, 'path/to/extract/to');
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
const node12Path = await tc.downloadTool('http://nodejs.org/dist/v12.7.0/node-v12.7.0-linux-x64.tar.gz');
|
|
||||||
const node12ExtractedFolder = await tc.extractTar(node12Path, 'path/to/extract/to');
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Cache
|
|
||||||
|
|
||||||
Finally, you can cache these directories in our tool-cache. This is useful if you want to switch back and forth between versions of a tool, or save a tool between runs for private runners (private runners are still in development but are on the roadmap).
|
|
||||||
|
|
||||||
You'll often want to add it to the path as part of this step:
|
|
||||||
|
|
||||||
```
|
|
||||||
const tc = require('@actions/tool-cache');
|
|
||||||
const core = require('@actions/core');
|
|
||||||
|
|
||||||
const node12Path = await tc.downloadTool('http://nodejs.org/dist/v12.7.0/node-v12.7.0-linux-x64.tar.gz');
|
|
||||||
const node12ExtractedFolder = await tc.extractTar(node12Path, 'path/to/extract/to');
|
|
||||||
|
|
||||||
const cachedPath = await tc.cacheDir(node12ExtractedFolder, 'node', '12.7.0');
|
|
||||||
core.addPath(cachedPath);
|
|
||||||
```
|
|
||||||
|
|
||||||
You can also cache files for reuse.
|
|
||||||
|
|
||||||
```
|
|
||||||
const tc = require('@actions/tool-cache');
|
|
||||||
|
|
||||||
tc.cacheFile('path/to/exe', 'destFileName.exe', 'myExeName', '1.1.0');
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Find
|
|
||||||
|
|
||||||
Finally, you can find directories and files you've previously cached:
|
|
||||||
|
|
||||||
```
|
|
||||||
const tc = require('@actions/tool-cache');
|
|
||||||
const core = require('@actions/core');
|
|
||||||
|
|
||||||
const nodeDirectory = tc.find('node', '12.x', 'x64');
|
|
||||||
core.addPath(nodeDirectory);
|
|
||||||
```
|
|
||||||
|
|
||||||
You can even find all cached versions of a tool:
|
|
||||||
|
|
||||||
```
|
|
||||||
const tc = require('@actions/tool-cache');
|
|
||||||
|
|
||||||
const allNodeVersions = tc.findAllVersions('node');
|
|
||||||
console.log(`Versions of node available: ${allNodeVersions}`);
|
|
||||||
```
|
|
||||||
|
|
@ -1,78 +0,0 @@
|
||||||
export declare class HTTPError extends Error {
|
|
||||||
readonly httpStatusCode: number | undefined;
|
|
||||||
constructor(httpStatusCode: number | undefined);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Download a tool from an url and stream it into a file
|
|
||||||
*
|
|
||||||
* @param url url of tool to download
|
|
||||||
* @returns path to downloaded tool
|
|
||||||
*/
|
|
||||||
export declare function downloadTool(url: string): Promise<string>;
|
|
||||||
/**
|
|
||||||
* Extract a .7z file
|
|
||||||
*
|
|
||||||
* @param file path to the .7z file
|
|
||||||
* @param dest destination directory. Optional.
|
|
||||||
* @param _7zPath path to 7zr.exe. Optional, for long path support. Most .7z archives do not have this
|
|
||||||
* problem. If your .7z archive contains very long paths, you can pass the path to 7zr.exe which will
|
|
||||||
* gracefully handle long paths. By default 7zdec.exe is used because it is a very small program and is
|
|
||||||
* bundled with the tool lib. However it does not support long paths. 7zr.exe is the reduced command line
|
|
||||||
* interface, it is smaller than the full command line interface, and it does support long paths. At the
|
|
||||||
* time of this writing, it is freely available from the LZMA SDK that is available on the 7zip website.
|
|
||||||
* Be sure to check the current license agreement. If 7zr.exe is bundled with your action, then the path
|
|
||||||
* to 7zr.exe can be pass to this function.
|
|
||||||
* @returns path to the destination directory
|
|
||||||
*/
|
|
||||||
export declare function extract7z(file: string, dest?: string, _7zPath?: string): Promise<string>;
|
|
||||||
/**
|
|
||||||
* Extract a tar
|
|
||||||
*
|
|
||||||
* @param file path to the tar
|
|
||||||
* @param dest destination directory. Optional.
|
|
||||||
* @returns path to the destination directory
|
|
||||||
*/
|
|
||||||
export declare function extractTar(file: string, dest?: string): Promise<string>;
|
|
||||||
/**
|
|
||||||
* Extract a zip
|
|
||||||
*
|
|
||||||
* @param file path to the zip
|
|
||||||
* @param dest destination directory. Optional.
|
|
||||||
* @returns path to the destination directory
|
|
||||||
*/
|
|
||||||
export declare function extractZip(file: string, dest?: string): Promise<string>;
|
|
||||||
/**
|
|
||||||
* Caches a directory and installs it into the tool cacheDir
|
|
||||||
*
|
|
||||||
* @param sourceDir the directory to cache into tools
|
|
||||||
* @param tool tool name
|
|
||||||
* @param version version of the tool. semver format
|
|
||||||
* @param arch architecture of the tool. Optional. Defaults to machine architecture
|
|
||||||
*/
|
|
||||||
export declare function cacheDir(sourceDir: string, tool: string, version: string, arch?: string): Promise<string>;
|
|
||||||
/**
|
|
||||||
* Caches a downloaded file (GUID) and installs it
|
|
||||||
* into the tool cache with a given targetName
|
|
||||||
*
|
|
||||||
* @param sourceFile the file to cache into tools. Typically a result of downloadTool which is a guid.
|
|
||||||
* @param targetFile the name of the file name in the tools directory
|
|
||||||
* @param tool tool name
|
|
||||||
* @param version version of the tool. semver format
|
|
||||||
* @param arch architecture of the tool. Optional. Defaults to machine architecture
|
|
||||||
*/
|
|
||||||
export declare function cacheFile(sourceFile: string, targetFile: string, tool: string, version: string, arch?: string): Promise<string>;
|
|
||||||
/**
|
|
||||||
* Finds the path to a tool version in the local installed tool cache
|
|
||||||
*
|
|
||||||
* @param toolName name of the tool
|
|
||||||
* @param versionSpec version of the tool
|
|
||||||
* @param arch optional arch. defaults to arch of computer
|
|
||||||
*/
|
|
||||||
export declare function find(toolName: string, versionSpec: string, arch?: string): string;
|
|
||||||
/**
|
|
||||||
* Finds the paths to all versions of a tool that are installed in the local tool cache
|
|
||||||
*
|
|
||||||
* @param toolName name of the tool
|
|
||||||
* @param arch optional arch. defaults to arch of computer
|
|
||||||
*/
|
|
||||||
export declare function findAllVersions(toolName: string, arch?: string): string[];
|
|
||||||
|
|
@ -1,436 +0,0 @@
|
||||||
"use strict";
|
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
const core = require("@actions/core");
|
|
||||||
const io = require("@actions/io");
|
|
||||||
const fs = require("fs");
|
|
||||||
const os = require("os");
|
|
||||||
const path = require("path");
|
|
||||||
const httpm = require("typed-rest-client/HttpClient");
|
|
||||||
const semver = require("semver");
|
|
||||||
const uuidV4 = require("uuid/v4");
|
|
||||||
const exec_1 = require("@actions/exec/lib/exec");
|
|
||||||
const assert_1 = require("assert");
|
|
||||||
class HTTPError extends Error {
|
|
||||||
constructor(httpStatusCode) {
|
|
||||||
super(`Unexpected HTTP response: ${httpStatusCode}`);
|
|
||||||
this.httpStatusCode = httpStatusCode;
|
|
||||||
Object.setPrototypeOf(this, new.target.prototype);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.HTTPError = HTTPError;
|
|
||||||
const IS_WINDOWS = process.platform === 'win32';
|
|
||||||
const userAgent = 'actions/tool-cache';
|
|
||||||
// On load grab temp directory and cache directory and remove them from env (currently don't want to expose this)
|
|
||||||
let tempDirectory = process.env['RUNNER_TEMP'] || '';
|
|
||||||
let cacheRoot = process.env['RUNNER_TOOL_CACHE'] || '';
|
|
||||||
// If directories not found, place them in common temp locations
|
|
||||||
if (!tempDirectory || !cacheRoot) {
|
|
||||||
let baseLocation;
|
|
||||||
if (IS_WINDOWS) {
|
|
||||||
// On windows use the USERPROFILE env variable
|
|
||||||
baseLocation = process.env['USERPROFILE'] || 'C:\\';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (process.platform === 'darwin') {
|
|
||||||
baseLocation = '/Users';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
baseLocation = '/home';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!tempDirectory) {
|
|
||||||
tempDirectory = path.join(baseLocation, 'actions', 'temp');
|
|
||||||
}
|
|
||||||
if (!cacheRoot) {
|
|
||||||
cacheRoot = path.join(baseLocation, 'actions', 'cache');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Download a tool from an url and stream it into a file
|
|
||||||
*
|
|
||||||
* @param url url of tool to download
|
|
||||||
* @returns path to downloaded tool
|
|
||||||
*/
|
|
||||||
function downloadTool(url) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
// Wrap in a promise so that we can resolve from within stream callbacks
|
|
||||||
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
||||||
try {
|
|
||||||
const http = new httpm.HttpClient(userAgent, [], {
|
|
||||||
allowRetries: true,
|
|
||||||
maxRetries: 3
|
|
||||||
});
|
|
||||||
const destPath = path.join(tempDirectory, uuidV4());
|
|
||||||
yield io.mkdirP(tempDirectory);
|
|
||||||
core.debug(`Downloading ${url}`);
|
|
||||||
core.debug(`Downloading ${destPath}`);
|
|
||||||
if (fs.existsSync(destPath)) {
|
|
||||||
throw new Error(`Destination file path ${destPath} already exists`);
|
|
||||||
}
|
|
||||||
const response = yield http.get(url);
|
|
||||||
if (response.message.statusCode !== 200) {
|
|
||||||
const err = new HTTPError(response.message.statusCode);
|
|
||||||
core.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`);
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
const file = fs.createWriteStream(destPath);
|
|
||||||
file.on('open', () => __awaiter(this, void 0, void 0, function* () {
|
|
||||||
try {
|
|
||||||
const stream = response.message.pipe(file);
|
|
||||||
stream.on('close', () => {
|
|
||||||
core.debug('download complete');
|
|
||||||
resolve(destPath);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
core.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`);
|
|
||||||
reject(err);
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
file.on('error', err => {
|
|
||||||
file.end();
|
|
||||||
reject(err);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
reject(err);
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
exports.downloadTool = downloadTool;
|
|
||||||
/**
|
|
||||||
* Extract a .7z file
|
|
||||||
*
|
|
||||||
* @param file path to the .7z file
|
|
||||||
* @param dest destination directory. Optional.
|
|
||||||
* @param _7zPath path to 7zr.exe. Optional, for long path support. Most .7z archives do not have this
|
|
||||||
* problem. If your .7z archive contains very long paths, you can pass the path to 7zr.exe which will
|
|
||||||
* gracefully handle long paths. By default 7zdec.exe is used because it is a very small program and is
|
|
||||||
* bundled with the tool lib. However it does not support long paths. 7zr.exe is the reduced command line
|
|
||||||
* interface, it is smaller than the full command line interface, and it does support long paths. At the
|
|
||||||
* time of this writing, it is freely available from the LZMA SDK that is available on the 7zip website.
|
|
||||||
* Be sure to check the current license agreement. If 7zr.exe is bundled with your action, then the path
|
|
||||||
* to 7zr.exe can be pass to this function.
|
|
||||||
* @returns path to the destination directory
|
|
||||||
*/
|
|
||||||
function extract7z(file, dest, _7zPath) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
assert_1.ok(IS_WINDOWS, 'extract7z() not supported on current OS');
|
|
||||||
assert_1.ok(file, 'parameter "file" is required');
|
|
||||||
dest = dest || (yield _createExtractFolder(dest));
|
|
||||||
const originalCwd = process.cwd();
|
|
||||||
process.chdir(dest);
|
|
||||||
if (_7zPath) {
|
|
||||||
try {
|
|
||||||
const args = [
|
|
||||||
'x',
|
|
||||||
'-bb1',
|
|
||||||
'-bd',
|
|
||||||
'-sccUTF-8',
|
|
||||||
file
|
|
||||||
];
|
|
||||||
const options = {
|
|
||||||
silent: true
|
|
||||||
};
|
|
||||||
yield exec_1.exec(`"${_7zPath}"`, args, options);
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
process.chdir(originalCwd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
const escapedScript = path
|
|
||||||
.join(__dirname, '..', 'scripts', 'Invoke-7zdec.ps1')
|
|
||||||
.replace(/'/g, "''")
|
|
||||||
.replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines
|
|
||||||
const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, '');
|
|
||||||
const escapedTarget = dest.replace(/'/g, "''").replace(/"|\n|\r/g, '');
|
|
||||||
const command = `& '${escapedScript}' -Source '${escapedFile}' -Target '${escapedTarget}'`;
|
|
||||||
const args = [
|
|
||||||
'-NoLogo',
|
|
||||||
'-Sta',
|
|
||||||
'-NoProfile',
|
|
||||||
'-NonInteractive',
|
|
||||||
'-ExecutionPolicy',
|
|
||||||
'Unrestricted',
|
|
||||||
'-Command',
|
|
||||||
command
|
|
||||||
];
|
|
||||||
const options = {
|
|
||||||
silent: true
|
|
||||||
};
|
|
||||||
try {
|
|
||||||
const powershellPath = yield io.which('powershell', true);
|
|
||||||
yield exec_1.exec(`"${powershellPath}"`, args, options);
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
process.chdir(originalCwd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return dest;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
exports.extract7z = extract7z;
|
|
||||||
/**
|
|
||||||
* Extract a tar
|
|
||||||
*
|
|
||||||
* @param file path to the tar
|
|
||||||
* @param dest destination directory. Optional.
|
|
||||||
* @returns path to the destination directory
|
|
||||||
*/
|
|
||||||
function extractTar(file, dest) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
if (!file) {
|
|
||||||
throw new Error("parameter 'file' is required");
|
|
||||||
}
|
|
||||||
dest = dest || (yield _createExtractFolder(dest));
|
|
||||||
const tarPath = yield io.which('tar', true);
|
|
||||||
yield exec_1.exec(`"${tarPath}"`, ['xzC', dest, '-f', file]);
|
|
||||||
return dest;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
exports.extractTar = extractTar;
|
|
||||||
/**
|
|
||||||
* Extract a zip
|
|
||||||
*
|
|
||||||
* @param file path to the zip
|
|
||||||
* @param dest destination directory. Optional.
|
|
||||||
* @returns path to the destination directory
|
|
||||||
*/
|
|
||||||
function extractZip(file, dest) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
if (!file) {
|
|
||||||
throw new Error("parameter 'file' is required");
|
|
||||||
}
|
|
||||||
dest = dest || (yield _createExtractFolder(dest));
|
|
||||||
if (IS_WINDOWS) {
|
|
||||||
yield extractZipWin(file, dest);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
yield extractZipNix(file, dest);
|
|
||||||
}
|
|
||||||
return dest;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
exports.extractZip = extractZip;
|
|
||||||
function extractZipWin(file, dest) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
// build the powershell command
|
|
||||||
const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines
|
|
||||||
const escapedDest = dest.replace(/'/g, "''").replace(/"|\n|\r/g, '');
|
|
||||||
const command = `$ErrorActionPreference = 'Stop' ; try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ; [System.IO.Compression.ZipFile]::ExtractToDirectory('${escapedFile}', '${escapedDest}')`;
|
|
||||||
// run powershell
|
|
||||||
const powershellPath = yield io.which('powershell');
|
|
||||||
const args = [
|
|
||||||
'-NoLogo',
|
|
||||||
'-Sta',
|
|
||||||
'-NoProfile',
|
|
||||||
'-NonInteractive',
|
|
||||||
'-ExecutionPolicy',
|
|
||||||
'Unrestricted',
|
|
||||||
'-Command',
|
|
||||||
command
|
|
||||||
];
|
|
||||||
yield exec_1.exec(`"${powershellPath}"`, args);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
function extractZipNix(file, dest) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
const unzipPath = path.join(__dirname, '..', 'scripts', 'externals', 'unzip');
|
|
||||||
yield exec_1.exec(`"${unzipPath}"`, [file], { cwd: dest });
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Caches a directory and installs it into the tool cacheDir
|
|
||||||
*
|
|
||||||
* @param sourceDir the directory to cache into tools
|
|
||||||
* @param tool tool name
|
|
||||||
* @param version version of the tool. semver format
|
|
||||||
* @param arch architecture of the tool. Optional. Defaults to machine architecture
|
|
||||||
*/
|
|
||||||
function cacheDir(sourceDir, tool, version, arch) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
version = semver.clean(version) || version;
|
|
||||||
arch = arch || os.arch();
|
|
||||||
core.debug(`Caching tool ${tool} ${version} ${arch}`);
|
|
||||||
core.debug(`source dir: ${sourceDir}`);
|
|
||||||
if (!fs.statSync(sourceDir).isDirectory()) {
|
|
||||||
throw new Error('sourceDir is not a directory');
|
|
||||||
}
|
|
||||||
// Create the tool dir
|
|
||||||
const destPath = yield _createToolPath(tool, version, arch);
|
|
||||||
// copy each child item. do not move. move can fail on Windows
|
|
||||||
// due to anti-virus software having an open handle on a file.
|
|
||||||
for (const itemName of fs.readdirSync(sourceDir)) {
|
|
||||||
const s = path.join(sourceDir, itemName);
|
|
||||||
yield io.cp(s, destPath, { recursive: true });
|
|
||||||
}
|
|
||||||
// write .complete
|
|
||||||
_completeToolPath(tool, version, arch);
|
|
||||||
return destPath;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
exports.cacheDir = cacheDir;
|
|
||||||
/**
|
|
||||||
* Caches a downloaded file (GUID) and installs it
|
|
||||||
* into the tool cache with a given targetName
|
|
||||||
*
|
|
||||||
* @param sourceFile the file to cache into tools. Typically a result of downloadTool which is a guid.
|
|
||||||
* @param targetFile the name of the file name in the tools directory
|
|
||||||
* @param tool tool name
|
|
||||||
* @param version version of the tool. semver format
|
|
||||||
* @param arch architecture of the tool. Optional. Defaults to machine architecture
|
|
||||||
*/
|
|
||||||
function cacheFile(sourceFile, targetFile, tool, version, arch) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
version = semver.clean(version) || version;
|
|
||||||
arch = arch || os.arch();
|
|
||||||
core.debug(`Caching tool ${tool} ${version} ${arch}`);
|
|
||||||
core.debug(`source file: ${sourceFile}`);
|
|
||||||
if (!fs.statSync(sourceFile).isFile()) {
|
|
||||||
throw new Error('sourceFile is not a file');
|
|
||||||
}
|
|
||||||
// create the tool dir
|
|
||||||
const destFolder = yield _createToolPath(tool, version, arch);
|
|
||||||
// copy instead of move. move can fail on Windows due to
|
|
||||||
// anti-virus software having an open handle on a file.
|
|
||||||
const destPath = path.join(destFolder, targetFile);
|
|
||||||
core.debug(`destination file ${destPath}`);
|
|
||||||
yield io.cp(sourceFile, destPath);
|
|
||||||
// write .complete
|
|
||||||
_completeToolPath(tool, version, arch);
|
|
||||||
return destFolder;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
exports.cacheFile = cacheFile;
|
|
||||||
/**
|
|
||||||
* Finds the path to a tool version in the local installed tool cache
|
|
||||||
*
|
|
||||||
* @param toolName name of the tool
|
|
||||||
* @param versionSpec version of the tool
|
|
||||||
* @param arch optional arch. defaults to arch of computer
|
|
||||||
*/
|
|
||||||
function find(toolName, versionSpec, arch) {
|
|
||||||
if (!toolName) {
|
|
||||||
throw new Error('toolName parameter is required');
|
|
||||||
}
|
|
||||||
if (!versionSpec) {
|
|
||||||
throw new Error('versionSpec parameter is required');
|
|
||||||
}
|
|
||||||
arch = arch || os.arch();
|
|
||||||
// attempt to resolve an explicit version
|
|
||||||
if (!_isExplicitVersion(versionSpec)) {
|
|
||||||
const localVersions = findAllVersions(toolName, arch);
|
|
||||||
const match = _evaluateVersions(localVersions, versionSpec);
|
|
||||||
versionSpec = match;
|
|
||||||
}
|
|
||||||
// check for the explicit version in the cache
|
|
||||||
let toolPath = '';
|
|
||||||
if (versionSpec) {
|
|
||||||
versionSpec = semver.clean(versionSpec) || '';
|
|
||||||
const cachePath = path.join(cacheRoot, toolName, versionSpec, arch);
|
|
||||||
core.debug(`checking cache: ${cachePath}`);
|
|
||||||
if (fs.existsSync(cachePath) && fs.existsSync(`${cachePath}.complete`)) {
|
|
||||||
core.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch}`);
|
|
||||||
toolPath = cachePath;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
core.debug('not found');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return toolPath;
|
|
||||||
}
|
|
||||||
exports.find = find;
|
|
||||||
/**
|
|
||||||
* Finds the paths to all versions of a tool that are installed in the local tool cache
|
|
||||||
*
|
|
||||||
* @param toolName name of the tool
|
|
||||||
* @param arch optional arch. defaults to arch of computer
|
|
||||||
*/
|
|
||||||
function findAllVersions(toolName, arch) {
|
|
||||||
const versions = [];
|
|
||||||
arch = arch || os.arch();
|
|
||||||
const toolPath = path.join(cacheRoot, toolName);
|
|
||||||
if (fs.existsSync(toolPath)) {
|
|
||||||
const children = fs.readdirSync(toolPath);
|
|
||||||
for (const child of children) {
|
|
||||||
if (_isExplicitVersion(child)) {
|
|
||||||
const fullPath = path.join(toolPath, child, arch || '');
|
|
||||||
if (fs.existsSync(fullPath) && fs.existsSync(`${fullPath}.complete`)) {
|
|
||||||
versions.push(child);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return versions;
|
|
||||||
}
|
|
||||||
exports.findAllVersions = findAllVersions;
|
|
||||||
function _createExtractFolder(dest) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
if (!dest) {
|
|
||||||
// create a temp dir
|
|
||||||
dest = path.join(tempDirectory, uuidV4());
|
|
||||||
}
|
|
||||||
yield io.mkdirP(dest);
|
|
||||||
return dest;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
function _createToolPath(tool, version, arch) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
const folderPath = path.join(cacheRoot, tool, semver.clean(version) || version, arch || '');
|
|
||||||
core.debug(`destination ${folderPath}`);
|
|
||||||
const markerPath = `${folderPath}.complete`;
|
|
||||||
yield io.rmRF(folderPath);
|
|
||||||
yield io.rmRF(markerPath);
|
|
||||||
yield io.mkdirP(folderPath);
|
|
||||||
return folderPath;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
function _completeToolPath(tool, version, arch) {
|
|
||||||
const folderPath = path.join(cacheRoot, tool, semver.clean(version) || version, arch || '');
|
|
||||||
const markerPath = `${folderPath}.complete`;
|
|
||||||
fs.writeFileSync(markerPath, '');
|
|
||||||
core.debug('finished caching tool');
|
|
||||||
}
|
|
||||||
function _isExplicitVersion(versionSpec) {
|
|
||||||
const c = semver.clean(versionSpec) || '';
|
|
||||||
core.debug(`isExplicit: ${c}`);
|
|
||||||
const valid = semver.valid(c) != null;
|
|
||||||
core.debug(`explicit? ${valid}`);
|
|
||||||
return valid;
|
|
||||||
}
|
|
||||||
function _evaluateVersions(versions, versionSpec) {
|
|
||||||
let version = '';
|
|
||||||
core.debug(`evaluating ${versions.length} versions`);
|
|
||||||
versions = versions.sort((a, b) => {
|
|
||||||
if (semver.gt(a, b)) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
});
|
|
||||||
for (let i = versions.length - 1; i >= 0; i--) {
|
|
||||||
const potential = versions[i];
|
|
||||||
const satisfied = semver.satisfies(potential, versionSpec);
|
|
||||||
if (satisfied) {
|
|
||||||
version = potential;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (version) {
|
|
||||||
core.debug(`matched: ${version}`);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
core.debug('match not found');
|
|
||||||
}
|
|
||||||
return version;
|
|
||||||
}
|
|
||||||
//# sourceMappingURL=tool-cache.js.map
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -1,75 +0,0 @@
|
||||||
{
|
|
||||||
"_from": "file:toolkit\\actions-tool-cache-0.0.0.tgz",
|
|
||||||
"_id": "@actions/tool-cache@0.0.0",
|
|
||||||
"_inBundle": false,
|
|
||||||
"_integrity": "sha512-33oYAVRdp6MWNT7Yca0//SmOsvpE7FpFfNA/LzwjIZdLucHaO6V67dqZ5p81CTBncrZal+O5kE9B8qSk0rhipg==",
|
|
||||||
"_location": "/@actions/tool-cache",
|
|
||||||
"_phantomChildren": {},
|
|
||||||
"_requested": {
|
|
||||||
"type": "file",
|
|
||||||
"where": "C:\\Users\\Administrator\\Documents\\setup-node",
|
|
||||||
"raw": "@actions/tool-cache@file:toolkit/actions-tool-cache-0.0.0.tgz",
|
|
||||||
"name": "@actions/tool-cache",
|
|
||||||
"escapedName": "@actions%2ftool-cache",
|
|
||||||
"scope": "@actions",
|
|
||||||
"rawSpec": "file:toolkit/actions-tool-cache-0.0.0.tgz",
|
|
||||||
"saveSpec": "file:toolkit\\actions-tool-cache-0.0.0.tgz",
|
|
||||||
"fetchSpec": "C:\\Users\\Administrator\\Documents\\setup-node\\toolkit\\actions-tool-cache-0.0.0.tgz"
|
|
||||||
},
|
|
||||||
"_requiredBy": [
|
|
||||||
"#USER",
|
|
||||||
"/"
|
|
||||||
],
|
|
||||||
"_resolved": "C:\\Users\\Administrator\\Documents\\setup-node\\toolkit\\actions-tool-cache-0.0.0.tgz",
|
|
||||||
"_shasum": "ce9e7d81ebb138911d20b9f74c8aa6120caac9b1",
|
|
||||||
"_spec": "@actions/tool-cache@file:toolkit/actions-tool-cache-0.0.0.tgz",
|
|
||||||
"_where": "C:\\Users\\Administrator\\Documents\\setup-node",
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/actions/toolkit/issues"
|
|
||||||
},
|
|
||||||
"bundleDependencies": false,
|
|
||||||
"dependencies": {
|
|
||||||
"@actions/core": "^0.0.0",
|
|
||||||
"@actions/exec": "^0.0.0",
|
|
||||||
"@actions/io": "^0.0.0",
|
|
||||||
"semver": "^6.1.0",
|
|
||||||
"typed-rest-client": "^1.4.0",
|
|
||||||
"uuid": "^3.3.2"
|
|
||||||
},
|
|
||||||
"deprecated": false,
|
|
||||||
"description": "Actions tool-cache lib",
|
|
||||||
"devDependencies": {
|
|
||||||
"@types/nock": "^10.0.3",
|
|
||||||
"@types/semver": "^6.0.0",
|
|
||||||
"@types/uuid": "^3.4.4",
|
|
||||||
"nock": "^10.0.6"
|
|
||||||
},
|
|
||||||
"directories": {
|
|
||||||
"lib": "lib",
|
|
||||||
"test": "__tests__"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"lib",
|
|
||||||
"scripts"
|
|
||||||
],
|
|
||||||
"homepage": "https://github.com/actions/toolkit/tree/master/packages/exec",
|
|
||||||
"keywords": [
|
|
||||||
"exec",
|
|
||||||
"actions"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"main": "lib/tool-cache.js",
|
|
||||||
"name": "@actions/tool-cache",
|
|
||||||
"publishConfig": {
|
|
||||||
"access": "public"
|
|
||||||
},
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/actions/toolkit.git"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"test": "echo \"Error: run tests from root\" && exit 1",
|
|
||||||
"tsc": "tsc"
|
|
||||||
},
|
|
||||||
"version": "0.0.0"
|
|
||||||
}
|
|
||||||
|
|
@ -1,60 +0,0 @@
|
||||||
[CmdletBinding()]
|
|
||||||
param(
|
|
||||||
[Parameter(Mandatory = $true)]
|
|
||||||
[string]$Source,
|
|
||||||
|
|
||||||
[Parameter(Mandatory = $true)]
|
|
||||||
[string]$Target)
|
|
||||||
|
|
||||||
# This script translates the output from 7zdec into UTF8. Node has limited
|
|
||||||
# built-in support for encodings.
|
|
||||||
#
|
|
||||||
# 7zdec uses the system default code page. The system default code page varies
|
|
||||||
# depending on the locale configuration. On an en-US box, the system default code
|
|
||||||
# page is Windows-1252.
|
|
||||||
#
|
|
||||||
# Note, on a typical en-US box, testing with the 'ç' character is a good way to
|
|
||||||
# determine whether data is passed correctly between processes. This is because
|
|
||||||
# the 'ç' character has a different code point across each of the common encodings
|
|
||||||
# on a typical en-US box, i.e.
|
|
||||||
# 1) the default console-output code page (IBM437)
|
|
||||||
# 2) the system default code page (i.e. CP_ACP) (Windows-1252)
|
|
||||||
# 3) UTF8
|
|
||||||
|
|
||||||
$ErrorActionPreference = 'Stop'
|
|
||||||
|
|
||||||
# Redefine the wrapper over STDOUT to use UTF8. Node expects UTF8 by default.
|
|
||||||
$stdout = [System.Console]::OpenStandardOutput()
|
|
||||||
$utf8 = New-Object System.Text.UTF8Encoding($false) # do not emit BOM
|
|
||||||
$writer = New-Object System.IO.StreamWriter($stdout, $utf8)
|
|
||||||
[System.Console]::SetOut($writer)
|
|
||||||
|
|
||||||
# All subsequent output must be written using [System.Console]::WriteLine(). In
|
|
||||||
# PowerShell 4, Write-Host and Out-Default do not consider the updated stream writer.
|
|
||||||
|
|
||||||
Set-Location -LiteralPath $Target
|
|
||||||
|
|
||||||
# Print the ##command.
|
|
||||||
$_7zdec = Join-Path -Path "$PSScriptRoot" -ChildPath "externals/7zdec.exe"
|
|
||||||
[System.Console]::WriteLine("##[command]$_7zdec x `"$Source`"")
|
|
||||||
|
|
||||||
# The $OutputEncoding variable instructs PowerShell how to interpret the output
|
|
||||||
# from the external command.
|
|
||||||
$OutputEncoding = [System.Text.Encoding]::Default
|
|
||||||
|
|
||||||
# Note, the output from 7zdec.exe needs to be iterated over. Otherwise PowerShell.exe
|
|
||||||
# will launch the external command in such a way that it inherits the streams.
|
|
||||||
& $_7zdec x $Source 2>&1 |
|
|
||||||
ForEach-Object {
|
|
||||||
if ($_ -is [System.Management.Automation.ErrorRecord]) {
|
|
||||||
[System.Console]::WriteLine($_.Exception.Message)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
[System.Console]::WriteLine($_)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
[System.Console]::WriteLine("##[debug]7zdec.exe exit code '$LASTEXITCODE'")
|
|
||||||
[System.Console]::Out.Flush()
|
|
||||||
if ($LASTEXITCODE -ne 0) {
|
|
||||||
exit $LASTEXITCODE
|
|
||||||
}
|
|
||||||
Binary file not shown.
Binary file not shown.
|
|
@ -1,47 +0,0 @@
|
||||||
# changes log
|
|
||||||
|
|
||||||
## 6.0
|
|
||||||
|
|
||||||
* Fix `intersects` logic.
|
|
||||||
|
|
||||||
This is technically a bug fix, but since it is also a change to behavior
|
|
||||||
that may require users updating their code, it is marked as a major
|
|
||||||
version increment.
|
|
||||||
|
|
||||||
## 5.7
|
|
||||||
|
|
||||||
* Add `minVersion` method
|
|
||||||
|
|
||||||
## 5.6
|
|
||||||
|
|
||||||
* Move boolean `loose` param to an options object, with
|
|
||||||
backwards-compatibility protection.
|
|
||||||
* Add ability to opt out of special prerelease version handling with
|
|
||||||
the `includePrerelease` option flag.
|
|
||||||
|
|
||||||
## 5.5
|
|
||||||
|
|
||||||
* Add version coercion capabilities
|
|
||||||
|
|
||||||
## 5.4
|
|
||||||
|
|
||||||
* Add intersection checking
|
|
||||||
|
|
||||||
## 5.3
|
|
||||||
|
|
||||||
* Add `minSatisfying` method
|
|
||||||
|
|
||||||
## 5.2
|
|
||||||
|
|
||||||
* Add `prerelease(v)` that returns prerelease components
|
|
||||||
|
|
||||||
## 5.1
|
|
||||||
|
|
||||||
* Add Backus-Naur for ranges
|
|
||||||
* Remove excessively cute inspection methods
|
|
||||||
|
|
||||||
## 5.0
|
|
||||||
|
|
||||||
* Remove AMD/Browserified build artifacts
|
|
||||||
* Fix ltr and gtr when using the `*` range
|
|
||||||
* Fix for range `*` with a prerelease identifier
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
The ISC License
|
|
||||||
|
|
||||||
Copyright (c) Isaac Z. Schlueter and Contributors
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
|
||||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
|
|
@ -1,430 +0,0 @@
|
||||||
semver(1) -- The semantic versioner for npm
|
|
||||||
===========================================
|
|
||||||
|
|
||||||
## Install
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npm install semver
|
|
||||||
````
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
As a node module:
|
|
||||||
|
|
||||||
```js
|
|
||||||
const semver = require('semver')
|
|
||||||
|
|
||||||
semver.valid('1.2.3') // '1.2.3'
|
|
||||||
semver.valid('a.b.c') // null
|
|
||||||
semver.clean(' =v1.2.3 ') // '1.2.3'
|
|
||||||
semver.satisfies('1.2.3', '1.x || >=2.5.0 || 5.0.0 - 7.2.3') // true
|
|
||||||
semver.gt('1.2.3', '9.8.7') // false
|
|
||||||
semver.lt('1.2.3', '9.8.7') // true
|
|
||||||
semver.minVersion('>=1.0.0') // '1.0.0'
|
|
||||||
semver.valid(semver.coerce('v2')) // '2.0.0'
|
|
||||||
semver.valid(semver.coerce('42.6.7.9.3-alpha')) // '42.6.7'
|
|
||||||
```
|
|
||||||
|
|
||||||
As a command-line utility:
|
|
||||||
|
|
||||||
```
|
|
||||||
$ semver -h
|
|
||||||
|
|
||||||
A JavaScript implementation of the https://semver.org/ specification
|
|
||||||
Copyright Isaac Z. Schlueter
|
|
||||||
|
|
||||||
Usage: semver [options] <version> [<version> [...]]
|
|
||||||
Prints valid versions sorted by SemVer precedence
|
|
||||||
|
|
||||||
Options:
|
|
||||||
-r --range <range>
|
|
||||||
Print versions that match the specified range.
|
|
||||||
|
|
||||||
-i --increment [<level>]
|
|
||||||
Increment a version by the specified level. Level can
|
|
||||||
be one of: major, minor, patch, premajor, preminor,
|
|
||||||
prepatch, or prerelease. Default level is 'patch'.
|
|
||||||
Only one version may be specified.
|
|
||||||
|
|
||||||
--preid <identifier>
|
|
||||||
Identifier to be used to prefix premajor, preminor,
|
|
||||||
prepatch or prerelease version increments.
|
|
||||||
|
|
||||||
-l --loose
|
|
||||||
Interpret versions and ranges loosely
|
|
||||||
|
|
||||||
-p --include-prerelease
|
|
||||||
Always include prerelease versions in range matching
|
|
||||||
|
|
||||||
-c --coerce
|
|
||||||
Coerce a string into SemVer if possible
|
|
||||||
(does not imply --loose)
|
|
||||||
|
|
||||||
Program exits successfully if any valid version satisfies
|
|
||||||
all supplied ranges, and prints all satisfying versions.
|
|
||||||
|
|
||||||
If no satisfying versions are found, then exits failure.
|
|
||||||
|
|
||||||
Versions are printed in ascending order, so supplying
|
|
||||||
multiple versions to the utility will just sort them.
|
|
||||||
```
|
|
||||||
|
|
||||||
## Versions
|
|
||||||
|
|
||||||
A "version" is described by the `v2.0.0` specification found at
|
|
||||||
<https://semver.org/>.
|
|
||||||
|
|
||||||
A leading `"="` or `"v"` character is stripped off and ignored.
|
|
||||||
|
|
||||||
## Ranges
|
|
||||||
|
|
||||||
A `version range` is a set of `comparators` which specify versions
|
|
||||||
that satisfy the range.
|
|
||||||
|
|
||||||
A `comparator` is composed of an `operator` and a `version`. The set
|
|
||||||
of primitive `operators` is:
|
|
||||||
|
|
||||||
* `<` Less than
|
|
||||||
* `<=` Less than or equal to
|
|
||||||
* `>` Greater than
|
|
||||||
* `>=` Greater than or equal to
|
|
||||||
* `=` Equal. If no operator is specified, then equality is assumed,
|
|
||||||
so this operator is optional, but MAY be included.
|
|
||||||
|
|
||||||
For example, the comparator `>=1.2.7` would match the versions
|
|
||||||
`1.2.7`, `1.2.8`, `2.5.3`, and `1.3.9`, but not the versions `1.2.6`
|
|
||||||
or `1.1.0`.
|
|
||||||
|
|
||||||
Comparators can be joined by whitespace to form a `comparator set`,
|
|
||||||
which is satisfied by the **intersection** of all of the comparators
|
|
||||||
it includes.
|
|
||||||
|
|
||||||
A range is composed of one or more comparator sets, joined by `||`. A
|
|
||||||
version matches a range if and only if every comparator in at least
|
|
||||||
one of the `||`-separated comparator sets is satisfied by the version.
|
|
||||||
|
|
||||||
For example, the range `>=1.2.7 <1.3.0` would match the versions
|
|
||||||
`1.2.7`, `1.2.8`, and `1.2.99`, but not the versions `1.2.6`, `1.3.0`,
|
|
||||||
or `1.1.0`.
|
|
||||||
|
|
||||||
The range `1.2.7 || >=1.2.9 <2.0.0` would match the versions `1.2.7`,
|
|
||||||
`1.2.9`, and `1.4.6`, but not the versions `1.2.8` or `2.0.0`.
|
|
||||||
|
|
||||||
### Prerelease Tags
|
|
||||||
|
|
||||||
If a version has a prerelease tag (for example, `1.2.3-alpha.3`) then
|
|
||||||
it will only be allowed to satisfy comparator sets if at least one
|
|
||||||
comparator with the same `[major, minor, patch]` tuple also has a
|
|
||||||
prerelease tag.
|
|
||||||
|
|
||||||
For example, the range `>1.2.3-alpha.3` would be allowed to match the
|
|
||||||
version `1.2.3-alpha.7`, but it would *not* be satisfied by
|
|
||||||
`3.4.5-alpha.9`, even though `3.4.5-alpha.9` is technically "greater
|
|
||||||
than" `1.2.3-alpha.3` according to the SemVer sort rules. The version
|
|
||||||
range only accepts prerelease tags on the `1.2.3` version. The
|
|
||||||
version `3.4.5` *would* satisfy the range, because it does not have a
|
|
||||||
prerelease flag, and `3.4.5` is greater than `1.2.3-alpha.7`.
|
|
||||||
|
|
||||||
The purpose for this behavior is twofold. First, prerelease versions
|
|
||||||
frequently are updated very quickly, and contain many breaking changes
|
|
||||||
that are (by the author's design) not yet fit for public consumption.
|
|
||||||
Therefore, by default, they are excluded from range matching
|
|
||||||
semantics.
|
|
||||||
|
|
||||||
Second, a user who has opted into using a prerelease version has
|
|
||||||
clearly indicated the intent to use *that specific* set of
|
|
||||||
alpha/beta/rc versions. By including a prerelease tag in the range,
|
|
||||||
the user is indicating that they are aware of the risk. However, it
|
|
||||||
is still not appropriate to assume that they have opted into taking a
|
|
||||||
similar risk on the *next* set of prerelease versions.
|
|
||||||
|
|
||||||
Note that this behavior can be suppressed (treating all prerelease
|
|
||||||
versions as if they were normal versions, for the purpose of range
|
|
||||||
matching) by setting the `includePrerelease` flag on the options
|
|
||||||
object to any
|
|
||||||
[functions](https://github.com/npm/node-semver#functions) that do
|
|
||||||
range matching.
|
|
||||||
|
|
||||||
#### Prerelease Identifiers
|
|
||||||
|
|
||||||
The method `.inc` takes an additional `identifier` string argument that
|
|
||||||
will append the value of the string as a prerelease identifier:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
semver.inc('1.2.3', 'prerelease', 'beta')
|
|
||||||
// '1.2.4-beta.0'
|
|
||||||
```
|
|
||||||
|
|
||||||
command-line example:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ semver 1.2.3 -i prerelease --preid beta
|
|
||||||
1.2.4-beta.0
|
|
||||||
```
|
|
||||||
|
|
||||||
Which then can be used to increment further:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ semver 1.2.4-beta.0 -i prerelease
|
|
||||||
1.2.4-beta.1
|
|
||||||
```
|
|
||||||
|
|
||||||
### Advanced Range Syntax
|
|
||||||
|
|
||||||
Advanced range syntax desugars to primitive comparators in
|
|
||||||
deterministic ways.
|
|
||||||
|
|
||||||
Advanced ranges may be combined in the same way as primitive
|
|
||||||
comparators using white space or `||`.
|
|
||||||
|
|
||||||
#### Hyphen Ranges `X.Y.Z - A.B.C`
|
|
||||||
|
|
||||||
Specifies an inclusive set.
|
|
||||||
|
|
||||||
* `1.2.3 - 2.3.4` := `>=1.2.3 <=2.3.4`
|
|
||||||
|
|
||||||
If a partial version is provided as the first version in the inclusive
|
|
||||||
range, then the missing pieces are replaced with zeroes.
|
|
||||||
|
|
||||||
* `1.2 - 2.3.4` := `>=1.2.0 <=2.3.4`
|
|
||||||
|
|
||||||
If a partial version is provided as the second version in the
|
|
||||||
inclusive range, then all versions that start with the supplied parts
|
|
||||||
of the tuple are accepted, but nothing that would be greater than the
|
|
||||||
provided tuple parts.
|
|
||||||
|
|
||||||
* `1.2.3 - 2.3` := `>=1.2.3 <2.4.0`
|
|
||||||
* `1.2.3 - 2` := `>=1.2.3 <3.0.0`
|
|
||||||
|
|
||||||
#### X-Ranges `1.2.x` `1.X` `1.2.*` `*`
|
|
||||||
|
|
||||||
Any of `X`, `x`, or `*` may be used to "stand in" for one of the
|
|
||||||
numeric values in the `[major, minor, patch]` tuple.
|
|
||||||
|
|
||||||
* `*` := `>=0.0.0` (Any version satisfies)
|
|
||||||
* `1.x` := `>=1.0.0 <2.0.0` (Matching major version)
|
|
||||||
* `1.2.x` := `>=1.2.0 <1.3.0` (Matching major and minor versions)
|
|
||||||
|
|
||||||
A partial version range is treated as an X-Range, so the special
|
|
||||||
character is in fact optional.
|
|
||||||
|
|
||||||
* `""` (empty string) := `*` := `>=0.0.0`
|
|
||||||
* `1` := `1.x.x` := `>=1.0.0 <2.0.0`
|
|
||||||
* `1.2` := `1.2.x` := `>=1.2.0 <1.3.0`
|
|
||||||
|
|
||||||
#### Tilde Ranges `~1.2.3` `~1.2` `~1`
|
|
||||||
|
|
||||||
Allows patch-level changes if a minor version is specified on the
|
|
||||||
comparator. Allows minor-level changes if not.
|
|
||||||
|
|
||||||
* `~1.2.3` := `>=1.2.3 <1.(2+1).0` := `>=1.2.3 <1.3.0`
|
|
||||||
* `~1.2` := `>=1.2.0 <1.(2+1).0` := `>=1.2.0 <1.3.0` (Same as `1.2.x`)
|
|
||||||
* `~1` := `>=1.0.0 <(1+1).0.0` := `>=1.0.0 <2.0.0` (Same as `1.x`)
|
|
||||||
* `~0.2.3` := `>=0.2.3 <0.(2+1).0` := `>=0.2.3 <0.3.0`
|
|
||||||
* `~0.2` := `>=0.2.0 <0.(2+1).0` := `>=0.2.0 <0.3.0` (Same as `0.2.x`)
|
|
||||||
* `~0` := `>=0.0.0 <(0+1).0.0` := `>=0.0.0 <1.0.0` (Same as `0.x`)
|
|
||||||
* `~1.2.3-beta.2` := `>=1.2.3-beta.2 <1.3.0` Note that prereleases in
|
|
||||||
the `1.2.3` version will be allowed, if they are greater than or
|
|
||||||
equal to `beta.2`. So, `1.2.3-beta.4` would be allowed, but
|
|
||||||
`1.2.4-beta.2` would not, because it is a prerelease of a
|
|
||||||
different `[major, minor, patch]` tuple.
|
|
||||||
|
|
||||||
#### Caret Ranges `^1.2.3` `^0.2.5` `^0.0.4`
|
|
||||||
|
|
||||||
Allows changes that do not modify the left-most non-zero element in the
|
|
||||||
`[major, minor, patch]` tuple. In other words, this allows patch and
|
|
||||||
minor updates for versions `1.0.0` and above, patch updates for
|
|
||||||
versions `0.X >=0.1.0`, and *no* updates for versions `0.0.X`.
|
|
||||||
|
|
||||||
Many authors treat a `0.x` version as if the `x` were the major
|
|
||||||
"breaking-change" indicator.
|
|
||||||
|
|
||||||
Caret ranges are ideal when an author may make breaking changes
|
|
||||||
between `0.2.4` and `0.3.0` releases, which is a common practice.
|
|
||||||
However, it presumes that there will *not* be breaking changes between
|
|
||||||
`0.2.4` and `0.2.5`. It allows for changes that are presumed to be
|
|
||||||
additive (but non-breaking), according to commonly observed practices.
|
|
||||||
|
|
||||||
* `^1.2.3` := `>=1.2.3 <2.0.0`
|
|
||||||
* `^0.2.3` := `>=0.2.3 <0.3.0`
|
|
||||||
* `^0.0.3` := `>=0.0.3 <0.0.4`
|
|
||||||
* `^1.2.3-beta.2` := `>=1.2.3-beta.2 <2.0.0` Note that prereleases in
|
|
||||||
the `1.2.3` version will be allowed, if they are greater than or
|
|
||||||
equal to `beta.2`. So, `1.2.3-beta.4` would be allowed, but
|
|
||||||
`1.2.4-beta.2` would not, because it is a prerelease of a
|
|
||||||
different `[major, minor, patch]` tuple.
|
|
||||||
* `^0.0.3-beta` := `>=0.0.3-beta <0.0.4` Note that prereleases in the
|
|
||||||
`0.0.3` version *only* will be allowed, if they are greater than or
|
|
||||||
equal to `beta`. So, `0.0.3-pr.2` would be allowed.
|
|
||||||
|
|
||||||
When parsing caret ranges, a missing `patch` value desugars to the
|
|
||||||
number `0`, but will allow flexibility within that value, even if the
|
|
||||||
major and minor versions are both `0`.
|
|
||||||
|
|
||||||
* `^1.2.x` := `>=1.2.0 <2.0.0`
|
|
||||||
* `^0.0.x` := `>=0.0.0 <0.1.0`
|
|
||||||
* `^0.0` := `>=0.0.0 <0.1.0`
|
|
||||||
|
|
||||||
A missing `minor` and `patch` values will desugar to zero, but also
|
|
||||||
allow flexibility within those values, even if the major version is
|
|
||||||
zero.
|
|
||||||
|
|
||||||
* `^1.x` := `>=1.0.0 <2.0.0`
|
|
||||||
* `^0.x` := `>=0.0.0 <1.0.0`
|
|
||||||
|
|
||||||
### Range Grammar
|
|
||||||
|
|
||||||
Putting all this together, here is a Backus-Naur grammar for ranges,
|
|
||||||
for the benefit of parser authors:
|
|
||||||
|
|
||||||
```bnf
|
|
||||||
range-set ::= range ( logical-or range ) *
|
|
||||||
logical-or ::= ( ' ' ) * '||' ( ' ' ) *
|
|
||||||
range ::= hyphen | simple ( ' ' simple ) * | ''
|
|
||||||
hyphen ::= partial ' - ' partial
|
|
||||||
simple ::= primitive | partial | tilde | caret
|
|
||||||
primitive ::= ( '<' | '>' | '>=' | '<=' | '=' ) partial
|
|
||||||
partial ::= xr ( '.' xr ( '.' xr qualifier ? )? )?
|
|
||||||
xr ::= 'x' | 'X' | '*' | nr
|
|
||||||
nr ::= '0' | ['1'-'9'] ( ['0'-'9'] ) *
|
|
||||||
tilde ::= '~' partial
|
|
||||||
caret ::= '^' partial
|
|
||||||
qualifier ::= ( '-' pre )? ( '+' build )?
|
|
||||||
pre ::= parts
|
|
||||||
build ::= parts
|
|
||||||
parts ::= part ( '.' part ) *
|
|
||||||
part ::= nr | [-0-9A-Za-z]+
|
|
||||||
```
|
|
||||||
|
|
||||||
## Functions
|
|
||||||
|
|
||||||
All methods and classes take a final `options` object argument. All
|
|
||||||
options in this object are `false` by default. The options supported
|
|
||||||
are:
|
|
||||||
|
|
||||||
- `loose` Be more forgiving about not-quite-valid semver strings.
|
|
||||||
(Any resulting output will always be 100% strict compliant, of
|
|
||||||
course.) For backwards compatibility reasons, if the `options`
|
|
||||||
argument is a boolean value instead of an object, it is interpreted
|
|
||||||
to be the `loose` param.
|
|
||||||
- `includePrerelease` Set to suppress the [default
|
|
||||||
behavior](https://github.com/npm/node-semver#prerelease-tags) of
|
|
||||||
excluding prerelease tagged versions from ranges unless they are
|
|
||||||
explicitly opted into.
|
|
||||||
|
|
||||||
Strict-mode Comparators and Ranges will be strict about the SemVer
|
|
||||||
strings that they parse.
|
|
||||||
|
|
||||||
* `valid(v)`: Return the parsed version, or null if it's not valid.
|
|
||||||
* `inc(v, release)`: Return the version incremented by the release
|
|
||||||
type (`major`, `premajor`, `minor`, `preminor`, `patch`,
|
|
||||||
`prepatch`, or `prerelease`), or null if it's not valid
|
|
||||||
* `premajor` in one call will bump the version up to the next major
|
|
||||||
version and down to a prerelease of that major version.
|
|
||||||
`preminor`, and `prepatch` work the same way.
|
|
||||||
* If called from a non-prerelease version, the `prerelease` will work the
|
|
||||||
same as `prepatch`. It increments the patch version, then makes a
|
|
||||||
prerelease. If the input version is already a prerelease it simply
|
|
||||||
increments it.
|
|
||||||
* `prerelease(v)`: Returns an array of prerelease components, or null
|
|
||||||
if none exist. Example: `prerelease('1.2.3-alpha.1') -> ['alpha', 1]`
|
|
||||||
* `major(v)`: Return the major version number.
|
|
||||||
* `minor(v)`: Return the minor version number.
|
|
||||||
* `patch(v)`: Return the patch version number.
|
|
||||||
* `intersects(r1, r2, loose)`: Return true if the two supplied ranges
|
|
||||||
or comparators intersect.
|
|
||||||
* `parse(v)`: Attempt to parse a string as a semantic version, returning either
|
|
||||||
a `SemVer` object or `null`.
|
|
||||||
|
|
||||||
### Comparison
|
|
||||||
|
|
||||||
* `gt(v1, v2)`: `v1 > v2`
|
|
||||||
* `gte(v1, v2)`: `v1 >= v2`
|
|
||||||
* `lt(v1, v2)`: `v1 < v2`
|
|
||||||
* `lte(v1, v2)`: `v1 <= v2`
|
|
||||||
* `eq(v1, v2)`: `v1 == v2` This is true if they're logically equivalent,
|
|
||||||
even if they're not the exact same string. You already know how to
|
|
||||||
compare strings.
|
|
||||||
* `neq(v1, v2)`: `v1 != v2` The opposite of `eq`.
|
|
||||||
* `cmp(v1, comparator, v2)`: Pass in a comparison string, and it'll call
|
|
||||||
the corresponding function above. `"==="` and `"!=="` do simple
|
|
||||||
string comparison, but are included for completeness. Throws if an
|
|
||||||
invalid comparison string is provided.
|
|
||||||
* `compare(v1, v2)`: Return `0` if `v1 == v2`, or `1` if `v1` is greater, or `-1` if
|
|
||||||
`v2` is greater. Sorts in ascending order if passed to `Array.sort()`.
|
|
||||||
* `rcompare(v1, v2)`: The reverse of compare. Sorts an array of versions
|
|
||||||
in descending order when passed to `Array.sort()`.
|
|
||||||
* `compareBuild(v1, v2)`: The same as `compare` but considers `build` when two versions
|
|
||||||
are equal. Sorts in ascending order if passed to `Array.sort()`.
|
|
||||||
`v2` is greater. Sorts in ascending order if passed to `Array.sort()`.
|
|
||||||
* `diff(v1, v2)`: Returns difference between two versions by the release type
|
|
||||||
(`major`, `premajor`, `minor`, `preminor`, `patch`, `prepatch`, or `prerelease`),
|
|
||||||
or null if the versions are the same.
|
|
||||||
|
|
||||||
### Comparators
|
|
||||||
|
|
||||||
* `intersects(comparator)`: Return true if the comparators intersect
|
|
||||||
|
|
||||||
### Ranges
|
|
||||||
|
|
||||||
* `validRange(range)`: Return the valid range or null if it's not valid
|
|
||||||
* `satisfies(version, range)`: Return true if the version satisfies the
|
|
||||||
range.
|
|
||||||
* `maxSatisfying(versions, range)`: Return the highest version in the list
|
|
||||||
that satisfies the range, or `null` if none of them do.
|
|
||||||
* `minSatisfying(versions, range)`: Return the lowest version in the list
|
|
||||||
that satisfies the range, or `null` if none of them do.
|
|
||||||
* `minVersion(range)`: Return the lowest version that can possibly match
|
|
||||||
the given range.
|
|
||||||
* `gtr(version, range)`: Return `true` if version is greater than all the
|
|
||||||
versions possible in the range.
|
|
||||||
* `ltr(version, range)`: Return `true` if version is less than all the
|
|
||||||
versions possible in the range.
|
|
||||||
* `outside(version, range, hilo)`: Return true if the version is outside
|
|
||||||
the bounds of the range in either the high or low direction. The
|
|
||||||
`hilo` argument must be either the string `'>'` or `'<'`. (This is
|
|
||||||
the function called by `gtr` and `ltr`.)
|
|
||||||
* `intersects(range)`: Return true if any of the ranges comparators intersect
|
|
||||||
|
|
||||||
Note that, since ranges may be non-contiguous, a version might not be
|
|
||||||
greater than a range, less than a range, *or* satisfy a range! For
|
|
||||||
example, the range `1.2 <1.2.9 || >2.0.0` would have a hole from `1.2.9`
|
|
||||||
until `2.0.0`, so the version `1.2.10` would not be greater than the
|
|
||||||
range (because `2.0.1` satisfies, which is higher), nor less than the
|
|
||||||
range (since `1.2.8` satisfies, which is lower), and it also does not
|
|
||||||
satisfy the range.
|
|
||||||
|
|
||||||
If you want to know if a version satisfies or does not satisfy a
|
|
||||||
range, use the `satisfies(version, range)` function.
|
|
||||||
|
|
||||||
### Coercion
|
|
||||||
|
|
||||||
* `coerce(version)`: Coerces a string to semver if possible
|
|
||||||
|
|
||||||
This aims to provide a very forgiving translation of a non-semver
|
|
||||||
string to semver. It looks for the first digit in a string, and
|
|
||||||
consumes all remaining characters which satisfy at least a partial semver
|
|
||||||
(e.g., `1`, `1.2`, `1.2.3`) up to the max permitted length (256 characters).
|
|
||||||
Longer versions are simply truncated (`4.6.3.9.2-alpha2` becomes `4.6.3`).
|
|
||||||
All surrounding text is simply ignored (`v3.4 replaces v3.3.1` becomes `3.4.0`).
|
|
||||||
Only text which lacks digits will fail coercion (`version one` is not valid).
|
|
||||||
The maximum length for any semver component considered for coercion is 16 characters;
|
|
||||||
longer components will be ignored (`10000000000000000.4.7.4` becomes `4.7.4`).
|
|
||||||
The maximum value for any semver component is `Integer.MAX_SAFE_INTEGER || (2**53 - 1)`;
|
|
||||||
higher value components are invalid (`9999999999999999.4.7.4` is likely invalid).
|
|
||||||
|
|
||||||
### Clean
|
|
||||||
|
|
||||||
* `clean(version)`: Clean a string to be a valid semver if possible
|
|
||||||
|
|
||||||
This will return a cleaned and trimmed semver version. If the provided version is not valid a null will be returned. This does not work for ranges.
|
|
||||||
|
|
||||||
ex.
|
|
||||||
* `s.clean(' = v 2.1.5foo')`: `null`
|
|
||||||
* `s.clean(' = v 2.1.5foo', { loose: true })`: `'2.1.5-foo'`
|
|
||||||
* `s.clean(' = v 2.1.5-foo')`: `null`
|
|
||||||
* `s.clean(' = v 2.1.5-foo', { loose: true })`: `'2.1.5-foo'`
|
|
||||||
* `s.clean('=v2.1.5')`: `'2.1.5'`
|
|
||||||
* `s.clean(' =v2.1.5')`: `2.1.5`
|
|
||||||
* `s.clean(' 2.1.5 ')`: `'2.1.5'`
|
|
||||||
* `s.clean('~1.0.0')`: `null`
|
|
||||||
|
|
@ -1,160 +0,0 @@
|
||||||
#!/usr/bin/env node
|
|
||||||
// Standalone semver comparison program.
|
|
||||||
// Exits successfully and prints matching version(s) if
|
|
||||||
// any supplied version is valid and passes all tests.
|
|
||||||
|
|
||||||
var argv = process.argv.slice(2)
|
|
||||||
|
|
||||||
var versions = []
|
|
||||||
|
|
||||||
var range = []
|
|
||||||
|
|
||||||
var inc = null
|
|
||||||
|
|
||||||
var version = require('../package.json').version
|
|
||||||
|
|
||||||
var loose = false
|
|
||||||
|
|
||||||
var includePrerelease = false
|
|
||||||
|
|
||||||
var coerce = false
|
|
||||||
|
|
||||||
var identifier
|
|
||||||
|
|
||||||
var semver = require('../semver')
|
|
||||||
|
|
||||||
var reverse = false
|
|
||||||
|
|
||||||
var options = {}
|
|
||||||
|
|
||||||
main()
|
|
||||||
|
|
||||||
function main () {
|
|
||||||
if (!argv.length) return help()
|
|
||||||
while (argv.length) {
|
|
||||||
var a = argv.shift()
|
|
||||||
var indexOfEqualSign = a.indexOf('=')
|
|
||||||
if (indexOfEqualSign !== -1) {
|
|
||||||
a = a.slice(0, indexOfEqualSign)
|
|
||||||
argv.unshift(a.slice(indexOfEqualSign + 1))
|
|
||||||
}
|
|
||||||
switch (a) {
|
|
||||||
case '-rv': case '-rev': case '--rev': case '--reverse':
|
|
||||||
reverse = true
|
|
||||||
break
|
|
||||||
case '-l': case '--loose':
|
|
||||||
loose = true
|
|
||||||
break
|
|
||||||
case '-p': case '--include-prerelease':
|
|
||||||
includePrerelease = true
|
|
||||||
break
|
|
||||||
case '-v': case '--version':
|
|
||||||
versions.push(argv.shift())
|
|
||||||
break
|
|
||||||
case '-i': case '--inc': case '--increment':
|
|
||||||
switch (argv[0]) {
|
|
||||||
case 'major': case 'minor': case 'patch': case 'prerelease':
|
|
||||||
case 'premajor': case 'preminor': case 'prepatch':
|
|
||||||
inc = argv.shift()
|
|
||||||
break
|
|
||||||
default:
|
|
||||||
inc = 'patch'
|
|
||||||
break
|
|
||||||
}
|
|
||||||
break
|
|
||||||
case '--preid':
|
|
||||||
identifier = argv.shift()
|
|
||||||
break
|
|
||||||
case '-r': case '--range':
|
|
||||||
range.push(argv.shift())
|
|
||||||
break
|
|
||||||
case '-c': case '--coerce':
|
|
||||||
coerce = true
|
|
||||||
break
|
|
||||||
case '-h': case '--help': case '-?':
|
|
||||||
return help()
|
|
||||||
default:
|
|
||||||
versions.push(a)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var options = { loose: loose, includePrerelease: includePrerelease }
|
|
||||||
|
|
||||||
versions = versions.map(function (v) {
|
|
||||||
return coerce ? (semver.coerce(v) || { version: v }).version : v
|
|
||||||
}).filter(function (v) {
|
|
||||||
return semver.valid(v)
|
|
||||||
})
|
|
||||||
if (!versions.length) return fail()
|
|
||||||
if (inc && (versions.length !== 1 || range.length)) { return failInc() }
|
|
||||||
|
|
||||||
for (var i = 0, l = range.length; i < l; i++) {
|
|
||||||
versions = versions.filter(function (v) {
|
|
||||||
return semver.satisfies(v, range[i], options)
|
|
||||||
})
|
|
||||||
if (!versions.length) return fail()
|
|
||||||
}
|
|
||||||
return success(versions)
|
|
||||||
}
|
|
||||||
|
|
||||||
function failInc () {
|
|
||||||
console.error('--inc can only be used on a single version with no range')
|
|
||||||
fail()
|
|
||||||
}
|
|
||||||
|
|
||||||
function fail () { process.exit(1) }
|
|
||||||
|
|
||||||
function success () {
|
|
||||||
var compare = reverse ? 'rcompare' : 'compare'
|
|
||||||
versions.sort(function (a, b) {
|
|
||||||
return semver[compare](a, b, options)
|
|
||||||
}).map(function (v) {
|
|
||||||
return semver.clean(v, options)
|
|
||||||
}).map(function (v) {
|
|
||||||
return inc ? semver.inc(v, inc, options, identifier) : v
|
|
||||||
}).forEach(function (v, i, _) { console.log(v) })
|
|
||||||
}
|
|
||||||
|
|
||||||
function help () {
|
|
||||||
console.log(['SemVer ' + version,
|
|
||||||
'',
|
|
||||||
'A JavaScript implementation of the https://semver.org/ specification',
|
|
||||||
'Copyright Isaac Z. Schlueter',
|
|
||||||
'',
|
|
||||||
'Usage: semver [options] <version> [<version> [...]]',
|
|
||||||
'Prints valid versions sorted by SemVer precedence',
|
|
||||||
'',
|
|
||||||
'Options:',
|
|
||||||
'-r --range <range>',
|
|
||||||
' Print versions that match the specified range.',
|
|
||||||
'',
|
|
||||||
'-i --increment [<level>]',
|
|
||||||
' Increment a version by the specified level. Level can',
|
|
||||||
' be one of: major, minor, patch, premajor, preminor,',
|
|
||||||
" prepatch, or prerelease. Default level is 'patch'.",
|
|
||||||
' Only one version may be specified.',
|
|
||||||
'',
|
|
||||||
'--preid <identifier>',
|
|
||||||
' Identifier to be used to prefix premajor, preminor,',
|
|
||||||
' prepatch or prerelease version increments.',
|
|
||||||
'',
|
|
||||||
'-l --loose',
|
|
||||||
' Interpret versions and ranges loosely',
|
|
||||||
'',
|
|
||||||
'-p --include-prerelease',
|
|
||||||
' Always include prerelease versions in range matching',
|
|
||||||
'',
|
|
||||||
'-c --coerce',
|
|
||||||
' Coerce a string into SemVer if possible',
|
|
||||||
' (does not imply --loose)',
|
|
||||||
'',
|
|
||||||
'Program exits successfully if any valid version satisfies',
|
|
||||||
'all supplied ranges, and prints all satisfying versions.',
|
|
||||||
'',
|
|
||||||
'If no satisfying versions are found, then exits failure.',
|
|
||||||
'',
|
|
||||||
'Versions are printed in ascending order, so supplying',
|
|
||||||
'multiple versions to the utility will just sort them.'
|
|
||||||
].join('\n'))
|
|
||||||
}
|
|
||||||
|
|
@ -1,62 +0,0 @@
|
||||||
{
|
|
||||||
"_from": "semver@^6.1.1",
|
|
||||||
"_id": "semver@6.1.2",
|
|
||||||
"_inBundle": false,
|
|
||||||
"_integrity": "sha512-z4PqiCpomGtWj8633oeAdXm1Kn1W++3T8epkZYnwiVgIYIJ0QHszhInYSJTYxebByQH7KVCEAn8R9duzZW2PhQ==",
|
|
||||||
"_location": "/semver",
|
|
||||||
"_phantomChildren": {},
|
|
||||||
"_requested": {
|
|
||||||
"type": "range",
|
|
||||||
"registry": true,
|
|
||||||
"raw": "semver@^6.1.1",
|
|
||||||
"name": "semver",
|
|
||||||
"escapedName": "semver",
|
|
||||||
"rawSpec": "^6.1.1",
|
|
||||||
"saveSpec": null,
|
|
||||||
"fetchSpec": "^6.1.1"
|
|
||||||
},
|
|
||||||
"_requiredBy": [
|
|
||||||
"/",
|
|
||||||
"/@actions/tool-cache",
|
|
||||||
"/istanbul-lib-instrument"
|
|
||||||
],
|
|
||||||
"_resolved": "https://registry.npmjs.org/semver/-/semver-6.1.2.tgz",
|
|
||||||
"_shasum": "079960381376a3db62eb2edc8a3bfb10c7cfe318",
|
|
||||||
"_spec": "semver@^6.1.1",
|
|
||||||
"_where": "C:\\Users\\Administrator\\Documents\\setup-node",
|
|
||||||
"bin": {
|
|
||||||
"semver": "./bin/semver"
|
|
||||||
},
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/npm/node-semver/issues"
|
|
||||||
},
|
|
||||||
"bundleDependencies": false,
|
|
||||||
"deprecated": false,
|
|
||||||
"description": "The semantic version parser used by npm.",
|
|
||||||
"devDependencies": {
|
|
||||||
"tap": "^14.1.6"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"bin",
|
|
||||||
"range.bnf",
|
|
||||||
"semver.js"
|
|
||||||
],
|
|
||||||
"homepage": "https://github.com/npm/node-semver#readme",
|
|
||||||
"license": "ISC",
|
|
||||||
"main": "semver.js",
|
|
||||||
"name": "semver",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/npm/node-semver.git"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"postpublish": "git push origin --follow-tags",
|
|
||||||
"postversion": "npm publish",
|
|
||||||
"preversion": "npm test",
|
|
||||||
"test": "tap"
|
|
||||||
},
|
|
||||||
"tap": {
|
|
||||||
"check-coverage": true
|
|
||||||
},
|
|
||||||
"version": "6.1.2"
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
range-set ::= range ( logical-or range ) *
|
|
||||||
logical-or ::= ( ' ' ) * '||' ( ' ' ) *
|
|
||||||
range ::= hyphen | simple ( ' ' simple ) * | ''
|
|
||||||
hyphen ::= partial ' - ' partial
|
|
||||||
simple ::= primitive | partial | tilde | caret
|
|
||||||
primitive ::= ( '<' | '>' | '>=' | '<=' | '=' ) partial
|
|
||||||
partial ::= xr ( '.' xr ( '.' xr qualifier ? )? )?
|
|
||||||
xr ::= 'x' | 'X' | '*' | nr
|
|
||||||
nr ::= '0' | [1-9] ( [0-9] ) *
|
|
||||||
tilde ::= '~' partial
|
|
||||||
caret ::= '^' partial
|
|
||||||
qualifier ::= ( '-' pre )? ( '+' build )?
|
|
||||||
pre ::= parts
|
|
||||||
build ::= parts
|
|
||||||
parts ::= part ( '.' part ) *
|
|
||||||
part ::= nr | [-0-9A-Za-z]+
|
|
||||||
|
|
@ -1,1552 +0,0 @@
|
||||||
exports = module.exports = SemVer
|
|
||||||
|
|
||||||
var debug
|
|
||||||
/* istanbul ignore next */
|
|
||||||
if (typeof process === 'object' &&
|
|
||||||
process.env &&
|
|
||||||
process.env.NODE_DEBUG &&
|
|
||||||
/\bsemver\b/i.test(process.env.NODE_DEBUG)) {
|
|
||||||
debug = function () {
|
|
||||||
var args = Array.prototype.slice.call(arguments, 0)
|
|
||||||
args.unshift('SEMVER')
|
|
||||||
console.log.apply(console, args)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
debug = function () {}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Note: this is the semver.org version of the spec that it implements
|
|
||||||
// Not necessarily the package version of this code.
|
|
||||||
exports.SEMVER_SPEC_VERSION = '2.0.0'
|
|
||||||
|
|
||||||
var MAX_LENGTH = 256
|
|
||||||
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
|
|
||||||
/* istanbul ignore next */ 9007199254740991
|
|
||||||
|
|
||||||
// Max safe segment length for coercion.
|
|
||||||
var MAX_SAFE_COMPONENT_LENGTH = 16
|
|
||||||
|
|
||||||
// The actual regexps go on exports.re
|
|
||||||
var re = exports.re = []
|
|
||||||
var src = exports.src = []
|
|
||||||
var R = 0
|
|
||||||
|
|
||||||
// The following Regular Expressions can be used for tokenizing,
|
|
||||||
// validating, and parsing SemVer version strings.
|
|
||||||
|
|
||||||
// ## Numeric Identifier
|
|
||||||
// A single `0`, or a non-zero digit followed by zero or more digits.
|
|
||||||
|
|
||||||
var NUMERICIDENTIFIER = R++
|
|
||||||
src[NUMERICIDENTIFIER] = '0|[1-9]\\d*'
|
|
||||||
var NUMERICIDENTIFIERLOOSE = R++
|
|
||||||
src[NUMERICIDENTIFIERLOOSE] = '[0-9]+'
|
|
||||||
|
|
||||||
// ## Non-numeric Identifier
|
|
||||||
// Zero or more digits, followed by a letter or hyphen, and then zero or
|
|
||||||
// more letters, digits, or hyphens.
|
|
||||||
|
|
||||||
var NONNUMERICIDENTIFIER = R++
|
|
||||||
src[NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*'
|
|
||||||
|
|
||||||
// ## Main Version
|
|
||||||
// Three dot-separated numeric identifiers.
|
|
||||||
|
|
||||||
var MAINVERSION = R++
|
|
||||||
src[MAINVERSION] = '(' + src[NUMERICIDENTIFIER] + ')\\.' +
|
|
||||||
'(' + src[NUMERICIDENTIFIER] + ')\\.' +
|
|
||||||
'(' + src[NUMERICIDENTIFIER] + ')'
|
|
||||||
|
|
||||||
var MAINVERSIONLOOSE = R++
|
|
||||||
src[MAINVERSIONLOOSE] = '(' + src[NUMERICIDENTIFIERLOOSE] + ')\\.' +
|
|
||||||
'(' + src[NUMERICIDENTIFIERLOOSE] + ')\\.' +
|
|
||||||
'(' + src[NUMERICIDENTIFIERLOOSE] + ')'
|
|
||||||
|
|
||||||
// ## Pre-release Version Identifier
|
|
||||||
// A numeric identifier, or a non-numeric identifier.
|
|
||||||
|
|
||||||
var PRERELEASEIDENTIFIER = R++
|
|
||||||
src[PRERELEASEIDENTIFIER] = '(?:' + src[NUMERICIDENTIFIER] +
|
|
||||||
'|' + src[NONNUMERICIDENTIFIER] + ')'
|
|
||||||
|
|
||||||
var PRERELEASEIDENTIFIERLOOSE = R++
|
|
||||||
src[PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[NUMERICIDENTIFIERLOOSE] +
|
|
||||||
'|' + src[NONNUMERICIDENTIFIER] + ')'
|
|
||||||
|
|
||||||
// ## Pre-release Version
|
|
||||||
// Hyphen, followed by one or more dot-separated pre-release version
|
|
||||||
// identifiers.
|
|
||||||
|
|
||||||
var PRERELEASE = R++
|
|
||||||
src[PRERELEASE] = '(?:-(' + src[PRERELEASEIDENTIFIER] +
|
|
||||||
'(?:\\.' + src[PRERELEASEIDENTIFIER] + ')*))'
|
|
||||||
|
|
||||||
var PRERELEASELOOSE = R++
|
|
||||||
src[PRERELEASELOOSE] = '(?:-?(' + src[PRERELEASEIDENTIFIERLOOSE] +
|
|
||||||
'(?:\\.' + src[PRERELEASEIDENTIFIERLOOSE] + ')*))'
|
|
||||||
|
|
||||||
// ## Build Metadata Identifier
|
|
||||||
// Any combination of digits, letters, or hyphens.
|
|
||||||
|
|
||||||
var BUILDIDENTIFIER = R++
|
|
||||||
src[BUILDIDENTIFIER] = '[0-9A-Za-z-]+'
|
|
||||||
|
|
||||||
// ## Build Metadata
|
|
||||||
// Plus sign, followed by one or more period-separated build metadata
|
|
||||||
// identifiers.
|
|
||||||
|
|
||||||
var BUILD = R++
|
|
||||||
src[BUILD] = '(?:\\+(' + src[BUILDIDENTIFIER] +
|
|
||||||
'(?:\\.' + src[BUILDIDENTIFIER] + ')*))'
|
|
||||||
|
|
||||||
// ## Full Version String
|
|
||||||
// A main version, followed optionally by a pre-release version and
|
|
||||||
// build metadata.
|
|
||||||
|
|
||||||
// Note that the only major, minor, patch, and pre-release sections of
|
|
||||||
// the version string are capturing groups. The build metadata is not a
|
|
||||||
// capturing group, because it should not ever be used in version
|
|
||||||
// comparison.
|
|
||||||
|
|
||||||
var FULL = R++
|
|
||||||
var FULLPLAIN = 'v?' + src[MAINVERSION] +
|
|
||||||
src[PRERELEASE] + '?' +
|
|
||||||
src[BUILD] + '?'
|
|
||||||
|
|
||||||
src[FULL] = '^' + FULLPLAIN + '$'
|
|
||||||
|
|
||||||
// like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
|
|
||||||
// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
|
|
||||||
// common in the npm registry.
|
|
||||||
var LOOSEPLAIN = '[v=\\s]*' + src[MAINVERSIONLOOSE] +
|
|
||||||
src[PRERELEASELOOSE] + '?' +
|
|
||||||
src[BUILD] + '?'
|
|
||||||
|
|
||||||
var LOOSE = R++
|
|
||||||
src[LOOSE] = '^' + LOOSEPLAIN + '$'
|
|
||||||
|
|
||||||
var GTLT = R++
|
|
||||||
src[GTLT] = '((?:<|>)?=?)'
|
|
||||||
|
|
||||||
// Something like "2.*" or "1.2.x".
|
|
||||||
// Note that "x.x" is a valid xRange identifer, meaning "any version"
|
|
||||||
// Only the first item is strictly required.
|
|
||||||
var XRANGEIDENTIFIERLOOSE = R++
|
|
||||||
src[XRANGEIDENTIFIERLOOSE] = src[NUMERICIDENTIFIERLOOSE] + '|x|X|\\*'
|
|
||||||
var XRANGEIDENTIFIER = R++
|
|
||||||
src[XRANGEIDENTIFIER] = src[NUMERICIDENTIFIER] + '|x|X|\\*'
|
|
||||||
|
|
||||||
var XRANGEPLAIN = R++
|
|
||||||
src[XRANGEPLAIN] = '[v=\\s]*(' + src[XRANGEIDENTIFIER] + ')' +
|
|
||||||
'(?:\\.(' + src[XRANGEIDENTIFIER] + ')' +
|
|
||||||
'(?:\\.(' + src[XRANGEIDENTIFIER] + ')' +
|
|
||||||
'(?:' + src[PRERELEASE] + ')?' +
|
|
||||||
src[BUILD] + '?' +
|
|
||||||
')?)?'
|
|
||||||
|
|
||||||
var XRANGEPLAINLOOSE = R++
|
|
||||||
src[XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[XRANGEIDENTIFIERLOOSE] + ')' +
|
|
||||||
'(?:\\.(' + src[XRANGEIDENTIFIERLOOSE] + ')' +
|
|
||||||
'(?:\\.(' + src[XRANGEIDENTIFIERLOOSE] + ')' +
|
|
||||||
'(?:' + src[PRERELEASELOOSE] + ')?' +
|
|
||||||
src[BUILD] + '?' +
|
|
||||||
')?)?'
|
|
||||||
|
|
||||||
var XRANGE = R++
|
|
||||||
src[XRANGE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAIN] + '$'
|
|
||||||
var XRANGELOOSE = R++
|
|
||||||
src[XRANGELOOSE] = '^' + src[GTLT] + '\\s*' + src[XRANGEPLAINLOOSE] + '$'
|
|
||||||
|
|
||||||
// Coercion.
|
|
||||||
// Extract anything that could conceivably be a part of a valid semver
|
|
||||||
var COERCE = R++
|
|
||||||
src[COERCE] = '(?:^|[^\\d])' +
|
|
||||||
'(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '})' +
|
|
||||||
'(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' +
|
|
||||||
'(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' +
|
|
||||||
'(?:$|[^\\d])'
|
|
||||||
|
|
||||||
// Tilde ranges.
|
|
||||||
// Meaning is "reasonably at or greater than"
|
|
||||||
var LONETILDE = R++
|
|
||||||
src[LONETILDE] = '(?:~>?)'
|
|
||||||
|
|
||||||
var TILDETRIM = R++
|
|
||||||
src[TILDETRIM] = '(\\s*)' + src[LONETILDE] + '\\s+'
|
|
||||||
re[TILDETRIM] = new RegExp(src[TILDETRIM], 'g')
|
|
||||||
var tildeTrimReplace = '$1~'
|
|
||||||
|
|
||||||
var TILDE = R++
|
|
||||||
src[TILDE] = '^' + src[LONETILDE] + src[XRANGEPLAIN] + '$'
|
|
||||||
var TILDELOOSE = R++
|
|
||||||
src[TILDELOOSE] = '^' + src[LONETILDE] + src[XRANGEPLAINLOOSE] + '$'
|
|
||||||
|
|
||||||
// Caret ranges.
|
|
||||||
// Meaning is "at least and backwards compatible with"
|
|
||||||
var LONECARET = R++
|
|
||||||
src[LONECARET] = '(?:\\^)'
|
|
||||||
|
|
||||||
var CARETTRIM = R++
|
|
||||||
src[CARETTRIM] = '(\\s*)' + src[LONECARET] + '\\s+'
|
|
||||||
re[CARETTRIM] = new RegExp(src[CARETTRIM], 'g')
|
|
||||||
var caretTrimReplace = '$1^'
|
|
||||||
|
|
||||||
var CARET = R++
|
|
||||||
src[CARET] = '^' + src[LONECARET] + src[XRANGEPLAIN] + '$'
|
|
||||||
var CARETLOOSE = R++
|
|
||||||
src[CARETLOOSE] = '^' + src[LONECARET] + src[XRANGEPLAINLOOSE] + '$'
|
|
||||||
|
|
||||||
// A simple gt/lt/eq thing, or just "" to indicate "any version"
|
|
||||||
var COMPARATORLOOSE = R++
|
|
||||||
src[COMPARATORLOOSE] = '^' + src[GTLT] + '\\s*(' + LOOSEPLAIN + ')$|^$'
|
|
||||||
var COMPARATOR = R++
|
|
||||||
src[COMPARATOR] = '^' + src[GTLT] + '\\s*(' + FULLPLAIN + ')$|^$'
|
|
||||||
|
|
||||||
// An expression to strip any whitespace between the gtlt and the thing
|
|
||||||
// it modifies, so that `> 1.2.3` ==> `>1.2.3`
|
|
||||||
var COMPARATORTRIM = R++
|
|
||||||
src[COMPARATORTRIM] = '(\\s*)' + src[GTLT] +
|
|
||||||
'\\s*(' + LOOSEPLAIN + '|' + src[XRANGEPLAIN] + ')'
|
|
||||||
|
|
||||||
// this one has to use the /g flag
|
|
||||||
re[COMPARATORTRIM] = new RegExp(src[COMPARATORTRIM], 'g')
|
|
||||||
var comparatorTrimReplace = '$1$2$3'
|
|
||||||
|
|
||||||
// Something like `1.2.3 - 1.2.4`
|
|
||||||
// Note that these all use the loose form, because they'll be
|
|
||||||
// checked against either the strict or loose comparator form
|
|
||||||
// later.
|
|
||||||
var HYPHENRANGE = R++
|
|
||||||
src[HYPHENRANGE] = '^\\s*(' + src[XRANGEPLAIN] + ')' +
|
|
||||||
'\\s+-\\s+' +
|
|
||||||
'(' + src[XRANGEPLAIN] + ')' +
|
|
||||||
'\\s*$'
|
|
||||||
|
|
||||||
var HYPHENRANGELOOSE = R++
|
|
||||||
src[HYPHENRANGELOOSE] = '^\\s*(' + src[XRANGEPLAINLOOSE] + ')' +
|
|
||||||
'\\s+-\\s+' +
|
|
||||||
'(' + src[XRANGEPLAINLOOSE] + ')' +
|
|
||||||
'\\s*$'
|
|
||||||
|
|
||||||
// Star ranges basically just allow anything at all.
|
|
||||||
var STAR = R++
|
|
||||||
src[STAR] = '(<|>)?=?\\s*\\*'
|
|
||||||
|
|
||||||
// Compile to actual regexp objects.
|
|
||||||
// All are flag-free, unless they were created above with a flag.
|
|
||||||
for (var i = 0; i < R; i++) {
|
|
||||||
debug(i, src[i])
|
|
||||||
if (!re[i]) {
|
|
||||||
re[i] = new RegExp(src[i])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.parse = parse
|
|
||||||
function parse (version, options) {
|
|
||||||
if (!options || typeof options !== 'object') {
|
|
||||||
options = {
|
|
||||||
loose: !!options,
|
|
||||||
includePrerelease: false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (version instanceof SemVer) {
|
|
||||||
return version
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof version !== 'string') {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
if (version.length > MAX_LENGTH) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
var r = options.loose ? re[LOOSE] : re[FULL]
|
|
||||||
if (!r.test(version)) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
return new SemVer(version, options)
|
|
||||||
} catch (er) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.valid = valid
|
|
||||||
function valid (version, options) {
|
|
||||||
var v = parse(version, options)
|
|
||||||
return v ? v.version : null
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.clean = clean
|
|
||||||
function clean (version, options) {
|
|
||||||
var s = parse(version.trim().replace(/^[=v]+/, ''), options)
|
|
||||||
return s ? s.version : null
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.SemVer = SemVer
|
|
||||||
|
|
||||||
function SemVer (version, options) {
|
|
||||||
if (!options || typeof options !== 'object') {
|
|
||||||
options = {
|
|
||||||
loose: !!options,
|
|
||||||
includePrerelease: false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (version instanceof SemVer) {
|
|
||||||
if (version.loose === options.loose) {
|
|
||||||
return version
|
|
||||||
} else {
|
|
||||||
version = version.version
|
|
||||||
}
|
|
||||||
} else if (typeof version !== 'string') {
|
|
||||||
throw new TypeError('Invalid Version: ' + version)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (version.length > MAX_LENGTH) {
|
|
||||||
throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters')
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(this instanceof SemVer)) {
|
|
||||||
return new SemVer(version, options)
|
|
||||||
}
|
|
||||||
|
|
||||||
debug('SemVer', version, options)
|
|
||||||
this.options = options
|
|
||||||
this.loose = !!options.loose
|
|
||||||
|
|
||||||
var m = version.trim().match(options.loose ? re[LOOSE] : re[FULL])
|
|
||||||
|
|
||||||
if (!m) {
|
|
||||||
throw new TypeError('Invalid Version: ' + version)
|
|
||||||
}
|
|
||||||
|
|
||||||
this.raw = version
|
|
||||||
|
|
||||||
// these are actually numbers
|
|
||||||
this.major = +m[1]
|
|
||||||
this.minor = +m[2]
|
|
||||||
this.patch = +m[3]
|
|
||||||
|
|
||||||
if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
|
|
||||||
throw new TypeError('Invalid major version')
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
|
|
||||||
throw new TypeError('Invalid minor version')
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
|
|
||||||
throw new TypeError('Invalid patch version')
|
|
||||||
}
|
|
||||||
|
|
||||||
// numberify any prerelease numeric ids
|
|
||||||
if (!m[4]) {
|
|
||||||
this.prerelease = []
|
|
||||||
} else {
|
|
||||||
this.prerelease = m[4].split('.').map(function (id) {
|
|
||||||
if (/^[0-9]+$/.test(id)) {
|
|
||||||
var num = +id
|
|
||||||
if (num >= 0 && num < MAX_SAFE_INTEGER) {
|
|
||||||
return num
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return id
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
this.build = m[5] ? m[5].split('.') : []
|
|
||||||
this.format()
|
|
||||||
}
|
|
||||||
|
|
||||||
SemVer.prototype.format = function () {
|
|
||||||
this.version = this.major + '.' + this.minor + '.' + this.patch
|
|
||||||
if (this.prerelease.length) {
|
|
||||||
this.version += '-' + this.prerelease.join('.')
|
|
||||||
}
|
|
||||||
return this.version
|
|
||||||
}
|
|
||||||
|
|
||||||
SemVer.prototype.toString = function () {
|
|
||||||
return this.version
|
|
||||||
}
|
|
||||||
|
|
||||||
SemVer.prototype.compare = function (other) {
|
|
||||||
debug('SemVer.compare', this.version, this.options, other)
|
|
||||||
if (!(other instanceof SemVer)) {
|
|
||||||
other = new SemVer(other, this.options)
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.compareMain(other) || this.comparePre(other)
|
|
||||||
}
|
|
||||||
|
|
||||||
SemVer.prototype.compareMain = function (other) {
|
|
||||||
if (!(other instanceof SemVer)) {
|
|
||||||
other = new SemVer(other, this.options)
|
|
||||||
}
|
|
||||||
|
|
||||||
return compareIdentifiers(this.major, other.major) ||
|
|
||||||
compareIdentifiers(this.minor, other.minor) ||
|
|
||||||
compareIdentifiers(this.patch, other.patch)
|
|
||||||
}
|
|
||||||
|
|
||||||
SemVer.prototype.comparePre = function (other) {
|
|
||||||
if (!(other instanceof SemVer)) {
|
|
||||||
other = new SemVer(other, this.options)
|
|
||||||
}
|
|
||||||
|
|
||||||
// NOT having a prerelease is > having one
|
|
||||||
if (this.prerelease.length && !other.prerelease.length) {
|
|
||||||
return -1
|
|
||||||
} else if (!this.prerelease.length && other.prerelease.length) {
|
|
||||||
return 1
|
|
||||||
} else if (!this.prerelease.length && !other.prerelease.length) {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
var i = 0
|
|
||||||
do {
|
|
||||||
var a = this.prerelease[i]
|
|
||||||
var b = other.prerelease[i]
|
|
||||||
debug('prerelease compare', i, a, b)
|
|
||||||
if (a === undefined && b === undefined) {
|
|
||||||
return 0
|
|
||||||
} else if (b === undefined) {
|
|
||||||
return 1
|
|
||||||
} else if (a === undefined) {
|
|
||||||
return -1
|
|
||||||
} else if (a === b) {
|
|
||||||
continue
|
|
||||||
} else {
|
|
||||||
return compareIdentifiers(a, b)
|
|
||||||
}
|
|
||||||
} while (++i)
|
|
||||||
}
|
|
||||||
|
|
||||||
SemVer.prototype.compareBuild = function (other) {
|
|
||||||
if (!(other instanceof SemVer)) {
|
|
||||||
other = new SemVer(other, this.options)
|
|
||||||
}
|
|
||||||
|
|
||||||
var i = 0
|
|
||||||
do {
|
|
||||||
var a = this.build[i]
|
|
||||||
var b = other.build[i]
|
|
||||||
debug('prerelease compare', i, a, b)
|
|
||||||
if (a === undefined && b === undefined) {
|
|
||||||
return 0
|
|
||||||
} else if (b === undefined) {
|
|
||||||
return 1
|
|
||||||
} else if (a === undefined) {
|
|
||||||
return -1
|
|
||||||
} else if (a === b) {
|
|
||||||
continue
|
|
||||||
} else {
|
|
||||||
return compareIdentifiers(a, b)
|
|
||||||
}
|
|
||||||
} while (++i)
|
|
||||||
}
|
|
||||||
|
|
||||||
// preminor will bump the version up to the next minor release, and immediately
|
|
||||||
// down to pre-release. premajor and prepatch work the same way.
|
|
||||||
SemVer.prototype.inc = function (release, identifier) {
|
|
||||||
switch (release) {
|
|
||||||
case 'premajor':
|
|
||||||
this.prerelease.length = 0
|
|
||||||
this.patch = 0
|
|
||||||
this.minor = 0
|
|
||||||
this.major++
|
|
||||||
this.inc('pre', identifier)
|
|
||||||
break
|
|
||||||
case 'preminor':
|
|
||||||
this.prerelease.length = 0
|
|
||||||
this.patch = 0
|
|
||||||
this.minor++
|
|
||||||
this.inc('pre', identifier)
|
|
||||||
break
|
|
||||||
case 'prepatch':
|
|
||||||
// If this is already a prerelease, it will bump to the next version
|
|
||||||
// drop any prereleases that might already exist, since they are not
|
|
||||||
// relevant at this point.
|
|
||||||
this.prerelease.length = 0
|
|
||||||
this.inc('patch', identifier)
|
|
||||||
this.inc('pre', identifier)
|
|
||||||
break
|
|
||||||
// If the input is a non-prerelease version, this acts the same as
|
|
||||||
// prepatch.
|
|
||||||
case 'prerelease':
|
|
||||||
if (this.prerelease.length === 0) {
|
|
||||||
this.inc('patch', identifier)
|
|
||||||
}
|
|
||||||
this.inc('pre', identifier)
|
|
||||||
break
|
|
||||||
|
|
||||||
case 'major':
|
|
||||||
// If this is a pre-major version, bump up to the same major version.
|
|
||||||
// Otherwise increment major.
|
|
||||||
// 1.0.0-5 bumps to 1.0.0
|
|
||||||
// 1.1.0 bumps to 2.0.0
|
|
||||||
if (this.minor !== 0 ||
|
|
||||||
this.patch !== 0 ||
|
|
||||||
this.prerelease.length === 0) {
|
|
||||||
this.major++
|
|
||||||
}
|
|
||||||
this.minor = 0
|
|
||||||
this.patch = 0
|
|
||||||
this.prerelease = []
|
|
||||||
break
|
|
||||||
case 'minor':
|
|
||||||
// If this is a pre-minor version, bump up to the same minor version.
|
|
||||||
// Otherwise increment minor.
|
|
||||||
// 1.2.0-5 bumps to 1.2.0
|
|
||||||
// 1.2.1 bumps to 1.3.0
|
|
||||||
if (this.patch !== 0 || this.prerelease.length === 0) {
|
|
||||||
this.minor++
|
|
||||||
}
|
|
||||||
this.patch = 0
|
|
||||||
this.prerelease = []
|
|
||||||
break
|
|
||||||
case 'patch':
|
|
||||||
// If this is not a pre-release version, it will increment the patch.
|
|
||||||
// If it is a pre-release it will bump up to the same patch version.
|
|
||||||
// 1.2.0-5 patches to 1.2.0
|
|
||||||
// 1.2.0 patches to 1.2.1
|
|
||||||
if (this.prerelease.length === 0) {
|
|
||||||
this.patch++
|
|
||||||
}
|
|
||||||
this.prerelease = []
|
|
||||||
break
|
|
||||||
// This probably shouldn't be used publicly.
|
|
||||||
// 1.0.0 "pre" would become 1.0.0-0 which is the wrong direction.
|
|
||||||
case 'pre':
|
|
||||||
if (this.prerelease.length === 0) {
|
|
||||||
this.prerelease = [0]
|
|
||||||
} else {
|
|
||||||
var i = this.prerelease.length
|
|
||||||
while (--i >= 0) {
|
|
||||||
if (typeof this.prerelease[i] === 'number') {
|
|
||||||
this.prerelease[i]++
|
|
||||||
i = -2
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (i === -1) {
|
|
||||||
// didn't increment anything
|
|
||||||
this.prerelease.push(0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (identifier) {
|
|
||||||
// 1.2.0-beta.1 bumps to 1.2.0-beta.2,
|
|
||||||
// 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
|
|
||||||
if (this.prerelease[0] === identifier) {
|
|
||||||
if (isNaN(this.prerelease[1])) {
|
|
||||||
this.prerelease = [identifier, 0]
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.prerelease = [identifier, 0]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw new Error('invalid increment argument: ' + release)
|
|
||||||
}
|
|
||||||
this.format()
|
|
||||||
this.raw = this.version
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.inc = inc
|
|
||||||
function inc (version, release, loose, identifier) {
|
|
||||||
if (typeof (loose) === 'string') {
|
|
||||||
identifier = loose
|
|
||||||
loose = undefined
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
return new SemVer(version, loose).inc(release, identifier).version
|
|
||||||
} catch (er) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.diff = diff
|
|
||||||
function diff (version1, version2) {
|
|
||||||
if (eq(version1, version2)) {
|
|
||||||
return null
|
|
||||||
} else {
|
|
||||||
var v1 = parse(version1)
|
|
||||||
var v2 = parse(version2)
|
|
||||||
var prefix = ''
|
|
||||||
if (v1.prerelease.length || v2.prerelease.length) {
|
|
||||||
prefix = 'pre'
|
|
||||||
var defaultResult = 'prerelease'
|
|
||||||
}
|
|
||||||
for (var key in v1) {
|
|
||||||
if (key === 'major' || key === 'minor' || key === 'patch') {
|
|
||||||
if (v1[key] !== v2[key]) {
|
|
||||||
return prefix + key
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return defaultResult // may be undefined
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.compareIdentifiers = compareIdentifiers
|
|
||||||
|
|
||||||
var numeric = /^[0-9]+$/
|
|
||||||
function compareIdentifiers (a, b) {
|
|
||||||
var anum = numeric.test(a)
|
|
||||||
var bnum = numeric.test(b)
|
|
||||||
|
|
||||||
if (anum && bnum) {
|
|
||||||
a = +a
|
|
||||||
b = +b
|
|
||||||
}
|
|
||||||
|
|
||||||
return a === b ? 0
|
|
||||||
: (anum && !bnum) ? -1
|
|
||||||
: (bnum && !anum) ? 1
|
|
||||||
: a < b ? -1
|
|
||||||
: 1
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.rcompareIdentifiers = rcompareIdentifiers
|
|
||||||
function rcompareIdentifiers (a, b) {
|
|
||||||
return compareIdentifiers(b, a)
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.major = major
|
|
||||||
function major (a, loose) {
|
|
||||||
return new SemVer(a, loose).major
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.minor = minor
|
|
||||||
function minor (a, loose) {
|
|
||||||
return new SemVer(a, loose).minor
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.patch = patch
|
|
||||||
function patch (a, loose) {
|
|
||||||
return new SemVer(a, loose).patch
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.compare = compare
|
|
||||||
function compare (a, b, loose) {
|
|
||||||
return new SemVer(a, loose).compare(new SemVer(b, loose))
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.compareLoose = compareLoose
|
|
||||||
function compareLoose (a, b) {
|
|
||||||
return compare(a, b, true)
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.compareBuild = compareBuild
|
|
||||||
function compareBuild (a, b, loose) {
|
|
||||||
var versionA = new SemVer(a, loose)
|
|
||||||
var versionB = new SemVer(b, loose)
|
|
||||||
return versionA.compare(versionB) || versionA.compareBuild(versionB)
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.rcompare = rcompare
|
|
||||||
function rcompare (a, b, loose) {
|
|
||||||
return compare(b, a, loose)
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.sort = sort
|
|
||||||
function sort (list, loose) {
|
|
||||||
return list.sort(function (a, b) {
|
|
||||||
return exports.compareBuild(a, b, loose)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.rsort = rsort
|
|
||||||
function rsort (list, loose) {
|
|
||||||
return list.sort(function (a, b) {
|
|
||||||
return exports.compareBuild(b, a, loose)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.gt = gt
|
|
||||||
function gt (a, b, loose) {
|
|
||||||
return compare(a, b, loose) > 0
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.lt = lt
|
|
||||||
function lt (a, b, loose) {
|
|
||||||
return compare(a, b, loose) < 0
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.eq = eq
|
|
||||||
function eq (a, b, loose) {
|
|
||||||
return compare(a, b, loose) === 0
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.neq = neq
|
|
||||||
function neq (a, b, loose) {
|
|
||||||
return compare(a, b, loose) !== 0
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.gte = gte
|
|
||||||
function gte (a, b, loose) {
|
|
||||||
return compare(a, b, loose) >= 0
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.lte = lte
|
|
||||||
function lte (a, b, loose) {
|
|
||||||
return compare(a, b, loose) <= 0
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.cmp = cmp
|
|
||||||
function cmp (a, op, b, loose) {
|
|
||||||
switch (op) {
|
|
||||||
case '===':
|
|
||||||
if (typeof a === 'object')
|
|
||||||
a = a.version
|
|
||||||
if (typeof b === 'object')
|
|
||||||
b = b.version
|
|
||||||
return a === b
|
|
||||||
|
|
||||||
case '!==':
|
|
||||||
if (typeof a === 'object')
|
|
||||||
a = a.version
|
|
||||||
if (typeof b === 'object')
|
|
||||||
b = b.version
|
|
||||||
return a !== b
|
|
||||||
|
|
||||||
case '':
|
|
||||||
case '=':
|
|
||||||
case '==':
|
|
||||||
return eq(a, b, loose)
|
|
||||||
|
|
||||||
case '!=':
|
|
||||||
return neq(a, b, loose)
|
|
||||||
|
|
||||||
case '>':
|
|
||||||
return gt(a, b, loose)
|
|
||||||
|
|
||||||
case '>=':
|
|
||||||
return gte(a, b, loose)
|
|
||||||
|
|
||||||
case '<':
|
|
||||||
return lt(a, b, loose)
|
|
||||||
|
|
||||||
case '<=':
|
|
||||||
return lte(a, b, loose)
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw new TypeError('Invalid operator: ' + op)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.Comparator = Comparator
|
|
||||||
function Comparator (comp, options) {
|
|
||||||
if (!options || typeof options !== 'object') {
|
|
||||||
options = {
|
|
||||||
loose: !!options,
|
|
||||||
includePrerelease: false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (comp instanceof Comparator) {
|
|
||||||
if (comp.loose === !!options.loose) {
|
|
||||||
return comp
|
|
||||||
} else {
|
|
||||||
comp = comp.value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(this instanceof Comparator)) {
|
|
||||||
return new Comparator(comp, options)
|
|
||||||
}
|
|
||||||
|
|
||||||
debug('comparator', comp, options)
|
|
||||||
this.options = options
|
|
||||||
this.loose = !!options.loose
|
|
||||||
this.parse(comp)
|
|
||||||
|
|
||||||
if (this.semver === ANY) {
|
|
||||||
this.value = ''
|
|
||||||
} else {
|
|
||||||
this.value = this.operator + this.semver.version
|
|
||||||
}
|
|
||||||
|
|
||||||
debug('comp', this)
|
|
||||||
}
|
|
||||||
|
|
||||||
var ANY = {}
|
|
||||||
Comparator.prototype.parse = function (comp) {
|
|
||||||
var r = this.options.loose ? re[COMPARATORLOOSE] : re[COMPARATOR]
|
|
||||||
var m = comp.match(r)
|
|
||||||
|
|
||||||
if (!m) {
|
|
||||||
throw new TypeError('Invalid comparator: ' + comp)
|
|
||||||
}
|
|
||||||
|
|
||||||
this.operator = m[1] !== undefined ? m[1] : ''
|
|
||||||
if (this.operator === '=') {
|
|
||||||
this.operator = ''
|
|
||||||
}
|
|
||||||
|
|
||||||
// if it literally is just '>' or '' then allow anything.
|
|
||||||
if (!m[2]) {
|
|
||||||
this.semver = ANY
|
|
||||||
} else {
|
|
||||||
this.semver = new SemVer(m[2], this.options.loose)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Comparator.prototype.toString = function () {
|
|
||||||
return this.value
|
|
||||||
}
|
|
||||||
|
|
||||||
Comparator.prototype.test = function (version) {
|
|
||||||
debug('Comparator.test', version, this.options.loose)
|
|
||||||
|
|
||||||
if (this.semver === ANY || version === ANY) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof version === 'string') {
|
|
||||||
try {
|
|
||||||
version = new SemVer(version, this.options)
|
|
||||||
} catch (er) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return cmp(version, this.operator, this.semver, this.options)
|
|
||||||
}
|
|
||||||
|
|
||||||
Comparator.prototype.intersects = function (comp, options) {
|
|
||||||
if (!(comp instanceof Comparator)) {
|
|
||||||
throw new TypeError('a Comparator is required')
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!options || typeof options !== 'object') {
|
|
||||||
options = {
|
|
||||||
loose: !!options,
|
|
||||||
includePrerelease: false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var rangeTmp
|
|
||||||
|
|
||||||
if (this.operator === '') {
|
|
||||||
if (this.value === '') {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
rangeTmp = new Range(comp.value, options)
|
|
||||||
return satisfies(this.value, rangeTmp, options)
|
|
||||||
} else if (comp.operator === '') {
|
|
||||||
if (comp.value === '') {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
rangeTmp = new Range(this.value, options)
|
|
||||||
return satisfies(comp.semver, rangeTmp, options)
|
|
||||||
}
|
|
||||||
|
|
||||||
var sameDirectionIncreasing =
|
|
||||||
(this.operator === '>=' || this.operator === '>') &&
|
|
||||||
(comp.operator === '>=' || comp.operator === '>')
|
|
||||||
var sameDirectionDecreasing =
|
|
||||||
(this.operator === '<=' || this.operator === '<') &&
|
|
||||||
(comp.operator === '<=' || comp.operator === '<')
|
|
||||||
var sameSemVer = this.semver.version === comp.semver.version
|
|
||||||
var differentDirectionsInclusive =
|
|
||||||
(this.operator === '>=' || this.operator === '<=') &&
|
|
||||||
(comp.operator === '>=' || comp.operator === '<=')
|
|
||||||
var oppositeDirectionsLessThan =
|
|
||||||
cmp(this.semver, '<', comp.semver, options) &&
|
|
||||||
((this.operator === '>=' || this.operator === '>') &&
|
|
||||||
(comp.operator === '<=' || comp.operator === '<'))
|
|
||||||
var oppositeDirectionsGreaterThan =
|
|
||||||
cmp(this.semver, '>', comp.semver, options) &&
|
|
||||||
((this.operator === '<=' || this.operator === '<') &&
|
|
||||||
(comp.operator === '>=' || comp.operator === '>'))
|
|
||||||
|
|
||||||
return sameDirectionIncreasing || sameDirectionDecreasing ||
|
|
||||||
(sameSemVer && differentDirectionsInclusive) ||
|
|
||||||
oppositeDirectionsLessThan || oppositeDirectionsGreaterThan
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.Range = Range
|
|
||||||
function Range (range, options) {
|
|
||||||
if (!options || typeof options !== 'object') {
|
|
||||||
options = {
|
|
||||||
loose: !!options,
|
|
||||||
includePrerelease: false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (range instanceof Range) {
|
|
||||||
if (range.loose === !!options.loose &&
|
|
||||||
range.includePrerelease === !!options.includePrerelease) {
|
|
||||||
return range
|
|
||||||
} else {
|
|
||||||
return new Range(range.raw, options)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (range instanceof Comparator) {
|
|
||||||
return new Range(range.value, options)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(this instanceof Range)) {
|
|
||||||
return new Range(range, options)
|
|
||||||
}
|
|
||||||
|
|
||||||
this.options = options
|
|
||||||
this.loose = !!options.loose
|
|
||||||
this.includePrerelease = !!options.includePrerelease
|
|
||||||
|
|
||||||
// First, split based on boolean or ||
|
|
||||||
this.raw = range
|
|
||||||
this.set = range.split(/\s*\|\|\s*/).map(function (range) {
|
|
||||||
return this.parseRange(range.trim())
|
|
||||||
}, this).filter(function (c) {
|
|
||||||
// throw out any that are not relevant for whatever reason
|
|
||||||
return c.length
|
|
||||||
})
|
|
||||||
|
|
||||||
if (!this.set.length) {
|
|
||||||
throw new TypeError('Invalid SemVer Range: ' + range)
|
|
||||||
}
|
|
||||||
|
|
||||||
this.format()
|
|
||||||
}
|
|
||||||
|
|
||||||
Range.prototype.format = function () {
|
|
||||||
this.range = this.set.map(function (comps) {
|
|
||||||
return comps.join(' ').trim()
|
|
||||||
}).join('||').trim()
|
|
||||||
return this.range
|
|
||||||
}
|
|
||||||
|
|
||||||
Range.prototype.toString = function () {
|
|
||||||
return this.range
|
|
||||||
}
|
|
||||||
|
|
||||||
Range.prototype.parseRange = function (range) {
|
|
||||||
var loose = this.options.loose
|
|
||||||
range = range.trim()
|
|
||||||
// `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
|
|
||||||
var hr = loose ? re[HYPHENRANGELOOSE] : re[HYPHENRANGE]
|
|
||||||
range = range.replace(hr, hyphenReplace)
|
|
||||||
debug('hyphen replace', range)
|
|
||||||
// `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
|
|
||||||
range = range.replace(re[COMPARATORTRIM], comparatorTrimReplace)
|
|
||||||
debug('comparator trim', range, re[COMPARATORTRIM])
|
|
||||||
|
|
||||||
// `~ 1.2.3` => `~1.2.3`
|
|
||||||
range = range.replace(re[TILDETRIM], tildeTrimReplace)
|
|
||||||
|
|
||||||
// `^ 1.2.3` => `^1.2.3`
|
|
||||||
range = range.replace(re[CARETTRIM], caretTrimReplace)
|
|
||||||
|
|
||||||
// normalize spaces
|
|
||||||
range = range.split(/\s+/).join(' ')
|
|
||||||
|
|
||||||
// At this point, the range is completely trimmed and
|
|
||||||
// ready to be split into comparators.
|
|
||||||
|
|
||||||
var compRe = loose ? re[COMPARATORLOOSE] : re[COMPARATOR]
|
|
||||||
var set = range.split(' ').map(function (comp) {
|
|
||||||
return parseComparator(comp, this.options)
|
|
||||||
}, this).join(' ').split(/\s+/)
|
|
||||||
if (this.options.loose) {
|
|
||||||
// in loose mode, throw out any that are not valid comparators
|
|
||||||
set = set.filter(function (comp) {
|
|
||||||
return !!comp.match(compRe)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
set = set.map(function (comp) {
|
|
||||||
return new Comparator(comp, this.options)
|
|
||||||
}, this)
|
|
||||||
|
|
||||||
return set
|
|
||||||
}
|
|
||||||
|
|
||||||
Range.prototype.intersects = function (range, options) {
|
|
||||||
if (!(range instanceof Range)) {
|
|
||||||
throw new TypeError('a Range is required')
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.set.some(function (thisComparators) {
|
|
||||||
return (
|
|
||||||
isSatisfiable(thisComparators, options) &&
|
|
||||||
range.set.some(function (rangeComparators) {
|
|
||||||
return (
|
|
||||||
isSatisfiable(rangeComparators, options) &&
|
|
||||||
thisComparators.every(function (thisComparator) {
|
|
||||||
return rangeComparators.every(function (rangeComparator) {
|
|
||||||
return thisComparator.intersects(rangeComparator, options)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
)
|
|
||||||
})
|
|
||||||
)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// take a set of comparators and determine whether there
|
|
||||||
// exists a version which can satisfy it
|
|
||||||
function isSatisfiable (comparators, options) {
|
|
||||||
var result = true
|
|
||||||
var remainingComparators = comparators.slice()
|
|
||||||
var testComparator = remainingComparators.pop()
|
|
||||||
|
|
||||||
while (result && remainingComparators.length) {
|
|
||||||
result = remainingComparators.every(function (otherComparator) {
|
|
||||||
return testComparator.intersects(otherComparator, options)
|
|
||||||
})
|
|
||||||
|
|
||||||
testComparator = remainingComparators.pop()
|
|
||||||
}
|
|
||||||
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mostly just for testing and legacy API reasons
|
|
||||||
exports.toComparators = toComparators
|
|
||||||
function toComparators (range, options) {
|
|
||||||
return new Range(range, options).set.map(function (comp) {
|
|
||||||
return comp.map(function (c) {
|
|
||||||
return c.value
|
|
||||||
}).join(' ').trim().split(' ')
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// comprised of xranges, tildes, stars, and gtlt's at this point.
|
|
||||||
// already replaced the hyphen ranges
|
|
||||||
// turn into a set of JUST comparators.
|
|
||||||
function parseComparator (comp, options) {
|
|
||||||
debug('comp', comp, options)
|
|
||||||
comp = replaceCarets(comp, options)
|
|
||||||
debug('caret', comp)
|
|
||||||
comp = replaceTildes(comp, options)
|
|
||||||
debug('tildes', comp)
|
|
||||||
comp = replaceXRanges(comp, options)
|
|
||||||
debug('xrange', comp)
|
|
||||||
comp = replaceStars(comp, options)
|
|
||||||
debug('stars', comp)
|
|
||||||
return comp
|
|
||||||
}
|
|
||||||
|
|
||||||
function isX (id) {
|
|
||||||
return !id || id.toLowerCase() === 'x' || id === '*'
|
|
||||||
}
|
|
||||||
|
|
||||||
// ~, ~> --> * (any, kinda silly)
|
|
||||||
// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0
|
|
||||||
// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0
|
|
||||||
// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0
|
|
||||||
// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0
|
|
||||||
// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0
|
|
||||||
function replaceTildes (comp, options) {
|
|
||||||
return comp.trim().split(/\s+/).map(function (comp) {
|
|
||||||
return replaceTilde(comp, options)
|
|
||||||
}).join(' ')
|
|
||||||
}
|
|
||||||
|
|
||||||
function replaceTilde (comp, options) {
|
|
||||||
var r = options.loose ? re[TILDELOOSE] : re[TILDE]
|
|
||||||
return comp.replace(r, function (_, M, m, p, pr) {
|
|
||||||
debug('tilde', comp, _, M, m, p, pr)
|
|
||||||
var ret
|
|
||||||
|
|
||||||
if (isX(M)) {
|
|
||||||
ret = ''
|
|
||||||
} else if (isX(m)) {
|
|
||||||
ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0'
|
|
||||||
} else if (isX(p)) {
|
|
||||||
// ~1.2 == >=1.2.0 <1.3.0
|
|
||||||
ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0'
|
|
||||||
} else if (pr) {
|
|
||||||
debug('replaceTilde pr', pr)
|
|
||||||
ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
|
|
||||||
' <' + M + '.' + (+m + 1) + '.0'
|
|
||||||
} else {
|
|
||||||
// ~1.2.3 == >=1.2.3 <1.3.0
|
|
||||||
ret = '>=' + M + '.' + m + '.' + p +
|
|
||||||
' <' + M + '.' + (+m + 1) + '.0'
|
|
||||||
}
|
|
||||||
|
|
||||||
debug('tilde return', ret)
|
|
||||||
return ret
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// ^ --> * (any, kinda silly)
|
|
||||||
// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0
|
|
||||||
// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0
|
|
||||||
// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0
|
|
||||||
// ^1.2.3 --> >=1.2.3 <2.0.0
|
|
||||||
// ^1.2.0 --> >=1.2.0 <2.0.0
|
|
||||||
function replaceCarets (comp, options) {
|
|
||||||
return comp.trim().split(/\s+/).map(function (comp) {
|
|
||||||
return replaceCaret(comp, options)
|
|
||||||
}).join(' ')
|
|
||||||
}
|
|
||||||
|
|
||||||
function replaceCaret (comp, options) {
|
|
||||||
debug('caret', comp, options)
|
|
||||||
var r = options.loose ? re[CARETLOOSE] : re[CARET]
|
|
||||||
return comp.replace(r, function (_, M, m, p, pr) {
|
|
||||||
debug('caret', comp, _, M, m, p, pr)
|
|
||||||
var ret
|
|
||||||
|
|
||||||
if (isX(M)) {
|
|
||||||
ret = ''
|
|
||||||
} else if (isX(m)) {
|
|
||||||
ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0'
|
|
||||||
} else if (isX(p)) {
|
|
||||||
if (M === '0') {
|
|
||||||
ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0'
|
|
||||||
} else {
|
|
||||||
ret = '>=' + M + '.' + m + '.0 <' + (+M + 1) + '.0.0'
|
|
||||||
}
|
|
||||||
} else if (pr) {
|
|
||||||
debug('replaceCaret pr', pr)
|
|
||||||
if (M === '0') {
|
|
||||||
if (m === '0') {
|
|
||||||
ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
|
|
||||||
' <' + M + '.' + m + '.' + (+p + 1)
|
|
||||||
} else {
|
|
||||||
ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
|
|
||||||
' <' + M + '.' + (+m + 1) + '.0'
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
|
|
||||||
' <' + (+M + 1) + '.0.0'
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
debug('no pr')
|
|
||||||
if (M === '0') {
|
|
||||||
if (m === '0') {
|
|
||||||
ret = '>=' + M + '.' + m + '.' + p +
|
|
||||||
' <' + M + '.' + m + '.' + (+p + 1)
|
|
||||||
} else {
|
|
||||||
ret = '>=' + M + '.' + m + '.' + p +
|
|
||||||
' <' + M + '.' + (+m + 1) + '.0'
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ret = '>=' + M + '.' + m + '.' + p +
|
|
||||||
' <' + (+M + 1) + '.0.0'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
debug('caret return', ret)
|
|
||||||
return ret
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function replaceXRanges (comp, options) {
|
|
||||||
debug('replaceXRanges', comp, options)
|
|
||||||
return comp.split(/\s+/).map(function (comp) {
|
|
||||||
return replaceXRange(comp, options)
|
|
||||||
}).join(' ')
|
|
||||||
}
|
|
||||||
|
|
||||||
function replaceXRange (comp, options) {
|
|
||||||
comp = comp.trim()
|
|
||||||
var r = options.loose ? re[XRANGELOOSE] : re[XRANGE]
|
|
||||||
return comp.replace(r, function (ret, gtlt, M, m, p, pr) {
|
|
||||||
debug('xRange', comp, ret, gtlt, M, m, p, pr)
|
|
||||||
var xM = isX(M)
|
|
||||||
var xm = xM || isX(m)
|
|
||||||
var xp = xm || isX(p)
|
|
||||||
var anyX = xp
|
|
||||||
|
|
||||||
if (gtlt === '=' && anyX) {
|
|
||||||
gtlt = ''
|
|
||||||
}
|
|
||||||
|
|
||||||
if (xM) {
|
|
||||||
if (gtlt === '>' || gtlt === '<') {
|
|
||||||
// nothing is allowed
|
|
||||||
ret = '<0.0.0'
|
|
||||||
} else {
|
|
||||||
// nothing is forbidden
|
|
||||||
ret = '*'
|
|
||||||
}
|
|
||||||
} else if (gtlt && anyX) {
|
|
||||||
// we know patch is an x, because we have any x at all.
|
|
||||||
// replace X with 0
|
|
||||||
if (xm) {
|
|
||||||
m = 0
|
|
||||||
}
|
|
||||||
p = 0
|
|
||||||
|
|
||||||
if (gtlt === '>') {
|
|
||||||
// >1 => >=2.0.0
|
|
||||||
// >1.2 => >=1.3.0
|
|
||||||
// >1.2.3 => >= 1.2.4
|
|
||||||
gtlt = '>='
|
|
||||||
if (xm) {
|
|
||||||
M = +M + 1
|
|
||||||
m = 0
|
|
||||||
p = 0
|
|
||||||
} else {
|
|
||||||
m = +m + 1
|
|
||||||
p = 0
|
|
||||||
}
|
|
||||||
} else if (gtlt === '<=') {
|
|
||||||
// <=0.7.x is actually <0.8.0, since any 0.7.x should
|
|
||||||
// pass. Similarly, <=7.x is actually <8.0.0, etc.
|
|
||||||
gtlt = '<'
|
|
||||||
if (xm) {
|
|
||||||
M = +M + 1
|
|
||||||
} else {
|
|
||||||
m = +m + 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = gtlt + M + '.' + m + '.' + p
|
|
||||||
} else if (xm) {
|
|
||||||
ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0'
|
|
||||||
} else if (xp) {
|
|
||||||
ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0'
|
|
||||||
}
|
|
||||||
|
|
||||||
debug('xRange return', ret)
|
|
||||||
|
|
||||||
return ret
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// Because * is AND-ed with everything else in the comparator,
|
|
||||||
// and '' means "any version", just remove the *s entirely.
|
|
||||||
function replaceStars (comp, options) {
|
|
||||||
debug('replaceStars', comp, options)
|
|
||||||
// Looseness is ignored here. star is always as loose as it gets!
|
|
||||||
return comp.trim().replace(re[STAR], '')
|
|
||||||
}
|
|
||||||
|
|
||||||
// This function is passed to string.replace(re[HYPHENRANGE])
|
|
||||||
// M, m, patch, prerelease, build
|
|
||||||
// 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
|
|
||||||
// 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do
|
|
||||||
// 1.2 - 3.4 => >=1.2.0 <3.5.0
|
|
||||||
function hyphenReplace ($0,
|
|
||||||
from, fM, fm, fp, fpr, fb,
|
|
||||||
to, tM, tm, tp, tpr, tb) {
|
|
||||||
if (isX(fM)) {
|
|
||||||
from = ''
|
|
||||||
} else if (isX(fm)) {
|
|
||||||
from = '>=' + fM + '.0.0'
|
|
||||||
} else if (isX(fp)) {
|
|
||||||
from = '>=' + fM + '.' + fm + '.0'
|
|
||||||
} else {
|
|
||||||
from = '>=' + from
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isX(tM)) {
|
|
||||||
to = ''
|
|
||||||
} else if (isX(tm)) {
|
|
||||||
to = '<' + (+tM + 1) + '.0.0'
|
|
||||||
} else if (isX(tp)) {
|
|
||||||
to = '<' + tM + '.' + (+tm + 1) + '.0'
|
|
||||||
} else if (tpr) {
|
|
||||||
to = '<=' + tM + '.' + tm + '.' + tp + '-' + tpr
|
|
||||||
} else {
|
|
||||||
to = '<=' + to
|
|
||||||
}
|
|
||||||
|
|
||||||
return (from + ' ' + to).trim()
|
|
||||||
}
|
|
||||||
|
|
||||||
// if ANY of the sets match ALL of its comparators, then pass
|
|
||||||
Range.prototype.test = function (version) {
|
|
||||||
if (!version) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof version === 'string') {
|
|
||||||
try {
|
|
||||||
version = new SemVer(version, this.options)
|
|
||||||
} catch (er) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var i = 0; i < this.set.length; i++) {
|
|
||||||
if (testSet(this.set[i], version, this.options)) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
function testSet (set, version, options) {
|
|
||||||
for (var i = 0; i < set.length; i++) {
|
|
||||||
if (!set[i].test(version)) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (version.prerelease.length && !options.includePrerelease) {
|
|
||||||
// Find the set of versions that are allowed to have prereleases
|
|
||||||
// For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
|
|
||||||
// That should allow `1.2.3-pr.2` to pass.
|
|
||||||
// However, `1.2.4-alpha.notready` should NOT be allowed,
|
|
||||||
// even though it's within the range set by the comparators.
|
|
||||||
for (i = 0; i < set.length; i++) {
|
|
||||||
debug(set[i].semver)
|
|
||||||
if (set[i].semver === ANY) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if (set[i].semver.prerelease.length > 0) {
|
|
||||||
var allowed = set[i].semver
|
|
||||||
if (allowed.major === version.major &&
|
|
||||||
allowed.minor === version.minor &&
|
|
||||||
allowed.patch === version.patch) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Version has a -pre, but it's not one of the ones we like.
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.satisfies = satisfies
|
|
||||||
function satisfies (version, range, options) {
|
|
||||||
try {
|
|
||||||
range = new Range(range, options)
|
|
||||||
} catch (er) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return range.test(version)
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.maxSatisfying = maxSatisfying
|
|
||||||
function maxSatisfying (versions, range, options) {
|
|
||||||
var max = null
|
|
||||||
var maxSV = null
|
|
||||||
try {
|
|
||||||
var rangeObj = new Range(range, options)
|
|
||||||
} catch (er) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
versions.forEach(function (v) {
|
|
||||||
if (rangeObj.test(v)) {
|
|
||||||
// satisfies(v, range, options)
|
|
||||||
if (!max || maxSV.compare(v) === -1) {
|
|
||||||
// compare(max, v, true)
|
|
||||||
max = v
|
|
||||||
maxSV = new SemVer(max, options)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return max
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.minSatisfying = minSatisfying
|
|
||||||
function minSatisfying (versions, range, options) {
|
|
||||||
var min = null
|
|
||||||
var minSV = null
|
|
||||||
try {
|
|
||||||
var rangeObj = new Range(range, options)
|
|
||||||
} catch (er) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
versions.forEach(function (v) {
|
|
||||||
if (rangeObj.test(v)) {
|
|
||||||
// satisfies(v, range, options)
|
|
||||||
if (!min || minSV.compare(v) === 1) {
|
|
||||||
// compare(min, v, true)
|
|
||||||
min = v
|
|
||||||
minSV = new SemVer(min, options)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return min
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.minVersion = minVersion
|
|
||||||
function minVersion (range, loose) {
|
|
||||||
range = new Range(range, loose)
|
|
||||||
|
|
||||||
var minver = new SemVer('0.0.0')
|
|
||||||
if (range.test(minver)) {
|
|
||||||
return minver
|
|
||||||
}
|
|
||||||
|
|
||||||
minver = new SemVer('0.0.0-0')
|
|
||||||
if (range.test(minver)) {
|
|
||||||
return minver
|
|
||||||
}
|
|
||||||
|
|
||||||
minver = null
|
|
||||||
for (var i = 0; i < range.set.length; ++i) {
|
|
||||||
var comparators = range.set[i]
|
|
||||||
|
|
||||||
comparators.forEach(function (comparator) {
|
|
||||||
// Clone to avoid manipulating the comparator's semver object.
|
|
||||||
var compver = new SemVer(comparator.semver.version)
|
|
||||||
switch (comparator.operator) {
|
|
||||||
case '>':
|
|
||||||
if (compver.prerelease.length === 0) {
|
|
||||||
compver.patch++
|
|
||||||
} else {
|
|
||||||
compver.prerelease.push(0)
|
|
||||||
}
|
|
||||||
compver.raw = compver.format()
|
|
||||||
/* fallthrough */
|
|
||||||
case '':
|
|
||||||
case '>=':
|
|
||||||
if (!minver || gt(minver, compver)) {
|
|
||||||
minver = compver
|
|
||||||
}
|
|
||||||
break
|
|
||||||
case '<':
|
|
||||||
case '<=':
|
|
||||||
/* Ignore maximum versions */
|
|
||||||
break
|
|
||||||
/* istanbul ignore next */
|
|
||||||
default:
|
|
||||||
throw new Error('Unexpected operation: ' + comparator.operator)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
if (minver && range.test(minver)) {
|
|
||||||
return minver
|
|
||||||
}
|
|
||||||
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.validRange = validRange
|
|
||||||
function validRange (range, options) {
|
|
||||||
try {
|
|
||||||
// Return '*' instead of '' so that truthiness works.
|
|
||||||
// This will throw if it's invalid anyway
|
|
||||||
return new Range(range, options).range || '*'
|
|
||||||
} catch (er) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Determine if version is less than all the versions possible in the range
|
|
||||||
exports.ltr = ltr
|
|
||||||
function ltr (version, range, options) {
|
|
||||||
return outside(version, range, '<', options)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Determine if version is greater than all the versions possible in the range.
|
|
||||||
exports.gtr = gtr
|
|
||||||
function gtr (version, range, options) {
|
|
||||||
return outside(version, range, '>', options)
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.outside = outside
|
|
||||||
function outside (version, range, hilo, options) {
|
|
||||||
version = new SemVer(version, options)
|
|
||||||
range = new Range(range, options)
|
|
||||||
|
|
||||||
var gtfn, ltefn, ltfn, comp, ecomp
|
|
||||||
switch (hilo) {
|
|
||||||
case '>':
|
|
||||||
gtfn = gt
|
|
||||||
ltefn = lte
|
|
||||||
ltfn = lt
|
|
||||||
comp = '>'
|
|
||||||
ecomp = '>='
|
|
||||||
break
|
|
||||||
case '<':
|
|
||||||
gtfn = lt
|
|
||||||
ltefn = gte
|
|
||||||
ltfn = gt
|
|
||||||
comp = '<'
|
|
||||||
ecomp = '<='
|
|
||||||
break
|
|
||||||
default:
|
|
||||||
throw new TypeError('Must provide a hilo val of "<" or ">"')
|
|
||||||
}
|
|
||||||
|
|
||||||
// If it satisifes the range it is not outside
|
|
||||||
if (satisfies(version, range, options)) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// From now on, variable terms are as if we're in "gtr" mode.
|
|
||||||
// but note that everything is flipped for the "ltr" function.
|
|
||||||
|
|
||||||
for (var i = 0; i < range.set.length; ++i) {
|
|
||||||
var comparators = range.set[i]
|
|
||||||
|
|
||||||
var high = null
|
|
||||||
var low = null
|
|
||||||
|
|
||||||
comparators.forEach(function (comparator) {
|
|
||||||
if (comparator.semver === ANY) {
|
|
||||||
comparator = new Comparator('>=0.0.0')
|
|
||||||
}
|
|
||||||
high = high || comparator
|
|
||||||
low = low || comparator
|
|
||||||
if (gtfn(comparator.semver, high.semver, options)) {
|
|
||||||
high = comparator
|
|
||||||
} else if (ltfn(comparator.semver, low.semver, options)) {
|
|
||||||
low = comparator
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
// If the edge version comparator has a operator then our version
|
|
||||||
// isn't outside it
|
|
||||||
if (high.operator === comp || high.operator === ecomp) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the lowest version comparator has an operator and our version
|
|
||||||
// is less than it then it isn't higher than the range
|
|
||||||
if ((!low.operator || low.operator === comp) &&
|
|
||||||
ltefn(version, low.semver)) {
|
|
||||||
return false
|
|
||||||
} else if (low.operator === ecomp && ltfn(version, low.semver)) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.prerelease = prerelease
|
|
||||||
function prerelease (version, options) {
|
|
||||||
var parsed = parse(version, options)
|
|
||||||
return (parsed && parsed.prerelease.length) ? parsed.prerelease : null
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.intersects = intersects
|
|
||||||
function intersects (r1, r2, options) {
|
|
||||||
r1 = new Range(r1, options)
|
|
||||||
r2 = new Range(r2, options)
|
|
||||||
return r1.intersects(r2)
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.coerce = coerce
|
|
||||||
function coerce (version, options) {
|
|
||||||
if (version instanceof SemVer) {
|
|
||||||
return version
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof version !== 'string') {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
var match = version.match(re[COERCE])
|
|
||||||
|
|
||||||
if (match == null) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
return parse(match[1] +
|
|
||||||
'.' + (match[2] || '0') +
|
|
||||||
'.' + (match[3] || '0'), options)
|
|
||||||
}
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
/.idea
|
|
||||||
/node_modules
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
# Changelog
|
|
||||||
|
|
||||||
- 0.0.4 (2016/01/23)
|
|
||||||
- supported Node v0.12 or later.
|
|
||||||
|
|
||||||
- 0.0.3 (2014/01/20)
|
|
||||||
- fixed package.json
|
|
||||||
|
|
||||||
- 0.0.1 (2012/02/18)
|
|
||||||
- supported Node v0.6.x (0.6.11 or later).
|
|
||||||
|
|
||||||
- 0.0.0 (2012/02/11)
|
|
||||||
- first release.
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
The MIT License (MIT)
|
|
||||||
|
|
||||||
Copyright (c) 2012 Koichi Kobayashi
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
|
||||||
all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
THE SOFTWARE.
|
|
||||||
|
|
@ -1,179 +0,0 @@
|
||||||
# node-tunnel - HTTP/HTTPS Agents for tunneling proxies
|
|
||||||
|
|
||||||
## Example
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var tunnel = require('tunnel');
|
|
||||||
|
|
||||||
var tunnelingAgent = tunnel.httpsOverHttp({
|
|
||||||
proxy: {
|
|
||||||
host: 'localhost',
|
|
||||||
port: 3128
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
var req = https.request({
|
|
||||||
host: 'example.com',
|
|
||||||
port: 443,
|
|
||||||
agent: tunnelingAgent
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
$ npm install tunnel
|
|
||||||
|
|
||||||
## Usages
|
|
||||||
|
|
||||||
### HTTP over HTTP tunneling
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var tunnelingAgent = tunnel.httpOverHttp({
|
|
||||||
maxSockets: poolSize, // Defaults to 5
|
|
||||||
|
|
||||||
proxy: { // Proxy settings
|
|
||||||
host: proxyHost, // Defaults to 'localhost'
|
|
||||||
port: proxyPort, // Defaults to 80
|
|
||||||
localAddress: localAddress, // Local interface if necessary
|
|
||||||
|
|
||||||
// Basic authorization for proxy server if necessary
|
|
||||||
proxyAuth: 'user:password',
|
|
||||||
|
|
||||||
// Header fields for proxy server if necessary
|
|
||||||
headers: {
|
|
||||||
'User-Agent': 'Node'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
var req = http.request({
|
|
||||||
host: 'example.com',
|
|
||||||
port: 80,
|
|
||||||
agent: tunnelingAgent
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
### HTTPS over HTTP tunneling
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var tunnelingAgent = tunnel.httpsOverHttp({
|
|
||||||
maxSockets: poolSize, // Defaults to 5
|
|
||||||
|
|
||||||
// CA for origin server if necessary
|
|
||||||
ca: [ fs.readFileSync('origin-server-ca.pem')],
|
|
||||||
|
|
||||||
// Client certification for origin server if necessary
|
|
||||||
key: fs.readFileSync('origin-server-key.pem'),
|
|
||||||
cert: fs.readFileSync('origin-server-cert.pem'),
|
|
||||||
|
|
||||||
proxy: { // Proxy settings
|
|
||||||
host: proxyHost, // Defaults to 'localhost'
|
|
||||||
port: proxyPort, // Defaults to 80
|
|
||||||
localAddress: localAddress, // Local interface if necessary
|
|
||||||
|
|
||||||
// Basic authorization for proxy server if necessary
|
|
||||||
proxyAuth: 'user:password',
|
|
||||||
|
|
||||||
// Header fields for proxy server if necessary
|
|
||||||
headers: {
|
|
||||||
'User-Agent': 'Node'
|
|
||||||
},
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
var req = https.request({
|
|
||||||
host: 'example.com',
|
|
||||||
port: 443,
|
|
||||||
agent: tunnelingAgent
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
### HTTP over HTTPS tunneling
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var tunnelingAgent = tunnel.httpOverHttps({
|
|
||||||
maxSockets: poolSize, // Defaults to 5
|
|
||||||
|
|
||||||
proxy: { // Proxy settings
|
|
||||||
host: proxyHost, // Defaults to 'localhost'
|
|
||||||
port: proxyPort, // Defaults to 443
|
|
||||||
localAddress: localAddress, // Local interface if necessary
|
|
||||||
|
|
||||||
// Basic authorization for proxy server if necessary
|
|
||||||
proxyAuth: 'user:password',
|
|
||||||
|
|
||||||
// Header fields for proxy server if necessary
|
|
||||||
headers: {
|
|
||||||
'User-Agent': 'Node'
|
|
||||||
},
|
|
||||||
|
|
||||||
// CA for proxy server if necessary
|
|
||||||
ca: [ fs.readFileSync('origin-server-ca.pem')],
|
|
||||||
|
|
||||||
// Server name for verification if necessary
|
|
||||||
servername: 'example.com',
|
|
||||||
|
|
||||||
// Client certification for proxy server if necessary
|
|
||||||
key: fs.readFileSync('origin-server-key.pem'),
|
|
||||||
cert: fs.readFileSync('origin-server-cert.pem'),
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
var req = http.request({
|
|
||||||
host: 'example.com',
|
|
||||||
port: 80,
|
|
||||||
agent: tunnelingAgent
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
### HTTPS over HTTPS tunneling
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var tunnelingAgent = tunnel.httpsOverHttps({
|
|
||||||
maxSockets: poolSize, // Defaults to 5
|
|
||||||
|
|
||||||
// CA for origin server if necessary
|
|
||||||
ca: [ fs.readFileSync('origin-server-ca.pem')],
|
|
||||||
|
|
||||||
// Client certification for origin server if necessary
|
|
||||||
key: fs.readFileSync('origin-server-key.pem'),
|
|
||||||
cert: fs.readFileSync('origin-server-cert.pem'),
|
|
||||||
|
|
||||||
proxy: { // Proxy settings
|
|
||||||
host: proxyHost, // Defaults to 'localhost'
|
|
||||||
port: proxyPort, // Defaults to 443
|
|
||||||
localAddress: localAddress, // Local interface if necessary
|
|
||||||
|
|
||||||
// Basic authorization for proxy server if necessary
|
|
||||||
proxyAuth: 'user:password',
|
|
||||||
|
|
||||||
// Header fields for proxy server if necessary
|
|
||||||
headers: {
|
|
||||||
'User-Agent': 'Node'
|
|
||||||
}
|
|
||||||
|
|
||||||
// CA for proxy server if necessary
|
|
||||||
ca: [ fs.readFileSync('origin-server-ca.pem')],
|
|
||||||
|
|
||||||
// Server name for verification if necessary
|
|
||||||
servername: 'example.com',
|
|
||||||
|
|
||||||
// Client certification for proxy server if necessary
|
|
||||||
key: fs.readFileSync('origin-server-key.pem'),
|
|
||||||
cert: fs.readFileSync('origin-server-cert.pem'),
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
var req = https.request({
|
|
||||||
host: 'example.com',
|
|
||||||
port: 443,
|
|
||||||
agent: tunnelingAgent
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
## CONTRIBUTORS
|
|
||||||
* [Aleksis Brezas (abresas)](https://github.com/abresas)
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
Licensed under the [MIT](https://github.com/koichik/node-tunnel/blob/master/LICENSE) license.
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
module.exports = require('./lib/tunnel');
|
|
||||||
|
|
@ -1,247 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var net = require('net');
|
|
||||||
var tls = require('tls');
|
|
||||||
var http = require('http');
|
|
||||||
var https = require('https');
|
|
||||||
var events = require('events');
|
|
||||||
var assert = require('assert');
|
|
||||||
var util = require('util');
|
|
||||||
|
|
||||||
|
|
||||||
exports.httpOverHttp = httpOverHttp;
|
|
||||||
exports.httpsOverHttp = httpsOverHttp;
|
|
||||||
exports.httpOverHttps = httpOverHttps;
|
|
||||||
exports.httpsOverHttps = httpsOverHttps;
|
|
||||||
|
|
||||||
|
|
||||||
function httpOverHttp(options) {
|
|
||||||
var agent = new TunnelingAgent(options);
|
|
||||||
agent.request = http.request;
|
|
||||||
return agent;
|
|
||||||
}
|
|
||||||
|
|
||||||
function httpsOverHttp(options) {
|
|
||||||
var agent = new TunnelingAgent(options);
|
|
||||||
agent.request = http.request;
|
|
||||||
agent.createSocket = createSecureSocket;
|
|
||||||
return agent;
|
|
||||||
}
|
|
||||||
|
|
||||||
function httpOverHttps(options) {
|
|
||||||
var agent = new TunnelingAgent(options);
|
|
||||||
agent.request = https.request;
|
|
||||||
return agent;
|
|
||||||
}
|
|
||||||
|
|
||||||
function httpsOverHttps(options) {
|
|
||||||
var agent = new TunnelingAgent(options);
|
|
||||||
agent.request = https.request;
|
|
||||||
agent.createSocket = createSecureSocket;
|
|
||||||
return agent;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function TunnelingAgent(options) {
|
|
||||||
var self = this;
|
|
||||||
self.options = options || {};
|
|
||||||
self.proxyOptions = self.options.proxy || {};
|
|
||||||
self.maxSockets = self.options.maxSockets || http.Agent.defaultMaxSockets;
|
|
||||||
self.requests = [];
|
|
||||||
self.sockets = [];
|
|
||||||
|
|
||||||
self.on('free', function onFree(socket, host, port, localAddress) {
|
|
||||||
var options = toOptions(host, port, localAddress);
|
|
||||||
for (var i = 0, len = self.requests.length; i < len; ++i) {
|
|
||||||
var pending = self.requests[i];
|
|
||||||
if (pending.host === options.host && pending.port === options.port) {
|
|
||||||
// Detect the request to connect same origin server,
|
|
||||||
// reuse the connection.
|
|
||||||
self.requests.splice(i, 1);
|
|
||||||
pending.request.onSocket(socket);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
socket.destroy();
|
|
||||||
self.removeSocket(socket);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
util.inherits(TunnelingAgent, events.EventEmitter);
|
|
||||||
|
|
||||||
TunnelingAgent.prototype.addRequest = function addRequest(req, host, port, localAddress) {
|
|
||||||
var self = this;
|
|
||||||
var options = mergeOptions({request: req}, self.options, toOptions(host, port, localAddress));
|
|
||||||
|
|
||||||
if (self.sockets.length >= this.maxSockets) {
|
|
||||||
// We are over limit so we'll add it to the queue.
|
|
||||||
self.requests.push(options);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we are under maxSockets create a new one.
|
|
||||||
self.createSocket(options, function(socket) {
|
|
||||||
socket.on('free', onFree);
|
|
||||||
socket.on('close', onCloseOrRemove);
|
|
||||||
socket.on('agentRemove', onCloseOrRemove);
|
|
||||||
req.onSocket(socket);
|
|
||||||
|
|
||||||
function onFree() {
|
|
||||||
self.emit('free', socket, options);
|
|
||||||
}
|
|
||||||
|
|
||||||
function onCloseOrRemove(err) {
|
|
||||||
self.removeSocket(socket);
|
|
||||||
socket.removeListener('free', onFree);
|
|
||||||
socket.removeListener('close', onCloseOrRemove);
|
|
||||||
socket.removeListener('agentRemove', onCloseOrRemove);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
TunnelingAgent.prototype.createSocket = function createSocket(options, cb) {
|
|
||||||
var self = this;
|
|
||||||
var placeholder = {};
|
|
||||||
self.sockets.push(placeholder);
|
|
||||||
|
|
||||||
var connectOptions = mergeOptions({}, self.proxyOptions, {
|
|
||||||
method: 'CONNECT',
|
|
||||||
path: options.host + ':' + options.port,
|
|
||||||
agent: false
|
|
||||||
});
|
|
||||||
if (connectOptions.proxyAuth) {
|
|
||||||
connectOptions.headers = connectOptions.headers || {};
|
|
||||||
connectOptions.headers['Proxy-Authorization'] = 'Basic ' +
|
|
||||||
new Buffer(connectOptions.proxyAuth).toString('base64');
|
|
||||||
}
|
|
||||||
|
|
||||||
debug('making CONNECT request');
|
|
||||||
var connectReq = self.request(connectOptions);
|
|
||||||
connectReq.useChunkedEncodingByDefault = false; // for v0.6
|
|
||||||
connectReq.once('response', onResponse); // for v0.6
|
|
||||||
connectReq.once('upgrade', onUpgrade); // for v0.6
|
|
||||||
connectReq.once('connect', onConnect); // for v0.7 or later
|
|
||||||
connectReq.once('error', onError);
|
|
||||||
connectReq.end();
|
|
||||||
|
|
||||||
function onResponse(res) {
|
|
||||||
// Very hacky. This is necessary to avoid http-parser leaks.
|
|
||||||
res.upgrade = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function onUpgrade(res, socket, head) {
|
|
||||||
// Hacky.
|
|
||||||
process.nextTick(function() {
|
|
||||||
onConnect(res, socket, head);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function onConnect(res, socket, head) {
|
|
||||||
connectReq.removeAllListeners();
|
|
||||||
socket.removeAllListeners();
|
|
||||||
|
|
||||||
if (res.statusCode === 200) {
|
|
||||||
assert.equal(head.length, 0);
|
|
||||||
debug('tunneling connection has established');
|
|
||||||
self.sockets[self.sockets.indexOf(placeholder)] = socket;
|
|
||||||
cb(socket);
|
|
||||||
} else {
|
|
||||||
debug('tunneling socket could not be established, statusCode=%d',
|
|
||||||
res.statusCode);
|
|
||||||
var error = new Error('tunneling socket could not be established, ' +
|
|
||||||
'statusCode=' + res.statusCode);
|
|
||||||
error.code = 'ECONNRESET';
|
|
||||||
options.request.emit('error', error);
|
|
||||||
self.removeSocket(placeholder);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function onError(cause) {
|
|
||||||
connectReq.removeAllListeners();
|
|
||||||
|
|
||||||
debug('tunneling socket could not be established, cause=%s\n',
|
|
||||||
cause.message, cause.stack);
|
|
||||||
var error = new Error('tunneling socket could not be established, ' +
|
|
||||||
'cause=' + cause.message);
|
|
||||||
error.code = 'ECONNRESET';
|
|
||||||
options.request.emit('error', error);
|
|
||||||
self.removeSocket(placeholder);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
TunnelingAgent.prototype.removeSocket = function removeSocket(socket) {
|
|
||||||
var pos = this.sockets.indexOf(socket)
|
|
||||||
if (pos === -1) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.sockets.splice(pos, 1);
|
|
||||||
|
|
||||||
var pending = this.requests.shift();
|
|
||||||
if (pending) {
|
|
||||||
// If we have pending requests and a socket gets closed a new one
|
|
||||||
// needs to be created to take over in the pool for the one that closed.
|
|
||||||
this.createSocket(pending, function(socket) {
|
|
||||||
pending.request.onSocket(socket);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
function createSecureSocket(options, cb) {
|
|
||||||
var self = this;
|
|
||||||
TunnelingAgent.prototype.createSocket.call(self, options, function(socket) {
|
|
||||||
var hostHeader = options.request.getHeader('host');
|
|
||||||
var tlsOptions = mergeOptions({}, self.options, {
|
|
||||||
socket: socket,
|
|
||||||
servername: hostHeader ? hostHeader.replace(/:.*$/, '') : options.host
|
|
||||||
});
|
|
||||||
|
|
||||||
// 0 is dummy port for v0.6
|
|
||||||
var secureSocket = tls.connect(0, tlsOptions);
|
|
||||||
self.sockets[self.sockets.indexOf(socket)] = secureSocket;
|
|
||||||
cb(secureSocket);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function toOptions(host, port, localAddress) {
|
|
||||||
if (typeof host === 'string') { // since v0.10
|
|
||||||
return {
|
|
||||||
host: host,
|
|
||||||
port: port,
|
|
||||||
localAddress: localAddress
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return host; // for v0.11 or later
|
|
||||||
}
|
|
||||||
|
|
||||||
function mergeOptions(target) {
|
|
||||||
for (var i = 1, len = arguments.length; i < len; ++i) {
|
|
||||||
var overrides = arguments[i];
|
|
||||||
if (typeof overrides === 'object') {
|
|
||||||
var keys = Object.keys(overrides);
|
|
||||||
for (var j = 0, keyLen = keys.length; j < keyLen; ++j) {
|
|
||||||
var k = keys[j];
|
|
||||||
if (overrides[k] !== undefined) {
|
|
||||||
target[k] = overrides[k];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return target;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
var debug;
|
|
||||||
if (process.env.NODE_DEBUG && /\btunnel\b/.test(process.env.NODE_DEBUG)) {
|
|
||||||
debug = function() {
|
|
||||||
var args = Array.prototype.slice.call(arguments);
|
|
||||||
if (typeof args[0] === 'string') {
|
|
||||||
args[0] = 'TUNNEL: ' + args[0];
|
|
||||||
} else {
|
|
||||||
args.unshift('TUNNEL:');
|
|
||||||
}
|
|
||||||
console.error.apply(console, args);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
debug = function() {};
|
|
||||||
}
|
|
||||||
exports.debug = debug; // for test
|
|
||||||
|
|
@ -1,64 +0,0 @@
|
||||||
{
|
|
||||||
"_from": "tunnel@0.0.4",
|
|
||||||
"_id": "tunnel@0.0.4",
|
|
||||||
"_inBundle": false,
|
|
||||||
"_integrity": "sha1-LTeFoVjBdMmhbcLARuxfxfF0IhM=",
|
|
||||||
"_location": "/tunnel",
|
|
||||||
"_phantomChildren": {},
|
|
||||||
"_requested": {
|
|
||||||
"type": "version",
|
|
||||||
"registry": true,
|
|
||||||
"raw": "tunnel@0.0.4",
|
|
||||||
"name": "tunnel",
|
|
||||||
"escapedName": "tunnel",
|
|
||||||
"rawSpec": "0.0.4",
|
|
||||||
"saveSpec": null,
|
|
||||||
"fetchSpec": "0.0.4"
|
|
||||||
},
|
|
||||||
"_requiredBy": [
|
|
||||||
"/typed-rest-client"
|
|
||||||
],
|
|
||||||
"_resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.4.tgz",
|
|
||||||
"_shasum": "2d3785a158c174c9a16dc2c046ec5fc5f1742213",
|
|
||||||
"_spec": "tunnel@0.0.4",
|
|
||||||
"_where": "C:\\Users\\Administrator\\Documents\\setup-node\\node_modules\\typed-rest-client",
|
|
||||||
"author": {
|
|
||||||
"name": "Koichi Kobayashi",
|
|
||||||
"email": "koichik@improvement.jp"
|
|
||||||
},
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/koichik/node-tunnel/issues"
|
|
||||||
},
|
|
||||||
"bundleDependencies": false,
|
|
||||||
"deprecated": false,
|
|
||||||
"description": "Node HTTP/HTTPS Agents for tunneling proxies",
|
|
||||||
"devDependencies": {
|
|
||||||
"mocha": "*",
|
|
||||||
"should": "*"
|
|
||||||
},
|
|
||||||
"directories": {
|
|
||||||
"lib": "./lib"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=0.6.11 <=0.7.0 || >=0.7.3"
|
|
||||||
},
|
|
||||||
"homepage": "https://github.com/koichik/node-tunnel/",
|
|
||||||
"keywords": [
|
|
||||||
"http",
|
|
||||||
"https",
|
|
||||||
"agent",
|
|
||||||
"proxy",
|
|
||||||
"tunnel"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"main": "./index.js",
|
|
||||||
"name": "tunnel",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/koichik/node-tunnel.git"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"test": "./node_modules/mocha/bin/mocha"
|
|
||||||
},
|
|
||||||
"version": "0.0.4"
|
|
||||||
}
|
|
||||||
|
|
@ -1,108 +0,0 @@
|
||||||
var http = require('http');
|
|
||||||
var net = require('net');
|
|
||||||
var should = require('should');
|
|
||||||
var tunnel = require('../index');
|
|
||||||
|
|
||||||
describe('HTTP over HTTP', function() {
|
|
||||||
it('should finish without error', function(done) {
|
|
||||||
var serverPort = 3000;
|
|
||||||
var proxyPort = 3001;
|
|
||||||
var poolSize = 3;
|
|
||||||
var N = 10;
|
|
||||||
var serverConnect = 0;
|
|
||||||
var proxyConnect = 0;
|
|
||||||
var clientConnect = 0;
|
|
||||||
var server;
|
|
||||||
var proxy;
|
|
||||||
var agent;
|
|
||||||
|
|
||||||
server = http.createServer(function(req, res) {
|
|
||||||
tunnel.debug('SERVER: got request');
|
|
||||||
++serverConnect;
|
|
||||||
res.writeHead(200);
|
|
||||||
res.end('Hello' + req.url);
|
|
||||||
tunnel.debug('SERVER: sending response');
|
|
||||||
});
|
|
||||||
server.listen(serverPort, setupProxy);
|
|
||||||
|
|
||||||
function setupProxy() {
|
|
||||||
proxy = http.createServer(function(req, res) {
|
|
||||||
should.fail();
|
|
||||||
});
|
|
||||||
proxy.on('upgrade', onConnect); // for v0.6
|
|
||||||
proxy.on('connect', onConnect); // for v0.7 or later
|
|
||||||
|
|
||||||
function onConnect(req, clientSocket, head) {
|
|
||||||
tunnel.debug('PROXY: got CONNECT request');
|
|
||||||
|
|
||||||
req.method.should.equal('CONNECT');
|
|
||||||
req.url.should.equal('localhost:' + serverPort);
|
|
||||||
req.headers.should.not.have.property('transfer-encoding');
|
|
||||||
req.headers.should.have.property('proxy-authorization',
|
|
||||||
'Basic ' + new Buffer('user:password').toString('base64'));
|
|
||||||
++proxyConnect;
|
|
||||||
|
|
||||||
tunnel.debug('PROXY: creating a tunnel');
|
|
||||||
var serverSocket = net.connect(serverPort, function() {
|
|
||||||
tunnel.debug('PROXY: replying to client CONNECT request');
|
|
||||||
clientSocket.write('HTTP/1.1 200 Connection established\r\n\r\n');
|
|
||||||
clientSocket.pipe(serverSocket);
|
|
||||||
serverSocket.write(head);
|
|
||||||
serverSocket.pipe(clientSocket);
|
|
||||||
// workaround, see joyent/node#2524
|
|
||||||
serverSocket.on('end', function() {
|
|
||||||
clientSocket.end();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
proxy.listen(proxyPort, setupClient);
|
|
||||||
}
|
|
||||||
|
|
||||||
function setupClient() {
|
|
||||||
agent = tunnel.httpOverHttp({
|
|
||||||
maxSockets: poolSize,
|
|
||||||
proxy: {
|
|
||||||
port: proxyPort,
|
|
||||||
proxyAuth: 'user:password'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
for (var i = 0; i < N; ++i) {
|
|
||||||
doClientRequest(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
function doClientRequest(i) {
|
|
||||||
tunnel.debug('CLIENT: Making HTTP request (%d)', i);
|
|
||||||
var req = http.get({
|
|
||||||
port: serverPort,
|
|
||||||
path: '/' + i,
|
|
||||||
agent: agent
|
|
||||||
}, function(res) {
|
|
||||||
tunnel.debug('CLIENT: got HTTP response (%d)', i);
|
|
||||||
res.setEncoding('utf8');
|
|
||||||
res.on('data', function(data) {
|
|
||||||
data.should.equal('Hello/' + i);
|
|
||||||
});
|
|
||||||
res.on('end', function() {
|
|
||||||
++clientConnect;
|
|
||||||
if (clientConnect === N) {
|
|
||||||
proxy.close();
|
|
||||||
server.close();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
server.on('close', function() {
|
|
||||||
serverConnect.should.equal(N);
|
|
||||||
proxyConnect.should.equal(poolSize);
|
|
||||||
clientConnect.should.equal(N);
|
|
||||||
|
|
||||||
agent.sockets.should.be.empty;
|
|
||||||
agent.requests.should.be.empty;
|
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
@ -1,130 +0,0 @@
|
||||||
var http = require('http');
|
|
||||||
var https = require('https');
|
|
||||||
var net = require('net');
|
|
||||||
var fs = require('fs');
|
|
||||||
var path = require('path');
|
|
||||||
var should = require('should');
|
|
||||||
var tunnel = require('../index');
|
|
||||||
|
|
||||||
function readPem(file) {
|
|
||||||
return fs.readFileSync(path.join('test/keys', file + '.pem'));
|
|
||||||
}
|
|
||||||
|
|
||||||
var proxyKey = readPem('proxy1-key');
|
|
||||||
var proxyCert = readPem('proxy1-cert');
|
|
||||||
var proxyCA = readPem('ca2-cert');
|
|
||||||
var clientKey = readPem('client1-key');
|
|
||||||
var clientCert = readPem('client1-cert');
|
|
||||||
var clientCA = readPem('ca3-cert');
|
|
||||||
|
|
||||||
describe('HTTP over HTTPS', function() {
|
|
||||||
it('should finish without error', function(done) {
|
|
||||||
var serverPort = 3004;
|
|
||||||
var proxyPort = 3005;
|
|
||||||
var poolSize = 3;
|
|
||||||
var N = 10;
|
|
||||||
var serverConnect = 0;
|
|
||||||
var proxyConnect = 0;
|
|
||||||
var clientConnect = 0;
|
|
||||||
var server;
|
|
||||||
var proxy;
|
|
||||||
var agent;
|
|
||||||
|
|
||||||
server = http.createServer(function(req, res) {
|
|
||||||
tunnel.debug('SERVER: got request');
|
|
||||||
++serverConnect;
|
|
||||||
res.writeHead(200);
|
|
||||||
res.end('Hello' + req.url);
|
|
||||||
tunnel.debug('SERVER: sending response');
|
|
||||||
});
|
|
||||||
server.listen(serverPort, setupProxy);
|
|
||||||
|
|
||||||
function setupProxy() {
|
|
||||||
proxy = https.createServer({
|
|
||||||
key: proxyKey,
|
|
||||||
cert: proxyCert,
|
|
||||||
ca: [clientCA],
|
|
||||||
requestCert: true,
|
|
||||||
rejectUnauthorized: true
|
|
||||||
}, function(req, res) {
|
|
||||||
should.fail();
|
|
||||||
});
|
|
||||||
proxy.on('upgrade', onConnect); // for v0.6
|
|
||||||
proxy.on('connect', onConnect); // for v0.7 or later
|
|
||||||
|
|
||||||
function onConnect(req, clientSocket, head) {
|
|
||||||
tunnel.debug('PROXY: got CONNECT request');
|
|
||||||
|
|
||||||
req.method.should.equal('CONNECT');
|
|
||||||
req.url.should.equal('localhost:' + serverPort);
|
|
||||||
req.headers.should.not.have.property('transfer-encoding');
|
|
||||||
++proxyConnect;
|
|
||||||
|
|
||||||
tunnel.debug('PROXY: creating a tunnel');
|
|
||||||
var serverSocket = net.connect(serverPort, function() {
|
|
||||||
tunnel.debug('PROXY: replying to client CONNECT request');
|
|
||||||
clientSocket.write('HTTP/1.1 200 Connection established\r\n\r\n');
|
|
||||||
clientSocket.pipe(serverSocket);
|
|
||||||
serverSocket.write(head);
|
|
||||||
serverSocket.pipe(clientSocket);
|
|
||||||
// workaround, see joyent/node#2524
|
|
||||||
serverSocket.on('end', function() {
|
|
||||||
clientSocket.end();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
proxy.listen(proxyPort, setupClient);
|
|
||||||
}
|
|
||||||
|
|
||||||
function setupClient() {
|
|
||||||
agent = tunnel.httpOverHttps({
|
|
||||||
maxSockets: poolSize,
|
|
||||||
proxy: {
|
|
||||||
port: proxyPort,
|
|
||||||
key: clientKey,
|
|
||||||
cert: clientCert,
|
|
||||||
ca: [proxyCA],
|
|
||||||
rejectUnauthorized: true
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
for (var i = 0; i < N; ++i) {
|
|
||||||
doClientRequest(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
function doClientRequest(i) {
|
|
||||||
tunnel.debug('CLIENT: Making HTTP request (%d)', i);
|
|
||||||
var req = http.get({
|
|
||||||
port: serverPort,
|
|
||||||
path: '/' + i,
|
|
||||||
agent: agent
|
|
||||||
}, function(res) {
|
|
||||||
tunnel.debug('CLIENT: got HTTP response (%d)', i);
|
|
||||||
res.setEncoding('utf8');
|
|
||||||
res.on('data', function(data) {
|
|
||||||
data.should.equal('Hello/' + i);
|
|
||||||
});
|
|
||||||
res.on('end', function() {
|
|
||||||
++clientConnect;
|
|
||||||
if (clientConnect === N) {
|
|
||||||
proxy.close();
|
|
||||||
server.close();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
server.on('close', function() {
|
|
||||||
serverConnect.should.equal(N);
|
|
||||||
proxyConnect.should.equal(poolSize);
|
|
||||||
clientConnect.should.equal(N);
|
|
||||||
|
|
||||||
var name = 'localhost:' + serverPort;
|
|
||||||
agent.sockets.should.be.empty;
|
|
||||||
agent.requests.should.be.empty;
|
|
||||||
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue