@speedkit/cli 2.95.0 → 3.1.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 (68) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +10 -7
  3. package/dist/commands/build-parameter-query.d.ts +0 -1
  4. package/dist/commands/build-parameter-query.js +9 -76
  5. package/dist/commands/build-prewarm-query.d.ts +0 -1
  6. package/dist/commands/build-prewarm-query.js +9 -48
  7. package/dist/commands/deploy.d.ts +3 -6
  8. package/dist/commands/deploy.js +3 -17
  9. package/dist/commands/onboarding.js +2 -2
  10. package/dist/helpers/array-helper.d.ts +1 -0
  11. package/dist/helpers/array-helper.js +9 -0
  12. package/dist/helpers/customer-config.d.ts +0 -1
  13. package/dist/helpers/customer-config.js +0 -2
  14. package/dist/models/cli-parameters.d.ts +7 -2
  15. package/dist/models/cli-parameters.js +12 -1
  16. package/dist/services/customer-config/customer-config-service-model.d.ts +0 -1
  17. package/dist/services/customer-config/customer-config-service.js +2 -8
  18. package/dist/services/customer-config/templates/config_customer.json.hbs +56 -0
  19. package/dist/services/deploy/context/deploy-context.d.ts +4 -2
  20. package/dist/services/deploy/context/deploy-context.js +28 -3
  21. package/dist/services/deploy/deploy-service-factory.js +2 -6
  22. package/dist/services/deploy/handler/customer-config-handler.d.ts +0 -1
  23. package/dist/services/deploy/handler/customer-config-handler.js +3 -8
  24. package/dist/services/deploy/handler/install-resource-handler.js +2 -2
  25. package/dist/services/deploy/handler/module-handler.js +2 -2
  26. package/dist/services/deploy/handler/server-config-handler.js +2 -2
  27. package/dist/services/diff/diff-service.d.ts +1 -1
  28. package/dist/services/diff/diff-service.js +1 -1
  29. package/dist/services/integration-api/error/invalid-config-format-error.d.ts +4 -0
  30. package/dist/services/integration-api/error/invalid-config-format-error.js +15 -0
  31. package/dist/services/integration-api/file-reader.d.ts +1 -0
  32. package/dist/services/integration-api/file-reader.js +4 -0
  33. package/dist/services/integration-api/handler/customer-config-handler.d.ts +2 -1
  34. package/dist/services/integration-api/handler/customer-config-handler.js +42 -25
  35. package/dist/services/integration-api/integration-api-factory.js +3 -3
  36. package/dist/services/integration-api/integration-api-model.d.ts +4 -2
  37. package/dist/services/integration-api/integration-api-model.js +6 -4
  38. package/dist/services/integration-api/spec/customer-config-validator.spec.js +1 -1
  39. package/dist/services/integration-api/spec/file-list.spec.js +2 -2
  40. package/dist/services/integration-api/spec/file-reader.spec.js +17 -3
  41. package/dist/services/integration-api/spec/integration-api-service.spec.js +15 -1
  42. package/dist/services/integration-api/struct/customer-config-file.d.ts +1 -0
  43. package/dist/services/integration-api/struct/customer-config-file.js +24 -12
  44. package/dist/services/integration-api/struct/customer-config.d.ts +5 -1
  45. package/dist/services/integration-api/validator/customer-config-validator.js +1 -1
  46. package/dist/services/onboarding/onboarding-model.d.ts +8 -1
  47. package/dist/services/onboarding/onboarding-model.js +61 -4
  48. package/dist/services/onboarding/onboarding-service-factory.js +1 -1
  49. package/dist/services/onboarding/onboarding-service.js +2 -9
  50. package/dist/services/pull/pull-service.d.ts +1 -0
  51. package/dist/services/pull/pull-service.js +13 -0
  52. package/dist/services/query-builder/error/parse-config-speed-kit-error.d.ts +4 -0
  53. package/dist/services/query-builder/error/parse-config-speed-kit-error.js +11 -0
  54. package/dist/services/query-builder/query/parameter.d.ts +4 -0
  55. package/dist/services/query-builder/query/parameter.js +49 -0
  56. package/dist/services/query-builder/query/prewarm.d.ts +4 -0
  57. package/dist/services/query-builder/query/prewarm.js +23 -0
  58. package/dist/services/query-builder/query-builder-factory.d.ts +11 -0
  59. package/dist/services/query-builder/query-builder-factory.js +48 -0
  60. package/dist/services/query-builder/query-builder-model.d.ts +20 -0
  61. package/dist/services/query-builder/query-builder-model.js +8 -0
  62. package/dist/services/query-builder/query-builder-service.d.ts +10 -0
  63. package/dist/services/query-builder/query-builder-service.js +48 -0
  64. package/oclif.manifest.json +36 -16
  65. package/package.json +2 -2
  66. package/dist/services/customer-config/templates/config_customer.js.hbs +0 -62
  67. package/dist/services/deploy/handler/module-modifier/deployment-detection-modifier.d.ts +0 -9
  68. package/dist/services/deploy/handler/module-modifier/deployment-detection-modifier.js +0 -24
