@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.
Files changed (35) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +1 -1
  3. package/dist/services/onboarding/browser/baqend-response.d.ts +3 -3
  4. package/dist/services/onboarding/browser/baqend-response.js +13 -12
  5. package/dist/services/onboarding/config-renderer/speed-kit-install-context.d.ts +4 -4
  6. package/dist/services/onboarding/config-renderer/speed-kit-install-context.js +38 -38
  7. package/dist/services/onboarding/dashboard/athena-service.d.ts +1 -1
  8. package/dist/services/onboarding/dashboard/athena-service.js +12 -12
  9. package/dist/services/onboarding/dashboard/index.d.ts +3 -3
  10. package/dist/services/onboarding/dashboard/index.js +14 -14
  11. package/dist/services/onboarding/dashboard/request-diff-service.d.ts +1 -1
  12. package/dist/services/onboarding/dashboard/request-diff-service.js +23 -23
  13. package/dist/services/onboarding/fetch-event-handler.d.ts +6 -6
  14. package/dist/services/onboarding/fetch-event-handler.js +52 -52
  15. package/dist/services/onboarding/fetch-events/customer-domain-document-response.d.ts +7 -7
  16. package/dist/services/onboarding/fetch-events/customer-domain-document-response.js +43 -43
  17. package/dist/services/onboarding/fetch-events/customer-service-worker-js.d.ts +2 -2
  18. package/dist/services/onboarding/fetch-events/customer-service-worker-js.js +4 -4
  19. package/dist/services/onboarding/fetch-events/dashboard-request.d.ts +1 -1
  20. package/dist/services/onboarding/fetch-events/dashboard-request.js +2 -2
  21. package/dist/services/onboarding/fetch-events/speed-kit-asset-request.d.ts +7 -7
  22. package/dist/services/onboarding/fetch-events/speed-kit-asset-request.js +27 -27
  23. package/dist/services/onboarding/fetch-events/speed-kit-install-html.d.ts +2 -2
  24. package/dist/services/onboarding/fetch-events/speed-kit-install-html.js +12 -12
  25. package/dist/services/onboarding/file-events/file-watcher.d.ts +9 -9
  26. package/dist/services/onboarding/file-events/file-watcher.js +67 -67
  27. package/dist/services/onboarding/onboarding-service.d.ts +6 -6
  28. package/dist/services/onboarding/onboarding-service.js +38 -39
  29. package/dist/services/onboarding/request-cache/cache.d.ts +3 -3
  30. package/dist/services/onboarding/request-cache/cache.js +7 -7
  31. package/dist/services/onboarding/server-config/index.js +1 -1
  32. package/dist/services/onboarding/todo-collector.d.ts +1 -1
  33. package/dist/services/onboarding/todo-collector.js +3 -4
  34. package/oclif.manifest.json +1 -1
  35. 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 { BrowserContext } from "./onboarding-model";
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 reinstallSpeedKit;
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 safe_1 = require("../../helpers/safe");
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
- executablePath: this.browserContext.chromePath,
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 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;
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 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);
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[^\n\r()|]*)((?:(?:\r\n|\r|\n)[^\n\r()|]*){3})/i;
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)
@@ -696,5 +696,5 @@
696
696
  ]
697
697
  }
698
698
  },
699
- "version": "2.14.0"
699
+ "version": "2.14.1"
700
700
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@speedkit/cli",
3
3
  "description": "Speed Kit CLI",
4
- "version": "2.14.0",
4
+ "version": "2.14.1",
5
5
  "author": {
6
6
  "name": "Baqend.com",
7
7
  "email": "info@baqend.com"