@speedkit/cli 2.18.0 → 2.19.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.
Files changed (122) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +36 -5
  3. package/dist/commands/build-parameter-query.js +5 -5
  4. package/dist/commands/build-prewarm-query.js +4 -4
  5. package/dist/commands/{param-diff.d.ts → diff-url-parameters.d.ts} +3 -1
  6. package/dist/commands/{param-diff.js → diff-url-parameters.js} +26 -24
  7. package/dist/commands/find-pops.js +9 -9
  8. package/dist/commands/generate-customer-config.d.ts +1 -1
  9. package/dist/commands/generate-customer-config.js +7 -7
  10. package/dist/commands/generate-pop-config.js +2 -2
  11. package/dist/commands/login.js +5 -4
  12. package/dist/commands/pop-prewarm.d.ts +3 -3
  13. package/dist/commands/pop-prewarm.js +19 -16
  14. package/dist/commands/prewarm.js +10 -10
  15. package/dist/commands/wpt-launcher.d.ts +1 -1
  16. package/dist/commands/wpt-launcher.js +9 -9
  17. package/dist/helpers/build-query-helper.d.ts +3 -3
  18. package/dist/helpers/build-query-helper.js +70 -69
  19. package/dist/helpers/cli-config.js +6 -5
  20. package/dist/helpers/{CustomerConfig.d.ts → customer-config.d.ts} +6 -6
  21. package/dist/helpers/{CustomerConfig.js → customer-config.js} +39 -39
  22. package/dist/helpers/file-helper.d.ts +1 -1
  23. package/dist/helpers/file-helper.js +5 -5
  24. package/dist/helpers/{getChromePath.js → get-chrome-path.js} +8 -8
  25. package/dist/helpers/get-parsed-config.d.ts +1 -1
  26. package/dist/helpers/get-parsed-config.js +7 -7
  27. package/dist/helpers/is-directory.d.ts +1 -0
  28. package/dist/helpers/{isDirectory.js → is-directory.js} +6 -6
  29. package/dist/helpers/{isExecutable.js → is-executable.js} +3 -3
  30. package/dist/helpers/{isFile.js → is-file.js} +4 -4
  31. package/dist/helpers/logging-helper.d.ts +3 -3
  32. package/dist/helpers/logging-helper.js +6 -6
  33. package/dist/helpers/normalize.d.ts +6 -6
  34. package/dist/helpers/normalize.js +35 -33
  35. package/dist/helpers/safe.d.ts +1 -1
  36. package/dist/helpers/safe.js +12 -12
  37. package/dist/helpers/{speedKitRuleToRegExp.js → speed-kit-rule-to-reg-exp.js} +3 -3
  38. package/dist/helpers/{watchFiles.js → watch-files.js} +2 -2
  39. package/dist/models/cli-parameters.d.ts +3 -3
  40. package/dist/models/cli-parameters.js +3 -3
  41. package/dist/services/athena/athena-service.js +2 -2
  42. package/dist/services/bundler/bundle-service.js +14 -14
  43. package/dist/services/cli/cli-service.js +8 -4
  44. package/dist/services/cli/hooks.js +3 -3
  45. package/dist/services/config-api/client.js +7 -6
  46. package/dist/services/config-api/factory/config-api-service-factory.js +4 -4
  47. package/dist/services/config-api/factory/entity-manager-factory.js +1 -1
  48. package/dist/services/config-api-service.d.ts +1 -1
  49. package/dist/services/config-api-service.js +7 -7
  50. package/dist/services/customer-config/customer-config-service-context.d.ts +2 -2
  51. package/dist/services/customer-config/customer-config-service-context.js +4 -4
  52. package/dist/services/customer-config/customer-config-service.js +45 -44
  53. package/dist/services/deploy/builder/install-resource-builder.d.ts +2 -2
  54. package/dist/services/deploy/builder/install-resource-builder.js +7 -7
  55. package/dist/services/deploy/checks/post-deploy/revalidated-module-check.js +1 -1
  56. package/dist/services/deploy/checks/post-deploy/save-files-check.js +4 -4
  57. package/dist/services/deploy/deploy-service.js +2 -4
  58. package/dist/services/deploy/error/create-find-temporary-directory-error.d.ts +4 -0
  59. package/dist/services/deploy/error/{create-find-temp-directory-error.js → create-find-temporary-directory-error.js} +2 -2
  60. package/dist/services/deploy/handler/customer-config-handler.js +1 -1
  61. package/dist/services/deploy/handler/install-resource-handler.js +8 -11
  62. package/dist/services/deploy/handler/install-resource-modifier/deleted-file-check.js +2 -2
  63. package/dist/services/deploy/handler/module-handler.js +8 -8
  64. package/dist/services/deploy/handler/server-config-handler.js +4 -4
  65. package/dist/services/diff/diff-service.d.ts +2 -2
  66. package/dist/services/diff/diff-service.js +22 -22
  67. package/dist/services/diff-service.d.ts +1 -1
  68. package/dist/services/diff-service.js +13 -13
  69. package/dist/services/document-handler-runtime/context/document-handler-runtime-context.js +10 -8
  70. package/dist/services/document-handler-runtime/document-handler-runtime-service.js +10 -10
  71. package/dist/services/document-handler-runtime/document-handler-server.js +12 -12
  72. package/dist/services/document-handler-runtime/factory/document-handler-runtime-service-factory.js +2 -2
  73. package/dist/services/document-handler-runtime/interface/template-interface.d.ts +2 -2
  74. package/dist/services/document-handler-runtime/interface/{template-param-interface.d.ts → template-parameter-interface.d.ts} +1 -1
  75. package/dist/services/document-handler-runtime/templates/abstract-template.d.ts +2 -2
  76. package/dist/services/document-handler-runtime/templates/abstract-template.js +3 -3
  77. package/dist/services/error-handling/factory/error-handling-factory.d.ts +1 -4
  78. package/dist/services/error-handling/factory/error-handling-factory.js +2 -1
  79. package/dist/services/integration-api/factory/integration-api-service-factory.js +1 -1
  80. package/dist/services/integration-api/file-list.js +4 -3
  81. package/dist/services/integration-api/file-reader.d.ts +1 -1
  82. package/dist/services/integration-api/file-reader.js +29 -26
  83. package/dist/services/integration-api/file-writer.js +3 -3
  84. package/dist/services/integration-api/handler/file-handler.js +1 -1
  85. package/dist/services/integration-api/handler/install-resource-handler.js +1 -1
  86. package/dist/services/integration-api/handler/module-handler.js +1 -1
  87. package/dist/services/integration-api/handler/server-config-handler.js +1 -1
  88. package/dist/services/integration-api/integration-api-service.js +2 -3
  89. package/dist/services/integration-api/struct/customer-config.d.ts +1 -1
  90. package/dist/services/integration-api/struct/customer-config.js +4 -4
  91. package/dist/services/integration-api/struct/file.js +1 -1
  92. package/dist/services/integration-api/validator/customer-config-validator.js +2 -2
  93. package/dist/services/integration-api/validator/mandatory-files-validator.js +7 -6
  94. package/dist/services/integration-api/virtual/external-recipe.js +2 -1
  95. package/dist/services/onboarding/browser/baqend-response.js +1 -2
  96. package/dist/services/onboarding/config-renderer/speed-kit-install-context.js +1 -1
  97. package/dist/services/onboarding/dashboard/index.d.ts +3 -3
  98. package/dist/services/onboarding/dashboard/index.js +12 -12
  99. package/dist/services/onboarding/dashboard/{param-query-builder.d.ts → parameter-query-builder.d.ts} +1 -1
  100. package/dist/services/onboarding/dashboard/{param-query-builder.js → parameter-query-builder.js} +6 -6
  101. package/dist/services/onboarding/dashboard/request-diff-service.js +24 -22
  102. package/dist/services/onboarding/fetch-events/customer-domain-document-response.js +8 -8
  103. package/dist/services/onboarding/fetch-events/speed-kit-asset-request.js +7 -7
  104. package/dist/services/onboarding/onboarding-model.js +4 -4
  105. package/dist/services/onboarding/onboarding-service-factory.js +3 -3
  106. package/dist/services/onboarding/onboarding-service.js +2 -1
  107. package/dist/services/onboarding/todo-collector.js +1 -1
  108. package/dist/services/prewarm-service.d.ts +1 -1
  109. package/dist/services/prewarm-service.js +8 -7
  110. package/dist/services/pull/pull-service.js +2 -2
  111. package/oclif.manifest.json +45 -42
  112. package/package.json +2 -1
  113. package/dist/helpers/isDirectory.d.ts +0 -1
  114. package/dist/services/context/app-context.d.ts +0 -1
  115. package/dist/services/deploy/error/create-find-temp-directory-error.d.ts +0 -4
  116. package/dist/services/document-handler-runtime/interface/template-param-interface.js +0 -2
  117. /package/dist/helpers/{getChromePath.d.ts → get-chrome-path.d.ts} +0 -0
  118. /package/dist/helpers/{isExecutable.d.ts → is-executable.d.ts} +0 -0
  119. /package/dist/helpers/{isFile.d.ts → is-file.d.ts} +0 -0
  120. /package/dist/helpers/{speedKitRuleToRegExp.d.ts → speed-kit-rule-to-reg-exp.d.ts} +0 -0
  121. /package/dist/helpers/{watchFiles.d.ts → watch-files.d.ts} +0 -0
  122. /package/dist/services/{context/app-context.js → document-handler-runtime/interface/template-parameter-interface.js} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [2.19.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.18.0...v2.19.0) (2024-04-09)
