@speedkit/cli 3.6.2 → 3.7.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 CHANGED
@@ -1,3 +1,22 @@
1
+ # [3.7.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v3.6.3...v3.7.0) (2025-10-10)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * clientPath missing for deployCommand ([5df90f1](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/5df90f10499d153e9c031b5b4d210ebc1a7e783a))
7
+
8
+
9
+ ### Features
10
+
11
+ * **onboarding:** dynamically install needed modules to run in localMode ([b7b41f1](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/b7b41f173b8bc7bc6061835c618013b9dc5bf8d5))
12
+
13
+ ## [3.6.3](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v3.6.2...v3.6.3) (2025-09-30)
14
+
15
+
16
+ ### Bug Fixes
17
+
18
+ * **onboarding:** test the variations using lowercase as we changed them to lowercase ([0c19e87](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/0c19e8719ec0d32caa085e9d739ac844e18c9447))
19
+
1
20
  ## [3.6.2](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v3.6.1...v3.6.2) (2025-09-24)
2
21
 
3
22
 
package/README.md CHANGED
@@ -21,7 +21,7 @@ $ npm install -g @speedkit/cli
21
21
  $ sk COMMAND
22
22
  running command...
23
23
  $ sk (--version)
24
- @speedkit/cli/3.6.2 linux-x64 node-v20.19.5
24
+ @speedkit/cli/3.7.0 linux-x64 node-v20.19.5
25
25
  $ sk --help [COMMAND]
26
26
  USAGE
27
27
  $ sk COMMAND
@@ -14,7 +14,7 @@ class Onboarding extends core_1.Command {
14
14
  ];
15
15
  async run() {
16
16
  const { args: { customerPath }, flags: { configName, domain, local, verboseLevel, ignoreContentSecurityPolicy, useTestConfig, }, } = await this.parse(Onboarding);
17
- const service = await new onboarding_1.OnboardingServiceFactory(new onboarding_1.OnboardingContext(customerPath, configName, domain, local, ignoreContentSecurityPolicy, this.config.root, verboseLevel, useTestConfig), new cli_config_1.CliConfig(this.config).load()).getService();
17
+ const service = await new onboarding_1.OnboardingServiceFactory(new onboarding_1.OnboardingContext(customerPath, configName, domain, local, ignoreContentSecurityPolicy, this.config.root, verboseLevel, useTestConfig), new cli_config_1.CliConfig(this.config).load(customerPath)).getService();
18
18
  await service.run();
19
19
  }
20
20
  }
@@ -10,12 +10,13 @@ export type UserCliConfig = {
10
10
  testApp: string;
11
11
  tempFolder: string;
12
12
  runtimeConfig: Config;
13
+ nodeModulesPath: string;
13
14
  };
