@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
|
@@ -27,10 +27,11 @@ const FILE_DEPENDENCIES = [
|
|
|
27
27
|
];
|
|
28
28
|
class DocumentHandlerRuntimeContext {
|
|
29
29
|
verboseLevel;
|
|
30
|
-
fileDependencies =
|
|
30
|
+
fileDependencies = [
|
|
31
|
+
...FILE_DEPENDENCIES,
|
|
31
32
|
exports.LOCAL_DOCUMENT_HANDLER,
|
|
32
33
|
exports.LOCAL_DYNAMIC_FETCHER,
|
|
33
|
-
]
|
|
34
|
+
];
|
|
34
35
|
customerPath;
|
|
35
36
|
configName;
|
|
36
37
|
testNames;
|
|
@@ -41,13 +42,14 @@ class DocumentHandlerRuntimeContext {
|
|
|
41
42
|
this.customerPath = customerPath;
|
|
42
43
|
this.testNames = testNames;
|
|
43
44
|
let dependencies = [];
|
|
44
|
-
if (this.testNames && this.testNames.length
|
|
45
|
-
this.testNames
|
|
46
|
-
dependencies =
|
|
45
|
+
if (this.testNames && this.testNames.length > 0) {
|
|
46
|
+
for (const testName of this.testNames) {
|
|
47
|
+
dependencies = [
|
|
48
|
+
...dependencies,
|
|
47
49
|
`${exports.TEST_FILE_NAME_PREFIX}-${testName}`,
|
|
48
|
-
]
|
|
49
|
-
}
|
|
50
|
-
this.fileDependencies = this.fileDependencies
|
|
50
|
+
];
|
|
51
|
+
}
|
|
52
|
+
this.fileDependencies = [...this.fileDependencies, ...dependencies];
|
|
51
53
|
}
|
|
52
54
|
this.requiredFiles = [
|
|
53
55
|
exports.CUSTOMER_CONFIG,
|
|
@@ -68,16 +68,16 @@ class DocumentHandlerRuntimeService {
|
|
|
68
68
|
this.cli.write("3. debug current file with intellij");
|
|
69
69
|
}
|
|
70
70
|
async createDocumentHandlerFile() {
|
|
71
|
-
const
|
|
72
|
-
const
|
|
71
|
+
const documentHandler = await this.getDocumentHandler();
|
|
72
|
+
const documentHandlerConfig = this.getDocumentHandlerConfig()
|
|
73
73
|
.replace("APP", this.escapeFileContent(this.customerConfig.app))
|
|
74
74
|
.replace("DYNAMIC_FETCHER", await this.getDynamicFetcher())
|
|
75
75
|
.replace("DYNAMIC_FETCHER_CONFIG", this.getDynamicFetcherConfig())
|
|
76
76
|
.replace("CUSTOM_STYLES", this.getStyles())
|
|
77
77
|
.replace(this.getConfigTransformSearchTemplate(), this.getConfigTransformReplaceTemplate());
|
|
78
78
|
const file = this.getTestDocHandlerFile();
|
|
79
|
-
const isNew = file.getContent().length
|
|
80
|
-
file.setContent(`${this.getSeparator("Context")} ${this.getContextVars()} ${
|
|
79
|
+
const isNew = file.getContent().length === 0;
|
|
80
|
+
file.setContent(`${this.getSeparator("Context")} ${this.getContextVars()} ${documentHandler} ${this.getSeparator("start config_documentHandler")} ${documentHandlerConfig}`);
|
|
81
81
|
await file.updateFile();
|
|
82
82
|
this.cli.writeSuccess(`${isNew ? "created" : "updated"} documentHandler from config`);
|
|
83
83
|
}
|
|
@@ -179,25 +179,25 @@ class DocumentHandlerRuntimeService {
|
|
|
179
179
|
return this.escapeFileContent(this.files.getByName(document_handler_runtime_context_1.LOCAL_STYLES).getContent());
|
|
180
180
|
}
|
|
181
181
|
getDocumentHandlerConfig() {
|
|
182
|
-
const
|
|
183
|
-
if (!
|
|
182
|
+
const documentHandlerFile = this.files.getByName(document_handler_runtime_context_1.LOCAL_DOCUMENT_HANDLER_CONFIG);
|
|
183
|
+
if (!documentHandlerFile) {
|
|
184
184
|
throw new required_file_not_found_error_1.default({
|
|
185
185
|
message: `file ${document_handler_runtime_context_1.LOCAL_DOCUMENT_HANDLER_CONFIG} not found`,
|
|
186
186
|
});
|
|
187
187
|
}
|
|
188
|
-
return
|
|
188
|
+
return documentHandlerFile.getContent();
|
|
189
189
|
}
|
|
190
190
|
getTestDocHandlerFile() {
|
|
191
191
|
return this.files.getByName(document_handler_runtime_context_1.TEST_DOCUMENT_HANDLER_FILE_NAME);
|
|
192
192
|
}
|
|
193
193
|
escapeFileContent(content) {
|
|
194
194
|
const escapedContent = content
|
|
195
|
-
.
|
|
196
|
-
.
|
|
195
|
+
.replaceAll("${", "\\${")
|
|
196
|
+
.replaceAll("`", "\\`");
|
|
197
197
|
return `\`${escapedContent}\``;
|
|
198
198
|
}
|
|
199
199
|
escapeFileContent2(content) {
|
|
200
|
-
const escapedContent = content.
|
|
200
|
+
const escapedContent = content.replaceAll("'", "\\'");
|
|
201
201
|
return `'${escapedContent}'`;
|
|
202
202
|
}
|
|
203
203
|
getContextVars() {
|
|
@@ -5,9 +5,9 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const document_handler_runtime_context_1 = require("./context/document-handler-runtime-context");
|
|
6
6
|
const required_file_not_found_error_1 = tslib_1.__importDefault(require("./error/required-file-not-found-error"));
|
|
7
7
|
const database_mock_1 = tslib_1.__importDefault(require("./templates/database-mock"));
|
|
8
|
-
const vm = tslib_1.__importStar(require("vm"));
|
|
8
|
+
const vm = tslib_1.__importStar(require("node:vm"));
|
|
9
9
|
const vm_error_1 = require("../onboarding/error/vm-error");
|
|
10
|
-
const
|
|
10
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
11
11
|
const files_1 = require("../../models/files");
|
|
12
12
|
// documentHandlerDependencies
|
|
13
13
|
const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
|
|
@@ -76,9 +76,9 @@ class DocumentHandlerServer {
|
|
|
76
76
|
this.cli.writeSuccess("rebuild documentHandler");
|
|
77
77
|
}
|
|
78
78
|
async createDocumentHandlerFile() {
|
|
79
|
-
const
|
|
80
|
-
const
|
|
81
|
-
return `${this.getContextVars()} ${
|
|
79
|
+
const documentHandler = await this.getDocumentHandler();
|
|
80
|
+
const documentHandlerConfig = this.getDocumentHandlerConfig().replace("export const post", "const post");
|
|
81
|
+
return `${this.getContextVars()} ${documentHandler} ${documentHandlerConfig}`;
|
|
82
82
|
}
|
|
83
83
|
async getDocumentHandler() {
|
|
84
84
|
return this.files
|
|
@@ -104,13 +104,13 @@ class DocumentHandlerServer {
|
|
|
104
104
|
return this.files.getByName(document_handler_runtime_context_1.LOCAL_STYLES).getContent();
|
|
105
105
|
}
|
|
106
106
|
getDocumentHandlerConfig() {
|
|
107
|
-
const
|
|
108
|
-
if (!
|
|
107
|
+
const documentHandlerFile = this.files.getByName(document_handler_runtime_context_1.LOCAL_DOCUMENT_HANDLER_CONFIG);
|
|
108
|
+
if (!documentHandlerFile) {
|
|
109
109
|
throw new required_file_not_found_error_1.default({
|
|
110
110
|
message: `file ${document_handler_runtime_context_1.LOCAL_DOCUMENT_HANDLER_CONFIG} not found`,
|
|
111
111
|
});
|
|
112
112
|
}
|
|
113
|
-
return
|
|
113
|
+
return documentHandlerFile.getContent();
|
|
114
114
|
}
|
|
115
115
|
getContextVars() {
|
|
116
116
|
let template = "";
|
|
@@ -139,9 +139,9 @@ class DocumentHandlerServer {
|
|
|
139
139
|
};
|
|
140
140
|
if (!this.database) {
|
|
141
141
|
const dataBaseMock = new database_mock_1.default();
|
|
142
|
-
const
|
|
142
|
+
const databaseCode = dataBaseMock.render(dataBaseMock.buildContext(this.customerConfig.origins[0], this.customerConfig.app));
|
|
143
143
|
const vmContext = { console: vmConsole, module: { exports: {} } };
|
|
144
|
-
vm.runInNewContext(
|
|
144
|
+
vm.runInNewContext(databaseCode, vmContext);
|
|
145
145
|
this.database = vmContext.module.exports;
|
|
146
146
|
}
|
|
147
147
|
return this.database;
|
|
@@ -167,8 +167,8 @@ class DocumentHandlerServer {
|
|
|
167
167
|
if (module.includes("fetch")) {
|
|
168
168
|
return this.createFetchMock();
|
|
169
169
|
}
|
|
170
|
-
const fileExtension =
|
|
171
|
-
const moduleFileName =
|
|
170
|
+
const fileExtension = node_path_1.default.extname(module);
|
|
171
|
+
const moduleFileName = node_path_1.default.basename(module, fileExtension);
|
|
172
172
|
if (this.files.hasFile(moduleFileName)) {
|
|
173
173
|
const vmContext = {
|
|
174
174
|
module: { exports: {} },
|
package/dist/services/document-handler-runtime/factory/document-handler-runtime-service-factory.js
CHANGED
|
@@ -52,13 +52,13 @@ class DocumentHandlerRuntimeServiceFactory extends abstract_async_error_handling
|
|
|
52
52
|
return await integrationApi.run();
|
|
53
53
|
}
|
|
54
54
|
checkRequiredFiles(files) {
|
|
55
|
-
this.context.requiredFiles
|
|
55
|
+
for (const requiredFile of this.context.requiredFiles) {
|
|
56
56
|
if (!files.hasFile(requiredFile)) {
|
|
57
57
|
throw new required_file_not_found_error_1.default({
|
|
58
58
|
message: `file ${requiredFile} not found`,
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
|
-
}
|
|
61
|
+
}
|
|
62
62
|
}
|
|
63
63
|
createNeededFolderStructure(integrationApi) {
|
|
64
64
|
integrationApi.createFolder(".local");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import TemplateParameter from "./template-parameter-interface";
|
|
2
2
|
import TemplateContextInterface from "./template-context-interface";
|
|
3
3
|
export default interface TemplateInterface {
|
|
4
|
-
_buildContext(...
|
|
4
|
+
_buildContext(...parameters: TemplateParameter[]): TemplateContextInterface;
|
|
5
5
|
render(context: TemplateContextInterface): string;
|
|
6
6
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import TemplateInterface from "../interface/template-interface";
|
|
2
|
-
import
|
|
2
|
+
import TemplateParameter from "../interface/template-parameter-interface";
|
|
3
3
|
import TemplateContextInterface from "../interface/template-context-interface";
|
|
4
4
|
import { Template } from "handlebars";
|
|
5
5
|
export default abstract class AbstractTemplate implements TemplateInterface {
|
|
6
|
-
_buildContext(...
|
|
6
|
+
_buildContext(...parameters: TemplateParameter[]): TemplateContextInterface;
|
|
7
7
|
render(context: TemplateContextInterface): string;
|
|
8
8
|
protected abstract getTemplate(): Template;
|
|
9
9
|
}
|
|
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const handlebars_1 = tslib_1.__importDefault(require("handlebars"));
|
|
5
5
|
class AbstractTemplate {
|
|
6
|
-
_buildContext(...
|
|
6
|
+
_buildContext(...parameters) {
|
|
7
7
|
const context = {};
|
|
8
|
-
|
|
8
|
+
for (const { key, value } of parameters) {
|
|
9
9
|
context[key] = value;
|
|
10
|
-
}
|
|
10
|
+
}
|
|
11
11
|
return context;
|
|
12
12
|
}
|
|
13
13
|
render(context) {
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import ErrorHandlingService from "../error-handling-service";
|
|
2
|
-
import CustomerConfigLegacyHandler from "../../integration-api/error/handler/customer-config-legacy-handler";
|
|
3
|
-
import OriginHandler from "../../integration-api/error/handler/origin-handler";
|
|
4
|
-
import { CustomerConfigHandler } from "../../integration-api/error/handler/customer-config-handler";
|
|
5
2
|
export default class ErrorHandlingFactory {
|
|
6
3
|
buildService(): ErrorHandlingService;
|
|
7
|
-
importHandlers(): (
|
|
4
|
+
importHandlers(): import("../interface/error-handler-interface").default[];
|
|
8
5
|
}
|
|
@@ -15,7 +15,8 @@ class ErrorHandlingFactory {
|
|
|
15
15
|
new customer_config_legacy_handler_1.default(),
|
|
16
16
|
new origin_handler_1.default(),
|
|
17
17
|
new customer_config_handler_1.CustomerConfigHandler(),
|
|
18
|
-
|
|
18
|
+
...document_handler_runtime_service_factory_1.default.getErrorHandlers(),
|
|
19
|
+
];
|
|
19
20
|
}
|
|
20
21
|
}
|
|
21
22
|
exports.default = ErrorHandlingFactory;
|
|
@@ -43,7 +43,7 @@ class IntegrationApiServiceFactory {
|
|
|
43
43
|
new install_resource_handler_1.default(fileReader),
|
|
44
44
|
new server_config_handler_1.default(fileReader),
|
|
45
45
|
new module_handler_1.default(fileReader),
|
|
46
|
-
], new file_writer_1.default(this.context.basePath), this.context.whiteList.length
|
|
46
|
+
], new file_writer_1.default(this.context.basePath), this.context.whiteList.length === 0);
|
|
47
47
|
}
|
|
48
48
|
getFileReader() {
|
|
49
49
|
if (!this.fileReader) {
|
|
@@ -55,16 +55,17 @@ class FileList {
|
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
57
|
getByName(name) {
|
|
58
|
-
const
|
|
58
|
+
const file_ = this.files.find((file) => {
|
|
59
59
|
return file.name === name;
|
|
60
60
|
});
|
|
61
|
-
return
|
|
61
|
+
return file_;
|
|
62
62
|
}
|
|
63
63
|
filter(callback) {
|
|
64
64
|
this.files = this.files.filter((file) => callback(file));
|
|
65
65
|
}
|
|
66
66
|
concat(fileList) {
|
|
67
|
-
|
|
67
|
+
for (const file of fileList.files)
|
|
68
|
+
this.files.push(file);
|
|
68
69
|
}
|
|
69
70
|
replace(replaceWith) {
|
|
70
71
|
const files = [];
|
|
@@ -5,7 +5,7 @@ export default class FileReader {
|
|
|
5
5
|
private readonly blockedFolders;
|
|
6
6
|
allowedExtensions: string[];
|
|
7
7
|
constructor(configName: string, basePath: string, whiteList?: string[], blockedFolders?: string[]);
|
|
8
|
-
getFileList(
|
|
8
|
+
getFileList(directoryName?: string): Promise<string[]>;
|
|
9
9
|
getContent(path: string): Promise<string>;
|
|
10
10
|
isAllowedFolder(folderName: string): boolean;
|
|
11
11
|
isAllowedFile(fileName: string): boolean;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const promises_1 = require("fs/promises");
|
|
4
|
+
const node_fs_1 = require("node:fs");
|
|
5
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
6
|
+
const promises_1 = require("node:fs/promises");
|
|
7
7
|
const CUSTOMER_CONFIG_FILE = "config_customer";
|
|
8
8
|
const DEFAULT_ENV = "production";
|
|
9
9
|
class FileReader {
|
|
@@ -18,21 +18,23 @@ class FileReader {
|
|
|
18
18
|
this.whiteList = whiteList;
|
|
19
19
|
this.blockedFolders = blockedFolders;
|
|
20
20
|
}
|
|
21
|
-
async getFileList(
|
|
21
|
+
async getFileList(directoryName = this.basePath) {
|
|
22
22
|
let files = [];
|
|
23
|
-
const items = await
|
|
23
|
+
const items = await node_fs_1.promises.readdir(directoryName, {
|
|
24
|
+
withFileTypes: true,
|
|
25
|
+
});
|
|
24
26
|
for (const item of items) {
|
|
25
27
|
if (item.isDirectory()) {
|
|
26
28
|
if (this.isAllowedFolder(item.name)) {
|
|
27
29
|
files = [
|
|
28
30
|
...files,
|
|
29
|
-
...(await this.getFileList(
|
|
31
|
+
...(await this.getFileList(node_path_1.default.resolve(directoryName, item.name))),
|
|
30
32
|
];
|
|
31
33
|
}
|
|
32
34
|
continue;
|
|
33
35
|
}
|
|
34
36
|
if (this.isAllowedFile(item.name)) {
|
|
35
|
-
files.push(
|
|
37
|
+
files.push(node_path_1.default.resolve(directoryName, item.name));
|
|
36
38
|
}
|
|
37
39
|
}
|
|
38
40
|
return this.mapEnvironment(files);
|
|
@@ -47,8 +49,7 @@ class FileReader {
|
|
|
47
49
|
}
|
|
48
50
|
isAllowedFile(fileName) {
|
|
49
51
|
const extension = this.getFileExtension(fileName);
|
|
50
|
-
return (this.allowedExtensions.
|
|
51
|
-
this.isWhiteListed(fileName));
|
|
52
|
+
return (this.allowedExtensions.includes(extension) && this.isWhiteListed(fileName));
|
|
52
53
|
}
|
|
53
54
|
getFileExtension(fileName) {
|
|
54
55
|
return fileName.slice(((fileName.lastIndexOf(".") - 1) >>> 0) + 2);
|
|
@@ -67,33 +68,35 @@ class FileReader {
|
|
|
67
68
|
});
|
|
68
69
|
}
|
|
69
70
|
mapEnvironment(fileList) {
|
|
70
|
-
const
|
|
71
|
+
const environmentFileList = {};
|
|
71
72
|
// create mapped object with all environment versions of a file
|
|
72
|
-
for (
|
|
73
|
-
const shortFileName =
|
|
74
|
-
const fullFileName = fileList[index];
|
|
73
|
+
for (const fullFileName of fileList) {
|
|
74
|
+
const shortFileName = node_path_1.default.basename(fullFileName);
|
|
75
75
|
const fileName = shortFileName.split(".").slice(0, -1).join(".");
|
|
76
|
-
let
|
|
77
|
-
if (
|
|
78
|
-
|
|
76
|
+
let environment = fileName.split(".").pop();
|
|
77
|
+
if (environment === fileName) {
|
|
78
|
+
environment = DEFAULT_ENV;
|
|
79
79
|
}
|
|
80
|
-
const fileKey =
|
|
80
|
+
const fileKey = environment === DEFAULT_ENV
|
|
81
81
|
? fileName
|
|
82
82
|
: fileName.split(".").slice(0, -1).join(".");
|
|
83
|
-
|
|
83
|
+
environmentFileList[fileKey] = {
|
|
84
|
+
...environmentFileList[fileKey],
|
|
85
|
+
[environment]: fullFileName,
|
|
86
|
+
};
|
|
84
87
|
}
|
|
85
88
|
// map object to current environment with fallback on production
|
|
86
|
-
return
|
|
87
|
-
.map((
|
|
88
|
-
if (this.configName in
|
|
89
|
-
return
|
|
89
|
+
return Object.values(environmentFileList)
|
|
90
|
+
.map((environmentFile) => {
|
|
91
|
+
if (this.configName in environmentFile) {
|
|
92
|
+
return environmentFile[this.configName];
|
|
90
93
|
}
|
|
91
|
-
if (DEFAULT_ENV in
|
|
92
|
-
return
|
|
94
|
+
if (DEFAULT_ENV in environmentFile) {
|
|
95
|
+
return environmentFile[DEFAULT_ENV];
|
|
93
96
|
}
|
|
94
97
|
// if no env was found return original fileName
|
|
95
|
-
for (const key in
|
|
96
|
-
return
|
|
98
|
+
for (const key in environmentFile) {
|
|
99
|
+
return environmentFile[key];
|
|
97
100
|
}
|
|
98
101
|
})
|
|
99
102
|
.filter((value) => !!value);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const node_fs_1 = require("node:fs");
|
|
5
|
-
const
|
|
5
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
6
6
|
class FileWriter {
|
|
7
7
|
basePath;
|
|
8
8
|
constructor(basePath) {
|
|
@@ -12,7 +12,7 @@ class FileWriter {
|
|
|
12
12
|
(0, node_fs_1.writeFileSync)(this.getPath(fileName, extension), content);
|
|
13
13
|
}
|
|
14
14
|
mkdir(directoryPath) {
|
|
15
|
-
(0, node_fs_1.mkdirSync)(
|
|
15
|
+
(0, node_fs_1.mkdirSync)(node_path_1.default.resolve(this.basePath, directoryPath), { recursive: true });
|
|
16
16
|
}
|
|
17
17
|
hasFile(fileName, extension) {
|
|
18
18
|
return (0, node_fs_1.existsSync)(this.getPath(fileName, extension));
|
|
@@ -21,7 +21,7 @@ class FileWriter {
|
|
|
21
21
|
(0, node_fs_1.unlinkSync)(this.getPath(fileName, extension));
|
|
22
22
|
}
|
|
23
23
|
getPath(fileName, extension) {
|
|
24
|
-
return
|
|
24
|
+
return node_path_1.default.resolve(this.basePath, `${fileName}.${extension}`);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
exports.default = FileWriter;
|
|
@@ -29,7 +29,7 @@ class InstallResourceHandler extends file_handler_1.default {
|
|
|
29
29
|
config_dynamicStyles: "customStyle",
|
|
30
30
|
};
|
|
31
31
|
canHandle(filePath) {
|
|
32
|
-
return this.allowedFiles.
|
|
32
|
+
return this.allowedFiles.includes(this.getFileName(filePath));
|
|
33
33
|
}
|
|
34
34
|
async handle(filePath) {
|
|
35
35
|
const fileName = this.getFileName(filePath);
|
|
@@ -11,7 +11,7 @@ class ModuleHandler extends file_handler_1.default {
|
|
|
11
11
|
* @param filePath
|
|
12
12
|
*/
|
|
13
13
|
canHandle(filePath) {
|
|
14
|
-
return this.blackList.
|
|
14
|
+
return !this.blackList.includes(this.getFileName(filePath));
|
|
15
15
|
}
|
|
16
16
|
async handle(filePath) {
|
|
17
17
|
return new module_file_1.default(this.getFileName(filePath), filePath, await this.fileReader.getContent(filePath), module_file_1.default);
|
|
@@ -6,7 +6,7 @@ const server_config_file_1 = tslib_1.__importDefault(require("../struct/server-c
|
|
|
6
6
|
class ServerConfigHandler extends file_handler_1.default {
|
|
7
7
|
allowedFiles = ["orestes_config"];
|
|
8
8
|
canHandle(filePath) {
|
|
9
|
-
return this.allowedFiles.
|
|
9
|
+
return this.allowedFiles.includes(this.getFileName(filePath));
|
|
10
10
|
}
|
|
11
11
|
async handle(filePath) {
|
|
12
12
|
const fileContent = await this.fileReader.getContent(filePath);
|
|
@@ -36,8 +36,7 @@ class IntegrationApiService {
|
|
|
36
36
|
async collectFiles() {
|
|
37
37
|
const files = await this.fileReader.getFileList();
|
|
38
38
|
const fileList = new file_list_1.default();
|
|
39
|
-
for (
|
|
40
|
-
const file = files[iteration];
|
|
39
|
+
for (const file of files) {
|
|
41
40
|
fileList.addFile(await this.processFile(file));
|
|
42
41
|
}
|
|
43
42
|
if (this.shouldValidate) {
|
|
@@ -53,7 +52,7 @@ class IntegrationApiService {
|
|
|
53
52
|
return await handler.handle(file);
|
|
54
53
|
}
|
|
55
54
|
}
|
|
56
|
-
throw Error(`No handler found for file: ${file}`);
|
|
55
|
+
throw new Error(`No handler found for file: ${file}`);
|
|
57
56
|
}
|
|
58
57
|
filterFilesToProcess(fileList) {
|
|
59
58
|
fileList.filter((file) => {
|
|
@@ -15,7 +15,7 @@ export default class CustomerConfig {
|
|
|
15
15
|
};
|
|
16
16
|
readonly skCliPre?: string;
|
|
17
17
|
readonly skCliPost?: string;
|
|
18
|
-
constructor(app: string, origins: string[], domain: string, swPath: string, scope: string, appDomain?: string, installPath?: string,
|
|
18
|
+
constructor(app: string, origins: string[], domain: string, swPath: string, scope: string, appDomain?: string, installPath?: string, installParameters?: string, name?: string, forceInstall?: boolean, chromeFlags?: string[], dependencies?: {
|
|
19
19
|
[dependency: string]: string;
|
|
20
20
|
}, skCliPre?: string, skCliPost?: string);
|
|
21
21
|
static createFrom(configFile: any, configName?: string): CustomerConfig;
|
|
@@ -17,7 +17,7 @@ class CustomerConfig {
|
|
|
17
17
|
dependencies;
|
|
18
18
|
skCliPre;
|
|
19
19
|
skCliPost;
|
|
20
|
-
constructor(app, origins, domain, swPath, scope, appDomain, installPath,
|
|
20
|
+
constructor(app, origins, domain, swPath, scope, appDomain, installPath, installParameters, name, forceInstall, chromeFlags, dependencies, skCliPre, skCliPost) {
|
|
21
21
|
this.app = app;
|
|
22
22
|
this.origins = origins;
|
|
23
23
|
this.domain = domain;
|
|
@@ -25,7 +25,7 @@ class CustomerConfig {
|
|
|
25
25
|
this.scope = scope;
|
|
26
26
|
this.appDomain = appDomain;
|
|
27
27
|
this.installPath = installPath;
|
|
28
|
-
this.installParams =
|
|
28
|
+
this.installParams = installParameters;
|
|
29
29
|
this.name = name;
|
|
30
30
|
this.forceInstall = forceInstall;
|
|
31
31
|
this.chromeFlags = chromeFlags;
|
|
@@ -35,12 +35,12 @@ class CustomerConfig {
|
|
|
35
35
|
}
|
|
36
36
|
static createFrom(configFile, configName) {
|
|
37
37
|
const { app, origins, domain, swPath, scope, appDomain, installPath, installParams, name, forceInstall, chromeFlags, dependencies, skCliPre, skCliPost, } = configFile;
|
|
38
|
-
return new CustomerConfig(new
|
|
38
|
+
return new CustomerConfig(new RequiredParameter("app", app).isString().getValue(), new RequiredParameter("origins", origins).isArray().getValue(), new RequiredParameter("domain", domain).isString().getValue(), new RequiredParameter("swPath", swPath).isString().getValue(), new RequiredParameter("scope", scope).isString().getValue(), appDomain || `${app}.app.baqend.com`, installPath ||
|
|
39
39
|
`https://${app}.app.baqend.com/v1/speedkit/install.js?d=${name || configName}`, installParams || 'async="" crossorigin="anonymous"', name, forceInstall, chromeFlags, dependencies, skCliPre, skCliPost);
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
exports.default = CustomerConfig;
|
|
43
|
-
class
|
|
43
|
+
class RequiredParameter {
|
|
44
44
|
key;
|
|
45
45
|
value;
|
|
46
46
|
constructor(key, value) {
|
|
@@ -25,8 +25,8 @@ class CustomerConfigValidator {
|
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
checkIfDuplicateExists(
|
|
29
|
-
return new Set(
|
|
28
|
+
checkIfDuplicateExists(array) {
|
|
29
|
+
return new Set(array).size !== array.length;
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
exports.default = CustomerConfigValidator;
|
|
@@ -15,26 +15,27 @@ class MandatoryFilesValidator {
|
|
|
15
15
|
},
|
|
16
16
|
};
|
|
17
17
|
validate(files) {
|
|
18
|
-
this.mandatoryFilesConfig.required
|
|
18
|
+
for (const fileName of this.mandatoryFilesConfig.required) {
|
|
19
19
|
if (!files.hasFile(fileName)) {
|
|
20
20
|
throw new mandatory_file_missing_error_1.default(fileName);
|
|
21
21
|
}
|
|
22
|
-
}
|
|
22
|
+
}
|
|
23
23
|
this.validateConditionally(files);
|
|
24
24
|
}
|
|
25
25
|
validateConditionally(files) {
|
|
26
26
|
let hasRequiredFiles = true;
|
|
27
|
-
this.mandatoryFilesConfig.conditionallyRequired
|
|
27
|
+
for (const fileName of this.mandatoryFilesConfig.conditionallyRequired
|
|
28
|
+
.this) {
|
|
28
29
|
if (!files.hasFile(fileName)) {
|
|
29
30
|
hasRequiredFiles = false;
|
|
30
31
|
}
|
|
31
|
-
}
|
|
32
|
+
}
|
|
32
33
|
let hasConditionallyRequiredFiles = true;
|
|
33
|
-
this.mandatoryFilesConfig.conditionallyRequired.or
|
|
34
|
+
for (const fileName of this.mandatoryFilesConfig.conditionallyRequired.or) {
|
|
34
35
|
if (!files.hasFile(fileName)) {
|
|
35
36
|
hasConditionallyRequiredFiles = false;
|
|
36
37
|
}
|
|
37
|
-
}
|
|
38
|
+
}
|
|
38
39
|
if (!hasRequiredFiles && !hasConditionallyRequiredFiles) {
|
|
39
40
|
throw new Error(`Please implement ${this.mandatoryFilesConfig.conditionallyRequired.this.join(", ")} or ${this.mandatoryFilesConfig.conditionallyRequired.or.join(", ")}`);
|
|
40
41
|
}
|
|
@@ -11,7 +11,8 @@ class ExternalRecipe {
|
|
|
11
11
|
}
|
|
12
12
|
async createContent() {
|
|
13
13
|
if (!this.content) {
|
|
14
|
-
|
|
14
|
+
const file = await this.externalFileReader.load(this.filePath);
|
|
15
|
+
this.content = file.getContent();
|
|
15
16
|
}
|
|
16
17
|
return this.content;
|
|
17
18
|
}
|
|
@@ -53,8 +53,7 @@ class BaqendResponse {
|
|
|
53
53
|
if (!headers?.find((o) => o.name === "Content-Type")) {
|
|
54
54
|
headers.push({ name: "Content-Type", value: String(this.contentType) });
|
|
55
55
|
}
|
|
56
|
-
headers.push({ name: "via", value: "sk-onboarding" });
|
|
57
|
-
headers.push({ name: "Service-Worker-Allowed", value: "/" });
|
|
56
|
+
headers.push({ name: "via", value: "sk-onboarding" }, { name: "Service-Worker-Allowed", value: "/" });
|
|
58
57
|
return headers;
|
|
59
58
|
}
|
|
60
59
|
}
|
|
@@ -59,7 +59,7 @@ class SpeedKitInstallContext {
|
|
|
59
59
|
return configString;
|
|
60
60
|
}
|
|
61
61
|
if (configString.includes("delayRacedOrigin")) {
|
|
62
|
-
return configString.replace(/delayRacedOrigin:[
|
|
62
|
+
return configString.replace(/delayRacedOrigin:[^\d,|](\d*)[^,]*,/, (config, value) => {
|
|
63
63
|
return config.replace(value, "100");
|
|
64
64
|
});
|
|
65
65
|
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { BaqendResponse } from "../browser/baqend-response";
|
|
2
2
|
import { Protocol } from "devtools-protocol";
|
|
3
|
-
import {
|
|
3
|
+
import { ParameterQueryBuilder } from "./parameter-query-builder";
|
|
4
4
|
import CustomerConfig from "../../integration-api/struct/customer-config";
|
|
5
5
|
import { RequestDiffService } from "./request-diff-service";
|
|
6
6
|
import { Cache } from "../request-cache/cache";
|
|
7
7
|
import { AthenaService } from "../../athena";
|
|
8
8
|
export declare class Dashboard {
|
|
9
9
|
private customerConfig;
|
|
10
|
-
private
|
|
10
|
+
private parameterQueryBuilder;
|
|
11
11
|
private athenaClient;
|
|
12
12
|
private requestDiffService;
|
|
13
13
|
private cache;
|
|
14
14
|
private athenaLastResult;
|
|
15
|
-
constructor(customerConfig: CustomerConfig,
|
|
15
|
+
constructor(customerConfig: CustomerConfig, parameterQueryBuilder: ParameterQueryBuilder, athenaClient: AthenaService, requestDiffService: RequestDiffService, cache: Cache);
|
|
16
16
|
getResponse(request: Protocol.Network.Request): Promise<BaqendResponse>;
|
|
17
17
|
}
|