@speedkit/cli 2.47.0 → 2.48.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,19 @@
1
+ # [2.48.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.47.1...v2.48.0) (2024-07-26)
2
+
3
+
4
+ ### Features
5
+
6
+ * **config-wizard:** add support for scrapingbee ([c8fe5a1](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/c8fe5a1b45c06fc373cbf868ef6fb6204cadc0fc))
7
+ * **config-wizard:** add support for scrapingbee ([1286550](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/1286550a41fd48a0effee9c4c8f5b424dc8cb864))
8
+ * **config-wizard:** add support for scrapingbee ([f1a6ba3](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/f1a6ba3dcf42ee5715943e5c7a923464c81b77db))
9
+
10
+ ## [2.47.1](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.47.0...v2.47.1) (2024-07-24)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * **diff-service:** resolve escaped spaces issue for macos ([1cf2d57](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/1cf2d577ab4ba15f3bd53394d95b2fa53e28fcd5))
16
+
1
17
  # [2.47.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.46.0...v2.47.0) (2024-07-24)
2
18
 
3
19
 
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.47.0 linux-x64 node-v20.15.1
24
+ @speedkit/cli/2.48.0 linux-x64 node-v20.16.0
25
25
  $ sk --help [COMMAND]
26
26
  USAGE
27
27
  $ sk COMMAND
