@speedkit/cli 2.62.0 → 2.63.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 +19 -0
- package/README.md +1 -1
- package/dist/helpers/safe.js +16 -3
- package/dist/services/document-handler-runtime/document-handler-server.js +4 -3
- package/dist/services/onboarding/dashboard/diff-against-current-page.d.ts +3 -1
- package/dist/services/onboarding/dashboard/diff-against-current-page.js +10 -1
- package/dist/services/onboarding/error/document-handler-transform-error.d.ts +3 -0
- package/dist/services/onboarding/error/document-handler-transform-error.js +11 -0
- package/dist/services/onboarding/onboarding-model.d.ts +2 -0
- package/dist/services/onboarding/onboarding-model.js +4 -2
- package/dist/services/onboarding/onboarding-service-factory.js +1 -3
- package/dist/services/onboarding/virtual-orestes-app/crawler.js +6 -0
- package/dist/services/onboarding/virtual-orestes-app/index.js +4 -6
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
# [2.63.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.62.1...v2.63.0) (2024-11-01)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* create dashboardEndpoint also without aws-credentials ([38ccbf9](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/38ccbf9d83b9d9fc3d37cbcbe3196e1509ffdaff))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **onboarding:** make documentHandler errors more verbose ([cfb7e44](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/cfb7e448491ae7469addfd2370167a303f381851))
|
|
12
|
+
|
|
13
|
+
## [2.62.1](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.62.0...v2.62.1) (2024-11-01)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
* **onboarding:** set correct userAgents from orestest-project ([d3f4287](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/d3f428701b55a2dd8ceeb53bab5f9d13db3fd59a))
|
|
19
|
+
|
|
1
20
|
# [2.62.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.61.1...v2.62.0) (2024-11-01)
|
|
2
21
|
|
|
3
22
|
|
package/README.md
CHANGED
package/dist/helpers/safe.js
CHANGED
|
@@ -13,10 +13,14 @@ async function safeAsync(promise) {
|
|
|
13
13
|
return { data, success: true };
|
|
14
14
|
}
|
|
15
15
|
catch (error) {
|
|
16
|
-
if (error instanceof Error) {
|
|
16
|
+
if (error instanceof Error || isError(error)) {
|
|
17
17
|
return { success: false, error: error.message, errorObj: error };
|
|
18
18
|
}
|
|
19
|
-
return {
|
|
19
|
+
return {
|
|
20
|
+
success: false,
|
|
21
|
+
error: "Something went wrong: " + error?.message,
|
|
22
|
+
errorObj: error,
|
|
23
|
+
};
|
|
20
24
|
}
|
|
21
25
|
}
|
|
22
26
|
function safeSync(function_) {
|
|
@@ -25,9 +29,18 @@ function safeSync(function_) {
|
|
|
25
29
|
return { data, success: true };
|
|
26
30
|
}
|
|
27
31
|
catch (error) {
|
|
28
|
-
if (error instanceof Error) {
|
|
32
|
+
if (error instanceof Error || isError(error)) {
|
|
29
33
|
return { success: false, error: error.message, errorObj: error };
|
|
30
34
|
}
|
|
31
35
|
return { success: false, error: "Something went wrong", errorObj: error };
|
|
32
36
|
}
|
|
33
37
|
}
|
|
38
|
+
function isError(error) {
|
|
39
|
+
if (!("message" in error)) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
if (!("stack" in error)) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
@@ -6,7 +6,6 @@ const document_handler_runtime_context_1 = require("./context/document-handler-r
|
|
|
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
8
|
const vm = tslib_1.__importStar(require("node:vm"));
|
|
9
|
-
const vm_error_1 = require("../onboarding/error/vm-error");
|
|
10
9
|
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
11
10
|
const files_1 = require("../../models/files");
|
|
12
11
|
// documentHandlerDependencies
|
|
@@ -15,6 +14,7 @@ const request_1 = require("./server/request");
|
|
|
15
14
|
const document_handler_response_1 = require("./server/document-handler-response");
|
|
16
15
|
const safe_1 = require("../../helpers/safe");
|
|
17
16
|
const vm_empty_response_error_1 = require("../onboarding/error/vm-empty-response-error");
|
|
17
|
+
const document_handler_transform_error_1 = require("../onboarding/error/document-handler-transform-error");
|
|
18
18
|
class DocumentHandlerServer {
|
|
19
19
|
customerConfig;
|
|
20
20
|
files;
|
|
@@ -50,6 +50,7 @@ class DocumentHandlerServer {
|
|
|
50
50
|
CUSTOM_STYLES: this.getStyles(),
|
|
51
51
|
...this.getContextVars(),
|
|
52
52
|
...this.createNodeVmContext(),
|
|
53
|
+
skErrorContext: {},
|
|
53
54
|
};
|
|
54
55
|
const customDocumentHandlerFile = this.files.getByName(files_1.INTEGRATION_FILES.CUSTOM.DOCUMENT_HANDLER);
|
|
55
56
|
if (customDocumentHandlerFile.path) {
|
|
@@ -77,10 +78,10 @@ class DocumentHandlerServer {
|
|
|
77
78
|
}
|
|
78
79
|
return vmResponse.data;
|
|
79
80
|
}
|
|
80
|
-
throw new
|
|
81
|
+
throw new document_handler_transform_error_1.DocumentHandlerTransformError(vmResponse.errorObj);
|
|
81
82
|
}
|
|
82
83
|
getTransformFunctionWrapper() {
|
|
83
|
-
return `\n\npost(db, skInternalRequest, skInternalResponse).catch((
|
|
84
|
+
return `\n\npost(db, skInternalRequest, skInternalResponse).catch((error)=>reject(error));`;
|
|
84
85
|
}
|
|
85
86
|
async buildDocumentHandler() {
|
|
86
87
|
this.documentHandlerCode = await this.getDocumentHandler();
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { DiffService } from "../../diff";
|
|
2
2
|
import { DocumentHandlerServer } from "../../document-handler-runtime/document-handler-server";
|
|
3
3
|
import { Crawler } from "../virtual-orestes-app/crawler";
|
|
4
|
+
import { CliService } from "../../cli";
|
|
4
5
|
export declare class DiffAgainstCurrentPage {
|
|
5
6
|
private diffService;
|
|
6
7
|
private documentHandlerRuntime;
|
|
7
8
|
private crawler;
|
|
8
|
-
|
|
9
|
+
private cli;
|
|
10
|
+
constructor(diffService: DiffService, documentHandlerRuntime: DocumentHandlerServer, crawler: Crawler, cli: CliService);
|
|
9
11
|
postDiff(currentHtml: string, currentUrl: string, variant?: string, transform?: boolean): Promise<boolean>;
|
|
10
12
|
}
|
|
@@ -1,21 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DiffAgainstCurrentPage = void 0;
|
|
4
|
+
const cli_1 = require("../../cli");
|
|
4
5
|
class DiffAgainstCurrentPage {
|
|
5
6
|
diffService;
|
|
6
7
|
documentHandlerRuntime;
|
|
7
8
|
crawler;
|
|
8
|
-
|
|
9
|
+
cli;
|
|
10
|
+
constructor(diffService, documentHandlerRuntime, crawler, cli) {
|
|
9
11
|
this.diffService = diffService;
|
|
10
12
|
this.documentHandlerRuntime = documentHandlerRuntime;
|
|
11
13
|
this.crawler = crawler;
|
|
14
|
+
this.cli = cli;
|
|
12
15
|
}
|
|
13
16
|
async postDiff(currentHtml, currentUrl, variant = "DEFAULT", transform = false) {
|
|
17
|
+
this.cli.writeWarning(`received diff for url: ${currentUrl}`);
|
|
18
|
+
this.cli.startAction(`fetch remote`);
|
|
14
19
|
const originResponse = await this.crawler.fetchRemote(currentUrl, variant.toUpperCase());
|
|
15
20
|
let originHtml = await originResponse?.text();
|
|
16
21
|
if (!originHtml) {
|
|
22
|
+
this.cli.endAction(cli_1.CliActionStatus.FAILED);
|
|
17
23
|
throw new Error("Could not fetch remote page");
|
|
18
24
|
}
|
|
25
|
+
this.cli.endAction(cli_1.CliActionStatus.COMPLETED);
|
|
26
|
+
this.cli.startAction(`transform documents`);
|
|
19
27
|
if (transform) {
|
|
20
28
|
// todo check if the currentHTML is already transformed
|
|
21
29
|
const currentDocumentHandlerResponse = await this.documentHandlerRuntime.transform(currentHtml, variant, currentUrl, {});
|
|
@@ -23,6 +31,7 @@ class DiffAgainstCurrentPage {
|
|
|
23
31
|
const originDocumentHandlerResponse = await this.documentHandlerRuntime.transform(originHtml, variant, currentUrl, {});
|
|
24
32
|
originHtml = originDocumentHandlerResponse.body;
|
|
25
33
|
}
|
|
34
|
+
this.cli.endAction(cli_1.CliActionStatus.COMPLETED);
|
|
26
35
|
const remoteFilePath = await this.diffService.writeContentToTemporalFile(`remote-${variant}`, originHtml);
|
|
27
36
|
const localFilePath = await this.diffService.writeContentToTemporalFile("current", currentHtml);
|
|
28
37
|
return await this.diffService.executeDiff(localFilePath, remoteFilePath);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DocumentHandlerTransformError = void 0;
|
|
4
|
+
class DocumentHandlerTransformError extends Error {
|
|
5
|
+
constructor(error) {
|
|
6
|
+
super(error.message);
|
|
7
|
+
this.stack = error.stack;
|
|
8
|
+
this.cause = error.cause;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.DocumentHandlerTransformError = DocumentHandlerTransformError;
|
|
@@ -111,7 +111,9 @@ class OnboardingContext {
|
|
|
111
111
|
}
|
|
112
112
|
exports.OnboardingContext = OnboardingContext;
|
|
113
113
|
exports.USER_AGENT = {
|
|
114
|
-
DESKTOP: "Mozilla/5.0 (
|
|
115
|
-
MOBILE: "Mozilla/5.0 (
|
|
114
|
+
DESKTOP: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.2 Safari/605.1.15 (compatible; SpeedKit/1.0)",
|
|
115
|
+
MOBILE: "Mozilla/5.0 (iPhone; CPU iPhone OS 14_7_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.2 Mobile/15E148 Safari/604.1 (compatible; SpeedKit/1.0)",
|
|
116
|
+
TABLET: "Mozilla/5.0 (iPad; CPU OS 14_7_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.2 Mobile/15E148 Safari/604.1 (compatible; SpeedKit/1.0)",
|
|
117
|
+
TV: "Mozilla/5.0 (Linux; NetCast; U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.79 Safari/537.36 SmartTV/10.0 Colt/2.0 (compatible; SpeedKit/1.0)",
|
|
116
118
|
};
|
|
117
119
|
exports.SpeedKitInstallRegex = /<script(?:(?!<\/script>).)*app\.baqend\.com\/v1\/speedkit\/install.js(?:(?!<\/script>).)*<\/script>/s;
|
|
@@ -124,14 +124,12 @@ class OnboardingServiceFactory {
|
|
|
124
124
|
new speed_kit_install_js_1.SpeedKitInstallJs(customerConfig, files.getByName(files_1.INTEGRATION_FILES.BUILD.INSTALL)),
|
|
125
125
|
new customer_service_worker_js_1.CustomerServiceWorkerJs(customerConfig),
|
|
126
126
|
new speed_kit_service_worker_js_1.SpeedKitServiceWorkerJs(customerConfig, files.getByName(files_1.INTEGRATION_FILES.CUSTOM.SW)),
|
|
127
|
+
new dashboard_request_1.DashboardRequest(new dashboard_1.Dashboard(customerConfig, parameterQueryBuilder, athenaClient, requestDiffService, new diff_against_current_page_1.DiffAgainstCurrentPage(DiffService, documentHandler, crawler, cli), cache)),
|
|
127
128
|
];
|
|
128
129
|
if (this.context.local) {
|
|
129
130
|
const orestesApp = new virtual_orestes_app_1.VirtualOrestesApp(customerConfig, crawler, documentHandler, cache, cli);
|
|
130
131
|
handlers.push(new speed_kit_asset_request_1.SpeedKitAssetRequest(customerConfig, orestesApp), new speed_kit_rum_pi_request_1.SpeedKitRumPiRequest(customerConfig, cache, cli));
|
|
131
132
|
}
|
|
132
|
-
if (athenaClient) {
|
|
133
|
-
handlers.push(new dashboard_request_1.DashboardRequest(new dashboard_1.Dashboard(customerConfig, parameterQueryBuilder, athenaClient, requestDiffService, new diff_against_current_page_1.DiffAgainstCurrentPage(DiffService, documentHandler, crawler), cache)));
|
|
134
|
-
}
|
|
135
133
|
return new fetch_event_handler_1.FetchEventHandler(handlers, customerConfig, cli, configApi);
|
|
136
134
|
}
|
|
137
135
|
async getSpeedKitServerConfig(configApi, cli) {
|
|
@@ -39,6 +39,12 @@ class Crawler {
|
|
|
39
39
|
if (variation.includes("MOBILE")) {
|
|
40
40
|
return onboarding_model_1.USER_AGENT.MOBILE;
|
|
41
41
|
}
|
|
42
|
+
if (variation.includes("TABLET")) {
|
|
43
|
+
return onboarding_model_1.USER_AGENT.TABLET;
|
|
44
|
+
}
|
|
45
|
+
if (variation.includes("TV")) {
|
|
46
|
+
return onboarding_model_1.USER_AGENT.TV;
|
|
47
|
+
}
|
|
42
48
|
return onboarding_model_1.USER_AGENT.DESKTOP;
|
|
43
49
|
}
|
|
44
50
|
prepareOriginRequest(originUrl, variationParameter, init) {
|
|
@@ -79,12 +79,10 @@ class VirtualOrestesApp {
|
|
|
79
79
|
return baqendResponse;
|
|
80
80
|
}
|
|
81
81
|
returnErrorResponse(customResponse, customHeaders) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
this.cli.writeError(message);
|
|
87
|
-
this.cli.writeError(JSON.stringify(customResponse.errorObj));
|
|
82
|
+
const message = `Could not transform html: - ${customResponse.error}`;
|
|
83
|
+
this.cli.writeError(`[VirtualOrestes]: ${message}`);
|
|
84
|
+
this.cli.comment(customResponse.errorObj.stack);
|
|
85
|
+
this.cli.writeWarning("Suggestion: check files: config_documentHandler.es6 | custom_documentHandler.js");
|
|
88
86
|
customHeaders.push({ name: "x-error", value: message });
|
|
89
87
|
return new baqend_response_1.BaqendResponse(message, null, customHeaders, 500);
|
|
90
88
|
}
|
package/oclif.manifest.json
CHANGED