@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.
- package/CHANGELOG.md +7 -0
- package/README.md +36 -5
- package/dist/commands/build-parameter-query.js +5 -5
- package/dist/commands/build-prewarm-query.js +4 -4
- package/dist/commands/{param-diff.d.ts → diff-url-parameters.d.ts} +3 -1
- package/dist/commands/{param-diff.js → diff-url-parameters.js} +26 -24
- package/dist/commands/find-pops.js +9 -9
- package/dist/commands/generate-customer-config.d.ts +1 -1
- package/dist/commands/generate-customer-config.js +7 -7
- package/dist/commands/generate-pop-config.js +2 -2
- package/dist/commands/login.js +5 -4
- package/dist/commands/pop-prewarm.d.ts +3 -3
- package/dist/commands/pop-prewarm.js +19 -16
- package/dist/commands/prewarm.js +10 -10
- package/dist/commands/wpt-launcher.d.ts +1 -1
- package/dist/commands/wpt-launcher.js +9 -9
- package/dist/helpers/build-query-helper.d.ts +3 -3
- package/dist/helpers/build-query-helper.js +70 -69
- package/dist/helpers/cli-config.js +6 -5
- package/dist/helpers/{CustomerConfig.d.ts → customer-config.d.ts} +6 -6
- package/dist/helpers/{CustomerConfig.js → customer-config.js} +39 -39
- package/dist/helpers/file-helper.d.ts +1 -1
- package/dist/helpers/file-helper.js +5 -5
- package/dist/helpers/{getChromePath.js → get-chrome-path.js} +8 -8
- package/dist/helpers/get-parsed-config.d.ts +1 -1
- package/dist/helpers/get-parsed-config.js +7 -7
- package/dist/helpers/is-directory.d.ts +1 -0
- package/dist/helpers/{isDirectory.js → is-directory.js} +6 -6
- package/dist/helpers/{isExecutable.js → is-executable.js} +3 -3
- package/dist/helpers/{isFile.js → is-file.js} +4 -4
- package/dist/helpers/logging-helper.d.ts +3 -3
- package/dist/helpers/logging-helper.js +6 -6
- package/dist/helpers/normalize.d.ts +6 -6
- package/dist/helpers/normalize.js +35 -33
- package/dist/helpers/safe.d.ts +1 -1
- package/dist/helpers/safe.js +12 -12
- package/dist/helpers/{speedKitRuleToRegExp.js → speed-kit-rule-to-reg-exp.js} +3 -3
- package/dist/helpers/{watchFiles.js → watch-files.js} +2 -2
- package/dist/models/cli-parameters.d.ts +3 -3
- package/dist/models/cli-parameters.js +3 -3
- package/dist/services/athena/athena-service.js +2 -2
- package/dist/services/bundler/bundle-service.js +14 -14
- package/dist/services/cli/cli-service.js +8 -4
- package/dist/services/cli/hooks.js +3 -3
- package/dist/services/config-api/client.js +7 -6
- package/dist/services/config-api/factory/config-api-service-factory.js +4 -4
- package/dist/services/config-api/factory/entity-manager-factory.js +1 -1
- package/dist/services/config-api-service.d.ts +1 -1
- package/dist/services/config-api-service.js +7 -7
- package/dist/services/customer-config/customer-config-service-context.d.ts +2 -2
- package/dist/services/customer-config/customer-config-service-context.js +4 -4
- package/dist/services/customer-config/customer-config-service.js +45 -44
- package/dist/services/deploy/builder/install-resource-builder.d.ts +2 -2
- package/dist/services/deploy/builder/install-resource-builder.js +7 -7
- package/dist/services/deploy/checks/post-deploy/revalidated-module-check.js +1 -1
- package/dist/services/deploy/checks/post-deploy/save-files-check.js +4 -4
- package/dist/services/deploy/deploy-service.js +2 -4
- package/dist/services/deploy/error/create-find-temporary-directory-error.d.ts +4 -0
- package/dist/services/deploy/error/{create-find-temp-directory-error.js → create-find-temporary-directory-error.js} +2 -2
- package/dist/services/deploy/handler/customer-config-handler.js +1 -1
- package/dist/services/deploy/handler/install-resource-handler.js +8 -11
- package/dist/services/deploy/handler/install-resource-modifier/deleted-file-check.js +2 -2
- package/dist/services/deploy/handler/module-handler.js +8 -8
- package/dist/services/deploy/handler/server-config-handler.js +4 -4
- package/dist/services/diff/diff-service.d.ts +2 -2
- package/dist/services/diff/diff-service.js +22 -22
- package/dist/services/diff-service.d.ts +1 -1
- package/dist/services/diff-service.js +13 -13
- package/dist/services/document-handler-runtime/context/document-handler-runtime-context.js +10 -8
- package/dist/services/document-handler-runtime/document-handler-runtime-service.js +10 -10
- package/dist/services/document-handler-runtime/document-handler-server.js +12 -12
- package/dist/services/document-handler-runtime/factory/document-handler-runtime-service-factory.js +2 -2
- package/dist/services/document-handler-runtime/interface/template-interface.d.ts +2 -2
- package/dist/services/document-handler-runtime/interface/{template-param-interface.d.ts → template-parameter-interface.d.ts} +1 -1
- package/dist/services/document-handler-runtime/templates/abstract-template.d.ts +2 -2
- package/dist/services/document-handler-runtime/templates/abstract-template.js +3 -3
- package/dist/services/error-handling/factory/error-handling-factory.d.ts +1 -4
- package/dist/services/error-handling/factory/error-handling-factory.js +2 -1
- package/dist/services/integration-api/factory/integration-api-service-factory.js +1 -1
- package/dist/services/integration-api/file-list.js +4 -3
- package/dist/services/integration-api/file-reader.d.ts +1 -1
- package/dist/services/integration-api/file-reader.js +29 -26
- package/dist/services/integration-api/file-writer.js +3 -3
- package/dist/services/integration-api/handler/file-handler.js +1 -1
- package/dist/services/integration-api/handler/install-resource-handler.js +1 -1
- package/dist/services/integration-api/handler/module-handler.js +1 -1
- package/dist/services/integration-api/handler/server-config-handler.js +1 -1
- package/dist/services/integration-api/integration-api-service.js +2 -3
- package/dist/services/integration-api/struct/customer-config.d.ts +1 -1
- package/dist/services/integration-api/struct/customer-config.js +4 -4
- package/dist/services/integration-api/struct/file.js +1 -1
- package/dist/services/integration-api/validator/customer-config-validator.js +2 -2
- package/dist/services/integration-api/validator/mandatory-files-validator.js +7 -6
- package/dist/services/integration-api/virtual/external-recipe.js +2 -1
- package/dist/services/onboarding/browser/baqend-response.js +1 -2
- package/dist/services/onboarding/config-renderer/speed-kit-install-context.js +1 -1
- package/dist/services/onboarding/dashboard/index.d.ts +3 -3
- package/dist/services/onboarding/dashboard/index.js +12 -12
- package/dist/services/onboarding/dashboard/{param-query-builder.d.ts → parameter-query-builder.d.ts} +1 -1
- package/dist/services/onboarding/dashboard/{param-query-builder.js → parameter-query-builder.js} +6 -6
- package/dist/services/onboarding/dashboard/request-diff-service.js +24 -22
- package/dist/services/onboarding/fetch-events/customer-domain-document-response.js +8 -8
- package/dist/services/onboarding/fetch-events/speed-kit-asset-request.js +7 -7
- package/dist/services/onboarding/onboarding-model.js +4 -4
- package/dist/services/onboarding/onboarding-service-factory.js +3 -3
- package/dist/services/onboarding/onboarding-service.js +2 -1
- package/dist/services/onboarding/todo-collector.js +1 -1
- package/dist/services/prewarm-service.d.ts +1 -1
- package/dist/services/prewarm-service.js +8 -7
- package/dist/services/pull/pull-service.js +2 -2
- package/oclif.manifest.json +45 -42
- package/package.json +2 -1
- package/dist/helpers/isDirectory.d.ts +0 -1
- package/dist/services/context/app-context.d.ts +0 -1
- package/dist/services/deploy/error/create-find-temp-directory-error.d.ts +0 -4
- package/dist/services/document-handler-runtime/interface/template-param-interface.js +0 -2
- /package/dist/helpers/{getChromePath.d.ts → get-chrome-path.d.ts} +0 -0
- /package/dist/helpers/{isExecutable.d.ts → is-executable.d.ts} +0 -0
- /package/dist/helpers/{isFile.d.ts → is-file.d.ts} +0 -0
- /package/dist/helpers/{speedKitRuleToRegExp.d.ts → speed-kit-rule-to-reg-exp.d.ts} +0 -0
- /package/dist/helpers/{watchFiles.d.ts → watch-files.d.ts} +0 -0
- /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.
|
|
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
|
|
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
|
-
.
|
|
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 =
|
|
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 =
|
|
80
|
+
const blacklistedPathnamesFilter = getRuleProperty(blacklist, "pathname")
|
|
82
81
|
.map((pathname) => getFilterForProperty(pathname, "url", false, "pathname"))
|
|
83
82
|
.join("\n and ");
|
|
84
|
-
const blacklistedUrlsFilter =
|
|
83
|
+
const blacklistedUrlsFilter = getRuleProperty(blacklist, "url")
|
|
85
84
|
.map((url) => getFilterForProperty(url, "url", false, "url"))
|
|
86
85
|
.join("\n and ");
|
|
87
|
-
const disabledFilter =
|
|
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(
|
|
110
|
-
return
|
|
111
|
-
.map((
|
|
108
|
+
function getParameterFilter(parameters, skConfigVersion = 1) {
|
|
109
|
+
return parameters
|
|
110
|
+
.map((parameter) => {
|
|
112
111
|
// Prefix comparison for strings
|
|
113
|
-
if (typeof
|
|
114
|
-
|
|
115
|
-
|
|
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(
|
|
123
|
-
return `not regexp_like(key, '${ignoreCase ? "(?i)" : ""}${getStringBetween(String(
|
|
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(
|
|
135
|
-
const
|
|
136
|
-
const
|
|
137
|
-
const
|
|
138
|
-
const
|
|
139
|
-
const
|
|
140
|
-
const
|
|
141
|
-
|
|
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
|
|
139
|
+
if (typeof parameter === "string") {
|
|
144
140
|
if (skConfigVersion === 1) {
|
|
145
|
-
|
|
141
|
+
prefixParameters.push(parameter);
|
|
142
|
+
continue;
|
|
146
143
|
}
|
|
147
144
|
else {
|
|
148
|
-
|
|
145
|
+
fullMatchParameters.push(parameter);
|
|
146
|
+
continue;
|
|
149
147
|
}
|
|
150
148
|
}
|
|
151
|
-
const ignoreCase = isRegExpIgnoringCase(
|
|
149
|
+
const ignoreCase = isRegExpIgnoringCase(parameter);
|
|
152
150
|
// Regex params with start marker but no end marker
|
|
153
|
-
if (/\/\^[^$]+$/.test(String(
|
|
154
|
-
|
|
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 (/\/[
|
|
158
|
-
|
|
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(
|
|
162
|
-
|
|
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 ?
|
|
166
|
-
}
|
|
166
|
+
(ignoreCase ? fullMatchIgnoreCaseParameters : fullMatchParameters).push(getStringBetween(String(parameter), "/", "/"));
|
|
167
|
+
}
|
|
167
168
|
let regExpQuery = "regexp_replace(url, '#.*' )";
|
|
168
169
|
const regExps = [
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
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
|
-
|
|
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
|
|
189
|
-
return
|
|
190
|
-
? `${ignoreCase ? "(?i)" : ""}[?&](${
|
|
189
|
+
function getParameterPrefixRegExp(parameters, ignoreCase) {
|
|
190
|
+
return parameters.length > 0
|
|
191
|
+
? `${ignoreCase ? "(?i)" : ""}[?&](${parameters.join("|")})[^&]*`
|
|
191
192
|
: null;
|
|
192
193
|
}
|
|
193
|
-
function
|
|
194
|
-
return
|
|
195
|
-
? `${ignoreCase ? "(?i)" : ""}[?&][^&]*(${
|
|
194
|
+
function getParameterSuffixRegExp(parameters, ignoreCase) {
|
|
195
|
+
return parameters.length > 0
|
|
196
|
+
? `${ignoreCase ? "(?i)" : ""}[?&][^&]*(${parameters.join("|")})(=[^&]*)?(?=&|$)`
|
|
196
197
|
: null;
|
|
197
198
|
}
|
|
198
|
-
function
|
|
199
|
-
return
|
|
200
|
-
? `${ignoreCase ? "(?i)" : ""}[?&](${
|
|
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
|
|
209
|
-
const
|
|
210
|
-
if (!
|
|
209
|
+
function getStrippedParameters(parsedConfig) {
|
|
210
|
+
const parameterArray = parsedConfig.stripQueryParams;
|
|
211
|
+
if (!parameterArray) {
|
|
211
212
|
return [];
|
|
212
213
|
}
|
|
213
|
-
const isSimpleArray =
|
|
214
|
+
const isSimpleArray = parameterArray.every((parameter) => typeof parameter === "string" || parameter instanceof RegExp);
|
|
214
215
|
if (isSimpleArray) {
|
|
215
|
-
return
|
|
216
|
+
return parameterArray;
|
|
216
217
|
}
|
|
217
|
-
const
|
|
218
|
-
for (const entry of
|
|
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
|
-
|
|
224
|
+
parameters.push(entry.params);
|
|
224
225
|
continue;
|
|
225
226
|
}
|
|
226
|
-
|
|
227
|
+
parameters.push(...entry.params);
|
|
227
228
|
}
|
|
228
|
-
return
|
|
229
|
+
return parameters;
|
|
229
230
|
}
|
|
230
|
-
exports.
|
|
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
|
|
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
|
|
73
|
+
if (!(configKey in environmentMapping)) {
|
|
74
74
|
continue;
|
|
75
75
|
}
|
|
76
|
-
const
|
|
77
|
-
if (
|
|
78
|
-
|
|
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
|
|
4
|
+
type Parameters_ = {
|
|
5
5
|
[param: string]: any;
|
|
6
6
|
};
|
|
7
|
-
type
|
|
8
|
-
[configName: string]:
|
|
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(
|
|
36
|
-
static loadCustomer(
|
|
37
|
-
constructor(
|
|
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
|
|
6
|
-
const
|
|
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,
|
|
32
|
-
if (check(
|
|
33
|
-
return
|
|
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.
|
|
35
|
+
throw new TypeError(`Please provide a ${check.name.slice(2)} "${name}" property.`);
|
|
36
36
|
}
|
|
37
|
-
function optional(check,
|
|
38
|
-
if (check(
|
|
39
|
-
return
|
|
37
|
+
function optional(check, parameters, name, defaultValue = null) {
|
|
38
|
+
if (check(parameters[name])) {
|
|
39
|
+
return parameters[name];
|
|
40
40
|
}
|
|
41
|
-
if (
|
|
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.
|
|
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(
|
|
78
|
-
const mainConfig = await ConfigFile.loadFile(
|
|
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(
|
|
86
|
-
const customerConfig = await this.loadConfig(
|
|
87
|
-
let
|
|
85
|
+
static async loadCustomer(directory, configName) {
|
|
86
|
+
const customerConfig = await this.loadConfig(directory);
|
|
87
|
+
let parameters;
|
|
88
88
|
if (configName in customerConfig) {
|
|
89
|
-
|
|
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
|
-
|
|
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(
|
|
99
|
+
configs[key] = await ConfigFile.loadFile(directory, path, path.replace(".js", ".es6"));
|
|
100
100
|
}
|
|
101
101
|
// Parse config
|
|
102
|
-
return new CustomerConfig({ name: configName, ...
|
|
102
|
+
return new CustomerConfig({ name: configName, ...parameters }, {
|
|
103
103
|
...configs,
|
|
104
|
-
popConfig: await ConfigFile.loadFile(
|
|
105
|
-
globalWhitelist: await ConfigFile.loadFile(
|
|
106
|
-
globalBlacklist: await ConfigFile.loadFile(
|
|
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(
|
|
110
|
-
this.domain = required(isString,
|
|
111
|
-
this.name = optional(isString,
|
|
112
|
-
this.swPath = optional(isString,
|
|
113
|
-
this.app = optional(isString,
|
|
114
|
-
this.appDomain = optional(isString,
|
|
115
|
-
this.chromeFlags = optional(Array.isArray,
|
|
116
|
-
this.installPath = optional(isString,
|
|
117
|
-
const scope = optional(isString,
|
|
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,
|
|
120
|
-
this.installParams = optional(isString,
|
|
121
|
-
this.forceInstall = optional(isBoolean,
|
|
122
|
-
this.bypassDeactivation = optional(isBoolean,
|
|
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 =
|
|
134
|
-
if (await (0,
|
|
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
|
|
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.
|
|
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
|
|
9
|
-
async function
|
|
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.
|
|
18
|
+
exports.createTemporalDirectory = createTemporalDirectory;
|
|
19
19
|
async function readLocalFile(basePath, fileName) {
|
|
20
20
|
try {
|
|
21
|
-
const file = await
|
|
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
|
|
5
|
-
const
|
|
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
|
|
20
|
-
if (!
|
|
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
|
|
24
|
-
const chromePath = ENV_CHROME_REGEX.test(
|
|
25
|
-
?
|
|
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,
|
|
27
|
+
return (await (0, is_file_1.isFile)(chromePath))
|
|
28
28
|
? chromePath
|
|
29
29
|
: CHROME_PATHS[process.platform];
|
|
30
30
|
}
|
|
@@ -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: () =>
|
|
13
|
-
getItem: () =>
|
|
12
|
+
clear: () => { },
|
|
13
|
+
getItem: () => { },
|
|
14
14
|
key: () => null,
|
|
15
|
-
removeItem: () =>
|
|
16
|
-
setItem: () =>
|
|
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 (
|
|
52
|
-
throw new Error(`Speed Kit config string could not be parsed.\n${
|
|
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(
|
|
4
|
+
const promises_1 = require("node:fs/promises");
|
|
5
|
+
async function isDirectory(directory) {
|
|
6
6
|
try {
|
|
7
|
-
const stats = await (0, promises_1.stat)(
|
|
7
|
+
const stats = await (0, promises_1.stat)(directory);
|
|
8
8
|
return stats.isDirectory();
|
|
9
9
|
}
|
|
10
|
-
catch (
|
|
11
|
-
if (
|
|
10
|
+
catch (error) {
|
|
11
|
+
if (error.code === "ENOENT") {
|
|
12
12
|
return false;
|
|
13
13
|
}
|
|
14
|
-
throw
|
|
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
|
|
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,
|
|
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 (
|
|
11
|
-
if (
|
|
10
|
+
catch (error) {
|
|
11
|
+
if (error.code === "ENOENT") {
|
|
12
12
|
return false;
|
|
13
13
|
}
|
|
14
|
-
throw
|
|
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, ...
|
|
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, ...
|
|
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, ...
|
|
12
|
+
export declare function logWarning(message: string, ...optionalParameters: any[]): void;
|