@speedkit/cli 2.9.0 → 2.11.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.
Files changed (78) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +44 -63
  3. package/dist/commands/build-parameter-query.d.ts +4 -4
  4. package/dist/commands/build-parameter-query.js +38 -38
  5. package/dist/commands/build-prewarm-query.d.ts +4 -4
  6. package/dist/commands/build-prewarm-query.js +33 -34
  7. package/dist/commands/deploy.d.ts +4 -4
  8. package/dist/commands/deploy.js +14 -15
  9. package/dist/commands/find-pops.js +4 -4
  10. package/dist/commands/generate-pop-config.js +3 -3
  11. package/dist/commands/login.js +1 -1
  12. package/dist/commands/pop-prewarm.js +3 -3
  13. package/dist/commands/prewarm.js +4 -4
  14. package/dist/commands/wpt-launcher.js +2 -2
  15. package/dist/helpers/cli-config.d.ts +8 -7
  16. package/dist/helpers/cli-config.js +50 -44
  17. package/dist/models/cli-parameters.js +2 -2
  18. package/dist/services/cli/cli-service.d.ts +4 -4
  19. package/dist/services/config-api/client.js +1 -1
  20. package/dist/services/config-api-service.js +1 -1
  21. package/dist/services/deploy/context/deploy-context.d.ts +1 -4
  22. package/dist/services/deploy/context/deploy-context.js +6 -7
  23. package/dist/services/deploy/deploy-service-factory.d.ts +4 -5
  24. package/dist/services/deploy/deploy-service-factory.js +19 -18
  25. package/dist/services/integration-api/handler/customer-config-handler.d.ts +3 -3
  26. package/dist/services/integration-api/handler/customer-config-handler.js +21 -15
  27. package/dist/services/integration-api/struct/customer-config-file.d.ts +4 -3
  28. package/dist/services/integration-api/struct/customer-config-file.js +8 -6
  29. package/dist/services/onboarding/browser/abort-response.js +1 -1
  30. package/dist/services/onboarding/browser/baqend-response.d.ts +4 -4
  31. package/dist/services/onboarding/browser/baqend-response.js +33 -25
  32. package/dist/services/onboarding/browser/origin-response.d.ts +1 -1
  33. package/dist/services/onboarding/browser/origin-response.js +2 -3
  34. package/dist/services/onboarding/config-renderer/speed-kit-install-context.d.ts +4 -4
  35. package/dist/services/onboarding/config-renderer/speed-kit-install-context.js +44 -32
  36. package/dist/services/onboarding/dashboard/athena-service.d.ts +2 -2
  37. package/dist/services/onboarding/dashboard/athena-service.js +28 -23
  38. package/dist/services/onboarding/dashboard/index.d.ts +3 -3
  39. package/dist/services/onboarding/dashboard/index.js +48 -36
  40. package/dist/services/onboarding/dashboard/param-query-builder.d.ts +2 -2
  41. package/dist/services/onboarding/dashboard/param-query-builder.js +2 -2
  42. package/dist/services/onboarding/dashboard/request-diff-service.d.ts +1 -1
  43. package/dist/services/onboarding/dashboard/request-diff-service.js +32 -28
  44. package/dist/services/onboarding/fetch-event-handler.d.ts +6 -6
  45. package/dist/services/onboarding/fetch-event-handler.js +72 -62
  46. package/dist/services/onboarding/fetch-events/customer-domain-document-response.d.ts +8 -8
  47. package/dist/services/onboarding/fetch-events/customer-domain-document-response.js +51 -49
  48. package/dist/services/onboarding/fetch-events/customer-service-worker-js.d.ts +3 -3
  49. package/dist/services/onboarding/fetch-events/customer-service-worker-js.js +6 -6
  50. package/dist/services/onboarding/fetch-events/dashboard-request.d.ts +2 -2
  51. package/dist/services/onboarding/fetch-events/dashboard-request.js +3 -3
  52. package/dist/services/onboarding/fetch-events/speed-kit-asset-request.d.ts +7 -7
  53. package/dist/services/onboarding/fetch-events/speed-kit-asset-request.js +76 -59
  54. package/dist/services/onboarding/fetch-events/speed-kit-install-html.d.ts +3 -3
  55. package/dist/services/onboarding/fetch-events/speed-kit-install-html.js +14 -14
  56. package/dist/services/onboarding/fetch-events/speed-kit-install-js.d.ts +6 -6
  57. package/dist/services/onboarding/fetch-events/speed-kit-install-js.js +12 -10
  58. package/dist/services/onboarding/fetch-events/speed-kit-rum-pi-request.d.ts +7 -7
  59. package/dist/services/onboarding/fetch-events/speed-kit-rum-pi-request.js +3 -3
  60. package/dist/services/onboarding/fetch-events/speed-kit-service-worker-js.d.ts +4 -4
  61. package/dist/services/onboarding/fetch-events/speed-kit-service-worker-js.js +6 -4
  62. package/dist/services/onboarding/file-events/{fileWatcher.d.ts → file-watcher.d.ts} +9 -8
  63. package/dist/services/onboarding/file-events/{fileWatcher.js → file-watcher.js} +74 -56
  64. package/dist/services/onboarding/index.d.ts +3 -3
  65. package/dist/services/onboarding/onboarding-model.d.ts +36 -34
  66. package/dist/services/onboarding/onboarding-model.js +19 -19
  67. package/dist/services/onboarding/onboarding-service-factory.d.ts +6 -6
  68. package/dist/services/onboarding/onboarding-service-factory.js +80 -75
  69. package/dist/services/onboarding/onboarding-service.d.ts +7 -7
  70. package/dist/services/onboarding/onboarding-service.js +54 -48
  71. package/dist/services/onboarding/request-cache/cache.d.ts +3 -3
  72. package/dist/services/onboarding/request-cache/cache.js +7 -7
  73. package/dist/services/onboarding/server-config/index.js +2 -2
  74. package/dist/services/onboarding/todo-collector.d.ts +1 -1
  75. package/dist/services/onboarding/todo-collector.js +8 -6
  76. package/dist/services/prewarm-service.js +2 -2
  77. package/oclif.manifest.json +9 -9
  78. package/package.json +24 -23
