@speedkit/cli 2.69.0 → 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,17 @@
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
+
8
+ ## [2.69.1](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.69.0...v2.69.1) (2024-12-11)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **axios:** remove unused axios dependency ([40f0238](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/40f023845a800667c284c63a1fafe816c3d42d12))
14
+
1
15
  # [2.69.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.68.0...v2.69.0) (2024-12-11)
2
16
 
3
17
 
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.0 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
 
@@ -21,7 +21,6 @@ export declare class CustomerConfigService {
21
21
  private compileHandlebarsFiles;
22
22
  private getEnvironmentConfig;
23
23
  private shouldFileBeOverwritten;
24
- private downloadAndSaveFile;
25
24
  private getConfigSettings;
26
25
  logWarnings(configSettings: CustomerConfigSettings): Promise<void>;
27
26
  generateConfig(): Promise<void>;
@@ -5,7 +5,6 @@ const tslib_1 = require("tslib");
5
5
  const fs = tslib_1.__importStar(require("node:fs"));
6
6
  const path = tslib_1.__importStar(require("node:path"));
7
7
  const Handlebars = tslib_1.__importStar(require("handlebars"));
8
- const axios_1 = tslib_1.__importDefault(require("axios"));
9
8
  const cli_1 = require("../cli");
10
9
  const customer_config_service_model_1 = require("./customer-config-service-model");
11
10
  class CustomerConfigService {
@@ -136,30 +135,6 @@ class CustomerConfigService {
136
135
  }
137
136
  return true;
138
137
  }
139
- async downloadAndSaveFile(url, outputFilePath) {
140
- this.cli.startAction(`Adding ${path.basename(outputFilePath)}`);
141
- try {
142
- if (!(await this.shouldFileBeOverwritten(outputFilePath))) {
143
- this.cli.endAction(cli_1.CliActionStatus.SKIPPED);
144
- return;
145
- }
146
- const response = await axios_1.default.get(url, { responseType: "text" });
147
- const date = new Date();
148
- const day = String(date.getDate()).padStart(2, "0");
149
- const month = String(date.getMonth() + 1).padStart(2, "0"); // Months are 0-indexed
150
- const year = date.getFullYear();
151
- const time = date.toLocaleTimeString("de-DE");
152
- const formattedDate = `${day}.${month}.${year}, ${time}`;
153
- // Add timestamp banner to the file
154
- const banner = `/**\n * Downloaded from:\n * ${url}\n * \n * Date: ${formattedDate}\n */\n\n`;
155
- const contentWithBanner = banner + response.data;
156
- fs.writeFileSync(outputFilePath, contentWithBanner);
157
- this.cli.endAction(cli_1.CliActionStatus.COMPLETED);
158
- }
159
- catch {
160
- this.cli.endAction(cli_1.CliActionStatus.FAILED);
161
- }
162
- }
163
138
  async getConfigSettings() {
164
139
  let { production, staging, subRouteScope, includeServiceWorker, activateImageOptimisation, removeLazyLoading, addPreRendering, supportShadowDomInPreRendering, shadowDomCustomElementPrefix, activateRumTracking, useGATracking, useScrapingBee, withGoogleOptimize, activateCfRocketLoaderWorkaround, hasSoftNavigations, isShopify, isShopware, isSalesforce, isPlentymarkets, shopifyId, } = {};
165
140
  this.appName = await this.cli.prompt(`Enter SK App Name:`, {
@@ -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.0"
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.0",
4
+ "version": "2.70.0",
5
5
  "author": {
6
6
  "name": "Baqend.com",
7
7
  "email": "info@baqend.com"
@@ -69,11 +69,10 @@
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",
75
- "axios": "^1.6",
76
- "baqend": "^3.4",
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
+ "baqend": "^4.1.0",
77
76
  "chalk": "^4.1.2",
78
77
  "clipboardy-cjs": "^3.0.0",
79
78
  "css-select": "5.1.0",
@@ -82,7 +81,7 @@
82
81
  "dom-serializer": "2.0.0",
83
82
  "domhandler": "5.0.3",
84
83
  "domutils": "^3.1",
85
- "dotenv": "^16.4.5",
84
+ "dotenv": "^16.4.7",
86
85
  "extract-zip": "^2.0.1",
87
86
  "fs-extra": "^11.2.0",
88
87
  "handlebars": "^4.7.8",
@@ -124,7 +123,7 @@
124
123
  "mocha": "^10.1.0",
125
124
  "mocha-junit-reporter": "^2.2.1",
126
125
  "mock-fs": "^5.2.0",
127
- "nock": "^13.5.5",
126
+ "nock": "^13.5.6",
128
127
  "nyc": "^15.1.0",
129
128
  "oclif": "^4.8.8",
130
129
  "shx": "^0.3.4",