@speedkit/cli 4.36.2 → 4.37.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 +7 -0
- package/README.md +12 -5
- package/dist/commands/onboarding.d.ts +2 -1
- package/dist/commands/onboarding.js +2 -0
- package/dist/services/onboarding/browse/browse-service.d.ts +18 -0
- package/dist/services/onboarding/browse/browse-service.js +61 -0
- package/dist/services/onboarding/browse/browse-url.d.ts +10 -0
- package/dist/services/onboarding/browse/browse-url.js +19 -0
- package/dist/services/onboarding/browser/executable/executable-validator.js +3 -1
- package/dist/services/onboarding/browser/extension/extension-downloader.js +2 -0
- package/dist/services/onboarding/browser/launch-browser.d.ts +9 -0
- package/dist/services/onboarding/browser/launch-browser.js +20 -0
- package/dist/services/onboarding/error/browse-domain-error.d.ts +6 -0
- package/dist/services/onboarding/error/browse-domain-error.js +11 -0
- package/dist/services/onboarding/error/missing-customer-path-error.d.ts +6 -0
- package/dist/services/onboarding/error/missing-customer-path-error.js +11 -0
- package/dist/services/onboarding/onboarding-service-build-context.d.ts +5 -1
- package/dist/services/onboarding/onboarding-service-build-context.js +15 -3
- package/dist/services/onboarding/onboarding-service-factory.d.ts +29 -1
- package/dist/services/onboarding/onboarding-service-factory.js +79 -20
- package/dist/services/onboarding/onboarding-service.d.ts +2 -0
- package/dist/services/onboarding/onboarding-service.js +5 -16
- package/dist/services/onboarding/spec/browse/browse-url.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/browse/browse-url.spec.js +28 -0
- package/dist/services/onboarding/spec/onboarding-service-factory.spec.d.ts +1 -0
- package/dist/services/onboarding/spec/onboarding-service-factory.spec.js +155 -0
- package/oclif.manifest.json +155 -147
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [4.37.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v4.36.2...v4.37.0) (2026-09-30)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **onboarding:** add --browse to open the live site in the onboarding Chrome ([baa3b2e](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/baa3b2e2bfb6215df5cf7791c0d6a6696ce3aafe))
|
|
7
|
+
|
|
1
8
|
## [4.36.2](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v4.36.1...v4.36.2) (2026-09-25)
|
|
2
9
|
|
|
3
10
|
|
package/README.md
CHANGED
|
@@ -88,7 +88,7 @@ By either...
|
|
|
88
88
|
* [`sk generate-pop-config APP`](#sk-generate-pop-config-app)
|
|
89
89
|
* [`sk help [COMMAND]`](#sk-help-command)
|
|
90
90
|
* [`sk login [APP]`](#sk-login-app)
|
|
91
|
-
* [`sk onboarding CUSTOMERPATH`](#sk-onboarding-customerpath)
|
|
91
|
+
* [`sk onboarding [CUSTOMERPATH]`](#sk-onboarding-customerpath)
|
|
92
92
|
* [`sk origin-request CUSTOMERPATH PAGEURL`](#sk-origin-request-customerpath-pageurl)
|
|
93
93
|
* [`sk param-diff PAGEURL`](#sk-param-diff-pageurl)
|
|
94
94
|
* [`sk prewarm APP PATH`](#sk-prewarm-app-path)
|
|
@@ -712,17 +712,17 @@ EXAMPLES
|
|
|
712
712
|
$ sk login appName
|
|
713
713
|
```
|
|
714
714
|
|
|
715
|
-
## `sk onboarding CUSTOMERPATH`
|
|
715
|
+
## `sk onboarding [CUSTOMERPATH]`
|
|
716
716
|
|
|
717
717
|
Start a local dev environment for building and testing the Speed Kit configuration
|
|
718
718
|
|
|
719
719
|
```
|
|
720
720
|
USAGE
|
|
721
|
-
$ sk onboarding CUSTOMERPATH [-c <value>] [-t] [-d <value>] [-l] [-p] [--debugPort <value>] [-v] [-s]
|
|
722
|
-
[--headless] [--browserFetch]
|
|
721
|
+
$ sk onboarding [CUSTOMERPATH] [-c <value>] [-t] [-d <value>] [-l] [-p] [--debugPort <value>] [-v] [-s]
|
|
722
|
+
[--headless] [--browse] [--browserFetch]
|
|
723
723
|
|
|
724
724
|
ARGUMENTS
|
|
725
|
-
CUSTOMERPATH The customer config path
|
|
725
|
+
[CUSTOMERPATH] The customer config path (optional with --browse)
|
|
726
726
|
|
|
727
727
|
FLAGS
|
|
728
728
|
-c, --configName=<value> [default: production] The costumer config name
|
|
@@ -732,6 +732,9 @@ FLAGS
|
|
|
732
732
|
-s, --ignoreContentSecurityPolicy Removes header/meta "content-security-policy" for origin-responses
|
|
733
733
|
-t, --useTestConfig Override app with configured testApp
|
|
734
734
|
-v, --verboseLevel Show all messages
|
|
735
|
+
--browse Open the live site in the onboarding Chrome, with its extensions, but without
|
|
736
|
+
request interception or Speed Kit injection. Takes the domain from -d or from the
|
|
737
|
+
customer config.
|
|
735
738
|
--browserFetch Fetch every origin document with a second headless Chrome instead of a direct
|
|
736
739
|
request. Only needed when bot protection refuses the CLI outright — a refusal is
|
|
737
740
|
otherwise detected and rerouted on its own.
|
|
@@ -747,6 +750,10 @@ EXAMPLES
|
|
|
747
750
|
$ sk onboarding <customerPath> -c <configName> -d <domain>
|
|
748
751
|
|
|
749
752
|
$ sk onboarding customers/decathlon.de -c production -d www.decathlon.de
|
|
753
|
+
|
|
754
|
+
$ sk onboarding --browse -d www.decathlon.de --headless --debugPort 9290
|
|
755
|
+
|
|
756
|
+
$ sk onboarding customers/decathlon.de --browse -p
|
|
750
757
|
```
|
|
751
758
|
|
|
752
759
|
## `sk origin-request CUSTOMERPATH PAGEURL`
|
|
@@ -16,12 +16,13 @@ export default class Onboarding extends SkCommand<OnboardingServiceBuildContext>
|
|
|
16
16
|
verboseLevel: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
17
17
|
ignoreContentSecurityPolicy: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
18
18
|
headless: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
19
|
+
browse: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
19
20
|
browserFetch: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
20
21
|
useTestConfig: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
21
22
|
configName: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
22
23
|
};
|
|
23
24
|
static examples: string[];
|
|
24
25
|
/** Onboarding runs the customer's documentHandler, with its node modules. */
|
|
25
|
-
protected customerPathForModules(args: Record<string, unknown>): string;
|
|
26
|
+
protected customerPathForModules(args: Record<string, unknown>): string | undefined;
|
|
26
27
|
run(): Promise<void>;
|
|
27
28
|
}
|
|
@@ -8,6 +8,8 @@ export default class Onboarding extends SkCommand {
|
|
|
8
8
|
static examples = [
|
|
9
9
|
`$ sk onboarding <customerPath> -c <configName> -d <domain>`,
|
|
10
10
|
`$ sk onboarding customers/decathlon.de -c production -d www.decathlon.de`,
|
|
11
|
+
`$ sk onboarding --browse -d www.decathlon.de --headless --debugPort 9290`,
|
|
12
|
+
`$ sk onboarding customers/decathlon.de --browse -p`,
|
|
11
13
|
];
|
|
12
14
|
/** Onboarding runs the customer's documentHandler, with its node modules. */
|
|
13
15
|
customerPathForModules(args) {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CliServiceInterface } from "../../cli/index.js";
|
|
2
|
+
import { BrowserContext } from "../onboarding-model.js";
|
|
3
|
+
/**
|
|
4
|
+
* `sk onboarding --browse`: the onboarding Chrome on the live site, as a visitor gets it.
|
|
5
|
+
*
|
|
6
|
+
* It launches the same Chrome as onboarding, with the same flags, profile and extensions. It
|
|
7
|
+
* installs no request interception, serves no local files and injects no Speed Kit, so a site that
|
|
8
|
+
* runs Speed Kit in production runs its own deployed build.
|
|
9
|
+
*/
|
|
10
|
+
export declare class BrowseService {
|
|
11
|
+
private readonly browserContext;
|
|
12
|
+
private readonly cli;
|
|
13
|
+
constructor(browserContext: BrowserContext, cli: CliServiceInterface);
|
|
14
|
+
/** Opens the site, then blocks until the caller aborts `externalSignal` or Chrome disconnects. */
|
|
15
|
+
run(externalSignal: AbortSignal): Promise<void>;
|
|
16
|
+
private readyLine;
|
|
17
|
+
private findPage;
|
|
18
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { safe } from "../../../helpers/safe.js";
|
|
2
|
+
import { launchBrowser, resetBrowserState } from "../browser/launch-browser.js";
|
|
3
|
+
import { BROWSER_EVENTS } from "../onboarding-model.js";
|
|
4
|
+
import { waitForAbort } from "../onboarding-service.js";
|
|
5
|
+
/**
|
|
6
|
+
* `sk onboarding --browse`: the onboarding Chrome on the live site, as a visitor gets it.
|
|
7
|
+
*
|
|
8
|
+
* It launches the same Chrome as onboarding, with the same flags, profile and extensions. It
|
|
9
|
+
* installs no request interception, serves no local files and injects no Speed Kit, so a site that
|
|
10
|
+
* runs Speed Kit in production runs its own deployed build.
|
|
11
|
+
*/
|
|
12
|
+
export class BrowseService {
|
|
13
|
+
browserContext;
|
|
14
|
+
cli;
|
|
15
|
+
constructor(browserContext, cli) {
|
|
16
|
+
this.browserContext = browserContext;
|
|
17
|
+
this.cli = cli;
|
|
18
|
+
}
|
|
19
|
+
/** Opens the site, then blocks until the caller aborts `externalSignal` or Chrome disconnects. */
|
|
20
|
+
async run(externalSignal) {
|
|
21
|
+
this.cli.startAction("ONBOARDING:BROWSE:BROWSER", `prepare browser ${this.cli.style.bold(this.browserContext.browserVersionString)}`);
|
|
22
|
+
const disconnected = new AbortController();
|
|
23
|
+
const shutdownSignal = AbortSignal.any([
|
|
24
|
+
externalSignal,
|
|
25
|
+
disconnected.signal,
|
|
26
|
+
]);
|
|
27
|
+
const browser = await launchBrowser(this.browserContext);
|
|
28
|
+
browser.on(BROWSER_EVENTS.DISCONNECTED, () => {
|
|
29
|
+
this.cli.writeError("Browser disconnected, shutting down");
|
|
30
|
+
disconnected.abort();
|
|
31
|
+
});
|
|
32
|
+
const page = await this.findPage(browser);
|
|
33
|
+
const url = this.browserContext.domain;
|
|
34
|
+
const reset = await safe(page
|
|
35
|
+
.target()
|
|
36
|
+
.createCDPSession()
|
|
37
|
+
.then((session) => resetBrowserState(session, new URL(url).origin)));
|
|
38
|
+
if (reset.success !== true) {
|
|
39
|
+
this.cli.writeWarning(`Could not reset the browser state: ${reset.error}`);
|
|
40
|
+
}
|
|
41
|
+
this.cli.successAction("ONBOARDING:BROWSE:BROWSER");
|
|
42
|
+
const navigation = await safe(page.goto(url));
|
|
43
|
+
if (navigation.success !== true) {
|
|
44
|
+
this.cli.writeWarning(`Could not open ${url}: ${navigation.error}`);
|
|
45
|
+
}
|
|
46
|
+
this.cli.writeSuccess(this.readyLine(url));
|
|
47
|
+
await waitForAbort(shutdownSignal);
|
|
48
|
+
await safe(browser.close());
|
|
49
|
+
}
|
|
50
|
+
readyLine(url) {
|
|
51
|
+
const { debuggingPort, headless, debugPort } = this.browserContext;
|
|
52
|
+
const cdp = debuggingPort || headless
|
|
53
|
+
? `CDP on http://127.0.0.1:${debugPort}`
|
|
54
|
+
: "no CDP port, pass -p or --headless to expose one";
|
|
55
|
+
return `Browsing ${url} live, without interception or Speed Kit injection; ${cdp}. Press Ctrl+C to stop.`;
|
|
56
|
+
}
|
|
57
|
+
async findPage(browser) {
|
|
58
|
+
const [page] = await browser.pages();
|
|
59
|
+
return page ?? browser.newPage();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CustomerConfig } from "../../integration-api/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* The URL that browse mode opens.
|
|
4
|
+
*
|
|
5
|
+
* The `--domain` flag wins. Without it, the customer config supplies its `domain`, else its first
|
|
6
|
+
* origin: browse mode never prompts, so it cannot ask which origin to take.
|
|
7
|
+
*
|
|
8
|
+
* @throws {BrowseDomainError} When neither the flag nor a customer config names a domain.
|
|
9
|
+
*/
|
|
10
|
+
export declare function resolveBrowseUrl(domain?: string, customerConfig?: Pick<CustomerConfig, "domain" | "origins">): string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BrowseDomainError } from "../error/browse-domain-error.js";
|
|
2
|
+
/**
|
|
3
|
+
* The URL that browse mode opens.
|
|
4
|
+
*
|
|
5
|
+
* The `--domain` flag wins. Without it, the customer config supplies its `domain`, else its first
|
|
6
|
+
* origin: browse mode never prompts, so it cannot ask which origin to take.
|
|
7
|
+
*
|
|
8
|
+
* @throws {BrowseDomainError} When neither the flag nor a customer config names a domain.
|
|
9
|
+
*/
|
|
10
|
+
export function resolveBrowseUrl(domain, customerConfig) {
|
|
11
|
+
const candidate = domain || customerConfig?.domain || customerConfig?.origins?.[0];
|
|
12
|
+
if (!candidate) {
|
|
13
|
+
throw new BrowseDomainError();
|
|
14
|
+
}
|
|
15
|
+
const url = /^https?:\/\//i.test(candidate)
|
|
16
|
+
? candidate
|
|
17
|
+
: `https://${candidate}`;
|
|
18
|
+
return new URL(url).href;
|
|
19
|
+
}
|
|
@@ -35,7 +35,9 @@ export class ExecutableValidator {
|
|
|
35
35
|
this.cli.writeWarning(`No Browser configured`);
|
|
36
36
|
}
|
|
37
37
|
// ask if you want to download stable chrome
|
|
38
|
-
|
|
38
|
+
// Without a TTY a prompt never gets an answer and ends the process, so take its default: download.
|
|
39
|
+
const result = this.cli.nonInteractive ||
|
|
40
|
+
(await this.cli.confirm("Do you want to download Chrome@latest via puppeteer?", true));
|
|
39
41
|
// @todo set more detailed error message here.
|
|
40
42
|
if (!result) {
|
|
41
43
|
throw new ApplicationError("No Browser found to use", [
|
|
@@ -24,6 +24,8 @@ export class ExtensionDownloader {
|
|
|
24
24
|
* update is declined or its download breaks.
|
|
25
25
|
*/
|
|
26
26
|
async installOrUpdate({ confirm = true, force = false, } = {}) {
|
|
27
|
+
// Without a TTY a prompt never gets an answer and ends the process, so take its default: install.
|
|
28
|
+
confirm = confirm && !this.cli.nonInteractive;
|
|
27
29
|
// check for already installed devExtension
|
|
28
30
|
const localVersion = this.getInstalledVersion();
|
|
29
31
|
const installed = { path: this.installedPath, version: localVersion };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Browser, CDPSession } from "puppeteer";
|
|
2
|
+
import { BrowserContext } from "../onboarding-model.js";
|
|
3
|
+
/** Launches the onboarding Chrome. Onboarding and browse mode share it, so their hardening cannot drift. */
|
|
4
|
+
export declare function launchBrowser(browserContext: BrowserContext): Promise<Browser>;
|
|
5
|
+
/**
|
|
6
|
+
* Starts from a clean state for `origin`: no service worker, no cookies, no stored data, no
|
|
7
|
+
* emulation left over from an earlier session on the same profile.
|
|
8
|
+
*/
|
|
9
|
+
export declare function resetBrowserState(cdpSession: CDPSession, origin: string): Promise<void>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import puppeteerExtra from "puppeteer-extra";
|
|
2
|
+
/** Launches the onboarding Chrome. Onboarding and browse mode share it, so their hardening cannot drift. */
|
|
3
|
+
export function launchBrowser(browserContext) {
|
|
4
|
+
return puppeteerExtra.default.launch(browserContext.getPuppeteerLaunchOptions());
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Starts from a clean state for `origin`: no service worker, no cookies, no stored data, no
|
|
8
|
+
* emulation left over from an earlier session on the same profile.
|
|
9
|
+
*/
|
|
10
|
+
export async function resetBrowserState(cdpSession, origin) {
|
|
11
|
+
await cdpSession.send("ServiceWorker.enable");
|
|
12
|
+
await cdpSession.send("ServiceWorker.unregister", { scopeURL: origin });
|
|
13
|
+
await cdpSession.send("Storage.clearCookies");
|
|
14
|
+
await cdpSession.send("Storage.clearDataForOrigin", {
|
|
15
|
+
origin,
|
|
16
|
+
storageTypes: "all",
|
|
17
|
+
});
|
|
18
|
+
await cdpSession.send("Emulation.clearDeviceMetricsOverride");
|
|
19
|
+
await cdpSession.send("Emulation.clearGeolocationOverride");
|
|
20
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import ApplicationError from "../../error-handling/error/application-error.js";
|
|
2
|
+
/** `sk onboarding --browse` has neither a `--domain` nor a customer config to take a domain from. */
|
|
3
|
+
export declare class BrowseDomainError extends ApplicationError {
|
|
4
|
+
readonly code = "BROWSE_DOMAIN_ERROR";
|
|
5
|
+
constructor();
|
|
6
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import ApplicationError from "../../error-handling/error/application-error.js";
|
|
2
|
+
/** `sk onboarding --browse` has neither a `--domain` nor a customer config to take a domain from. */
|
|
3
|
+
export class BrowseDomainError extends ApplicationError {
|
|
4
|
+
code = "BROWSE_DOMAIN_ERROR";
|
|
5
|
+
constructor() {
|
|
6
|
+
super("Browse mode needs a domain to open.", [
|
|
7
|
+
"pass one with -d/--domain, e.g. `sk onboarding --browse -d www.example.com`",
|
|
8
|
+
"or pass a CUSTOMERPATH whose config_customer.json names a domain",
|
|
9
|
+
]);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import ApplicationError from "../../error-handling/error/application-error.js";
|
|
2
|
+
/** `sk onboarding` without `--browse` runs a customer config, so it needs its directory. */
|
|
3
|
+
export declare class MissingCustomerPathError extends ApplicationError {
|
|
4
|
+
readonly code = "MISSING_CUSTOMER_PATH";
|
|
5
|
+
constructor();
|
|
6
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import ApplicationError from "../../error-handling/error/application-error.js";
|
|
2
|
+
/** `sk onboarding` without `--browse` runs a customer config, so it needs its directory. */
|
|
3
|
+
export class MissingCustomerPathError extends ApplicationError {
|
|
4
|
+
code = "MISSING_CUSTOMER_PATH";
|
|
5
|
+
constructor() {
|
|
6
|
+
super("Missing CUSTOMERPATH: onboarding needs a customer config.", [
|
|
7
|
+
"pass the customer directory, e.g. `sk onboarding customers/example-shop`",
|
|
8
|
+
"or add --browse to open the live site without a config",
|
|
9
|
+
]);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -13,12 +13,14 @@ declare const flags: {
|
|
|
13
13
|
verboseLevel: Interfaces.BooleanFlag<boolean>;
|
|
14
14
|
ignoreContentSecurityPolicy: Interfaces.BooleanFlag<boolean>;
|
|
15
15
|
headless: Interfaces.BooleanFlag<boolean>;
|
|
16
|
+
browse: Interfaces.BooleanFlag<boolean>;
|
|
16
17
|
browserFetch: Interfaces.BooleanFlag<boolean>;
|
|
17
18
|
useTestConfig: Interfaces.BooleanFlag<boolean>;
|
|
18
19
|
configName: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
|
|
19
20
|
};
|
|
20
21
|
export interface OnboardingServiceBuildContextValues extends CommandContextValues {
|
|
21
|
-
|
|
22
|
+
/** Missing only in browse mode. */
|
|
23
|
+
readonly customerPath?: string;
|
|
22
24
|
readonly configName: string;
|
|
23
25
|
readonly domain?: string;
|
|
24
26
|
readonly local: boolean;
|
|
@@ -31,6 +33,7 @@ export interface OnboardingServiceBuildContextValues extends CommandContextValue
|
|
|
31
33
|
readonly headless: boolean;
|
|
32
34
|
readonly debugPort: number;
|
|
33
35
|
readonly browserFetch: boolean;
|
|
36
|
+
readonly browse: boolean;
|
|
34
37
|
}
|
|
35
38
|
declare const OnboardingServiceBuildContext_base: new (values: OnboardingServiceBuildContextValues) => Readonly<OnboardingServiceBuildContextValues>;
|
|
36
39
|
/** What `sk onboarding` starts: a local Speed Kit dev environment for one customer. */
|
|
@@ -48,6 +51,7 @@ export declare class OnboardingServiceBuildContext extends OnboardingServiceBuil
|
|
|
48
51
|
verboseLevel: Interfaces.BooleanFlag<boolean>;
|
|
49
52
|
ignoreContentSecurityPolicy: Interfaces.BooleanFlag<boolean>;
|
|
50
53
|
headless: Interfaces.BooleanFlag<boolean>;
|
|
54
|
+
browse: Interfaces.BooleanFlag<boolean>;
|
|
51
55
|
browserFetch: Interfaces.BooleanFlag<boolean>;
|
|
52
56
|
useTestConfig: Interfaces.BooleanFlag<boolean>;
|
|
53
57
|
configName: Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
import { Flags } from "@oclif/core";
|
|
2
|
-
import { CLI_CONFIG_IS_TEST, CLI_CONFIG_NAME,
|
|
1
|
+
import { Args, Flags } from "@oclif/core";
|
|
2
|
+
import { CLI_CONFIG_IS_TEST, CLI_CONFIG_NAME, } from "../integration-api/customer-config-flags.js";
|
|
3
3
|
import { Context } from "../../models/context.js";
|
|
4
|
-
const args = {
|
|
4
|
+
const args = {
|
|
5
|
+
// Optional for `--browse`, which analyses a site before its config exists; the factory requires it otherwise.
|
|
6
|
+
customerPath: Args.directory({
|
|
7
|
+
name: "customerPath",
|
|
8
|
+
required: false,
|
|
9
|
+
description: "The customer config path (optional with --browse)",
|
|
10
|
+
}),
|
|
11
|
+
};
|
|
5
12
|
const flags = {
|
|
6
13
|
...CLI_CONFIG_NAME,
|
|
7
14
|
...CLI_CONFIG_IS_TEST,
|
|
@@ -37,6 +44,10 @@ const flags = {
|
|
|
37
44
|
default: false,
|
|
38
45
|
description: "Run Chrome in headless mode (for CI environments). Implicitly enables remote debugging port.",
|
|
39
46
|
}),
|
|
47
|
+
browse: Flags.boolean({
|
|
48
|
+
default: false,
|
|
49
|
+
description: "Open the live site in the onboarding Chrome, with its extensions, but without request interception or Speed Kit injection. Takes the domain from -d or from the customer config.",
|
|
50
|
+
}),
|
|
40
51
|
browserFetch: Flags.boolean({
|
|
41
52
|
default: false,
|
|
42
53
|
description: "Fetch every origin document with a second headless Chrome instead of a direct request. Only needed when bot protection refuses the CLI outright — a refusal is otherwise detected and rerouted on its own.",
|
|
@@ -61,6 +72,7 @@ export class OnboardingServiceBuildContext extends Context() {
|
|
|
61
72
|
headless: parsedFlags.headless,
|
|
62
73
|
debugPort: parsedFlags.debugPort,
|
|
63
74
|
browserFetch: parsedFlags.browserFetch,
|
|
75
|
+
browse: parsedFlags.browse,
|
|
64
76
|
});
|
|
65
77
|
}
|
|
66
78
|
}
|
|
@@ -1,9 +1,37 @@
|
|
|
1
1
|
import { OnboardingServiceBuildContext } from "./onboarding-service-build-context.js";
|
|
2
|
+
import { BrowserContext } from "./onboarding-model.js";
|
|
2
3
|
import { OnboardingService } from "./onboarding-service.js";
|
|
4
|
+
import { BrowseService } from "./browse/browse-service.js";
|
|
5
|
+
import { BrowserExtensions } from "./browser/extension/extension-validator.js";
|
|
3
6
|
export declare class OnboardingServiceFactory {
|
|
4
7
|
private readonly context;
|
|
5
8
|
constructor(context: OnboardingServiceBuildContext);
|
|
6
|
-
|
|
9
|
+
/**
|
|
10
|
+
* The service `sk onboarding` runs: the browse service under `--browse`, the onboarding service
|
|
11
|
+
* otherwise.
|
|
12
|
+
*
|
|
13
|
+
* @throws {MissingCustomerPathError} Without `--browse` and without a CUSTOMERPATH.
|
|
14
|
+
*/
|
|
15
|
+
getService(): Promise<OnboardingService | BrowseService>;
|
|
16
|
+
/** The live site in the onboarding Chrome: the same launch, none of the interception. */
|
|
17
|
+
private getBrowseService;
|
|
18
|
+
/** Only config_customer.json: browse mode reads its domain and chromeFlags, nothing else. */
|
|
19
|
+
private readCustomerConfig;
|
|
20
|
+
/**
|
|
21
|
+
* Resolves the extensions and the Chrome executable, then builds the launch. Onboarding and
|
|
22
|
+
* browse mode both come through here, so they launch the same Chrome.
|
|
23
|
+
*/
|
|
24
|
+
protected prepareBrowser(domain: string, customerChromeFlags?: string[]): Promise<{
|
|
25
|
+
browserContext: BrowserContext;
|
|
26
|
+
browserExtensions: BrowserExtensions;
|
|
27
|
+
}>;
|
|
28
|
+
/** The launch for `domain`. It reads no mode of the build context, so browse mode cannot drift from onboarding. */
|
|
29
|
+
buildBrowserContext({ domain, browserVersionString, customerChromeFlags, }: {
|
|
30
|
+
domain: string;
|
|
31
|
+
browserVersionString: string;
|
|
32
|
+
customerChromeFlags?: string[];
|
|
33
|
+
}): BrowserContext;
|
|
34
|
+
private getOnboardingService;
|
|
7
35
|
private prepareMessagehandler;
|
|
8
36
|
private getAppToken;
|
|
9
37
|
private buildInstallResource;
|
|
@@ -23,10 +23,13 @@ import { SpeedKitServiceWorkerJs } from "./fetch-events/speed-kit-service-worker
|
|
|
23
23
|
import { FileWatcher } from "./file-events/file-watcher.js";
|
|
24
24
|
import { BrowserContext, } from "./onboarding-model.js";
|
|
25
25
|
import { OnboardingService } from "./onboarding-service.js";
|
|
26
|
+
import { BrowseService } from "./browse/browse-service.js";
|
|
27
|
+
import { resolveBrowseUrl } from "./browse/browse-url.js";
|
|
28
|
+
import { MissingCustomerPathError } from "./error/missing-customer-path-error.js";
|
|
26
29
|
import { Cache } from "./request-cache/cache.js";
|
|
27
30
|
import { InstallSpeedKitHtmlTemplate } from "./templates/install-speed-kit-html-template.js";
|
|
28
31
|
import { InstallSpeedKitJsTemplate } from "./templates/install-speed-kit-js-template.js";
|
|
29
|
-
import { ExtensionValidator } from "./browser/extension/extension-validator.js";
|
|
32
|
+
import { ExtensionValidator, } from "./browser/extension/extension-validator.js";
|
|
30
33
|
import { DevtoolsExtensionApi } from "./browser/extension/devtools-extension-api.js";
|
|
31
34
|
import { ExtensionBridge } from "./browser/extension/extension-bridge.js";
|
|
32
35
|
import { TodoCollector } from "./todo-collector.js";
|
|
@@ -50,7 +53,81 @@ export class OnboardingServiceFactory {
|
|
|
50
53
|
constructor(context) {
|
|
51
54
|
this.context = context;
|
|
52
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* The service `sk onboarding` runs: the browse service under `--browse`, the onboarding service
|
|
58
|
+
* otherwise.
|
|
59
|
+
*
|
|
60
|
+
* @throws {MissingCustomerPathError} Without `--browse` and without a CUSTOMERPATH.
|
|
61
|
+
*/
|
|
53
62
|
async getService() {
|
|
63
|
+
if (this.context.browse) {
|
|
64
|
+
return this.getBrowseService();
|
|
65
|
+
}
|
|
66
|
+
if (!this.context.customerPath) {
|
|
67
|
+
throw new MissingCustomerPathError();
|
|
68
|
+
}
|
|
69
|
+
return this.getOnboardingService();
|
|
70
|
+
}
|
|
71
|
+
/** The live site in the onboarding Chrome: the same launch, none of the interception. */
|
|
72
|
+
async getBrowseService() {
|
|
73
|
+
const cli = this.context.environment.cli;
|
|
74
|
+
const customerConfig = this.context.customerPath
|
|
75
|
+
? await this.readCustomerConfig()
|
|
76
|
+
: undefined;
|
|
77
|
+
applyOriginProxy(customerConfig?.chromeFlags, cli);
|
|
78
|
+
const url = resolveBrowseUrl(this.context.domain, customerConfig);
|
|
79
|
+
const { browserContext } = await this.prepareBrowser(url, customerConfig?.chromeFlags);
|
|
80
|
+
return new BrowseService(browserContext, cli);
|
|
81
|
+
}
|
|
82
|
+
/** Only config_customer.json: browse mode reads its domain and chromeFlags, nothing else. */
|
|
83
|
+
async readCustomerConfig() {
|
|
84
|
+
const integrationApi = new IntegrationApiFactory(new IntegrationApiServiceBuildContext({
|
|
85
|
+
environment: this.context.environment,
|
|
86
|
+
basePath: this.context.customerPath,
|
|
87
|
+
configName: this.context.configName,
|
|
88
|
+
whitelist: [INTEGRATION_FILES.CONFIG.CUSTOMER],
|
|
89
|
+
blockedFolders: [],
|
|
90
|
+
useTestConfig: this.context.useTestConfig,
|
|
91
|
+
})).buildService();
|
|
92
|
+
const files = await integrationApi.run();
|
|
93
|
+
return files.getCustomerConfig().config;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Resolves the extensions and the Chrome executable, then builds the launch. Onboarding and
|
|
97
|
+
* browse mode both come through here, so they launch the same Chrome.
|
|
98
|
+
*/
|
|
99
|
+
async prepareBrowser(domain, customerChromeFlags) {
|
|
100
|
+
const cli = this.context.environment.cli;
|
|
101
|
+
const extensionDownloader = new ExtensionDownloader(this.context.environment, cli);
|
|
102
|
+
const browserExtensions = await new ExtensionValidator(extensionDownloader, this.context.environment, cli).getValidBrowserExtensions();
|
|
103
|
+
this.context.environment.settings.chromeExtensionPaths =
|
|
104
|
+
browserExtensions.paths.join(",");
|
|
105
|
+
const browserValidator = new ExecutableValidator(this.context.environment, cli);
|
|
106
|
+
const browserVersionString = await browserValidator.validateOrInstall();
|
|
107
|
+
const browserContext = this.buildBrowserContext({
|
|
108
|
+
domain,
|
|
109
|
+
browserVersionString,
|
|
110
|
+
customerChromeFlags,
|
|
111
|
+
});
|
|
112
|
+
for (const duplicate of browserContext.findDuplicateFlags()) {
|
|
113
|
+
cli.writeWarning(formatChromeFlagDuplicate(duplicate));
|
|
114
|
+
}
|
|
115
|
+
for (const finding of browserContext.findFeatureFindings()) {
|
|
116
|
+
cli.writeWarning(formatChromeFeatureFinding(finding));
|
|
117
|
+
}
|
|
118
|
+
if (this.context.debuggingPort || this.context.headless) {
|
|
119
|
+
cli.writeWarning(`Chrome remote debugging enabled on port ${this.context.debugPort}.`);
|
|
120
|
+
}
|
|
121
|
+
if (this.context.headless) {
|
|
122
|
+
cli.writeWarning("Running in headless mode.");
|
|
123
|
+
}
|
|
124
|
+
return { browserContext, browserExtensions };
|
|
125
|
+
}
|
|
126
|
+
/** The launch for `domain`. It reads no mode of the build context, so browse mode cannot drift from onboarding. */
|
|
127
|
+
buildBrowserContext({ domain, browserVersionString, customerChromeFlags, }) {
|
|
128
|
+
return new BrowserContext(domain, browserVersionString, withOriginProxyFlag(customerChromeFlags), this.context.environment, undefined, this.context.debuggingPort, this.context.headless, this.context.debugPort);
|
|
129
|
+
}
|
|
130
|
+
async getOnboardingService() {
|
|
54
131
|
const cli = this.context.environment.cli;
|
|
55
132
|
const files = await this.getIntegrationFiles(cli);
|
|
56
133
|
const customerConfig = files.getCustomerConfig().config;
|
|
@@ -78,25 +155,7 @@ export class OnboardingServiceFactory {
|
|
|
78
155
|
const skTemplate = new InstallSpeedKitJsTemplate();
|
|
79
156
|
const speedKitInstallContext = new SpeedKitInstallContext(customerConfig, this.context.configName, files, bundler, skTemplate, this.context.local);
|
|
80
157
|
await this.buildInstallResource(speedKitInstallContext, files, cli);
|
|
81
|
-
const
|
|
82
|
-
const browserExtensions = await new ExtensionValidator(extensionDownloader, this.context.environment, cli).getValidBrowserExtensions();
|
|
83
|
-
this.context.environment.settings.chromeExtensionPaths =
|
|
84
|
-
browserExtensions.paths.join(",");
|
|
85
|
-
const browserValidator = new ExecutableValidator(this.context.environment, cli);
|
|
86
|
-
const browserVersionString = await browserValidator.validateOrInstall();
|
|
87
|
-
const browserContext = new BrowserContext(domainToStart, browserVersionString, withOriginProxyFlag(customerConfig.chromeFlags), this.context.environment, undefined, this.context.debuggingPort, this.context.headless, this.context.debugPort);
|
|
88
|
-
for (const duplicate of browserContext.findDuplicateFlags()) {
|
|
89
|
-
cli.writeWarning(formatChromeFlagDuplicate(duplicate));
|
|
90
|
-
}
|
|
91
|
-
for (const finding of browserContext.findFeatureFindings()) {
|
|
92
|
-
cli.writeWarning(formatChromeFeatureFinding(finding));
|
|
93
|
-
}
|
|
94
|
-
if (this.context.debuggingPort || this.context.headless) {
|
|
95
|
-
cli.writeWarning(`Chrome remote debugging enabled on port ${this.context.debugPort}.`);
|
|
96
|
-
}
|
|
97
|
-
if (this.context.headless) {
|
|
98
|
-
cli.writeWarning("Running in headless mode.");
|
|
99
|
-
}
|
|
158
|
+
const { browserContext, browserExtensions } = await this.prepareBrowser(domainToStart, customerConfig.chromeFlags);
|
|
100
159
|
const fileWatcher = new FileWatcher(cli, customerConfig, files, documentHandler, browserContext, cache);
|
|
101
160
|
const athenaClient = (await this.getAthenaClient(customerConfig.app)) || null;
|
|
102
161
|
const messageHandler = await this.prepareMessagehandler(athenaClient, files, customerConfig);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import puppeteerExtra from "puppeteer-extra";
|
|
2
1
|
import { BROWSER_EVENTS, CDP_SESSION, } from "./onboarding-model.js";
|
|
3
2
|
import { safe } from "../../helpers/safe.js";
|
|
4
3
|
import { isEmptyServiceWorkerUrl } from "./empty-service-worker.js";
|
|
4
|
+
import { launchBrowser, resetBrowserState } from "./browser/launch-browser.js";
|
|
5
5
|
// A SW version activating later than this after the last locally served sw.js
|
|
6
6
|
// cannot originate from our interception — it is a deployed-build takeover.
|
|
7
7
|
const LOCAL_SW_SERVE_GRACE_MS = 10_000;
|
|
@@ -60,7 +60,7 @@ export class OnboardingService {
|
|
|
60
60
|
await safe(this.browserFetch.close());
|
|
61
61
|
}
|
|
62
62
|
async prepareBrowser(localController) {
|
|
63
|
-
const browser = await
|
|
63
|
+
const browser = await launchBrowser(this.browserContext);
|
|
64
64
|
for (const target of browser.targets()) {
|
|
65
65
|
if (target.type() === "browser") {
|
|
66
66
|
await this.fetchEventHandler.handleRequestFetchEvents(target);
|
|
@@ -109,19 +109,7 @@ export class OnboardingService {
|
|
|
109
109
|
}
|
|
110
110
|
async prepareCleanState(page) {
|
|
111
111
|
const cdpSession = await page.target().createCDPSession();
|
|
112
|
-
|
|
113
|
-
await cdpSession.send("ServiceWorker.enable");
|
|
114
|
-
await cdpSession.send("ServiceWorker.unregister", {
|
|
115
|
-
scopeURL: this.browserContext.domain,
|
|
116
|
-
});
|
|
117
|
-
// clear storage for a clean start
|
|
118
|
-
await cdpSession.send("Storage.clearCookies");
|
|
119
|
-
await cdpSession.send("Storage.clearDataForOrigin", {
|
|
120
|
-
origin: this.browserContext.domain,
|
|
121
|
-
storageTypes: "all",
|
|
122
|
-
});
|
|
123
|
-
await cdpSession.send("Emulation.clearDeviceMetricsOverride");
|
|
124
|
-
await cdpSession.send("Emulation.clearGeolocationOverride");
|
|
112
|
+
await resetBrowserState(cdpSession, this.browserContext.domain);
|
|
125
113
|
this.registerForeignSwGuard(page, cdpSession);
|
|
126
114
|
safe(() => {
|
|
127
115
|
cdpSession.on(CDP_SESSION.EVENTS.SERVICE_WORKER.REGISTRATION_UPDATED, ({ registrations, }) => {
|
|
@@ -226,7 +214,8 @@ export class OnboardingService {
|
|
|
226
214
|
await safe(page.goto(goto.toString()));
|
|
227
215
|
}
|
|
228
216
|
}
|
|
229
|
-
|
|
217
|
+
/** Resolves once `signal` aborts. */
|
|
218
|
+
export function waitForAbort(signal) {
|
|
230
219
|
if (signal.aborted) {
|
|
231
220
|
return Promise.resolve();
|
|
232
221
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { describe, it } from "mocha";
|
|
3
|
+
import { resolveBrowseUrl } from "../../browse/browse-url.js";
|
|
4
|
+
import { BrowseDomainError } from "../../error/browse-domain-error.js";
|
|
5
|
+
describe("resolveBrowseUrl", () => {
|
|
6
|
+
const customerConfig = {
|
|
7
|
+
domain: "www.example.com",
|
|
8
|
+
origins: ["https://www.example.com", "https://shop.example.com"],
|
|
9
|
+
};
|
|
10
|
+
it("takes the --domain flag over the customer config", () => {
|
|
11
|
+
expect(resolveBrowseUrl("other.example.com", customerConfig)).to.equal("https://other.example.com/");
|
|
12
|
+
});
|
|
13
|
+
it("takes the domain of the customer config without a flag", () => {
|
|
14
|
+
expect(resolveBrowseUrl(undefined, customerConfig)).to.equal("https://www.example.com/");
|
|
15
|
+
});
|
|
16
|
+
it("falls back to the first origin when the config names no domain", () => {
|
|
17
|
+
expect(resolveBrowseUrl(undefined, {
|
|
18
|
+
domain: undefined,
|
|
19
|
+
origins: ["https://shop.example.com"],
|
|
20
|
+
})).to.equal("https://shop.example.com/");
|
|
21
|
+
});
|
|
22
|
+
it("keeps an explicit scheme and path", () => {
|
|
23
|
+
expect(resolveBrowseUrl("http://example.com/de/")).to.equal("http://example.com/de/");
|
|
24
|
+
});
|
|
25
|
+
it("fails without a flag and without a customer config", () => {
|
|
26
|
+
expect(() => resolveBrowseUrl()).to.throw(BrowseDomainError);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { after, before, describe, it } from "mocha";
|
|
3
|
+
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
import { BrowseService } from "../browse/browse-service.js";
|
|
7
|
+
import { BrowseDomainError } from "../error/browse-domain-error.js";
|
|
8
|
+
import { MissingCustomerPathError } from "../error/missing-customer-path-error.js";
|
|
9
|
+
import { BrowserContext } from "../onboarding-model.js";
|
|
10
|
+
import { OnboardingServiceBuildContext, } from "../onboarding-service-build-context.js";
|
|
11
|
+
import { OnboardingServiceFactory } from "../onboarding-service-factory.js";
|
|
12
|
+
const cli = new Proxy({}, {
|
|
13
|
+
get: (_target, property) => property === "nonInteractive" ? true : () => undefined,
|
|
14
|
+
});
|
|
15
|
+
function environment() {
|
|
16
|
+
// chromeUserProfilePath keeps BrowserContext off the filesystem.
|
|
17
|
+
return {
|
|
18
|
+
cli,
|
|
19
|
+
settings: {
|
|
20
|
+
chromePath: "/usr/bin/google-chrome",
|
|
21
|
+
chromeUserProfilePath: "/tmp/sk-test-profile",
|
|
22
|
+
chromeExtensionPaths: "/tmp/sk-test-devtools",
|
|
23
|
+
chromeFlags: ["--lang=de"],
|
|
24
|
+
testApp: "",
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function buildContext(values = {}) {
|
|
29
|
+
return new OnboardingServiceBuildContext({
|
|
30
|
+
environment: environment(),
|
|
31
|
+
customerPath: undefined,
|
|
32
|
+
configName: "production",
|
|
33
|
+
domain: undefined,
|
|
34
|
+
local: false,
|
|
35
|
+
ignoreContentSecurityPolicy: false,
|
|
36
|
+
cliPath: "/tmp",
|
|
37
|
+
verboseLevel: false,
|
|
38
|
+
useTestConfig: false,
|
|
39
|
+
debuggingPort: false,
|
|
40
|
+
headless: true,
|
|
41
|
+
debugPort: 9290,
|
|
42
|
+
browserFetch: false,
|
|
43
|
+
browse: false,
|
|
44
|
+
...values,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
/** Records what browse mode would launch, instead of resolving extensions and Chrome. */
|
|
48
|
+
class RecordingFactory extends OnboardingServiceFactory {
|
|
49
|
+
launched;
|
|
50
|
+
async prepareBrowser(domain, customerChromeFlags) {
|
|
51
|
+
this.launched = { domain, customerChromeFlags };
|
|
52
|
+
return {
|
|
53
|
+
browserContext: this.buildBrowserContext({
|
|
54
|
+
domain,
|
|
55
|
+
browserVersionString: "Google Chrome 146.0.7680.165",
|
|
56
|
+
customerChromeFlags,
|
|
57
|
+
}),
|
|
58
|
+
browserExtensions: { paths: [], hasDevtoolsExtension: false },
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
describe("OnboardingServiceFactory", () => {
|
|
63
|
+
describe("CUSTOMERPATH", () => {
|
|
64
|
+
it("is required without --browse", async () => {
|
|
65
|
+
const factory = new OnboardingServiceFactory(buildContext());
|
|
66
|
+
const error = await factory.getService().catch((error_) => error_);
|
|
67
|
+
expect(error).to.be.instanceOf(MissingCustomerPathError);
|
|
68
|
+
});
|
|
69
|
+
it("is optional with --browse", async () => {
|
|
70
|
+
const factory = new RecordingFactory(buildContext({ browse: true, domain: "www.example.com" }));
|
|
71
|
+
const service = await factory.getService();
|
|
72
|
+
expect(service).to.be.instanceOf(BrowseService);
|
|
73
|
+
expect(factory.launched).to.deep.equal({
|
|
74
|
+
domain: "https://www.example.com/",
|
|
75
|
+
customerChromeFlags: undefined,
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
it("fails in browse mode without a domain and without a CUSTOMERPATH", async () => {
|
|
79
|
+
const factory = new RecordingFactory(buildContext({ browse: true }));
|
|
80
|
+
const error = await factory.getService().catch((error_) => error_);
|
|
81
|
+
expect(error).to.be.instanceOf(BrowseDomainError);
|
|
82
|
+
expect(factory.launched).to.equal(undefined);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
describe("browse mode with a CUSTOMERPATH", () => {
|
|
86
|
+
let customerPath;
|
|
87
|
+
before(() => {
|
|
88
|
+
customerPath = mkdtempSync(join(tmpdir(), "sk-browse-"));
|
|
89
|
+
writeFileSync(join(customerPath, "config_customer.json"), JSON.stringify({
|
|
90
|
+
production: {
|
|
91
|
+
app: "example-shop",
|
|
92
|
+
domain: "www.example.com",
|
|
93
|
+
origins: ["https://www.example.com"],
|
|
94
|
+
swPath: "/sw.js",
|
|
95
|
+
scope: "/",
|
|
96
|
+
chromeFlags: ["--lang=fr"],
|
|
97
|
+
},
|
|
98
|
+
}));
|
|
99
|
+
});
|
|
100
|
+
after(() => rmSync(customerPath, { recursive: true, force: true }));
|
|
101
|
+
it("opens the domain and passes the chromeFlags of config_customer.json", async () => {
|
|
102
|
+
const factory = new RecordingFactory(buildContext({ browse: true, customerPath }));
|
|
103
|
+
await factory.getService();
|
|
104
|
+
expect(factory.launched).to.deep.equal({
|
|
105
|
+
domain: "https://www.example.com/",
|
|
106
|
+
customerChromeFlags: ["--lang=fr"],
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
it("lets --domain win over config_customer.json", async () => {
|
|
110
|
+
const factory = new RecordingFactory(buildContext({
|
|
111
|
+
browse: true,
|
|
112
|
+
customerPath,
|
|
113
|
+
domain: "shop.example.com",
|
|
114
|
+
}));
|
|
115
|
+
await factory.getService();
|
|
116
|
+
expect(factory.launched?.domain).to.equal("https://shop.example.com/");
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
describe("buildBrowserContext", () => {
|
|
120
|
+
const inputs = {
|
|
121
|
+
domain: "https://www.example.com/",
|
|
122
|
+
browserVersionString: "Google Chrome 146.0.7680.165",
|
|
123
|
+
customerChromeFlags: ["--lang=fr"],
|
|
124
|
+
};
|
|
125
|
+
function launchOptions(values) {
|
|
126
|
+
return new OnboardingServiceFactory(buildContext(values))
|
|
127
|
+
.buildBrowserContext(inputs)
|
|
128
|
+
.getPuppeteerLaunchOptions();
|
|
129
|
+
}
|
|
130
|
+
for (const mode of [
|
|
131
|
+
{ headless: true, debuggingPort: false },
|
|
132
|
+
{ headless: false, debuggingPort: true },
|
|
133
|
+
{ headless: false, debuggingPort: false },
|
|
134
|
+
]) {
|
|
135
|
+
it(`launches the same Chrome in browse mode as in onboarding (${JSON.stringify(mode)})`, () => {
|
|
136
|
+
expect(launchOptions({ ...mode, browse: true })).to.deep.equal(launchOptions({ ...mode, browse: false }));
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
it("keeps the extensions and a TCP debug port next to the pipe", () => {
|
|
140
|
+
const options = launchOptions({ browse: true, headless: true });
|
|
141
|
+
expect(options).to.include({ pipe: true, headless: true });
|
|
142
|
+
expect(options["enableExtensions"]).to.deep.equal([
|
|
143
|
+
"/tmp/sk-test-devtools",
|
|
144
|
+
]);
|
|
145
|
+
expect(options.args).to.include("--remote-debugging-port=9290");
|
|
146
|
+
expect(options.args).to.include("--lang=fr");
|
|
147
|
+
expect(options.args).to.include("--lang=de");
|
|
148
|
+
});
|
|
149
|
+
it("is a BrowserContext for the given domain", () => {
|
|
150
|
+
const browserContext = new OnboardingServiceFactory(buildContext({ browse: true })).buildBrowserContext(inputs);
|
|
151
|
+
expect(browserContext).to.be.instanceOf(BrowserContext);
|
|
152
|
+
expect(browserContext.domain).to.equal(inputs.domain);
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
});
|
package/oclif.manifest.json
CHANGED
|
@@ -632,15 +632,17 @@
|
|
|
632
632
|
"aliases": [],
|
|
633
633
|
"args": {
|
|
634
634
|
"customerPath": {
|
|
635
|
-
"description": "The customer config path",
|
|
635
|
+
"description": "The customer config path (optional with --browse)",
|
|
636
636
|
"name": "customerPath",
|
|
637
|
-
"required":
|
|
637
|
+
"required": false
|
|
638
638
|
}
|
|
639
639
|
},
|
|
640
640
|
"description": "Start a local dev environment for building and testing the Speed Kit configuration",
|
|
641
641
|
"examples": [
|
|
642
642
|
"$ sk onboarding <customerPath> -c <configName> -d <domain>",
|
|
643
|
-
"$ sk onboarding customers/decathlon.de -c production -d www.decathlon.de"
|
|
643
|
+
"$ sk onboarding customers/decathlon.de -c production -d www.decathlon.de",
|
|
644
|
+
"$ sk onboarding --browse -d www.decathlon.de --headless --debugPort 9290",
|
|
645
|
+
"$ sk onboarding customers/decathlon.de --browse -p"
|
|
644
646
|
],
|
|
645
647
|
"flags": {
|
|
646
648
|
"configName": {
|
|
@@ -710,6 +712,12 @@
|
|
|
710
712
|
"allowNo": false,
|
|
711
713
|
"type": "boolean"
|
|
712
714
|
},
|
|
715
|
+
"browse": {
|
|
716
|
+
"description": "Open the live site in the onboarding Chrome, with its extensions, but without request interception or Speed Kit injection. Takes the domain from -d or from the customer config.",
|
|
717
|
+
"name": "browse",
|
|
718
|
+
"allowNo": false,
|
|
719
|
+
"type": "boolean"
|
|
720
|
+
},
|
|
713
721
|
"browserFetch": {
|
|
714
722
|
"description": "Fetch every origin document with a second headless Chrome instead of a direct request. Only needed when bot protection refuses the CLI outright — a refusal is otherwise detected and rerouted on its own.",
|
|
715
723
|
"name": "browserFetch",
|
|
@@ -1283,149 +1291,6 @@
|
|
|
1283
1291
|
"setup.js"
|
|
1284
1292
|
]
|
|
1285
1293
|
},
|
|
1286
|
-
"extension:add": {
|
|
1287
|
-
"aliases": [],
|
|
1288
|
-
"args": {
|
|
1289
|
-
"ref": {
|
|
1290
|
-
"description": "Chrome Web Store link or extension id",
|
|
1291
|
-
"name": "ref",
|
|
1292
|
-
"required": false
|
|
1293
|
-
}
|
|
1294
|
-
},
|
|
1295
|
-
"description": "Install a Chrome extension into the onboarding browser by Web Store link or id",
|
|
1296
|
-
"examples": [
|
|
1297
|
-
"$ sk extension add fmkadmapgofadopljbjfkapdkoienihi",
|
|
1298
|
-
"$ sk extension add https://chromewebstore.google.com/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi",
|
|
1299
|
-
"$ sk extension add"
|
|
1300
|
-
],
|
|
1301
|
-
"flags": {},
|
|
1302
|
-
"hasDynamicHelp": false,
|
|
1303
|
-
"hiddenAliases": [],
|
|
1304
|
-
"id": "extension:add",
|
|
1305
|
-
"pluginAlias": "@speedkit/cli",
|
|
1306
|
-
"pluginName": "@speedkit/cli",
|
|
1307
|
-
"pluginType": "core",
|
|
1308
|
-
"strict": true,
|
|
1309
|
-
"enableJsonFlag": false,
|
|
1310
|
-
"isESM": true,
|
|
1311
|
-
"relativePath": [
|
|
1312
|
-
"dist",
|
|
1313
|
-
"commands",
|
|
1314
|
-
"extension",
|
|
1315
|
-
"add.js"
|
|
1316
|
-
]
|
|
1317
|
-
},
|
|
1318
|
-
"extension:devtools": {
|
|
1319
|
-
"aliases": [],
|
|
1320
|
-
"args": {},
|
|
1321
|
-
"description": "Install the integration-devtools extension for the onboarding browser, or update it to the latest release",
|
|
1322
|
-
"examples": [
|
|
1323
|
-
"$ sk extension devtools",
|
|
1324
|
-
"$ sk extension devtools --force"
|
|
1325
|
-
],
|
|
1326
|
-
"flags": {
|
|
1327
|
-
"force": {
|
|
1328
|
-
"description": "reinstall the latest release even when it is up to date",
|
|
1329
|
-
"name": "force",
|
|
1330
|
-
"allowNo": false,
|
|
1331
|
-
"type": "boolean"
|
|
1332
|
-
}
|
|
1333
|
-
},
|
|
1334
|
-
"hasDynamicHelp": false,
|
|
1335
|
-
"hiddenAliases": [],
|
|
1336
|
-
"id": "extension:devtools",
|
|
1337
|
-
"pluginAlias": "@speedkit/cli",
|
|
1338
|
-
"pluginName": "@speedkit/cli",
|
|
1339
|
-
"pluginType": "core",
|
|
1340
|
-
"strict": true,
|
|
1341
|
-
"enableJsonFlag": false,
|
|
1342
|
-
"isESM": true,
|
|
1343
|
-
"relativePath": [
|
|
1344
|
-
"dist",
|
|
1345
|
-
"commands",
|
|
1346
|
-
"extension",
|
|
1347
|
-
"devtools.js"
|
|
1348
|
-
]
|
|
1349
|
-
},
|
|
1350
|
-
"extension:list": {
|
|
1351
|
-
"aliases": [],
|
|
1352
|
-
"args": {},
|
|
1353
|
-
"description": "List Chrome extensions managed by the setup wizard",
|
|
1354
|
-
"examples": [
|
|
1355
|
-
"$ sk extension list"
|
|
1356
|
-
],
|
|
1357
|
-
"flags": {},
|
|
1358
|
-
"hasDynamicHelp": false,
|
|
1359
|
-
"hiddenAliases": [],
|
|
1360
|
-
"id": "extension:list",
|
|
1361
|
-
"pluginAlias": "@speedkit/cli",
|
|
1362
|
-
"pluginName": "@speedkit/cli",
|
|
1363
|
-
"pluginType": "core",
|
|
1364
|
-
"strict": true,
|
|
1365
|
-
"enableJsonFlag": false,
|
|
1366
|
-
"isESM": true,
|
|
1367
|
-
"relativePath": [
|
|
1368
|
-
"dist",
|
|
1369
|
-
"commands",
|
|
1370
|
-
"extension",
|
|
1371
|
-
"list.js"
|
|
1372
|
-
]
|
|
1373
|
-
},
|
|
1374
|
-
"extension:remove": {
|
|
1375
|
-
"aliases": [],
|
|
1376
|
-
"args": {
|
|
1377
|
-
"ref": {
|
|
1378
|
-
"description": "Chrome Web Store link or extension id",
|
|
1379
|
-
"name": "ref",
|
|
1380
|
-
"required": false
|
|
1381
|
-
}
|
|
1382
|
-
},
|
|
1383
|
-
"description": "Remove a managed Chrome extension",
|
|
1384
|
-
"examples": [
|
|
1385
|
-
"$ sk extension remove",
|
|
1386
|
-
"$ sk extension remove <id>"
|
|
1387
|
-
],
|
|
1388
|
-
"flags": {},
|
|
1389
|
-
"hasDynamicHelp": false,
|
|
1390
|
-
"hiddenAliases": [],
|
|
1391
|
-
"id": "extension:remove",
|
|
1392
|
-
"pluginAlias": "@speedkit/cli",
|
|
1393
|
-
"pluginName": "@speedkit/cli",
|
|
1394
|
-
"pluginType": "core",
|
|
1395
|
-
"strict": true,
|
|
1396
|
-
"enableJsonFlag": false,
|
|
1397
|
-
"isESM": true,
|
|
1398
|
-
"relativePath": [
|
|
1399
|
-
"dist",
|
|
1400
|
-
"commands",
|
|
1401
|
-
"extension",
|
|
1402
|
-
"remove.js"
|
|
1403
|
-
]
|
|
1404
|
-
},
|
|
1405
|
-
"extension:update": {
|
|
1406
|
-
"aliases": [],
|
|
1407
|
-
"args": {},
|
|
1408
|
-
"description": "Check managed Chrome extensions for updates and install them",
|
|
1409
|
-
"examples": [
|
|
1410
|
-
"$ sk extension update"
|
|
1411
|
-
],
|
|
1412
|
-
"flags": {},
|
|
1413
|
-
"hasDynamicHelp": false,
|
|
1414
|
-
"hiddenAliases": [],
|
|
1415
|
-
"id": "extension:update",
|
|
1416
|
-
"pluginAlias": "@speedkit/cli",
|
|
1417
|
-
"pluginName": "@speedkit/cli",
|
|
1418
|
-
"pluginType": "core",
|
|
1419
|
-
"strict": true,
|
|
1420
|
-
"enableJsonFlag": false,
|
|
1421
|
-
"isESM": true,
|
|
1422
|
-
"relativePath": [
|
|
1423
|
-
"dist",
|
|
1424
|
-
"commands",
|
|
1425
|
-
"extension",
|
|
1426
|
-
"update.js"
|
|
1427
|
-
]
|
|
1428
|
-
},
|
|
1429
1294
|
"query:parameter": {
|
|
1430
1295
|
"aliases": [
|
|
1431
1296
|
"build-parameter-query"
|
|
@@ -1736,7 +1601,150 @@
|
|
|
1736
1601
|
"query",
|
|
1737
1602
|
"prewarm.js"
|
|
1738
1603
|
]
|
|
1604
|
+
},
|
|
1605
|
+
"extension:add": {
|
|
1606
|
+
"aliases": [],
|
|
1607
|
+
"args": {
|
|
1608
|
+
"ref": {
|
|
1609
|
+
"description": "Chrome Web Store link or extension id",
|
|
1610
|
+
"name": "ref",
|
|
1611
|
+
"required": false
|
|
1612
|
+
}
|
|
1613
|
+
},
|
|
1614
|
+
"description": "Install a Chrome extension into the onboarding browser by Web Store link or id",
|
|
1615
|
+
"examples": [
|
|
1616
|
+
"$ sk extension add fmkadmapgofadopljbjfkapdkoienihi",
|
|
1617
|
+
"$ sk extension add https://chromewebstore.google.com/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi",
|
|
1618
|
+
"$ sk extension add"
|
|
1619
|
+
],
|
|
1620
|
+
"flags": {},
|
|
1621
|
+
"hasDynamicHelp": false,
|
|
1622
|
+
"hiddenAliases": [],
|
|
1623
|
+
"id": "extension:add",
|
|
1624
|
+
"pluginAlias": "@speedkit/cli",
|
|
1625
|
+
"pluginName": "@speedkit/cli",
|
|
1626
|
+
"pluginType": "core",
|
|
1627
|
+
"strict": true,
|
|
1628
|
+
"enableJsonFlag": false,
|
|
1629
|
+
"isESM": true,
|
|
1630
|
+
"relativePath": [
|
|
1631
|
+
"dist",
|
|
1632
|
+
"commands",
|
|
1633
|
+
"extension",
|
|
1634
|
+
"add.js"
|
|
1635
|
+
]
|
|
1636
|
+
},
|
|
1637
|
+
"extension:devtools": {
|
|
1638
|
+
"aliases": [],
|
|
1639
|
+
"args": {},
|
|
1640
|
+
"description": "Install the integration-devtools extension for the onboarding browser, or update it to the latest release",
|
|
1641
|
+
"examples": [
|
|
1642
|
+
"$ sk extension devtools",
|
|
1643
|
+
"$ sk extension devtools --force"
|
|
1644
|
+
],
|
|
1645
|
+
"flags": {
|
|
1646
|
+
"force": {
|
|
1647
|
+
"description": "reinstall the latest release even when it is up to date",
|
|
1648
|
+
"name": "force",
|
|
1649
|
+
"allowNo": false,
|
|
1650
|
+
"type": "boolean"
|
|
1651
|
+
}
|
|
1652
|
+
},
|
|
1653
|
+
"hasDynamicHelp": false,
|
|
1654
|
+
"hiddenAliases": [],
|
|
1655
|
+
"id": "extension:devtools",
|
|
1656
|
+
"pluginAlias": "@speedkit/cli",
|
|
1657
|
+
"pluginName": "@speedkit/cli",
|
|
1658
|
+
"pluginType": "core",
|
|
1659
|
+
"strict": true,
|
|
1660
|
+
"enableJsonFlag": false,
|
|
1661
|
+
"isESM": true,
|
|
1662
|
+
"relativePath": [
|
|
1663
|
+
"dist",
|
|
1664
|
+
"commands",
|
|
1665
|
+
"extension",
|
|
1666
|
+
"devtools.js"
|
|
1667
|
+
]
|
|
1668
|
+
},
|
|
1669
|
+
"extension:list": {
|
|
1670
|
+
"aliases": [],
|
|
1671
|
+
"args": {},
|
|
1672
|
+
"description": "List Chrome extensions managed by the setup wizard",
|
|
1673
|
+
"examples": [
|
|
1674
|
+
"$ sk extension list"
|
|
1675
|
+
],
|
|
1676
|
+
"flags": {},
|
|
1677
|
+
"hasDynamicHelp": false,
|
|
1678
|
+
"hiddenAliases": [],
|
|
1679
|
+
"id": "extension:list",
|
|
1680
|
+
"pluginAlias": "@speedkit/cli",
|
|
1681
|
+
"pluginName": "@speedkit/cli",
|
|
1682
|
+
"pluginType": "core",
|
|
1683
|
+
"strict": true,
|
|
1684
|
+
"enableJsonFlag": false,
|
|
1685
|
+
"isESM": true,
|
|
1686
|
+
"relativePath": [
|
|
1687
|
+
"dist",
|
|
1688
|
+
"commands",
|
|
1689
|
+
"extension",
|
|
1690
|
+
"list.js"
|
|
1691
|
+
]
|
|
1692
|
+
},
|
|
1693
|
+
"extension:remove": {
|
|
1694
|
+
"aliases": [],
|
|
1695
|
+
"args": {
|
|
1696
|
+
"ref": {
|
|
1697
|
+
"description": "Chrome Web Store link or extension id",
|
|
1698
|
+
"name": "ref",
|
|
1699
|
+
"required": false
|
|
1700
|
+
}
|
|
1701
|
+
},
|
|
1702
|
+
"description": "Remove a managed Chrome extension",
|
|
1703
|
+
"examples": [
|
|
1704
|
+
"$ sk extension remove",
|
|
1705
|
+
"$ sk extension remove <id>"
|
|
1706
|
+
],
|
|
1707
|
+
"flags": {},
|
|
1708
|
+
"hasDynamicHelp": false,
|
|
1709
|
+
"hiddenAliases": [],
|
|
1710
|
+
"id": "extension:remove",
|
|
1711
|
+
"pluginAlias": "@speedkit/cli",
|
|
1712
|
+
"pluginName": "@speedkit/cli",
|
|
1713
|
+
"pluginType": "core",
|
|
1714
|
+
"strict": true,
|
|
1715
|
+
"enableJsonFlag": false,
|
|
1716
|
+
"isESM": true,
|
|
1717
|
+
"relativePath": [
|
|
1718
|
+
"dist",
|
|
1719
|
+
"commands",
|
|
1720
|
+
"extension",
|
|
1721
|
+
"remove.js"
|
|
1722
|
+
]
|
|
1723
|
+
},
|
|
1724
|
+
"extension:update": {
|
|
1725
|
+
"aliases": [],
|
|
1726
|
+
"args": {},
|
|
1727
|
+
"description": "Check managed Chrome extensions for updates and install them",
|
|
1728
|
+
"examples": [
|
|
1729
|
+
"$ sk extension update"
|
|
1730
|
+
],
|
|
1731
|
+
"flags": {},
|
|
1732
|
+
"hasDynamicHelp": false,
|
|
1733
|
+
"hiddenAliases": [],
|
|
1734
|
+
"id": "extension:update",
|
|
1735
|
+
"pluginAlias": "@speedkit/cli",
|
|
1736
|
+
"pluginName": "@speedkit/cli",
|
|
1737
|
+
"pluginType": "core",
|
|
1738
|
+
"strict": true,
|
|
1739
|
+
"enableJsonFlag": false,
|
|
1740
|
+
"isESM": true,
|
|
1741
|
+
"relativePath": [
|
|
1742
|
+
"dist",
|
|
1743
|
+
"commands",
|
|
1744
|
+
"extension",
|
|
1745
|
+
"update.js"
|
|
1746
|
+
]
|
|
1739
1747
|
}
|
|
1740
1748
|
},
|
|
1741
|
-
"version": "4.
|
|
1749
|
+
"version": "4.37.0"
|
|
1742
1750
|
}
|