@speedkit/cli 2.13.0 → 2.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +1 -1
  3. package/dist/commands/document-handler.d.ts +1 -1
  4. package/dist/commands/document-handler.js +4 -4
  5. package/dist/commands/find-pops.d.ts +1 -1
  6. package/dist/commands/find-pops.js +21 -18
  7. package/dist/commands/login.d.ts +1 -1
  8. package/dist/commands/login.js +4 -4
  9. package/dist/commands/onboarding.d.ts +1 -1
  10. package/dist/commands/onboarding.js +12 -4
  11. package/dist/commands/param-diff.d.ts +2 -2
  12. package/dist/commands/param-diff.js +16 -16
  13. package/dist/commands/pop-prewarm.d.ts +2 -2
  14. package/dist/commands/pop-prewarm.js +20 -13
  15. package/dist/commands/prewarm.d.ts +2 -2
  16. package/dist/commands/prewarm.js +35 -19
  17. package/dist/commands/pull.d.ts +1 -1
  18. package/dist/commands/pull.js +2 -2
  19. package/dist/commands/wpt-launcher.d.ts +2 -2
  20. package/dist/commands/wpt-launcher.js +35 -19
  21. package/dist/helpers/CustomerConfig.d.ts +1 -1
  22. package/dist/helpers/CustomerConfig.js +36 -35
  23. package/dist/helpers/file-helper.js +6 -6
  24. package/dist/services/onboarding/browser/baqend-response.d.ts +3 -3
  25. package/dist/services/onboarding/browser/baqend-response.js +13 -12
  26. package/dist/services/onboarding/config-renderer/speed-kit-install-context.d.ts +4 -4
  27. package/dist/services/onboarding/config-renderer/speed-kit-install-context.js +38 -38
  28. package/dist/services/onboarding/dashboard/athena-service.d.ts +1 -1
  29. package/dist/services/onboarding/dashboard/athena-service.js +12 -12
  30. package/dist/services/onboarding/dashboard/index.d.ts +3 -3
  31. package/dist/services/onboarding/dashboard/index.js +14 -14
  32. package/dist/services/onboarding/dashboard/request-diff-service.d.ts +1 -1
  33. package/dist/services/onboarding/dashboard/request-diff-service.js +23 -23
  34. package/dist/services/onboarding/fetch-event-handler.d.ts +6 -6
  35. package/dist/services/onboarding/fetch-event-handler.js +52 -52
  36. package/dist/services/onboarding/fetch-events/customer-domain-document-response.d.ts +7 -7
  37. package/dist/services/onboarding/fetch-events/customer-domain-document-response.js +43 -43
  38. package/dist/services/onboarding/fetch-events/customer-service-worker-js.d.ts +2 -2
  39. package/dist/services/onboarding/fetch-events/customer-service-worker-js.js +4 -4
  40. package/dist/services/onboarding/fetch-events/dashboard-request.d.ts +1 -1
  41. package/dist/services/onboarding/fetch-events/dashboard-request.js +2 -2
  42. package/dist/services/onboarding/fetch-events/speed-kit-asset-request.d.ts +7 -7
  43. package/dist/services/onboarding/fetch-events/speed-kit-asset-request.js +27 -27
  44. package/dist/services/onboarding/fetch-events/speed-kit-install-html.d.ts +2 -2
  45. package/dist/services/onboarding/fetch-events/speed-kit-install-html.js +12 -12
  46. package/dist/services/onboarding/file-events/file-watcher.d.ts +9 -9
  47. package/dist/services/onboarding/file-events/file-watcher.js +67 -67
  48. package/dist/services/onboarding/onboarding-service.d.ts +6 -6
  49. package/dist/services/onboarding/onboarding-service.js +38 -39
  50. package/dist/services/onboarding/request-cache/cache.d.ts +3 -3
  51. package/dist/services/onboarding/request-cache/cache.js +7 -7
  52. package/dist/services/onboarding/server-config/index.js +1 -1
  53. package/dist/services/onboarding/todo-collector.d.ts +1 -1
  54. package/dist/services/onboarding/todo-collector.js +3 -4
  55. package/oclif.manifest.json +1 -1
  56. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ ## [2.14.1](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.14.0...v2.14.1) (2024-03-20)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **onboarding:** undo perfectionist sorting ([db3ba2e](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/db3ba2ec7395ab84a7e795e5c10f3f463148a97c))
7
+
8
+ # [2.14.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.13.0...v2.14.0) (2024-03-18)
9
+
10
+
11
+ ### Features
12
+
13
+ * optimise ci pipelines ([3b3e68c](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/3b3e68ce78579b066b8d84a476e4291179158cb7))
14
+ * optimise ci pipelines ([695f57b](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/695f57b52132452341c7d02abe24583a11f25648))
15
+
1
16
  # [2.13.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.12.0...v2.13.0) (2024-03-15)
