@speedkit/cli 2.69.1 → 2.70.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,3 +1,10 @@
1
+ # [2.70.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.69.1...v2.70.0) (2024-12-12)
2
+
3
+
4
+ ### Features
5
+
6
+ * prepare CLI to support dictionary compression [@edge](https://gitlab.orestes.info/edge) ([c7c4353](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/c7c4353ca48dcaf00af481b98c329f37768c0aea))
7
+
1
8
  ## [2.69.1](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.69.0...v2.69.1) (2024-12-11)
2
9
 
3
10
 
package/README.md CHANGED
@@ -21,7 +21,7 @@ $ npm install -g @speedkit/cli
21
21
  $ sk COMMAND
22
22
  running command...
23
23
  $ sk (--version)
24
- @speedkit/cli/2.69.1 linux-x64 node-v20.18.1
24
+ @speedkit/cli/2.70.0 linux-x64 node-v20.18.1
25
25
  $ sk --help [COMMAND]
26
26
  USAGE
27
27
  $ sk COMMAND
@@ -353,7 +353,7 @@ DESCRIPTION
353
353
  Display help for sk.
354
354
  ```
355
355
 
356
- _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.16/src/commands/help.ts)_
356
+ _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.19/src/commands/help.ts)_
357
357
 
358
358
  ## `sk login [APP]`
359
359
 
@@ -28,15 +28,16 @@ class AssetApiClient {
28
28
  this.isValidUrl(url);
29
29
  const assetUrl = new node_url_1.URL((0, normalize_1.normalize)(url, this.sortParameters));
30
30
  if (variation !== "DEFAULT" && variation !== "DESKTOP") {
31
- assetUrl.searchParams.set("bqvariation", variation.toLowerCase());
31
+ assetUrl.searchParams.set("bqvariation", variation);
32
32
  }
33
33
  assetUrl.searchParams.set("bqpass", "1");
34
34
  return (0, node_fetch_1.default)(`https://${this.app}.app.baqend.com/v1/asset/${assetUrl.toString()}`, {
35
35
  agent: this.agent,
36
36
  headers: {
37
- "Accept-Encoding": "gzip, deflate, br",
37
+ "Accept-Encoding": "gzip, deflate, br, dcb",
38
38
  Origin: assetUrl.origin,
39
39
  authorization: `BAT ${this.authenticationToken}`,
40
+ "baqend-choose-dictionary": "1",
40
41
  },
41
42
  method: "HEAD",
42
43
  });
@@ -1,48 +1,54 @@
1
- const fetch = require('node-fetch')
2
- const https = require('node:https')
1
+ const fetch = require("node-fetch");
2
+ const https = require("node:https");
3
3
 
4
4
  /* global Abort, ORIGIN_POPS */
5
5
 
6
- const agent = new https.Agent({rejectUnauthorized: false})
6
+ const agent = new https.Agent({ rejectUnauthorized: false });
7
7
 
8
8
  {{config}} // eslint-disable-line
9
9
 
10
- const ORIGIN_PATHS = Object.keys(ORIGIN_POPS).filter(origin => origin.endsWith('/'))
10
+ const ORIGIN_PATHS = Object.keys(ORIGIN_POPS).filter((origin) =>
11
+ origin.endsWith("/"),
12
+ );
11
13
 
12
- const fetchURL = async (ip, url, origin, variation, db) => {
13
- if (variation && variation !== 'DEFAULT') {
14
- url = url + (url.includes('?') ? '&' : '?') + `bqvariation=${variation.toLowerCase()}`
14
+ const fetchURL = async (ip, url, origin, variation, database) => {
15
+ if (variation && variation !== "DEFAULT") {
16
+ url =
17
+ url +
18
+ (url.includes("?") ? "&" : "?") +
19
+ `bqvariation=${variation.toLowerCase()}`;
15
20
  }
16
21
 
17
- const app = db.connection.host
22
+ const app = database.connection.host;
18
23
  try {
19
24
  await fetch(`https://${ip}/v1/asset/${url}`, {
20
25
  agent,
21
26
  headers: {
22
- 'Accept-Encoding': 'gzip, deflate, br',
27
+ "Accept-Encoding": "gzip, deflate, br, dcb",
23
28
  Host: `${app}.app.baqend.com`,
24
29
  Origin: origin,
25
- authorization: `BAT ${db.token}`,
26
- 'baqend-prewarm': '1',
30
+ authorization: `BAT ${database.token}`,
31
+ "baqend-prewarm": "1",
32
+ "baqend-choose-dictionary": "1",
27
33
  },
28
- method: 'HEAD',
34
+ method: "HEAD",
29
35
  timeout: 3000,
30
- })
36
+ });
31
37
  } catch (error) {
32
- console.log(`error fetching https://${ip}/v1/asset/${url}`, error)
38
+ console.log(`error fetching https://${ip}/v1/asset/${url}`, error);
33
39
  }
34
- }
40
+ };
35
41
 
