saucectl 0.164.0 → 0.164.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. package/README.md +1 -1
  2. package/index.js +94 -60
  3. package/install.js +9 -4
  4. package/package.json +18 -13
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  Node.js saucectl Wrapper ![build](https://github.com/saucelabs/node-saucectl/workflows/saucectl%20pipeline/badge.svg)
2
2
  ========================
3
3
 
4
- Node.js wrapper for saucectl: Sauce Labs Testrunner Toolkit.
4
+ Node.js wrapper for [saucectl](https://github.com/saucelabs/saucectl).
5
5
 
6
6
  ## Install
7
7
 
package/index.js CHANGED
@@ -4,83 +4,117 @@ const path = require('path');
4
4
  const { BinWrapper } = require('@saucelabs/bin-wrapper');
5
5
  const { Writable } = require('stream');
6
6
 
7
- const version = '0.164.0'
8
- const defaultBinInstallBase = 'https://github.com/saucelabs/saucectl/releases/download';
7
+ const version = '0.164.1';
8
+ const defaultBinInstallBase =
9
+ 'https://github.com/saucelabs/saucectl/releases/download';
9
10
  const binWrapper = (binInstallURL = null, binInstallBase = null) => {
10
- const bw = new BinWrapper();
11
+ const bw = new BinWrapper();
11
12
 
12
- if (process.env.GITHUB_TOKEN) {
13
- bw.httpOptions({
14
- headers: {
15
- authorization: `Bearer ${process.env.GITHUB_TOKEN}`,
16
- }
17
- });
18
- }
19
-
20
- const base = binInstallBase || defaultBinInstallBase;
13
+ if (process.env.GITHUB_TOKEN) {
14
+ bw.httpOptions({
15
+ headers: {
16
+ authorization: `Bearer ${process.env.GITHUB_TOKEN}`,
17
+ },
18
+ });
19
+ }
21
20
 
22
- let sources = [
23
- { url: `${base}/v${version}/saucectl_${version}_mac_64-bit.tar.gz`, os: 'darwin', arch: 'x64' },
24
- { url: `${base}/v${version}/saucectl_${version}_mac_arm64.tar.gz`, os: 'darwin', arch: 'arm64' },
25
- { url: `${base}/v${version}/saucectl_${version}_linux_32-bit.tar.gz`, os: 'linux', arch: 'x86' },
26
- { url: `${base}/v${version}/saucectl_${version}_linux_64-bit.tar.gz`, os: 'linux', arch: 'x64' },
27
- { url: `${base}/v${version}/saucectl_${version}_linux_arm64.tar.gz`, os: 'linux', arch: 'arm64' },
28
- { url: `${base}/v${version}/saucectl_${version}_win_32-bit.zip`, os: 'win32', arch: 'x86' },
29
- { url: `${base}/v${version}/saucectl_${version}_win_64-bit.zip`, os: 'win32', arch: 'x64' },
30
- ];
21
+ const base = binInstallBase || defaultBinInstallBase;
31
22
 
32
- sources = sources.filter(x => process.platform === x.os && process.arch === x.arch);
23
+ let sources = [
24
+ {
25
+ url: `${base}/v${version}/saucectl_${version}_mac_64-bit.tar.gz`,
26
+ os: 'darwin',
27
+ arch: 'x64',
28
+ },
29
+ {
30
+ url: `${base}/v${version}/saucectl_${version}_mac_arm64.tar.gz`,
31
+ os: 'darwin',
32
+ arch: 'arm64',
33
+ },
34
+ {
35
+ url: `${base}/v${version}/saucectl_${version}_linux_32-bit.tar.gz`,
36
+ os: 'linux',
37
+ arch: 'x86',
38
+ },
39
+ {
40
+ url: `${base}/v${version}/saucectl_${version}_linux_64-bit.tar.gz`,
41
+ os: 'linux',
42
+ arch: 'x64',
43
+ },
44
+ {
45
+ url: `${base}/v${version}/saucectl_${version}_linux_arm64.tar.gz`,
46
+ os: 'linux',
47
+ arch: 'arm64',
48
+ },
49
+ {
50
+ url: `${base}/v${version}/saucectl_${version}_win_32-bit.zip`,
51
+ os: 'win32',
52
+ arch: 'x86',
53
+ },
54
+ {
55
+ url: `${base}/v${version}/saucectl_${version}_win_64-bit.zip`,
56
+ os: 'win32',
57
+ arch: 'x64',
58
+ },
59
+ ];
33
60
 
34
- if (binInstallURL) {
35
- bw.src(binInstallURL, process.platform, process.arch);
36
- } else {
37
- if (sources.length === 0) {
38
- return Promise.reject(new Error(`No binary found matching your system. It's probably not supported.`));
39
- }
61
+ sources = sources.filter(
62
+ (x) => process.platform === x.os && process.arch === x.arch,
63
+ );
40
64
 
41
- bw.src(sources[0].url, process.platform, process.arch);
65
+ if (binInstallURL) {
66
+ bw.src(binInstallURL, process.platform, process.arch);
67
+ } else {
68
+ if (sources.length === 0) {
69
+ return Promise.reject(
70
+ new Error(
71
+ `No binary found matching your system. It's probably not supported.`,
72
+ ),
73
+ );
42
74
  }
43
75
 
44
- bw.dest(path.join(__dirname, 'bin'));
45
- bw.use(process.platform.startsWith('win') ? 'saucectl.exe' : 'saucectl');
76
+ bw.src(sources[0].url, process.platform, process.arch);
77
+ }
46
78
 
47
- return bw;
48
- }
79
+ bw.dest(path.join(__dirname, 'bin'));
80
+ bw.use(process.platform.startsWith('win') ? 'saucectl.exe' : 'saucectl');
49
81
 
50
- async function preRun (b) {
51
- let buf = Buffer.from('');
52
- const st = new Writable();
53
- st._write = (d) => buf = Buffer.concat([buf, d]);
82
+ return bw;
83
+ };
54
84
 
55
- const exitCode = await b.run(['--version'], {
56
- stdout: st,
57
- stderr: st,
58
- });
85
+ async function preRun(b) {
86
+ let buf = Buffer.from('');
87
+ const st = new Writable();
88
+ st._write = (d) => (buf = Buffer.concat([buf, d]));
59
89
 
60
- if (exitCode !== 0) {
61
- console.log('Post-installation checks failed. saucectl output was:')
62
- console.log(buf.toString());
63
- // eslint-disable-next-line no-process-exit
64
- process.exit(exitCode);
65
- }
90
+ const exitCode = await b.run(['--version'], {
91
+ stdout: st,
92
+ stderr: st,
93
+ });
94
+
95
+ if (exitCode !== 0) {
96
+ console.log('Post-installation checks failed. saucectl output was:');
97
+ console.log(buf.toString());
98
+ process.exit(exitCode);
99
+ }
66
100
  }
67
101
 
68
- /* istanbul ignore next */
69
- async function main (b, args) {
70
- await preRun(b);
71
- const saucectlProcess = spawn(b.path(), args, {
72
- stdio: [process.stdin, process.stdout, process.stderr]
73
- });
74
- saucectlProcess.on('exit', function (code) {
75
- // eslint-disable-next-line no-process-exit
76
- process.exit(code);
77
- });
102
+ async function main(b, args) {
103
+ await preRun(b);
104
+ const saucectlProcess = spawn(b.path(), args, {
105
+ stdio: [process.stdin, process.stdout, process.stderr],
106
+ });
107
+ saucectlProcess.on('exit', function (code) {
108
+ process.exit(code);
109
+ });
78
110
  }
79
111
 
80
- /* istanbul ignore if */
81
112
  if (require.main === module) {
82
- const bw = binWrapper(process.env.SAUCECTL_INSTALL_BINARY, process.env.SAUCECTL_INSTALL_BINARY_MIRROR);
83
- main(bw, process.argv.slice(2));
113
+ const bw = binWrapper(
114
+ process.env.SAUCECTL_INSTALL_BINARY,
115
+ process.env.SAUCECTL_INSTALL_BINARY_MIRROR,
116
+ );
117
+ main(bw, process.argv.slice(2));
84
118
  }
85
119
 
86
120
  module.exports = main;
package/install.js CHANGED
@@ -5,9 +5,12 @@ const { binWrapper } = require('./index.js');
5
5
  // execute "saucectl --version".
6
6
  // So we are 100% sure that the saucectl binary will be available for the next
7
7
  // execution.
8
- async function install () {
8
+ async function install() {
9
9
  console.info('Fetching saucectl binary');
10
- const bw = binWrapper(process.env.SAUCECTL_INSTALL_BINARY, process.env.SAUCECTL_INSTALL_BINARY_MIRROR);
10
+ const bw = binWrapper(
11
+ process.env.SAUCECTL_INSTALL_BINARY,
12
+ process.env.SAUCECTL_INSTALL_BINARY_MIRROR,
13
+ );
11
14
  bw.run(['--version'])
12
15
  .then(() => {
13
16
  console.info(`Installation succeed`);
@@ -15,13 +18,15 @@ async function install () {
15
18
  })
16
19
  .catch((e) => {
17
20
  console.error(`Installation failed: ${e}`);
18
- console.error(`Check that you have access to https://github.com/saucelabs/saucectl/releases or format of the SAUCECTL_INSTALL_BINARY environment variable is correct\n\n`);
21
+ console.error(
22
+ `Check that you have access to https://github.com/saucelabs/saucectl/releases or format of the SAUCECTL_INSTALL_BINARY environment variable is correct\n\n`,
23
+ );
19
24
  process.exit(1);
20
25
  });
21
26
  }
22
27
 
23
28
  if (require.main === module) {
24
- install();
29
+ install();
25
30
  }
26
31
 
27
32
  module.exports = install;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "saucectl",
3
- "version": "0.164.0",
3
+ "version": "0.164.1",
4
4
  "description": "Node.js wrapper for saucectl",
5
5
  "main": "index.js",
6
6
  "bin": "index.js",
@@ -11,9 +11,9 @@
11
11
  "release:patch": "np patch",
12
12
  "release:minor": "np minor",
13
13
  "release:major": "np major",
14
- "test": "run-s test:*",
15
- "test:lint": "eslint index.js __tests__",
16
- "test:unit": "jest",
14
+ "lint": "prettier --check '**/*.{js,ts,mjs,cjs}' && eslint .",
15
+ "fmt": "prettier --write '**/*.{js,ts,mjs,cjs}'",
16
+ "test": "jest",
17
17
  "version": "run-p version:* && git add .",
18
18
  "version:bump": "replace-in-files --regex=\"version = '\\d+.\\d+.\\d+'\" --replacement=\"version = '${npm_package_version}'\" ./index.js"
19
19
  },
@@ -35,18 +35,23 @@
35
35
  "url": "https://github.com/saucelabs/node-saucectl/issues"
36
36
  },
37
37
  "homepage": "https://github.com/saucelabs/node-saucectl#readme",
38
+ "engines": {
39
+ "node": ">=16.13.2"
40
+ },
38
41
  "dependencies": {
39
- "@saucelabs/bin-wrapper": "^0.4.0"
42
+ "@saucelabs/bin-wrapper": "^1.0.0"
40
43
  },
41
44
  "devDependencies": {
42
- "eslint": "^6.8.0",
43
- "eslint-plugin-jest": "^23.9.0",
44
- "eslint-plugin-node": "^11.1.0",
45
- "jest": "^29.3.1",
46
- "np": "^6.2.3",
45
+ "eslint": "^8.51.0",
46
+ "eslint-config-prettier": "^9.0.0",
47
+ "eslint-plugin-jest": "^27.4.2",
48
+ "eslint-plugin-prettier": "^5.0.1",
49
+ "jest": "^29.7.0",
50
+ "np": "^8.0.4",
47
51
  "npm-run-all": "^4.1.5",
48
- "replace-in-files-cli": "^0.3.1",
49
- "rimraf": "^3.0.2",
50
- "ts-jest": "^29.0.5"
52
+ "prettier": "^3.0.3",
53
+ "replace-in-files-cli": "^2.2.0",
54
+ "rimraf": "^5.0.5",
55
+ "ts-jest": "^29.1.1"
51
56
  }
52
57
  }