saucectl 0.165.0 → 0.166.0
Sign up to get free protection for your applications and to get access to all the features.
- package/index.js +22 -1
- package/install.js +35 -3
- package/package.json +1 -1
package/index.js
CHANGED
@@ -4,12 +4,33 @@ const path = require('path');
|
|
4
4
|
const { BinWrapper } = require('@saucelabs/bin-wrapper');
|
5
5
|
const { Writable } = require('stream');
|
6
6
|
|
7
|
-
const version = '0.
|
7
|
+
const version = '0.166.0';
|
8
8
|
const defaultBinInstallBase =
|
9
9
|
'https://github.com/saucelabs/saucectl/releases/download';
|
10
10
|
const binWrapper = (binInstallURL = null, binInstallBase = null) => {
|
11
11
|
const bw = new BinWrapper();
|
12
12
|
|
13
|
+
if (binInstallURL) {
|
14
|
+
try {
|
15
|
+
new URL(binInstallURL);
|
16
|
+
} catch (e) {
|
17
|
+
console.error(
|
18
|
+
`Please ensure the provided saucectl binary source is valid: ${e}`,
|
19
|
+
);
|
20
|
+
return;
|
21
|
+
}
|
22
|
+
}
|
23
|
+
if (binInstallBase) {
|
24
|
+
try {
|
25
|
+
new URL(binInstallBase);
|
26
|
+
} catch (e) {
|
27
|
+
console.error(
|
28
|
+
`Please ensure the provided saucectl binary source mirror is valid: ${e}`,
|
29
|
+
);
|
30
|
+
return;
|
31
|
+
}
|
32
|
+
}
|
33
|
+
|
13
34
|
if (process.env.GITHUB_TOKEN) {
|
14
35
|
bw.httpOptions({
|
15
36
|
headers: {
|
package/install.js
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
const { binWrapper } = require('./index.js');
|
2
2
|
|
3
|
+
function sanitizeURL(inputURL) {
|
4
|
+
const parsedURL = new URL(inputURL);
|
5
|
+
|
6
|
+
// Remove the username and password (authentication) if present
|
7
|
+
parsedURL.username = '';
|
8
|
+
parsedURL.password = '';
|
9
|
+
|
10
|
+
// Convert the sanitized URL back to a string
|
11
|
+
return parsedURL.toString();
|
12
|
+
}
|
13
|
+
|
3
14
|
// install.js is executed during the npm installation step.
|
4
15
|
// To re-use BinWrapper logic, and limit changes, we force BinWrapper to
|
5
16
|
// execute "saucectl --version".
|
@@ -11,6 +22,9 @@ async function install() {
|
|
11
22
|
process.env.SAUCECTL_INSTALL_BINARY,
|
12
23
|
process.env.SAUCECTL_INSTALL_BINARY_MIRROR,
|
13
24
|
);
|
25
|
+
if (!bw) {
|
26
|
+
return;
|
27
|
+
}
|
14
28
|
bw.run(['--version'])
|
15
29
|
.then(() => {
|
16
30
|
console.info(`Installation succeed`);
|
@@ -18,9 +32,27 @@ async function install() {
|
|
18
32
|
})
|
19
33
|
.catch((e) => {
|
20
34
|
console.error(`Installation failed: ${e}`);
|
21
|
-
|
22
|
-
|
23
|
-
|
35
|
+
if (e.message.includes('AxiosError')) {
|
36
|
+
const binarySource = process.env.SAUCECTL_INSTALL_BINARY;
|
37
|
+
const binarySourceMirror = process.env.SAUCECTL_INSTALL_BINARY_MIRROR;
|
38
|
+
if (binarySource) {
|
39
|
+
console.error(
|
40
|
+
`Please check that you have access to the URL provided by the SAUCECTL_INSTALL_BINARY environment variable: ${sanitizeURL(
|
41
|
+
binarySource,
|
42
|
+
)}\n\n`,
|
43
|
+
);
|
44
|
+
} else if (binarySourceMirror) {
|
45
|
+
console.error(
|
46
|
+
`Please check that you have access to the URL provided by the SAUCECTL_INSTALL_BINARY_MIRROR environment variable: ${sanitizeURL(
|
47
|
+
binarySourceMirror,
|
48
|
+
)}\n\n`,
|
49
|
+
);
|
50
|
+
} else {
|
51
|
+
console.error(
|
52
|
+
`Please check that you have access to https://github.com/saucelabs/saucectl/releases\n\n`,
|
53
|
+
);
|
54
|
+
}
|
55
|
+
}
|
24
56
|
process.exit(1);
|
25
57
|
});
|
26
58
|
}
|