@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
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getStrippedParams = exports.getParameterReplaceFilter = exports.getParameterFilter = exports.getBlacklistedFilter = exports.getWhitelistedFilter = void 0;
3
+ exports.getStrippedParameters = exports.getParameterReplaceFilter = exports.getParameterFilter = exports.getBlacklistedFilter = exports.getWhitelistedFilter = void 0;
4
4
  /**
5
5
  * Returns the string between a left bound and a right bound.
6
6
  *
@@ -39,15 +39,14 @@ function getFilterForProperty(property, sqlField, shouldEqual, type) {
39
39
  * @param speedKitRuleValues - The speed kit rule value to get the properties from (e.g. the whitelist).
40
40
  * @param key - The key to get the properties with (e.g. 'pathname').
41
41
  */
42
- function getRuleProp(speedKitRuleValues, key) {
42
+ function getRuleProperty(speedKitRuleValues, key) {
43
43
  const properties = [];
44
44
  if (!speedKitRuleValues) {
45
45
  return properties;
46
46
  }
47
47
  for (const ruleValue of speedKitRuleValues) {
48
- Object.keys(ruleValue)
49
- .filter((ruleKey) => key === ruleKey)
50
- .forEach((ruleKey) => properties.push(...ruleValue[ruleKey]));
48
+ for (const ruleKey of Object.keys(ruleValue).filter((ruleKey) => key === ruleKey))
49
+ properties.push(...ruleValue[ruleKey]);
51
50
  }
52
51
  return properties;
53
52
  }
@@ -62,7 +61,7 @@ function getWhitelistedFilter(parsedConfig) {
62
61
  const whitelistedFilter = `(\n ${(whitelist[0].host || whitelist[0].url)
63
62
  .map((hostname) => getFilterForProperty(hostname, "url", true, "url"))
64
63
  .join("\n or ")}\n )`;
65
- const enabledFilter = getRuleProp(enabledSites, "pathname")
64
+ const enabledFilter = getRuleProperty(enabledSites, "pathname")
66
65
  .map((pathname) => getFilterForProperty(pathname, "url", true, "pathname"))
67
66
  .join("\nor ");
68
67
  if (!enabledFilter) {
@@ -78,13 +77,13 @@ exports.getWhitelistedFilter = getWhitelistedFilter;
78
77
  */
79
78
  function getBlacklistedFilter(parsedConfig) {
80
79
  const { blacklist, disabledSites } = parsedConfig;
81
- const blacklistedPathnamesFilter = getRuleProp(blacklist, "pathname")
80
+ const blacklistedPathnamesFilter = getRuleProperty(blacklist, "pathname")
82
81
  .map((pathname) => getFilterForProperty(pathname, "url", false, "pathname"))
83
82
  .join("\n and ");
84
- const blacklistedUrlsFilter = getRuleProp(blacklist, "url")
83
+ const blacklistedUrlsFilter = getRuleProperty(blacklist, "url")
85
84
  .map((url) => getFilterForProperty(url, "url", false, "url"))
86
85
  .join("\n and ");
87
- const disabledFilter = getRuleProp(disabledSites, "pathname")
86
+ const disabledFilter = getRuleProperty(disabledSites, "pathname")
88
87
  .map((pathname) => getFilterForProperty(pathname, "url", false, "pathname"))
89
88
  .join("\n and ");
90
89
  let blacklistedFilter = "";
@@ -106,21 +105,18 @@ exports.getBlacklistedFilter = getBlacklistedFilter;
106
105
  * @param params - The stripped parameters that are named within the speed kit config.
107
106
  * @param skConfigVersion - The Speed Kit config ruleset version.
108
107
  */
109
- function getParameterFilter(params, skConfigVersion = 1) {
110
- return params
111
- .map((param) => {
108
+ function getParameterFilter(parameters, skConfigVersion = 1) {
109
+ return parameters
110
+ .map((parameter) => {
112
111
  // Prefix comparison for strings
113
- if (typeof param === "string") {
114
- if (skConfigVersion === 1) {
115
- return `not regexp_like(key, '^${param}')`;
116
- }
117
- else {
118
- return `key <> '${param}'`;
119
- }
112
+ if (typeof parameter === "string") {
113
+ return skConfigVersion === 1
114
+ ? `not regexp_like(key, '^${parameter}')`
115
+ : `key <> '${parameter}'`;
120
116
  }
121
117
  // Regexp like for complex regular expressions
122
- const ignoreCase = isRegExpIgnoringCase(param);
123
- return `not regexp_like(key, '${ignoreCase ? "(?i)" : ""}${getStringBetween(String(param), "/", "/")}')`;
118
+ const ignoreCase = isRegExpIgnoringCase(parameter);
119
+ return `not regexp_like(key, '${ignoreCase ? "(?i)" : ""}${getStringBetween(String(parameter), "/", "/")}')`;
124
120
  })
125
121
  .join("\nand ");
126
122
  }
@@ -131,73 +127,78 @@ exports.getParameterFilter = getParameterFilter;
131
127
  * @param params - The stripped parameters that are named within the speed kit config.
132
128
  * @param skConfigVersion - The Speed Kit config ruleset version.
133
129
  */
134
- function getParameterReplaceFilter(params, skConfigVersion = 1) {
135
- const prefixParams = [];
136
- const suffixParams = [];
137
- const fullMatchParams = [];
138
- const prefixIgnoreCaseParams = [];
139
- const suffixIgnoreCaseParams = [];
140
- const fullMatchIgnoreCaseParams = [];
141
- params.forEach((param) => {
130
+ function getParameterReplaceFilter(parameters, skConfigVersion = 1) {
131
+ const prefixParameters = [];
132
+ const suffixParameters = [];
133
+ const fullMatchParameters = [];
134
+ const prefixIgnoreCaseParameters = [];
135
+ const suffixIgnoreCaseParameters = [];
136
+ const fullMatchIgnoreCaseParameters = [];
137
+ for (const parameter of parameters) {
142
138
  // String params or regex params with start marker but no end marker
143
- if (typeof param === "string") {
139
+ if (typeof parameter === "string") {
144
140
  if (skConfigVersion === 1) {
145
- return prefixParams.push(param);
141
+ prefixParameters.push(parameter);
142
+ continue;
146
143
  }
147
144
  else {
148
- return fullMatchParams.push(param);
145
+ fullMatchParameters.push(parameter);
146
+ continue;
149
147
  }
150
148
  }
151
- const ignoreCase = isRegExpIgnoringCase(param);
149
+ const ignoreCase = isRegExpIgnoringCase(parameter);
152
150
  // Regex params with start marker but no end marker
153
- if (/\/\^[^$]+$/.test(String(param))) {
154
- return (ignoreCase ? prefixIgnoreCaseParams : prefixParams).push(getStringBetween(String(param), "^", "/"));
151
+ if (/\/\^[^$]+$/.test(String(parameter))) {
152
+ (ignoreCase ? prefixIgnoreCaseParameters : prefixParameters).push(getStringBetween(String(parameter), "^", "/"));
153
+ continue;
155
154
  }
156
155
  // Regex params with end marker but no start marker
157
- if (/\/[^^$]+\$/.test(String(param))) {
158
- return (ignoreCase ? suffixIgnoreCaseParams : suffixParams).push(getStringBetween(String(param), "/", "$"));
156
+ if (/\/[^$^]+\$/.test(String(parameter))) {
157
+ (ignoreCase ? suffixIgnoreCaseParameters : suffixParameters).push(getStringBetween(String(parameter), "/", "$"));
158
+ continue;
159
159
  }
160
160
  // Regex params with start marker and end marker
161
- if (/\/\^[^$]+\$\//.test(String(param))) {
162
- return (ignoreCase ? fullMatchIgnoreCaseParams : fullMatchParams).push(getStringBetween(String(param), "^", "$"));
161
+ if (/\/\^[^$]+\$\//.test(String(parameter))) {
162
+ (ignoreCase ? fullMatchIgnoreCaseParameters : fullMatchParameters).push(getStringBetween(String(parameter), "^", "$"));
163
+ continue;
163
164
  }
164
165
  // Regex params with no start marker and no end marker are being considered full matches
165
- (ignoreCase ? fullMatchIgnoreCaseParams : fullMatchParams).push(getStringBetween(String(param), "/", "/"));
166
- });
166
+ (ignoreCase ? fullMatchIgnoreCaseParameters : fullMatchParameters).push(getStringBetween(String(parameter), "/", "/"));
167
+ }
167
168
  let regExpQuery = "regexp_replace(url, '#.*' )";
168
169
  const regExps = [
169
- getParamPrefixRegExp(prefixParams, false),
170
- getParamPrefixRegExp(prefixIgnoreCaseParams, true),
171
- getParamSuffixRegExp(suffixParams, false),
172
- getParamSuffixRegExp(suffixIgnoreCaseParams, true),
173
- getParamFullMatchRegExp(fullMatchParams, false),
174
- getParamFullMatchRegExp(fullMatchIgnoreCaseParams, true),
170
+ getParameterPrefixRegExp(prefixParameters, false),
171
+ getParameterPrefixRegExp(prefixIgnoreCaseParameters, true),
172
+ getParameterSuffixRegExp(suffixParameters, false),
173
+ getParameterSuffixRegExp(suffixIgnoreCaseParameters, true),
174
+ getParameterFullMatchRegExp(fullMatchParameters, false),
175
+ getParameterFullMatchRegExp(fullMatchIgnoreCaseParameters, true),
175
176
  ];
176
177
  // Nest all regexes inside each other:
177
- regExps.forEach((regExp) => {
178
+ for (const regExp of regExps) {
178
179
  if (regExp) {
179
180
  regExpQuery = `regexp_replace(${regExpQuery}, '${regExp}', '')`;
180
181
  }
181
- });
182
+ }
182
183
  return regExpQuery;
183
184
  }
184
185
  exports.getParameterReplaceFilter = getParameterReplaceFilter;
185
186
  function isRegExpIgnoringCase(regExp) {
186
187
  return /\/i$/.test(String(regExp));
187
188
  }
188
- function getParamPrefixRegExp(params, ignoreCase) {
189
- return params.length > 0
190
- ? `${ignoreCase ? "(?i)" : ""}[?&](${params.join("|")})[^&]*`
189
+ function getParameterPrefixRegExp(parameters, ignoreCase) {
190
+ return parameters.length > 0
191
+ ? `${ignoreCase ? "(?i)" : ""}[?&](${parameters.join("|")})[^&]*`
191
192
  : null;
192
193
  }
193
- function getParamSuffixRegExp(params, ignoreCase) {
194
- return params.length > 0
195
- ? `${ignoreCase ? "(?i)" : ""}[?&][^&]*(${params.join("|")})(=[^&]*)?(?=&|$)`
194
+ function getParameterSuffixRegExp(parameters, ignoreCase) {
195
+ return parameters.length > 0
196
+ ? `${ignoreCase ? "(?i)" : ""}[?&][^&]*(${parameters.join("|")})(=[^&]*)?(?=&|$)`
196
197
  : null;
197
198
  }
198
- function getParamFullMatchRegExp(params, ignoreCase) {
199
- return params.length > 0
200
- ? `${ignoreCase ? "(?i)" : ""}[?&](${params.join("|")})(=[^&]*)?(?=&|$)`
199
+ function getParameterFullMatchRegExp(parameters, ignoreCase) {
200
+ return parameters.length > 0
201
+ ? `${ignoreCase ? "(?i)" : ""}[?&](${parameters.join("|")})(=[^&]*)?(?=&|$)`
201
202
  : null;
202
203
  }
203
204
  /**
@@ -205,26 +206,26 @@ function getParamFullMatchRegExp(params, ignoreCase) {
205
206
  *
206
207
  * @param parsedConfig - The speed kit config parsed as an object.
207
208
  */
208
- function getStrippedParams(parsedConfig) {
209
- const paramArray = parsedConfig.stripQueryParams;
210
- if (!paramArray) {
209
+ function getStrippedParameters(parsedConfig) {
210
+ const parameterArray = parsedConfig.stripQueryParams;
211
+ if (!parameterArray) {
211
212
  return [];
212
213
  }
213
- const isSimpleArray = paramArray.every((param) => typeof param === "string" || param instanceof RegExp);
214
+ const isSimpleArray = parameterArray.every((parameter) => typeof parameter === "string" || parameter instanceof RegExp);
214
215
  if (isSimpleArray) {
215
- return paramArray;
216
+ return parameterArray;
216
217
  }
217
- const params = [];
218
- for (const entry of paramArray) {
218
+ const parameters = [];
219
+ for (const entry of parameterArray) {
219
220
  if (!entry.params) {
220
221
  continue;
221
222
  }
222
223
  if (!Array.isArray(entry.params)) {
223
- params.push(entry.params);
224
+ parameters.push(entry.params);
224
225
  continue;
225
226
  }
226
- params.push(...entry.params);
227
+ parameters.push(...entry.params);
227
228
  }
228
- return params;
229
+ return parameters;
229
230
  }
230
- exports.getStrippedParams = getStrippedParams;
231
+ exports.getStrippedParameters = getStrippedParameters;
@@ -6,7 +6,7 @@ const dotenv = tslib_1.__importStar(require("dotenv"));
6
6
  const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
7
7
  const node_path_1 = tslib_1.__importDefault(require("node:path"));
8
8
  dotenv.config();
9
- const envMapping = {
9
+ const environmentMapping = {
10
10
  chromeExtensionPaths: "CHROME_EXTENSION_PATHS",
11
11
  chromePath: "CHROME_PATH",
12
12
  chromeUserProfilePath: "CHROME_USER_PROFILE_PATH",
@@ -70,12 +70,13 @@ class CliConfig {
70
70
  }
71
71
  loadConfigFromEnvironment() {
72
72
  for (const configKey in this.userCliConfig) {
73
- if (!(configKey in envMapping)) {
73
+ if (!(configKey in environmentMapping)) {
74
74
  continue;
75
75
  }
76
- const envVar = envMapping[configKey];
77
- if (envVar in process.env && process.env[envVar].length > 0) {
78
- this.userCliConfig[configKey] = process.env[envVar];
76
+ const environmentVariable = environmentMapping[configKey];
77
+ if (environmentVariable in process.env &&
78
+ process.env[environmentVariable].length > 0) {
79
+ this.userCliConfig[configKey] = process.env[environmentVariable];
79
80
  }
80
81
  }
81
82
  }
@@ -1,11 +1,11 @@
1
1
  import { InstallConfigs } from "../models/install";
2
2
  export declare const SPEED_KIT_INSTALL_PATH: string;
3
3
  export declare const INSTALLATION_PROPERTIES: InstallConfigs<string>;
4
- type Params = {
4
+ type Parameters_ = {
5
5
  [param: string]: any;
6
6
  };
7
- type MultiConfigParams = {
8
- [configName: string]: Params;
7
+ type MultiConfigParameters = {
8
+ [configName: string]: Parameters_;
9
9
  };
10
10
  export declare class CustomerConfig implements InstallConfigs<ConfigFile | null> {
11
11
  readonly name: string;
@@ -32,9 +32,9 @@ export declare class CustomerConfig implements InstallConfigs<ConfigFile | null>
32
32
  readonly chromeFlags: string[];
33
33
  readonly globalWhitelist: ConfigFile;
34
34
  readonly globalBlacklist: ConfigFile;
35
- static loadConfig(dir: string): Promise<MultiConfigParams | Params>;
36
- static loadCustomer(dir: string, configName: string): Promise<CustomerConfig>;
37
- constructor(params: Params, configFiles: InstallConfigs<ConfigFile | null> & {
35
+ static loadConfig(directory: string): Promise<MultiConfigParameters | Parameters_>;
36
+ static loadCustomer(directory: string, configName: string): Promise<CustomerConfig>;
37
+ constructor(parameters: Parameters_, configFiles: InstallConfigs<ConfigFile | null> & {
38
38
  globalWhitelist: any;
39
39
  globalBlacklist: any;
40
40
  popConfig: any;
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ConfigFile = exports.CustomerConfig = exports.INSTALLATION_PROPERTIES = exports.SPEED_KIT_INSTALL_PATH = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const path_1 = tslib_1.__importDefault(require("path"));
6
- const isFile_1 = require("./isFile");
7
- const promises_1 = require("fs/promises");
5
+ const node_path_1 = tslib_1.__importDefault(require("node:path"));
6
+ const is_file_1 = require("./is-file");
7
+ const promises_1 = require("node:fs/promises");
8
8
  const logging_helper_1 = require("./logging-helper");
9
9
  exports.SPEED_KIT_INSTALL_PATH = "/speed-kit-install.js";
10
10
  const CUSTOMER_CONFIG_BASENAME = "config_customer.js";
@@ -28,20 +28,20 @@ exports.INSTALLATION_PROPERTIES = {
28
28
  documentHandlerConfig: DOCUMENT_HANDLER_CONFIG,
29
29
  customStyle: DF_STYLES_BASENAME,
30
30
  };
31
- function required(check, params, name) {
32
- if (check(params[name])) {
33
- return params[name];
31
+ function required(check, parameters, name) {
32
+ if (check(parameters[name])) {
33
+ return parameters[name];
34
34
  }
35
- throw new TypeError(`Please provide a ${check.name.substring(2)} "${name}" property.`);
35
+ throw new TypeError(`Please provide a ${check.name.slice(2)} "${name}" property.`);
36
36
  }
37
- function optional(check, params, name, defaultValue = null) {
38
- if (check(params[name])) {
39
- return params[name];
37
+ function optional(check, parameters, name, defaultValue = null) {
38
+ if (check(parameters[name])) {
39
+ return parameters[name];
40
40
  }
41
- if (typeof params[name] === "undefined" || params[name] === null) {
41
+ if (parameters[name] === undefined || parameters[name] === null) {
42
42
  return defaultValue;
43
43
  }
44
- throw new TypeError(`Property "${name}" must be a ${check.name.substring(2)}.`);
44
+ throw new TypeError(`Property "${name}" must be a ${check.name.slice(2)}.`);
45
45
  }
46
46
  function isString(value) {
47
47
  return typeof value === "string";
@@ -74,52 +74,52 @@ class CustomerConfig {
74
74
  chromeFlags;
75
75
  globalWhitelist;
76
76
  globalBlacklist;
77
- static async loadConfig(dir) {
78
- const mainConfig = await ConfigFile.loadFile(dir, CUSTOMER_CONFIG_BASENAME);
77
+ static async loadConfig(directory) {
78
+ const mainConfig = await ConfigFile.loadFile(directory, CUSTOMER_CONFIG_BASENAME);
79
79
  if (!mainConfig) {
80
80
  throw new Error(`Could not find customer config file "${CUSTOMER_CONFIG_BASENAME}".`);
81
81
  }
82
82
  // eslint-disable-next-line @typescript-eslint/no-var-requires
83
83
  return require(mainConfig.filePath);
84
84
  }
85
- static async loadCustomer(dir, configName) {
86
- const customerConfig = await this.loadConfig(dir);
87
- let params;
85
+ static async loadCustomer(directory, configName) {
86
+ const customerConfig = await this.loadConfig(directory);
87
+ let parameters;
88
88
  if (configName in customerConfig) {
89
- params = customerConfig[configName];
89
+ parameters = customerConfig[configName];
90
90
  }
91
91
  else {
92
92
  (0, logging_helper_1.logWarning)("Use legacy customer config loading format.");
93
93
  (0, logging_helper_1.logWarning)("Make sure to export the different app configs under their config names like:");
94
94
  (0, logging_helper_1.logWarning)("module.exports = { production, staging }");
95
- params = customerConfig;
95
+ parameters = customerConfig;
96
96
  }
97
97
  const configs = {};
98
98
  for (const [key, path] of Object.entries(exports.INSTALLATION_PROPERTIES)) {
99
- configs[key] = await ConfigFile.loadFile(dir, path, path.replace(".js", ".es6"));
99
+ configs[key] = await ConfigFile.loadFile(directory, path, path.replace(".js", ".es6"));
100
100
  }
101
101
  // Parse config
102
- return new CustomerConfig({ name: configName, ...params }, {
102
+ return new CustomerConfig({ name: configName, ...parameters }, {
103
103
  ...configs,
104
- popConfig: await ConfigFile.loadFile(dir, "config_pops.js"),
105
- globalWhitelist: await ConfigFile.loadFile(dir, "../../rules/global-whitelist.js"),
106
- globalBlacklist: await ConfigFile.loadFile(dir, "../../rules/global-blacklist.js"),
104
+ popConfig: await ConfigFile.loadFile(directory, "config_pops.js"),
105
+ globalWhitelist: await ConfigFile.loadFile(directory, "../../rules/global-whitelist.js"),
106
+ globalBlacklist: await ConfigFile.loadFile(directory, "../../rules/global-blacklist.js"),
107
107
  });
108
108
  }
109
- constructor(params, configFiles) {
110
- this.domain = required(isString, params, "domain");
111
- this.name = optional(isString, params, "name");
112
- this.swPath = optional(isString, params, "swPath", "/wrapper-sw.js");
113
- this.app = optional(isString, params, "app");
114
- this.appDomain = optional(isString, params, "appDomain", "*.app.baqend.com");
115
- this.chromeFlags = optional(Array.isArray, params, "chromeFlags", []);
116
- this.installPath = optional(isString, params, "installPath", exports.SPEED_KIT_INSTALL_PATH);
117
- const scope = optional(isString, params, "scope", "/");
109
+ constructor(parameters, configFiles) {
110
+ this.domain = required(isString, parameters, "domain");
111
+ this.name = optional(isString, parameters, "name");
112
+ this.swPath = optional(isString, parameters, "swPath", "/wrapper-sw.js");
113
+ this.app = optional(isString, parameters, "app");
114
+ this.appDomain = optional(isString, parameters, "appDomain", "*.app.baqend.com");
115
+ this.chromeFlags = optional(Array.isArray, parameters, "chromeFlags", []);
116
+ this.installPath = optional(isString, parameters, "installPath", exports.SPEED_KIT_INSTALL_PATH);
117
+ const scope = optional(isString, parameters, "scope", "/");
118
118
  this.scope = scope + (scope.endsWith("/") ? "" : "/");
119
- this.origins = optional(Array.isArray, params, "origins", []);
120
- this.installParams = optional(isString, params, "installParams", 'async crossorigin="anonymous"');
121
- this.forceInstall = optional(isBoolean, params, "forceInstall", false);
122
- this.bypassDeactivation = optional(isBoolean, params, "bypassDeactivation", true);
119
+ this.origins = optional(Array.isArray, parameters, "origins", []);
120
+ this.installParams = optional(isString, parameters, "installParams", 'async crossorigin="anonymous"');
121
+ this.forceInstall = optional(isBoolean, parameters, "forceInstall", false);
122
+ this.bypassDeactivation = optional(isBoolean, parameters, "bypassDeactivation", true);
123
123
  // Assign Config Files
124
124
  Object.assign(this, configFiles);
125
125
  }
@@ -130,8 +130,8 @@ class ConfigFile {
130
130
  name;
131
131
  static async loadFile(basePath, ...alternativeFileNames) {
132
132
  for (const fileName of alternativeFileNames) {
133
- const filePath = path_1.default.resolve(basePath, fileName);
134
- if (await (0, isFile_1.isFile)(filePath)) {
133
+ const filePath = node_path_1.default.resolve(basePath, fileName);
134
+ if (await (0, is_file_1.isFile)(filePath)) {
135
135
  return new ConfigFile(filePath, fileName);
136
136
  }
137
137
  }
@@ -1,2 +1,2 @@
1
- export declare function createTemporalDir(): Promise<null | string>;
1
+ export declare function createTemporalDirectory(): Promise<null | string>;
2
2
  export declare function readLocalFile(basePath: string, fileName: string): Promise<null | string>;
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.readLocalFile = exports.createTemporalDir = void 0;
3
+ exports.readLocalFile = exports.createTemporalDirectory = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const node_fs_1 = require("node:fs");
6
6
  const os = tslib_1.__importStar(require("node:os"));
7
7
  const path = tslib_1.__importStar(require("node:path"));
8
- const CustomerConfig_1 = require("./CustomerConfig");
9
- async function createTemporalDir() {
8
+ const customer_config_1 = require("./customer-config");
9
+ async function createTemporalDirectory() {
10
10
  try {
11
11
  return (0, node_fs_1.mkdtempSync)(path.join(os.tmpdir(), "speed-kit-cli-"));
12
12
  }
@@ -15,10 +15,10 @@ async function createTemporalDir() {
15
15
  return null;
16
16
  }
17
17
  }
18
- exports.createTemporalDir = createTemporalDir;
18
+ exports.createTemporalDirectory = createTemporalDirectory;
19
19
  async function readLocalFile(basePath, fileName) {
20
20
  try {
21
- const file = await CustomerConfig_1.ConfigFile.loadFile(basePath, fileName);
21
+ const file = await customer_config_1.ConfigFile.loadFile(basePath, fileName);
22
22
  return await file.readContent();
23
23
  }
24
24
  catch {
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getChromePath = void 0;
4
- const CustomerConfig_1 = require("./CustomerConfig");
5
- const isFile_1 = require("./isFile");
4
+ const customer_config_1 = require("./customer-config");
5
+ const is_file_1 = require("./is-file");
6
6
  const CHROME_PATHS = {
7
7
  darwin: "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
8
8
  win32: "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe",
@@ -16,15 +16,15 @@ const ENV_CHROME_REGEX = new RegExp(/^\s*CHROME_PATH=(.*)$/mu);
16
16
  * @param customerPath - Path to customer in skonboarding-project.
17
17
  */
18
18
  async function getChromePath(customerPath) {
19
- const envFile = await CustomerConfig_1.ConfigFile.loadFile(customerPath, "../../.env");
20
- if (!envFile) {
19
+ const environmentFile = await customer_config_1.ConfigFile.loadFile(customerPath, "../../.env");
20
+ if (!environmentFile) {
21
21
  return CHROME_PATHS[process.platform];
22
22
  }
23
- const envContent = await envFile.readContent();
24
- const chromePath = ENV_CHROME_REGEX.test(envContent)
25
- ? envContent.match(ENV_CHROME_REGEX)[1]
23
+ const environmentContent = await environmentFile.readContent();
24
+ const chromePath = ENV_CHROME_REGEX.test(environmentContent)
25
+ ? environmentContent.match(ENV_CHROME_REGEX)[1]
26
26
  : "";
27
- return (await (0, isFile_1.isFile)(chromePath))
27
+ return (await (0, is_file_1.isFile)(chromePath))
28
28
  ? chromePath
29
29
  : CHROME_PATHS[process.platform];
30
30
  }
@@ -1,4 +1,4 @@
1
- import { ConfigFile } from "./CustomerConfig";
1
+ import { ConfigFile } from "./customer-config";
2
2
  interface SpeedKitConfig {
3
3
  ruleSetConfig?: {
4
4
  version?: string;
@@ -2,18 +2,18 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getSpeedKitConfigVersion = exports.getParsedConfig = exports.parseSpeedKitConfig = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const vm = tslib_1.__importStar(require("vm"));
5
+ const vm = tslib_1.__importStar(require("node:vm"));
6
6
  function parseSpeedKitConfig(config) {
7
7
  // Replace all properties that use function calls or that are related to other objects like window
8
8
  const window = {};
9
9
  window.top = window;
10
10
  const storage = {
11
11
  length: 0,
12
- clear: () => undefined,
13
- getItem: () => undefined,
12
+ clear: () => { },
13
+ getItem: () => { },
14
14
  key: () => null,
15
- removeItem: () => undefined,
16
- setItem: () => undefined,
15
+ removeItem: () => { },
16
+ setItem: () => { },
17
17
  };
18
18
  const node = {
19
19
  querySelector: () => node,
@@ -48,8 +48,8 @@ async function getParsedConfig(configFile) {
48
48
  try {
49
49
  parsedConfig = parseSpeedKitConfig(configString);
50
50
  }
51
- catch (e) {
52
- throw new Error(`Speed Kit config string could not be parsed.\n${e.stack}`);
51
+ catch (error) {
52
+ throw new Error(`Speed Kit config string could not be parsed.\n${error.stack}`);
53
53
  }
54
54
  if (!parsedConfig) {
55
55
  throw new Error("Speed Kit config was not correctly exposed on the global speedKit variable.");
@@ -0,0 +1 @@
1
+ export declare function isDirectory(directory: string): Promise<boolean>;
@@ -1,17 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isDirectory = void 0;
4
- const promises_1 = require("fs/promises");
5
- async function isDirectory(dir) {
4
+ const promises_1 = require("node:fs/promises");
5
+ async function isDirectory(directory) {
6
6
  try {
7
- const stats = await (0, promises_1.stat)(dir);
7
+ const stats = await (0, promises_1.stat)(directory);
8
8
  return stats.isDirectory();
9
9
  }
10
- catch (e) {
11
- if (e.code === "ENOENT") {
10
+ catch (error) {
11
+ if (error.code === "ENOENT") {
12
12
  return false;
13
13
  }
14
- throw e;
14
+ throw error;
15
15
  }
16
16
  }
17
17
  exports.isDirectory = isDirectory;
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isExecutable = void 0;
4
- const promises_1 = require("fs/promises");
5
- const fs_1 = require("fs");
4
+ const promises_1 = require("node:fs/promises");
5
+ const node_fs_1 = require("node:fs");
6
6
  async function isExecutable(filename) {
7
7
  try {
8
- await (0, promises_1.access)(filename, fs_1.constants.X_OK);
8
+ await (0, promises_1.access)(filename, node_fs_1.constants.X_OK);
9
9
  return true;
10
10
  }
11
11
  catch {
@@ -1,17 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isFile = void 0;
4
- const promises_1 = require("fs/promises");
4
+ const promises_1 = require("node:fs/promises");
5
5
  async function isFile(filename) {
6
6
  try {
7
7
  const stats = await (0, promises_1.stat)(filename);
8
8
  return stats.isFile();
9
9
  }
10
- catch (e) {
11
- if (e.code === "ENOENT") {
10
+ catch (error) {
11
+ if (error.code === "ENOENT") {
12
12
  return false;
13
13
  }
14
- throw e;
14
+ throw error;
15
15
  }
16
16
  }
17
17
  exports.isFile = isFile;
@@ -1,12 +1,12 @@
1
1
  /**
2
2
  * Logs the given message 'green' in the console.
3
3
  */
4
- export declare function logInfo(message: string, ...optionalParams: any[]): void;
4
+ export declare function logInfo(message: string, ...optionalParameters: any[]): void;
5
5
  /**
6
6
  * Logs the given message 'red' in the console.
7
7
  */
8
- export declare function logError(message: string, ...optionalParams: any[]): void;
8
+ export declare function logError(message: string, ...optionalParameters: any[]): void;
9
9
  /**
10
10
  * Logs the given message 'yellow' in the console.
11
11
  */
12
- export declare function logWarning(message: string, ...optionalParams: any[]): void;
12
+ export declare function logWarning(message: string, ...optionalParameters: any[]): void;