@speedkit/cli 2.26.0 → 2.28.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 +25 -0
- package/README.md +1 -1
- package/dist/models/files.d.ts +4 -0
- package/dist/models/files.js +4 -0
- package/dist/services/cli/error/cli-type-error.d.ts +1 -2
- package/dist/services/cli/error/cli-type-error.js +1 -3
- package/dist/services/config-api/context/config-api-context.d.ts +1 -2
- package/dist/services/config-api/factory/config-api-service-factory.js +1 -2
- package/dist/services/config-api/interface/config-api-context-interface.d.ts +1 -2
- package/dist/services/customer-config/customer-config-service.js +0 -3
- package/dist/services/customer-config/templates/config_documentHandler.js.hbs +0 -4
- package/dist/services/deploy/checks/post-deploy/save-files-check.d.ts +1 -1
- package/dist/services/deploy/checks/pre-deploy/split-change-check.d.ts +1 -2
- package/dist/services/deploy/deploy-service-factory.js +3 -4
- package/dist/services/deploy/deploy-service.d.ts +3 -2
- package/dist/services/deploy/deploy-service.js +23 -1
- package/dist/services/deploy/handler/customer-config-handler.d.ts +4 -5
- package/dist/services/deploy/handler/customer-config-handler.js +2 -2
- package/dist/services/deploy/handler/install-resource-handler.d.ts +3 -4
- package/dist/services/deploy/handler/install-resource-handler.js +2 -3
- package/dist/services/deploy/handler/module-handler.d.ts +8 -5
- package/dist/services/deploy/handler/module-handler.js +2 -3
- package/dist/services/deploy/handler/server-config-handler.d.ts +9 -6
- package/dist/services/deploy/handler/server-config-handler.js +6 -4
- package/dist/services/document-handler-runtime/document-handler-runtime-service.d.ts +2 -3
- package/dist/services/document-handler-runtime/document-handler-runtime-service.js +2 -6
- package/dist/services/document-handler-runtime/document-handler-server.d.ts +1 -2
- package/dist/services/document-handler-runtime/document-handler-server.js +2 -5
- package/dist/services/document-handler-runtime/error/required-file-not-found-error.d.ts +1 -2
- package/dist/services/document-handler-runtime/error/required-file-not-found-error.js +1 -3
- package/dist/services/document-handler-runtime/factory/document-handler-runtime-service-factory.d.ts +3 -6
- package/dist/services/document-handler-runtime/factory/document-handler-runtime-service-factory.js +9 -18
- package/dist/services/integration-api/error/customer-config-legacy-error.d.ts +1 -2
- package/dist/services/integration-api/error/customer-config-legacy-error.js +1 -3
- package/dist/services/integration-api/error/handler/customer-config-legacy-handler.d.ts +1 -2
- package/dist/services/integration-api/error/handler/customer-config-legacy-handler.js +1 -1
- package/dist/services/integration-api/error/handler/origin-handler.d.ts +1 -2
- package/dist/services/integration-api/error/handler/origin-handler.js +1 -1
- package/dist/services/integration-api/error/origin-error.d.ts +1 -2
- package/dist/services/integration-api/error/origin-error.js +1 -3
- package/dist/services/integration-api/file-list.d.ts +3 -5
- package/dist/services/integration-api/file-list.js +6 -10
- package/dist/services/integration-api/file-reader.d.ts +14 -6
- package/dist/services/integration-api/file-reader.js +8 -8
- package/dist/services/integration-api/file-writer.d.ts +10 -2
- package/dist/services/integration-api/file-writer.js +9 -6
- package/dist/services/integration-api/handler/customer-config-handler.js +6 -8
- package/dist/services/integration-api/handler/install-resource-handler.js +3 -4
- package/dist/services/integration-api/handler/module-handler.js +2 -2
- package/dist/services/integration-api/handler/server-config-handler.js +2 -2
- package/dist/services/integration-api/index.d.ts +3 -0
- package/dist/services/integration-api/index.js +6 -0
- package/dist/services/integration-api/integration-api-factory.d.ts +13 -0
- package/dist/services/integration-api/integration-api-factory.js +50 -0
- package/dist/services/integration-api/integration-api-model.d.ts +33 -14
- package/dist/services/integration-api/integration-api-model.js +37 -0
- package/dist/services/integration-api/integration-api-service.d.ts +1 -2
- package/dist/services/integration-api/integration-api-service.js +3 -23
- package/dist/services/integration-api/spec/customer-config-validator.spec.d.ts +1 -0
- package/dist/services/integration-api/spec/customer-config-validator.spec.js +50 -0
- package/dist/services/integration-api/spec/file-list.spec.d.ts +1 -0
- package/dist/services/integration-api/spec/file-list.spec.js +163 -0
- package/dist/services/integration-api/spec/file-reader.spec.d.ts +1 -0
- package/dist/services/integration-api/spec/file-reader.spec.js +71 -0
- package/dist/services/integration-api/spec/file-writer.spec.d.ts +1 -0
- package/dist/services/integration-api/spec/file-writer.spec.js +55 -0
- package/dist/services/integration-api/spec/integration-api-service.spec.d.ts +1 -0
- package/dist/services/integration-api/spec/integration-api-service.spec.js +122 -0
- package/dist/services/integration-api/spec/mandatory-files-validator.spec.d.ts +1 -0
- package/dist/services/integration-api/spec/mandatory-files-validator.spec.js +105 -0
- package/dist/services/integration-api/struct/customer-config-file.d.ts +3 -4
- package/dist/services/integration-api/struct/customer-config-file.js +7 -6
- package/dist/services/integration-api/struct/customer-config.d.ts +3 -5
- package/dist/services/integration-api/struct/customer-config.js +5 -8
- package/dist/services/integration-api/struct/file.d.ts +4 -4
- package/dist/services/integration-api/struct/file.js +6 -6
- package/dist/services/integration-api/struct/install-resource-file.d.ts +4 -3
- package/dist/services/integration-api/struct/install-resource-file.js +7 -5
- package/dist/services/integration-api/struct/module-file.d.ts +4 -3
- package/dist/services/integration-api/struct/module-file.js +7 -5
- package/dist/services/integration-api/struct/ro-file.d.ts +2 -2
- package/dist/services/integration-api/struct/ro-file.js +1 -1
- package/dist/services/integration-api/struct/server-config-file.d.ts +5 -4
- package/dist/services/integration-api/struct/server-config-file.js +7 -5
- package/dist/services/integration-api/struct/virtual-file.d.ts +2 -2
- package/dist/services/integration-api/struct/virtual-file.js +2 -1
- package/dist/services/integration-api/validator/customer-config-validator.d.ts +5 -1
- package/dist/services/integration-api/validator/customer-config-validator.js +28 -17
- package/dist/services/integration-api/virtual/static-recipe.d.ts +6 -0
- package/dist/services/integration-api/virtual/static-recipe.js +14 -0
- package/dist/services/integration-api/virtual/virtual-file-handler.js +2 -2
- package/dist/services/onboarding/config-renderer/speed-kit-install-context.d.ts +1 -2
- package/dist/services/onboarding/dashboard/index.d.ts +1 -1
- package/dist/services/onboarding/dashboard/parameter-query-builder.d.ts +1 -2
- package/dist/services/onboarding/fetch-event-handler.d.ts +1 -1
- package/dist/services/onboarding/fetch-events/customer-domain-document-response.d.ts +1 -2
- package/dist/services/onboarding/fetch-events/customer-service-worker-js.d.ts +1 -1
- package/dist/services/onboarding/fetch-events/speed-kit-asset-request.d.ts +1 -1
- package/dist/services/onboarding/fetch-events/speed-kit-install-html.d.ts +1 -1
- package/dist/services/onboarding/fetch-events/speed-kit-install-js.d.ts +1 -2
- package/dist/services/onboarding/fetch-events/speed-kit-rum-pi-request.d.ts +1 -1
- package/dist/services/onboarding/fetch-events/speed-kit-service-worker-js.d.ts +1 -2
- package/dist/services/onboarding/file-events/file-watcher.d.ts +1 -2
- package/dist/services/onboarding/file-events/file-watcher.js +3 -3
- package/dist/services/onboarding/onboarding-service-factory.js +9 -13
- package/dist/services/onboarding/onboarding-service.d.ts +1 -1
- package/dist/services/onboarding/todo-collector.js +2 -2
- package/dist/services/pull/pull-service-factory.js +3 -4
- package/dist/services/pull/pull-service.d.ts +1 -1
- package/dist/services/pull/pull-service.js +2 -3
- package/oclif.manifest.json +1 -1
- package/package.json +5 -5
- package/dist/services/context/error/context-runtime-error.d.ts +0 -3
- package/dist/services/context/error/context-runtime-error.js +0 -7
- package/dist/services/context/interface/context-interface.d.ts +0 -2
- package/dist/services/context/interface/context-interface.js +0 -2
- package/dist/services/customer-config/templates/deploymentDetection.es6.hbs +0 -303
- package/dist/services/document-handler-runtime/error/handler/required-file-not-found-handler.d.ts +0 -6
- package/dist/services/document-handler-runtime/error/handler/required-file-not-found-handler.js +0 -14
- package/dist/services/error-handling/abstract/abstract-async-error-handling-factory.d.ts +0 -6
- package/dist/services/error-handling/abstract/abstract-async-error-handling-factory.js +0 -19
- package/dist/services/error-handling/abstract/abstract-async-error-handling-service.d.ts +0 -6
- package/dist/services/error-handling/abstract/abstract-async-error-handling-service.js +0 -18
- package/dist/services/error-handling/abstract/abstract-error-handling-factory.d.ts +0 -6
- package/dist/services/error-handling/abstract/abstract-error-handling-factory.js +0 -19
- package/dist/services/error-handling/abstract/abstract-error-handling-service.d.ts +0 -6
- package/dist/services/error-handling/abstract/abstract-error-handling-service.js +0 -19
- package/dist/services/error-handling/error/application-error.d.ts +0 -5
- package/dist/services/error-handling/error/application-error.js +0 -11
- package/dist/services/error-handling/error-handling-service.d.ts +0 -7
- package/dist/services/error-handling/error-handling-service.js +0 -27
- package/dist/services/error-handling/factory/error-handling-factory.d.ts +0 -5
- package/dist/services/error-handling/factory/error-handling-factory.js +0 -22
- package/dist/services/error-handling/interface/error-context-interface.d.ts +0 -6
- package/dist/services/error-handling/interface/error-context-interface.js +0 -2
- package/dist/services/error-handling/interface/error-handler-interface.d.ts +0 -5
- package/dist/services/error-handling/interface/error-handler-interface.js +0 -2
- package/dist/services/error-handling/interface/error-handling-factory-interface.d.ts +0 -8
- package/dist/services/error-handling/interface/error-handling-factory-interface.js +0 -2
- package/dist/services/error-handling/interface/error-handling-service-interface.d.ts +0 -8
- package/dist/services/error-handling/interface/error-handling-service-interface.js +0 -2
- package/dist/services/integration-api/context/integration-api-context.d.ts +0 -9
- package/dist/services/integration-api/context/integration-api-context.js +0 -20
- package/dist/services/integration-api/error/handler/customer-config-handler.d.ts +0 -5
- package/dist/services/integration-api/error/handler/customer-config-handler.js +0 -19
- package/dist/services/integration-api/factory/integration-api-service-factory.d.ts +0 -13
- package/dist/services/integration-api/factory/integration-api-service-factory.js +0 -55
package/dist/services/document-handler-runtime/factory/document-handler-runtime-service-factory.js
CHANGED
|
@@ -1,39 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
const
|
|
5
|
-
const integration_api_service_factory_1 = tslib_1.__importDefault(require("../../integration-api/factory/integration-api-service-factory"));
|
|
4
|
+
const integration_api_1 = require("../../integration-api");
|
|
6
5
|
const document_handler_runtime_context_1 = require("../context/document-handler-runtime-context");
|
|
7
6
|
const document_handler_runtime_service_1 = tslib_1.__importDefault(require("../document-handler-runtime-service"));
|
|
8
|
-
const abstract_async_error_handling_factory_1 = tslib_1.__importDefault(require("../../error-handling/abstract/abstract-async-error-handling-factory"));
|
|
9
7
|
const cli_1 = require("../../cli");
|
|
10
|
-
const required_file_not_found_handler_1 = tslib_1.__importDefault(require("../error/handler/required-file-not-found-handler"));
|
|
11
8
|
const required_file_not_found_error_1 = tslib_1.__importDefault(require("../error/required-file-not-found-error"));
|
|
12
9
|
const document_handler_server_1 = require("../document-handler-server");
|
|
13
10
|
const bundler_1 = require("../../bundler");
|
|
14
|
-
class DocumentHandlerRuntimeServiceFactory
|
|
11
|
+
class DocumentHandlerRuntimeServiceFactory {
|
|
15
12
|
context;
|
|
16
13
|
cliConfig;
|
|
17
14
|
files;
|
|
18
15
|
constructor(context, cliConfig, files) {
|
|
19
|
-
super();
|
|
20
16
|
this.context = context;
|
|
21
17
|
this.cliConfig = cliConfig;
|
|
22
18
|
this.files = files;
|
|
23
19
|
}
|
|
24
|
-
async
|
|
20
|
+
async buildService() {
|
|
25
21
|
const integrationApi = this.prepareIntegrationApi();
|
|
26
22
|
const files = await this.getIntegrationFiles(integrationApi);
|
|
27
23
|
this.checkRequiredFiles(files);
|
|
28
24
|
const cliService = new cli_1.CliServiceFactory().getService();
|
|
29
25
|
const customerConfig = this.getCustomerConfig(files);
|
|
30
26
|
this.preparePackageJson(integrationApi, customerConfig);
|
|
31
|
-
return new document_handler_runtime_service_1.default(files, customerConfig, cliService, { testNames: this.context.testNames || [] }
|
|
27
|
+
return new document_handler_runtime_service_1.default(files, customerConfig, cliService, { testNames: this.context.testNames || [] });
|
|
32
28
|
}
|
|
33
29
|
async buildDocumentHandlerServer() {
|
|
34
|
-
const integrationApiContext = new
|
|
30
|
+
const integrationApiContext = new integration_api_1.IntegrationApiContext(this.context.customerPath, this.context.configName, []);
|
|
35
31
|
const files = this.files ||
|
|
36
|
-
(await new
|
|
32
|
+
(await new integration_api_1.IntegrationApiFactory(integrationApiContext, this.cliConfig)
|
|
37
33
|
.buildService()
|
|
38
34
|
.run());
|
|
39
35
|
const customerConfig = this.getCustomerConfig(files);
|
|
@@ -42,8 +38,8 @@ class DocumentHandlerRuntimeServiceFactory extends abstract_async_error_handling
|
|
|
42
38
|
return new document_handler_server_1.DocumentHandlerServer(customerConfig, files, bundler, cliService, this.context.verboseLevel);
|
|
43
39
|
}
|
|
44
40
|
prepareIntegrationApi() {
|
|
45
|
-
const integrationApiContext = new
|
|
46
|
-
return new
|
|
41
|
+
const integrationApiContext = new integration_api_1.IntegrationApiContext(this.context.customerPath, this.context.configName, this.context.fileDependencies, [".git", ".idea", "node_modules"]);
|
|
42
|
+
return new integration_api_1.IntegrationApiFactory(integrationApiContext, this.cliConfig).buildService();
|
|
47
43
|
}
|
|
48
44
|
async getIntegrationFiles(integrationApi) {
|
|
49
45
|
this.createNeededFolderStructure(integrationApi);
|
|
@@ -54,9 +50,7 @@ class DocumentHandlerRuntimeServiceFactory extends abstract_async_error_handling
|
|
|
54
50
|
checkRequiredFiles(files) {
|
|
55
51
|
for (const requiredFile of this.context.requiredFiles) {
|
|
56
52
|
if (!files.hasFile(requiredFile)) {
|
|
57
|
-
throw new required_file_not_found_error_1.default({
|
|
58
|
-
message: `file ${requiredFile} not found`,
|
|
59
|
-
});
|
|
53
|
+
throw new required_file_not_found_error_1.default(`file ${requiredFile} not found`);
|
|
60
54
|
}
|
|
61
55
|
}
|
|
62
56
|
}
|
|
@@ -103,8 +97,5 @@ class DocumentHandlerRuntimeServiceFactory extends abstract_async_error_handling
|
|
|
103
97
|
const configFile = files.getByName("config_customer");
|
|
104
98
|
return configFile.config;
|
|
105
99
|
}
|
|
106
|
-
static getErrorHandlers() {
|
|
107
|
-
return [new required_file_not_found_handler_1.default()];
|
|
108
|
-
}
|
|
109
100
|
}
|
|
110
101
|
exports.default = DocumentHandlerRuntimeServiceFactory;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
const application_error_1 = tslib_1.__importDefault(require("../../error-handling/error/application-error"));
|
|
5
|
-
class CustomerConfigLegacyError extends application_error_1.default {
|
|
3
|
+
class CustomerConfigLegacyError extends Error {
|
|
6
4
|
}
|
|
7
5
|
exports.default = CustomerConfigLegacyError;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import CustomerConfigLegacyError from "../customer-config-legacy-error";
|
|
2
|
-
|
|
3
|
-
export default class CustomerConfigLegacyHandler implements ErrorHandlerInterface {
|
|
2
|
+
export default class CustomerConfigLegacyHandler {
|
|
4
3
|
canHandle(error: Error): boolean;
|
|
5
4
|
handle(error: CustomerConfigLegacyError): void;
|
|
6
5
|
}
|
|
@@ -10,7 +10,7 @@ class CustomerConfigLegacyHandler {
|
|
|
10
10
|
}
|
|
11
11
|
handle(error) {
|
|
12
12
|
core_1.ux.log();
|
|
13
|
-
core_1.ux.log(chalk_1.default.red(`config ${chalk_1.default.bold.white(error.
|
|
13
|
+
core_1.ux.log(chalk_1.default.red(`config ${chalk_1.default.bold.white(error.message)} not found`));
|
|
14
14
|
core_1.ux.log();
|
|
15
15
|
core_1.ux.log(chalk_1.default.italic("Is this still a legacy customer config format?"));
|
|
16
16
|
core_1.ux.log(chalk_1.default.italic("Make sure to export the different app configs under their config names like:"));
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import ErrorHandlerInterface from "../../../error-handling/interface/error-handler-interface";
|
|
2
1
|
import OriginError from "../origin-error";
|
|
3
|
-
export default class OriginHandler
|
|
2
|
+
export default class OriginHandler {
|
|
4
3
|
canHandle(error: Error): boolean;
|
|
5
4
|
handle(error: OriginError): void;
|
|
6
5
|
}
|
|
@@ -10,7 +10,7 @@ class OriginHandler {
|
|
|
10
10
|
}
|
|
11
11
|
handle(error) {
|
|
12
12
|
core_1.ux.log();
|
|
13
|
-
core_1.ux.log(chalk_1.default.red(error.
|
|
13
|
+
core_1.ux.log(chalk_1.default.red(error.message));
|
|
14
14
|
core_1.ux.log();
|
|
15
15
|
core_1.ux.log(chalk_1.default.italic("Example entry:"));
|
|
16
16
|
core_1.ux.log(chalk_1.default.bgBlack.hidden(" origins: ['https://speedkit.com', 'https://baqend.com'], "));
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
const application_error_1 = tslib_1.__importDefault(require("../../error-handling/error/application-error"));
|
|
5
|
-
class OriginError extends application_error_1.default {
|
|
3
|
+
class OriginError extends Error {
|
|
6
4
|
}
|
|
7
5
|
exports.default = OriginError;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { CustomerConfigInterface, FileInterface, FileListInterface, InstallResourceInterface, ModuleInterface, ServerConfigInterface } from "./integration-api-model";
|
|
2
|
-
import { RoFile } from "./struct/ro-file";
|
|
3
|
-
import { VirtualFile } from "./struct/virtual-file";
|
|
1
|
+
import { CustomerConfigInterface, FILE_TYPE, FileInterface, FileListInterface, InstallResourceInterface, ModuleInterface, ServerConfigInterface, RoFile, VirtualFile } from "./integration-api-model";
|
|
4
2
|
export default class FileList implements FileListInterface {
|
|
5
3
|
files: FileInterface[];
|
|
6
4
|
addFile(file: FileInterface): void;
|
|
@@ -9,8 +7,8 @@ export default class FileList implements FileListInterface {
|
|
|
9
7
|
getModules(): ModuleInterface[];
|
|
10
8
|
getServerConfig(): ServerConfigInterface;
|
|
11
9
|
getCustomerConfig(): CustomerConfigInterface;
|
|
12
|
-
getTypes():
|
|
13
|
-
getByType(type:
|
|
10
|
+
getTypes(): FILE_TYPE[];
|
|
11
|
+
getByType<T>(type: FILE_TYPE): FileInterface[] | T[];
|
|
14
12
|
getByName<T>(name: string): T;
|
|
15
13
|
filter(callback: (file: FileInterface) => boolean): void;
|
|
16
14
|
concat(fileList: FileListInterface): void;
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
4
|
-
const module_file_1 = tslib_1.__importDefault(require("./struct/module-file"));
|
|
5
|
-
const server_config_file_1 = tslib_1.__importDefault(require("./struct/server-config-file"));
|
|
6
|
-
const customer_config_file_1 = tslib_1.__importDefault(require("./struct/customer-config-file"));
|
|
7
|
-
const install_resource_file_1 = tslib_1.__importDefault(require("./struct/install-resource-file"));
|
|
3
|
+
const integration_api_model_1 = require("./integration-api-model");
|
|
8
4
|
class FileList {
|
|
9
5
|
files = [];
|
|
10
6
|
addFile(file) {
|
|
@@ -21,23 +17,23 @@ class FileList {
|
|
|
21
17
|
}
|
|
22
18
|
getInstallResources() {
|
|
23
19
|
return this.files.filter((file) => {
|
|
24
|
-
return file instanceof
|
|
20
|
+
return file instanceof integration_api_model_1.InstallResourceFile;
|
|
25
21
|
});
|
|
26
22
|
}
|
|
27
23
|
getModules() {
|
|
28
24
|
return this.files.filter((file) => {
|
|
29
|
-
return file instanceof
|
|
25
|
+
return file instanceof integration_api_model_1.ModuleFile;
|
|
30
26
|
});
|
|
31
27
|
}
|
|
32
28
|
getServerConfig() {
|
|
33
29
|
const configFiles = this.files.filter((file) => {
|
|
34
|
-
return file instanceof
|
|
30
|
+
return file instanceof integration_api_model_1.ServerConfigFile;
|
|
35
31
|
});
|
|
36
32
|
return configFiles.shift();
|
|
37
33
|
}
|
|
38
34
|
getCustomerConfig() {
|
|
39
35
|
const configFiles = this.files.filter((file) => {
|
|
40
|
-
return file instanceof
|
|
36
|
+
return file instanceof integration_api_model_1.CustomerConfigFile;
|
|
41
37
|
});
|
|
42
38
|
return configFiles.shift();
|
|
43
39
|
}
|
|
@@ -51,7 +47,7 @@ class FileList {
|
|
|
51
47
|
}
|
|
52
48
|
getByType(type) {
|
|
53
49
|
return this.files.filter((file) => {
|
|
54
|
-
return file
|
|
50
|
+
return file.type === type;
|
|
55
51
|
});
|
|
56
52
|
}
|
|
57
53
|
getByName(name) {
|
|
@@ -1,15 +1,23 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Dirent } from "node:fs";
|
|
1
3
|
export default class FileReader {
|
|
4
|
+
private fileSystem;
|
|
2
5
|
readonly configName: string;
|
|
3
6
|
private readonly basePath;
|
|
4
7
|
private readonly whiteList;
|
|
5
8
|
private readonly blockedFolders;
|
|
6
9
|
allowedExtensions: string[];
|
|
7
|
-
constructor(
|
|
8
|
-
|
|
10
|
+
constructor(fileSystem: {
|
|
11
|
+
readFileSync: (path: string, options: "utf-8") => string;
|
|
12
|
+
readdirSync: (path: string, options: {
|
|
13
|
+
withFileTypes: boolean;
|
|
14
|
+
}) => Dirent[];
|
|
15
|
+
}, configName: string, basePath: string, whiteList?: string[], blockedFolders?: string[]);
|
|
16
|
+
getFileList(basePath?: string): string[];
|
|
9
17
|
getContent(path: string): Promise<string>;
|
|
10
|
-
isAllowedFolder
|
|
11
|
-
isAllowedFile
|
|
12
|
-
getFileExtension
|
|
13
|
-
isWhiteListed
|
|
18
|
+
private isAllowedFolder;
|
|
19
|
+
private isAllowedFile;
|
|
20
|
+
private getFileExtension;
|
|
21
|
+
private isWhiteListed;
|
|
14
22
|
private mapEnvironment;
|
|
15
23
|
}
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
const node_fs_1 = require("node:fs");
|
|
5
4
|
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
6
|
-
const promises_1 = require("node:fs/promises");
|
|
7
5
|
const CUSTOMER_CONFIG_FILE = "config_customer";
|
|
8
6
|
const DEFAULT_ENV = "production";
|
|
9
7
|
class FileReader {
|
|
8
|
+
fileSystem;
|
|
10
9
|
configName;
|
|
11
10
|
basePath;
|
|
12
11
|
whiteList;
|
|
13
12
|
blockedFolders;
|
|
14
13
|
allowedExtensions = ["js", "es6", "json", "css"];
|
|
15
|
-
constructor(configName, basePath, whiteList = [], blockedFolders = []) {
|
|
14
|
+
constructor(fileSystem, configName, basePath, whiteList = [], blockedFolders = []) {
|
|
15
|
+
this.fileSystem = fileSystem;
|
|
16
16
|
this.configName = configName;
|
|
17
17
|
this.basePath = basePath;
|
|
18
18
|
this.whiteList = whiteList;
|
|
19
19
|
this.blockedFolders = blockedFolders;
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
getFileList(basePath = this.basePath) {
|
|
22
22
|
let files = [];
|
|
23
|
-
const items =
|
|
23
|
+
const items = this.fileSystem.readdirSync(basePath, {
|
|
24
24
|
withFileTypes: true,
|
|
25
25
|
});
|
|
26
26
|
for (const item of items) {
|
|
@@ -28,19 +28,19 @@ class FileReader {
|
|
|
28
28
|
if (this.isAllowedFolder(item.name)) {
|
|
29
29
|
files = [
|
|
30
30
|
...files,
|
|
31
|
-
...
|
|
31
|
+
...this.getFileList(node_path_1.default.resolve(basePath, item.name)),
|
|
32
32
|
];
|
|
33
33
|
}
|
|
34
34
|
continue;
|
|
35
35
|
}
|
|
36
36
|
if (this.isAllowedFile(item.name)) {
|
|
37
|
-
files.push(node_path_1.default.resolve(
|
|
37
|
+
files.push(node_path_1.default.resolve(basePath, item.name));
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
return this.mapEnvironment(files);
|
|
41
41
|
}
|
|
42
42
|
async getContent(path) {
|
|
43
|
-
return
|
|
43
|
+
return this.fileSystem.readFileSync(path, "utf-8");
|
|
44
44
|
}
|
|
45
45
|
isAllowedFolder(folderName) {
|
|
46
46
|
return !this.blockedFolders.some((entry) => {
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
export default class FileWriter {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
private fileSystem;
|
|
3
|
+
readonly basePath: string;
|
|
4
|
+
constructor(fileSystem: {
|
|
5
|
+
writeFileSync: (path: string, content: string) => void;
|
|
6
|
+
mkdirSync: (path: string, options: {
|
|
7
|
+
recursive: boolean;
|
|
8
|
+
}) => void;
|
|
9
|
+
existsSync: (path: string) => boolean;
|
|
10
|
+
unlinkSync: (path: string) => void;
|
|
11
|
+
}, basePath: string);
|
|
4
12
|
writeFile(fileName: string, extension: string, content: string): void;
|
|
5
13
|
mkdir(directoryPath: string): void;
|
|
6
14
|
hasFile(fileName: string, extension: string): boolean;
|
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
const node_fs_1 = require("node:fs");
|
|
5
4
|
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
6
5
|
class FileWriter {
|
|
6
|
+
fileSystem;
|
|
7
7
|
basePath;
|
|
8
|
-
constructor(basePath) {
|
|
8
|
+
constructor(fileSystem, basePath) {
|
|
9
|
+
this.fileSystem = fileSystem;
|
|
9
10
|
this.basePath = basePath;
|
|
10
11
|
}
|
|
11
12
|
writeFile(fileName, extension, content) {
|
|
12
|
-
|
|
13
|
+
this.fileSystem.writeFileSync(this.getPath(fileName, extension), content);
|
|
13
14
|
}
|
|
14
15
|
mkdir(directoryPath) {
|
|
15
|
-
|
|
16
|
+
this.fileSystem.mkdirSync(node_path_1.default.resolve(this.basePath, directoryPath), {
|
|
17
|
+
recursive: true,
|
|
18
|
+
});
|
|
16
19
|
}
|
|
17
20
|
hasFile(fileName, extension) {
|
|
18
|
-
return
|
|
21
|
+
return this.fileSystem.existsSync(this.getPath(fileName, extension));
|
|
19
22
|
}
|
|
20
23
|
removeFile(fileName, extension) {
|
|
21
|
-
|
|
24
|
+
this.fileSystem.unlinkSync(this.getPath(fileName, extension));
|
|
22
25
|
}
|
|
23
26
|
getPath(fileName, extension) {
|
|
24
27
|
return node_path_1.default.resolve(this.basePath, `${fileName}.${extension}`);
|
|
@@ -4,8 +4,8 @@ const tslib_1 = require("tslib");
|
|
|
4
4
|
const vm = tslib_1.__importStar(require("node:vm"));
|
|
5
5
|
const customer_config_error_1 = tslib_1.__importDefault(require("../error/customer-config-error"));
|
|
6
6
|
const customer_config_legacy_error_1 = tslib_1.__importDefault(require("../error/customer-config-legacy-error"));
|
|
7
|
-
const customer_config_1 =
|
|
8
|
-
const customer_config_file_1 =
|
|
7
|
+
const customer_config_1 = require("../struct/customer-config");
|
|
8
|
+
const customer_config_file_1 = require("../struct/customer-config-file");
|
|
9
9
|
const file_handler_1 = tslib_1.__importDefault(require("./file-handler"));
|
|
10
10
|
class CustomerConfigHandler extends file_handler_1.default {
|
|
11
11
|
cli;
|
|
@@ -27,7 +27,7 @@ class CustomerConfigHandler extends file_handler_1.default {
|
|
|
27
27
|
const fileContent = await this.fileReader.getContent(filePath);
|
|
28
28
|
const config = await this.loadConfig(fileContent, filePath);
|
|
29
29
|
this.validator.validate(config);
|
|
30
|
-
return new customer_config_file_1.
|
|
30
|
+
return new customer_config_file_1.CustomerConfigFile(this.getFileName(filePath), filePath, fileContent, config, this.configName, this.testApp);
|
|
31
31
|
}
|
|
32
32
|
async loadConfig(fileContent, filePath) {
|
|
33
33
|
if ((fileContent.includes("process.env.TEST_APP") && this.testApp === null) ||
|
|
@@ -49,16 +49,14 @@ class CustomerConfigHandler extends file_handler_1.default {
|
|
|
49
49
|
typeof configs === "string" ||
|
|
50
50
|
"origins" in configs ||
|
|
51
51
|
"name" in configs) {
|
|
52
|
-
throw new customer_config_legacy_error_1.default(
|
|
53
|
-
configName: this.configName,
|
|
54
|
-
});
|
|
52
|
+
throw new customer_config_legacy_error_1.default(this.configName);
|
|
55
53
|
}
|
|
56
54
|
if (this.configName in configs) {
|
|
57
|
-
return customer_config_1.
|
|
55
|
+
return customer_config_1.CustomerConfig.createFrom(configs[this.configName], this.configName);
|
|
58
56
|
}
|
|
59
57
|
this.cli.writeWarning(`config: ${this.configName} does not exist.`);
|
|
60
58
|
const selectedConfig = await this.cli.select("please select config: ", Object.keys(configs).map((option) => ({ name: option, value: option })));
|
|
61
|
-
return customer_config_1.
|
|
59
|
+
return customer_config_1.CustomerConfig.createFrom(configs[selectedConfig], selectedConfig);
|
|
62
60
|
}
|
|
63
61
|
}
|
|
64
62
|
exports.default = CustomerConfigHandler;
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const file_handler_1 = tslib_1.__importDefault(require("./file-handler"));
|
|
5
|
-
const
|
|
6
|
-
const application_error_1 = tslib_1.__importDefault(require("../../error-handling/error/application-error"));
|
|
5
|
+
const integration_api_model_1 = require("../integration-api-model");
|
|
7
6
|
const PREDICTIVE_PRELOADING = "predictive-preloading";
|
|
8
7
|
class InstallResourceHandler extends file_handler_1.default {
|
|
9
8
|
allowedFiles = [
|
|
@@ -33,11 +32,11 @@ class InstallResourceHandler extends file_handler_1.default {
|
|
|
33
32
|
}
|
|
34
33
|
async handle(filePath) {
|
|
35
34
|
const fileName = this.getFileName(filePath);
|
|
36
|
-
return new
|
|
35
|
+
return new integration_api_model_1.InstallResourceFile(fileName, filePath, await this.getFileContent(fileName, filePath), this.getRemoteKey(fileName));
|
|
37
36
|
}
|
|
38
37
|
getRemoteKey(fileName) {
|
|
39
38
|
if (!this.remoteKeyMapping[fileName]) {
|
|
40
|
-
throw new
|
|
39
|
+
throw new Error(`unknown fileName ${fileName}`);
|
|
41
40
|
}
|
|
42
41
|
return this.remoteKeyMapping[fileName];
|
|
43
42
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const file_handler_1 = tslib_1.__importDefault(require("./file-handler"));
|
|
5
|
-
const module_file_1 =
|
|
5
|
+
const module_file_1 = require("../struct/module-file");
|
|
6
6
|
class ModuleHandler extends file_handler_1.default {
|
|
7
7
|
blackList = [];
|
|
8
8
|
/**
|
|
@@ -14,7 +14,7 @@ class ModuleHandler extends file_handler_1.default {
|
|
|
14
14
|
return !this.blackList.includes(this.getFileName(filePath));
|
|
15
15
|
}
|
|
16
16
|
async handle(filePath) {
|
|
17
|
-
return new module_file_1.
|
|
17
|
+
return new module_file_1.ModuleFile(this.getFileName(filePath), filePath, await this.fileReader.getContent(filePath), module_file_1.ModuleFile);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
exports.default = ModuleHandler;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const file_handler_1 = tslib_1.__importDefault(require("./file-handler"));
|
|
5
|
-
const
|
|
5
|
+
const integration_api_model_1 = require("../integration-api-model");
|
|
6
6
|
class ServerConfigHandler extends file_handler_1.default {
|
|
7
7
|
allowedFiles = ["orestes_config"];
|
|
8
8
|
canHandle(filePath) {
|
|
@@ -10,7 +10,7 @@ class ServerConfigHandler extends file_handler_1.default {
|
|
|
10
10
|
}
|
|
11
11
|
async handle(filePath) {
|
|
12
12
|
const fileContent = await this.fileReader.getContent(filePath);
|
|
13
|
-
return new
|
|
13
|
+
return new integration_api_model_1.ServerConfigFile(this.getFileName(filePath), filePath, fileContent, this.getConfig(fileContent));
|
|
14
14
|
}
|
|
15
15
|
getConfig(content) {
|
|
16
16
|
return JSON.parse(content);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./integration-api-model"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./integration-api-factory"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./integration-api-service"), exports);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IntegrationApiService } from "./integration-api-service";
|
|
2
|
+
import { IntegrationApiContext } from "./integration-api-model";
|
|
3
|
+
import { UserCliConfig } from "../../helpers/cli-config";
|
|
4
|
+
export declare class IntegrationApiFactory {
|
|
5
|
+
private context;
|
|
6
|
+
private cliConfig;
|
|
7
|
+
service?: IntegrationApiService;
|
|
8
|
+
private fileReader?;
|
|
9
|
+
constructor(context: IntegrationApiContext, cliConfig: UserCliConfig);
|
|
10
|
+
buildService(): IntegrationApiService;
|
|
11
|
+
private build;
|
|
12
|
+
private getFileReader;
|
|
13
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IntegrationApiFactory = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const integration_api_service_1 = require("./integration-api-service");
|
|
6
|
+
const file_reader_1 = tslib_1.__importDefault(require("./file-reader"));
|
|
7
|
+
const mandatory_files_validator_1 = tslib_1.__importDefault(require("./validator/mandatory-files-validator"));
|
|
8
|
+
const customer_config_handler_1 = tslib_1.__importDefault(require("./handler/customer-config-handler"));
|
|
9
|
+
const customer_config_validator_1 = tslib_1.__importDefault(require("./validator/customer-config-validator"));
|
|
10
|
+
const install_resource_handler_1 = tslib_1.__importDefault(require("./handler/install-resource-handler"));
|
|
11
|
+
const module_handler_1 = tslib_1.__importDefault(require("./handler/module-handler"));
|
|
12
|
+
const server_config_handler_1 = tslib_1.__importDefault(require("./handler/server-config-handler"));
|
|
13
|
+
const file_writer_1 = tslib_1.__importDefault(require("./file-writer"));
|
|
14
|
+
const cli_1 = require("../cli");
|
|
15
|
+
const virtual_file_handler_1 = require("./virtual/virtual-file-handler");
|
|
16
|
+
const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
|
|
17
|
+
class IntegrationApiFactory {
|
|
18
|
+
context;
|
|
19
|
+
cliConfig;
|
|
20
|
+
service = undefined;
|
|
21
|
+
fileReader;
|
|
22
|
+
constructor(context, cliConfig) {
|
|
23
|
+
this.context = context;
|
|
24
|
+
this.cliConfig = cliConfig;
|
|
25
|
+
}
|
|
26
|
+
buildService() {
|
|
27
|
+
if (!(this.service instanceof integration_api_service_1.IntegrationApiService)) {
|
|
28
|
+
this.build();
|
|
29
|
+
}
|
|
30
|
+
return this.service;
|
|
31
|
+
}
|
|
32
|
+
build() {
|
|
33
|
+
const fileReader = this.getFileReader();
|
|
34
|
+
const cli = new cli_1.CliServiceFactory().getService();
|
|
35
|
+
const virtualFileHandler = new virtual_file_handler_1.VirtualFileHandler(cli);
|
|
36
|
+
this.service = new integration_api_service_1.IntegrationApiService(fileReader, virtualFileHandler, new mandatory_files_validator_1.default(), [
|
|
37
|
+
new customer_config_handler_1.default(fileReader, cli, new customer_config_validator_1.default(), this.context.configName, this.cliConfig.testApp),
|
|
38
|
+
new install_resource_handler_1.default(fileReader),
|
|
39
|
+
new server_config_handler_1.default(fileReader),
|
|
40
|
+
new module_handler_1.default(fileReader),
|
|
41
|
+
], new file_writer_1.default(node_fs_1.default, this.context.basePath), this.context.whiteList.length === 0);
|
|
42
|
+
}
|
|
43
|
+
getFileReader() {
|
|
44
|
+
if (!this.fileReader) {
|
|
45
|
+
this.fileReader = new file_reader_1.default(node_fs_1.default, this.context.configName, this.context.basePath, this.context.whiteList, this.context.blockedFolders);
|
|
46
|
+
}
|
|
47
|
+
return this.fileReader;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.IntegrationApiFactory = IntegrationApiFactory;
|
|
@@ -1,4 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
export * from "./struct/customer-config";
|
|
2
|
+
export * from "./struct/file";
|
|
3
|
+
export * from "./struct/customer-config-file";
|
|
4
|
+
export * from "./struct/module-file";
|
|
5
|
+
export * from "./struct/install-resource-file";
|
|
6
|
+
export * from "./struct/server-config-file";
|
|
7
|
+
export * from "./struct/ro-file";
|
|
8
|
+
export * from "./struct/virtual-file";
|
|
9
|
+
export * from "./virtual/virtual-file-handler";
|
|
10
|
+
export * from "./virtual/external-recipe";
|
|
11
|
+
export * from "./external/external-file-reader";
|
|
12
|
+
import { CustomerConfig } from "./struct/customer-config";
|
|
2
13
|
import { RoFile } from "./struct/ro-file";
|
|
3
14
|
import { VirtualFile } from "./struct/virtual-file";
|
|
4
15
|
export interface CustomerConfigOnboardingFile {
|
|
@@ -13,8 +24,6 @@ export interface CustomerConfigOnboardingFile {
|
|
|
13
24
|
};
|
|
14
25
|
};
|
|
15
26
|
}
|
|
16
|
-
type FileType = InstallResourceInterface | ModuleInterface | ServerConfigInterface | FileInterface | RoFile | VirtualFile;
|
|
17
|
-
type FileTypes = FileType[];
|
|
18
27
|
export interface FileListInterface {
|
|
19
28
|
files: (InstallResourceInterface | ModuleInterface | ServerConfigInterface | FileInterface | RoFile | VirtualFile)[];
|
|
20
29
|
addFile(file: FileInterface): void;
|
|
@@ -22,20 +31,14 @@ export interface FileListInterface {
|
|
|
22
31
|
getModules(): ModuleInterface[];
|
|
23
32
|
getServerConfig(): ServerConfigInterface;
|
|
24
33
|
getCustomerConfig(): CustomerConfigInterface;
|
|
25
|
-
getByType(type:
|
|
26
|
-
getTypes():
|
|
34
|
+
getByType<T>(type: FILE_TYPE): FileInterface[] | T[];
|
|
35
|
+
getTypes(): FILE_TYPE[];
|
|
27
36
|
filter(callback: (file: FileInterface) => boolean): void;
|
|
28
37
|
hasFile(fileName: string): boolean;
|
|
29
38
|
getByName<T>(name: string): T;
|
|
30
39
|
concat(fileList: FileListInterface): void;
|
|
31
40
|
replace(replace: InstallResourceInterface | ModuleInterface | ServerConfigInterface | FileInterface | RoFile | VirtualFile): void;
|
|
32
41
|
}
|
|
33
|
-
export interface IntegrationApiContextInterface {
|
|
34
|
-
basePath: string;
|
|
35
|
-
configName: string;
|
|
36
|
-
whiteList: string[];
|
|
37
|
-
blockedFolders: string[];
|
|
38
|
-
}
|
|
39
42
|
export interface IntegrationApiHandler {
|
|
40
43
|
canHandle(filePath: string): boolean;
|
|
41
44
|
handle(filePath: string): Promise<FileInterface>;
|
|
@@ -47,9 +50,18 @@ export interface MandatoryFilesConfigInterface {
|
|
|
47
50
|
or: string[];
|
|
48
51
|
};
|
|
49
52
|
}
|
|
53
|
+
export declare enum FILE_TYPE {
|
|
54
|
+
CONFIG_FILE = "config",
|
|
55
|
+
INSTALL_FILE = "install",
|
|
56
|
+
MODULE_FILE = "module",
|
|
57
|
+
SERVER_FILE = "server",
|
|
58
|
+
VIRTUAL_FILE = "virtual",
|
|
59
|
+
READONLY_FILE = "readonly",
|
|
60
|
+
CUSTOMER_FILE = "customer"
|
|
61
|
+
}
|
|
50
62
|
export interface FileInterface {
|
|
51
|
-
readonly type: any;
|
|
52
63
|
readonly name: string;
|
|
64
|
+
readonly type: FILE_TYPE;
|
|
53
65
|
skipFile(): void;
|
|
54
66
|
shouldSkipFile(): boolean;
|
|
55
67
|
getContent(): string;
|
|
@@ -71,7 +83,7 @@ export interface ServerConfigInterface extends ConfigFileInterface, FileInterfac
|
|
|
71
83
|
export interface InstallResourceInterface extends ConfigFileInterface, FileInterface {
|
|
72
84
|
readonly remoteKey: string;
|
|
73
85
|
}
|
|
74
|
-
export interface CustomerConfigInterface extends ConfigFileInterface
|
|
86
|
+
export interface CustomerConfigInterface extends ConfigFileInterface {
|
|
75
87
|
config: CustomerConfig;
|
|
76
88
|
readonly configName: string;
|
|
77
89
|
}
|
|
@@ -86,4 +98,11 @@ export type VirtualFileConfig = {
|
|
|
86
98
|
recipe: VirtualFileRecipe;
|
|
87
99
|
overrideLocalFile?: boolean;
|
|
88
100
|
};
|
|
89
|
-
export
|
|
101
|
+
export declare const DEFAULT_BLOCKED_FOLDERS: string[];
|
|
102
|
+
export declare class IntegrationApiContext {
|
|
103
|
+
readonly basePath: string;
|
|
104
|
+
readonly configName: string;
|
|
105
|
+
readonly whiteList: string[];
|
|
106
|
+
readonly blockedFolders: string[];
|
|
107
|
+
constructor(basePath: string, configName: string, whitelist: string[], blockedFolders?: string[]);
|
|
108
|
+
}
|