sitespeed.io 27.5.0 → 27.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # CHANGELOG - sitespeed.io (we use [semantic versioning](https://semver.org))
2
2
 
3
+
4
+ ## 27.6.0 - 2023-05-10
5
+ ### Fixed
6
+ * More fixes to the upcoming API, and fixing wrong exit code.
7
+
8
+ ### Added
9
+ * Firefox and Edge 113 in the Docker container.
10
+
11
+ ## 27.5.1 - 2023-05-03
12
+ ### Fixed
13
+ * Another fix for storing result data as JSON.
14
+
3
15
  ## 27.5.0 - 2023-05-03
4
16
  ### Added
5
17
  * Use Chrome 113 in the Docker container.
package/Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- FROM sitespeedio/webbrowsers:chrome-113.0-firefox-112.0-edge-112.0
1
+ FROM sitespeedio/webbrowsers:chrome-113.0-firefox-113.0-edge-113.0
2
2
 
3
3
  ARG TARGETPLATFORM=linux/amd64
4
4
 
package/bin/sitespeed.js CHANGED
@@ -56,7 +56,7 @@ async function api(options) {
56
56
  }).start();
57
57
 
58
58
  try {
59
- const data = await addTest(hostname, apiOptions, spinner);
59
+ const data = await addTest(hostname, apiOptions);
60
60
  const testId = JSON.parse(data).id;
61
61
  spinner.color = 'yellow';
62
62
  spinner.text = `Added test with id ${testId}`;
@@ -74,7 +74,6 @@ async function api(options) {
74
74
  );
75
75
  if (result.status === 'completed') {
76
76
  spinner.succeed(`Got test result with id ${testId}`);
77
-
78
77
  if (options.api.json) {
79
78
  console.log(JSON.stringify(result));
80
79
  } else {
@@ -87,7 +86,7 @@ async function api(options) {
87
86
  }
88
87
  }
89
88
  } catch (error) {
90
- spinner.fail(error.toString());
89
+ spinner.fail(error.message);
91
90
  process.exitCode = 1;
92
91
  process.exit();
93
92
  }
@@ -115,6 +114,7 @@ async function start() {
115
114
  parsed.options.urlsMetaData = parsed.urlsMetaData;
116
115
 
117
116
  let options = parsed.options;
117
+
118
118
  if (options.api && options.api.hostname) {
119
119
  api(options);
120
120
  } else {
@@ -123,8 +123,13 @@ async function start() {
123
123
 
124
124
  // This can be used as an option to get hold of where the data is stored
125
125
  // for third parties
126
- if (options.storeResult == 'true') {
127
- writeFileSync('result.json', JSON.stringify(result));
126
+ if (options.storeResult) {
127
+ if (options.storeResult == 'true') {
128
+ writeFileSync('result.json', JSON.stringify(result));
129
+ } else {
130
+ // Use the name supplied
131
+ writeFileSync(options.storeResult, JSON.stringify(result));
132
+ }
128
133
  }
129
134
 
130
135
  if (result.errors.length > 0) {
package/lib/api/send.js CHANGED
@@ -3,7 +3,7 @@ import https from 'node:https';
3
3
 
4
4
  const delay = ms => new Promise(res => setTimeout(res, ms));
5
5
 
6
- export async function addTest(hostname, options, spinner) {
6
+ export async function addTest(hostname, options) {
7
7
  const port = options.api.port ?? 3000;
8
8
  const postData = options;
9
9
  const postOptions = {
@@ -21,24 +21,17 @@ export async function addTest(hostname, options, spinner) {
21
21
  // not perfect but maybe work for us
22
22
  const library = options.api.port === 443 ? https : http;
23
23
  const request = library.request(postOptions, res => {
24
- if (res.statusCode === 200) {
25
- res.setEncoding('utf8');
26
- let body = '';
27
- res.on('data', chunk => (body += chunk));
28
- res.on('end', () => resolve(body));
29
- } else {
30
- spinner.text = `Got ${res.statusCode} from the API: ${res.statusMessage}`;
31
- spinner.color = 'red';
32
- const e = new Error(
33
- `Got ${res.statusCode} from the API: ${res.statusMessage}`
34
- );
35
- reject(e);
36
- }
24
+ // res.setEncoding('utf8');
25
+ let data = [];
26
+ res.on('data', chunk => data.push(chunk));
27
+ res.on('end', () => {
28
+ return res.statusCode === 200
29
+ ? resolve(Buffer.concat(data).toString('utf8'))
30
+ : reject(Buffer.concat(data).toString('utf8'));
31
+ });
37
32
  });
38
33
  request.on('error', error => {
39
- spinner.text = `Got ${error.toString()} from the API`;
40
- spinner.color = 'red';
41
- reject(error);
34
+ reject({ message: error.toString() });
42
35
  });
43
36
  request.write(JSON.stringify(postData));
44
37
  request.end();
@@ -71,21 +64,14 @@ export async function get(testId, hostname, options) {
71
64
  library
72
65
  .get(url, res => {
73
66
  let data = [];
74
-
75
- if (res.statusCode != 200) {
76
- return reject(
77
- new Error(
78
- `Got response code ${res.statusCode} from the API: ${res.statusMessage}`
79
- )
80
- );
81
- }
82
-
83
67
  res.on('data', chunk => {
84
68
  data.push(chunk);
85
69
  });
86
70
 
87
71
  res.on('end', () => {
88
- return resolve(JSON.parse(Buffer.concat(data).toString()));
72
+ return res.statusCode === 200
73
+ ? resolve(Buffer.concat(data).toString('utf8'))
74
+ : reject(Buffer.concat(data).toString('utf8'));
89
75
  });
90
76
  })
91
77
  .on('error', () => {
package/lib/cli/cli.js CHANGED
@@ -149,6 +149,11 @@ function validateInput(argv) {
149
149
  return 'There is no benefit running debug mode inside a Docker container.';
150
150
  }
151
151
 
152
+ // If we ask the API for finished test, we don't need a URL
153
+ if (argv._.length === 0 && !argv.api.id) {
154
+ return 'You need to supply one/multiple URLs or scripts';
155
+ }
156
+
152
157
  // validate URLs/files
153
158
  const urlOrFiles = argv._;
154
159
  for (let urlOrFile of urlOrFiles) {
@@ -208,7 +213,6 @@ export async function parseCommandLine() {
208
213
  .parserConfiguration({ 'deep-merge-config': true })
209
214
  .env('SITESPEED_IO')
210
215
  .usage('$0 [options] <url>/<file>')
211
- .require(1, 'One or multiple URLs or scripts')
212
216
 
213
217
  .option('debugMessages', {
214
218
  default: false,
@@ -1092,21 +1096,6 @@ export async function parseCommandLine() {
1092
1096
  'The wait time before you start the real testing after your pre-cache request.'
1093
1097
  })
1094
1098
  /*
1095
- API options
1096
- */
1097
- .option('api.key', {
1098
- describe: 'The API key to use',
1099
- group: 'API'
1100
- })
1101
- .option('api.hostname', {
1102
- describe: 'The hostname of the server hosting the API',
1103
- group: 'API'
1104
- })
1105
- .option('api.serverName', {
1106
- describe: 'The serverName that will run the actual test',
1107
- group: 'API'
1108
- })
1109
- /*
1110
1099
  Crawler options
1111
1100
  */
1112
1101
  .option('crawler.depth', {
@@ -1814,8 +1803,13 @@ export async function parseCommandLine() {
1814
1803
  });
1815
1804
 
1816
1805
  parsed
1817
- .option('api.type', {
1818
- describe: 'The type of API call you want to do: S',
1806
+ .option('api.key', {
1807
+ describe: 'The API key to use.',
1808
+ group: 'API'
1809
+ })
1810
+ .option('api.action', {
1811
+ describe:
1812
+ 'The type of API call you want to do: You get add a test and wait for the result, just add a test or get the result. To get the result, make sure you add the id using --api.id',
1819
1813
  default: 'addAndGetResult',
1820
1814
  choices: ['add', 'addAndGetResult', 'get'],
1821
1815
  group: 'API'
@@ -1824,9 +1818,20 @@ export async function parseCommandLine() {
1824
1818
  describe: 'The hostname of the API server.',
1825
1819
  group: 'API'
1826
1820
  })
1821
+ .option('api.location', {
1822
+ describe: 'The location of the worker that run the test.',
1823
+ group: 'API'
1824
+ })
1825
+ .option('api.testType', {
1826
+ describe:
1827
+ 'The test type you want to run. The location needs tp have the chosen test type.',
1828
+ default: 'desktop',
1829
+ choices: ['desktop', 'emulatedMobile', 'android', 'ios'],
1830
+ group: 'API'
1831
+ })
1827
1832
  .option('api.silent', {
1828
1833
  describe:
1829
- 'Set to true if you do not want to log anything from the comunication',
1834
+ 'Set to true if you do not want to log anything from the communication',
1830
1835
  default: false,
1831
1836
  type: 'boolean',
1832
1837
  group: 'API'
@@ -1838,13 +1843,15 @@ export async function parseCommandLine() {
1838
1843
  })
1839
1844
  .option('api.id', {
1840
1845
  describe:
1841
- 'The id of the test. You it when you want to get the test result.',
1846
+ 'The id of the test. Use it when you want to get the test result.',
1847
+ type: 'string',
1842
1848
  group: 'API'
1843
1849
  })
1844
1850
  .option('api.json', {
1845
1851
  describe: 'Output the result as JSON.',
1846
1852
  group: 'API'
1847
1853
  });
1854
+
1848
1855
  parsed
1849
1856
  .option('mobile', {
1850
1857
  describe:
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "sitespeed.io",
3
- "version": "27.5.0",
3
+ "version": "27.6.0",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "sitespeed.io",
9
- "version": "27.5.0",
9
+ "version": "27.6.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@google-cloud/storage": "6.9.5",
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "sitespeed.io": "./bin/sitespeed.js",
6
6
  "sitespeed.io-wpr": "./bin/browsertimeWebPageReplay.js"
7
7
  },
8
- "version": "27.5.0",
8
+ "version": "27.6.0",
9
9
  "description": "Analyze the web performance of your site",
10
10
  "keywords": [
11
11
  "performance",