@@ -3,83 +3,89 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CliConfig = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const dotenv = tslib_1.__importStar(require("dotenv"));
6
- const fs_1 = tslib_1.__importDefault(require("fs"));
7
- const path_1 = tslib_1.__importDefault(require("path"));
6
+ const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
7
+ const node_path_1 = tslib_1.__importDefault(require("node:path"));
8
8
  dotenv.config();
9
9
  const envMapping = {
10
+ chromeExtensionPaths: "CHROME_EXTENSION_PATHS",
10
11
  chromePath: "CHROME_PATH",
11
12
  chromeUserProfilePath: "CHROME_USER_PROFILE_PATH",
12
- slackToken: "SLACK_TOKEN",
13
- speedKitBrowserExtensionPath: "SPEED_KIT_EXTENSION_PATH",
14
- testApp: "TEST_APP",
15
- ideaDirectory: "IDEA_INITIAL_DIRECTORY",
16
13
  diffExec: "DIFF_EXEC",
17
14
  diffExecTemplate: "DIFF_EXEC_TEMPLATE",
15
+ ideaDirectory: "IDEA_INITIAL_DIRECTORY",
16
+ slackToken: "SLACK_TOKEN",
17
+ testApp: "TEST_APP",
18
18
  };
19
19
  const CONFIG_FILE_NAME = "config.json";