36
- const fetchAssets = async (ip, assets, db) => {
37
- const fetches = []
42
+ const fetchAssets = async (ip, assets, database) => {
43
+ const fetches = [];
38
44
  for (const asset of assets) {
39
- let {extendedURL, origin, url, variation} = asset
40
- url += (extendedURL || '')
41
- fetches.push(fetchURL(ip, url, origin, variation, db))
45
+ let { extendedURL, origin, url, variation } = asset;
46
+ url += extendedURL || "";
47
+ fetches.push(fetchURL(ip, url, origin, variation, database));
42
48
  }
43
49
 
44
- await Promise.all(fetches)
45
- }
50
+ await Promise.all(fetches);
51
+ };
46
52
 
47
53
  /**
48
54
  *
@@ -50,37 +56,38 @@ const fetchAssets = async (ip, assets, db) => {
50
56
  * @param {Array<{ extendedURL: string, origin: string, url: string, variation: string }>} assets - list of assets to prewar
51
57
  * @return {Promise<void>}
52
58
  */
53
- exports.call = async (db, assets) => {
54
- if (!db.User.me || db.User.me.key !== '1') {
55
- throw new Abort('Not logged in.')
59
+ exports.call = async (database, assets) => {
60
+ if (!database.User.me || database.User.me.key !== "1") {
61
+ throw new Abort("Not logged in.");
56
62
  }
57
63
 
58
- const originBuckets = {}
64
+ const originBuckets = {};
59
65
  for (const asset of assets) {
60
- let bucket = 'DEFAULT'
66
+ let bucket = "DEFAULT";
61
67
 
62
68
  if (ORIGIN_POPS[asset.origin]) {
63
- bucket = asset.origin
69
+ bucket = asset.origin;
64
70
  }
65
71
 
66
72
  // if there is a path specific prewarm list, overwrite the default prewarm list.
67
- const path = ORIGIN_PATHS.find(path => asset.url.startsWith(path))
73
+ const path = ORIGIN_PATHS.find((path) => asset.url.startsWith(path));
68
74
  if (path) {
69
- bucket = path
75
+ bucket = path;
70
76
  }
71
77
 
72
- originBuckets[bucket] = originBuckets[bucket] || []
73
- originBuckets[bucket].push(asset)
78
+ originBuckets[bucket] = originBuckets[bucket] || [];
79
+ originBuckets[bucket].push(asset);
74
80
  }
75
81
 
76
82
  // wait for fastly purge
77
83
  setTimeout(async () => {
78
84
  for (const bucket of Object.keys(originBuckets)) {
79
85
  for (const pop of ORIGIN_POPS[bucket]) {
80
- if (pop) { // prevent np when the pop is not defined
81
- await fetchAssets(pop, originBuckets[bucket], db)
86
+ if (pop) {
87
+ // prevent np when the pop is not defined
88
+ await fetchAssets(pop, originBuckets[bucket], database);
82
89
  }
83
90
  }
84
91
  }
85
- }, 5000)
86
- }
92
+ }, 5000);
93
+ };
@@ -712,5 +712,5 @@
712
712
  ]
713
713
  }
714
714
  },
715
- "version": "2.69.1"
715
+ "version": "2.70.0"
716
716
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@speedkit/cli",
3
3
  "description": "Speed Kit CLI",
4
- "version": "2.69.1",
4
+ "version": "2.70.0",
5
5
  "author": {
6
6
  "name": "Baqend.com",
7
7
  "email": "info@baqend.com"
@@ -69,9 +69,9 @@
69
69
  "@inquirer/prompts": "^3.3.2",
70
70
  "@oclif/core": "^3.23",
71
71
  "@oclif/plugin-autocomplete": "^3.0",
72
- "@oclif/plugin-help": "^6.2.16",
73
- "@oclif/plugin-not-found": "^3.2.25",
74
- "@oclif/plugin-warn-if-update-available": "^3.1.21",
72
+ "@oclif/plugin-help": "^6.2.19",
73
+ "@oclif/plugin-not-found": "^3.2.30",
74
+ "@oclif/plugin-warn-if-update-available": "^3.1.26",
75
75
  "baqend": "^4.1.0",
76
76
  "chalk": "^4.1.2",
77
77
  "clipboardy-cjs": "^3.0.0",
@@ -81,7 +81,7 @@
81
81
  "dom-serializer": "2.0.0",
82
82
  "domhandler": "5.0.3",
83
83
  "domutils": "^3.1",
84
- "dotenv": "^16.4.5",
84
+ "dotenv": "^16.4.7",
85
85
  "extract-zip": "^2.0.1",
86
86
  "fs-extra": "^11.2.0",
87
87
  "handlebars": "^4.7.8",
@@ -123,7 +123,7 @@
123
123
  "mocha": "^10.1.0",
124
124
  "mocha-junit-reporter": "^2.2.1",
125
125
  "mock-fs": "^5.2.0",
126
- "nock": "^13.5.5",
126
+ "nock": "^13.5.6",
127
127
  "nyc": "^15.1.0",
128
128
  "oclif": "^4.8.8",
129
129
  "shx": "^0.3.4",