@speedkit/cli 2.68.0 → 2.69.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 +22 -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/customer-config/customer-config-service.d.ts +0 -1
- package/dist/services/customer-config/customer-config-service.js +0 -25
- 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 +2 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
## [2.69.1](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.69.0...v2.69.1) (2024-12-11)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **axios:** remove unused axios dependency ([40f0238](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/40f023845a800667c284c63a1fafe816c3d42d12))
|
|
7
|
+
|
|
8
|
+
# [2.69.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.68.0...v2.69.0) (2024-12-11)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* createProfileFolder if not exists ([e820a45](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/e820a45f6c4398b646f609c6d072d8d7775e4ac9))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* create dynamic browserProfile from last session ([cce0f99](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/cce0f995fb6ee8d9c84818d93ef1db50a6bd7820))
|
|
19
|
+
* **diff:** add .html-extension so idea can have syntaxHighlighting ([748bc25](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/748bc2541a7d6b6a521b2eecf8e22666aefe68b4))
|
|
20
|
+
* load last browserConfig and create a fresh profile with it ([878a420](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/878a42027b15a43d59f438bc34a88f8b10a652e6))
|
|
21
|
+
* **onboarding:** filter unwanted configKeys from previous configs ([b3f08a0](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/b3f08a09d05fe6689fd826a03e5702559c5c6a68))
|
|
22
|
+
|
|
1
23
|
# [2.68.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.67.0...v2.68.0) (2024-12-11)
|
|
2
24
|
|
|
3
25
|
|
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() {
|
|
@@ -21,7 +21,6 @@ export declare class CustomerConfigService {
|
|
|
21
21
|
private compileHandlebarsFiles;
|
|
22
22
|
private getEnvironmentConfig;
|
|
23
23
|
private shouldFileBeOverwritten;
|
|
24
|
-
private downloadAndSaveFile;
|
|
25
24
|
private getConfigSettings;
|
|
26
25
|
logWarnings(configSettings: CustomerConfigSettings): Promise<void>;
|
|
27
26
|
generateConfig(): Promise<void>;
|
|
@@ -5,7 +5,6 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const fs = tslib_1.__importStar(require("node:fs"));
|
|
6
6
|
const path = tslib_1.__importStar(require("node:path"));
|
|
7
7
|
const Handlebars = tslib_1.__importStar(require("handlebars"));
|
|
8
|
-
const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
9
8
|
const cli_1 = require("../cli");
|
|
10
9
|
const customer_config_service_model_1 = require("./customer-config-service-model");
|
|
11
10
|
class CustomerConfigService {
|
|
@@ -136,30 +135,6 @@ class CustomerConfigService {
|
|
|
136
135
|
}
|
|
137
136
|
return true;
|
|
138
137
|
}
|
|
139
|
-
async downloadAndSaveFile(url, outputFilePath) {
|
|
140
|
-
this.cli.startAction(`Adding ${path.basename(outputFilePath)}`);
|
|
141
|
-
try {
|
|
142
|
-
if (!(await this.shouldFileBeOverwritten(outputFilePath))) {
|
|
143
|
-
this.cli.endAction(cli_1.CliActionStatus.SKIPPED);
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
const response = await axios_1.default.get(url, { responseType: "text" });
|
|
147
|
-
const date = new Date();
|
|
148
|
-
const day = String(date.getDate()).padStart(2, "0");
|
|
149
|
-
const month = String(date.getMonth() + 1).padStart(2, "0"); // Months are 0-indexed
|
|
150
|
-
const year = date.getFullYear();
|
|
151
|
-
const time = date.toLocaleTimeString("de-DE");
|
|
152
|
-
const formattedDate = `${day}.${month}.${year}, ${time}`;
|
|
153
|
-
// Add timestamp banner to the file
|
|
154
|
-
const banner = `/**\n * Downloaded from:\n * ${url}\n * \n * Date: ${formattedDate}\n */\n\n`;
|
|
155
|
-
const contentWithBanner = banner + response.data;
|
|
156
|
-
fs.writeFileSync(outputFilePath, contentWithBanner);
|
|
157
|
-
this.cli.endAction(cli_1.CliActionStatus.COMPLETED);
|
|
158
|
-
}
|
|
159
|
-
catch {
|
|
160
|
-
this.cli.endAction(cli_1.CliActionStatus.FAILED);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
138
|
async getConfigSettings() {
|
|
164
139
|
let { production, staging, subRouteScope, includeServiceWorker, activateImageOptimisation, removeLazyLoading, addPreRendering, supportShadowDomInPreRendering, shadowDomCustomElementPrefix, activateRumTracking, useGATracking, useScrapingBee, withGoogleOptimize, activateCfRocketLoaderWorkaround, hasSoftNavigations, isShopify, isShopware, isSalesforce, isPlentymarkets, shopifyId, } = {};
|
|
165
140
|
this.appName = await this.cli.prompt(`Enter SK App Name:`, {
|
|
@@ -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.1",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Baqend.com",
|
|
7
7
|
"email": "info@baqend.com"
|
|
@@ -72,8 +72,7 @@
|
|
|
72
72
|
"@oclif/plugin-help": "^6.2.16",
|
|
73
73
|
"@oclif/plugin-not-found": "^3.2.25",
|
|
74
74
|
"@oclif/plugin-warn-if-update-available": "^3.1.21",
|
|
75
|
-
"
|
|
76
|
-
"baqend": "^3.4",
|
|
75
|
+
"baqend": "^4.1.0",
|
|
77
76
|
"chalk": "^4.1.2",
|
|
78
77
|
"clipboardy-cjs": "^3.0.0",
|
|
79
78
|
"css-select": "5.1.0",
|
|
@@ -92,9 +91,7 @@
|
|
|
92
91
|
"parse5": "7.1",
|
|
93
92
|
"parse5-htmlparser2-tree-adapter": "7.0.0",
|
|
94
93
|
"puppeteer": "^22.6.5",
|
|
95
|
-
"puppeteer-core": "^22.6.5",
|
|
96
94
|
"puppeteer-extra": "^3.3.6",
|
|
97
|
-
"puppeteer-extra-plugin-user-preferences": "^2.4.1",
|
|
98
95
|
"strip-comments": "^2.0.1",
|
|
99
96
|
"uuid": "^9.0.1",
|
|
100
97
|
"esbuild": "^0.20.2",
|