@@ -39,3 +39,9 @@ export declare function transformNoValueParameters(url: URL, manipulatedUrl: URL
39
39
  * @returns The normalized URL.
40
40
  */
41
41
  export declare function normalize(urlString: string, withParameterSorting: boolean): string;
42
+ /**
43
+ * Remove backslashes before spaces from given string.
44
+ *
45
+ * @param string_
46
+ */
47
+ export declare function unescapeSpaces(string_: string): string;
@@ -4,6 +4,7 @@ exports.sortParameters = sortParameters;
4
4
  exports.convertNotEncodedParameters = convertNotEncodedParameters;
5
5
  exports.transformNoValueParameters = transformNoValueParameters;
6
6
  exports.normalize = normalize;
7
+ exports.unescapeSpaces = unescapeSpaces;
7
8
  const node_url_1 = require("node:url");
8
9
  /**
9
10
  * Sorts all urls params manually.
@@ -113,3 +114,11 @@ function normalize(urlString, withParameterSorting) {
113
114
  transformNoValueParameters(new node_url_1.URL(urlString), url);
114
115
  return url.toString();
115
116
  }
117
+ /**
118
+ * Remove backslashes before spaces from given string.
119
+ *
120
+ * @param string_
121
+ */
122
+ function unescapeSpaces(string_) {
123
+ return string_.replaceAll("\\ ", " ");
124
+ }
@@ -0,0 +1 @@
1
+ export declare const DEFAULT_INTELLIJ_IDEA_PATH_MACOS = "/Applications/IntelliJ IDEA.app/Contents/MacOS";
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_INTELLIJ_IDEA_PATH_MACOS = void 0;
4
+ exports.DEFAULT_INTELLIJ_IDEA_PATH_MACOS = "/Applications/IntelliJ IDEA.app/Contents/MacOS";
@@ -32,6 +32,7 @@ export interface CustomerConfigSettings {
32
32
  shadowDomCustomElementPrefix?: string;
33
33
  activateRumTracking?: boolean;
34
34
  useGATracking?: boolean;
35
+ useScrapingBee?: boolean;
35
36
  withGoogleOptimize?: boolean;
36
37
  activateCfRocketLoaderWorkaround?: boolean;
37
38
  isShopify?: boolean;
@@ -24,5 +24,6 @@ export declare class CustomerConfigService {
24
24
  private downloadAndSaveFile;
25
25
  private getConfigSettings;
26
26
  handleDocumentHandler({ addPreRendering }: CustomerConfigSettings): Promise<void>;
27
+ logWarnings(configSettings: CustomerConfigSettings): Promise<void>;
27
28
  generateConfig(): Promise<void>;
28
29
  }
@@ -161,7 +161,7 @@ class CustomerConfigService {
161
161
  }
162
162
  }
163
163
  async getConfigSettings() {
164
- let { production, staging, subRouteScope, includeServiceWorker, activateImageOptimisation, removeLazyLoading, addPreRendering, supportShadowDomInPreRendering, shadowDomCustomElementPrefix, activateRumTracking, useGATracking, withGoogleOptimize, activateCfRocketLoaderWorkaround, isShopify, isShopware, isSalesforce, isPlentymarkets, shopifyId, } = {};
164
+ let { production, staging, subRouteScope, includeServiceWorker, activateImageOptimisation, removeLazyLoading, addPreRendering, supportShadowDomInPreRendering, shadowDomCustomElementPrefix, activateRumTracking, useGATracking, useScrapingBee, withGoogleOptimize, activateCfRocketLoaderWorkaround, isShopify, isShopware, isSalesforce, isPlentymarkets, shopifyId, } = {};
165
165
  this.appName = await this.cli.prompt(`Enter SK App Name:`, {
166
166
  validator: (input) => /^[\da-z]+(?:-[\da-z]+)*$/.test(input) ? "" : "No valid kebab-case",
167
167
  defaultAnswer: this.appName,
@@ -214,6 +214,7 @@ class CustomerConfigService {
214
214
  shadowDomCustomElementPrefix = await this.cli.prompt("Please specify the prefix of the custom elements used (e.g. o2 uses tef-): ", { defaultAnswer: "custom-" });
215
215
  }
216
216
  }
217
+ useScrapingBee = await this.cli.confirm("Do customer responses differ geo-location-based (ScrapingBee will be needed to fetch documents)?", false);
217
218
  activateRumTracking = await this.cli.confirm("Activate RUM Tracking?");
218
219
  if (activateRumTracking && !isShopify) {
219
220
  useGATracking = await this.cli.confirm("Add Tracking based on Google Analytics' DataLayer?");
@@ -235,6 +236,7 @@ class CustomerConfigService {
235
236
  shadowDomCustomElementPrefix,
236
237
  activateRumTracking,
237
238
  useGATracking,
239
+ useScrapingBee,
238
240
  withGoogleOptimize,
239
241
  activateCfRocketLoaderWorkaround,
240
242
  isShopify,
@@ -269,6 +271,16 @@ class CustomerConfigService {
269
271
  `);
270
272
  }
271
273
  }
274
+ async logWarnings(configSettings) {
275
+ if (configSettings.useScrapingBee) {
276
+ this.cli.writeWarning(`
277
+ ⚠️ MANUAL ACTION NEEDED ⚠️
278
+
279
+ Remember to set it up the variation in the orestes config.
280
+ See more info here: https://www.notion.so/baqend/How-to-use-Scraping-Bee-in-the-orestes-config-b94d8571e1a04c9e8310810df55a9a62
281
+ `);
282
+ }
283
+ }
272
284
  async generateConfig() {
273
285
  this.cli.write("\nLet's generate a config...\n");
274
286
  const configSettings = await this.getConfigSettings();
@@ -278,6 +290,7 @@ class CustomerConfigService {
278
290
  }
279
291
  await this.compileHandlebarsFiles(configSettings);
280
292
  await this.handleDocumentHandler(configSettings);
293
+ await this.logWarnings(configSettings);
281
294
  this.cli.writeSuccess("\nConfig generation completed 👏\n");
282
295
  }
283
296
  }
@@ -74,6 +74,18 @@
74
74
  split: CURRENT_HOST_CONFIG.split,
75
75
  splitTestId: CURRENT_HOST_CONFIG.splitTestId,
76
76
  disabled: !CURRENT_HOST_CONFIG.enabled{{#if addPreRendering}} || isTablet(){{/if}},
77
+ {{#if useScrapingBee}}
78
+ customVariation: [
79
+ {
80
+ variationFunction: function (request, device, cookies) {
81
+ if (device === "desktop") {
82
+ return "proxycrawl";
83
+ }
84
+ return "proxycrawlmobile";
85
+ },
86
+ },
87
+ ],
88
+ {{/if}}
77
89
  enabledSites: [
78
90
  {
79
91
  pathname: [
@@ -56,6 +56,13 @@ const config = {
56
56
  return `Tablet viewport is unsupported: ${url}`;
57
57
  }
58
58
 
59
+ {{/if}}
60
+ {{#if useScrapingBee}}
61
+ // dynamically blacklist not 200 status codes from ScrapingBee
62
+ const spbStatusCode = headers["Spb-initial-status-code"];
63
+ if (spbStatusCode && spbStatusCode !== "200") {
64
+ return `initial status code unequal to 200 received from scrapingbee: ${url} ${spbStatusCode}`;
65
+ }
59
66
  {{/if}}
60
67
  return false;
61
68
  },
@@ -6,6 +6,8 @@ const node_path_1 = tslib_1.__importDefault(require("node:path"));
6
6
  const promises_1 = tslib_1.__importStar(require("node:fs/promises"));
7
7
  const node_child_process_1 = require("node:child_process");
8
8
  const file_helper_1 = require("../../helpers/file-helper");
9
+ const normalize_1 = require("../../helpers/normalize");
10
+ const os_1 = require("../../models/os");
9
11
  class DiffService {
10
12
  cli;
11
13
  diffExecutablePath;
@@ -113,10 +115,11 @@ class DiffService {
113
115
  }
114
116
  return false;
115
117
  }
116
- const isWindows = process.platform.startsWith("win");
117
118
  let ideaCommandAvailable;
118
119
  try {
119
- (0, node_child_process_1.execSync)(`idea diff "${localPath}" "${remotePath}"`);
120
+ (0, node_child_process_1.execSync)(`idea diff "${localPath}" "${remotePath}"`, {
121
+ stdio: ["pipe", "ignore", "pipe"], // prevent output of "/bin/sh: idea: command not found"
122
+ });
120
123
  ideaCommandAvailable = true;
121
124
  }
122
125
  catch {
@@ -124,17 +127,20 @@ class DiffService {
124
127
  }
125
128
  try {
126
129
  if (!ideaCommandAvailable) {
130
+ const isWindows = process.platform.startsWith("win");
127
131
  if (isWindows) {
128
132
  (0, node_child_process_1.execSync)(`"%IDEA_INITIAL_DIRECTORY%\\idea" diff ${localPath} ${remotePath}`, { stdio: "pipe" });
129
133
  }
130
134
  else {
131
- (0, node_child_process_1.execSync)(`"$IDEA_INITIAL_DIRECTORY/idea" diff ${localPath} ${remotePath}`, { stdio: "pipe" });
135
+ const ideaInitialDirectory = (0, normalize_1.unescapeSpaces)(process.env.IDEA_INITIAL_DIRECTORY ||
136
+ os_1.DEFAULT_INTELLIJ_IDEA_PATH_MACOS);
137
+ (0, node_child_process_1.execSync)(`"${ideaInitialDirectory}/idea" diff ${localPath} ${remotePath}`, { stdio: "pipe" });
132
138
  }
133
139
  }
134
140
  return false;
135
141
  }
136
142
  catch (error) {
137
- this.cli.writeError(`Error executing diff command: ${error.message}`);
143
+ this.cli.writeError(`Error executing diff command: ${error.message} (diff/diff-service)`);
138
144
  return false;
139
145
  }
140
146
  }
@@ -6,6 +6,8 @@ const fs = tslib_1.__importStar(require("node:fs/promises"));
6
6
  const node_child_process_1 = require("node:child_process");
7
7
  const node_path_1 = tslib_1.__importDefault(require("node:path"));
8
8
  const file_helper_1 = require("../helpers/file-helper");
9
+ const normalize_1 = require("../helpers/normalize");
10
+ const os_1 = require("../models/os");
9
11
  /**
10
12
  * @deprecated
11
13
  */
@@ -86,10 +88,11 @@ class DiffService {
86
88
  else if (hide) {
87
89
  return true;
88
90
  }
89
- const isWindows = process.platform.startsWith("win");
90
91
  let ideaCommandAvailable;
91
92
  try {
92
- (0, node_child_process_1.execSync)(`idea diff "${filePath1}" "${filePath2}"`, { stdio: "pipe" });
93
+ (0, node_child_process_1.execSync)(`idea diff "${filePath1}" "${filePath2}"`, {
94
+ stdio: ["pipe", "ignore", "pipe"], // prevent output of "/bin/sh: idea: command not found"
95
+ });
93
96
  ideaCommandAvailable = true;
94
97
  }
95
98
  catch {
@@ -97,16 +100,19 @@ class DiffService {
97
100
  }
98
101
  try {
99
102
  if (!ideaCommandAvailable) {
103
+ const isWindows = process.platform.startsWith("win");
100
104
  if (isWindows) {
101
105
  (0, node_child_process_1.execSync)(`"%IDEA_INITIAL_DIRECTORY%\\idea" diff ${filePath1} ${filePath2}`, { stdio: "pipe" });
102
106
  }
103
107
  else {
104
- (0, node_child_process_1.execSync)(`"$IDEA_INITIAL_DIRECTORY/idea" diff ${filePath1} ${filePath2}`, { stdio: "pipe" });
108
+ const ideaInitialDirectory = (0, normalize_1.unescapeSpaces)(process.env.IDEA_INITIAL_DIRECTORY ||
109
+ os_1.DEFAULT_INTELLIJ_IDEA_PATH_MACOS);
110
+ (0, node_child_process_1.execSync)(`"${ideaInitialDirectory}/idea" diff ${filePath1} ${filePath2}`, { stdio: "pipe" });
105
111
  }
106
112
  }
107
113
  }
108
114
  catch (error) {
109
- this.cli.writeError(`Error executing diff command: ${error.message}`);
115
+ this.cli.writeError(`Error executing diff command: ${error.message} (services/diff-service)`);
110
116
  this.cli.exit(1);
111
117
  }
112
118
  return true;
@@ -712,5 +712,5 @@
712
712
  ]
713
713
  }
714
714
  },
715
- "version": "2.47.0"
715
+ "version": "2.48.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.47.0",
4
+ "version": "2.48.0",
5
5
  "author": {
6
6
  "name": "Baqend.com",
7
7
  "email": "info@baqend.com"