@speedkit/cli 2.14.0 → 2.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/README.md +1 -1
- package/dist/services/onboarding/browser/baqend-response.d.ts +3 -3
- package/dist/services/onboarding/browser/baqend-response.js +13 -12
- 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 +38 -38
- package/dist/services/onboarding/dashboard/athena-service.d.ts +1 -1
- package/dist/services/onboarding/dashboard/athena-service.js +12 -12
- package/dist/services/onboarding/dashboard/index.d.ts +3 -3
- package/dist/services/onboarding/dashboard/index.js +14 -14
- package/dist/services/onboarding/dashboard/request-diff-service.d.ts +1 -1
- package/dist/services/onboarding/dashboard/request-diff-service.js +23 -23
- package/dist/services/onboarding/fetch-event-handler.d.ts +6 -6
- package/dist/services/onboarding/fetch-event-handler.js +52 -52
- package/dist/services/onboarding/fetch-events/customer-domain-document-response.d.ts +7 -7
- package/dist/services/onboarding/fetch-events/customer-domain-document-response.js +43 -43
- package/dist/services/onboarding/fetch-events/customer-service-worker-js.d.ts +2 -2
- package/dist/services/onboarding/fetch-events/customer-service-worker-js.js +4 -4
- package/dist/services/onboarding/fetch-events/dashboard-request.d.ts +1 -1
- package/dist/services/onboarding/fetch-events/dashboard-request.js +2 -2
- 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 +27 -27
- package/dist/services/onboarding/fetch-events/speed-kit-install-html.d.ts +2 -2
- package/dist/services/onboarding/fetch-events/speed-kit-install-html.js +12 -12
- package/dist/services/onboarding/file-events/file-watcher.d.ts +9 -9
- package/dist/services/onboarding/file-events/file-watcher.js +67 -67
- package/dist/services/onboarding/onboarding-service.d.ts +6 -6
- package/dist/services/onboarding/onboarding-service.js +38 -39
- 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 +1 -1
- package/dist/services/onboarding/todo-collector.d.ts +1 -1
- package/dist/services/onboarding/todo-collector.js +3 -4
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { CliService } from "../cli";
|
|
2
1
|
import CustomerConfig from "../integration-api/struct/customer-config";
|
|
2
|
+
import { BrowserContext } from "./onboarding-model";
|
|
3
3
|
import { FetchEventHandler } from "./fetch-event-handler";
|
|
4
4
|
import { FileWatcher } from "./file-events/file-watcher";
|
|
5
|
-
import {
|
|
5
|
+
import { CliService } from "../cli";
|
|
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 findPage;
|
|
24
|
-
private navigate;
|
|
25
23
|
private prepareBrowser;
|
|
26
|
-
private prepareCleanState;
|
|
27
24
|
private preparePage;
|
|
25
|
+
private findPage;
|
|
26
|
+
private prepareCleanState;
|
|
27
|
+
private reinstallSpeedKit;
|
|
28
28
|
private registerFileWatcher;
|
|
29
29
|
private registerReinstallSpeedKitOnNavigate;
|
|
30
|
-
private
|
|
30
|
+
private navigate;
|
|
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 chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
6
5
|
const puppeteer_extra_1 = tslib_1.__importDefault(require("puppeteer-extra"));
|
|
7
|
-
const
|
|
6
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
8
7
|
const cli_1 = require("../cli");
|
|
8
|
+
const safe_1 = require("../../helpers/safe");
|
|
9
9
|
/**
|
|
10
10
|
* Represents the OnboardingService which is responsible for setting up the browser to test a config using Puppeteer.
|
|
11
11
|
*/
|
|
@@ -34,32 +34,17 @@ class OnboardingService {
|
|
|
34
34
|
const page = await this.preparePage(browser);
|
|
35
35
|
this.cli.endAction(cli_1.CliActionStatus.COMPLETED);
|
|
36
36
|
if (this.browserContext.startParameterDashboard) {
|
|
37
|
-
// eslint-disable-next-line unicorn/no-await-expression-member
|
|
38
37
|
await (await browser.newPage()).goto("http://skonboarding.local/");
|
|
39
38
|
}
|
|
40
39
|
await this.navigate(page, `${this.customerConfig.scope}speed-kit-install.html?url=${this.customerConfig.scope}`);
|
|
41
40
|
}
|
|
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
|
-
}
|
|
56
41
|
async prepareBrowser() {
|
|
57
42
|
const browser = await puppeteer_extra_1.default.launch({
|
|
58
|
-
args: this.browserContext.browserArgs,
|
|
59
|
-
defaultViewport: null,
|
|
60
43
|
devtools: true,
|
|
61
|
-
|
|
44
|
+
defaultViewport: null,
|
|
62
45
|
headless: false /* ignoreDefaultArgs: true, */,
|
|
46
|
+
executablePath: this.browserContext.chromePath,
|
|
47
|
+
args: this.browserContext.browserArgs,
|
|
63
48
|
});
|
|
64
49
|
for (const target of browser.targets()) {
|
|
65
50
|
if (target.type() === "browser") {
|
|
@@ -72,6 +57,27 @@ class OnboardingService {
|
|
|
72
57
|
});
|
|
73
58
|
return browser;
|
|
74
59
|
}
|
|
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
|
+
}
|
|
75
81
|
async prepareCleanState(page) {
|
|
76
82
|
const pageClient = await page.target().createCDPSession();
|
|
77
83
|
pageClient.on("ServiceWorker.workerRegistrationUpdated", ({ registrations, }) => {
|
|
@@ -95,17 +101,14 @@ class OnboardingService {
|
|
|
95
101
|
await pageClient.send("Emulation.clearDeviceMetricsOverride");
|
|
96
102
|
await pageClient.send("Emulation.clearGeolocationOverride");
|
|
97
103
|
}
|
|
98
|
-
async
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
await (0, safe_1.safe)(page.evaluate(`window.skOnboarding = ${JSON.stringify(tasks)}`));
|
|
107
|
-
});
|
|
108
|
-
return page;
|
|
104
|
+
async reinstallSpeedKit(page, pathname) {
|
|
105
|
+
const url = new URL(page.url());
|
|
106
|
+
let target = url.href;
|
|
107
|
+
if (!pathname.includes("/speed-kit-install.html")) {
|
|
108
|
+
target = `${this.customerConfig.scope}speed-kit-install.html?url=${encodeURIComponent(target)}`;
|
|
109
|
+
}
|
|
110
|
+
this.reinstallOnNextNavigate = false;
|
|
111
|
+
await this.navigate(page, target);
|
|
109
112
|
}
|
|
110
113
|
registerFileWatcher(page) {
|
|
111
114
|
this.fileWatcher.addCallbackOnFileChange(page, async () => {
|
|
@@ -123,14 +126,10 @@ class OnboardingService {
|
|
|
123
126
|
}
|
|
124
127
|
});
|
|
125
128
|
}
|
|
126
|
-
async
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
target = `${this.customerConfig.scope}speed-kit-install.html?url=${encodeURIComponent(target)}`;
|
|
131
|
-
}
|
|
132
|
-
this.reinstallOnNextNavigate = false;
|
|
133
|
-
await this.navigate(page, target);
|
|
129
|
+
async navigate(page, pathname) {
|
|
130
|
+
const goto = new URL(pathname, `${this.browserContext.domain}`);
|
|
131
|
+
await page.goto(goto.toString());
|
|
132
|
+
await page.bringToFront();
|
|
134
133
|
}
|
|
135
134
|
}
|
|
136
135
|
exports.OnboardingService = OnboardingService;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CliService } from "../../cli";
|
|
2
1
|
import { BaqendResponse } from "../browser/baqend-response";
|
|
2
|
+
import { CliService } from "../../cli";
|
|
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;
|
|
12
10
|
getAll(): IterableIterator<[string, BaqendResponse]>;
|
|
13
11
|
getEntry(requestUri: string): BaqendResponse | void;
|
|
12
|
+
addEntry(requestUri: string, response: BaqendResponse): void;
|
|
14
13
|
removeEntry(requestUri: string): void;
|
|
14
|
+
clear(): void;
|
|
15
15
|
}
|
|
@@ -10,13 +10,6 @@ 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
|
-
}
|
|
20
13
|
getAll() {
|
|
21
14
|
return this.inMemoryCache.entries();
|
|
22
15
|
}
|
|
@@ -25,8 +18,15 @@ class Cache {
|
|
|
25
18
|
return this.inMemoryCache.get(requestUri);
|
|
26
19
|
}
|
|
27
20
|
}
|
|
21
|
+
addEntry(requestUri, response) {
|
|
22
|
+
this.inMemoryCache.set(requestUri, response);
|
|
23
|
+
}
|
|
28
24
|
removeEntry(requestUri) {
|
|
29
25
|
this.inMemoryCache.delete(requestUri);
|
|
30
26
|
}
|
|
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 safe_1 = require("../../../helpers/safe");
|
|
5
4
|
const cli_1 = require("../../cli");
|
|
5
|
+
const safe_1 = require("../../../helpers/safe");
|
|
6
6
|
class ServerConfig {
|
|
7
7
|
cli;
|
|
8
8
|
client;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { FileInterface } from "../integration-api/integration-api-model";
|
|
2
2
|
export type task = {
|
|
3
|
+
todo: string;
|
|
3
4
|
context: string;
|
|
4
5
|
file: string;
|
|
5
6
|
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[^(\r\n|\r|\n)]*)((?:\r\n|\r|\n)[^(\r\n|\r|\n)]*(?:\r\n|\r|\n)[^(\r\n|\r|\n)]*(?:\r\n|\r|\n)[^(\r\n|\r|\n)]*)/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
|
|
@@ -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,
|
|
24
25
|
context: encodeURI(taskContext),
|
|
25
26
|
file: configFile.name,
|
|
26
27
|
line: this.lineNumber(task, content),
|
|
27
|
-
todo: task,
|
|
28
28
|
});
|
|
29
29
|
return taskString;
|
|
30
30
|
});
|
|
@@ -36,8 +36,7 @@ class TodoCollector {
|
|
|
36
36
|
}
|
|
37
37
|
lineNumberByIndex(index, string) {
|
|
38
38
|
// RegExp
|
|
39
|
-
let line = 0;
|
|
40
|
-
let match;
|
|
39
|
+
let line = 0, match;
|
|
41
40
|
const re = /(^)[\S\s]/gm;
|
|
42
41
|
while ((match = re.exec(string))) {
|
|
43
42
|
if (match.index > index)
|
package/oclif.manifest.json
CHANGED