@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
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import Protocol from "devtools-protocol";
|
|
2
|
-
import { FileInterface } from "../../integration-api
|
|
3
|
-
import CustomerConfig from "../../integration-api/struct/customer-config";
|
|
2
|
+
import { CustomerConfig, FileInterface } from "../../integration-api";
|
|
4
3
|
import { FetchRequestPausedEventHandler } from "../onboarding-model";
|
|
5
4
|
/**
|
|
6
5
|
* SpeedKitServiceWorkerJs class is responsible for handling fetch requests for the SpeedKit service worker.
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { CliService } from "../../cli";
|
|
2
2
|
import { Page } from "puppeteer";
|
|
3
|
-
import CustomerConfig from "../../integration-api/struct/customer-config";
|
|
4
3
|
import { DocumentHandlerServer } from "../../document-handler-runtime/document-handler-server";
|
|
5
4
|
import { Cache } from "../request-cache/cache";
|
|
6
|
-
import { ConfigFileInterface, FileListInterface } from "../../integration-api
|
|
5
|
+
import { ConfigFileInterface, CustomerConfig, FileListInterface } from "../../integration-api";
|
|
7
6
|
import { BrowserContext } from "../onboarding-model";
|
|
8
7
|
/**
|
|
9
8
|
* Add different callbacks that will be executed if a local file is changed.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FileWatcher = void 0;
|
|
4
4
|
const safe_1 = require("../../../helpers/safe");
|
|
5
|
-
const
|
|
5
|
+
const integration_api_1 = require("../../integration-api");
|
|
6
6
|
const files_1 = require("../../../models/files");
|
|
7
7
|
/**
|
|
8
8
|
* Add different callbacks that will be executed if a local file is changed.
|
|
@@ -41,7 +41,7 @@ class FileWatcher {
|
|
|
41
41
|
continue;
|
|
42
42
|
}
|
|
43
43
|
const file = this.files.getByName(dependency);
|
|
44
|
-
if (file.type ===
|
|
44
|
+
if (file.type === integration_api_1.FILE_TYPE.VIRTUAL_FILE) {
|
|
45
45
|
continue;
|
|
46
46
|
}
|
|
47
47
|
file.onChange(async (file) => {
|
|
@@ -65,7 +65,7 @@ class FileWatcher {
|
|
|
65
65
|
continue;
|
|
66
66
|
}
|
|
67
67
|
const file = this.files.getByName(configFile);
|
|
68
|
-
if (file.type ===
|
|
68
|
+
if (file.type === integration_api_1.FILE_TYPE.VIRTUAL_FILE) {
|
|
69
69
|
continue;
|
|
70
70
|
}
|
|
71
71
|
file.onChange(async (file) => {
|
|
@@ -11,11 +11,6 @@ const config_api_context_1 = tslib_1.__importDefault(require("../config-api/cont
|
|
|
11
11
|
const config_api_service_factory_1 = tslib_1.__importDefault(require("../config-api/factory/config-api-service-factory"));
|
|
12
12
|
const diff_1 = require("../diff");
|
|
13
13
|
const document_handler_runtime_service_factory_1 = tslib_1.__importDefault(require("../document-handler-runtime/factory/document-handler-runtime-service-factory"));
|
|
14
|
-
const integration_api_context_1 = tslib_1.__importDefault(require("../integration-api/context/integration-api-context"));
|
|
15
|
-
const external_file_reader_1 = require("../integration-api/external/external-file-reader");
|
|
16
|
-
const integration_api_service_factory_1 = tslib_1.__importDefault(require("../integration-api/factory/integration-api-service-factory"));
|
|
17
|
-
const virtual_file_1 = require("../integration-api/struct/virtual-file");
|
|
18
|
-
const external_recipe_1 = require("../integration-api/virtual/external-recipe");
|
|
19
14
|
const install_file_recipe_1 = require("./config-renderer/install-file-recipe");
|
|
20
15
|
const speed_kit_install_context_1 = require("./config-renderer/speed-kit-install-context");
|
|
21
16
|
const dashboard_1 = require("./dashboard");
|
|
@@ -37,6 +32,7 @@ const cache_1 = require("./request-cache/cache");
|
|
|
37
32
|
const install_speed_kit_html_template_1 = require("./templates/install-speed-kit-html-template");
|
|
38
33
|
const install_speed_kit_js_template_1 = require("./templates/install-speed-kit-js-template");
|
|
39
34
|
const todo_collector_1 = require("./todo-collector");
|
|
35
|
+
const integration_api_1 = require("../integration-api");
|
|
40
36
|
class OnboardingServiceFactory {
|
|
41
37
|
context;
|
|
42
38
|
cliConfig;
|
|
@@ -70,7 +66,7 @@ class OnboardingServiceFactory {
|
|
|
70
66
|
}
|
|
71
67
|
async buildInstallResource(speedKitInstallContext, files, cli) {
|
|
72
68
|
cli.startAction("build file install_resource");
|
|
73
|
-
const installResourceFile = new
|
|
69
|
+
const installResourceFile = new integration_api_1.VirtualFile(files_1.INTEGRATION_FILES.BUILD.INSTALL, new install_file_recipe_1.InstallFileRecipe(speedKitInstallContext));
|
|
74
70
|
const result = await (0, safe_1.safe)(installResourceFile.buildContent());
|
|
75
71
|
if (result.success === true) {
|
|
76
72
|
files.addFile(installResourceFile);
|
|
@@ -119,25 +115,25 @@ class OnboardingServiceFactory {
|
|
|
119
115
|
return new fetch_event_handler_1.FetchEventHandler(handlers, customerConfig, cli, configApi);
|
|
120
116
|
}
|
|
121
117
|
async getIntegrationFiles() {
|
|
122
|
-
const integrationApiContext = new
|
|
123
|
-
const integrationApi = new
|
|
124
|
-
const externalFileReader = new
|
|
118
|
+
const integrationApiContext = new integration_api_1.IntegrationApiContext(this.context.customerPath, this.context.configName, []);
|
|
119
|
+
const integrationApi = new integration_api_1.IntegrationApiFactory(integrationApiContext, this.cliConfig).buildService();
|
|
120
|
+
const externalFileReader = new integration_api_1.ExternalFileReader();
|
|
125
121
|
return integrationApi.run([
|
|
126
122
|
{
|
|
127
123
|
name: files_1.INTEGRATION_FILES.CUSTOM.SW,
|
|
128
|
-
recipe: new
|
|
124
|
+
recipe: new integration_api_1.ExternalRecipe(this.context.DEFAULT_SW_PATH, externalFileReader),
|
|
129
125
|
},
|
|
130
126
|
{
|
|
131
127
|
name: files_1.INTEGRATION_FILES.CUSTOM.DYNAMIC_FETCHER,
|
|
132
|
-
recipe: new
|
|
128
|
+
recipe: new integration_api_1.ExternalRecipe(this.context.DEFAULT_DF_PATH, externalFileReader),
|
|
133
129
|
},
|
|
134
130
|
{
|
|
135
131
|
name: files_1.INTEGRATION_FILES.CUSTOM.LOADER,
|
|
136
|
-
recipe: new
|
|
132
|
+
recipe: new integration_api_1.ExternalRecipe(this.context.DEFAULT_SNIPPET_PATH, externalFileReader),
|
|
137
133
|
},
|
|
138
134
|
{
|
|
139
135
|
name: files_1.INTEGRATION_FILES.CUSTOM.DOCUMENT_HANDLER,
|
|
140
|
-
recipe: new
|
|
136
|
+
recipe: new integration_api_1.ExternalRecipe(this.context.DEFAULT_DOCUMENT_HANDLER_PATH, externalFileReader),
|
|
141
137
|
},
|
|
142
138
|
]);
|
|
143
139
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import CustomerConfig from "../integration-api
|
|
1
|
+
import { CustomerConfig } from "../integration-api";
|
|
2
2
|
import { BrowserContext } from "./onboarding-model";
|
|
3
3
|
import { FetchEventHandler } from "./fetch-event-handler";
|
|
4
4
|
import { FileWatcher } from "./file-events/file-watcher";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TodoCollector = void 0;
|
|
4
|
-
const
|
|
4
|
+
const integration_api_model_1 = require("../integration-api/integration-api-model");
|
|
5
5
|
const TODO_MATCH = /(todo[^\n\r()|]*)((?:(?:\r\n|\r|\n)[^\n\r()|]*){3})/i;
|
|
6
6
|
/**
|
|
7
7
|
* Represents a TodoCollector class that collects open tasks from files.
|
|
@@ -14,7 +14,7 @@ class TodoCollector {
|
|
|
14
14
|
}
|
|
15
15
|
getOpenTasks() {
|
|
16
16
|
const configFiles = this.files.filter((file) => {
|
|
17
|
-
return !(file.type
|
|
17
|
+
return !(file.type === integration_api_model_1.FILE_TYPE.VIRTUAL_FILE);
|
|
18
18
|
});
|
|
19
19
|
const tasks = [];
|
|
20
20
|
for (const configFile of configFiles) {
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PullServiceFactory = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
6
|
-
const integration_api_service_factory_1 = tslib_1.__importDefault(require("../integration-api/factory/integration-api-service-factory"));
|
|
5
|
+
const integration_api_1 = require("../integration-api");
|
|
7
6
|
const config_api_service_factory_1 = tslib_1.__importDefault(require("../config-api/factory/config-api-service-factory"));
|
|
8
7
|
const config_api_context_1 = tslib_1.__importDefault(require("../config-api/context/config-api-context"));
|
|
9
8
|
const cli_1 = require("../cli");
|
|
@@ -32,8 +31,8 @@ class PullServiceFactory {
|
|
|
32
31
|
this.service = new _1.PullService(files, cliService, configApi, configName, this.context.customerPath);
|
|
33
32
|
}
|
|
34
33
|
async getIntegrationFiles() {
|
|
35
|
-
const integrationApiContext = new
|
|
36
|
-
const integrationApi = new
|
|
34
|
+
const integrationApiContext = new integration_api_1.IntegrationApiContext(this.context.customerPath, this.context.configName, []);
|
|
35
|
+
const integrationApi = new integration_api_1.IntegrationApiFactory(integrationApiContext, this.userConfig).buildService();
|
|
37
36
|
return await integrationApi.run();
|
|
38
37
|
}
|
|
39
38
|
getConfigApi(app) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CliServiceInterface } from "../cli";
|
|
2
|
-
import { FileListInterface } from "../integration-api
|
|
2
|
+
import { FileListInterface } from "../integration-api";
|
|
3
3
|
import ConfigApiService from "../config-api/config-api-service";
|
|
4
4
|
export declare class PullService {
|
|
5
5
|
private fileList;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PullService = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const cli_1 = require("../cli");
|
|
6
|
-
const
|
|
5
|
+
const integration_api_1 = require("../integration-api");
|
|
7
6
|
const _1 = require("./");
|
|
8
7
|
const safe_1 = require("../../helpers/safe");
|
|
9
8
|
const node_child_process_1 = require("node:child_process");
|
|
@@ -87,7 +86,7 @@ class PullService {
|
|
|
87
86
|
return this.fileList.getByName(fileName);
|
|
88
87
|
}
|
|
89
88
|
async createFile(fileName, extension, content, key) {
|
|
90
|
-
const resourceFile = new
|
|
89
|
+
const resourceFile = new integration_api_1.InstallResourceFile(fileName, `${this.basePath}/${fileName}.${extension}`, content, key);
|
|
91
90
|
this.fileList.addFile(resourceFile);
|
|
92
91
|
await resourceFile.updateFile();
|
|
93
92
|
}
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@speedkit/cli",
|
|
3
3
|
"description": "Speed Kit CLI",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.28.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Baqend.com",
|
|
7
7
|
"email": "info@baqend.com"
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"build:dashboard": "copyfiles -u 1 src/services/onboarding/dashboard/frontend-dist/**/*.html dist && copyfiles -u 1 src/services/onboarding/dashboard/frontend-dist/**/*.js dist && copyfiles -u 1 src/services/onboarding/dashboard/frontend-dist/**/*.css dist",
|
|
27
27
|
"postbuild": "oclif manifest && oclif readme",
|
|
28
28
|
"prepack": "npm run build",
|
|
29
|
-
"test": "mocha --reporter mocha-junit-reporter --reporter-options mochaFile=junit.xml",
|
|
29
|
+
"test": "mocha --config ./.mocharc.cjs --reporter mocha-junit-reporter --reporter-options mochaFile=junit.xml",
|
|
30
30
|
"coverage": "nyc mocha",
|
|
31
31
|
"coverage:report": "nyc --reporter cobertura mocha"
|
|
32
32
|
},
|
|
@@ -83,6 +83,7 @@
|
|
|
83
83
|
"domhandler": "5.0.3",
|
|
84
84
|
"domutils": "^3.1",
|
|
85
85
|
"dotenv": "^16.4",
|
|
86
|
+
"esbuild": "^0.20",
|
|
86
87
|
"extract-zip": "^2.0.1",
|
|
87
88
|
"fs-extra": "^10.1.0",
|
|
88
89
|
"handlebars": "^4.7",
|
|
@@ -96,8 +97,7 @@
|
|
|
96
97
|
"puppeteer-extra": "^3.3",
|
|
97
98
|
"puppeteer-extra-plugin-user-preferences": "^2.4",
|
|
98
99
|
"strip-comments": "^2.0.1",
|
|
99
|
-
"uuid": "^8.3.2"
|
|
100
|
-
"esbuild": "^0.20"
|
|
100
|
+
"uuid": "^8.3.2"
|
|
101
101
|
},
|
|
102
102
|
"devDependencies": {
|
|
103
103
|
"@commitlint/cli": "^17.7.1",
|
|
@@ -121,9 +121,9 @@
|
|
|
121
121
|
"globby": "^11",
|
|
122
122
|
"husky": "^8.0.3",
|
|
123
123
|
"lint-staged": "^14.0.1",
|
|
124
|
+
"memfs": "^4.8.0",
|
|
124
125
|
"mocha": "^10.1.0",
|
|
125
126
|
"mocha-junit-reporter": "^2.2.1",
|
|
126
|
-
"mock-fs": "^5.2.0",
|
|
127
127
|
"nock": "^13.5",
|
|
128
128
|
"nyc": "^15.1.0",
|
|
129
129
|
"oclif": "^4.5",
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const application_error_1 = tslib_1.__importDefault(require("../../error-handling/error/application-error"));
|
|
5
|
-
class ContextRuntimeError extends application_error_1.default {
|
|
6
|
-
}
|
|
7
|
-
exports.default = ContextRuntimeError;
|
|
@@ -1,303 +0,0 @@
|
|
|
1
|
-
// Salesforce specific:
|
|
2
|
-
|
|
3
|
-
const { run: executeRefresh } = require('./speedKit.CronJob');
|
|
4
|
-
const fetch = require('node-fetch');
|
|
5
|
-
|
|
6
|
-
const minutesToMilliseconds = (minutes) => {
|
|
7
|
-
return minutes * 60000;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const LOCALES_BY_LAYOUT = [
|
|
11
|
-
// TODO: adjust/replace this exemplary list
|
|
12
|
-
ExampleLayoutA: ["de_DE", "en_DE"],
|
|
13
|
-
ExampleLayoutB: ["en_US"],
|
|
14
|
-
];
|
|
15
|
-
const ASSET_SUB_PATHS = [
|
|
16
|
-
// These assets are expected to be found via the following base URL:
|
|
17
|
-
// https://<ORIGIN>/on/demandware.static/Sites-<LAYOUT>-Site/-/<LOCALE>/v<VERSION>/...
|
|
18
|
-
|
|
19
|
-
// TODO: adjust/replace this exemplary list
|
|
20
|
-
|
|
21
|
-
// JS:
|
|
22
|
-
"js/main.js",
|
|
23
|
-
"internal/jscript/dwanalytics-(.*).js",
|
|
24
|
-
|
|
25
|
-
// CSS:
|
|
26
|
-
"css/style.css",
|
|
27
|
-
];
|
|
28
|
-
|
|
29
|
-
function getAssetList() {
|
|
30
|
-
return Object.entries(LOCALES_BY_LAYOUT).flatMap(([layout, locales]) =>
|
|
31
|
-
locales.flatMap((locale) =>
|
|
32
|
-
ASSET_SUB_PATHS.map(
|
|
33
|
-
(subPath) =>
|
|
34
|
-
{{#if staging.host}}
|
|
35
|
-
`^https://(?:{{production.host}}|{{staging.host}})/on/demandware.static/Sites-${layout}-Site/-/${locale}/v(\\d{13})/${subPath}`,
|
|
36
|
-
{{else}}
|
|
37
|
-
`^https://{{production.host}}/on/demandware.static/Sites-${layout}-Site/-/${locale}/v(\\d{13})/${subPath}`,
|
|
38
|
-
{{/if}}
|
|
39
|
-
),
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const deploymentConfig = {
|
|
44
|
-
slack: "<1Password deployment token>",
|
|
45
|
-
origins: [
|
|
46
|
-
// Production:
|
|
47
|
-
"https://{{production.host}}",
|
|
48
|
-
{{#if staging.host}}
|
|
49
|
-
|
|
50
|
-
// Staging:
|
|
51
|
-
"https://{{staging.host}}",
|
|
52
|
-
{{/if}}
|
|
53
|
-
|
|
54
|
-
// TODO: also check for other origins like e.g. https://*.my.salesforce.com
|
|
55
|
-
],
|
|
56
|
-
jobType: "deployment", // "instant" | "deployment"
|
|
57
|
-
|
|
58
|
-
// configure how long the origin deployment takes in milliseconds:
|
|
59
|
-
deploymentDelay: minutesToMilliseconds(15),
|
|
60
|
-
|
|
61
|
-
// throttling the HTML refresh:
|
|
62
|
-
revalidationDelay: minutesToMilliseconds(0),
|
|
63
|
-
|
|
64
|
-
compareVersionStrings: false, // Compares version strings of the new and previous assets and only triggers deployment, when the current is newer. The version must be the first group in the regex
|
|
65
|
-
compareContentHashes: true,
|
|
66
|
-
|
|
67
|
-
assetList: [
|
|
68
|
-
...getAssetList(),
|
|
69
|
-
|
|
70
|
-
// TODO: add additional non-demandware asset urls as needed
|
|
71
|
-
],
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function getQuery(assetRegex, origin) {
|
|
75
|
-
const query = getBaseQuery(origin);
|
|
76
|
-
query.url = { "$regex": assetRegex };
|
|
77
|
-
return query;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function getBaseQuery(...origins) {
|
|
81
|
-
return {
|
|
82
|
-
"contentType": { "$in": ["script", "style"] },
|
|
83
|
-
"variation": "DEFAULT",
|
|
84
|
-
"origin": { "$in": origins },
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const DEPLOYMENT_REFRESH_JOB_ID_TEMPLATE = '/db/jobs.Definition/deployment-refresh'
|
|
89
|
-
const DEPLOYMENT_CHECKER_JOB_ID = '/db/jobs.Definition/deployment-check'
|
|
90
|
-
const MINUTE = 60 * 1000;
|
|
91
|
-
|
|
92
|
-
exports.get = async function(db, req, res) {
|
|
93
|
-
if (!db.User.me || db.User.me.key !== '1') {
|
|
94
|
-
throw new Abort("Unauthorized");
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const assetsByOrigin = {};
|
|
98
|
-
|
|
99
|
-
for (const origin of deploymentConfig.origins) {
|
|
100
|
-
assetsByOrigin[origin] = await Promise.all(deploymentConfig.assetList.map(async asset => {
|
|
101
|
-
const { url } = await findAsset(db, asset, origin) || { url: null };
|
|
102
|
-
return url;
|
|
103
|
-
}))
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
res.json(assetsByOrigin);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
exports.post = async function(db, req, res) {
|
|
111
|
-
if (!db.User.me || db.User.me.key !== '1') {
|
|
112
|
-
throw new Abort("Unauthorized");
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
const deploymentJobs = await Promise.all(deploymentConfig.origins.map(
|
|
116
|
-
origin => createDeploymentJob(db, deploymentConfig, origin)));
|
|
117
|
-
|
|
118
|
-
const deploymentChecker = await (new db['jobs.Definition']({
|
|
119
|
-
id: DEPLOYMENT_CHECKER_JOB_ID,
|
|
120
|
-
module: 'deploymentDetection',
|
|
121
|
-
cronpattern: '42 */10 * * * *',
|
|
122
|
-
startsAt: new Date(),
|
|
123
|
-
}).save().catch(e => e.message));
|
|
124
|
-
|
|
125
|
-
res.json({ deploymentChecker, deploymentJobs });
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function getDeploymentJobId(origin) {
|
|
129
|
-
const originWithoutSlashes = origin.replace(/https:/g, '').replace(/\//g, '');
|
|
130
|
-
return `${DEPLOYMENT_REFRESH_JOB_ID_TEMPLATE}-${originWithoutSlashes}`;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
function getDeploymentJobName(origin) {
|
|
134
|
-
const originWithoutSlashes = origin.replace(/https:/g, '').replace(/\//g, '');
|
|
135
|
-
return `Deployment ${originWithoutSlashes}`
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
function createDeploymentJob(db, deploymentConfig, origin) {
|
|
139
|
-
return (new db['jobs.Definition']({
|
|
140
|
-
id: getDeploymentJobId(origin),
|
|
141
|
-
module: 'speedKit.CronJob',
|
|
142
|
-
cronpattern: '*/60 */24 */30 */12 *',
|
|
143
|
-
startsAt: new Date(),
|
|
144
|
-
expiresAt: new Date(1970,0, 1),
|
|
145
|
-
data: {
|
|
146
|
-
"name": getDeploymentJobName(origin),
|
|
147
|
-
"jobType": deploymentConfig.jobType || "deployment",
|
|
148
|
-
"filter": {
|
|
149
|
-
"contentTypes": [ "document" ],
|
|
150
|
-
"origin": [ origin ],
|
|
151
|
-
},
|
|
152
|
-
"scheduleIn": deploymentConfig.deploymentDelay,
|
|
153
|
-
"revalidationDelay": deploymentConfig.revalidationDelay,
|
|
154
|
-
},
|
|
155
|
-
}).save({ force: true }).catch(e => e.message));
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
exports.run = async function triggerRefreshAfterDeployment(db, status) {
|
|
159
|
-
const interval = new Date(Date.now() - 10 * MINUTE - 10);
|
|
160
|
-
const origins = await findNewAsset(db, interval, deploymentConfig.origins);
|
|
161
|
-
const app = db.connection.host;
|
|
162
|
-
|
|
163
|
-
if (origins.size === 0) {
|
|
164
|
-
status.data = {refreshing: false, reason: "no new asset" };
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
const data = status.data = {};
|
|
169
|
-
for (const origin of origins) {
|
|
170
|
-
try {
|
|
171
|
-
const changedAsset = await getChangedAssets(db, origin);
|
|
172
|
-
if (!changedAsset) {
|
|
173
|
-
data[origin] = {
|
|
174
|
-
refreshing: false, origin, reason: "asset hash not changed",
|
|
175
|
-
};
|
|
176
|
-
continue;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
const reason = `Asset changed: ${changedAsset}`;
|
|
180
|
-
fetch(deploymentConfig.slack, {
|
|
181
|
-
username: 'Deployment Detection',
|
|
182
|
-
method: 'post',
|
|
183
|
-
body: JSON.stringify({text: `Deployment on ${app} on ${origin} detected. Starting HTML ${deploymentConfig.jobType || "deployment"} Refresh. ${reason}`}),
|
|
184
|
-
}).catch(db.log.warn);
|
|
185
|
-
|
|
186
|
-
await runDeploymentJob(db, origin, reason);
|
|
187
|
-
|
|
188
|
-
data[origin] = {
|
|
189
|
-
refreshing: true, origin, latestAsset: changedAsset,
|
|
190
|
-
};
|
|
191
|
-
} catch (e) {
|
|
192
|
-
fetch(deploymentConfig.slack, {
|
|
193
|
-
username: 'Deployment Detection',
|
|
194
|
-
method: 'post',
|
|
195
|
-
body: JSON.stringify({text: `Deployment detection on ${app} and ${origin} failed. ${e.message}`}),
|
|
196
|
-
}).catch(db.log.warn);
|
|
197
|
-
data[origin] = {
|
|
198
|
-
refreshing: false, origin, reason: e.stack,
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
return data;
|
|
203
|
-
};
|
|
204
|
-
|
|
205
|
-
async function getChangedAssets(db, origin) {
|
|
206
|
-
for (const urlRegex of deploymentConfig.assetList) {
|
|
207
|
-
const interval = new Date(Date.now() - 10 * MINUTE - 10);
|
|
208
|
-
const current = await findAsset(db, urlRegex, origin, interval);
|
|
209
|
-
const previous = await findAsset(db, urlRegex, origin, null, interval);
|
|
210
|
-
|
|
211
|
-
if (!current) {
|
|
212
|
-
continue;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
// trigger deployment since we see a new matching asset
|
|
216
|
-
if (!previous) {
|
|
217
|
-
return current.url;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
if (deploymentConfig.compareContentHashes) {
|
|
221
|
-
if (current.contentHash === previous.contentHash) {
|
|
222
|
-
continue;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
if (await hasCachedAsset(db, current, urlRegex, interval)) {
|
|
226
|
-
db.log.info('contentHash already known', {current, previous});
|
|
227
|
-
continue;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
if (deploymentConfig.compareVersionStrings) {
|
|
232
|
-
const prevVersion = previous.url.match(urlRegex)[1];
|
|
233
|
-
const currentVersion = current.url.match(urlRegex)[1];
|
|
234
|
-
if (currentVersion < prevVersion) {
|
|
235
|
-
db.log.info('content version has not increased', {current, previous});
|
|
236
|
-
continue;
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
return current.url;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
return false;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
async function findAsset(db, urlRegex, origin, from, to) {
|
|
247
|
-
return await db["speedKit.Asset"].find()
|
|
248
|
-
.where(getQuery(urlRegex, origin))
|
|
249
|
-
.le('createdAt', to || new Date(Date.now() + MINUTE))
|
|
250
|
-
.gt('createdAt', from || new Date(1970, 0, 1))
|
|
251
|
-
.descending('createdAt')
|
|
252
|
-
.singleResult();
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
async function findNewAsset(db, from, origins) {
|
|
256
|
-
const result = await db["speedKit.Asset"].find()
|
|
257
|
-
.where(getBaseQuery(...origins))
|
|
258
|
-
.gt('createdAt', from || new Date(1970, 0, 1))
|
|
259
|
-
.resultList();
|
|
260
|
-
|
|
261
|
-
return new Set(result.map(asset => asset.origin));
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
async function hasAssetChanged(asset1, asset2) {
|
|
265
|
-
const res1 = await fetch(asset1.url);
|
|
266
|
-
const text1 = await res1.text();
|
|
267
|
-
|
|
268
|
-
const res2 = await fetch(asset2.url);
|
|
269
|
-
const text2 = await res2.text();
|
|
270
|
-
|
|
271
|
-
return text1 !== text2;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
/**
|
|
275
|
-
* Check whether we have seen the hash before
|
|
276
|
-
*/
|
|
277
|
-
async function hasCachedAsset(db, asset, urlRegex, to) {
|
|
278
|
-
return (await db["speedKit.Asset"].find()
|
|
279
|
-
.where(getQuery(urlRegex, asset.origin))
|
|
280
|
-
.equal('contentType', asset.contentType)
|
|
281
|
-
.equal('variation', asset.variation)
|
|
282
|
-
.equal('contentHash', asset.contentHash)
|
|
283
|
-
.le('createdAt', to || new Date(Date.now() + MINUTE))
|
|
284
|
-
.count()
|
|
285
|
-
) > 0;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
async function runDeploymentJob(db, origin, reason) {
|
|
289
|
-
const status = new db['jobs.Status']();
|
|
290
|
-
const jobId = getDeploymentJobId(origin);
|
|
291
|
-
const cronjob = await db['jobs.Definition'].load(jobId);
|
|
292
|
-
// TODO: quite hacky right now we may need a way to pass additional parameters to the run job code
|
|
293
|
-
cronjob.data.reason = reason;
|
|
294
|
-
status.cronjob = cronjob;
|
|
295
|
-
|
|
296
|
-
try {
|
|
297
|
-
await executeRefresh(db, status, cronjob);
|
|
298
|
-
} catch(error) {
|
|
299
|
-
status.status = 'failed';
|
|
300
|
-
status.error = error;
|
|
301
|
-
await status.save();
|
|
302
|
-
}
|
|
303
|
-
}
|
package/dist/services/document-handler-runtime/error/handler/required-file-not-found-handler.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import ErrorHandlerInterface from "../../../error-handling/interface/error-handler-interface";
|
|
2
|
-
import RequiredFileNotFoundError from "../required-file-not-found-error";
|
|
3
|
-
export default class RequiredFileNotFoundHandler implements ErrorHandlerInterface {
|
|
4
|
-
canHandle(error: any): boolean;
|
|
5
|
-
handle(error: RequiredFileNotFoundError): any;
|
|
6
|
-
}
|
package/dist/services/document-handler-runtime/error/handler/required-file-not-found-handler.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const required_file_not_found_error_1 = tslib_1.__importDefault(require("../required-file-not-found-error"));
|
|
5
|
-
class RequiredFileNotFoundHandler {
|
|
6
|
-
canHandle(error) {
|
|
7
|
-
return error instanceof required_file_not_found_error_1.default;
|
|
8
|
-
}
|
|
9
|
-
handle(error) {
|
|
10
|
-
console.error(error.message);
|
|
11
|
-
console.warn("Did you choose the correct folder?");
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
exports.default = RequiredFileNotFoundHandler;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { AsyncErrorHandlingFactory } from "../interface/error-handling-factory-interface";
|
|
2
|
-
export default abstract class AbstractAsyncErrorHandlingFactory implements AsyncErrorHandlingFactory {
|
|
3
|
-
buildService(): Promise<any>;
|
|
4
|
-
abstract _buildService(): Promise<any>;
|
|
5
|
-
private getErrorHandler;
|
|
6
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const error_handling_factory_1 = tslib_1.__importDefault(require("../factory/error-handling-factory"));
|
|
5
|
-
class AbstractAsyncErrorHandlingFactory {
|
|
6
|
-
async buildService() {
|
|
7
|
-
const errorHandler = this.getErrorHandler();
|
|
8
|
-
try {
|
|
9
|
-
return await this._buildService();
|
|
10
|
-
}
|
|
11
|
-
catch (error) {
|
|
12
|
-
errorHandler.handle(error);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
getErrorHandler() {
|
|
16
|
-
return new error_handling_factory_1.default().buildService();
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
exports.default = AbstractAsyncErrorHandlingFactory;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { ErrorHandlingServiceInterface } from "../interface/error-handling-service-interface";
|
|
2
|
-
export default abstract class AbstractAsyncErrorHandlingService implements ErrorHandlingServiceInterface {
|
|
3
|
-
run(): Promise<any>;
|
|
4
|
-
abstract _run(): Promise<any>;
|
|
5
|
-
private getErrorHandler;
|
|
6
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const error_handling_factory_1 = tslib_1.__importDefault(require("../factory/error-handling-factory"));
|
|
5
|
-
class AbstractAsyncErrorHandlingService {
|
|
6
|
-
async run() {
|
|
7
|
-
try {
|
|
8
|
-
return await this._run();
|
|
9
|
-
}
|
|
10
|
-
catch (error) {
|
|
11
|
-
this.getErrorHandler().handle(error);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
getErrorHandler() {
|
|
15
|
-
return new error_handling_factory_1.default().buildService();
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
exports.default = AbstractAsyncErrorHandlingService;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { ErrorHandlingFactoryInterface } from "../interface/error-handling-factory-interface";
|
|
2
|
-
export default abstract class AbstractErrorHandlingFactory implements ErrorHandlingFactoryInterface {
|
|
3
|
-
buildService(): any;
|
|
4
|
-
abstract _buildService(): any;
|
|
5
|
-
private getErrorHandler;
|
|
6
|
-
}
|