@@ -1,14 +1,20 @@
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");
4
5
  const core_1 = require("@oclif/core");
5
6
  const cli_parameters_1 = require("../../models/cli-parameters");
6
7
  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");
7
12
  const DEFAULT_BROWSER_ARGS = [
8
13
  "--enable-features=Translate,NetworkService",
9
14
  "--no-first-run",
10
15
  "--no-default-browser-check",
11
16
  "--disable-infobars",
17
+ // "--enable-automation",
12
18
  ];
13
19
  exports.BROWSER_EVENTS = {
14
20
  DISCONNECTED: "disconnected",
@@ -43,6 +49,7 @@ class BrowserContext {
43
49
  userAgent;
44
50
  browserArgs;
45
51
  chromePath;
52
+ browserDetails;
46
53
  constructor(domain, chromeFlags, userConfig, userAgent) {
47
54
  this.domain = domain;
48
55
  this.chromeFlags = chromeFlags;
@@ -52,9 +59,7 @@ class BrowserContext {
52
59
  this.chromeFlags = chromeFlags || [];
53
60
  this.chromePath = userConfig.chromePath;
54
61
  const browserArguments = DEFAULT_BROWSER_ARGS;
55
- if (userConfig?.chromeExtensionPaths) {
56
- browserArguments.push(`--load-extension=${userConfig?.chromeExtensionPaths}`, `--disable-extensions-except=${userConfig?.chromeExtensionPaths}`);
57
- }
62
+ this.browserDetails = this.checkBrowserDetails(userConfig.chromePath);
58
63
  if (userConfig?.chromeUserProfilePath) {
59
64
  browserArguments.push(`--user-data-dir=${userConfig?.chromeUserProfilePath}`);
60
65
  }
@@ -69,6 +74,55 @@ class BrowserContext {
69
74
  ...this.chromeFlags,
70
75
  ];
71
76
  }
77
+ checkBrowserDetails(browserExecutablePath) {
78
+ if (!(0, node_fs_1.existsSync)(browserExecutablePath)) {
79
+ throw new application_error_1.default(`No executable found in ${browserExecutablePath}`, [
80
+ "Check your configured browserExecutablePath",
81
+ "in envVar CHROME_PATH",
82
+ "or ~/.config/speed-kit-cli/config.json {chromePath:}",
83
+ ]);
84
+ }
85
+ const result = (0, safe_1.safe)(() => {
86
+ return (0, node_child_process_1.execSync)(`${browserExecutablePath} --version`).toString();
87
+ });
88
+ if (result.success === false) {
89
+ throw new application_error_1.default(result.error, [
90
+ "Check your configured browserExecutablePath",
91
+ `No executable found in ${browserExecutablePath}`,
92
+ ]);
93
+ }
94
+ return result.data.trim().replaceAll("\n", "");
95
+ }
96
+ isChromeBrowser() {
97
+ return (!!/chrome/i.test(this.browserDetails) &&
98
+ !!/google/i.test(this.browserDetails));
99
+ }
100
+ getBrowserExtensionPath() {
101
+ if (this.userConfig?.chromeExtensionPaths) {
102
+ return this.userConfig.chromeExtensionPaths.split(",");
103
+ }
104
+ return [];
105
+ }
106
+ getPuppeteerLaunchOptions() {
107
+ const options = {
108
+ devtools: true,
109
+ timeout: 0,
110
+ defaultViewport: null,
111
+ headless: false /* ignoreDefaultArgs: true, */,
112
+ executablePath: this.chromePath,
113
+ args: this.browserArgs,
114
+ };
115
+ if (this.userConfig?.chromeExtensionPaths) {
116
+ if (this.isChromeBrowser()) {
117
+ options["pipe"] = true;
118
+ options["enableExtensions"] = this.getBrowserExtensionPath();
119
+ }
120
+ else {
121
+ options.args.push(`--load-extension=${this.userConfig?.chromeExtensionPaths}`, `--disable-extensions-except=${this.userConfig?.chromeExtensionPaths}`);
122
+ }
123
+ }
124
+ return options;
125
+ }
72
126
  }
73
127
  exports.BrowserContext = BrowserContext;
74
128
  class OnboardingContext {
@@ -79,8 +133,10 @@ class OnboardingContext {
79
133
  ignoreContentSecurityPolicy;
80
134
  cliPath;
81
135
  verboseLevel;
136
+ useTestConfig;
82
137
  static flags = {
83
138
  ...cli_parameters_1.CLI_CONFIG_NAME,
139
+ ...cli_parameters_1.CLI_CONFIG_IS_TEST,
84
140
  [cli_parameters_1.CLIParameters.Domain]: core_1.Flags.string({
85
141
  char: cli_parameters_1.CLIParametersChar.Domain,
86
142
  description: "Startup domain (optional)",
@@ -105,7 +161,7 @@ class OnboardingContext {
105
161
  DEFAULT_DOCUMENT_HANDLER_PATH = "https://www.baqend.com/speed-kit-handler/latest/DocumentHandler.js";
106
162
  DEFAULT_SNIPPET_PATH = "https://www.baqend.com/speed-kit/latest/snippet.js";
107
163
  DEFAULT_SW_PATH = "https://www.baqend.com/speed-kit/latest/sw.js";
108
- constructor(customerPath, configName, domain, local, ignoreContentSecurityPolicy = false, cliPath, verboseLevel) {
164
+ constructor(customerPath, configName, domain, local, ignoreContentSecurityPolicy = false, cliPath, verboseLevel, useTestConfig = false) {
109
165
  this.customerPath = customerPath;
110
166
  this.configName = configName;
111
167
  this.domain = domain;
@@ -113,6 +169,7 @@ class OnboardingContext {
113
169
  this.ignoreContentSecurityPolicy = ignoreContentSecurityPolicy;
114
170
  this.cliPath = cliPath;
115
171
  this.verboseLevel = verboseLevel;
172
+ this.useTestConfig = useTestConfig;
116
173
  }
117
174
  }
118
175
  exports.OnboardingContext = OnboardingContext;
@@ -152,7 +152,7 @@ class OnboardingServiceFactory {
152
152
  const swPath = path.join(speedKitBuildPath, "sw.js");
153
153
  const dfPath = path.join(speedKitBuildPath, "dynamic-fetcher.js");
154
154
  const loaderPath = path.join(speedKitBuildPath, "snippet.js");
155
- const integrationApiContext = new integration_api_1.IntegrationApiContext(this.context.customerPath, this.context.configName, []);
155
+ const integrationApiContext = new integration_api_1.IntegrationApiContext(this.context.customerPath, this.context.configName, [], [], this.context.useTestConfig);
156
156
  const integrationApi = new integration_api_1.IntegrationApiFactory(integrationApiContext, this.cliConfig).buildService();
157
157
  const externalFileReader = new integration_api_1.ExternalFileReader();
158
158
  const integrationApiArray = [
@@ -29,21 +29,14 @@ class OnboardingService {
29
29
  * prepare puppeteerBrowser, add eventListeners and start
30
30
  */
31
31
  async run() {
32
- this.cli.startAction("prepare browser");
32
+ this.cli.startAction(`prepare browser ${this.cli.style.bold(this.browserContext.browserDetails)}`);
33
33
  const browser = await this.prepareBrowser();
34
34
  const page = await this.preparePage(browser);
35
35
  this.cli.endAction(cli_1.CliActionStatus.COMPLETED);
36
36
  await this.navigate(page, `${this.customerConfig.scope}speed-kit-install.html?url=${this.customerConfig.scope}`);
37
37
  }
38
38
  async prepareBrowser() {
39
- const browser = await puppeteer_extra_1.default.launch({
40
- devtools: true,
41
- timeout: 0,
42
- defaultViewport: null,
43
- headless: false /* ignoreDefaultArgs: true, */,
44
- executablePath: this.browserContext.chromePath,
45
- args: this.browserContext.browserArgs,
46
- });
39
+ const browser = await puppeteer_extra_1.default.launch(this.browserContext.getPuppeteerLaunchOptions());
47
40
  for (const target of browser.targets()) {
48
41
  if (target.type() === "browser") {
49
42
  await this.fetchEventHandler.handleRequestFetchEvents(target);
@@ -15,4 +15,5 @@ export declare class PullService {
15
15
  private readLocalFile;
16
16
  private createFile;
17
17
  private hasGitChanges;
18
+ private handleConfigCustomer;
18
19
  }
@@ -37,6 +37,7 @@ class PullService {
37
37
  }
38
38
  this.cli.endAction(cli_1.CliActionStatus.COMPLETED);
39
39
  const installResource = installResourceResult.data;
40
+ await this.handleConfigCustomer(installResource);
40
41
  for (const key in _1.InstallResourceToFileMapping) {
41
42
  await this.updateLocalFileByInstallResource(installResource, key);
42
43
  }
@@ -107,5 +108,17 @@ class PullService {
107
108
  this.cli.exit(1);
108
109
  }
109
110
  }
111
+ async handleConfigCustomer(installResource) {
112
+ const customerConfigFile = this.fileList.getCustomerConfig();
113
+ const config = customerConfigFile.config;
114
+ if (JSON.stringify(installResource.origins.sort()) !==
115
+ JSON.stringify(config.origins.sort())) {
116
+ this.cli.writeWarning(`update: config_customer(origins)`);
117
+ customerConfigFile.updateOrigins(installResource.origins);
118
+ await customerConfigFile.updateFile();
119
+ return;
120
+ }
121
+ this.cli.writeSuccess("equal, skip: config_customer(origins)");
122
+ }
110
123
  }
111
124
  exports.PullService = PullService;
@@ -0,0 +1,4 @@
1
+ import { ConfigFileError } from "../../error-handling/error/config-file-error";
2
+ export declare class ParseConfigSpeedKitError extends ConfigFileError {
3
+ constructor(message: string);
4
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ParseConfigSpeedKitError = void 0;
4
+ const config_file_error_1 = require("../../error-handling/error/config-file-error");
5
+ class ParseConfigSpeedKitError extends config_file_error_1.ConfigFileError {
6
+ constructor(message) {
7
+ super(message);
8
+ this.suggestions = ["please check file config_SpeedKit"];
9
+ }
10
+ }
11
+ exports.ParseConfigSpeedKitError = ParseConfigSpeedKitError;
@@ -0,0 +1,4 @@
1
+ export declare class Parameter {
2
+ readonly query: string;
3
+ constructor(app: string, parameterFilter: string, whitelistedFilter: string, blacklistedFilter: string, parameterReplaceFilter: string);
4
+ }
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Parameter = void 0;
4
+ class Parameter {
5
+ query;
6
+ constructor(app, parameterFilter, whitelistedFilter, blacklistedFilter, parameterReplaceFilter) {
7
+ const nowMinusOneMonth = new Date(new Date().setMonth(new Date().getMonth() - 1, new Date().getDate()));
8
+ const monthString = `${nowMinusOneMonth.getMonth() + 1 < 10 ? "0" : ""}${nowMinusOneMonth.getMonth() + 1}`;
9
+ const dateString = `${nowMinusOneMonth.getDate() < 10 ? "0" : ""}${nowMinusOneMonth.getDate()}`;
10
+ const date = `${nowMinusOneMonth.getFullYear()}-${monthString}-${dateString}`;
11
+ this.query = `
12
+ with urlWithParams as (
13
+ select
14
+ url,
15
+ createdat,
16
+ split(url, '?')[1] as urlWithoutParams,
17
+ filter (
18
+ transform(
19
+ split(split(url, '?')[2], '&'),
20
+ (pair) -> split(pair, '=')[1]
21
+ ),
22
+ (key) -> ${parameterFilter}
23
+ ) as paramKeys
24
+ from live.rum.pi
25
+ where app = '${app}'
26
+ and date >= '${date}'
27
+ and cardinality(split(url, '?')) > 1
28
+ and (${whitelistedFilter})
29
+ and ${blacklistedFilter}
30
+ ), prepared as (
31
+ select count(*) as PIs,
32
+ count(distinct url) as urls,
33
+ count(distinct ${parameterReplaceFilter}) as cachedUrls,
34
+ count(distinct urlWithoutParams) as uniqueWithoutParam,
35
+ paramKeys,
36
+ element_at(array_distinct(max_by(url, MD5(to_utf8(to_iso8601(createdat))), 500)), 1) as example1,
37
+ element_at(array_distinct(max_by(url, MD5(to_utf8(to_iso8601(createdat))), 500)), 2) as example2,
38
+ element_at(array_distinct(max_by(url, MD5(to_utf8(to_iso8601(createdat))), 500)), 3) as example3
39
+ from urlWithParams
40
+ group by paramKeys
41
+ )
42
+
43
+ select paramKeys, cachedUrls - uniqueWithoutParam as potentialGain, cachedUrls, PIs, example1, example2, example3
44
+ from prepared
45
+ where cardinality(paramKeys) > 0
46
+ order by potentialGain desc, cachedUrls desc, PIs desc`;
47
+ }
48
+ }
49
+ exports.Parameter = Parameter;
@@ -0,0 +1,4 @@
1
+ export declare class Prewarm {
2
+ readonly query: string;
3
+ constructor(app: string, whitelistedFilter: string, blacklistedFilter: string, parameterReplaceFilter: string);
4
+ }
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Prewarm = void 0;
4
+ class Prewarm {
5
+ query;
6
+ constructor(app, whitelistedFilter, blacklistedFilter, parameterReplaceFilter) {
7
+ const now = new Date();
8
+ now.setDate(now.getDate() - 10);
9
+ const date = now.toISOString().split("T")[0];
10
+ this.query = `
11
+ select url
12
+ from (
13
+ select regexp_replace(regexp_replace(${parameterReplaceFilter}, '(^[^&?]*)&','$1?'), '\\?$','') as url
14
+ from live.rum.pi
15
+ where app = '${app}'
16
+ and date >= '${date}'
17
+ and ${whitelistedFilter}
18
+ and ${blacklistedFilter})
19
+ group by url
20
+ order by count(*) desc`;
21
+ }
22
+ }
23
+ exports.Prewarm = Prewarm;
@@ -0,0 +1,11 @@
1
+ import { QueryBuilderService } from "./query-builder-service";
2
+ import { QueryBuilderFactoryContext, QueryTpe } from "./query-builder-model";
3
+ import { UserCliConfig } from "../../helpers/cli-config";
4
+ export declare class QueryBuilderFactory {
5
+ private context;
6
+ private userConfig;
7
+ constructor(context: QueryBuilderFactoryContext, userConfig: UserCliConfig);
8
+ buildService(queryType: QueryTpe): Promise<QueryBuilderService>;
9
+ private getIntegrationFiles;
10
+ private getSpeedKitConfig;
11
+ }
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.QueryBuilderFactory = void 0;
4
+ const query_builder_service_1 = require("./query-builder-service");
5
+ const integration_api_1 = require("../integration-api");
6
+ const files_1 = require("../../models/files");
7
+ const get_parsed_config_1 = require("../../helpers/get-parsed-config");
8
+ const cli_1 = require("../cli");
9
+ const safe_1 = require("../../helpers/safe");
10
+ const parse_config_speed_kit_error_1 = require("./error/parse-config-speed-kit-error");
11
+ class QueryBuilderFactory {
12
+ context;
13
+ userConfig;
14
+ constructor(context, userConfig) {
15
+ this.context = context;
16
+ this.userConfig = userConfig;
17
+ }
18
+ async buildService(queryType) {
19
+ const cli = new cli_1.CliServiceFactory().getService();
20
+ const files = await this.getIntegrationFiles();
21
+ const app = files.getCustomerConfig().config.app;
22
+ const speedKitConfigFile = files.getByName(files_1.INTEGRATION_FILES.CONFIG.SPEED_KIT);
23
+ const speedKitConfig = this.getSpeedKitConfig(speedKitConfigFile.getContent());
24
+ const serviceContext = {
25
+ app,
26
+ queryType,
27
+ isWindows: this.context.isWindows,
28
+ };
29
+ return new query_builder_service_1.QueryBuilderService(serviceContext, speedKitConfig, cli);
30
+ }
31
+ async getIntegrationFiles() {
32
+ const integrationApiContext = new integration_api_1.IntegrationApiContext(this.context.customerPath, this.context.configName, ["config_SpeedKit"]);
33
+ const integrationApi = new integration_api_1.IntegrationApiFactory(integrationApiContext, this.userConfig).buildService();
34
+ return await integrationApi.run();
35
+ }
36
+ // todo create a customService to exchange parseSpeedKitConfig()
37
+ // this service then can also be used in: deploy/checks/pre-deploy
38
+ getSpeedKitConfig(fileContentString) {
39
+ const result = (0, safe_1.safe)(() => {
40
+ return (0, get_parsed_config_1.parseSpeedKitConfig)(fileContentString);
41
+ });
42
+ if (result.success !== true) {
43
+ throw new parse_config_speed_kit_error_1.ParseConfigSpeedKitError(result.error);
44
+ }
45
+ return result.data;
46
+ }
47
+ }
48
+ exports.QueryBuilderFactory = QueryBuilderFactory;
@@ -0,0 +1,20 @@
1
+ export type QueryBuilderContext = {
2
+ isWindows?: boolean;
3
+ queryType: QueryTpe;
4
+ app: string;
5
+ };
6
+ export type QueryBuilderFactoryContext = {
7
+ readonly customerPath: string;
8
+ readonly configName: string;
9
+ readonly isWindows?: boolean;
10
+ };
11
+ export declare enum QueryTpe {
12
+ prewarm = "prewarm",
13
+ parameter = "parameter"
14
+ }
15
+ export type SpeedKitConfig = {
16
+ ruleSetConfig?: {
17
+ version?: string;
18
+ };
19
+ [key: string]: any;
20
+ };
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.QueryTpe = void 0;
4
+ var QueryTpe;
5
+ (function (QueryTpe) {
6
+ QueryTpe["prewarm"] = "prewarm";
7
+ QueryTpe["parameter"] = "parameter";
8
+ })(QueryTpe || (exports.QueryTpe = QueryTpe = {}));
@@ -0,0 +1,10 @@
1
+ import { QueryBuilderContext, SpeedKitConfig } from "./query-builder-model";
2
+ import { CliServiceInterface } from "../cli";
3
+ export declare class QueryBuilderService {
4
+ private context;
5
+ private speedKitConfig;
6
+ private cli;
7
+ constructor(context: QueryBuilderContext, speedKitConfig: SpeedKitConfig, cli: CliServiceInterface);
8
+ run(): Promise<void>;
9
+ private buildQuery;
10
+ }
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.QueryBuilderService = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const get_parsed_config_1 = require("../../helpers/get-parsed-config");
6
+ const build_query_helper_1 = require("../../helpers/build-query-helper");
7
+ const clipboardy_cjs_1 = tslib_1.__importDefault(require("clipboardy-cjs"));
8
+ const query_builder_model_1 = require("./query-builder-model");
9
+ const prewarm_1 = require("./query/prewarm");
10
+ const parameter_1 = require("./query/parameter");
11
+ const cli_1 = require("../cli");
12
+ class QueryBuilderService {
13
+ context;
14
+ speedKitConfig;
15
+ cli;
16
+ constructor(context, speedKitConfig, cli) {
17
+ this.context = context;
18
+ this.speedKitConfig = speedKitConfig;
19
+ this.cli = cli;
20
+ }
21
+ async run() {
22
+ this.cli.startAction(`build ${this.context.queryType}-query`);
23
+ const parameters = (0, build_query_helper_1.getStrippedParameters)(this.speedKitConfig);
24
+ const parameterReplaceFilter = (0, build_query_helper_1.getParameterReplaceFilter)(parameters, (0, get_parsed_config_1.getSpeedKitConfigVersion)(this.speedKitConfig));
25
+ const whitelistedFilter = (0, build_query_helper_1.getWhitelistedFilter)(this.speedKitConfig);
26
+ const blacklistedFilter = (0, build_query_helper_1.getBlacklistedFilter)(this.speedKitConfig);
27
+ const skConfigVersion = (0, get_parsed_config_1.getSpeedKitConfigVersion)(this.speedKitConfig);
28
+ const parameterFilter = (0, build_query_helper_1.getParameterFilter)(parameters, skConfigVersion);
29
+ const result = this.buildQuery(this.context.app, parameterFilter, whitelistedFilter, blacklistedFilter, parameterReplaceFilter);
30
+ this.cli.endAction(cli_1.CliActionStatus.COMPLETED);
31
+ if (!this.context.isWindows) {
32
+ clipboardy_cjs_1.default.writeSync(result);
33
+ }
34
+ this.cli.write(this.cli.style.dim.italic(result));
35
+ if (!this.context.isWindows) {
36
+ this.cli.writeSuccess("Result has been copied to the clipboard 📋");
37
+ }
38
+ }
39
+ buildQuery(app, parameterFilter, whitelistedFilter, blacklistedFilter, parameterReplaceFilter) {
40
+ if (this.context.queryType === query_builder_model_1.QueryTpe.prewarm) {
41
+ return new prewarm_1.Prewarm(app, whitelistedFilter, blacklistedFilter, parameterReplaceFilter).query;
42
+ }
43
+ if (this.context.queryType === query_builder_model_1.QueryTpe.parameter) {
44
+ return new parameter_1.Parameter(app, parameterFilter, whitelistedFilter, blacklistedFilter, parameterReplaceFilter).query;
45
+ }
46
+ }
47
+ }
48
+ exports.QueryBuilderService = QueryBuilderService;
@@ -107,28 +107,41 @@
107
107
  "multiple": false,
108
108
  "type": "option"
109
109
  },
110
- "artifacts": {
111
- "char": "a",
112
- "description": "Whitelist of files to deploy",
113
- "name": "artifacts",
110
+ "useTestConfig": {
111
+ "char": "t",
112
+ "description": "Override app with configured testApp",
113
+ "name": "useTestConfig",
114
+ "allowNo": false,
115
+ "type": "boolean"
116
+ },
117
+ "domain": {
118
+ "char": "d",
119
+ "description": "Startup domain (optional)",
120
+ "name": "domain",
114
121
  "hasDynamicHelp": false,
115
122
  "multiple": false,
116
123
  "type": "option"
117
124
  },
118
- "dryRun": {
119
- "char": "d",
120
- "description": "Do not deploy changes",
121
- "name": "dryRun",
125
+ "local": {
126
+ "char": "l",
127
+ "description": "Run with local documentHandler",
128
+ "name": "local",
122
129
  "allowNo": false,
123
130
  "type": "boolean"
124
131
  },
125
- "slackToken": {
126
- "char": "t",
127
- "description": "Slack hook found on 1Pass",
128
- "name": "slackToken",
129
- "hasDynamicHelp": false,
130
- "multiple": false,
131
- "type": "option"
132
+ "verboseLevel": {
133
+ "char": "v",
134
+ "description": "Show all messages",
135
+ "name": "verboseLevel",
136
+ "allowNo": false,
137
+ "type": "boolean"
138
+ },
139
+ "ignoreContentSecurityPolicy": {
140
+ "char": "s",
141
+ "description": "Removes header/meta \"content-security-policy\" for origin-responses",
142
+ "name": "ignoreContentSecurityPolicy",
143
+ "allowNo": false,
144
+ "type": "boolean"
132
145
  }
133
146
  },
134
147
  "hasDynamicHelp": false,
@@ -458,6 +471,13 @@
458
471
  "multiple": false,
459
472
  "type": "option"
460
473
  },
474
+ "useTestConfig": {
475
+ "char": "t",
476
+ "description": "Override app with configured testApp",
477
+ "name": "useTestConfig",
478
+ "allowNo": false,
479
+ "type": "boolean"
480
+ },
461
481
  "domain": {
462
482
  "char": "d",
463
483
  "description": "Startup domain (optional)",
@@ -712,5 +732,5 @@
712
732
  ]
713
733
  }
714
734
  },
715
- "version": "2.95.0"
735
+ "version": "3.1.0"
716
736
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@speedkit/cli",
3
3
  "description": "Speed Kit CLI",
4
- "version": "2.95.0",
4
+ "version": "3.1.0",
5
5
  "author": {
6
6
  "name": "Baqend.com",
7
7
  "email": "info@baqend.com"
@@ -91,7 +91,7 @@
91
91
  "node-fetch": "^2.7.0",
92
92
  "parse5": "7.1",
93
93
  "parse5-htmlparser2-tree-adapter": "7.0.0",
94
- "puppeteer": "^22.6.5",
94
+ "puppeteer": "^24.16.0",
95
95
  "puppeteer-extra": "^3.3.6",
96
96
  "semver": "^7.6.3",
97
97
  "strip-comments": "^2.0.1",
@@ -1,62 +0,0 @@
1
- /**
2
- * Shop/Frontend system in use:
3
- {{#if isShopify}}
4
- * - Shopify
5
- {{else if isShopware}}
6
- * - Shopware
7
- {{else if isSalesforce}}
8
- * - Salesforce Commerce Cloud
9
- {{else if isOxid}}
10
- * - OXID eShop
11
- {{else if isPlentymarkets}}
12
- * - Plentymarkets
13
- {{else}}
14
- * - TODO: enter name of system in use
15
- {{/if}}
16
- */
17
-
18
- const shared = {
19
- app: "{{appName}}",
20
- domain: "{{production.host}}",
21
- origins: [
22
- "https://{{production.host}}",
23
- ],
24
- {{#if isShopify}}
25
- shopifyId: "{{shopifyId}}", // Shopify specific
26
- swPath: "/apps/speed-kit/sw.js", // Shopify specific
27
- {{else}}
28
- swPath: "/wrapper-sw.js",
29
- {{/if}}
30
- {{#if subRouteScope}}
31
- scope: "/{{subRouteScope}}/",
32
- {{else}}
33
- scope: "/",
34
- {{/if}}
35
- };
36
-
37
- module.exports = {
38
- test: {
39
- ...shared,
40
- app: process.env.TEST_APP,
41
- name: shared.app,
42
- forceInstall: true,
43
- },
44
- {{#if staging.host}}
45
- staging: {
46
- ...shared,
47
- name: "staging",
48
- domain: "{{staging.host}}",
49
- origins: [
50
- "https://{{staging.host}}",
51
- ],
52
- forceInstall: {{staging.forceInstall}}, // use when our setup is not present yet
53
- // bypassDeactivation: false, // comment out when SK deactivation should not be bypassed
54
- },
55
- {{/if}}
56
- production: {
57
- ...shared,
58
- name: "production",
59
- forceInstall: {{production.forceInstall}}, // use when our setup is not present yet
60
- // bypassDeactivation: false, // comment out when SK deactivation should not be bypassed
61
- },
62
- };
@@ -1,9 +0,0 @@
1
- import RuntimeModifier from "../../interface/runtime-modifier";
2
- import { ModuleInterface } from "../../../integration-api/integration-api-model";
3
- export default class DeploymentDetectionModifier implements RuntimeModifier {
4
- private readonly slackToken;
5
- constructor(slackToken?: string);
6
- canModify(file: ModuleInterface): boolean;
7
- modify(file: ModuleInterface): void;
8
- revert(file: ModuleInterface): void;
9
- }
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const FILE = "deploymentDetection";
4
- const SLACK_TOKEN_PLACEHOLDER = "<1Password deployment token>";
5
- class DeploymentDetectionModifier {
6
- slackToken;
7
- constructor(slackToken) {
8
- this.slackToken = slackToken;
9
- }
10
- canModify(file) {
11
- return file.name === FILE;
12
- }
13
- modify(file) {
14
- if (this.slackToken) {
15
- file.setContent(file.getContent().replace(SLACK_TOKEN_PLACEHOLDER, this.slackToken));
16
- }
17
- }
18
- revert(file) {
19
- if (this.slackToken) {
20
- file.setContent(file.getContent().replace(this.slackToken, SLACK_TOKEN_PLACEHOLDER));
21
- }
22
- }
23
- }
24
- exports.default = DeploymentDetectionModifier;