2
+
3
+
4
+ ### Features
5
+
6
+ * add eslint plugin unicorn ([5fec1f7](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/5fec1f7c648329804f51121abc1ff2fa26f5583d))
7
+
1
8
  # [2.18.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.17.0...v2.18.0) (2024-04-08)
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.18.0 linux-x64 node-v20.12.1
24
+ @speedkit/cli/2.19.0 linux-x64 node-v20.12.1
25
25
  $ sk --help [COMMAND]
26
26
  USAGE
27
27
  $ sk COMMAND
@@ -69,6 +69,7 @@ By either...
69
69
  * [`sk build-parameter-query CUSTOMERPATH`](#sk-build-parameter-query-customerpath)
70
70
  * [`sk build-prewarm-query CUSTOMERPATH`](#sk-build-prewarm-query-customerpath)
71
71
  * [`sk deploy CUSTOMERPATH`](#sk-deploy-customerpath)
72
+ * [`sk diff-url-parameters PAGEURL`](#sk-diff-url-parameters-pageurl)
72
73
  * [`sk document-handler CUSTOMERPATH`](#sk-document-handler-customerpath)
73
74
  * [`sk find-pops APP`](#sk-find-pops-app)
74
75
  * [`sk generate-customer-config`](#sk-generate-customer-config)
@@ -185,6 +186,32 @@ EXAMPLES
185
186
  $ sk deploy customer/decathlon.de -c production -t someSlackToken -a dynamic,SpeedKit -d
186
187
  ```
187
188
 
189
+ ## `sk diff-url-parameters PAGEURL`
190
+
191
+ Shows difference in documents with query parameters on/off
192
+
193
+ ```
194
+ USAGE
195
+ $ sk diff-url-parameters PAGEURL [-h]
196
+
197
+ ARGUMENTS
198
+ PAGEURL Link of the page
199
+
200
+ FLAGS
201
+ -h, --hideDiff Hide the code diff in IDE code diff window
202
+
203
+ DESCRIPTION
204
+ Shows difference in documents with query parameters on/off
205
+
206
+ ALIASES
207
+ $ sk param-diff
208
+
209
+ EXAMPLES
210
+ $ sk prewarm <pageUrl> -h
211
+
212
+ $ sk prewarm https://www.decathlon.de/ -h
213
+ ```
214
+
188
215
  ## `sk document-handler CUSTOMERPATH`
189
216
 
190
217
  Creates testable documentHandler in folder {CUSTOMER_PATH}/test/src/
@@ -241,15 +268,16 @@ USAGE
241
268
  $ sk generate-customer-config [-a <value>] [-d <value>]
242
269
 
243
270
  FLAGS
244
- -a, --app=<value> The SK app name which is also being used the config output directory name (kebab-case)
245
- -d, --customersDir=<value> Name of the sk-onboarding directory where all customer configs are being stored (default:
246
- "customers")
271
+ -a, --app=<value> The SK app name which is also being used the config output directory name
272
+ (kebab-case)
273
+ -d, --customersDirectory=<value> Name of the sk-onboarding directory where all customer configs are being stored
274
+ (default: "customers")
247
275
 
248
276
  DESCRIPTION
249
277
  Generates a customer config guided by a wizard 🧙‍
250
278
 
251
279
  EXAMPLES
252
- $ sk generate-customer-config -a <app> -d <customersDir>
280
+ $ sk generate-customer-config -a <app> -d <customersDirectory>
253
281
 
254
282
  $ sk generate-customer-config -a decathlon -d customers
255
283
  ```
@@ -373,6 +401,9 @@ FLAGS
373
401
  DESCRIPTION
374
402
  Shows difference in documents with query parameters on/off
375
403
 
404
+ ALIASES
405
+ $ sk param-diff
406
+
376
407
  EXAMPLES
377
408
  $ sk prewarm <pageUrl> -h
378
409
 
@@ -4,7 +4,7 @@ const tslib_1 = require("tslib");
4
4
  const core_1 = require("@oclif/core");
5
5
  const chalk_1 = tslib_1.__importDefault(require("chalk"));
6
6
  const clipboardy_cjs_1 = tslib_1.__importDefault(require("clipboardy-cjs"));
7
- const CustomerConfig_1 = require("../helpers/CustomerConfig");
7
+ const customer_config_1 = require("../helpers/customer-config");
8
8
  const build_query_helper_1 = require("../helpers/build-query-helper");
9
9
  const get_parsed_config_1 = require("../helpers/get-parsed-config");
10
10
  const logging_helper_1 = require("../helpers/logging-helper");
@@ -65,12 +65,12 @@ order by potentialGain desc, cachedUrls desc, PIs desc`;
65
65
  const { args: { customerPath }, flags: { configName }, } = await this.parse(BuildParameterQuery);
66
66
  core_1.ux.action.start("Building parameter query");
67
67
  try {
68
- const { app, config } = await CustomerConfig_1.CustomerConfig.loadCustomer(customerPath, configName);
68
+ const { app, config } = await customer_config_1.CustomerConfig.loadCustomer(customerPath, configName);
69
69
  const parsedConfig = await (0, get_parsed_config_1.getParsedConfig)(config);
70
- const params = (0, build_query_helper_1.getStrippedParams)(parsedConfig);
70
+ const parameters = (0, build_query_helper_1.getStrippedParameters)(parsedConfig);
71
71
  const skConfigVersion = (0, get_parsed_config_1.getSpeedKitConfigVersion)(parsedConfig);
72
- const parameterFilter = (0, build_query_helper_1.getParameterFilter)(params, skConfigVersion);
73
- const parameterReplaceFilter = (0, build_query_helper_1.getParameterReplaceFilter)(params, skConfigVersion);
72
+ const parameterFilter = (0, build_query_helper_1.getParameterFilter)(parameters, skConfigVersion);
73
+ const parameterReplaceFilter = (0, build_query_helper_1.getParameterReplaceFilter)(parameters, skConfigVersion);
74
74
  const whitelistedFilter = (0, build_query_helper_1.getWhitelistedFilter)(parsedConfig);
75
75
  const blacklistedFilter = (0, build_query_helper_1.getBlacklistedFilter)(parsedConfig);
76
76
  const result = this.buildParameterQuery(app || parsedConfig.appName, parameterFilter, whitelistedFilter, blacklistedFilter, parameterReplaceFilter);
@@ -4,7 +4,7 @@ const tslib_1 = require("tslib");
4
4
  const core_1 = require("@oclif/core");
5
5
  const chalk_1 = tslib_1.__importDefault(require("chalk"));
6
6
  const clipboardy_cjs_1 = tslib_1.__importDefault(require("clipboardy-cjs"));
7
- const CustomerConfig_1 = require("../helpers/CustomerConfig");
7
+ const customer_config_1 = require("../helpers/customer-config");
8
8
  const build_query_helper_1 = require("../helpers/build-query-helper");
9
9
  const get_parsed_config_1 = require("../helpers/get-parsed-config");
10
10
  const logging_helper_1 = require("../helpers/logging-helper");
@@ -40,10 +40,10 @@ order by count(*) desc`;
40
40
  const { args: { customerPath }, flags: { configName }, } = await this.parse(BuildPrewarmQuery);
41
41
  core_1.ux.action.start("Building pre-warm query");
42
42
  try {
43
- const { app, config } = await CustomerConfig_1.CustomerConfig.loadCustomer(customerPath, configName);
43
+ const { app, config } = await customer_config_1.CustomerConfig.loadCustomer(customerPath, configName);
44
44
  const parsedConfig = await (0, get_parsed_config_1.getParsedConfig)(config);
45
- const params = (0, build_query_helper_1.getStrippedParams)(parsedConfig);
46
- const parameterReplaceFilter = (0, build_query_helper_1.getParameterReplaceFilter)(params, (0, get_parsed_config_1.getSpeedKitConfigVersion)(parsedConfig));
45
+ const parameters = (0, build_query_helper_1.getStrippedParameters)(parsedConfig);
46
+ const parameterReplaceFilter = (0, build_query_helper_1.getParameterReplaceFilter)(parameters, (0, get_parsed_config_1.getSpeedKitConfigVersion)(parsedConfig));
47
47
  const whitelistedFilter = (0, build_query_helper_1.getWhitelistedFilter)(parsedConfig);
48
48
  const blacklistedFilter = (0, build_query_helper_1.getBlacklistedFilter)(parsedConfig);
49
49
  const result = this.buildPrewarmQuery(app || parsedConfig.appName, whitelistedFilter, blacklistedFilter, parameterReplaceFilter);
@@ -1,8 +1,10 @@
1
1
  import { Config, Command } from "@oclif/core";
2
2
  import { CliService } from "../services/cli";
3
- export default class ParamDiff extends Command {
3
+ export default class DiffUrlParameters extends Command {
4
4
  cli: CliService;
5
5
  static description: string;
6
+ static aliases: string[];
7
+ static deprecateAliases: boolean;
6
8
  static args: {
7
9
  pageUrl: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
8
10
  };
@@ -5,12 +5,14 @@ const core_1 = require("@oclif/core");
5
5
  const scrape_1 = tslib_1.__importDefault(require("../helpers/scrape"));
6
6
  const cli_parameters_1 = require("../models/cli-parameters");
7
7
  const cli_1 = require("../services/cli");
8
- const url = tslib_1.__importStar(require("url"));
8
+ const url = tslib_1.__importStar(require("node:url"));
9
9
  const diff_1 = require("../services/diff");
10
10
  const cli_config_1 = require("../helpers/cli-config");
11
- class ParamDiff extends core_1.Command {
11
+ class DiffUrlParameters extends core_1.Command {
12
12
  cli;
13
13
  static description = "Shows difference in documents with query parameters on/off";
14
+ static aliases = ["param-diff"];
15
+ static deprecateAliases = true;
14
16
  static args = {
15
17
  [cli_parameters_1.CLIParameters.PageUrl]: core_1.Args.string({
16
18
  name: cli_parameters_1.CLIParameters.PageUrl,
@@ -39,32 +41,32 @@ class ParamDiff extends core_1.Command {
39
41
  this.cli.exit(1);
40
42
  }
41
43
  async run() {
42
- const { args, flags } = await this.parse(ParamDiff);
44
+ const { args, flags } = await this.parse(DiffUrlParameters);
43
45
  const { pageUrl: originalUrl } = args;
44
46
  const originalData = await (0, scrape_1.default)(originalUrl);
45
47
  if (!originalData) {
46
48
  this.logError("Failed to fetch original document");
47
49
  }
48
50
  const parsedUrl = url.parse(originalUrl, true);
49
- const withoutAnyParamsUrl = url.format({
51
+ const withoutAnyParametersUrl = url.format({
50
52
  protocol: parsedUrl.protocol,
51
53
  host: parsedUrl.host,
52
54
  pathname: parsedUrl.pathname,
53
55
  });
54
- const withoutAnyParamsData = await (0, scrape_1.default)(withoutAnyParamsUrl);
55
- if (!withoutAnyParamsData) {
56
+ const withoutAnyParametersData = await (0, scrape_1.default)(withoutAnyParametersUrl);
57
+ if (!withoutAnyParametersData) {
56
58
  this.logError("Failed to fetch document without any params");
57
59
  }
58
60
  const userConfig = new cli_config_1.CliConfig(this.config).load();
59
61
  const context = new diff_1.DiffContext(userConfig.diffExec, userConfig.diffExecTemplate);
60
62
  const diffService = new diff_1.DiffServiceFactory(context).getService();
61
63
  const originalFilePath = await diffService.writeContentToTemporalFile("original.html", originalData);
62
- const withoutAnyParamsFilePath = await diffService.writeContentToTemporalFile("without-any-params.html", withoutAnyParamsData);
64
+ const withoutAnyParametersFilePath = await diffService.writeContentToTemporalFile("without-any-params.html", withoutAnyParametersData);
63
65
  this.cli.spacer();
64
66
  this.cli.write(`Checking any parameter...`);
65
67
  this.cli.write(`- with: ${originalUrl}`);
66
- this.cli.write(`- without: ${withoutAnyParamsUrl}`);
67
- const isEqual = await diffService.executeDiff(originalFilePath, withoutAnyParamsFilePath, flags.hideDiff);
68
+ this.cli.write(`- without: ${withoutAnyParametersUrl}`);
69
+ const isEqual = await diffService.executeDiff(originalFilePath, withoutAnyParametersFilePath, flags.hideDiff);
68
70
  if (isEqual) {
69
71
  this.cli.writeSuccess(`✅ No diff found`);
70
72
  return;
@@ -74,28 +76,28 @@ class ParamDiff extends core_1.Command {
74
76
  // there's a difference in the general check, do a detailed check:
75
77
  if (Object.keys(parsedUrl.query).length === 1)
76
78
  return;
77
- for (const param in parsedUrl.query) {
78
- const withoutCurrentParamQuery = { ...parsedUrl.query };
79
- delete withoutCurrentParamQuery[param]; // Remove the current parameter
80
- const withoutCurrentParamUrl = url.format({
79
+ for (const parameter in parsedUrl.query) {
80
+ const withoutCurrentParameterQuery = { ...parsedUrl.query };
81
+ delete withoutCurrentParameterQuery[parameter]; // Remove the current parameter
82
+ const withoutCurrentParameterUrl = url.format({
81
83
  protocol: parsedUrl.protocol,
82
84
  host: parsedUrl.host,
83
85
  pathname: parsedUrl.pathname,
84
- query: withoutCurrentParamQuery,
86
+ query: withoutCurrentParameterQuery,
85
87
  });
86
- const withoutCurrentParamData = await (0, scrape_1.default)(withoutCurrentParamUrl);
87
- if (!withoutCurrentParamData) {
88
- this.logError(`Failed to fetch document without "${param}" parameter`);
88
+ const withoutCurrentParameterData = await (0, scrape_1.default)(withoutCurrentParameterUrl);
89
+ if (!withoutCurrentParameterData) {
90
+ this.logError(`Failed to fetch document without "${parameter}" parameter`);
89
91
  }
90
- const withoutCurrentParamFilePath = await diffService.writeContentToTemporalFile(`without-${param}-param.html`, withoutCurrentParamData);
92
+ const withoutCurrentParameterFilePath = await diffService.writeContentToTemporalFile(`without-${parameter}-param.html`, withoutCurrentParameterData);
91
93
  this.cli.spacer();
92
- this.cli.write(`Checking "${param}" parameter...`);
94
+ this.cli.write(`Checking "${parameter}" parameter...`);
93
95
  this.cli.write(`- with: ${originalUrl}`);
94
- this.cli.write(`- without: ${withoutCurrentParamUrl}`);
95
- const hasSpecificDiff = !(await diffService.executeDiff(originalFilePath, withoutCurrentParamFilePath, flags.hideDiff));
96
+ this.cli.write(`- without: ${withoutCurrentParameterUrl}`);
97
+ const hasSpecificDiff = !(await diffService.executeDiff(originalFilePath, withoutCurrentParameterFilePath, flags.hideDiff));
96
98
  if (hasSpecificDiff) {
97
- const hasDiffWithoutAnyParams = !(await diffService.executeDiff(withoutAnyParamsFilePath, withoutCurrentParamFilePath, true));
98
- if (hasDiffWithoutAnyParams) {
99
+ const hasDiffWithoutAnyParameters = !(await diffService.executeDiff(withoutAnyParametersFilePath, withoutCurrentParameterFilePath, true));
100
+ if (hasDiffWithoutAnyParameters) {
99
101
  this.cli.writeWarning("⚠️ Found diff");
100
102
  }
101
103
  else {
@@ -108,4 +110,4 @@ class ParamDiff extends core_1.Command {
108
110
  }
109
111
  }
110
112
  }
111
- exports.default = ParamDiff;
113
+ exports.default = DiffUrlParameters;
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const core_1 = require("@oclif/core");
5
- const fs_1 = tslib_1.__importDefault(require("fs"));
5
+ const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
6
6
  const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
7
- const https = tslib_1.__importStar(require("https"));
7
+ const https = tslib_1.__importStar(require("node:https"));
8
8
  const cli_1 = require("baqend/cli");
9
9
  const logging_helper_1 = require("../helpers/logging-helper");
10
10
  const cli_parameters_1 = require("../models/cli-parameters");
@@ -36,16 +36,16 @@ class FindPops extends core_1.Command {
36
36
  pops = {};
37
37
  async run() {
38
38
  const { args: { app }, flags: { ips }, } = await this.parse(FindPops);
39
- const db = await cli_1.account.login({ app });
39
+ const database = await cli_1.account.login({ app });
40
40
  const ranges = ips.split(",");
41
41
  const fetches = [];
42
42
  for (const range of ranges) {
43
- for (let i = 0; i < 255; i++) {
44
- fetches.push(this.getPop(range.replace("x", String(i)), app, db.token));
43
+ for (let index = 0; index < 255; index++) {
44
+ fetches.push(this.getPop(range.replace("x", String(index)), app, database.token));
45
45
  }
46
46
  }
47
47
  const results = await Promise.all(fetches);
48
- results.forEach((r) => {
48
+ for (const r of results) {
49
49
  if (r) {
50
50
  const airport = airports[r.pop];
51
51
  let id = r.pop;
@@ -55,8 +55,8 @@ class FindPops extends core_1.Command {
55
55
  this.pops[id] = this.pops[id] || [];
56
56
  this.pops[id].push(r.ip);
57
57
  }
58
- });
59
- fs_1.default.writeFileSync("pops.json", JSON.stringify(this.pops));
58
+ }
59
+ node_fs_1.default.writeFileSync("pops.json", JSON.stringify(this.pops));
60
60
  (0, logging_helper_1.logInfo)("List of POPs was successfully created in pops.json");
61
61
  }
62
62
  async getPop(ip, app, token) {
@@ -79,7 +79,7 @@ class FindPops extends core_1.Command {
79
79
  pop: servedBy.split("-")[2],
80
80
  };
81
81
  }
82
- catch (error) {
82
+ catch {
83
83
  return null;
84
84
  }
85
85
  }
@@ -4,7 +4,7 @@ export default class GenerateCustomerConfig extends Command {
4
4
  static examples: string[];
5
5
  static flags: {
6
6
  app: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
7
- customersDir: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
7
+ customersDirectory: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
8
8
  };
9
9
  run(): Promise<void>;
10
10
  }
@@ -6,22 +6,22 @@ const customer_config_1 = require("../services/customer-config");
6
6
  class GenerateCustomerConfig extends core_1.Command {
7
7
  static description = "Generates a customer config guided by a wizard 🧙‍";
8
8
  static examples = [
9
- `$ sk generate-customer-config -${cli_parameters_1.CLIParametersChar.AppName} <${cli_parameters_1.CLIParameters.AppName}> -${cli_parameters_1.CLIParametersChar.CustomersDir} <${cli_parameters_1.CLIParameters.CustomersDir}>`,
10
- `$ sk generate-customer-config -${cli_parameters_1.CLIParametersChar.AppName} ${cli_parameters_1.CLIParametersExample.AppName} -${cli_parameters_1.CLIParametersChar.CustomersDir} ${cli_parameters_1.CLIParametersExample.CustomersDir}`,
9
+ `$ sk generate-customer-config -${cli_parameters_1.CLIParametersChar.AppName} <${cli_parameters_1.CLIParameters.AppName}> -${cli_parameters_1.CLIParametersChar.CustomersDirectory} <${cli_parameters_1.CLIParameters.CustomersDirectory}>`,
10
+ `$ sk generate-customer-config -${cli_parameters_1.CLIParametersChar.AppName} ${cli_parameters_1.CLIParametersExample.AppName} -${cli_parameters_1.CLIParametersChar.CustomersDirectory} ${cli_parameters_1.CLIParametersExample.CustomersDirectory}`,
11
11
  ];
12
12
  static flags = {
13
13
  [cli_parameters_1.CLIParameters.AppName]: core_1.Flags.string({
14
14
  char: cli_parameters_1.CLIParametersChar.AppName,
15
15
  description: "The SK app name which is also being used the config output directory name (kebab-case)",
16
16
  }),
17
- [cli_parameters_1.CLIParameters.CustomersDir]: core_1.Flags.string({
18
- char: cli_parameters_1.CLIParametersChar.CustomersDir,
19
- description: `Name of the sk-onboarding directory where all customer configs are being stored (default: "${cli_parameters_1.CLIParametersExample.CustomersDir}")`,
17
+ [cli_parameters_1.CLIParameters.CustomersDirectory]: core_1.Flags.string({
18
+ char: cli_parameters_1.CLIParametersChar.CustomersDirectory,
19
+ description: `Name of the sk-onboarding directory where all customer configs are being stored (default: "${cli_parameters_1.CLIParametersExample.CustomersDirectory}")`,
20
20
  }),
21
21
  };
22
22
  async run() {
23
- const { flags: { app, customersDir }, } = await this.parse(GenerateCustomerConfig);
24
- const context = new customer_config_1.CustomerConfigServiceContext(app, customersDir);
23
+ const { flags: { app, customersDirectory }, } = await this.parse(GenerateCustomerConfig);
24
+ const context = new customer_config_1.CustomerConfigServiceContext(app, customersDirectory);
25
25
  const customerConfigService = await new customer_config_1.CustomerConfigServiceFactory(context).buildService();
26
26
  await customerConfigService.generateConfig();
27
27
  }
@@ -118,8 +118,8 @@ class GeneratePopConfig extends core_1.Command {
118
118
  }
119
119
  async deployPrewarmingConfig(app, config, deploy) {
120
120
  const moduleName = "speedKit.Revalidated";
121
- const db = await cli_1.account.login({ app });
122
- const configService = new config_api_service_1.default(db, app);
121
+ const database = await cli_1.account.login({ app });
122
+ const configService = new config_api_service_1.default(database, app);
123
123
  const cliService = new cli_2.CliServiceFactory().getService();
124
124
  const diffService = new diff_service_1.DiffService(cliService);
125
125
  const popPrewarmingCode = await this.createPopPrewarmingCode(config);
@@ -5,7 +5,7 @@ const core_1 = require("@oclif/core");
5
5
  const cli_1 = require("baqend/cli");
6
6
  const cli_parameters_1 = require("../models/cli-parameters");
7
7
  const node_fs_1 = require("node:fs");
8
- const path_1 = tslib_1.__importDefault(require("path"));
8
+ const node_path_1 = tslib_1.__importDefault(require("node:path"));
9
9
  class Login extends core_1.Command {
10
10
  static description = "Login to your app";
11
11
  static args = {
@@ -21,13 +21,14 @@ class Login extends core_1.Command {
21
21
  "$ sk login appName",
22
22
  ];
23
23
  async run() {
24
- const { app } = (await this.parse(Login)).args;
24
+ const parsedLogin = await this.parse(Login);
25
+ const { app } = parsedLogin.args;
25
26
  this.createLoginTokenFileIfNotExists();
26
27
  await cli_1.account.persistLogin({ app });
27
28
  }
28
29
  createLoginTokenFileIfNotExists() {
29
- if (!(0, node_fs_1.existsSync)(path_1.default.resolve(this.config.home, ".baqend"))) {
30
- (0, node_fs_1.writeFileSync)(path_1.default.resolve(this.config.home, ".baqend"), "{}");
30
+ if (!(0, node_fs_1.existsSync)(node_path_1.default.resolve(this.config.home, ".baqend"))) {
31
+ (0, node_fs_1.writeFileSync)(node_path_1.default.resolve(this.config.home, ".baqend"), "{}");
31
32
  (0, node_fs_1.writeFileSync)("~/.baqend", "{}");
32
33
  }
33
34
  }
@@ -11,7 +11,7 @@ export default class PopPrewarm extends Command {
11
11
  };
12
12
  static examples: string[];
13
13
  run(): Promise<void>;
14
- getCount(db: EntityManager, contentTypes: string[]): Promise<any>;
15
- queryDb(db: EntityManager, contentTypes: string[], lastId?: string): Promise<any>;
16
- fetchAssets(db: EntityManager, ips: string[], contentTypes: string[], app: string, progress: any, lastId?: string): Promise<any>;
14
+ getCount(database: EntityManager, contentTypes: string[]): Promise<any>;
15
+ queryDb(database: EntityManager, contentTypes: string[], lastId?: string): Promise<any>;
16
+ fetchAssets(database: EntityManager, ips: string[], contentTypes: string[], app: string, progress: any, lastId?: string): Promise<any>;
17
17
  }
@@ -33,30 +33,33 @@ class PopPrewarm extends core_1.Command {
33
33
  ];
34
34
  async run() {
35
35
  const { args: { app }, flags: { ips, contentTypes }, } = await this.parse(PopPrewarm);
36
- const db = await cli_1.account.login({ app });
37
- const contentTypeArr = contentTypes.split(",");
38
- const ipsArr = ips.split(",");
39
- const count = await this.getCount(db, contentTypeArr);
36
+ const database = await cli_1.account.login({ app });
37
+ const contentTypeArray = contentTypes.split(",");
38
+ const ipsArray = ips.split(",");
39
+ const count = await this.getCount(database, contentTypeArray);
40
40
  const progress = core_2.ux.progress();
41
41
  progress.start(count * ips.length, 0);
42
- await this.fetchAssets(db, ipsArr, contentTypeArr, app, progress);
42
+ await this.fetchAssets(database, ipsArray, contentTypeArray, app, progress);
43
43
  progress.stop();
44
44
  }
45
- async getCount(db, contentTypes) {
46
- return db["speedKit.Asset"].find().in("contentType", contentTypes).count();
45
+ async getCount(database, contentTypes) {
46
+ return database["speedKit.Asset"]
47
+ .find()
48
+ .in("contentType", contentTypes)
49
+ .count();
47
50
  }
48
- async queryDb(db, contentTypes, lastId = "") {
49
- let qb = db["speedKit.Asset"].find().in("contentType", contentTypes);
51
+ async queryDb(database, contentTypes, lastId = "") {
52
+ let qb = database["speedKit.Asset"].find().in("contentType", contentTypes);
50
53
  if (lastId) {
51
54
  qb = qb.gt("id", lastId);
52
55
  }
53
56
  return qb.limit(100).sort({ id: 1 }).resultList();
54
57
  }
55
58
  /* eslint-disable @typescript-eslint/no-explicit-any */
56
- async fetchAssets(db, ips, contentTypes, app, progress, lastId = "") {
57
- const resultList = await this.queryDb(db, contentTypes, lastId);
59
+ async fetchAssets(database, ips, contentTypes, app, progress, lastId = "") {
60
+ const resultList = await this.queryDb(database, contentTypes, lastId);
58
61
  if (resultList.length === 0) {
59
- return Promise.resolve();
62
+ return;
60
63
  }
61
64
  const assetChunks = prewarm_service_1.default.chunk(resultList, 50);
62
65
  let fetches = [];
@@ -66,7 +69,7 @@ class PopPrewarm extends core_1.Command {
66
69
  let { url } = asset;
67
70
  const { origin, variation, extendedURL } = asset;
68
71
  url += extendedURL || "";
69
- fetches.push(prewarm_service_1.default.fetchURLByIp(ip, url, origin, variation, app, db.token));
72
+ fetches.push(prewarm_service_1.default.fetchURLByIp(ip, url, origin, variation, app, database.token));
70
73
  }
71
74
  try {
72
75
  // eslint-disable-next-line no-await-in-loop
@@ -79,9 +82,9 @@ class PopPrewarm extends core_1.Command {
79
82
  fetches = [];
80
83
  }
81
84
  }
82
- db.clear();
83
- this.log(resultList[resultList.length - 1].url);
84
- return this.fetchAssets(db, ips, contentTypes, app, progress, resultList[resultList.length - 1].id);
85
+ database.clear();
86
+ this.log(resultList.at(-1).url);
87
+ return this.fetchAssets(database, ips, contentTypes, app, progress, resultList.at(-1).id);
85
88
  }
86
89
  }
87
90
  exports.default = PopPrewarm;
@@ -7,8 +7,8 @@ const cli_1 = require("baqend/cli");
7
7
  const cli_parameters_1 = require("../models/cli-parameters");
8
8
  const logging_helper_1 = require("../helpers/logging-helper");
9
9
  const prewarm_service_1 = tslib_1.__importDefault(require("../services/prewarm-service"));
10
- const url_1 = require("url");
11
- const fs_1 = tslib_1.__importDefault(require("fs"));
10
+ const node_url_1 = require("node:url");
11
+ const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
12
12
  class Prewarm extends core_1.Command {
13
13
  static description = "Pre-warm Fastly";
14
14
  static args = {
@@ -55,12 +55,12 @@ class Prewarm extends core_1.Command {
55
55
  async run() {
56
56
  const { args: { app, path }, flags: { variation, variationPath, delay, keepParameterSorting }, } = await this.parse(Prewarm);
57
57
  const sortParameters = !keepParameterSorting;
58
- const db = await cli_1.account.login({ app });
58
+ const database = await cli_1.account.login({ app });
59
59
  const urls = this.loadAssets(path);
60
60
  const variations = variationPath
61
61
  ? this.loadVariations(variationPath)
62
62
  : [variation];
63
- await this.prewarmVariations(variations, urls, app, db.token, delay, sortParameters);
63
+ await this.prewarmVariations(variations, urls, app, database.token, delay, sortParameters);
64
64
  }
65
65
  /**
66
66
  * Pre-warms a list of URLs with the given variations.
@@ -105,14 +105,14 @@ class Prewarm extends core_1.Command {
105
105
  progress.stop();
106
106
  }
107
107
  loadAssets(path, origin = "") {
108
- const data = fs_1.default.readFileSync(path, "utf8");
108
+ const data = node_fs_1.default.readFileSync(path, "utf8");
109
109
  const entries = data.split(/\r?\n/);
110
110
  return entries.map((entry) => {
111
111
  entry = /^"[^"]+"/.test(entry) ? entry.slice(1, -1) : entry;
112
112
  try {
113
113
  return {
114
114
  url: entry,
115
- origin: origin || new url_1.URL(entry).origin,
115
+ origin: origin || new node_url_1.URL(entry).origin,
116
116
  };
117
117
  }
118
118
  catch (error) {
@@ -127,17 +127,17 @@ class Prewarm extends core_1.Command {
127
127
  */
128
128
  loadVariations(path) {
129
129
  const variations = [];
130
- const data = fs_1.default.readFileSync(path, "utf8");
130
+ const data = node_fs_1.default.readFileSync(path, "utf8");
131
131
  const entries = data.split(/\r?\n/);
132
- entries.forEach((entry) => {
132
+ for (const entry of entries) {
133
133
  if (entry !== "") {
134
134
  variations.push(entry);
135
135
  }
136
- });
136
+ }
137
137
  return variations;
138
138
  }
139
139
  async sleep(ms) {
140
- return new Promise((res) => setTimeout(res, ms));
140
+ return new Promise((response) => setTimeout(response, ms));
141
141
  }
142
142
  }
143
143
  exports.default = Prewarm;
@@ -16,6 +16,6 @@ export default class WptLauncher extends Command {
16
16
  isMobile(mobile: string): boolean;
17
17
  getViewPortSize(isMobile: boolean): string;
18
18
  allResourceUrls(urls: string): Array<string>;
19
- getResourceOrigin(urlsArr: Array<string>): string;
19
+ getResourceOrigin(urlsArray: Array<string>): string;
20
20
  postScript(script: string): Promise<NonNullable<unknown>>;
21
21
  }
@@ -46,9 +46,9 @@ class WptLauncher extends core_1.Command {
46
46
  exec localStorage.setItem('baqend-speedkit-ab-test-info', encodeURIComponent(JSON.stringify({group:${group},testId:${testId})));
47
47
  navigate ${resourceOrigin}
48
48
  navigate ${WptLauncher.localhostUrl}`;
49
- this.allResourceUrls(urls).forEach((url) => {
49
+ for (const url of this.allResourceUrls(urls)) {
50
50
  script += `\n navigate ${url}`;
51
- });
51
+ }
52
52
  const postscript = (await this.postScript(script));
53
53
  const currentTestIdUrl = `http://wpt.baqend.com/results.php?test=${postscript.wptTestId}`;
54
54
  if (!currentTestIdUrl) {
@@ -73,23 +73,23 @@ class WptLauncher extends core_1.Command {
73
73
  return "1500 1300"; // desktop
74
74
  }
75
75
  allResourceUrls(urls) {
76
- const urlsArr = urls.split(",");
77
- if (urlsArr.length > 0) {
78
- return urlsArr;
76
+ const urlsArray = urls.split(",");
77
+ if (urlsArray.length > 0) {
78
+ return urlsArray;
79
79
  }
80
80
  throw new Error("urls must not be null");
81
81
  }
82
- getResourceOrigin(urlsArr) {
83
- return new URL(urlsArr[0]).origin;
82
+ getResourceOrigin(urlsArray) {
83
+ return new URL(urlsArray[0]).origin;
84
84
  }
85
85
  // ---------------- wpt launcher --------------------------
86
86
  async postScript(script) {
87
87
  const urlPath = "https://makefast.app.baqend.com/v1/code/testAPI";
88
- const res = await (0, node_fetch_1.default)(urlPath, {
88
+ const response = await (0, node_fetch_1.default)(urlPath, {
89
89
  body: JSON.stringify({ script }),
90
90
  method: "POST",
91
91
  });
92
- return res.json();
92
+ return response.json();
93
93
  }
94
94
  }
95
95
  exports.default = WptLauncher;
@@ -16,17 +16,17 @@ export declare function getBlacklistedFilter(parsedConfig: any): string;
16
16
  * @param params - The stripped parameters that are named within the speed kit config.
17
17
  * @param skConfigVersion - The Speed Kit config ruleset version.
18
18
  */
19
- export declare function getParameterFilter(params: (string | RegExp)[], skConfigVersion?: number): string;
19
+ export declare function getParameterFilter(parameters: (string | RegExp)[], skConfigVersion?: number): string;
20
20
  /**
21
21
  * Returns the parameter replace (regexp_replace) as a SQL query string.
22
22
  *
23
23
  * @param params - The stripped parameters that are named within the speed kit config.
24
24
  * @param skConfigVersion - The Speed Kit config ruleset version.
25
25
  */
26
- export declare function getParameterReplaceFilter(params: (string | RegExp)[], skConfigVersion?: number): string;
26
+ export declare function getParameterReplaceFilter(parameters: (string | RegExp)[], skConfigVersion?: number): string;
27
27
  /**
28
28
  * Returns the stripped parameters that are named within the speed kit config.
29
29
  *
30
30
  * @param parsedConfig - The speed kit config parsed as an object.
31
31
  */
32
- export declare function getStrippedParams(parsedConfig: any): (string | RegExp)[];
32
+ export declare function getStrippedParameters(parsedConfig: any): (string | RegExp)[];