@speedkit/cli 2.68.0 → 2.69.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 +15 -0
- package/README.md +1 -1
- package/dist/helpers/cli-config.d.ts +1 -0
- package/dist/helpers/cli-config.js +2 -0
- package/dist/services/onboarding/browser/config/browser-config.d.ts +27 -0
- package/dist/services/onboarding/browser/config/browser-config.js +102 -0
- package/dist/services/onboarding/dashboard/diff-against-current-page.js +2 -2
- package/dist/services/onboarding/onboarding-model.js +6 -0
- package/oclif.manifest.json +1 -1
- package/package.json +1 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
# [2.69.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.68.0...v2.69.0) (2024-12-11)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* createProfileFolder if not exists ([e820a45](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/e820a45f6c4398b646f609c6d072d8d7775e4ac9))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* create dynamic browserProfile from last session ([cce0f99](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/cce0f995fb6ee8d9c84818d93ef1db50a6bd7820))
|
|
12
|
+
* **diff:** add .html-extension so idea can have syntaxHighlighting ([748bc25](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/748bc2541a7d6b6a521b2eecf8e22666aefe68b4))
|
|
13
|
+
* load last browserConfig and create a fresh profile with it ([878a420](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/878a42027b15a43d59f438bc34a88f8b10a652e6))
|
|
14
|
+
* **onboarding:** filter unwanted configKeys from previous configs ([b3f08a0](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/b3f08a09d05fe6689fd826a03e5702559c5c6a68))
|
|
15
|
+
|
|
1
16
|
# [2.68.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.67.0...v2.68.0) (2024-12-11)
|
|
2
17
|
|
|
3
18
|
|
package/README.md
CHANGED
|
@@ -28,6 +28,7 @@ class CliConfig {
|
|
|
28
28
|
ideaDirectory: "",
|
|
29
29
|
slackToken: "",
|
|
30
30
|
testApp: "",
|
|
31
|
+
tempFolder: "/tmp",
|
|
31
32
|
};
|
|
32
33
|
constructor(config) {
|
|
33
34
|
this.config = config;
|
|
@@ -38,6 +39,7 @@ class CliConfig {
|
|
|
38
39
|
// override config from environment
|
|
39
40
|
this.loadConfigFromEnvironment();
|
|
40
41
|
this.resolveExtensionConfigPaths();
|
|
42
|
+
this.userCliConfig.tempFolder = this.config.cacheDir;
|
|
41
43
|
return this.userCliConfig;
|
|
42
44
|
}
|
|
43
45
|
createEmptyConfigFile() {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { UserCliConfig } from "../../../../helpers/cli-config";
|
|
2
|
+
/**
|
|
3
|
+
* this class makes sure you always start skOnboarding with a fresh browser,
|
|
4
|
+
* but still keep your window/devtools-configuration
|
|
5
|
+
*/
|
|
6
|
+
export declare class BrowserConfig {
|
|
7
|
+
private userConfig;
|
|
8
|
+
constructor(userConfig: UserCliConfig);
|
|
9
|
+
/**
|
|
10
|
+
* create a new temporary profileFolder
|
|
11
|
+
* load browserConfigJsonFile from last profileFolder
|
|
12
|
+
* delete older profiles
|
|
13
|
+
*/
|
|
14
|
+
loadProfileTempDir(): string;
|
|
15
|
+
/**
|
|
16
|
+
* load latest browserConfig and put it into newly created profilePath
|
|
17
|
+
*/
|
|
18
|
+
private createProfileDirWithLatestConfig;
|
|
19
|
+
private sortFoldersByDate;
|
|
20
|
+
/**
|
|
21
|
+
* remove keys we don't need
|
|
22
|
+
*
|
|
23
|
+
* @param configString
|
|
24
|
+
* @private
|
|
25
|
+
*/
|
|
26
|
+
private cleanUpLastConfig;
|
|
27
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BrowserConfig = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
6
|
+
const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
|
|
7
|
+
const chromeProfilesParentFolder = "chrome_profile";
|
|
8
|
+
const keysToRemove = new Set([
|
|
9
|
+
"sessions",
|
|
10
|
+
"extensions",
|
|
11
|
+
"in_product_help",
|
|
12
|
+
"history_clusters",
|
|
13
|
+
"media",
|
|
14
|
+
"profile",
|
|
15
|
+
"protection",
|
|
16
|
+
]);
|
|
17
|
+
/**
|
|
18
|
+
* this class makes sure you always start skOnboarding with a fresh browser,
|
|
19
|
+
* but still keep your window/devtools-configuration
|
|
20
|
+
*/
|
|
21
|
+
class BrowserConfig {
|
|
22
|
+
userConfig;
|
|
23
|
+
constructor(userConfig) {
|
|
24
|
+
this.userConfig = userConfig;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* create a new temporary profileFolder
|
|
28
|
+
* load browserConfigJsonFile from last profileFolder
|
|
29
|
+
* delete older profiles
|
|
30
|
+
*/
|
|
31
|
+
loadProfileTempDir() {
|
|
32
|
+
const chromeProfilePath = node_path_1.default.resolve(this.userConfig.tempFolder, chromeProfilesParentFolder, String(Date.now()));
|
|
33
|
+
const chromeProfilesParentFolderPath = node_path_1.default.resolve(this.userConfig.tempFolder, chromeProfilesParentFolder);
|
|
34
|
+
// create parentFolder if not exists
|
|
35
|
+
if (!node_fs_1.default.existsSync(chromeProfilesParentFolderPath)) {
|
|
36
|
+
node_fs_1.default.mkdirSync(chromeProfilesParentFolderPath, { recursive: true });
|
|
37
|
+
}
|
|
38
|
+
// load older profiles
|
|
39
|
+
const chromeProfileFolders = node_fs_1.default.readdirSync(chromeProfilesParentFolderPath);
|
|
40
|
+
if (!chromeProfileFolders || chromeProfileFolders.length === 0) {
|
|
41
|
+
return chromeProfilePath;
|
|
42
|
+
}
|
|
43
|
+
const sortedFolders = this.sortFoldersByDate(chromeProfileFolders);
|
|
44
|
+
this.createProfileDirWithLatestConfig(sortedFolders, chromeProfilesParentFolderPath, chromeProfilePath);
|
|
45
|
+
return chromeProfilePath;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* load latest browserConfig and put it into newly created profilePath
|
|
49
|
+
*/
|
|
50
|
+
createProfileDirWithLatestConfig(sortedFolders, chromeTemporaryFolderPath, chromeProfilePath) {
|
|
51
|
+
let foundLatestFolder = false;
|
|
52
|
+
for (const folderName of sortedFolders) {
|
|
53
|
+
const preferencesPath = node_path_1.default.resolve(chromeTemporaryFolderPath, folderName, "Default", "Preferences");
|
|
54
|
+
// look for chrome preferences in latest profileFolder
|
|
55
|
+
// delete folders not containing any profiles
|
|
56
|
+
// delete all older folders after we found latest profile
|
|
57
|
+
if (!node_fs_1.default.existsSync(preferencesPath) || foundLatestFolder) {
|
|
58
|
+
node_fs_1.default.rmSync(node_path_1.default.resolve(chromeTemporaryFolderPath, folderName), {
|
|
59
|
+
recursive: true,
|
|
60
|
+
force: true,
|
|
61
|
+
});
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
// return latest found config
|
|
65
|
+
const lastConfigString = this.cleanUpLastConfig(node_fs_1.default.readFileSync(preferencesPath, "utf8"));
|
|
66
|
+
node_fs_1.default.mkdirSync(node_path_1.default.resolve(chromeProfilePath, "Default"), {
|
|
67
|
+
recursive: true,
|
|
68
|
+
});
|
|
69
|
+
node_fs_1.default.writeFileSync(node_path_1.default.resolve(chromeProfilePath, "Default", "Preferences"), lastConfigString, { encoding: "utf-8" });
|
|
70
|
+
// after adding latest profile to new profile
|
|
71
|
+
// delete folder where we got the latest config from
|
|
72
|
+
node_fs_1.default.rmSync(node_path_1.default.resolve(chromeTemporaryFolderPath, folderName), {
|
|
73
|
+
recursive: true,
|
|
74
|
+
force: true,
|
|
75
|
+
});
|
|
76
|
+
foundLatestFolder = true;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
sortFoldersByDate(chromeProfileFolders) {
|
|
80
|
+
return chromeProfileFolders.sort((a, b) => {
|
|
81
|
+
return Number.parseInt(b) - Number.parseInt(a);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* remove keys we don't need
|
|
86
|
+
*
|
|
87
|
+
* @param configString
|
|
88
|
+
* @private
|
|
89
|
+
*/
|
|
90
|
+
cleanUpLastConfig(configString) {
|
|
91
|
+
const config = JSON.parse(configString);
|
|
92
|
+
const newConfig = {};
|
|
93
|
+
for (const key in config) {
|
|
94
|
+
if (keysToRemove.has(key)) {
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
newConfig[key] = config[key];
|
|
98
|
+
}
|
|
99
|
+
return JSON.stringify(newConfig);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
exports.BrowserConfig = BrowserConfig;
|
|
@@ -32,8 +32,8 @@ class DiffAgainstCurrentPage {
|
|
|
32
32
|
originHtml = originDocumentHandlerResponse.body;
|
|
33
33
|
}
|
|
34
34
|
this.cli.endAction(cli_1.CliActionStatus.COMPLETED);
|
|
35
|
-
const remoteFilePath = await this.diffService.writeContentToTemporalFile(`remote-${variant}`, originHtml);
|
|
36
|
-
const localFilePath = await this.diffService.writeContentToTemporalFile("current", currentHtml);
|
|
35
|
+
const remoteFilePath = await this.diffService.writeContentToTemporalFile(`remote-${variant}.html`, originHtml);
|
|
36
|
+
const localFilePath = await this.diffService.writeContentToTemporalFile("current.html", currentHtml);
|
|
37
37
|
return await this.diffService.executeDiff(localFilePath, remoteFilePath);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
@@ -3,6 +3,7 @@ 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
4
|
const core_1 = require("@oclif/core");
|
|
5
5
|
const cli_parameters_1 = require("../../models/cli-parameters");
|
|
6
|
+
const browser_config_1 = require("./browser/config/browser-config");
|
|
6
7
|
const DEFAULT_BROWSER_ARGS = [
|
|
7
8
|
"--enable-features=Translate,NetworkService",
|
|
8
9
|
"--no-first-run",
|
|
@@ -57,6 +58,11 @@ class BrowserContext {
|
|
|
57
58
|
if (userConfig?.chromeUserProfilePath) {
|
|
58
59
|
browserArguments.push(`--user-data-dir=${userConfig?.chromeUserProfilePath}`);
|
|
59
60
|
}
|
|
61
|
+
else {
|
|
62
|
+
const browserConfig = new browser_config_1.BrowserConfig(this.userConfig);
|
|
63
|
+
const temporaryProfileDirectory = browserConfig.loadProfileTempDir();
|
|
64
|
+
browserArguments.push(`--user-data-dir=${temporaryProfileDirectory}`);
|
|
65
|
+
}
|
|
60
66
|
this.browserArgs = [
|
|
61
67
|
...browserArguments,
|
|
62
68
|
`--unsafely-treat-insecure-origin-as-secure=${domain}`,
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@speedkit/cli",
|
|
3
3
|
"description": "Speed Kit CLI",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.69.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Baqend.com",
|
|
7
7
|
"email": "info@baqend.com"
|
|
@@ -92,9 +92,7 @@
|
|
|
92
92
|
"parse5": "7.1",
|
|
93
93
|
"parse5-htmlparser2-tree-adapter": "7.0.0",
|
|
94
94
|
"puppeteer": "^22.6.5",
|
|
95
|
-
"puppeteer-core": "^22.6.5",
|
|
96
95
|
"puppeteer-extra": "^3.3.6",
|
|
97
|
-
"puppeteer-extra-plugin-user-preferences": "^2.4.1",
|
|
98
96
|
"strip-comments": "^2.0.1",
|
|
99
97
|
"uuid": "^9.0.1",
|
|
100
98
|
"esbuild": "^0.20.2",
|