2
17
 
3
18
 
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.13.0 linux-x64 node-v20.11.1
24
+ @speedkit/cli/2.14.1 linux-x64 node-v20.11.1
25
25
  $ sk --help [COMMAND]
26
26
  USAGE
27
27
  $ sk COMMAND
@@ -1,4 +1,4 @@
1
- import { Command } from '@oclif/core';
1
+ import { Command } from "@oclif/core";
2
2
  export default class DocumentHandler extends Command {
3
3
  static description: string;
4
4
  static args: {
@@ -7,7 +7,7 @@ const document_handler_runtime_service_factory_1 = tslib_1.__importDefault(requi
7
7
  const document_handler_runtime_context_1 = tslib_1.__importDefault(require("../services/document-handler-runtime/context/document-handler-runtime-context"));
8
8
  const cli_config_1 = require("../helpers/cli-config");
9
9
  class DocumentHandler extends core_1.Command {
10
- static description = 'Creates testable documentHandler in folder {CUSTOMER_PATH}/test/src/';
10
+ static description = "Creates testable documentHandler in folder {CUSTOMER_PATH}/test/src/";
11
11
  static args = cli_parameters_1.CLI_CUSTOMER_CONFIG;
12
12
  static flags = {
13
13
  ...cli_parameters_1.CLI_CONFIG_NAME,
@@ -15,7 +15,7 @@ class DocumentHandler extends core_1.Command {
15
15
  char: cli_parameters_1.CLIParametersChar.CreateTests,
16
16
  multiple: true,
17
17
  required: false,
18
- description: 'name of the test to create'
18
+ description: "name of the test to create",
19
19
  }),
20
20
  };
21
21
  static examples = [
@@ -23,8 +23,8 @@ class DocumentHandler extends core_1.Command {
23
23
  `$ sk deploy ${cli_parameters_1.CLIParametersExample.CustomerPath} -${cli_parameters_1.CLIParametersChar.ConfigName} ${cli_parameters_1.CLIParametersExample.ConfigName}`,
24
24
  ];
25
25
  async run() {
26
- const { args: { customerPath }, flags: { configName, CreateTests } } = await this.parse(DocumentHandler);
27
- const runtime = await (new document_handler_runtime_service_factory_1.default(new document_handler_runtime_context_1.default(customerPath, configName, CreateTests), new cli_config_1.CliConfig(this.config).load())).buildService();
26
+ const { args: { customerPath }, flags: { configName, CreateTests }, } = await this.parse(DocumentHandler);
27
+ const runtime = await new document_handler_runtime_service_factory_1.default(new document_handler_runtime_context_1.default(customerPath, configName, CreateTests), new cli_config_1.CliConfig(this.config).load()).buildService();
28
28
  await runtime.run();
29
29
  }
30
30
  async finally(error) {
@@ -1,4 +1,4 @@
1
- import { Command } from '@oclif/core';
1
+ import { Command } from "@oclif/core";
2
2
  export default class FindPops extends Command {
3
3
  static description: string;
4
4
  static args: {
@@ -2,29 +2,32 @@
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 logging_helper_1 = require("../helpers/logging-helper");
6
- const airports = tslib_1.__importStar(require("./airports_iata.json"));
7
- const fs = require('fs');
8
- const fetch = require('node-fetch');
9
- const cli_1 = require("baqend/cli");
5
+ const fs_1 = tslib_1.__importDefault(require("fs"));
6
+ const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
10
7
  const https = tslib_1.__importStar(require("https"));
8
+ const cli_1 = require("baqend/cli");
9
+ const logging_helper_1 = require("../helpers/logging-helper");
11
10
  const cli_parameters_1 = require("../models/cli-parameters");
11
+ const airports = tslib_1.__importStar(require("./airports_iata.json"));
12
12
  const agent = new https.Agent({
13
13
  rejectUnauthorized: false,
14
14
  keepAlive: true,
15
15
  });
16
16
  class FindPops extends core_1.Command {
17
- static description = 'Get IPs for all fastly PoPs';
17
+ static description = "Get IPs for all fastly PoPs";
18
18
  static args = {
19
19
  [cli_parameters_1.CLIParameters.AppName]: core_1.Args.string({
20
20
  name: cli_parameters_1.CLIParameters.AppName, // name of arg to show in help and reference with args[name]
21
21
  required: true, // make the arg required with `required: true`
22
- description: 'The customers appName', // help description
22
+ description: "The customers appName", // help description
23
23
  hidden: false, // hide this arg from help
24
24
  }),
25
25
  };
26
26
  static flags = {
27
- [cli_parameters_1.CLIParameters.Ips]: core_1.Flags.string({ default: '151.101.x.194', char: cli_parameters_1.CLIParametersChar.Ips }),
27
+ [cli_parameters_1.CLIParameters.Ips]: core_1.Flags.string({
28
+ default: "151.101.x.194",
29
+ char: cli_parameters_1.CLIParametersChar.Ips,
30
+ }),
28
31
  };
29
32
  static examples = [
30
33
  `$ sk find-pops <${cli_parameters_1.CLIParameters.AppName}> -${cli_parameters_1.CLIParametersChar.Ips} <${cli_parameters_1.CLIParameters.Ips}>`,
@@ -32,17 +35,17 @@ class FindPops extends core_1.Command {
32
35
  ];
33
36
  pops = {};
34
37
  async run() {
35
- const { args: { app }, flags: { ips } } = await this.parse(FindPops);
38
+ const { args: { app }, flags: { ips }, } = await this.parse(FindPops);
36
39
  const db = await cli_1.account.login({ app });
37
- const ranges = ips.split(',');
40
+ const ranges = ips.split(",");
38
41
  const fetches = [];
39
42
  for (const range of ranges) {
40
43
  for (let i = 0; i < 255; i++) {
41
- fetches.push(this.getPop(range.replace('x', String(i)), app, db.token));
44
+ fetches.push(this.getPop(range.replace("x", String(i)), app, db.token));
42
45
  }
43
46
  }
44
47
  const results = await Promise.all(fetches);
45
- results.forEach(r => {
48
+ results.forEach((r) => {
46
49
  if (r) {
47
50
  const airport = airports[r.pop];
48
51
  let id = r.pop;
@@ -53,27 +56,27 @@ class FindPops extends core_1.Command {
53
56
  this.pops[id].push(r.ip);
54
57
  }
55
58
  });
56
- fs.writeFileSync('pops.json', JSON.stringify(this.pops));
57
- (0, logging_helper_1.logInfo)('List of POPs was successfully created in pops.json');
59
+ fs_1.default.writeFileSync("pops.json", JSON.stringify(this.pops));
60
+ (0, logging_helper_1.logInfo)("List of POPs was successfully created in pops.json");
58
61
  }
59
62
  async getPop(ip, app, token) {
60
63
  try {
61
- const resp = await fetch(`https://${ip}/`, {
64
+ const resp = await (0, node_fetch_1.default)(`https://${ip}/`, {
62
65
  agent,
63
- method: 'HEAD',
66
+ method: "HEAD",
64
67
  headers: {
65
68
  Host: `${app}.app.baqend.com`,
66
69
  authorization: `BAT ${token}`,
67
70
  },
68
71
  timeout: 10_000,
69
72
  });
70
- const servedBy = resp.headers.get('x-served-by');
73
+ const servedBy = resp.headers.get("x-served-by");
71
74
  if (resp.status !== 200 || !servedBy) {
72
75
  return null;
73
76
  }
74
77
  return {
75
78
  ip,
76
- pop: servedBy.split('-')[2],
79
+ pop: servedBy.split("-")[2],
77
80
  };
78
81
  }
79
82
  catch (error) {
@@ -1,4 +1,4 @@
1
- import { Command } from '@oclif/core';
1
+ import { Command } from "@oclif/core";
2
2
  export default class Login extends Command {
3
3
  static description: string;
4
4
  static args: {
@@ -7,18 +7,18 @@ const cli_parameters_1 = require("../models/cli-parameters");
7
7
  const node_fs_1 = require("node:fs");
8
8
  const path_1 = tslib_1.__importDefault(require("path"));
9
9
  class Login extends core_1.Command {
10
- static description = 'Login to your app';
10
+ static description = "Login to your app";
11
11
  static args = {
12
12
  [cli_parameters_1.CLIParameters.AppName]: core_1.Args.string({
13
13
  name: cli_parameters_1.CLIParameters.AppName, // name of arg to show in help and reference with args[name]
14
14
  required: false,
15
- default: 'bbq',
16
- description: 'The customers appName', // help description
15
+ default: "bbq",
16
+ description: "The customers appName", // help description
17
17
  }),
18
18
  };
19
19
  static examples = [
20
20
  `$ sk login <${cli_parameters_1.CLIParameters.AppName}>`,
21
- '$ sk login appName',
21
+ "$ sk login appName",
22
22
  ];
23
23
  async run() {
24
24
  const { app } = (await this.parse(Login)).args;
@@ -1,4 +1,4 @@
1
- import { Command } from '@oclif/core';
1
+ import { Command } from "@oclif/core";
2
2
  export default class Onboarding extends Command {
3
3
  static description: string;
4
4
  static flags: {
@@ -5,11 +5,19 @@ const cli_parameters_1 = require("../models/cli-parameters");
5
5
  const onboarding_1 = require("../services/onboarding");
6
6
  const cli_config_1 = require("../helpers/cli-config");
7
7
  class Onboarding extends core_1.Command {
8
- static description = 'Start a local dev environment for building and testing the Speed Kit configuration';
8
+ static description = "Start a local dev environment for building and testing the Speed Kit configuration";
9
9
  static flags = {
10
10
  ...cli_parameters_1.CLI_CONFIG_NAME,
11
- 'local': core_1.Flags.boolean({ char: 'l', default: false, description: 'Run with local documentHandler' }),
12
- 'verboseLevel': core_1.Flags.boolean({ char: 'v', default: false, description: 'Show all messages' }),
11
+ local: core_1.Flags.boolean({
12
+ char: "l",
13
+ default: false,
14
+ description: "Run with local documentHandler",
15
+ }),
16
+ verboseLevel: core_1.Flags.boolean({
17
+ char: "v",
18
+ default: false,
19
+ description: "Show all messages",
20
+ }),
13
21
  };
14
22
  static args = cli_parameters_1.CLI_CUSTOMER_CONFIG;
15
23
  static examples = [
@@ -17,7 +25,7 @@ class Onboarding extends core_1.Command {
17
25
  `$ sk onboarding ${cli_parameters_1.CLIParametersExample.CustomerPath} -${cli_parameters_1.CLIParametersChar.ConfigName} ${cli_parameters_1.CLIParametersExample.ConfigName}`,
18
26
  ];
19
27
  async run() {
20
- const { args: { customerPath }, flags: { configName, local, verboseLevel } } = await this.parse(Onboarding);
28
+ const { args: { customerPath }, flags: { configName, local, verboseLevel }, } = await this.parse(Onboarding);
21
29
  const service = await new onboarding_1.OnboardingServiceFactory(new onboarding_1.OnboardingContext(customerPath, configName, local, verboseLevel), new cli_config_1.CliConfig(this.config).load()).getService();
22
30
  await service.run();
23
31
  }
@@ -1,4 +1,4 @@
1
- import { Command } from '@oclif/core';
1
+ import { Config, Command } from "@oclif/core";
2
2
  import { CliService } from "../services/cli";
3
3
  export default class ParamDiff extends Command {
4
4
  cli: CliService;
@@ -10,7 +10,7 @@ export default class ParamDiff extends Command {
10
10
  hideDiff: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
11
11
  };
12
12
  static examples: string[];
13
- constructor(argv: string[], config: any);
13
+ constructor(argv: string[], config: Config);
14
14
  logError(message: any): void;
15
15
  run(): Promise<void>;
16
16
  }
@@ -10,19 +10,19 @@ const diff_1 = require("../services/diff");
10
10
  const cli_config_1 = require("../helpers/cli-config");
11
11
  class ParamDiff extends core_1.Command {
12
12
  cli;
13
- static description = 'Shows difference in documents with query parameters on/off';
13
+ static description = "Shows difference in documents with query parameters on/off";
14
14
  static args = {
15
15
  [cli_parameters_1.CLIParameters.PageUrl]: core_1.Args.string({
16
16
  name: cli_parameters_1.CLIParameters.PageUrl,
17
17
  required: true,
18
- description: 'Link of the page',
19
- example: cli_parameters_1.CLIParametersExample.PageUrl
20
- })
18
+ description: "Link of the page",
19
+ example: cli_parameters_1.CLIParametersExample.PageUrl,
20
+ }),
21
21
  };
22
22
  static flags = {
23
23
  [cli_parameters_1.CLIParameters.HideDiff]: core_1.Flags.boolean({
24
24
  char: cli_parameters_1.CLIParametersChar.HideDiff,
25
- description: 'Hide the code diff in IDE code diff window'
25
+ description: "Hide the code diff in IDE code diff window",
26
26
  }),
27
27
  };
28
28
  static examples = [
@@ -43,7 +43,7 @@ class ParamDiff extends core_1.Command {
43
43
  const { pageUrl: originalUrl } = args;
44
44
  const originalData = await (0, scrape_1.default)(originalUrl);
45
45
  if (!originalData) {
46
- this.logError('Failed to fetch original document');
46
+ this.logError("Failed to fetch original document");
47
47
  }
48
48
  const parsedUrl = url.parse(originalUrl, true);
49
49
  const withoutAnyParamsUrl = url.format({
@@ -53,13 +53,13 @@ class ParamDiff extends core_1.Command {
53
53
  });
54
54
  const withoutAnyParamsData = await (0, scrape_1.default)(withoutAnyParamsUrl);
55
55
  if (!withoutAnyParamsData) {
56
- this.logError('Failed to fetch document without any params');
56
+ this.logError("Failed to fetch document without any params");
57
57
  }
58
58
  const userConfig = new cli_config_1.CliConfig(this.config).load();
59
59
  const context = new diff_1.DiffContext(userConfig.diffExec, userConfig.diffExecTemplate);
60
60
  const diffService = new diff_1.DiffServiceFactory(context).getService();
61
- const originalFilePath = await diffService.writeContentToTemporalFile('original.html', originalData);
62
- const withoutAnyParamsFilePath = await diffService.writeContentToTemporalFile('without-any-params.html', withoutAnyParamsData);
61
+ const originalFilePath = await diffService.writeContentToTemporalFile("original.html", originalData);
62
+ const withoutAnyParamsFilePath = await diffService.writeContentToTemporalFile("without-any-params.html", withoutAnyParamsData);
63
63
  this.cli.spacer();
64
64
  this.cli.write(`Checking any parameter...`);
65
65
  this.cli.write(`- with: ${originalUrl}`);
@@ -69,19 +69,19 @@ class ParamDiff extends core_1.Command {
69
69
  this.cli.writeSuccess(`✅ No diff found`);
70
70
  return;
71
71
  }
72
- this.cli.writeWarning('⚠️ Found diff');
72
+ this.cli.writeWarning("⚠️ Found diff");
73
73
  // If there is more than one query params given &
74
74
  // there's a difference in the general check, do a detailed check:
75
75
  if (Object.keys(parsedUrl.query).length === 1)
76
76
  return;
77
- for (let param in parsedUrl.query) {
77
+ for (const param in parsedUrl.query) {
78
78
  const withoutCurrentParamQuery = { ...parsedUrl.query };
79
79
  delete withoutCurrentParamQuery[param]; // Remove the current parameter
80
80
  const withoutCurrentParamUrl = url.format({
81
81
  protocol: parsedUrl.protocol,
82
82
  host: parsedUrl.host,
83
83
  pathname: parsedUrl.pathname,
84
- query: withoutCurrentParamQuery
84
+ query: withoutCurrentParamQuery,
85
85
  });
86
86
  const withoutCurrentParamData = await (0, scrape_1.default)(withoutCurrentParamUrl);
87
87
  if (!withoutCurrentParamData) {
@@ -92,14 +92,14 @@ class ParamDiff extends core_1.Command {
92
92
  this.cli.write(`Checking "${param}" parameter...`);
93
93
  this.cli.write(`- with: ${originalUrl}`);
94
94
  this.cli.write(`- without: ${withoutCurrentParamUrl}`);
95
- const hasSpecificDiff = !await diffService.executeDiff(originalFilePath, withoutCurrentParamFilePath, flags.hideDiff);
95
+ const hasSpecificDiff = !(await diffService.executeDiff(originalFilePath, withoutCurrentParamFilePath, flags.hideDiff));
96
96
  if (hasSpecificDiff) {
97
- const hasDiffWithoutAnyParams = !await diffService.executeDiff(withoutAnyParamsFilePath, withoutCurrentParamFilePath, true);
97
+ const hasDiffWithoutAnyParams = !(await diffService.executeDiff(withoutAnyParamsFilePath, withoutCurrentParamFilePath, true));
98
98
  if (hasDiffWithoutAnyParams) {
99
- this.cli.writeWarning('⚠️ Found diff');
99
+ this.cli.writeWarning("⚠️ Found diff");
100
100
  }
101
101
  else {
102
- this.cli.writeWarning('⚠️ Found diff (identical with having all params removed)');
102
+ this.cli.writeWarning("⚠️ Found diff (identical with having all params removed)");
103
103
  }
104
104
  }
105
105
  else {
@@ -1,5 +1,5 @@
1
- import { Command } from '@oclif/core';
2
- import { EntityManager } from 'baqend';
1
+ import { Command } from "@oclif/core";
2
+ import { EntityManager } from "baqend";
3
3
  export default class PopPrewarm extends Command {
4
4
  static description: string;
5
5
  static args: {
@@ -8,28 +8,34 @@ const prewarm_service_1 = tslib_1.__importDefault(require("../services/prewarm-s
8
8
  const cli_parameters_1 = require("../models/cli-parameters");
9
9
  const logging_helper_1 = require("../helpers/logging-helper");
10
10
  class PopPrewarm extends core_1.Command {
11
- static description = 'Pre-warm Fastly PoPs';
11
+ static description = "Pre-warm Fastly PoPs";
12
12
  static args = {
13
13
  [cli_parameters_1.CLIParameters.AppName]: core_1.Args.string({
14
14
  name: cli_parameters_1.CLIParameters.AppName, // name of arg to show in help and reference with args[name]
15
15
  required: true, // make the arg required with `required: true`
16
- description: 'The customers appName', // help description
16
+ description: "The customers appName", // help description
17
17
  hidden: false, // hide this arg from help
18
18
  }),
19
19
  };
20
20
  static flags = {
21
- [cli_parameters_1.CLIParameters.Ips]: core_1.Flags.string({ default: '151.101.120.194', char: cli_parameters_1.CLIParametersChar.Ips }),
22
- [cli_parameters_1.CLIParameters.ContentTypes]: core_1.Flags.string({ default: 'image', char: cli_parameters_1.CLIParametersChar.ContentTypes }),
21
+ [cli_parameters_1.CLIParameters.Ips]: core_1.Flags.string({
22
+ default: "151.101.120.194",
23
+ char: cli_parameters_1.CLIParametersChar.Ips,
24
+ }),
25
+ [cli_parameters_1.CLIParameters.ContentTypes]: core_1.Flags.string({
26
+ default: "image",
27
+ char: cli_parameters_1.CLIParametersChar.ContentTypes,
28
+ }),
23
29
  };
24
30
  static examples = [
25
31
  `$ sk pop-prewarm <${cli_parameters_1.CLIParameters.AppName}> -${cli_parameters_1.CLIParametersChar.ContentTypes} <${cli_parameters_1.CLIParameters.ContentTypes}> -${cli_parameters_1.CLIParametersChar.Ips} <${cli_parameters_1.CLIParameters.Ips}>`,
26
32
  `$ sk pop-prewarm decathlon -${cli_parameters_1.CLIParametersChar.ContentTypes} ${cli_parameters_1.CLIParametersExample.ContentTypes} -${cli_parameters_1.CLIParametersChar.Ips} ${cli_parameters_1.CLIParametersExample.Ips}`,
27
33
  ];
28
34
  async run() {
29
- const { args: { app }, flags: { ips, contentTypes } } = await this.parse(PopPrewarm);
35
+ const { args: { app }, flags: { ips, contentTypes }, } = await this.parse(PopPrewarm);
30
36
  const db = await cli_1.account.login({ app });
31
- const contentTypeArr = contentTypes.split(',');
32
- const ipsArr = ips.split(',');
37
+ const contentTypeArr = contentTypes.split(",");
38
+ const ipsArr = ips.split(",");
33
39
  const count = await this.getCount(db, contentTypeArr);
34
40
  const progress = core_2.ux.progress();
35
41
  progress.start(count * ips.length, 0);
@@ -37,16 +43,17 @@ class PopPrewarm extends core_1.Command {
37
43
  progress.stop();
38
44
  }
39
45
  async getCount(db, contentTypes) {
40
- return db['speedKit.Asset'].find().in('contentType', contentTypes).count();
46
+ return db["speedKit.Asset"].find().in("contentType", contentTypes).count();
41
47
  }
42
- async queryDb(db, contentTypes, lastId = '') {
43
- let qb = db['speedKit.Asset'].find().in('contentType', contentTypes);
48
+ async queryDb(db, contentTypes, lastId = "") {
49
+ let qb = db["speedKit.Asset"].find().in("contentType", contentTypes);
44
50
  if (lastId) {
45
- qb = qb.gt('id', lastId);
51
+ qb = qb.gt("id", lastId);
46
52
  }
47
53
  return qb.limit(100).sort({ id: 1 }).resultList();
48
54
  }
49
- async fetchAssets(db, ips, contentTypes, app, progress, lastId = '') {
55
+ /* eslint-disable @typescript-eslint/no-explicit-any */
56
+ async fetchAssets(db, ips, contentTypes, app, progress, lastId = "") {
50
57
  const resultList = await this.queryDb(db, contentTypes, lastId);
51
58
  if (resultList.length === 0) {
52
59
  return Promise.resolve();
@@ -58,7 +65,7 @@ class PopPrewarm extends core_1.Command {
58
65
  for (const asset of assets) {
59
66
  let { url } = asset;
60
67
  const { origin, variation, extendedURL } = asset;
61
- url += (extendedURL || '');
68
+ url += extendedURL || "";
62
69
  fetches.push(prewarm_service_1.default.fetchURLByIp(ip, url, origin, variation, app, db.token));
63
70
  }
64
71
  try {
@@ -1,4 +1,4 @@
1
- import { Command } from '@oclif/core';
1
+ import { Command } from "@oclif/core";
2
2
  export default class Prewarm extends Command {
3
3
  static description: string;
4
4
  static args: {
@@ -35,6 +35,6 @@ export default class Prewarm extends Command {
35
35
  * Extracts variations line by line from a given file.
36
36
  * @param path - path to the csv containing variations
37
37
  */
38
- loadVariations(path: string): (string[]);
38
+ loadVariations(path: string): string[];
39
39
  sleep(ms: any): Promise<unknown>;
40
40
  }
@@ -7,27 +7,41 @@ 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 { URL } = require('url');
11
- const fs = require('fs');
10
+ const url_1 = require("url");
11
+ const fs_1 = tslib_1.__importDefault(require("fs"));
12
12
  class Prewarm extends core_1.Command {
13
- static description = 'Pre-warm Fastly';
13
+ static description = "Pre-warm Fastly";
14
14
  static args = {
15
15
  [cli_parameters_1.CLIParameters.AppName]: core_1.Args.string({
16
16
  name: cli_parameters_1.CLIParameters.AppName, // name of arg to show in help and reference with args[name]
17
17
  required: true, // make the arg required with `required: true`
18
- description: 'The customer app name', // help description
18
+ description: "The customer app name", // help description
19
19
  }),
20
20
  [cli_parameters_1.CLIParameters.Path]: core_1.Args.string({
21
21
  name: cli_parameters_1.CLIParameters.Path, // name of arg to show in help and reference with args[name]
22
22
  required: true, // make the arg required with `required: true`
23
- description: 'path to prewarmFile', // help description
23
+ description: "path to prewarmFile", // help description
24
24
  }),
25
25
  };
26
26
  static flags = {
27
- [cli_parameters_1.CLIParameters.Variation]: core_1.Flags.string({ char: cli_parameters_1.CLIParametersChar.Variation, default: 'DEFAULT' }),
28
- [cli_parameters_1.CLIParameters.VariationPath]: core_1.Flags.string({ char: cli_parameters_1.CLIParametersChar.VariationPath, exclusive: [cli_parameters_1.CLIParameters.Variation] }),
29
- [cli_parameters_1.CLIParameters.Delay]: core_1.Flags.integer({ char: cli_parameters_1.CLIParametersChar.Delay, default: 0, description: 'Request delay in ms' }),
30
- [cli_parameters_1.CLIParameters.KeepParameterSorting]: core_1.Flags.boolean({ char: cli_parameters_1.CLIParametersChar.KeepParameterSorting, default: false, description: 'Prevents alphabetical sorting of the URL parameters' }),
27
+ [cli_parameters_1.CLIParameters.Variation]: core_1.Flags.string({
28
+ char: cli_parameters_1.CLIParametersChar.Variation,
29
+ default: "DEFAULT",
30
+ }),
31
+ [cli_parameters_1.CLIParameters.VariationPath]: core_1.Flags.string({
32
+ char: cli_parameters_1.CLIParametersChar.VariationPath,
33
+ exclusive: [cli_parameters_1.CLIParameters.Variation],
34
+ }),
35
+ [cli_parameters_1.CLIParameters.Delay]: core_1.Flags.integer({
36
+ char: cli_parameters_1.CLIParametersChar.Delay,
37
+ default: 0,
38
+ description: "Request delay in ms",
39
+ }),
40
+ [cli_parameters_1.CLIParameters.KeepParameterSorting]: core_1.Flags.boolean({
41
+ char: cli_parameters_1.CLIParametersChar.KeepParameterSorting,
42
+ default: false,
43
+ description: "Prevents alphabetical sorting of the URL parameters",
44
+ }),
31
45
  };
32
46
  static examples = [
33
47
  "for a single variation:",
@@ -39,11 +53,13 @@ class Prewarm extends core_1.Command {
39
53
  `$ sk prewarm ${cli_parameters_1.CLIParametersExample.AppName} ${cli_parameters_1.CLIParametersExample.Path} -${cli_parameters_1.CLIParametersChar.Path} ${cli_parameters_1.CLIParametersExample.VariationPath} -${cli_parameters_1.CLIParametersChar.Delay} ${cli_parameters_1.CLIParametersExample.Delay} -${cli_parameters_1.CLIParametersChar.KeepParameterSorting}`,
40
54
  ];
41
55
  async run() {
42
- const { args: { app, path }, flags: { variation, variationPath, delay, keepParameterSorting } } = await this.parse(Prewarm);
56
+ const { args: { app, path }, flags: { variation, variationPath, delay, keepParameterSorting }, } = await this.parse(Prewarm);
43
57
  const sortParameters = !keepParameterSorting;
44
58
  const db = await cli_1.account.login({ app });
45
59
  const urls = this.loadAssets(path);
46
- const variations = variationPath ? this.loadVariations(variationPath) : [variation];
60
+ const variations = variationPath
61
+ ? this.loadVariations(variationPath)
62
+ : [variation];
47
63
  await this.prewarmVariations(variations, urls, app, db.token, delay, sortParameters);
48
64
  }
49
65
  /**
@@ -88,15 +104,15 @@ class Prewarm extends core_1.Command {
88
104
  }
89
105
  progress.stop();
90
106
  }
91
- loadAssets(path, origin = '') {
92
- const data = fs.readFileSync(path, 'utf8');
107
+ loadAssets(path, origin = "") {
108
+ const data = fs_1.default.readFileSync(path, "utf8");
93
109
  const entries = data.split(/\r?\n/);
94
- return entries.map(entry => {
110
+ return entries.map((entry) => {
95
111
  entry = /^"[^"]+"/.test(entry) ? entry.slice(1, -1) : entry;
96
112
  try {
97
113
  return {
98
114
  url: entry,
99
- origin: origin || new URL(entry).origin,
115
+ origin: origin || new url_1.URL(entry).origin,
100
116
  };
101
117
  }
102
118
  catch (error) {
@@ -110,10 +126,10 @@ class Prewarm extends core_1.Command {
110
126
  * @param path - path to the csv containing variations
111
127
  */
112
128
  loadVariations(path) {
113
- let variations = [];
114
- const data = fs.readFileSync(path, 'utf8');
129
+ const variations = [];
130
+ const data = fs_1.default.readFileSync(path, "utf8");
115
131
  const entries = data.split(/\r?\n/);
116
- entries.forEach(entry => {
132
+ entries.forEach((entry) => {
117
133
  if (entry !== "") {
118
134
  variations.push(entry);
119
135
  }
@@ -121,7 +137,7 @@ class Prewarm extends core_1.Command {
121
137
  return variations;
122
138
  }
123
139
  async sleep(ms) {
124
- return new Promise(res => setTimeout(res, ms));
140
+ return new Promise((res) => setTimeout(res, ms));
125
141
  }
126
142
  }
127
143
  exports.default = Prewarm;
@@ -1,4 +1,4 @@
1
- import { Command } from '@oclif/core';
1
+ import { Command } from "@oclif/core";
2
2
  export default class Pull extends Command {
3
3
  static description: string;
4
4
  static args: {
@@ -5,7 +5,7 @@ const cli_parameters_1 = require("../models/cli-parameters");
5
5
  const pull_1 = require("../services/pull");
6
6
  const cli_config_1 = require("../helpers/cli-config");
7
7
  class Pull extends core_1.Command {
8
- static description = 'Pull the specified customer config from orestes';
8
+ static description = "Pull the specified customer config from orestes";
9
9
  static args = cli_parameters_1.CLI_CUSTOMER_CONFIG;
10
10
  static flags = {
11
11
  ...cli_parameters_1.CLI_CONFIG_NAME,
@@ -15,7 +15,7 @@ class Pull extends core_1.Command {
15
15
  `$ sk pull ${cli_parameters_1.CLIParametersExample.CustomerPath} -${cli_parameters_1.CLIParametersChar.ConfigName} ${cli_parameters_1.CLIParametersExample.ConfigName}`,
16
16
  ];
17
17
  async run() {
18
- const { args: { customerPath }, flags: { configName } } = await this.parse(Pull);
18
+ const { args: { customerPath }, flags: { configName }, } = await this.parse(Pull);
19
19
  const pullContext = new pull_1.PullContext(customerPath, configName);
20
20
  const pullService = await new pull_1.PullServiceFactory(pullContext, new cli_config_1.CliConfig(this.config).load()).buildService();
21
21
  await pullService.run();
@@ -1,4 +1,4 @@
1
- import { Command } from '@oclif/core';
1
+ import { Command } from "@oclif/core";
2
2
  export default class WptLauncher extends Command {
3
3
  static description: string;
4
4
  static args: {
@@ -17,5 +17,5 @@ export default class WptLauncher extends Command {
17
17
  getViewPortSize(isMobile: boolean): string;
18
18
  allResourceUrls(urls: string): Array<string>;
19
19
  getResourceOrigin(urlsArr: Array<string>): string;
20
- postScript(script: string): Promise<{}>;
20
+ postScript(script: string): Promise<NonNullable<unknown>>;
21
21
  }