@speedkit/cli 2.10.0 → 2.12.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 +21 -0
- package/README.md +41 -62
- package/dist/commands/build-parameter-query.d.ts +4 -4
- package/dist/commands/build-parameter-query.js +38 -38
- package/dist/commands/build-prewarm-query.d.ts +4 -4
- package/dist/commands/build-prewarm-query.js +33 -34
- package/dist/commands/deploy.d.ts +4 -4
- package/dist/commands/deploy.js +14 -15
- package/dist/helpers/cli-config.d.ts +8 -7
- package/dist/helpers/cli-config.js +50 -44
- package/dist/services/cli/cli-service.d.ts +1 -1
- package/dist/services/deploy/context/deploy-context.d.ts +1 -4
- package/dist/services/deploy/context/deploy-context.js +6 -7
- package/dist/services/deploy/deploy-service-factory.d.ts +4 -5
- package/dist/services/deploy/deploy-service-factory.js +19 -18
- package/dist/services/integration-api/handler/customer-config-handler.d.ts +3 -3
- package/dist/services/integration-api/handler/customer-config-handler.js +20 -14
- package/dist/services/integration-api/struct/customer-config-file.d.ts +4 -3
- package/dist/services/integration-api/struct/customer-config-file.js +7 -5
- package/dist/services/onboarding/browser/abort-response.js +1 -1
- package/dist/services/onboarding/browser/baqend-response.d.ts +4 -4
- package/dist/services/onboarding/browser/baqend-response.js +33 -25
- package/dist/services/onboarding/browser/origin-response.d.ts +1 -1
- package/dist/services/onboarding/browser/origin-response.js +2 -3
- package/dist/services/onboarding/config-renderer/speed-kit-install-context.d.ts +4 -4
- package/dist/services/onboarding/config-renderer/speed-kit-install-context.js +44 -32
- package/dist/services/onboarding/dashboard/athena-service.d.ts +2 -2
- package/dist/services/onboarding/dashboard/athena-service.js +28 -23
- package/dist/services/onboarding/dashboard/index.d.ts +3 -3
- package/dist/services/onboarding/dashboard/index.js +48 -36
- package/dist/services/onboarding/dashboard/param-query-builder.d.ts +2 -2
- package/dist/services/onboarding/dashboard/param-query-builder.js +2 -2
- package/dist/services/onboarding/dashboard/request-diff-service.d.ts +1 -1
- package/dist/services/onboarding/dashboard/request-diff-service.js +32 -28
- package/dist/services/onboarding/fetch-event-handler.d.ts +6 -6
- package/dist/services/onboarding/fetch-event-handler.js +72 -62
- package/dist/services/onboarding/fetch-events/customer-domain-document-response.d.ts +8 -8
- package/dist/services/onboarding/fetch-events/customer-domain-document-response.js +51 -49
- package/dist/services/onboarding/fetch-events/customer-service-worker-js.d.ts +3 -3
- package/dist/services/onboarding/fetch-events/customer-service-worker-js.js +6 -6
- package/dist/services/onboarding/fetch-events/dashboard-request.d.ts +2 -2
- package/dist/services/onboarding/fetch-events/dashboard-request.js +3 -3
- package/dist/services/onboarding/fetch-events/speed-kit-asset-request.d.ts +7 -7
- package/dist/services/onboarding/fetch-events/speed-kit-asset-request.js +76 -59
- package/dist/services/onboarding/fetch-events/speed-kit-install-html.d.ts +3 -3
- package/dist/services/onboarding/fetch-events/speed-kit-install-html.js +14 -14
- package/dist/services/onboarding/fetch-events/speed-kit-install-js.d.ts +6 -6
- package/dist/services/onboarding/fetch-events/speed-kit-install-js.js +12 -10
- package/dist/services/onboarding/fetch-events/speed-kit-rum-pi-request.d.ts +7 -7
- package/dist/services/onboarding/fetch-events/speed-kit-rum-pi-request.js +3 -3
- package/dist/services/onboarding/fetch-events/speed-kit-service-worker-js.d.ts +4 -4
- package/dist/services/onboarding/fetch-events/speed-kit-service-worker-js.js +6 -4
- package/dist/services/onboarding/file-events/{fileWatcher.d.ts → file-watcher.d.ts} +9 -8
- package/dist/services/onboarding/file-events/{fileWatcher.js → file-watcher.js} +74 -56
- package/dist/services/onboarding/index.d.ts +3 -3
- package/dist/services/onboarding/onboarding-model.d.ts +36 -34
- package/dist/services/onboarding/onboarding-model.js +19 -19
- package/dist/services/onboarding/onboarding-service-factory.d.ts +6 -6
- package/dist/services/onboarding/onboarding-service-factory.js +80 -75
- package/dist/services/onboarding/onboarding-service.d.ts +7 -7
- package/dist/services/onboarding/onboarding-service.js +54 -48
- package/dist/services/onboarding/request-cache/cache.d.ts +3 -3
- package/dist/services/onboarding/request-cache/cache.js +7 -7
- package/dist/services/onboarding/server-config/index.js +2 -2
- package/dist/services/onboarding/todo-collector.d.ts +1 -1
- package/dist/services/onboarding/todo-collector.js +8 -6
- package/oclif.manifest.json +9 -9
- package/package.json +12 -5
|
@@ -2,44 +2,44 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.OnboardingServiceFactory = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const fetch_event_handler_1 = require("./fetch-event-handler");
|
|
10
|
-
const speed_kit_install_html_1 = require("./fetch-events/speed-kit-install-html");
|
|
11
|
-
const customer_domain_document_response_1 = require("./fetch-events/customer-domain-document-response");
|
|
12
|
-
const speed_kit_install_context_1 = require("./config-renderer/speed-kit-install-context");
|
|
13
|
-
const install_speed_kit_js_template_1 = require("./templates/install-speed-kit-js-template");
|
|
5
|
+
const client_athena_1 = require("@aws-sdk/client-athena");
|
|
6
|
+
const vm = tslib_1.__importStar(require("node:vm"));
|
|
7
|
+
const safe_1 = require("../../helpers/safe");
|
|
8
|
+
const files_1 = require("../../models/files");
|
|
14
9
|
const bundler_1 = require("../bundler");
|
|
15
|
-
const speed_kit_install_js_1 = require("./fetch-events/speed-kit-install-js");
|
|
16
|
-
const speed_kit_service_worker_js_1 = require("./fetch-events/speed-kit-service-worker-js");
|
|
17
|
-
const customer_service_worker_js_1 = require("./fetch-events/customer-service-worker-js");
|
|
18
|
-
const fileWatcher_1 = require("./file-events/fileWatcher");
|
|
19
10
|
const cli_1 = require("../cli");
|
|
20
|
-
const install_speed_kit_html_template_1 = require("./templates/install-speed-kit-html-template");
|
|
21
11
|
const config_api_context_1 = tslib_1.__importDefault(require("../config-api/context/config-api-context"));
|
|
22
12
|
const config_api_service_factory_1 = tslib_1.__importDefault(require("../config-api/factory/config-api-service-factory"));
|
|
23
|
-
const speed_kit_asset_request_1 = require("./fetch-events/speed-kit-asset-request");
|
|
24
|
-
const document_handler_runtime_service_factory_1 = tslib_1.__importDefault(require("../document-handler-runtime/factory/document-handler-runtime-service-factory"));
|
|
25
|
-
const cache_1 = require("./request-cache/cache");
|
|
26
|
-
const todo_collector_1 = require("./todo-collector");
|
|
27
|
-
const dashboard_request_1 = require("./fetch-events/dashboard-request");
|
|
28
|
-
const dashboard_1 = require("./dashboard");
|
|
29
|
-
const param_query_builder_1 = require("./dashboard/param-query-builder");
|
|
30
|
-
const athena_service_1 = require("./dashboard/athena-service");
|
|
31
|
-
const client_athena_1 = require("@aws-sdk/client-athena");
|
|
32
13
|
const diff_1 = require("../diff");
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const vm = tslib_1.__importStar(require("vm"));
|
|
36
|
-
const external_recipe_1 = require("../integration-api/virtual/external-recipe");
|
|
14
|
+
const document_handler_runtime_service_factory_1 = tslib_1.__importDefault(require("../document-handler-runtime/factory/document-handler-runtime-service-factory"));
|
|
15
|
+
const integration_api_context_1 = tslib_1.__importDefault(require("../integration-api/context/integration-api-context"));
|
|
37
16
|
const external_file_reader_1 = require("../integration-api/external/external-file-reader");
|
|
17
|
+
const integration_api_service_factory_1 = tslib_1.__importDefault(require("../integration-api/factory/integration-api-service-factory"));
|
|
38
18
|
const virtual_file_1 = require("../integration-api/struct/virtual-file");
|
|
19
|
+
const external_recipe_1 = require("../integration-api/virtual/external-recipe");
|
|
39
20
|
const install_file_recipe_1 = require("./config-renderer/install-file-recipe");
|
|
40
|
-
const
|
|
21
|
+
const speed_kit_install_context_1 = require("./config-renderer/speed-kit-install-context");
|
|
22
|
+
const dashboard_1 = require("./dashboard");
|
|
23
|
+
const athena_service_1 = require("./dashboard/athena-service");
|
|
24
|
+
const param_query_builder_1 = require("./dashboard/param-query-builder");
|
|
25
|
+
const request_diff_service_1 = require("./dashboard/request-diff-service");
|
|
26
|
+
const fetch_event_handler_1 = require("./fetch-event-handler");
|
|
27
|
+
const customer_domain_document_response_1 = require("./fetch-events/customer-domain-document-response");
|
|
28
|
+
const customer_service_worker_js_1 = require("./fetch-events/customer-service-worker-js");
|
|
29
|
+
const dashboard_request_1 = require("./fetch-events/dashboard-request");
|
|
30
|
+
const speed_kit_asset_request_1 = require("./fetch-events/speed-kit-asset-request");
|
|
31
|
+
const speed_kit_install_html_1 = require("./fetch-events/speed-kit-install-html");
|
|
32
|
+
const speed_kit_install_js_1 = require("./fetch-events/speed-kit-install-js");
|
|
41
33
|
const speed_kit_rum_pi_request_1 = require("./fetch-events/speed-kit-rum-pi-request");
|
|
34
|
+
const speed_kit_service_worker_js_1 = require("./fetch-events/speed-kit-service-worker-js");
|
|
35
|
+
const file_watcher_1 = require("./file-events/file-watcher");
|
|
36
|
+
const onboarding_model_1 = require("./onboarding-model");
|
|
37
|
+
const onboarding_service_1 = require("./onboarding-service");
|
|
38
|
+
const cache_1 = require("./request-cache/cache");
|
|
42
39
|
const server_config_1 = require("./server-config");
|
|
40
|
+
const install_speed_kit_html_template_1 = require("./templates/install-speed-kit-html-template");
|
|
41
|
+
const install_speed_kit_js_template_1 = require("./templates/install-speed-kit-js-template");
|
|
42
|
+
const todo_collector_1 = require("./todo-collector");
|
|
43
43
|
class OnboardingServiceFactory {
|
|
44
44
|
context;
|
|
45
45
|
cliConfig;
|
|
@@ -58,30 +58,21 @@ class OnboardingServiceFactory {
|
|
|
58
58
|
customerPath: this.context.customerPath,
|
|
59
59
|
fileDependencies: [],
|
|
60
60
|
requiredFiles: [],
|
|
61
|
-
verboseLevel: this.context.verboseLevel
|
|
61
|
+
verboseLevel: this.context.verboseLevel,
|
|
62
62
|
};
|
|
63
63
|
const documentHandler = await new document_handler_runtime_service_factory_1.default(documentHandlerContext, this.cliConfig, files).buildDocumentHandlerServer();
|
|
64
64
|
const bundler = new bundler_1.BundleServiceFactory().buildService();
|
|
65
65
|
const skTemplate = new install_speed_kit_js_template_1.InstallSpeedKitJsTemplate();
|
|
66
66
|
const speedKitInstallContext = new speed_kit_install_context_1.SpeedKitInstallContext(customerConfig, this.context.configName, files, bundler, skTemplate, this.context.local);
|
|
67
67
|
await this.buildInstallResource(speedKitInstallContext, files, cli);
|
|
68
|
-
const browserContext = new onboarding_model_1.BrowserContext(domainToStart, customerConfig.chromeFlags || []);
|
|
69
|
-
const fileWatcher = new
|
|
68
|
+
const browserContext = new onboarding_model_1.BrowserContext(domainToStart, customerConfig.chromeFlags || [], this.cliConfig);
|
|
69
|
+
const fileWatcher = new file_watcher_1.FileWatcher(cli, customerConfig, files, documentHandler, browserContext, cache);
|
|
70
70
|
const fetchHandler = await this.getFetchEventHandler(files, customerConfig, documentHandler, cache, cli, browserContext);
|
|
71
71
|
const fileTodoCollector = new todo_collector_1.TodoCollector(files.getInstallResources());
|
|
72
72
|
return new onboarding_service_1.OnboardingService(browserContext, customerConfig, fetchHandler, fileWatcher, cli, fileTodoCollector);
|
|
73
73
|
}
|
|
74
|
-
async getUrlForTest(customerConfig, cli) {
|
|
75
|
-
let domainToStart = customerConfig.origins[0];
|
|
76
|
-
if (customerConfig.origins.length > 1) {
|
|
77
|
-
domainToStart = await cli.select('select domain to start', customerConfig.origins.map((origin) => {
|
|
78
|
-
return { name: origin, value: origin };
|
|
79
|
-
}));
|
|
80
|
-
}
|
|
81
|
-
return domainToStart;
|
|
82
|
-
}
|
|
83
74
|
async buildInstallResource(speedKitInstallContext, files, cli) {
|
|
84
|
-
cli.startAction(
|
|
75
|
+
cli.startAction("build file install_resource");
|
|
85
76
|
const installResourceFile = new virtual_file_1.VirtualFile(files_1.INTEGRATION_FILES.BUILD.INSTALL, new install_file_recipe_1.InstallFileRecipe(speedKitInstallContext));
|
|
86
77
|
const result = await (0, safe_1.safe)(installResourceFile.buildContent());
|
|
87
78
|
if (result.success === true) {
|
|
@@ -92,6 +83,38 @@ class OnboardingServiceFactory {
|
|
|
92
83
|
cli.endAction(cli_1.CliActionStatus.FAILED);
|
|
93
84
|
cli.writeError(result.error);
|
|
94
85
|
}
|
|
86
|
+
async getAthenaClient(cli) {
|
|
87
|
+
const credentials = await this.getCredentials(cli);
|
|
88
|
+
if (!credentials) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const config = {
|
|
92
|
+
credentials: {
|
|
93
|
+
accessKeyId: credentials?.accessKeyId,
|
|
94
|
+
secretAccessKey: credentials?.secretAccessKey,
|
|
95
|
+
},
|
|
96
|
+
region: "eu-central-1",
|
|
97
|
+
};
|
|
98
|
+
return new athena_service_1.AthenaService(new client_athena_1.Athena(config), cli);
|
|
99
|
+
}
|
|
100
|
+
getConfigApi(app) {
|
|
101
|
+
const configApiContext = new config_api_context_1.default(app);
|
|
102
|
+
return new config_api_service_factory_1.default(configApiContext).getService();
|
|
103
|
+
}
|
|
104
|
+
async getCredentials(cli) {
|
|
105
|
+
cli.startAction("fetch athena credentials");
|
|
106
|
+
const configApiContext = new config_api_context_1.default("onboarding");
|
|
107
|
+
const configApi = new config_api_service_factory_1.default(configApiContext).getService();
|
|
108
|
+
const credentialsResult = await (0, safe_1.safe)(configApi.getModule("credentials"));
|
|
109
|
+
if (credentialsResult.success === true) {
|
|
110
|
+
const context = { module: { exports: { AWS_ATHENA: {} } } };
|
|
111
|
+
vm.runInNewContext(credentialsResult.data, context);
|
|
112
|
+
cli.endAction(cli_1.CliActionStatus.COMPLETED);
|
|
113
|
+
return context.module.exports.AWS_ATHENA;
|
|
114
|
+
}
|
|
115
|
+
cli.endAction(cli_1.CliActionStatus.FAILED);
|
|
116
|
+
cli.writeError(credentialsResult.error);
|
|
117
|
+
}
|
|
95
118
|
async getFetchEventHandler(files, customerConfig, documentHandler, cache, cli, browserContext) {
|
|
96
119
|
const configApi = this.getConfigApi(customerConfig.app);
|
|
97
120
|
const paramQueryBuilder = new param_query_builder_1.ParamQueryBuilder(customerConfig, files.getByName(files_1.INTEGRATION_FILES.CONFIG.SPEED_KIT));
|
|
@@ -106,8 +129,7 @@ class OnboardingServiceFactory {
|
|
|
106
129
|
];
|
|
107
130
|
if (this.context.local) {
|
|
108
131
|
const speedKitConfigLoader = new server_config_1.ServerConfig(cli, configApi);
|
|
109
|
-
handlers.push(new speed_kit_asset_request_1.SpeedKitAssetRequest(customerConfig, documentHandler, cache, cli, await speedKitConfigLoader.getServerSpeedKitConfig()));
|
|
110
|
-
handlers.push(new speed_kit_rum_pi_request_1.SpeedKitRumPiRequest(customerConfig, cache, cli));
|
|
132
|
+
handlers.push(new speed_kit_asset_request_1.SpeedKitAssetRequest(customerConfig, documentHandler, cache, cli, await speedKitConfigLoader.getServerSpeedKitConfig()), new speed_kit_rum_pi_request_1.SpeedKitRumPiRequest(customerConfig, cache, cli));
|
|
111
133
|
}
|
|
112
134
|
const athenaClient = await this.getAthenaClient(cli);
|
|
113
135
|
if (athenaClient) {
|
|
@@ -120,50 +142,33 @@ class OnboardingServiceFactory {
|
|
|
120
142
|
const integrationApiContext = new integration_api_context_1.default(this.context.customerPath, this.context.configName, []);
|
|
121
143
|
const integrationApi = new integration_api_service_factory_1.default(integrationApiContext, this.cliConfig).buildService();
|
|
122
144
|
const externalFileReader = new external_file_reader_1.ExternalFileReader();
|
|
123
|
-
return
|
|
124
|
-
{
|
|
145
|
+
return integrationApi.run([
|
|
146
|
+
{
|
|
147
|
+
name: files_1.INTEGRATION_FILES.CUSTOM.SW,
|
|
148
|
+
recipe: new external_recipe_1.ExternalRecipe(this.context.DEFAULT_SW_PATH, externalFileReader),
|
|
149
|
+
},
|
|
125
150
|
{
|
|
126
151
|
name: files_1.INTEGRATION_FILES.CUSTOM.DYNAMIC_FETCHER,
|
|
127
|
-
recipe: new external_recipe_1.ExternalRecipe(this.context.DEFAULT_DF_PATH, externalFileReader)
|
|
152
|
+
recipe: new external_recipe_1.ExternalRecipe(this.context.DEFAULT_DF_PATH, externalFileReader),
|
|
128
153
|
},
|
|
129
154
|
{
|
|
130
155
|
name: files_1.INTEGRATION_FILES.CUSTOM.LOADER,
|
|
131
|
-
recipe: new external_recipe_1.ExternalRecipe(this.context.DEFAULT_SNIPPET_PATH, externalFileReader)
|
|
156
|
+
recipe: new external_recipe_1.ExternalRecipe(this.context.DEFAULT_SNIPPET_PATH, externalFileReader),
|
|
132
157
|
},
|
|
133
158
|
{
|
|
134
159
|
name: files_1.INTEGRATION_FILES.CUSTOM.DOCUMENT_HANDLER,
|
|
135
|
-
recipe: new external_recipe_1.ExternalRecipe(this.context.DEFAULT_DOCUMENT_HANDLER_PATH, externalFileReader)
|
|
160
|
+
recipe: new external_recipe_1.ExternalRecipe(this.context.DEFAULT_DOCUMENT_HANDLER_PATH, externalFileReader),
|
|
136
161
|
},
|
|
137
162
|
]);
|
|
138
163
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
if (!credentials) {
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
const config = {
|
|
149
|
-
region: 'eu-central-1',
|
|
150
|
-
credentials: { accessKeyId: credentials?.accessKeyId, secretAccessKey: credentials?.secretAccessKey },
|
|
151
|
-
};
|
|
152
|
-
return new athena_service_1.AthenaService(new client_athena_1.Athena(config), cli);
|
|
153
|
-
}
|
|
154
|
-
async getCredentials(cli) {
|
|
155
|
-
cli.startAction('fetch athena credentials');
|
|
156
|
-
const configApiContext = new config_api_context_1.default('onboarding');
|
|
157
|
-
const configApi = new config_api_service_factory_1.default(configApiContext).getService();
|
|
158
|
-
const credentialsResult = await (0, safe_1.safe)(configApi.getModule('credentials'));
|
|
159
|
-
if (credentialsResult.success === true) {
|
|
160
|
-
const context = { module: { exports: { AWS_ATHENA: {} } } };
|
|
161
|
-
vm.runInNewContext(credentialsResult.data, context);
|
|
162
|
-
cli.endAction(cli_1.CliActionStatus.COMPLETED);
|
|
163
|
-
return context.module.exports.AWS_ATHENA;
|
|
164
|
+
async getUrlForTest(customerConfig, cli) {
|
|
165
|
+
let domainToStart = customerConfig.origins[0];
|
|
166
|
+
if (customerConfig.origins.length > 1) {
|
|
167
|
+
domainToStart = await cli.select("select domain to start", customerConfig.origins.map((origin) => {
|
|
168
|
+
return { name: origin, value: origin };
|
|
169
|
+
}));
|
|
164
170
|
}
|
|
165
|
-
|
|
166
|
-
cli.writeError(credentialsResult.error);
|
|
171
|
+
return domainToStart;
|
|
167
172
|
}
|
|
168
173
|
}
|
|
169
174
|
exports.OnboardingServiceFactory = OnboardingServiceFactory;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { CliService } from "../cli";
|
|
1
2
|
import CustomerConfig from "../integration-api/struct/customer-config";
|
|
2
|
-
import { BrowserContext } from "./onboarding-model";
|
|
3
3
|
import { FetchEventHandler } from "./fetch-event-handler";
|
|
4
|
-
import { FileWatcher } from "./file-events/
|
|
5
|
-
import {
|
|
4
|
+
import { FileWatcher } from "./file-events/file-watcher";
|
|
5
|
+
import { BrowserContext } from "./onboarding-model";
|
|
6
6
|
import { TodoCollector } from "./todo-collector";
|
|
7
7
|
/**
|
|
8
8
|
* Represents the OnboardingService which is responsible for setting up the browser to test a config using Puppeteer.
|
|
@@ -20,12 +20,12 @@ export declare class OnboardingService {
|
|
|
20
20
|
* prepare puppeteerBrowser, add eventListeners and start
|
|
21
21
|
*/
|
|
22
22
|
run(): Promise<void>;
|
|
23
|
-
private prepareBrowser;
|
|
24
|
-
private preparePage;
|
|
25
23
|
private findPage;
|
|
24
|
+
private navigate;
|
|
25
|
+
private prepareBrowser;
|
|
26
26
|
private prepareCleanState;
|
|
27
|
-
private
|
|
27
|
+
private preparePage;
|
|
28
28
|
private registerFileWatcher;
|
|
29
29
|
private registerReinstallSpeedKitOnNavigate;
|
|
30
|
-
private
|
|
30
|
+
private reinstallSpeedKit;
|
|
31
31
|
}
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.OnboardingService = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const puppeteer_extra_1 = tslib_1.__importDefault(require("puppeteer-extra"));
|
|
6
5
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
7
|
-
const
|
|
6
|
+
const puppeteer_extra_1 = tslib_1.__importDefault(require("puppeteer-extra"));
|
|
8
7
|
const safe_1 = require("../../helpers/safe");
|
|
8
|
+
const cli_1 = require("../cli");
|
|
9
9
|
/**
|
|
10
10
|
* Represents the OnboardingService which is responsible for setting up the browser to test a config using Puppeteer.
|
|
11
11
|
*/
|
|
@@ -29,58 +29,52 @@ class OnboardingService {
|
|
|
29
29
|
* prepare puppeteerBrowser, add eventListeners and start
|
|
30
30
|
*/
|
|
31
31
|
async run() {
|
|
32
|
-
this.cli.startAction(
|
|
32
|
+
this.cli.startAction("prepare browser");
|
|
33
33
|
const browser = await this.prepareBrowser();
|
|
34
34
|
const page = await this.preparePage(browser);
|
|
35
35
|
this.cli.endAction(cli_1.CliActionStatus.COMPLETED);
|
|
36
36
|
if (this.browserContext.startParameterDashboard) {
|
|
37
|
-
|
|
37
|
+
// eslint-disable-next-line unicorn/no-await-expression-member
|
|
38
|
+
await (await browser.newPage()).goto("http://skonboarding.local/");
|
|
38
39
|
}
|
|
39
40
|
await this.navigate(page, `${this.customerConfig.scope}speed-kit-install.html?url=${this.customerConfig.scope}`);
|
|
40
41
|
}
|
|
42
|
+
async findPage(browser) {
|
|
43
|
+
if (!browser)
|
|
44
|
+
throw new Error("Please start a browser first.");
|
|
45
|
+
const [page] = await browser.pages();
|
|
46
|
+
if (page) {
|
|
47
|
+
return page;
|
|
48
|
+
}
|
|
49
|
+
return browser.newPage();
|
|
50
|
+
}
|
|
51
|
+
async navigate(page, pathname) {
|
|
52
|
+
const goto = new URL(pathname, `${this.browserContext.domain}`);
|
|
53
|
+
await page.goto(goto.toString());
|
|
54
|
+
await page.bringToFront();
|
|
55
|
+
}
|
|
41
56
|
async prepareBrowser() {
|
|
42
57
|
const browser = await puppeteer_extra_1.default.launch({
|
|
43
|
-
|
|
58
|
+
args: this.browserContext.browserArgs,
|
|
44
59
|
defaultViewport: null,
|
|
45
|
-
|
|
60
|
+
devtools: true,
|
|
46
61
|
executablePath: this.browserContext.chromePath,
|
|
47
|
-
|
|
62
|
+
headless: false /* ignoreDefaultArgs: true, */,
|
|
48
63
|
});
|
|
49
64
|
for (const target of browser.targets()) {
|
|
50
|
-
if (target.type() ===
|
|
65
|
+
if (target.type() === "browser") {
|
|
51
66
|
await this.fetchEventHandler.handleRequestFetchEvents(target);
|
|
52
67
|
}
|
|
53
68
|
}
|
|
54
|
-
browser.on(
|
|
55
|
-
this.cli.writeError(
|
|
69
|
+
browser.on("disconnected", () => {
|
|
70
|
+
this.cli.writeError("Browser disconnected, shutting down");
|
|
56
71
|
process.exit(-1);
|
|
57
72
|
});
|
|
58
73
|
return browser;
|
|
59
74
|
}
|
|
60
|
-
async preparePage(browser) {
|
|
61
|
-
const page = await this.findPage(browser);
|
|
62
|
-
await this.prepareCleanState(page);
|
|
63
|
-
this.registerFileWatcher(page);
|
|
64
|
-
this.registerReinstallSpeedKitOnNavigate(page);
|
|
65
|
-
// inject open Todos from configFiles
|
|
66
|
-
page.on('framenavigated', async (frame) => {
|
|
67
|
-
const tasks = this.taskCollector.getOpenTasks();
|
|
68
|
-
await (0, safe_1.safe)(page.evaluate(`window.skOnboarding = ${JSON.stringify(tasks)}`));
|
|
69
|
-
});
|
|
70
|
-
return page;
|
|
71
|
-
}
|
|
72
|
-
async findPage(browser) {
|
|
73
|
-
if (!browser)
|
|
74
|
-
throw new Error('Please start a browser first.');
|
|
75
|
-
const [page] = await browser.pages();
|
|
76
|
-
if (page) {
|
|
77
|
-
return page;
|
|
78
|
-
}
|
|
79
|
-
return browser.newPage();
|
|
80
|
-
}
|
|
81
75
|
async prepareCleanState(page) {
|
|
82
76
|
const pageClient = await page.target().createCDPSession();
|
|
83
|
-
pageClient.on(
|
|
77
|
+
pageClient.on("ServiceWorker.workerRegistrationUpdated", ({ registrations, }) => {
|
|
84
78
|
for (const registration of registrations) {
|
|
85
79
|
if (registration.isDeleted) {
|
|
86
80
|
this.cli.writeWarning((0, chalk_1.default) `{yellow Unregistered Service Worker} at {bold ${registration.scopeURL}} (${registration.registrationId})`);
|
|
@@ -89,21 +83,29 @@ class OnboardingService {
|
|
|
89
83
|
});
|
|
90
84
|
// cleanUp old serviceWorkers
|
|
91
85
|
await pageClient.send("ServiceWorker.enable");
|
|
92
|
-
await pageClient.send("ServiceWorker.unregister", {
|
|
86
|
+
await pageClient.send("ServiceWorker.unregister", {
|
|
87
|
+
scopeURL: this.browserContext.domain,
|
|
88
|
+
});
|
|
93
89
|
// clear storage for a clean start
|
|
94
|
-
await pageClient.send(
|
|
95
|
-
await pageClient.send("Storage.clearDataForOrigin", {
|
|
90
|
+
await pageClient.send("Storage.clearCookies");
|
|
91
|
+
await pageClient.send("Storage.clearDataForOrigin", {
|
|
92
|
+
origin: this.browserContext.domain,
|
|
93
|
+
storageTypes: "all",
|
|
94
|
+
});
|
|
96
95
|
await pageClient.send("Emulation.clearDeviceMetricsOverride");
|
|
97
96
|
await pageClient.send("Emulation.clearGeolocationOverride");
|
|
98
97
|
}
|
|
99
|
-
async
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
98
|
+
async preparePage(browser) {
|
|
99
|
+
const page = await this.findPage(browser);
|
|
100
|
+
await this.prepareCleanState(page);
|
|
101
|
+
this.registerFileWatcher(page);
|
|
102
|
+
this.registerReinstallSpeedKitOnNavigate(page);
|
|
103
|
+
// inject open Todos from configFiles
|
|
104
|
+
page.on("framenavigated", async (_frame) => {
|
|
105
|
+
const tasks = this.taskCollector.getOpenTasks();
|
|
106
|
+
await (0, safe_1.safe)(page.evaluate(`window.skOnboarding = ${JSON.stringify(tasks)}`));
|
|
107
|
+
});
|
|
108
|
+
return page;
|
|
107
109
|
}
|
|
108
110
|
registerFileWatcher(page) {
|
|
109
111
|
this.fileWatcher.addCallbackOnFileChange(page, async () => {
|
|
@@ -111,7 +113,7 @@ class OnboardingService {
|
|
|
111
113
|
});
|
|
112
114
|
}
|
|
113
115
|
registerReinstallSpeedKitOnNavigate(page) {
|
|
114
|
-
page.on(
|
|
116
|
+
page.on("framenavigated", async (frame) => {
|
|
115
117
|
if (frame.parentFrame() !== null) {
|
|
116
118
|
return;
|
|
117
119
|
}
|
|
@@ -121,10 +123,14 @@ class OnboardingService {
|
|
|
121
123
|
}
|
|
122
124
|
});
|
|
123
125
|
}
|
|
124
|
-
async
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
|
|
126
|
+
async reinstallSpeedKit(page, pathname) {
|
|
127
|
+
const url = new URL(page.url());
|
|
128
|
+
let target = url.href;
|
|
129
|
+
if (!pathname.includes("/speed-kit-install.html")) {
|
|
130
|
+
target = `${this.customerConfig.scope}speed-kit-install.html?url=${encodeURIComponent(target)}`;
|
|
131
|
+
}
|
|
132
|
+
this.reinstallOnNextNavigate = false;
|
|
133
|
+
await this.navigate(page, target);
|
|
128
134
|
}
|
|
129
135
|
}
|
|
130
136
|
exports.OnboardingService = OnboardingService;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BaqendResponse } from "../browser/baqend-response";
|
|
2
1
|
import { CliService } from "../../cli";
|
|
2
|
+
import { BaqendResponse } from "../browser/baqend-response";
|
|
3
3
|
/**
|
|
4
4
|
* This class represents a cache for storing responses from the localDocumentHandler.
|
|
5
5
|
*/
|
|
@@ -7,9 +7,9 @@ export declare class Cache {
|
|
|
7
7
|
private cli;
|
|
8
8
|
private inMemoryCache;
|
|
9
9
|
constructor(cli: CliService);
|
|
10
|
+
addEntry(requestUri: string, response: BaqendResponse): void;
|
|
11
|
+
clear(): void;
|
|
10
12
|
getAll(): IterableIterator<[string, BaqendResponse]>;
|
|
11
13
|
getEntry(requestUri: string): BaqendResponse | void;
|
|
12
|
-
addEntry(requestUri: string, response: BaqendResponse): void;
|
|
13
14
|
removeEntry(requestUri: string): void;
|
|
14
|
-
clear(): void;
|
|
15
15
|
}
|
|
@@ -10,6 +10,13 @@ class Cache {
|
|
|
10
10
|
constructor(cli) {
|
|
11
11
|
this.cli = cli;
|
|
12
12
|
}
|
|
13
|
+
addEntry(requestUri, response) {
|
|
14
|
+
this.inMemoryCache.set(requestUri, response);
|
|
15
|
+
}
|
|
16
|
+
clear() {
|
|
17
|
+
this.cli.writeWarning("clear request-caches");
|
|
18
|
+
this.inMemoryCache.clear();
|
|
19
|
+
}
|
|
13
20
|
getAll() {
|
|
14
21
|
return this.inMemoryCache.entries();
|
|
15
22
|
}
|
|
@@ -18,15 +25,8 @@ class Cache {
|
|
|
18
25
|
return this.inMemoryCache.get(requestUri);
|
|
19
26
|
}
|
|
20
27
|
}
|
|
21
|
-
addEntry(requestUri, response) {
|
|
22
|
-
this.inMemoryCache.set(requestUri, response);
|
|
23
|
-
}
|
|
24
28
|
removeEntry(requestUri) {
|
|
25
29
|
this.inMemoryCache.delete(requestUri);
|
|
26
30
|
}
|
|
27
|
-
clear() {
|
|
28
|
-
this.cli.writeWarning('clear request-caches');
|
|
29
|
-
this.inMemoryCache.clear();
|
|
30
|
-
}
|
|
31
31
|
}
|
|
32
32
|
exports.Cache = Cache;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ServerConfig = void 0;
|
|
4
|
-
const cli_1 = require("../../cli");
|
|
5
4
|
const safe_1 = require("../../../helpers/safe");
|
|
5
|
+
const cli_1 = require("../../cli");
|
|
6
6
|
class ServerConfig {
|
|
7
7
|
cli;
|
|
8
8
|
client;
|
|
@@ -18,7 +18,7 @@ class ServerConfig {
|
|
|
18
18
|
return JSON.parse(serverConfig);
|
|
19
19
|
}
|
|
20
20
|
async getServerConfig() {
|
|
21
|
-
this.cli.startAction(
|
|
21
|
+
this.cli.startAction("wait for credentials from server-config");
|
|
22
22
|
const serverConfigResponse = await (0, safe_1.safe)(this.client.getServerConfig());
|
|
23
23
|
if (serverConfigResponse.success === false) {
|
|
24
24
|
this.cli.endAction(cli_1.CliActionStatus.FAILED);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { FileInterface } from "../integration-api/integration-api-model";
|
|
2
2
|
export type task = {
|
|
3
|
-
todo: string;
|
|
4
3
|
context: string;
|
|
5
4
|
file: string;
|
|
6
5
|
line: number;
|
|
6
|
+
todo: string;
|
|
7
7
|
};
|
|
8
8
|
/**
|
|
9
9
|
* Represents a TodoCollector class that collects open tasks from files.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TodoCollector = void 0;
|
|
4
4
|
const virtual_file_1 = require("../integration-api/struct/virtual-file");
|
|
5
|
-
const TODO_MATCH = /(todo[
|
|
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.
|
|
8
8
|
* This files will then be injected to the current open page, so you or the browser-extension can access and display them
|
|
@@ -13,7 +13,7 @@ class TodoCollector {
|
|
|
13
13
|
this.files = files;
|
|
14
14
|
}
|
|
15
15
|
getOpenTasks() {
|
|
16
|
-
const configFiles = this.files.filter(file => {
|
|
16
|
+
const configFiles = this.files.filter((file) => {
|
|
17
17
|
return !(file.type instanceof virtual_file_1.VirtualFile);
|
|
18
18
|
});
|
|
19
19
|
const tasks = [];
|
|
@@ -21,10 +21,10 @@ class TodoCollector {
|
|
|
21
21
|
const content = configFile.getContent();
|
|
22
22
|
content.replace(TODO_MATCH, (taskString, task, taskContext) => {
|
|
23
23
|
tasks.push({
|
|
24
|
-
todo: task,
|
|
25
24
|
context: encodeURI(taskContext),
|
|
26
25
|
file: configFile.name,
|
|
27
|
-
line: this.lineNumber(task, content)
|
|
26
|
+
line: this.lineNumber(task, content),
|
|
27
|
+
todo: task,
|
|
28
28
|
});
|
|
29
29
|
return taskString;
|
|
30
30
|
});
|
|
@@ -36,8 +36,10 @@ class TodoCollector {
|
|
|
36
36
|
}
|
|
37
37
|
lineNumberByIndex(index, string) {
|
|
38
38
|
// RegExp
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
let line = 0;
|
|
40
|
+
let match;
|
|
41
|
+
const re = /(^)[\S\s]/gm;
|
|
42
|
+
while ((match = re.exec(string))) {
|
|
41
43
|
if (match.index > index)
|
|
42
44
|
break;
|
|
43
45
|
line++;
|
package/oclif.manifest.json
CHANGED
|
@@ -104,14 +104,6 @@
|
|
|
104
104
|
"multiple": false,
|
|
105
105
|
"type": "option"
|
|
106
106
|
},
|
|
107
|
-
"slackToken": {
|
|
108
|
-
"char": "t",
|
|
109
|
-
"description": "Slack hook found on 1Pass",
|
|
110
|
-
"name": "slackToken",
|
|
111
|
-
"hasDynamicHelp": false,
|
|
112
|
-
"multiple": false,
|
|
113
|
-
"type": "option"
|
|
114
|
-
},
|
|
115
107
|
"artifacts": {
|
|
116
108
|
"char": "a",
|
|
117
109
|
"description": "Whitelist of files to deploy",
|
|
@@ -126,6 +118,14 @@
|
|
|
126
118
|
"name": "dryRun",
|
|
127
119
|
"allowNo": false,
|
|
128
120
|
"type": "boolean"
|
|
121
|
+
},
|
|
122
|
+
"slackToken": {
|
|
123
|
+
"char": "t",
|
|
124
|
+
"description": "Slack hook found on 1Pass",
|
|
125
|
+
"name": "slackToken",
|
|
126
|
+
"hasDynamicHelp": false,
|
|
127
|
+
"multiple": false,
|
|
128
|
+
"type": "option"
|
|
129
129
|
}
|
|
130
130
|
},
|
|
131
131
|
"hasDynamicHelp": false,
|
|
@@ -696,5 +696,5 @@
|
|
|
696
696
|
]
|
|
697
697
|
}
|
|
698
698
|
},
|
|
699
|
-
"version": "2.
|
|
699
|
+
"version": "2.12.0"
|
|
700
700
|
}
|
package/package.json
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@speedkit/cli",
|
|
3
3
|
"description": "Speed Kit CLI",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.12.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Baqend.com",
|
|
7
7
|
"email": "info@baqend.com"
|
|
8
8
|
},
|
|
9
|
-
"repository":
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://gitlab.orestes.info/baqend/speed-kit-cli.git"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://www.notion.so/baqend/d3749c5796d647f5892aa5ebfa2fd75f?v=002e4f2c19af4b50a590c093fd82afed",
|
|
15
|
+
"email": "info@baqend.com"
|
|
16
|
+
},
|
|
10
17
|
"homepage": "https://gitlab.orestes.info/baqend/speed-kit-cli",
|
|
11
|
-
"bugs": "https://www.notion.so/baqend/d3749c5796d647f5892aa5ebfa2fd75f?v=002e4f2c19af4b50a590c093fd82afed",
|
|
12
18
|
"license": "MIT",
|
|
13
19
|
"publishConfig": {
|
|
14
20
|
"access": "public"
|
|
@@ -104,6 +110,7 @@
|
|
|
104
110
|
"@types/mock-fs": "^4.13.4",
|
|
105
111
|
"@types/node": "^18.19",
|
|
106
112
|
"@types/uuid": "^8.3.4",
|
|
113
|
+
"@typescript-eslint/eslint-plugin": "^7.2.0",
|
|
107
114
|
"chai": "^4.4",
|
|
108
115
|
"copyfiles": "^2.4.1",
|
|
109
116
|
"esbuild": "^0.20",
|
|
@@ -117,14 +124,14 @@
|
|
|
117
124
|
"lint-staged": "^14.0.1",
|
|
118
125
|
"mocha": "^10.1.0",
|
|
119
126
|
"mocha-junit-reporter": "^2.2.1",
|
|
120
|
-
"nock": "^13.5",
|
|
121
|
-
"ts-sinon": "^2.0.2",
|
|
122
127
|
"mock-fs": "^5.2.0",
|
|
128
|
+
"nock": "^13.5",
|
|
123
129
|
"nyc": "^15.1.0",
|
|
124
130
|
"oclif": "^4.5",
|
|
125
131
|
"shx": "^0.3.4",
|
|
126
132
|
"ts-mocha": "^10.0.0",
|
|
127
133
|
"ts-node": "^10.9",
|
|
134
|
+
"ts-sinon": "^2.0.2",
|
|
128
135
|
"tslib": "^2.6",
|
|
129
136
|
"typescript": "^5.4",
|
|
130
137
|
"typescript-json-serializer": "^4.3.0"
|