@speedkit/cli 2.18.0 → 2.19.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 +7 -0
- package/README.md +36 -5
- package/dist/commands/build-parameter-query.js +5 -5
- package/dist/commands/build-prewarm-query.js +4 -4
- package/dist/commands/{param-diff.d.ts → diff-url-parameters.d.ts} +3 -1
- package/dist/commands/{param-diff.js → diff-url-parameters.js} +26 -24
- package/dist/commands/find-pops.js +9 -9
- package/dist/commands/generate-customer-config.d.ts +1 -1
- package/dist/commands/generate-customer-config.js +7 -7
- package/dist/commands/generate-pop-config.js +2 -2
- package/dist/commands/login.js +5 -4
- package/dist/commands/pop-prewarm.d.ts +3 -3
- package/dist/commands/pop-prewarm.js +19 -16
- package/dist/commands/prewarm.js +10 -10
- package/dist/commands/wpt-launcher.d.ts +1 -1
- package/dist/commands/wpt-launcher.js +9 -9
- package/dist/helpers/build-query-helper.d.ts +3 -3
- package/dist/helpers/build-query-helper.js +70 -69
- package/dist/helpers/cli-config.js +6 -5
- package/dist/helpers/{CustomerConfig.d.ts → customer-config.d.ts} +6 -6
- package/dist/helpers/{CustomerConfig.js → customer-config.js} +39 -39
- package/dist/helpers/file-helper.d.ts +1 -1
- package/dist/helpers/file-helper.js +5 -5
- package/dist/helpers/{getChromePath.js → get-chrome-path.js} +8 -8
- package/dist/helpers/get-parsed-config.d.ts +1 -1
- package/dist/helpers/get-parsed-config.js +7 -7
- package/dist/helpers/is-directory.d.ts +1 -0
- package/dist/helpers/{isDirectory.js → is-directory.js} +6 -6
- package/dist/helpers/{isExecutable.js → is-executable.js} +3 -3
- package/dist/helpers/{isFile.js → is-file.js} +4 -4
- package/dist/helpers/logging-helper.d.ts +3 -3
- package/dist/helpers/logging-helper.js +6 -6
- package/dist/helpers/normalize.d.ts +6 -6
- package/dist/helpers/normalize.js +35 -33
- package/dist/helpers/safe.d.ts +1 -1
- package/dist/helpers/safe.js +12 -12
- package/dist/helpers/{speedKitRuleToRegExp.js → speed-kit-rule-to-reg-exp.js} +3 -3
- package/dist/helpers/{watchFiles.js → watch-files.js} +2 -2
- package/dist/models/cli-parameters.d.ts +3 -3
- package/dist/models/cli-parameters.js +3 -3
- package/dist/services/athena/athena-service.js +2 -2
- package/dist/services/bundler/bundle-service.js +14 -14
- package/dist/services/cli/cli-service.js +8 -4
- package/dist/services/cli/hooks.js +3 -3
- package/dist/services/config-api/client.js +7 -6
- package/dist/services/config-api/factory/config-api-service-factory.js +4 -4
- package/dist/services/config-api/factory/entity-manager-factory.js +1 -1
- package/dist/services/config-api-service.d.ts +1 -1
- package/dist/services/config-api-service.js +7 -7
- package/dist/services/customer-config/customer-config-service-context.d.ts +2 -2
- package/dist/services/customer-config/customer-config-service-context.js +4 -4
- package/dist/services/customer-config/customer-config-service.js +45 -44
- package/dist/services/deploy/builder/install-resource-builder.d.ts +2 -2
- package/dist/services/deploy/builder/install-resource-builder.js +7 -7
- package/dist/services/deploy/checks/post-deploy/revalidated-module-check.js +1 -1
- package/dist/services/deploy/checks/post-deploy/save-files-check.js +4 -4
- package/dist/services/deploy/deploy-service.js +2 -4
- package/dist/services/deploy/error/create-find-temporary-directory-error.d.ts +4 -0
- package/dist/services/deploy/error/{create-find-temp-directory-error.js → create-find-temporary-directory-error.js} +2 -2
- package/dist/services/deploy/handler/customer-config-handler.js +1 -1
- package/dist/services/deploy/handler/install-resource-handler.js +8 -11
- package/dist/services/deploy/handler/install-resource-modifier/deleted-file-check.js +2 -2
- package/dist/services/deploy/handler/module-handler.js +8 -8
- package/dist/services/deploy/handler/server-config-handler.js +4 -4
- package/dist/services/diff/diff-service.d.ts +2 -2
- package/dist/services/diff/diff-service.js +22 -22
- package/dist/services/diff-service.d.ts +1 -1
- package/dist/services/diff-service.js +13 -13
- package/dist/services/document-handler-runtime/context/document-handler-runtime-context.js +10 -8
- package/dist/services/document-handler-runtime/document-handler-runtime-service.js +10 -10
- package/dist/services/document-handler-runtime/document-handler-server.js +12 -12
- package/dist/services/document-handler-runtime/factory/document-handler-runtime-service-factory.js +2 -2
- package/dist/services/document-handler-runtime/interface/template-interface.d.ts +2 -2
- package/dist/services/document-handler-runtime/interface/{template-param-interface.d.ts → template-parameter-interface.d.ts} +1 -1
- package/dist/services/document-handler-runtime/templates/abstract-template.d.ts +2 -2
- package/dist/services/document-handler-runtime/templates/abstract-template.js +3 -3
- package/dist/services/error-handling/factory/error-handling-factory.d.ts +1 -4
- package/dist/services/error-handling/factory/error-handling-factory.js +2 -1
- package/dist/services/integration-api/factory/integration-api-service-factory.js +1 -1
- package/dist/services/integration-api/file-list.js +4 -3
- package/dist/services/integration-api/file-reader.d.ts +1 -1
- package/dist/services/integration-api/file-reader.js +29 -26
- package/dist/services/integration-api/file-writer.js +3 -3
- package/dist/services/integration-api/handler/file-handler.js +1 -1
- package/dist/services/integration-api/handler/install-resource-handler.js +1 -1
- package/dist/services/integration-api/handler/module-handler.js +1 -1
- package/dist/services/integration-api/handler/server-config-handler.js +1 -1
- package/dist/services/integration-api/integration-api-service.js +2 -3
- package/dist/services/integration-api/struct/customer-config.d.ts +1 -1
- package/dist/services/integration-api/struct/customer-config.js +4 -4
- package/dist/services/integration-api/struct/file.js +1 -1
- package/dist/services/integration-api/validator/customer-config-validator.js +2 -2
- package/dist/services/integration-api/validator/mandatory-files-validator.js +7 -6
- package/dist/services/integration-api/virtual/external-recipe.js +2 -1
- package/dist/services/onboarding/browser/baqend-response.js +1 -2
- package/dist/services/onboarding/config-renderer/speed-kit-install-context.js +1 -1
- package/dist/services/onboarding/dashboard/index.d.ts +3 -3
- package/dist/services/onboarding/dashboard/index.js +12 -12
- package/dist/services/onboarding/dashboard/{param-query-builder.d.ts → parameter-query-builder.d.ts} +1 -1
- package/dist/services/onboarding/dashboard/{param-query-builder.js → parameter-query-builder.js} +6 -6
- package/dist/services/onboarding/dashboard/request-diff-service.js +24 -22
- package/dist/services/onboarding/fetch-events/customer-domain-document-response.js +8 -8
- package/dist/services/onboarding/fetch-events/speed-kit-asset-request.js +7 -7
- package/dist/services/onboarding/onboarding-model.js +4 -4
- package/dist/services/onboarding/onboarding-service-factory.js +3 -3
- package/dist/services/onboarding/onboarding-service.js +2 -1
- package/dist/services/onboarding/todo-collector.js +1 -1
- package/dist/services/prewarm-service.d.ts +1 -1
- package/dist/services/prewarm-service.js +8 -7
- package/dist/services/pull/pull-service.js +2 -2
- package/oclif.manifest.json +45 -42
- package/package.json +2 -1
- package/dist/helpers/isDirectory.d.ts +0 -1
- package/dist/services/context/app-context.d.ts +0 -1
- package/dist/services/deploy/error/create-find-temp-directory-error.d.ts +0 -4
- package/dist/services/document-handler-runtime/interface/template-param-interface.js +0 -2
- /package/dist/helpers/{getChromePath.d.ts → get-chrome-path.d.ts} +0 -0
- /package/dist/helpers/{isExecutable.d.ts → is-executable.d.ts} +0 -0
- /package/dist/helpers/{isFile.d.ts → is-file.d.ts} +0 -0
- /package/dist/helpers/{speedKitRuleToRegExp.d.ts → speed-kit-rule-to-reg-exp.d.ts} +0 -0
- /package/dist/helpers/{watchFiles.d.ts → watch-files.d.ts} +0 -0
- /package/dist/services/{context/app-context.js → document-handler-runtime/interface/template-parameter-interface.js} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [2.19.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.18.0...v2.19.0) (2024-04-09)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* add eslint plugin unicorn ([5fec1f7](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/5fec1f7c648329804f51121abc1ff2fa26f5583d))
|
|
7
|
+
|
|
1
8
|
# [2.18.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.17.0...v2.18.0) (2024-04-08)
|
|
2
9
|
|
|
3
10
|
|
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/2.
|
|
24
|
+
@speedkit/cli/2.19.0 linux-x64 node-v20.12.1
|
|
25
25
|
$ sk --help [COMMAND]
|
|
26
26
|
USAGE
|
|
27
27
|
$ sk COMMAND
|
|
@@ -69,6 +69,7 @@ By either...
|
|
|
69
69
|
* [`sk build-parameter-query CUSTOMERPATH`](#sk-build-parameter-query-customerpath)
|
|
70
70
|
* [`sk build-prewarm-query CUSTOMERPATH`](#sk-build-prewarm-query-customerpath)
|
|
71
71
|
* [`sk deploy CUSTOMERPATH`](#sk-deploy-customerpath)
|
|
72
|
+
* [`sk diff-url-parameters PAGEURL`](#sk-diff-url-parameters-pageurl)
|
|
72
73
|
* [`sk document-handler CUSTOMERPATH`](#sk-document-handler-customerpath)
|
|
73
74
|
* [`sk find-pops APP`](#sk-find-pops-app)
|
|
74
75
|
* [`sk generate-customer-config`](#sk-generate-customer-config)
|
|
@@ -185,6 +186,32 @@ EXAMPLES
|
|
|
185
186
|
$ sk deploy customer/decathlon.de -c production -t someSlackToken -a dynamic,SpeedKit -d
|
|
186
187
|
```
|
|
187
188
|
|
|
189
|
+
## `sk diff-url-parameters PAGEURL`
|
|
190
|
+
|
|
191
|
+
Shows difference in documents with query parameters on/off
|
|
192
|
+
|
|
193
|
+
```
|
|
194
|
+
USAGE
|
|
195
|
+
$ sk diff-url-parameters PAGEURL [-h]
|
|
196
|
+
|
|
197
|
+
ARGUMENTS
|
|
198
|
+
PAGEURL Link of the page
|
|
199
|
+
|
|
200
|
+
FLAGS
|
|
201
|
+
-h, --hideDiff Hide the code diff in IDE code diff window
|
|
202
|
+
|
|
203
|
+
DESCRIPTION
|
|
204
|
+
Shows difference in documents with query parameters on/off
|
|
205
|
+
|
|
206
|
+
ALIASES
|
|
207
|
+
$ sk param-diff
|
|
208
|
+
|
|
209
|
+
EXAMPLES
|
|
210
|
+
$ sk prewarm <pageUrl> -h
|
|
211
|
+
|
|
212
|
+
$ sk prewarm https://www.decathlon.de/ -h
|
|
213
|
+
```
|
|
214
|
+
|
|
188
215
|
## `sk document-handler CUSTOMERPATH`
|
|
189
216
|
|
|
190
217
|
Creates testable documentHandler in folder {CUSTOMER_PATH}/test/src/
|
|
@@ -241,15 +268,16 @@ USAGE
|
|
|
241
268
|
$ sk generate-customer-config [-a <value>] [-d <value>]
|
|
242
269
|
|
|
243
270
|
FLAGS
|
|
244
|
-
-a, --app=<value>
|
|
245
|
-
|
|
246
|
-
|
|
271
|
+
-a, --app=<value> The SK app name which is also being used the config output directory name
|
|
272
|
+
(kebab-case)
|
|
273
|
+
-d, --customersDirectory=<value> Name of the sk-onboarding directory where all customer configs are being stored
|
|
274
|
+
(default: "customers")
|
|
247
275
|
|
|
248
276
|
DESCRIPTION
|
|
249
277
|
Generates a customer config guided by a wizard 🧙
|
|
250
278
|
|
|
251
279
|
EXAMPLES
|
|
252
|
-
$ sk generate-customer-config -a <app> -d <
|
|
280
|
+
$ sk generate-customer-config -a <app> -d <customersDirectory>
|
|
253
281
|
|
|
254
282
|
$ sk generate-customer-config -a decathlon -d customers
|
|
255
283
|
```
|
|
@@ -373,6 +401,9 @@ FLAGS
|
|
|
373
401
|
DESCRIPTION
|
|
374
402
|
Shows difference in documents with query parameters on/off
|
|
375
403
|
|
|
404
|
+
ALIASES
|
|
405
|
+
$ sk param-diff
|
|
406
|
+
|
|
376
407
|
EXAMPLES
|
|
377
408
|
$ sk prewarm <pageUrl> -h
|
|
378
409
|
|
|
@@ -4,7 +4,7 @@ const tslib_1 = require("tslib");
|
|
|
4
4
|
const core_1 = require("@oclif/core");
|
|
5
5
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
6
6
|
const clipboardy_cjs_1 = tslib_1.__importDefault(require("clipboardy-cjs"));
|
|
7
|
-
const
|
|
7
|
+
const customer_config_1 = require("../helpers/customer-config");
|
|
8
8
|
const build_query_helper_1 = require("../helpers/build-query-helper");
|
|
9
9
|
const get_parsed_config_1 = require("../helpers/get-parsed-config");
|
|
10
10
|
const logging_helper_1 = require("../helpers/logging-helper");
|
|
@@ -65,12 +65,12 @@ order by potentialGain desc, cachedUrls desc, PIs desc`;
|
|
|
65
65
|
const { args: { customerPath }, flags: { configName }, } = await this.parse(BuildParameterQuery);
|
|
66
66
|
core_1.ux.action.start("Building parameter query");
|
|
67
67
|
try {
|
|
68
|
-
const { app, config } = await
|
|
68
|
+
const { app, config } = await customer_config_1.CustomerConfig.loadCustomer(customerPath, configName);
|
|
69
69
|
const parsedConfig = await (0, get_parsed_config_1.getParsedConfig)(config);
|
|
70
|
-
const
|
|
70
|
+
const parameters = (0, build_query_helper_1.getStrippedParameters)(parsedConfig);
|
|
71
71
|
const skConfigVersion = (0, get_parsed_config_1.getSpeedKitConfigVersion)(parsedConfig);
|
|
72
|
-
const parameterFilter = (0, build_query_helper_1.getParameterFilter)(
|
|
73
|
-
const parameterReplaceFilter = (0, build_query_helper_1.getParameterReplaceFilter)(
|
|
72
|
+
const parameterFilter = (0, build_query_helper_1.getParameterFilter)(parameters, skConfigVersion);
|
|
73
|
+
const parameterReplaceFilter = (0, build_query_helper_1.getParameterReplaceFilter)(parameters, skConfigVersion);
|
|
74
74
|
const whitelistedFilter = (0, build_query_helper_1.getWhitelistedFilter)(parsedConfig);
|
|
75
75
|
const blacklistedFilter = (0, build_query_helper_1.getBlacklistedFilter)(parsedConfig);
|
|
76
76
|
const result = this.buildParameterQuery(app || parsedConfig.appName, parameterFilter, whitelistedFilter, blacklistedFilter, parameterReplaceFilter);
|
|
@@ -4,7 +4,7 @@ const tslib_1 = require("tslib");
|
|
|
4
4
|
const core_1 = require("@oclif/core");
|
|
5
5
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
6
6
|
const clipboardy_cjs_1 = tslib_1.__importDefault(require("clipboardy-cjs"));
|
|
7
|
-
const
|
|
7
|
+
const customer_config_1 = require("../helpers/customer-config");
|
|
8
8
|
const build_query_helper_1 = require("../helpers/build-query-helper");
|
|
9
9
|
const get_parsed_config_1 = require("../helpers/get-parsed-config");
|
|
10
10
|
const logging_helper_1 = require("../helpers/logging-helper");
|
|
@@ -40,10 +40,10 @@ order by count(*) desc`;
|
|
|
40
40
|
const { args: { customerPath }, flags: { configName }, } = await this.parse(BuildPrewarmQuery);
|
|
41
41
|
core_1.ux.action.start("Building pre-warm query");
|
|
42
42
|
try {
|
|
43
|
-
const { app, config } = await
|
|
43
|
+
const { app, config } = await customer_config_1.CustomerConfig.loadCustomer(customerPath, configName);
|
|
44
44
|
const parsedConfig = await (0, get_parsed_config_1.getParsedConfig)(config);
|
|
45
|
-
const
|
|
46
|
-
const parameterReplaceFilter = (0, build_query_helper_1.getParameterReplaceFilter)(
|
|
45
|
+
const parameters = (0, build_query_helper_1.getStrippedParameters)(parsedConfig);
|
|
46
|
+
const parameterReplaceFilter = (0, build_query_helper_1.getParameterReplaceFilter)(parameters, (0, get_parsed_config_1.getSpeedKitConfigVersion)(parsedConfig));
|
|
47
47
|
const whitelistedFilter = (0, build_query_helper_1.getWhitelistedFilter)(parsedConfig);
|
|
48
48
|
const blacklistedFilter = (0, build_query_helper_1.getBlacklistedFilter)(parsedConfig);
|
|
49
49
|
const result = this.buildPrewarmQuery(app || parsedConfig.appName, whitelistedFilter, blacklistedFilter, parameterReplaceFilter);
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { Config, Command } from "@oclif/core";
|
|
2
2
|
import { CliService } from "../services/cli";
|
|
3
|
-
export default class
|
|
3
|
+
export default class DiffUrlParameters extends Command {
|
|
4
4
|
cli: CliService;
|
|
5
5
|
static description: string;
|
|
6
|
+
static aliases: string[];
|
|
7
|
+
static deprecateAliases: boolean;
|
|
6
8
|
static args: {
|
|
7
9
|
pageUrl: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
8
10
|
};
|
|
@@ -5,12 +5,14 @@ const core_1 = require("@oclif/core");
|
|
|
5
5
|
const scrape_1 = tslib_1.__importDefault(require("../helpers/scrape"));
|
|
6
6
|
const cli_parameters_1 = require("../models/cli-parameters");
|
|
7
7
|
const cli_1 = require("../services/cli");
|
|
8
|
-
const url = tslib_1.__importStar(require("url"));
|
|
8
|
+
const url = tslib_1.__importStar(require("node:url"));
|
|
9
9
|
const diff_1 = require("../services/diff");
|
|
10
10
|
const cli_config_1 = require("../helpers/cli-config");
|
|
11
|
-
class
|
|
11
|
+
class DiffUrlParameters extends core_1.Command {
|
|
12
12
|
cli;
|
|
13
13
|
static description = "Shows difference in documents with query parameters on/off";
|
|
14
|
+
static aliases = ["param-diff"];
|
|
15
|
+
static deprecateAliases = true;
|
|
14
16
|
static args = {
|
|
15
17
|
[cli_parameters_1.CLIParameters.PageUrl]: core_1.Args.string({
|
|
16
18
|
name: cli_parameters_1.CLIParameters.PageUrl,
|
|
@@ -39,32 +41,32 @@ class ParamDiff extends core_1.Command {
|
|
|
39
41
|
this.cli.exit(1);
|
|
40
42
|
}
|
|
41
43
|
async run() {
|
|
42
|
-
const { args, flags } = await this.parse(
|
|
44
|
+
const { args, flags } = await this.parse(DiffUrlParameters);
|
|
43
45
|
const { pageUrl: originalUrl } = args;
|
|
44
46
|
const originalData = await (0, scrape_1.default)(originalUrl);
|
|
45
47
|
if (!originalData) {
|
|
46
48
|
this.logError("Failed to fetch original document");
|
|
47
49
|
}
|
|
48
50
|
const parsedUrl = url.parse(originalUrl, true);
|
|
49
|
-
const
|
|
51
|
+
const withoutAnyParametersUrl = url.format({
|
|
50
52
|
protocol: parsedUrl.protocol,
|
|
51
53
|
host: parsedUrl.host,
|
|
52
54
|
pathname: parsedUrl.pathname,
|
|
53
55
|
});
|
|
54
|
-
const
|
|
55
|
-
if (!
|
|
56
|
+
const withoutAnyParametersData = await (0, scrape_1.default)(withoutAnyParametersUrl);
|
|
57
|
+
if (!withoutAnyParametersData) {
|
|
56
58
|
this.logError("Failed to fetch document without any params");
|
|
57
59
|
}
|
|
58
60
|
const userConfig = new cli_config_1.CliConfig(this.config).load();
|
|
59
61
|
const context = new diff_1.DiffContext(userConfig.diffExec, userConfig.diffExecTemplate);
|
|
60
62
|
const diffService = new diff_1.DiffServiceFactory(context).getService();
|
|
61
63
|
const originalFilePath = await diffService.writeContentToTemporalFile("original.html", originalData);
|
|
62
|
-
const
|
|
64
|
+
const withoutAnyParametersFilePath = await diffService.writeContentToTemporalFile("without-any-params.html", withoutAnyParametersData);
|
|
63
65
|
this.cli.spacer();
|
|
64
66
|
this.cli.write(`Checking any parameter...`);
|
|
65
67
|
this.cli.write(`- with: ${originalUrl}`);
|
|
66
|
-
this.cli.write(`- without: ${
|
|
67
|
-
const isEqual = await diffService.executeDiff(originalFilePath,
|
|
68
|
+
this.cli.write(`- without: ${withoutAnyParametersUrl}`);
|
|
69
|
+
const isEqual = await diffService.executeDiff(originalFilePath, withoutAnyParametersFilePath, flags.hideDiff);
|
|
68
70
|
if (isEqual) {
|
|
69
71
|
this.cli.writeSuccess(`✅ No diff found`);
|
|
70
72
|
return;
|
|
@@ -74,28 +76,28 @@ class ParamDiff extends core_1.Command {
|
|
|
74
76
|
// there's a difference in the general check, do a detailed check:
|
|
75
77
|
if (Object.keys(parsedUrl.query).length === 1)
|
|
76
78
|
return;
|
|
77
|
-
for (const
|
|
78
|
-
const
|
|
79
|
-
delete
|
|
80
|
-
const
|
|
79
|
+
for (const parameter in parsedUrl.query) {
|
|
80
|
+
const withoutCurrentParameterQuery = { ...parsedUrl.query };
|
|
81
|
+
delete withoutCurrentParameterQuery[parameter]; // Remove the current parameter
|
|
82
|
+
const withoutCurrentParameterUrl = url.format({
|
|
81
83
|
protocol: parsedUrl.protocol,
|
|
82
84
|
host: parsedUrl.host,
|
|
83
85
|
pathname: parsedUrl.pathname,
|
|
84
|
-
query:
|
|
86
|
+
query: withoutCurrentParameterQuery,
|
|
85
87
|
});
|
|
86
|
-
const
|
|
87
|
-
if (!
|
|
88
|
-
this.logError(`Failed to fetch document without "${
|
|
88
|
+
const withoutCurrentParameterData = await (0, scrape_1.default)(withoutCurrentParameterUrl);
|
|
89
|
+
if (!withoutCurrentParameterData) {
|
|
90
|
+
this.logError(`Failed to fetch document without "${parameter}" parameter`);
|
|
89
91
|
}
|
|
90
|
-
const
|
|
92
|
+
const withoutCurrentParameterFilePath = await diffService.writeContentToTemporalFile(`without-${parameter}-param.html`, withoutCurrentParameterData);
|
|
91
93
|
this.cli.spacer();
|
|
92
|
-
this.cli.write(`Checking "${
|
|
94
|
+
this.cli.write(`Checking "${parameter}" parameter...`);
|
|
93
95
|
this.cli.write(`- with: ${originalUrl}`);
|
|
94
|
-
this.cli.write(`- without: ${
|
|
95
|
-
const hasSpecificDiff = !(await diffService.executeDiff(originalFilePath,
|
|
96
|
+
this.cli.write(`- without: ${withoutCurrentParameterUrl}`);
|
|
97
|
+
const hasSpecificDiff = !(await diffService.executeDiff(originalFilePath, withoutCurrentParameterFilePath, flags.hideDiff));
|
|
96
98
|
if (hasSpecificDiff) {
|
|
97
|
-
const
|
|
98
|
-
if (
|
|
99
|
+
const hasDiffWithoutAnyParameters = !(await diffService.executeDiff(withoutAnyParametersFilePath, withoutCurrentParameterFilePath, true));
|
|
100
|
+
if (hasDiffWithoutAnyParameters) {
|
|
99
101
|
this.cli.writeWarning("⚠️ Found diff");
|
|
100
102
|
}
|
|
101
103
|
else {
|
|
@@ -108,4 +110,4 @@ class ParamDiff extends core_1.Command {
|
|
|
108
110
|
}
|
|
109
111
|
}
|
|
110
112
|
}
|
|
111
|
-
exports.default =
|
|
113
|
+
exports.default = DiffUrlParameters;
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const core_1 = require("@oclif/core");
|
|
5
|
-
const
|
|
5
|
+
const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
|
|
6
6
|
const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
|
|
7
|
-
const https = tslib_1.__importStar(require("https"));
|
|
7
|
+
const https = tslib_1.__importStar(require("node:https"));
|
|
8
8
|
const cli_1 = require("baqend/cli");
|
|
9
9
|
const logging_helper_1 = require("../helpers/logging-helper");
|
|
10
10
|
const cli_parameters_1 = require("../models/cli-parameters");
|
|
@@ -36,16 +36,16 @@ class FindPops extends core_1.Command {
|
|
|
36
36
|
pops = {};
|
|
37
37
|
async run() {
|
|
38
38
|
const { args: { app }, flags: { ips }, } = await this.parse(FindPops);
|
|
39
|
-
const
|
|
39
|
+
const database = await cli_1.account.login({ app });
|
|
40
40
|
const ranges = ips.split(",");
|
|
41
41
|
const fetches = [];
|
|
42
42
|
for (const range of ranges) {
|
|
43
|
-
for (let
|
|
44
|
-
fetches.push(this.getPop(range.replace("x", String(
|
|
43
|
+
for (let index = 0; index < 255; index++) {
|
|
44
|
+
fetches.push(this.getPop(range.replace("x", String(index)), app, database.token));
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
const results = await Promise.all(fetches);
|
|
48
|
-
|
|
48
|
+
for (const r of results) {
|
|
49
49
|
if (r) {
|
|
50
50
|
const airport = airports[r.pop];
|
|
51
51
|
let id = r.pop;
|
|
@@ -55,8 +55,8 @@ class FindPops extends core_1.Command {
|
|
|
55
55
|
this.pops[id] = this.pops[id] || [];
|
|
56
56
|
this.pops[id].push(r.ip);
|
|
57
57
|
}
|
|
58
|
-
}
|
|
59
|
-
|
|
58
|
+
}
|
|
59
|
+
node_fs_1.default.writeFileSync("pops.json", JSON.stringify(this.pops));
|
|
60
60
|
(0, logging_helper_1.logInfo)("List of POPs was successfully created in pops.json");
|
|
61
61
|
}
|
|
62
62
|
async getPop(ip, app, token) {
|
|
@@ -79,7 +79,7 @@ class FindPops extends core_1.Command {
|
|
|
79
79
|
pop: servedBy.split("-")[2],
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
|
-
catch
|
|
82
|
+
catch {
|
|
83
83
|
return null;
|
|
84
84
|
}
|
|
85
85
|
}
|
|
@@ -4,7 +4,7 @@ export default class GenerateCustomerConfig extends Command {
|
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
6
|
app: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
7
|
-
|
|
7
|
+
customersDirectory: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
8
8
|
};
|
|
9
9
|
run(): Promise<void>;
|
|
10
10
|
}
|
|
@@ -6,22 +6,22 @@ const customer_config_1 = require("../services/customer-config");
|
|
|
6
6
|
class GenerateCustomerConfig extends core_1.Command {
|
|
7
7
|
static description = "Generates a customer config guided by a wizard 🧙";
|
|
8
8
|
static examples = [
|
|
9
|
-
`$ sk generate-customer-config -${cli_parameters_1.CLIParametersChar.AppName} <${cli_parameters_1.CLIParameters.AppName}> -${cli_parameters_1.CLIParametersChar.
|
|
10
|
-
`$ sk generate-customer-config -${cli_parameters_1.CLIParametersChar.AppName} ${cli_parameters_1.CLIParametersExample.AppName} -${cli_parameters_1.CLIParametersChar.
|
|
9
|
+
`$ sk generate-customer-config -${cli_parameters_1.CLIParametersChar.AppName} <${cli_parameters_1.CLIParameters.AppName}> -${cli_parameters_1.CLIParametersChar.CustomersDirectory} <${cli_parameters_1.CLIParameters.CustomersDirectory}>`,
|
|
10
|
+
`$ sk generate-customer-config -${cli_parameters_1.CLIParametersChar.AppName} ${cli_parameters_1.CLIParametersExample.AppName} -${cli_parameters_1.CLIParametersChar.CustomersDirectory} ${cli_parameters_1.CLIParametersExample.CustomersDirectory}`,
|
|
11
11
|
];
|
|
12
12
|
static flags = {
|
|
13
13
|
[cli_parameters_1.CLIParameters.AppName]: core_1.Flags.string({
|
|
14
14
|
char: cli_parameters_1.CLIParametersChar.AppName,
|
|
15
15
|
description: "The SK app name which is also being used the config output directory name (kebab-case)",
|
|
16
16
|
}),
|
|
17
|
-
[cli_parameters_1.CLIParameters.
|
|
18
|
-
char: cli_parameters_1.CLIParametersChar.
|
|
19
|
-
description: `Name of the sk-onboarding directory where all customer configs are being stored (default: "${cli_parameters_1.CLIParametersExample.
|
|
17
|
+
[cli_parameters_1.CLIParameters.CustomersDirectory]: core_1.Flags.string({
|
|
18
|
+
char: cli_parameters_1.CLIParametersChar.CustomersDirectory,
|
|
19
|
+
description: `Name of the sk-onboarding directory where all customer configs are being stored (default: "${cli_parameters_1.CLIParametersExample.CustomersDirectory}")`,
|
|
20
20
|
}),
|
|
21
21
|
};
|
|
22
22
|
async run() {
|
|
23
|
-
const { flags: { app,
|
|
24
|
-
const context = new customer_config_1.CustomerConfigServiceContext(app,
|
|
23
|
+
const { flags: { app, customersDirectory }, } = await this.parse(GenerateCustomerConfig);
|
|
24
|
+
const context = new customer_config_1.CustomerConfigServiceContext(app, customersDirectory);
|
|
25
25
|
const customerConfigService = await new customer_config_1.CustomerConfigServiceFactory(context).buildService();
|
|
26
26
|
await customerConfigService.generateConfig();
|
|
27
27
|
}
|
|
@@ -118,8 +118,8 @@ class GeneratePopConfig extends core_1.Command {
|
|
|
118
118
|
}
|
|
119
119
|
async deployPrewarmingConfig(app, config, deploy) {
|
|
120
120
|
const moduleName = "speedKit.Revalidated";
|
|
121
|
-
const
|
|
122
|
-
const configService = new config_api_service_1.default(
|
|
121
|
+
const database = await cli_1.account.login({ app });
|
|
122
|
+
const configService = new config_api_service_1.default(database, app);
|
|
123
123
|
const cliService = new cli_2.CliServiceFactory().getService();
|
|
124
124
|
const diffService = new diff_service_1.DiffService(cliService);
|
|
125
125
|
const popPrewarmingCode = await this.createPopPrewarmingCode(config);
|
package/dist/commands/login.js
CHANGED
|
@@ -5,7 +5,7 @@ const core_1 = require("@oclif/core");
|
|
|
5
5
|
const cli_1 = require("baqend/cli");
|
|
6
6
|
const cli_parameters_1 = require("../models/cli-parameters");
|
|
7
7
|
const node_fs_1 = require("node:fs");
|
|
8
|
-
const
|
|
8
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
9
9
|
class Login extends core_1.Command {
|
|
10
10
|
static description = "Login to your app";
|
|
11
11
|
static args = {
|
|
@@ -21,13 +21,14 @@ class Login extends core_1.Command {
|
|
|
21
21
|
"$ sk login appName",
|
|
22
22
|
];
|
|
23
23
|
async run() {
|
|
24
|
-
const
|
|
24
|
+
const parsedLogin = await this.parse(Login);
|
|
25
|
+
const { app } = parsedLogin.args;
|
|
25
26
|
this.createLoginTokenFileIfNotExists();
|
|
26
27
|
await cli_1.account.persistLogin({ app });
|
|
27
28
|
}
|
|
28
29
|
createLoginTokenFileIfNotExists() {
|
|
29
|
-
if (!(0, node_fs_1.existsSync)(
|
|
30
|
-
(0, node_fs_1.writeFileSync)(
|
|
30
|
+
if (!(0, node_fs_1.existsSync)(node_path_1.default.resolve(this.config.home, ".baqend"))) {
|
|
31
|
+
(0, node_fs_1.writeFileSync)(node_path_1.default.resolve(this.config.home, ".baqend"), "{}");
|
|
31
32
|
(0, node_fs_1.writeFileSync)("~/.baqend", "{}");
|
|
32
33
|
}
|
|
33
34
|
}
|
|
@@ -11,7 +11,7 @@ export default class PopPrewarm extends Command {
|
|
|
11
11
|
};
|
|
12
12
|
static examples: string[];
|
|
13
13
|
run(): Promise<void>;
|
|
14
|
-
getCount(
|
|
15
|
-
queryDb(
|
|
16
|
-
fetchAssets(
|
|
14
|
+
getCount(database: EntityManager, contentTypes: string[]): Promise<any>;
|
|
15
|
+
queryDb(database: EntityManager, contentTypes: string[], lastId?: string): Promise<any>;
|
|
16
|
+
fetchAssets(database: EntityManager, ips: string[], contentTypes: string[], app: string, progress: any, lastId?: string): Promise<any>;
|
|
17
17
|
}
|
|
@@ -33,30 +33,33 @@ class PopPrewarm extends core_1.Command {
|
|
|
33
33
|
];
|
|
34
34
|
async run() {
|
|
35
35
|
const { args: { app }, flags: { ips, contentTypes }, } = await this.parse(PopPrewarm);
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
const count = await this.getCount(
|
|
36
|
+
const database = await cli_1.account.login({ app });
|
|
37
|
+
const contentTypeArray = contentTypes.split(",");
|
|
38
|
+
const ipsArray = ips.split(",");
|
|
39
|
+
const count = await this.getCount(database, contentTypeArray);
|
|
40
40
|
const progress = core_2.ux.progress();
|
|
41
41
|
progress.start(count * ips.length, 0);
|
|
42
|
-
await this.fetchAssets(
|
|
42
|
+
await this.fetchAssets(database, ipsArray, contentTypeArray, app, progress);
|
|
43
43
|
progress.stop();
|
|
44
44
|
}
|
|
45
|
-
async getCount(
|
|
46
|
-
return
|
|
45
|
+
async getCount(database, contentTypes) {
|
|
46
|
+
return database["speedKit.Asset"]
|
|
47
|
+
.find()
|
|
48
|
+
.in("contentType", contentTypes)
|
|
49
|
+
.count();
|
|
47
50
|
}
|
|
48
|
-
async queryDb(
|
|
49
|
-
let qb =
|
|
51
|
+
async queryDb(database, contentTypes, lastId = "") {
|
|
52
|
+
let qb = database["speedKit.Asset"].find().in("contentType", contentTypes);
|
|
50
53
|
if (lastId) {
|
|
51
54
|
qb = qb.gt("id", lastId);
|
|
52
55
|
}
|
|
53
56
|
return qb.limit(100).sort({ id: 1 }).resultList();
|
|
54
57
|
}
|
|
55
58
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
56
|
-
async fetchAssets(
|
|
57
|
-
const resultList = await this.queryDb(
|
|
59
|
+
async fetchAssets(database, ips, contentTypes, app, progress, lastId = "") {
|
|
60
|
+
const resultList = await this.queryDb(database, contentTypes, lastId);
|
|
58
61
|
if (resultList.length === 0) {
|
|
59
|
-
return
|
|
62
|
+
return;
|
|
60
63
|
}
|
|
61
64
|
const assetChunks = prewarm_service_1.default.chunk(resultList, 50);
|
|
62
65
|
let fetches = [];
|
|
@@ -66,7 +69,7 @@ class PopPrewarm extends core_1.Command {
|
|
|
66
69
|
let { url } = asset;
|
|
67
70
|
const { origin, variation, extendedURL } = asset;
|
|
68
71
|
url += extendedURL || "";
|
|
69
|
-
fetches.push(prewarm_service_1.default.fetchURLByIp(ip, url, origin, variation, app,
|
|
72
|
+
fetches.push(prewarm_service_1.default.fetchURLByIp(ip, url, origin, variation, app, database.token));
|
|
70
73
|
}
|
|
71
74
|
try {
|
|
72
75
|
// eslint-disable-next-line no-await-in-loop
|
|
@@ -79,9 +82,9 @@ class PopPrewarm extends core_1.Command {
|
|
|
79
82
|
fetches = [];
|
|
80
83
|
}
|
|
81
84
|
}
|
|
82
|
-
|
|
83
|
-
this.log(resultList
|
|
84
|
-
return this.fetchAssets(
|
|
85
|
+
database.clear();
|
|
86
|
+
this.log(resultList.at(-1).url);
|
|
87
|
+
return this.fetchAssets(database, ips, contentTypes, app, progress, resultList.at(-1).id);
|
|
85
88
|
}
|
|
86
89
|
}
|
|
87
90
|
exports.default = PopPrewarm;
|
package/dist/commands/prewarm.js
CHANGED
|
@@ -7,8 +7,8 @@ const cli_1 = require("baqend/cli");
|
|
|
7
7
|
const cli_parameters_1 = require("../models/cli-parameters");
|
|
8
8
|
const logging_helper_1 = require("../helpers/logging-helper");
|
|
9
9
|
const prewarm_service_1 = tslib_1.__importDefault(require("../services/prewarm-service"));
|
|
10
|
-
const
|
|
11
|
-
const
|
|
10
|
+
const node_url_1 = require("node:url");
|
|
11
|
+
const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
|
|
12
12
|
class Prewarm extends core_1.Command {
|
|
13
13
|
static description = "Pre-warm Fastly";
|
|
14
14
|
static args = {
|
|
@@ -55,12 +55,12 @@ class Prewarm extends core_1.Command {
|
|
|
55
55
|
async run() {
|
|
56
56
|
const { args: { app, path }, flags: { variation, variationPath, delay, keepParameterSorting }, } = await this.parse(Prewarm);
|
|
57
57
|
const sortParameters = !keepParameterSorting;
|
|
58
|
-
const
|
|
58
|
+
const database = await cli_1.account.login({ app });
|
|
59
59
|
const urls = this.loadAssets(path);
|
|
60
60
|
const variations = variationPath
|
|
61
61
|
? this.loadVariations(variationPath)
|
|
62
62
|
: [variation];
|
|
63
|
-
await this.prewarmVariations(variations, urls, app,
|
|
63
|
+
await this.prewarmVariations(variations, urls, app, database.token, delay, sortParameters);
|
|
64
64
|
}
|
|
65
65
|
/**
|
|
66
66
|
* Pre-warms a list of URLs with the given variations.
|
|
@@ -105,14 +105,14 @@ class Prewarm extends core_1.Command {
|
|
|
105
105
|
progress.stop();
|
|
106
106
|
}
|
|
107
107
|
loadAssets(path, origin = "") {
|
|
108
|
-
const data =
|
|
108
|
+
const data = node_fs_1.default.readFileSync(path, "utf8");
|
|
109
109
|
const entries = data.split(/\r?\n/);
|
|
110
110
|
return entries.map((entry) => {
|
|
111
111
|
entry = /^"[^"]+"/.test(entry) ? entry.slice(1, -1) : entry;
|
|
112
112
|
try {
|
|
113
113
|
return {
|
|
114
114
|
url: entry,
|
|
115
|
-
origin: origin || new
|
|
115
|
+
origin: origin || new node_url_1.URL(entry).origin,
|
|
116
116
|
};
|
|
117
117
|
}
|
|
118
118
|
catch (error) {
|
|
@@ -127,17 +127,17 @@ class Prewarm extends core_1.Command {
|
|
|
127
127
|
*/
|
|
128
128
|
loadVariations(path) {
|
|
129
129
|
const variations = [];
|
|
130
|
-
const data =
|
|
130
|
+
const data = node_fs_1.default.readFileSync(path, "utf8");
|
|
131
131
|
const entries = data.split(/\r?\n/);
|
|
132
|
-
|
|
132
|
+
for (const entry of entries) {
|
|
133
133
|
if (entry !== "") {
|
|
134
134
|
variations.push(entry);
|
|
135
135
|
}
|
|
136
|
-
}
|
|
136
|
+
}
|
|
137
137
|
return variations;
|
|
138
138
|
}
|
|
139
139
|
async sleep(ms) {
|
|
140
|
-
return new Promise((
|
|
140
|
+
return new Promise((response) => setTimeout(response, ms));
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
exports.default = Prewarm;
|
|
@@ -16,6 +16,6 @@ export default class WptLauncher extends Command {
|
|
|
16
16
|
isMobile(mobile: string): boolean;
|
|
17
17
|
getViewPortSize(isMobile: boolean): string;
|
|
18
18
|
allResourceUrls(urls: string): Array<string>;
|
|
19
|
-
getResourceOrigin(
|
|
19
|
+
getResourceOrigin(urlsArray: Array<string>): string;
|
|
20
20
|
postScript(script: string): Promise<NonNullable<unknown>>;
|
|
21
21
|
}
|
|
@@ -46,9 +46,9 @@ class WptLauncher extends core_1.Command {
|
|
|
46
46
|
exec localStorage.setItem('baqend-speedkit-ab-test-info', encodeURIComponent(JSON.stringify({group:${group},testId:${testId})));
|
|
47
47
|
navigate ${resourceOrigin}
|
|
48
48
|
navigate ${WptLauncher.localhostUrl}`;
|
|
49
|
-
this.allResourceUrls(urls)
|
|
49
|
+
for (const url of this.allResourceUrls(urls)) {
|
|
50
50
|
script += `\n navigate ${url}`;
|
|
51
|
-
}
|
|
51
|
+
}
|
|
52
52
|
const postscript = (await this.postScript(script));
|
|
53
53
|
const currentTestIdUrl = `http://wpt.baqend.com/results.php?test=${postscript.wptTestId}`;
|
|
54
54
|
if (!currentTestIdUrl) {
|
|
@@ -73,23 +73,23 @@ class WptLauncher extends core_1.Command {
|
|
|
73
73
|
return "1500 1300"; // desktop
|
|
74
74
|
}
|
|
75
75
|
allResourceUrls(urls) {
|
|
76
|
-
const
|
|
77
|
-
if (
|
|
78
|
-
return
|
|
76
|
+
const urlsArray = urls.split(",");
|
|
77
|
+
if (urlsArray.length > 0) {
|
|
78
|
+
return urlsArray;
|
|
79
79
|
}
|
|
80
80
|
throw new Error("urls must not be null");
|
|
81
81
|
}
|
|
82
|
-
getResourceOrigin(
|
|
83
|
-
return new URL(
|
|
82
|
+
getResourceOrigin(urlsArray) {
|
|
83
|
+
return new URL(urlsArray[0]).origin;
|
|
84
84
|
}
|
|
85
85
|
// ---------------- wpt launcher --------------------------
|
|
86
86
|
async postScript(script) {
|
|
87
87
|
const urlPath = "https://makefast.app.baqend.com/v1/code/testAPI";
|
|
88
|
-
const
|
|
88
|
+
const response = await (0, node_fetch_1.default)(urlPath, {
|
|
89
89
|
body: JSON.stringify({ script }),
|
|
90
90
|
method: "POST",
|
|
91
91
|
});
|
|
92
|
-
return
|
|
92
|
+
return response.json();
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
exports.default = WptLauncher;
|
|
@@ -16,17 +16,17 @@ export declare function getBlacklistedFilter(parsedConfig: any): string;
|
|
|
16
16
|
* @param params - The stripped parameters that are named within the speed kit config.
|
|
17
17
|
* @param skConfigVersion - The Speed Kit config ruleset version.
|
|
18
18
|
*/
|
|
19
|
-
export declare function getParameterFilter(
|
|
19
|
+
export declare function getParameterFilter(parameters: (string | RegExp)[], skConfigVersion?: number): string;
|
|
20
20
|
/**
|
|
21
21
|
* Returns the parameter replace (regexp_replace) as a SQL query string.
|
|
22
22
|
*
|
|
23
23
|
* @param params - The stripped parameters that are named within the speed kit config.
|
|
24
24
|
* @param skConfigVersion - The Speed Kit config ruleset version.
|
|
25
25
|
*/
|
|
26
|
-
export declare function getParameterReplaceFilter(
|
|
26
|
+
export declare function getParameterReplaceFilter(parameters: (string | RegExp)[], skConfigVersion?: number): string;
|
|
27
27
|
/**
|
|
28
28
|
* Returns the stripped parameters that are named within the speed kit config.
|
|
29
29
|
*
|
|
30
30
|
* @param parsedConfig - The speed kit config parsed as an object.
|
|
31
31
|
*/
|
|
32
|
-
export declare function
|
|
32
|
+
export declare function getStrippedParameters(parsedConfig: any): (string | RegExp)[];
|