20
20
  class CliConfig {
21
21
  config;
22
22
  userCliConfig = {
23
+ chromeExtensionPaths: "",
23
24
  chromePath: "",
24
25
  chromeUserProfilePath: "",
25
- slackToken: "",
26
- speedKitBrowserExtensionPath: "",
27
- testApp: "",
28
- ideaDirectory: "",
29
26
  diffExec: "",
30
27
  diffExecTemplate: "$exec $file1 $file2",
28
+ ideaDirectory: "",
29
+ slackToken: "",
30
+ testApp: "",
31
31
  };
32
32
  constructor(config) {
33
33
  this.config = config;
34
34
  }
35
35
  load() {
36
- this.loadConfigFromEnvironment();
36
+ // load config from configFile
37
37
  this.loadConfigFromConfigFile();
38
+ // override config from environment
39
+ this.loadConfigFromEnvironment();
38
40
  return this.userCliConfig;
39
41
  }
40
- loadConfigFromEnvironment() {
41
- for (const key in this.userCliConfig) {
42
- const envVar = envMapping[key];
43
- if (envVar in process.env && process.env[envVar].length > 0) {
44
- this.userCliConfig[key] = process.env[envVar];
45
- }
46
- }
42
+ createEmptyConfigFile() {
43
+ node_fs_1.default.mkdirSync(node_path_1.default.resolve(this.config.configDir), { recursive: true });
44
+ node_fs_1.default.writeFileSync(this.getConfigFilePath(), JSON.stringify(this.createEmptyUserConfig(), null, `\t`));
45
+ }
46
+ createEmptyUserConfig() {
47
+ return {
48
+ chromeExtensionPaths: "",
49
+ chromePath: "",
50
+ chromeUserProfilePath: "",
51
+ diffExec: "",
52
+ ideaDirectory: "",
53
+ slackToken: "",
54
+ testApp: "",
55
+ };
47
56
  }
48
57
  getConfigFilePath() {
49
- return path_1.default.resolve(this.config.configDir, CONFIG_FILE_NAME);
58
+ return node_path_1.default.resolve(this.config.configDir, CONFIG_FILE_NAME);
50
59
  }
51
60
  loadConfigFromConfigFile() {
52
- if (!fs_1.default.existsSync(this.getConfigFilePath())) {
53
- this.createEmptyConfigFile();
61
+ const configJson = this.readCliConfigFromFile();
62
+ if (!configJson) {
54
63
  return;
55
64
  }
56
- const configFileContent = fs_1.default.readFileSync(this.getConfigFilePath(), 'utf8');
57
- try {
58
- const configJson = JSON.parse(configFileContent);
59
- for (const key in configJson) {
60
- if (configJson[key].length > 0) {
61
- this.userCliConfig[key] = configJson[key];
62
- }
65
+ for (const configKey in this.userCliConfig) {
66
+ if (configKey in configJson && configJson[configKey].length > 0) {
67
+ this.userCliConfig[configKey] = configJson[configKey];
63
68
  }
64
- return;
65
- }
66
- catch (error) {
67
69
  }
68
70
  }
69
- createEmptyConfigFile() {
70
- fs_1.default.mkdirSync(path_1.default.resolve(this.config.configDir), { recursive: true });
71
- fs_1.default.writeFileSync(this.getConfigFilePath(), JSON.stringify(this.createEmptyUserConfig(), null, `\t`));
71
+ loadConfigFromEnvironment() {
72
+ for (const configKey in this.userCliConfig) {
73
+ if (!(configKey in envMapping)) {
74
+ continue;
75
+ }
76
+ const envVar = envMapping[configKey];
77
+ if (envVar in process.env && process.env[envVar].length > 0) {
78
+ this.userCliConfig[configKey] = process.env[envVar];
79
+ }
80
+ }
72
81
  }
73
- createEmptyUserConfig() {
74
- return {
75
- chromePath: "",
76
- chromeUserProfilePath: "",
77
- slackToken: "",
78
- speedKitBrowserExtensionPath: "",
79
- testApp: "",
80
- ideaDirectory: "",
81
- diffExec: "",
82
- };
82
+ readCliConfigFromFile() {
83
+ if (!node_fs_1.default.existsSync(this.getConfigFilePath())) {
84
+ this.createEmptyConfigFile();
85
+ return;
86
+ }
87
+ const configFileContent = node_fs_1.default.readFileSync(this.getConfigFilePath(), "utf8");
88
+ return JSON.parse(configFileContent);
83
89
  }
84
90
  }
85
91
  exports.CliConfig = CliConfig;
@@ -75,8 +75,8 @@ exports.CLI_CONFIG_NAME = {
75
75
  };
76
76
  exports.CLI_CUSTOMER_CONFIG = {
77
77
  [CLIParameters.CustomerPath]: core_1.Args.directory({
78
- name: CLIParameters.CustomerPath,
79
- required: true,
78
+ name: CLIParameters.CustomerPath, // name of arg to show in help and reference with args[name]
79
+ required: true, // make the arg required with `required: true`
80
80
  description: 'The customer config path', // help description
81
81
  }),
82
82
  };
@@ -6,10 +6,10 @@ export declare class CliService implements CliServiceInterface {
6
6
  style: chalk.Chalk & chalk.ChalkFunction & {
7
7
  supportsColor: false | chalk.ColorSupport;
8
8
  Level: chalk.Level;
9
- Color: ("black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white" | "gray" | "grey" | "blackBright" | "redBright" | "greenBright" | "yellowBright" | "blueBright" | "magentaBright" | "cyanBright" | "whiteBright") | ("bgBlack" | "bgRed" | "bgGreen" | "bgYellow" | "bgBlue" | "bgMagenta" | "bgCyan" | "bgWhite" | "bgGray" | "bgGrey" | "bgBlackBright" | "bgRedBright" | "bgGreenBright" | "bgYellowBright" | "bgBlueBright" | "bgMagentaBright" | "bgCyanBright" | "bgWhiteBright");
10
- ForegroundColor: "black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white" | "gray" | "grey" | "blackBright" | "redBright" | "greenBright" | "yellowBright" | "blueBright" | "magentaBright" | "cyanBright" | "whiteBright";
11
- BackgroundColor: "bgBlack" | "bgRed" | "bgGreen" | "bgYellow" | "bgBlue" | "bgMagenta" | "bgCyan" | "bgWhite" | "bgGray" | "bgGrey" | "bgBlackBright" | "bgRedBright" | "bgGreenBright" | "bgYellowBright" | "bgBlueBright" | "bgMagentaBright" | "bgCyanBright" | "bgWhiteBright";
12
- Modifiers: "hidden" | "bold" | "reset" | "dim" | "italic" | "underline" | "inverse" | "strikethrough" | "visible";
9
+ Color: ("white" | "black" | "blue" | "yellow" | "green" | "red" | "magenta" | "cyan" | "gray" | "blackBright" | "redBright" | "greenBright" | "yellowBright" | "blueBright" | "magentaBright" | "cyanBright" | "whiteBright" | "grey") | ("bgBlack" | "bgRed" | "bgGreen" | "bgYellow" | "bgBlue" | "bgMagenta" | "bgCyan" | "bgWhite" | "bgGray" | "bgBlackBright" | "bgRedBright" | "bgGreenBright" | "bgYellowBright" | "bgBlueBright" | "bgMagentaBright" | "bgCyanBright" | "bgWhiteBright" | "bgGrey");
10
+ ForegroundColor: "white" | "black" | "blue" | "yellow" | "green" | "red" | "magenta" | "cyan" | "gray" | "blackBright" | "redBright" | "greenBright" | "yellowBright" | "blueBright" | "magentaBright" | "cyanBright" | "whiteBright" | "grey";
11
+ BackgroundColor: "bgBlack" | "bgRed" | "bgGreen" | "bgYellow" | "bgBlue" | "bgMagenta" | "bgCyan" | "bgWhite" | "bgGray" | "bgBlackBright" | "bgRedBright" | "bgGreenBright" | "bgYellowBright" | "bgBlueBright" | "bgMagentaBright" | "bgCyanBright" | "bgWhiteBright" | "bgGrey";
12
+ Modifiers: "bold" | "hidden" | "underline" | "dim" | "italic" | "strikethrough" | "visible" | "reset" | "inverse";
13
13
  stderr: chalk.Chalk & {
14
14
  supportsColor: false | chalk.ColorSupport;
15
15
  };
@@ -5,7 +5,7 @@ const https_1 = require("https");
5
5
  const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
6
6
  const deepmerge_1 = tslib_1.__importDefault(require("deepmerge"));
7
7
  const race_1 = require("../../helpers/race");
8
- const REQUEST_TIMEOUT = 10000;
8
+ const REQUEST_TIMEOUT = 10_000;
9
9
  const CONTENT_TYPE = 'application/json;charset=UTF-8';
10
10
  class Client {
11
11
  entityManagerFactory;
@@ -24,7 +24,7 @@ class ConfigApiService {
24
24
  authorization: `BAT ${this.db.token}`,
25
25
  'Content-Type': 'application/json;charset=UTF-8',
26
26
  },
27
- timeout: 10000,
27
+ timeout: 10_000,
28
28
  };
29
29
  }
30
30
  async fetchActiveInstall(configName) {
@@ -2,11 +2,8 @@ export default class DeployContext {
2
2
  readonly customerPath: string;
3
3
  readonly configName: string;
4
4
  readonly slackToken?: string;
5
+ readonly dryRun: boolean;
5
6
  readonly artifacts?: string[];
6
- readonly dryRun?: boolean;
7
- runTime: {
8
- app: string;
9
- };
10
7
  constructor(customerPath: string, configName?: string, slackToken?: string, artifacts?: string, dryRun?: boolean);
11
8
  hasArtifacts(): boolean;
12
9
  }
@@ -3,21 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const dotenv = tslib_1.__importStar(require("dotenv"));
5
5
  dotenv.config();
6
- const DEFAULT_CONFIG_NAME = 'production';
7
- const ARTIFACTS_SEPARATOR = ',';
6
+ const DEFAULT_CONFIG_NAME = "production";
7
+ const ARTIFACTS_SEPARATOR = ",";
8
8
  class DeployContext {
9
9
  customerPath;
10
10
  configName;
11
11
  slackToken;
12
+ dryRun;
12
13
  artifacts;
13
- dryRun = false;
14
- runTime = { app: undefined };
15
- constructor(customerPath, configName = DEFAULT_CONFIG_NAME, slackToken, artifacts, dryRun) {
14
+ constructor(customerPath, configName = DEFAULT_CONFIG_NAME, slackToken, artifacts, dryRun = false) {
16
15
  this.customerPath = customerPath;
17
16
  this.configName = configName;
18
- this.slackToken = slackToken || process.env.SLACK_TOKEN || undefined;
19
- this.artifacts = artifacts ? artifacts.split(ARTIFACTS_SEPARATOR) : [];
17
+ this.slackToken = slackToken;
20
18
  this.dryRun = dryRun;
19
+ this.artifacts = artifacts ? artifacts.split(ARTIFACTS_SEPARATOR) : [];
21
20
  }
22
21
  hasArtifacts() {
23
22
  return this.artifacts?.length > 0;
@@ -1,13 +1,12 @@
1
- import DeployService from "./deploy-service";
2
- import DeployContext from "./context/deploy-context";
3
- import AbstractAsyncErrorHandlingFactory from "../error-handling/abstract/abstract-async-error-handling-factory";
4
1
  import { UserCliConfig } from "../../helpers/cli-config";
5
- export default class DeployServiceFactory extends AbstractAsyncErrorHandlingFactory {
2
+ import DeployContext from "./context/deploy-context";
3
+ import DeployService from "./deploy-service";
4
+ export default class DeployServiceFactory {
6
5
  private context;
7
6
  private cliConfig;
8
7
  private service?;
9
8
  constructor(context: DeployContext, cliConfig: UserCliConfig);
10
- _buildService(): Promise<DeployService>;
9
+ buildService(): Promise<DeployService>;
11
10
  private build;
12
11
  private getConfigApi;
13
12
  private getIntegrationFiles;
@@ -1,33 +1,31 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- const deploy_service_1 = tslib_1.__importDefault(require("./deploy-service"));
5
- const integration_api_context_1 = tslib_1.__importDefault(require("../integration-api/context/integration-api-context"));
6
- const integration_api_service_factory_1 = tslib_1.__importDefault(require("../integration-api/factory/integration-api-service-factory"));
7
- const config_api_service_factory_1 = tslib_1.__importDefault(require("../config-api/factory/config-api-service-factory"));
4
+ const cli_1 = require("../cli");
8
5
  const config_api_context_1 = tslib_1.__importDefault(require("../config-api/context/config-api-context"));
9
- const install_resource_handler_1 = tslib_1.__importDefault(require("./handler/install-resource-handler"));
10
- const customer_config_handler_1 = tslib_1.__importDefault(require("./handler/customer-config-handler"));
6
+ const config_api_service_factory_1 = tslib_1.__importDefault(require("../config-api/factory/config-api-service-factory"));
11
7
  const diff_1 = require("../diff");
12
- const cli_1 = require("../cli");
8
+ const integration_api_context_1 = tslib_1.__importDefault(require("../integration-api/context/integration-api-context"));
9
+ const integration_api_service_factory_1 = tslib_1.__importDefault(require("../integration-api/factory/integration-api-service-factory"));
13
10
  const install_resource_builder_1 = tslib_1.__importDefault(require("./builder/install-resource-builder"));
14
- const module_handler_1 = tslib_1.__importDefault(require("./handler/module-handler"));
15
- const server_config_handler_1 = tslib_1.__importDefault(require("./handler/server-config-handler"));
16
- const deployment_detection_modifier_1 = tslib_1.__importDefault(require("./handler/module-modifier/deployment-detection-modifier"));
17
- const abstract_async_error_handling_factory_1 = tslib_1.__importDefault(require("../error-handling/abstract/abstract-async-error-handling-factory"));
18
- const save_files_check_1 = tslib_1.__importDefault(require("./checks/post-deploy/save-files-check"));
19
11
  const revalidated_module_check_1 = tslib_1.__importDefault(require("./checks/post-deploy/revalidated-module-check"));
12
+ const save_files_check_1 = tslib_1.__importDefault(require("./checks/post-deploy/save-files-check"));
13
+ const deploy_service_1 = tslib_1.__importDefault(require("./deploy-service"));
14
+ const customer_config_handler_1 = tslib_1.__importDefault(require("./handler/customer-config-handler"));
15
+ const install_resource_handler_1 = tslib_1.__importDefault(require("./handler/install-resource-handler"));
20
16
  const deleted_file_check_1 = tslib_1.__importDefault(require("./handler/install-resource-modifier/deleted-file-check"));
21
- class DeployServiceFactory extends abstract_async_error_handling_factory_1.default {
17
+ const module_handler_1 = tslib_1.__importDefault(require("./handler/module-handler"));
18
+ const deployment_detection_modifier_1 = tslib_1.__importDefault(require("./handler/module-modifier/deployment-detection-modifier"));
19
+ const server_config_handler_1 = tslib_1.__importDefault(require("./handler/server-config-handler"));
20
+ class DeployServiceFactory {
22
21
  context;
23
22
  cliConfig;
24
23
  service = undefined;
25
24
  constructor(context, cliConfig) {
26
- super();
27
25
  this.context = context;
28
26
  this.cliConfig = cliConfig;
29
27
  }
30
- async _buildService() {
28
+ async buildService() {
31
29
  if (!(this.service instanceof deploy_service_1.default)) {
32
30
  await this.build();
33
31
  }
@@ -42,11 +40,14 @@ class DeployServiceFactory extends abstract_async_error_handling_factory_1.defau
42
40
  const cliService = new cli_1.CliServiceFactory().getService();
43
41
  const installResourceBuilder = new install_resource_builder_1.default(configApi);
44
42
  const deletedFilesChecker = new deleted_file_check_1.default(cliService, this.context.hasArtifacts());
43
+ const slackToken = this.context.slackToken || this.cliConfig.slackToken;
45
44
  this.service = new deploy_service_1.default(files, [
46
45
  new customer_config_handler_1.default(customer, configApi, configName, diffService, cliService, installResourceBuilder),
47
46
  new install_resource_handler_1.default(customer, configApi, configName, diffService, cliService, installResourceBuilder, deletedFilesChecker),
48
- new module_handler_1.default(configApi, diffService, cliService, [new deployment_detection_modifier_1.default(this.context.slackToken)]),
49
- new server_config_handler_1.default(configApi, diffService, cliService)
47
+ new module_handler_1.default(configApi, diffService, cliService, [
48
+ new deployment_detection_modifier_1.default(slackToken),
49
+ ]),
50
+ new server_config_handler_1.default(configApi, diffService, cliService),
50
51
  ], cliService, this.getPostDeployChecks(files, cliService, configApi, customer.app), this.context.dryRun);
51
52
  }
52
53
  getConfigApi(app) {
@@ -56,7 +57,7 @@ class DeployServiceFactory extends abstract_async_error_handling_factory_1.defau
56
57
  async getIntegrationFiles() {
57
58
  const integrationApiContext = new integration_api_context_1.default(this.context.customerPath, this.context.configName, this.context.artifacts);
58
59
  const integrationApi = new integration_api_service_factory_1.default(integrationApiContext, this.cliConfig).buildService();
59
- return await integrationApi.run();
60
+ return integrationApi.run();
60
61
  }
61
62
  getPostDeployChecks(files, cliService, configApi, app) {
62
63
  return [
@@ -1,8 +1,8 @@
1
- import FileHandler from "./file-handler";
2
- import FileReader from "../file-reader";
3
- import CustomerConfigValidator from "../validator/customer-config-validator";
4
1
  import { CliService } from "../../cli";
2
+ import FileReader from "../file-reader";
5
3
  import { CustomerConfigInterface } from "../integration-api-model";
4
+ import CustomerConfigValidator from "../validator/customer-config-validator";
5
+ import FileHandler from "./file-handler";
6
6
  export default class CustomerConfigHandler extends FileHandler {
7
7
  private cli;
8
8
  private validator;
@@ -1,18 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- const file_handler_1 = tslib_1.__importDefault(require("./file-handler"));
5
- const customer_config_file_1 = tslib_1.__importDefault(require("../struct/customer-config-file"));
6
- const customer_config_1 = tslib_1.__importDefault(require("../struct/customer-config"));
7
- const customer_config_legacy_error_1 = tslib_1.__importDefault(require("../error/customer-config-legacy-error"));
8
- const vm = tslib_1.__importStar(require("vm"));
4
+ const vm = tslib_1.__importStar(require("node:vm"));
9
5
  const customer_config_error_1 = tslib_1.__importDefault(require("../error/customer-config-error"));
6
+ const customer_config_legacy_error_1 = tslib_1.__importDefault(require("../error/customer-config-legacy-error"));
7
+ const customer_config_1 = tslib_1.__importDefault(require("../struct/customer-config"));
8
+ const customer_config_file_1 = tslib_1.__importDefault(require("../struct/customer-config-file"));
9
+ const file_handler_1 = tslib_1.__importDefault(require("./file-handler"));
10
10
  class CustomerConfigHandler extends file_handler_1.default {
11
11
  cli;
12
12
  validator;
13
13
  configName;
14
14
  testApp;
15
- allowedFile = 'config_customer';
15
+ allowedFile = "config_customer";
16
16
  constructor(fileReader, cli, validator, configName, testApp) {
17
17
  super(fileReader);
18
18
  this.cli = cli;
@@ -27,28 +27,34 @@ class CustomerConfigHandler extends file_handler_1.default {
27
27
  const fileContent = await this.fileReader.getContent(filePath);
28
28
  const config = await this.loadConfig(fileContent);
29
29
  this.validator.validate(config);
30
- return new customer_config_file_1.default(this.getFileName(filePath), filePath, fileContent, config, this.configName);
30
+ return new customer_config_file_1.default(this.getFileName(filePath), filePath, fileContent, config, this.configName, this.testApp);
31
31
  }
32
32
  async loadConfig(fileContent) {
33
- if (fileContent.includes('process.env.TEST_APP') && (this.testApp === null) || this.testApp.length === 0) {
34
- throw new customer_config_error_1.default('please specify env TEST_APP in your .env or configFile file');
33
+ if ((fileContent.includes("process.env.TEST_APP") && this.testApp === null) ||
34
+ this.testApp.length === 0) {
35
+ throw new customer_config_error_1.default("please specify env TEST_APP in your .env or configFile file");
35
36
  }
36
37
  const customerConfigContext = {
37
- module: { exports: {} },
38
+ module: { exports: {} }, // make TEST_APP available for vm
38
39
  process: {
39
- env: { TEST_APP: this.testApp } // make TEST_APP available for vm
40
- }
40
+ env: { TEST_APP: this.testApp }, // make TEST_APP available for vm
41
+ },
41
42
  };
42
43
  vm.runInNewContext(fileContent, customerConfigContext);
43
44
  const configs = customerConfigContext?.module?.exports;
44
- if (Array.isArray(configs) || typeof configs === 'string' || 'origins' in configs || 'name' in configs) {
45
- throw new customer_config_legacy_error_1.default({ configName: this.configName });
45
+ if (Array.isArray(configs) ||
46
+ typeof configs === "string" ||
47
+ "origins" in configs ||
48
+ "name" in configs) {
49
+ throw new customer_config_legacy_error_1.default({
50
+ configName: this.configName,
51
+ });
46
52
  }
47
53
  if (this.configName in configs) {
48
54
  return customer_config_1.default.createFrom(configs[this.configName], this.configName);
49
55
  }
50
56
  this.cli.writeWarning(`config: ${this.configName} does not exist.`);
51
- const selectedConfig = await this.cli.select('please select config: ', Object.keys(configs).map(option => ({ name: option, value: option })));
57
+ const selectedConfig = await this.cli.select("please select config: ", Object.keys(configs).map((option) => ({ name: option, value: option })));
52
58
  return customer_config_1.default.createFrom(configs[selectedConfig], selectedConfig);
53
59
  }
54
60
  }
@@ -1,10 +1,11 @@
1
- import File from "./file";
2
- import CustomerConfig from "./customer-config";
3
1
  import { CustomerConfigInterface } from "../integration-api-model";
2
+ import CustomerConfig from "./customer-config";
3
+ import File from "./file";
4
4
  export default class CustomerConfigFile extends File implements CustomerConfigInterface {
5
5
  config: CustomerConfig;
6
6
  readonly configName: string;
7
- constructor(name: string, path: string, content: string, config: CustomerConfig, configName: string);
7
+ readonly testApp?: string;
8
+ constructor(name: string, path: string, content: string, config: CustomerConfig, configName: string, testApp?: string);
8
9
  setContent(content: string): void;
9
10
  private updateConfigByContent;
10
11
  }
@@ -1,16 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- const file_1 = tslib_1.__importDefault(require("./file"));
4
+ const vm = tslib_1.__importStar(require("node:vm"));
5
5
  const customer_config_1 = tslib_1.__importDefault(require("./customer-config"));
6
- const vm = tslib_1.__importStar(require("vm"));
6
+ const file_1 = tslib_1.__importDefault(require("./file"));
7
7
  class CustomerConfigFile extends file_1.default {
8
8
  config;
9
9
  configName;
10
- constructor(name, path, content, config, configName) {
10
+ testApp;
11
+ constructor(name, path, content, config, configName, testApp) {
11
12
  super(name, path, content, CustomerConfigFile);
12
13
  this.config = config;
13
14
  this.configName = configName;
15
+ this.testApp = testApp;
14
16
  }
15
17
  setContent(content) {
16
18
  super.setContent(content);
@@ -18,10 +20,10 @@ class CustomerConfigFile extends file_1.default {
18
20
  }
19
21
  updateConfigByContent() {
20
22
  const customerConfigContext = {
21
- module: { exports: {} },
23
+ module: { exports: {} }, // make TEST_APP available for vm
22
24
  process: {
23
- env: { TEST_APP: process.env.TEST_APP } // make TEST_APP available for vm
24
- }
25
+ env: { TEST_APP: this.testApp }, // make TEST_APP available for vm
26
+ },
25
27
  };
26
28
  vm.runInNewContext(this.getContent(), customerConfigContext);
27
29
  if (this.configName in customerConfigContext.module.exports) {
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AbortResponse = void 0;
4
4
  class AbortResponse {
5
5
  errorReason;
6
- constructor(errorReason = 'Aborted') {
6
+ constructor(errorReason = "Aborted") {
7
7
  this.errorReason = errorReason;
8
8
  }
9
9
  }
@@ -1,12 +1,12 @@
1
- import Protocol from 'devtools-protocol';
1
+ import Protocol from "devtools-protocol";
2
2
  export declare class BaqendResponse implements Partial<Protocol.Fetch.FulfillRequestRequest> {
3
+ readonly body: string;
3
4
  readonly requestId?: string;
4
5
  readonly responseCode: number;
5
- readonly body: string;
6
6
  responseHeaders: Protocol.Fetch.HeaderEntry[];
7
- private contentType;
8
7
  private contentLength;
8
+ private contentType;
9
9
  constructor(body: string, contentType?: string, headers?: Protocol.Fetch.HeaderEntry[], status?: number);
10
- setHeader(name: string, value: string): void;
11
10
  protected addCustomHeaders(headers?: Protocol.Fetch.HeaderEntry[]): Protocol.Fetch.HeaderEntry[];
11
+ setHeader(name: string, value: string): void;
12
12
  }
@@ -2,24 +2,50 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BaqendResponse = void 0;
4
4
  const DEFAULT_HEADERS = [
5
- { name: 'Date', value: new Date().toUTCString() },
6
- { name: 'Content-Encoding', value: 'identity' }
5
+ { name: "Date", value: new Date().toUTCString() },
6
+ { name: "Content-Encoding", value: "identity" },
7
7
  ];
8
- const DEFAULT_CONTENT_TYPE = 'text/html; charset=utf-8';
8
+ const DEFAULT_CONTENT_TYPE = "text/html; charset=utf-8";
9
9
  const DEFAULT_STATUS = 200;
10
10
  class BaqendResponse {
11
+ body;
11
12
  requestId;
12
13
  responseCode;
13
- body;
14
14
  responseHeaders;
15
- contentType;
16
15
  contentLength;
16
+ contentType;
17
17
  constructor(body, contentType, headers, status) {
18
18
  this.responseCode = status || DEFAULT_STATUS;
19
19
  this.contentType = contentType || DEFAULT_CONTENT_TYPE;
20
- this.responseHeaders = this.addCustomHeaders([...DEFAULT_HEADERS, ...headers || []]);
20
+ this.responseHeaders = this.addCustomHeaders([
21
+ ...DEFAULT_HEADERS,
22
+ ...(headers || []),
23
+ ]);
21
24
  this.contentLength = body.length;
22
- this.body = Buffer.from(body).toString('base64');
25
+ this.body = Buffer.from(body).toString("base64");
26
+ }
27
+ addCustomHeaders(headers) {
28
+ if (!headers?.find((o) => o.name === "Cache-Control")) {
29
+ headers.push({
30
+ name: "Cache-Control",
31
+ value: "max-age=0, nocache, nostore",
32
+ });
33
+ }
34
+ const origin = headers?.find((o) => o.name.toLowerCase() === "origin")?.value;
35
+ if (origin) {
36
+ headers.push({ name: "Access-Control-Allow-Origin", value: origin });
37
+ }
38
+ if (!headers?.find((o) => o.name === "Content-Length")) {
39
+ headers.push({
40
+ name: "Content-Length",
41
+ value: String(this.contentLength),
42
+ });
43
+ }
44
+ if (!headers?.find((o) => o.name === "Content-Type")) {
45
+ headers.push({ name: "Content-Type", value: String(this.contentType) });
46
+ }
47
+ headers.push({ name: "via", value: "sk-onboarding" }, { name: "Service-Worker-Allowed", value: "/" });
48
+ return headers;
23
49
  }
24
50
  setHeader(name, value) {
25
51
  for (const header of this.responseHeaders) {
@@ -30,23 +56,5 @@ class BaqendResponse {
30
56
  }
31
57
  this.responseHeaders.push({ name, value });
32
58
  }
33
- addCustomHeaders(headers) {
34
- if (!headers?.find((o) => o.name === 'Cache-Control')) {
35
- headers.push({ name: 'Cache-Control', value: 'max-age=0, nocache, nostore' });
36
- }
37
- const origin = headers?.find((o) => o.name.toLowerCase() === 'origin')?.value;
38
- if (origin) {
39
- headers.push({ name: 'Access-Control-Allow-Origin', value: origin });
40
- }
41
- if (!headers?.find((o) => o.name === 'Content-Length')) {
42
- headers.push({ name: 'Content-Length', value: String(this.contentLength) });
43
- }
44
- if (!headers?.find((o) => o.name === 'Content-Type')) {
45
- headers.push({ name: 'Content-Type', value: String(this.contentType) });
46
- }
47
- headers.push({ name: 'via', value: 'sk-onboarding' });
48
- headers.push({ name: 'Service-Worker-Allowed', value: '/' });
49
- return headers;
50
- }
51
59
  }
52
60
  exports.BaqendResponse = BaqendResponse;
@@ -1,4 +1,4 @@
1
- import Protocol from 'devtools-protocol';
1
+ import Protocol from "devtools-protocol";
2
2
  export declare class OriginResponse implements Partial<Protocol.Fetch.FulfillRequestRequest> {
3
3
  readonly body: string;
4
4
  readonly responseCode: number;
@@ -9,11 +9,10 @@ class OriginResponse {
9
9
  this.body = body;
10
10
  this.responseCode = responseCode;
11
11
  this.responseHeaders = this.addCustomHeaders(headers);
12
- this.body = Buffer.from(body).toString('base64');
12
+ this.body = Buffer.from(body).toString("base64");
13
13
  }
14
14
  addCustomHeaders(headers) {
15
- headers.push({ name: 'x-served-via', value: 'sk-onboarding' });
16
- headers.push({ name: 'Service-Worker-Allowed', value: '/' });
15
+ headers.push({ name: "x-served-via", value: "sk-onboarding" }, { name: "Service-Worker-Allowed", value: "/" });
17
16
  return headers;
18
17
  }
19
18
  }
@@ -1,7 +1,7 @@
1
- import { InstallSpeedKitJsTemplate } from '../templates/install-speed-kit-js-template';
2
- import CustomerConfig from "../../integration-api/struct/customer-config";
3
1
  import { BundleService } from "../../bundler";
4
2
  import { FileListInterface } from "../../integration-api/integration-api-model";
3
+ import CustomerConfig from "../../integration-api/struct/customer-config";
4
+ import { InstallSpeedKitJsTemplate } from "../templates/install-speed-kit-js-template";
5
5
  export declare class SpeedKitInstallContext {
6
6
  private customerConfig;
7
7
  private configName;
@@ -10,8 +10,6 @@ export declare class SpeedKitInstallContext {
10
10
  private skTemplate;
11
11
  private isLocalRuntime;
12
12
  constructor(customerConfig: CustomerConfig, configName: string, files: FileListInterface, bundler: BundleService, skTemplate: InstallSpeedKitJsTemplate, isLocalRuntime?: boolean);
13
- getSpeedKitInstallJs(): Promise<string>;
14
- private getConfigSpeedKit;
15
13
  /**
16
14
  * Fetches and returns the latest dynamic fetcher from the code repository. If a new version is available online it is
17
15
  * downloaded and cached, otherwise the fetcher id returned from cache. The resulting module gets minified afterwards.
@@ -19,4 +17,6 @@ export declare class SpeedKitInstallContext {
19
17
  * @returns {Promise<string>} a Promise which resolves to the latest dynamic fetcher
20
18
  */
21
19
  bundleDynamicFetcher(): Promise<string>;
20
+ getSpeedKitInstallJs(): Promise<string>;
21
+ private getConfigSpeedKit;
22
22
  }