@speedkit/cli 3.4.1 → 3.4.2
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/cli/cli-service-model.d.ts +1 -0
- package/dist/services/cli/cli-service.d.ts +1 -0
- package/dist/services/cli/cli-service.js +15 -0
- package/dist/services/onboarding/browser/executable/executable-validator.d.ts +2 -2
- package/dist/services/onboarding/browser/executable/executable-validator.js +10 -9
- package/dist/services/onboarding/onboarding-model.d.ts +2 -4
- package/dist/services/onboarding/onboarding-model.js +4 -32
- package/dist/services/onboarding/onboarding-service-factory.js +2 -2
- package/dist/services/onboarding/onboarding-service.js +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [3.4.2](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v3.4.1...v3.4.2) (2025-08-19)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **onboarding:** set universal fix for whiteSpacePaths for chromeExecutable ([fa3c743](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/fa3c7433161b4d1f0a184e31afe1d74b17f535b5))
|
|
7
|
+
|
|
1
8
|
## [3.4.1](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v3.4.0...v3.4.1) (2025-08-19)
|
|
2
9
|
|
|
3
10
|
|
package/README.md
CHANGED
|
@@ -35,4 +35,5 @@ export interface CliServiceInterface {
|
|
|
35
35
|
writeError(message: string, buffered?: boolean): void;
|
|
36
36
|
writeSuccess(message: string, buffered?: boolean): void;
|
|
37
37
|
writeWarning(message: string, buffered?: boolean): void;
|
|
38
|
+
execSync(command: string, arguments_: string[]): string;
|
|
38
39
|
}
|
|
@@ -30,5 +30,6 @@ export declare class CliService implements CliServiceInterface {
|
|
|
30
30
|
writeError(message: string, buffered?: boolean): void;
|
|
31
31
|
writeSuccess(message: string, buffered?: boolean): void;
|
|
32
32
|
writeWarning(message: string, buffered?: boolean): void;
|
|
33
|
+
execSync(command: string, arguments_?: string[]): string;
|
|
33
34
|
private getFormattedMessage;
|
|
34
35
|
}
|
|
@@ -6,6 +6,9 @@ const prompts_1 = require("@inquirer/prompts");
|
|
|
6
6
|
const chalk_1 = tslib_1.__importDefault(require("chalk")); // interactive prompts
|
|
7
7
|
const core_1 = require("@oclif/core");
|
|
8
8
|
const cli_service_model_1 = require("./cli-service-model");
|
|
9
|
+
const safe_1 = require("../../helpers/safe");
|
|
10
|
+
const node_child_process_1 = require("node:child_process");
|
|
11
|
+
const application_error_1 = tslib_1.__importDefault(require("../error-handling/error/application-error"));
|
|
9
12
|
class CliService {
|
|
10
13
|
quiet;
|
|
11
14
|
style = chalk_1.default;
|
|
@@ -158,6 +161,18 @@ class CliService {
|
|
|
158
161
|
}
|
|
159
162
|
this.write(this.style.yellow(message));
|
|
160
163
|
}
|
|
164
|
+
execSync(command, arguments_) {
|
|
165
|
+
const result = (0, safe_1.safe)(() => {
|
|
166
|
+
return (0, node_child_process_1.execSync)(`"${command}" ${arguments_.join(" ")}`).toString();
|
|
167
|
+
});
|
|
168
|
+
if (result.success !== true) {
|
|
169
|
+
throw new application_error_1.default(result.error, [
|
|
170
|
+
`running ${command}`,
|
|
171
|
+
`with arguments ${arguments_.join(" ")}`,
|
|
172
|
+
]);
|
|
173
|
+
}
|
|
174
|
+
return result.data;
|
|
175
|
+
}
|
|
161
176
|
getFormattedMessage(questionText) {
|
|
162
177
|
return `${this.style.bold(questionText)}`;
|
|
163
178
|
}
|
|
@@ -4,9 +4,9 @@ export declare class ExecutableValidator {
|
|
|
4
4
|
readonly userConfig: UserCliConfig;
|
|
5
5
|
private cli;
|
|
6
6
|
constructor(userConfig: UserCliConfig, cli: CliServiceInterface);
|
|
7
|
-
validateOrInstall(): Promise<
|
|
7
|
+
validateOrInstall(): Promise<string>;
|
|
8
|
+
private getCurrentBrowserVersion;
|
|
8
9
|
private getExecutablePathFromPuppeteer;
|
|
9
10
|
private isValidBrowserExecutable;
|
|
10
|
-
private cleanPath;
|
|
11
11
|
installBrowser(): Promise<void>;
|
|
12
12
|
}
|
|
@@ -19,9 +19,8 @@ class ExecutableValidator {
|
|
|
19
19
|
async validateOrInstall() {
|
|
20
20
|
// check if a valid browserExecutablePath is configured
|
|
21
21
|
const userChromePath = this.userConfig?.chromePath;
|
|
22
|
-
if (
|
|
23
|
-
this.
|
|
24
|
-
return;
|
|
22
|
+
if (this.isValidBrowserExecutable()) {
|
|
23
|
+
return this.getCurrentBrowserVersion();
|
|
25
24
|
}
|
|
26
25
|
// write error if configured path is not executable
|
|
27
26
|
if (userChromePath.length > 0) {
|
|
@@ -33,7 +32,7 @@ class ExecutableValidator {
|
|
|
33
32
|
if (installedBrowsers.length > 0) {
|
|
34
33
|
// found an installed browser, set path to this
|
|
35
34
|
this.userConfig.chromePath = installedBrowsers[0].executablePath;
|
|
36
|
-
return;
|
|
35
|
+
return this.getCurrentBrowserVersion();
|
|
37
36
|
}
|
|
38
37
|
// write warning that no browser is configured
|
|
39
38
|
if (userChromePath.length === 0) {
|
|
@@ -53,17 +52,19 @@ class ExecutableValidator {
|
|
|
53
52
|
await this.installBrowser();
|
|
54
53
|
// set path to freshly installed chrome
|
|
55
54
|
this.userConfig.chromePath = this.getExecutablePathFromPuppeteer();
|
|
55
|
+
return this.getCurrentBrowserVersion();
|
|
56
|
+
}
|
|
57
|
+
getCurrentBrowserVersion() {
|
|
58
|
+
return this.cli.execSync(`"${this.userConfig.chromePath}"`, ["--version"]);
|
|
56
59
|
}
|
|
57
60
|
getExecutablePathFromPuppeteer() {
|
|
58
61
|
const puppeteerCache = new browsers_2.Cache(this.userConfig.tempFolder);
|
|
59
62
|
const installedBrowsers = puppeteerCache.getInstalledBrowsers();
|
|
60
63
|
return installedBrowsers[0].executablePath;
|
|
61
64
|
}
|
|
62
|
-
isValidBrowserExecutable(
|
|
63
|
-
return (
|
|
64
|
-
|
|
65
|
-
cleanPath(path) {
|
|
66
|
-
return path.trim().replaceAll(" ", "\\ ");
|
|
65
|
+
isValidBrowserExecutable() {
|
|
66
|
+
return (this.userConfig?.chromePath.length > 0 &&
|
|
67
|
+
(0, node_fs_1.existsSync)((0, node_path_1.resolve)(this.userConfig?.chromePath.trim())));
|
|
67
68
|
}
|
|
68
69
|
async installBrowser() {
|
|
69
70
|
const puppeteerCli = new browsers_1.CLI({
|
|
@@ -32,15 +32,13 @@ export declare const CDP_SESSION: {
|
|
|
32
32
|
};
|
|
33
33
|
export declare class BrowserContext {
|
|
34
34
|
readonly domain: string;
|
|
35
|
+
readonly browserVersionString: string;
|
|
35
36
|
readonly chromeFlags?: string[];
|
|
36
37
|
readonly userConfig?: UserCliConfig;
|
|
37
38
|
userAgent?: string;
|
|
38
39
|
readonly browserArgs: string[];
|
|
39
40
|
readonly chromePath: string;
|
|
40
|
-
|
|
41
|
-
constructor(domain: string, chromeFlags?: string[], userConfig?: UserCliConfig, userAgent?: string);
|
|
42
|
-
private cleanPath;
|
|
43
|
-
private checkBrowserDetails;
|
|
41
|
+
constructor(domain: string, browserVersionString: string, chromeFlags?: string[], userConfig?: UserCliConfig, userAgent?: string);
|
|
44
42
|
private isChromeBrowser;
|
|
45
43
|
private getBrowserExtensionPath;
|
|
46
44
|
getPuppeteerLaunchOptions(): Parameters<VanillaPuppeteer["launch"]>[0];
|
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SpeedKitInstallRegex = exports.USER_AGENT = exports.OnboardingContext = exports.BrowserContext = exports.CDP_SESSION = exports.BROWSER_EVENTS = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const core_1 = require("@oclif/core");
|
|
6
5
|
const cli_parameters_1 = require("../../models/cli-parameters");
|
|
7
6
|
const browser_config_1 = require("./browser/config/browser-config");
|
|
8
|
-
const node_child_process_1 = require("node:child_process");
|
|
9
|
-
const safe_1 = require("../../helpers/safe");
|
|
10
|
-
const application_error_1 = tslib_1.__importDefault(require("../error-handling/error/application-error"));
|
|
11
|
-
const node_fs_1 = require("node:fs");
|
|
12
7
|
const node_path_1 = require("node:path");
|
|
13
8
|
const DEFAULT_BROWSER_ARGS = [
|
|
14
9
|
"--enable-features=Translate,NetworkService",
|
|
@@ -45,14 +40,15 @@ exports.CDP_SESSION = {
|
|
|
45
40
|
};
|
|
46
41
|
class BrowserContext {
|
|
47
42
|
domain;
|
|
43
|
+
browserVersionString;
|
|
48
44
|
chromeFlags;
|
|
49
45
|
userConfig;
|
|
50
46
|
userAgent;
|
|
51
47
|
browserArgs;
|
|
52
48
|
chromePath;
|
|
53
|
-
|
|
54
|
-
constructor(domain, chromeFlags, userConfig, userAgent) {
|
|
49
|
+
constructor(domain, browserVersionString, chromeFlags, userConfig, userAgent) {
|
|
55
50
|
this.domain = domain;
|
|
51
|
+
this.browserVersionString = browserVersionString;
|
|
56
52
|
this.chromeFlags = chromeFlags;
|
|
57
53
|
this.userConfig = userConfig;
|
|
58
54
|
this.userAgent = userAgent;
|
|
@@ -60,7 +56,6 @@ class BrowserContext {
|
|
|
60
56
|
this.chromeFlags = chromeFlags || [];
|
|
61
57
|
this.chromePath = (0, node_path_1.resolve)(userConfig.chromePath);
|
|
62
58
|
const browserArguments = DEFAULT_BROWSER_ARGS;
|
|
63
|
-
this.browserDetails = this.checkBrowserDetails(this.chromePath);
|
|
64
59
|
if (userConfig?.chromeUserProfilePath) {
|
|
65
60
|
browserArguments.push(`--user-data-dir=${userConfig?.chromeUserProfilePath}`);
|
|
66
61
|
}
|
|
@@ -75,31 +70,8 @@ class BrowserContext {
|
|
|
75
70
|
...this.chromeFlags,
|
|
76
71
|
];
|
|
77
72
|
}
|
|
78
|
-
cleanPath(path) {
|
|
79
|
-
return path.trim().replaceAll(" ", "\\ ");
|
|
80
|
-
}
|
|
81
|
-
checkBrowserDetails(browserExecutablePath) {
|
|
82
|
-
if (!(0, node_fs_1.existsSync)(browserExecutablePath)) {
|
|
83
|
-
throw new application_error_1.default(`No executable found in ${browserExecutablePath}`, [
|
|
84
|
-
"Check your configured browserExecutablePath",
|
|
85
|
-
"in envVar CHROME_PATH",
|
|
86
|
-
"or ~/.config/speed-kit-cli/config.json {chromePath:}",
|
|
87
|
-
]);
|
|
88
|
-
}
|
|
89
|
-
const result = (0, safe_1.safe)(() => {
|
|
90
|
-
return (0, node_child_process_1.execSync)(`${this.cleanPath(browserExecutablePath)} --version`).toString();
|
|
91
|
-
});
|
|
92
|
-
if (result.success === false) {
|
|
93
|
-
throw new application_error_1.default(result.error, [
|
|
94
|
-
"Check your configured browserExecutablePath",
|
|
95
|
-
`No executable found in ${browserExecutablePath}`,
|
|
96
|
-
]);
|
|
97
|
-
}
|
|
98
|
-
return result.data.trim().replaceAll("\n", "");
|
|
99
|
-
}
|
|
100
73
|
isChromeBrowser() {
|
|
101
|
-
return
|
|
102
|
-
!!/google/i.test(this.browserDetails));
|
|
74
|
+
return !!/chrome/i.test(this.browserVersionString);
|
|
103
75
|
}
|
|
104
76
|
getBrowserExtensionPath() {
|
|
105
77
|
if (this.userConfig?.chromeExtensionPaths) {
|
|
@@ -72,8 +72,8 @@ class OnboardingServiceFactory {
|
|
|
72
72
|
const extensionPaths = await new extension_validator_1.ExtensionValidator(extensionDownloader, this.cliConfig, cli).getValidBrowserExtensionPaths();
|
|
73
73
|
this.cliConfig.chromeExtensionPaths = extensionPaths.join(",");
|
|
74
74
|
const browserValidator = new executable_validator_1.ExecutableValidator(this.cliConfig, cli);
|
|
75
|
-
await browserValidator.validateOrInstall();
|
|
76
|
-
const browserContext = new onboarding_model_1.BrowserContext(domainToStart, customerConfig.chromeFlags || [], this.cliConfig);
|
|
75
|
+
const browserVersionString = await browserValidator.validateOrInstall();
|
|
76
|
+
const browserContext = new onboarding_model_1.BrowserContext(domainToStart, browserVersionString, customerConfig.chromeFlags || [], this.cliConfig);
|
|
77
77
|
const fileWatcher = new file_watcher_1.FileWatcher(cli, customerConfig, files, documentHandler, browserContext, cache);
|
|
78
78
|
const athenaClient = (await this.getAthenaClient()) || null;
|
|
79
79
|
const fetchHandler = await this.getFetchEventHandler(files, customerConfig, documentHandler, cache, cli, browserContext, athenaClient);
|
|
@@ -29,7 +29,7 @@ class OnboardingService {
|
|
|
29
29
|
* prepare puppeteerBrowser, add eventListeners and start
|
|
30
30
|
*/
|
|
31
31
|
async run() {
|
|
32
|
-
this.cli.startAction(`prepare browser ${this.cli.style.bold(this.browserContext.
|
|
32
|
+
this.cli.startAction(`prepare browser ${this.cli.style.bold(this.browserContext.browserVersionString)}`);
|
|
33
33
|
const browser = await this.prepareBrowser();
|
|
34
34
|
const page = await this.preparePage(browser);
|
|
35
35
|
this.cli.endAction(cli_1.CliActionStatus.COMPLETED);
|
package/oclif.manifest.json
CHANGED