14
15
  export declare class CliConfig {
15
16
  private config;
16
17
  private userCliConfig;
17
18
  constructor(config: Config);
18
- load(): UserCliConfig;
19
+ load(customerPath?: string): UserCliConfig;
19
20
  private createEmptyConfigFile;
20
21
  private createEmptyUserConfig;
21
22
  private getConfigFilePath;
@@ -4,7 +4,7 @@ exports.CliConfig = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const dotenv = tslib_1.__importStar(require("dotenv"));
6
6
  const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
7
- const node_path_1 = tslib_1.__importDefault(require("node:path"));
7
+ const node_path_1 = tslib_1.__importStar(require("node:path"));
8
8
  dotenv.config();
9
9
  const environmentMapping = {
10
10
  chromeExtensionPaths: "CHROME_EXTENSION_PATHS",
@@ -34,7 +34,7 @@ class CliConfig {
34
34
  constructor(config) {
35
35
  this.config = config;
36
36
  }
37
- load() {
37
+ load(customerPath) {
38
38
  // load config from configFile
39
39
  this.loadConfigFromConfigFile();
40
40
  // override config from environment
@@ -42,6 +42,7 @@ class CliConfig {
42
42
  this.resolveExtensionConfigPaths();
43
43
  this.userCliConfig.tempFolder = this.config.cacheDir;
44
44
  this.userCliConfig.runtimeConfig = this.config;
45
+ this.userCliConfig.nodeModulesPath = (0, node_path_1.resolve)(this.config.cacheDir, "additional_node_modules", customerPath || "");
45
46
  return this.userCliConfig;
46
47
  }
47
48
  createEmptyConfigFile() {
@@ -8,12 +8,13 @@ export declare class DocumentHandlerServer {
8
8
  private files;
9
9
  private bundler;
10
10
  private cli;
11
+ private nodeModulesPath;
11
12
  private verboseLevel;
12
13
  private entityManager?;
13
14
  private documentHandlerCode;
14
15
  private documentHandlerConfigCode;
15
16
  private database;
16
- constructor(customerConfig: CustomerConfig, files: FileListInterface, bundler: BundleService, cli: CliService, verboseLevel?: boolean, entityManager?: EntityManager);
17
+ constructor(customerConfig: CustomerConfig, files: FileListInterface, bundler: BundleService, cli: CliService, nodeModulesPath: string, verboseLevel?: boolean, entityManager?: EntityManager);
17
18
  transform(html: string, variation: string, url: string, headers: {
18
19
  [name: string]: string;
19
20
  }): Promise<DocumentHandlerResponse>;
@@ -36,10 +37,6 @@ export declare class DocumentHandlerServer {
36
37
  * Fetches and returns the latest dynamic fetcher from the code repository. If a new version is available online it is
37
38
  * downloaded and cached, otherwise the fetcher id returned from cache. The resulting module gets minified afterwards.
38
39
  *
39
- * @param {Map<string, string>} basePaths tha path mapping to resolve imports from
40
- * @param {string} dynamicFetcher the dynamic fetcher to bundle the config with
41
- *
42
- * @returns {Promise<string>} a Promise which resolves to the latest dynamic fetcher
43
40
  */
44
41
  bundleDynamicFetcher(basePaths: {
45
42
  [k: string]: string;
@@ -7,7 +7,7 @@ const required_file_not_found_error_1 = tslib_1.__importDefault(require("./error
7
7
  const database_mock_1 = tslib_1.__importDefault(require("./templates/database-mock"));
8
8
  const vm = tslib_1.__importStar(require("node:vm"));
9
9
  const cli_1 = require("../cli");
10
- const node_path_1 = tslib_1.__importDefault(require("node:path"));
10
+ const node_path_1 = tslib_1.__importStar(require("node:path"));
11
11
  const files_1 = require("../../models/files");
12
12
  // documentHandlerDependencies
13
13
  const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
@@ -21,16 +21,18 @@ class DocumentHandlerServer {
21
21
  files;
22
22
  bundler;
23
23
  cli;
24
+ nodeModulesPath;
24
25
  verboseLevel;
25
26
  entityManager;
26
27
  documentHandlerCode;
27
28
  documentHandlerConfigCode;
28
29
  database;
29
- constructor(customerConfig, files, bundler, cli, verboseLevel = false, entityManager) {
30
+ constructor(customerConfig, files, bundler, cli, nodeModulesPath, verboseLevel = false, entityManager) {
30
31
  this.customerConfig = customerConfig;
31
32
  this.files = files;
32
33
  this.bundler = bundler;
33
34
  this.cli = cli;
35
+ this.nodeModulesPath = nodeModulesPath;
34
36
  this.verboseLevel = verboseLevel;
35
37
  this.entityManager = entityManager;
36
38
  }
@@ -208,10 +210,17 @@ class DocumentHandlerServer {
208
210
  // eslint-disable-next-line @typescript-eslint/no-var-requires
209
211
  return require(module);
210
212
  }
211
- catch (error) {
212
- this.cli.writeError(`[documentHandler] could not load module: ${module}`);
213
- this.cli.writeError(error.message);
213
+ catch {
214
+ // do nothing
214
215
  }
216
+ try {
217
+ const additional = (0, node_path_1.resolve)(this.nodeModulesPath, "node_modules", module);
218
+ return require(additional);
219
+ }
220
+ catch {
221
+ // do nothing
222
+ }
223
+ this.cli.writeError(`[documentHandler] could not load module: ${module}`);
215
224
  };
216
225
  }
217
226
  createFetchMock() {
@@ -240,10 +249,6 @@ class DocumentHandlerServer {
240
249
  * Fetches and returns the latest dynamic fetcher from the code repository. If a new version is available online it is
241
250
  * downloaded and cached, otherwise the fetcher id returned from cache. The resulting module gets minified afterwards.
242
251
  *
243
- * @param {Map<string, string>} basePaths tha path mapping to resolve imports from
244
- * @param {string} dynamicFetcher the dynamic fetcher to bundle the config with
245
- *
246
- * @returns {Promise<string>} a Promise which resolves to the latest dynamic fetcher
247
252
  */
248
253
  async bundleDynamicFetcher(basePaths, dynamicFetcher) {
249
254
  return this.bundler.bundle({
@@ -18,4 +18,5 @@ export default class DocumentHandlerRuntimeServiceFactory {
18
18
  private preparePackageJson;
19
19
  private prepareTestCases;
20
20
  private getCustomerConfig;
21
+ private installAdditionalDependencies;
21
22
  }
@@ -10,6 +10,7 @@ const document_handler_server_1 = require("../document-handler-server");
10
10
  const bundler_1 = require("../../bundler");
11
11
  const entity_manager_factory_1 = require("../../config-api/entity-manager-factory");
12
12
  const safe_1 = require("../../../helpers/safe");
13
+ const node_fs_1 = require("node:fs");
13
14
  class DocumentHandlerRuntimeServiceFactory {
14
15
  context;
15
16
  cliConfig;
@@ -37,8 +38,9 @@ class DocumentHandlerRuntimeServiceFactory {
37
38
  const customerConfig = this.getCustomerConfig(files);
38
39
  const bundler = new bundler_1.BundleServiceFactory().buildService();
39
40
  const cliService = new cli_1.CliServiceFactory().getService();
41
+ await this.installAdditionalDependencies(customerConfig, cliService);
40
42
  const entityManagerResult = await (0, safe_1.safe)(new entity_manager_factory_1.EntityManagerFactory().getEntityManager(customerConfig.app));
41
- return new document_handler_server_1.DocumentHandlerServer(customerConfig, files, bundler, cliService, this.context.verboseLevel, entityManagerResult.success ? entityManagerResult.data : null);
43
+ return new document_handler_server_1.DocumentHandlerServer(customerConfig, files, bundler, cliService, this.cliConfig.nodeModulesPath, this.context.verboseLevel, entityManagerResult.success ? entityManagerResult.data : null);
42
44
  }
43
45
  prepareIntegrationApi() {
44
46
  const integrationApiContext = new integration_api_1.IntegrationApiContext(this.context.customerPath, this.context.configName, this.context.fileDependencies, [".git", ".idea", "node_modules"]);
@@ -100,5 +102,33 @@ class DocumentHandlerRuntimeServiceFactory {
100
102
  const configFile = files.getByName("config_customer");
101
103
  return configFile.config;
102
104
  }
105
+ async installAdditionalDependencies(customerConfig, cli) {
106
+ const workSpace = this.cliConfig.nodeModulesPath;
107
+ if (!customerConfig.dependencies ||
108
+ Object.keys(customerConfig.dependencies).length === 0) {
109
+ return;
110
+ }
111
+ const nypm = await import("nypm");
112
+ if (!(0, node_fs_1.existsSync)(workSpace)) {
113
+ (0, node_fs_1.mkdirSync)(workSpace, { recursive: true });
114
+ }
115
+ cli.write("install additional dependencies");
116
+ for (const packageName in customerConfig.dependencies) {
117
+ const version = customerConfig.dependencies[packageName];
118
+ const dependency = `${packageName}@${version}`;
119
+ cli.startAction(`install ${dependency}`);
120
+ const result = await (0, safe_1.safe)(nypm.addDependency(dependency, {
121
+ cwd: workSpace,
122
+ packageManager: "npm",
123
+ silent: true,
124
+ }));
125
+ if (result.success === true) {
126
+ cli.endAction(cli_1.CliActionStatus.COMPLETED);
127
+ continue;
128
+ }
129
+ cli.endAction(cli_1.CliActionStatus.FAILED);
130
+ cli.writeError(result.error);
131
+ }
132
+ }
103
133
  }
104
134
  exports.default = DocumentHandlerRuntimeServiceFactory;
@@ -36,13 +36,13 @@ class Crawler {
36
36
  this.cli.writeError(JSON.stringify(fetchResponse.errorObj));
37
37
  }
38
38
  setDefaultUserAgent(variation) {
39
- if (variation.includes("MOBILE")) {
39
+ if (variation.includes("mobile")) {
40
40
  return onboarding_model_1.USER_AGENT.MOBILE;
41
41
  }
42
- if (variation.includes("TABLET")) {
42
+ if (variation.includes("tablet")) {
43
43
  return onboarding_model_1.USER_AGENT.TABLET;
44
44
  }
45
- if (variation.includes("TV")) {
45
+ if (variation.includes("tv")) {
46
46
  return onboarding_model_1.USER_AGENT.TV;
47
47
  }
48
48
  return onboarding_model_1.USER_AGENT.DESKTOP;
@@ -732,5 +732,5 @@
732
732
  ]
733
733
  }
734
734
  },
735
- "version": "3.6.2"
735
+ "version": "3.7.0"
736
736
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@speedkit/cli",
3
3
  "description": "Speed Kit CLI",
4
- "version": "3.6.2",
4
+ "version": "3.7.0",
5
5
  "author": {
6
6
  "name": "Baqend.com",
7
7
  "email": "info@baqend.com"
@@ -92,6 +92,7 @@
92
92
  "iconv-lite": "^0.6.3",
93
93
  "json2csv": "^6.0.0-alpha.2",
94
94
  "node-fetch": "^2.7.0",
95
+ "nypm": "^0.6.2",
95
96
  "parse5": "7.1",
96
97
  "parse5-htmlparser2-tree-adapter": "7.0.0",
97
98
  "puppeteer": "^24.16.0",