@speedkit/cli 2.22.0 → 2.23.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 (40) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +12 -34
  3. package/dist/commands/prewarm.d.ts +5 -26
  4. package/dist/commands/prewarm.js +23 -103
  5. package/dist/models/cli-parameters.d.ts +4 -1
  6. package/dist/models/cli-parameters.js +3 -0
  7. package/dist/services/cli/cli-service-factory.d.ts +3 -0
  8. package/dist/services/cli/cli-service-factory.js +9 -1
  9. package/dist/services/cli/cli-service-model.d.ts +19 -11
  10. package/dist/services/cli/cli-service-model.js +8 -1
  11. package/dist/services/cli/cli-service.d.ts +20 -13
  12. package/dist/services/cli/cli-service.js +102 -66
  13. package/dist/services/config-api/client.d.ts +7 -9
  14. package/dist/services/config-api/client.js +26 -30
  15. package/dist/services/prewarm/assets/asset-api-client.d.ts +13 -0
  16. package/dist/services/prewarm/assets/asset-api-client.js +58 -0
  17. package/dist/services/prewarm/assets/asset-item.d.ts +14 -0
  18. package/dist/services/prewarm/assets/asset-item.js +29 -0
  19. package/dist/services/prewarm/assets/asset-list.d.ts +14 -0
  20. package/dist/services/prewarm/assets/asset-list.js +43 -0
  21. package/dist/services/prewarm/csv-reader.d.ts +5 -0
  22. package/dist/services/prewarm/csv-reader.js +34 -0
  23. package/dist/services/prewarm/error/invalid-origin-error.d.ts +2 -0
  24. package/dist/services/prewarm/error/invalid-origin-error.js +6 -0
  25. package/dist/services/prewarm/error/read-csv-error.d.ts +8 -0
  26. package/dist/services/prewarm/error/read-csv-error.js +18 -0
  27. package/dist/services/prewarm/index.d.ts +3 -0
  28. package/dist/services/prewarm/index.js +6 -0
  29. package/dist/services/prewarm/pre-warm-factory.d.ts +8 -0
  30. package/dist/services/prewarm/pre-warm-factory.js +40 -0
  31. package/dist/services/prewarm/pre-warm-model.d.ts +38 -0
  32. package/dist/services/prewarm/pre-warm-model.js +38 -0
  33. package/dist/services/prewarm/pre-warm-service.d.ts +21 -0
  34. package/dist/services/prewarm/pre-warm-service.js +154 -0
  35. package/oclif.manifest.json +24 -63
  36. package/package.json +1 -1
  37. package/dist/commands/pop-prewarm.d.ts +0 -17
  38. package/dist/commands/pop-prewarm.js +0 -90
  39. package/dist/services/cli/hooks.d.ts +0 -11
  40. package/dist/services/cli/hooks.js +0 -33
package/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ # [2.23.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.22.0...v2.23.0) (2024-04-12)
2
+
3
+
4
+ ### Features
5
+
6
+ * **origins:** wip implement rateLimiter ([44b1d7f](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/44b1d7f1b8e81b3a0bd5950fa172382558a4cbc9))
7
+ * **prewarm:** marl delayFlag as deprecated ([b7ff1dd](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/b7ff1ddc7ca27a125ffe1433b66c16074df056f5))
8
+ * **prewarm:** realigne code and add more comments ([434467b](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/434467bae8765e1c8be9326edec8a8fa63eb4fc9))
9
+ * **prewarm:** refactor to unified service structure ([e8cd5fe](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/e8cd5fea1f356a3c1623fc2ced06a2d9feec2233))
10
+ * **prewarm:** wip: create readOnlyListFor urlObjects + implement timeBased rateLimiter ([3da0706](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/3da0706474cd0a6f74425ccd9c85234935d7ef33))
11
+
1
12
  # [2.22.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.21.0...v2.22.0) (2024-04-12)
2
13
 
3
14
 
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.22.0 linux-x64 node-v20.12.2
24
+ @speedkit/cli/2.23.0 linux-x64 node-v20.12.2
25
25
  $ sk --help [COMMAND]
26
26
  USAGE
27
27
  $ sk COMMAND
@@ -78,7 +78,6 @@ By either...
78
78
  * [`sk login [APP]`](#sk-login-app)
79
79
  * [`sk onboarding CUSTOMERPATH`](#sk-onboarding-customerpath)
80
80
  * [`sk param-diff PAGEURL`](#sk-param-diff-pageurl)
81
- * [`sk pop-prewarm APP`](#sk-pop-prewarm-app)
82
81
  * [`sk prewarm APP PATH`](#sk-prewarm-app-path)
83
82
  * [`sk pull CUSTOMERPATH`](#sk-pull-customerpath)
84
83
  * [`sk wpt-launcher URLS TESTID`](#sk-wpt-launcher-urls-testid)
@@ -410,46 +409,23 @@ EXAMPLES
410
409
  $ sk prewarm https://www.decathlon.de/ -h
411
410
  ```
412
411
 
413
- ## `sk pop-prewarm APP`
414
-
415
- Pre-warm Fastly PoPs
416
-
417
- ```
418
- USAGE
419
- $ sk pop-prewarm APP [-i <value>] [-c <value>]
420
-
421
- ARGUMENTS
422
- APP The customers appName
423
-
424
- FLAGS
425
- -c, --contentTypes=<value> [default: image]
426
- -i, --ips=<value> [default: 151.101.120.194]
427
-
428
- DESCRIPTION
429
- Pre-warm Fastly PoPs
430
-
431
- EXAMPLES
432
- $ sk pop-prewarm <app> -c <contentTypes> -i <ips>
433
-
434
- $ sk pop-prewarm decathlon -c image,style -i 151.101.120.194
435
- ```
436
-
437
412
  ## `sk prewarm APP PATH`
438
413
 
439
414
  Pre-warm Fastly
440
415
 
441
416
  ```
442
417
  USAGE
443
- $ sk prewarm APP PATH [-p <value> | -v <value>] [-d <value>] [-k]
418
+ $ sk prewarm APP PATH [-p <value> | -v <value>] [-k] [-q] [-d <value>]
444
419
 
445
420
  ARGUMENTS
446
421
  APP The customer app name
447
- PATH path to prewarmFile
422
+ PATH path to prewarmFile.csv
448
423
 
449
424
  FLAGS
450
- -d, --delay=<value> Request delay in ms
425
+ -d, --delay=<value> Request delay in ms (deprecated)
451
426
  -k, --keepParameterSorting Prevents alphabetical sorting of the URL parameters
452
- -p, --variationPath=<value>
427
+ -p, --variationPath=<value> path to variations.csv
428
+ -q, --quiet less output non interactive
453
429
  -v, --variation=<value> [default: DEFAULT]
454
430
 
455
431
  DESCRIPTION
@@ -458,17 +434,19 @@ DESCRIPTION
458
434
  EXAMPLES
459
435
  for a single variation:
460
436
 
461
- $ sk prewarm <app> <path> -v <variation> -d <delay> -k
437
+ $ sk prewarm <app> <path> -v <variation> -k
462
438
 
463
- $ sk prewarm decathlon C:\Users\testUser\file.csv -v MOBILE -d 1200 -k
439
+ $ sk prewarm decathlon C:\Users\testUser\file.csv -v MOBILE -k
464
440
 
465
441
 
466
442
 
467
443
  for a list of variations:
468
444
 
469
- $ sk prewarm <app> <path> -p <variationPath> -d <delay> -k
445
+ $ sk prewarm <app> <path> -p <variationPath> -k
446
+
447
+ $ sk prewarm decathlon C:\Users\testUser\file.csv -v MOBILE,DESKTOP -k
470
448
 
471
- $ sk prewarm decathlon C:\Users\testUser\file.csv -p C:\Users\testUser\variations.csv -d 1200 -k
449
+ $ sk prewarm decathlon C:\Users\testUser\file.csv -p C:\Users\testUser\variations.csv -k
472
450
  ```
473
451
 
474
452
  ## `sk pull CUSTOMERPATH`
@@ -3,38 +3,17 @@ export default class Prewarm extends Command {
3
3
  static description: string;
4
4
  static args: {
5
5
  app: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
6
- path: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
6
+ path: import("@oclif/core/lib/interfaces").Arg<string, {
7
+ exists?: boolean;
8
+ }>;
7
9
  };
8
10
  static flags: {
9
11
  variation: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
10
12
  variationPath: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
11
- delay: import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces").CustomOptions>;
12
13
  keepParameterSorting: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
14
+ quiet: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
15
+ delay: import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces").CustomOptions>;
13
16
  };
14
17
  static examples: string[];
15
18
  run(): Promise<void>;
16
- /**
17
- * Pre-warms a list of URLs with the given variations.
18
- *
19
- * @param variations - Variations to be prewarmed.
20
- * @param urls - The URLs to be prewarmed.
21
- * @param app - The baqend app to prewarm on.
22
- * @param token - The baqend token to authorize the user.
23
- * @param delay - The delay between requests in ms.
24
- * @param sortParameters - Activates alphabetical sorting of the URL parameters.
25
- */
26
- prewarmVariations(variations: string[], urls: {
27
- url: string;
28
- origin: string;
29
- }[], app: string, token: string, delay: number, sortParameters: boolean): Promise<void>;
30
- loadAssets(path: string, origin?: string): ({
31
- url: string;
32
- origin: string;
33
- } | null)[];
34
- /**
35
- * Extracts variations line by line from a given file.
36
- * @param path - path to the csv containing variations
37
- */
38
- loadVariations(path: string): string[];
39
- sleep(ms: any): Promise<unknown>;
40
19
  }
@@ -1,14 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
3
  const core_1 = require("@oclif/core");
5
- const core_2 = require("@oclif/core");
6
- const cli_1 = require("baqend/cli");
7
4
  const cli_parameters_1 = require("../models/cli-parameters");
8
- const logging_helper_1 = require("../helpers/logging-helper");
9
- const prewarm_service_1 = tslib_1.__importDefault(require("../services/prewarm-service"));
10
- const node_url_1 = require("node:url");
11
- const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
5
+ const prewarm_1 = require("../services/prewarm");
12
6
  class Prewarm extends core_1.Command {
13
7
  static description = "Pre-warm Fastly";
14
8
  static args = {
@@ -17,10 +11,10 @@ class Prewarm extends core_1.Command {
17
11
  required: true, // make the arg required with `required: true`
18
12
  description: "The customer app name", // help description
19
13
  }),
20
- [cli_parameters_1.CLIParameters.Path]: core_1.Args.string({
14
+ [cli_parameters_1.CLIParameters.Path]: core_1.Args.file({
21
15
  name: cli_parameters_1.CLIParameters.Path, // name of arg to show in help and reference with args[name]
22
16
  required: true, // make the arg required with `required: true`
23
- description: "path to prewarmFile", // help description
17
+ description: "path to prewarmFile.csv", // help description
24
18
  }),
25
19
  };
26
20
  static flags = {
@@ -28,116 +22,42 @@ class Prewarm extends core_1.Command {
28
22
  char: cli_parameters_1.CLIParametersChar.Variation,
29
23
  default: "DEFAULT",
30
24
  }),
31
- [cli_parameters_1.CLIParameters.VariationPath]: core_1.Flags.string({
25
+ [cli_parameters_1.CLIParameters.VariationPath]: core_1.Flags.file({
32
26
  char: cli_parameters_1.CLIParametersChar.VariationPath,
33
27
  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",
28
+ description: "path to variations.csv",
39
29
  }),
40
30
  [cli_parameters_1.CLIParameters.KeepParameterSorting]: core_1.Flags.boolean({
41
31
  char: cli_parameters_1.CLIParametersChar.KeepParameterSorting,
42
32
  default: false,
43
33
  description: "Prevents alphabetical sorting of the URL parameters",
44
34
  }),
35
+ [cli_parameters_1.CLIParameters.Quiet]: core_1.Flags.boolean({
36
+ char: cli_parameters_1.CLIParametersChar.Quiet,
37
+ default: false,
38
+ description: "less output non interactive",
39
+ }),
40
+ ["delay"]: core_1.Flags.integer({
41
+ char: "d",
42
+ description: "Request delay in ms (deprecated)",
43
+ deprecated: true,
44
+ }),
45
45
  };
46
46
  static examples = [
47
47
  "for a single variation:",
48
- `$ sk prewarm <${cli_parameters_1.CLIParameters.AppName}> <${cli_parameters_1.CLIParameters.Path}> -${cli_parameters_1.CLIParametersChar.Variation} <${cli_parameters_1.CLIParameters.Variation}> -${cli_parameters_1.CLIParametersChar.Delay} <${cli_parameters_1.CLIParameters.Delay}> -${cli_parameters_1.CLIParametersChar.KeepParameterSorting}`,
49
- `$ sk prewarm ${cli_parameters_1.CLIParametersExample.AppName} ${cli_parameters_1.CLIParametersExample.Path} -${cli_parameters_1.CLIParametersChar.Variation} ${cli_parameters_1.CLIParametersExample.Variation} -${cli_parameters_1.CLIParametersChar.Delay} ${cli_parameters_1.CLIParametersExample.Delay} -${cli_parameters_1.CLIParametersChar.KeepParameterSorting}`,
48
+ `$ sk prewarm <${cli_parameters_1.CLIParameters.AppName}> <${cli_parameters_1.CLIParameters.Path}> -${cli_parameters_1.CLIParametersChar.Variation} <${cli_parameters_1.CLIParameters.Variation}> -${cli_parameters_1.CLIParametersChar.KeepParameterSorting}`,
49
+ `$ sk prewarm ${cli_parameters_1.CLIParametersExample.AppName} ${cli_parameters_1.CLIParametersExample.Path} -${cli_parameters_1.CLIParametersChar.Variation} ${cli_parameters_1.CLIParametersExample.Variation} -${cli_parameters_1.CLIParametersChar.KeepParameterSorting}`,
50
50
  "",
51
51
  "for a list of variations:",
52
- `$ sk prewarm <${cli_parameters_1.CLIParameters.AppName}> <${cli_parameters_1.CLIParameters.Path}> -${cli_parameters_1.CLIParametersChar.Path} <${cli_parameters_1.CLIParameters.VariationPath}> -${cli_parameters_1.CLIParametersChar.Delay} <${cli_parameters_1.CLIParameters.Delay}> -${cli_parameters_1.CLIParametersChar.KeepParameterSorting}`,
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}`,
52
+ `$ sk prewarm <${cli_parameters_1.CLIParameters.AppName}> <${cli_parameters_1.CLIParameters.Path}> -${cli_parameters_1.CLIParametersChar.Path} <${cli_parameters_1.CLIParameters.VariationPath}> -${cli_parameters_1.CLIParametersChar.KeepParameterSorting}`,
53
+ `$ sk prewarm ${cli_parameters_1.CLIParametersExample.AppName} ${cli_parameters_1.CLIParametersExample.Path} -${cli_parameters_1.CLIParametersChar.Variation} ${cli_parameters_1.CLIParametersExample.Variations} -${cli_parameters_1.CLIParametersChar.KeepParameterSorting}`,
54
+ `$ 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.KeepParameterSorting}`,
54
55
  ];
55
56
  async run() {
56
- const { args: { app, path }, flags: { variation, variationPath, delay, keepParameterSorting }, } = await this.parse(Prewarm);
57
+ const { args: { app, path }, flags: { variation, variationPath, keepParameterSorting, quiet }, } = await this.parse(Prewarm);
57
58
  const sortParameters = !keepParameterSorting;
58
- const database = await cli_1.account.login({ app });
59
- const urls = this.loadAssets(path);
60
- const variations = variationPath
61
- ? this.loadVariations(variationPath)
62
- : [variation];
63
- await this.prewarmVariations(variations, urls, app, database.token, delay, sortParameters);
64
- }
65
- /**
66
- * Pre-warms a list of URLs with the given variations.
67
- *
68
- * @param variations - Variations to be prewarmed.
69
- * @param urls - The URLs to be prewarmed.
70
- * @param app - The baqend app to prewarm on.
71
- * @param token - The baqend token to authorize the user.
72
- * @param delay - The delay between requests in ms.
73
- * @param sortParameters - Activates alphabetical sorting of the URL parameters.
74
- */
75
- async prewarmVariations(variations, urls, app, token, delay, sortParameters) {
76
- const progress = core_2.ux.progress();
77
- const chunks = prewarm_service_1.default.chunk(urls, 5);
78
- let fetches = [];
79
- progress.start(urls.length * variations.length, 0);
80
- for (const chunk of chunks) {
81
- for (const entry of chunk) {
82
- if (delay)
83
- await this.sleep(delay);
84
- for (const variation of variations) {
85
- try {
86
- if (entry) {
87
- fetches.push(prewarm_service_1.default.fetchURL(entry.url, entry.origin, variation, app, token, sortParameters));
88
- }
89
- }
90
- catch (error) {
91
- (0, logging_helper_1.logError)(error);
92
- }
93
- }
94
- }
95
- try {
96
- // eslint-disable-next-line no-await-in-loop
97
- await Promise.all(fetches);
98
- }
99
- catch (error) {
100
- (0, logging_helper_1.logWarning)(error);
101
- }
102
- progress.increment(fetches.length);
103
- fetches = [];
104
- }
105
- progress.stop();
106
- }
107
- loadAssets(path, origin = "") {
108
- const data = node_fs_1.default.readFileSync(path, "utf8");
109
- const entries = data.split(/\r?\n/);
110
- return entries.map((entry) => {
111
- entry = /^"[^"]+"/.test(entry) ? entry.slice(1, -1) : entry;
112
- try {
113
- return {
114
- url: entry,
115
- origin: origin || new node_url_1.URL(entry).origin,
116
- };
117
- }
118
- catch (error) {
119
- (0, logging_helper_1.logWarning)(`Error loading asset for URL: ${entry}`, error);
120
- }
121
- return null;
122
- });
123
- }
124
- /**
125
- * Extracts variations line by line from a given file.
126
- * @param path - path to the csv containing variations
127
- */
128
- loadVariations(path) {
129
- const variations = [];
130
- const data = node_fs_1.default.readFileSync(path, "utf8");
131
- const entries = data.split(/\r?\n/);
132
- for (const entry of entries) {
133
- if (entry !== "") {
134
- variations.push(entry);
135
- }
136
- }
137
- return variations;
138
- }
139
- async sleep(ms) {
140
- return new Promise((response) => setTimeout(response, ms));
59
+ const service = await new prewarm_1.PreWarmFactory(new prewarm_1.PreWarmContext(app, path, variation, variationPath, sortParameters, quiet)).getService();
60
+ await service.run();
141
61
  }
142
62
  }
143
63
  exports.default = Prewarm;
@@ -13,6 +13,7 @@ export declare enum CLIParameters {
13
13
  HideDiff = "hideDiff",
14
14
  Ips = "ips",
15
15
  KeepParameterSorting = "keepParameterSorting",
16
+ Quiet = "quiet",
16
17
  Mobile = "mobile",
17
18
  PageUrl = "pageUrl",
18
19
  Path = "path",
@@ -41,7 +42,8 @@ export declare enum CLIParametersChar {
41
42
  SlackToken = "t",
42
43
  Path = "p",
43
44
  Variation = "v",
44
- VariationPath = "p"
45
+ VariationPath = "p",
46
+ Quiet = "q"
45
47
  }
46
48
  export declare enum CLIParametersExample {
47
49
  AppName = "decathlon",
@@ -61,6 +63,7 @@ export declare enum CLIParametersExample {
61
63
  TestId = "listing-50vs50",
62
64
  Urls = "url1,url2,url3",
63
65
  Variation = "MOBILE",
66
+ Variations = "MOBILE,DESKTOP",
64
67
  VariationPath = "C:\\Users\\testUser\\variations.csv"
65
68
  }
66
69
  export declare const CLI_CONFIG_NAME: {
@@ -18,6 +18,7 @@ var CLIParameters;
18
18
  CLIParameters["HideDiff"] = "hideDiff";
19
19
  CLIParameters["Ips"] = "ips";
20
20
  CLIParameters["KeepParameterSorting"] = "keepParameterSorting";
21
+ CLIParameters["Quiet"] = "quiet";
21
22
  CLIParameters["Mobile"] = "mobile";
22
23
  CLIParameters["PageUrl"] = "pageUrl";
23
24
  CLIParameters["Path"] = "path";
@@ -49,6 +50,7 @@ var CLIParametersChar;
49
50
  CLIParametersChar["Path"] = "p";
50
51
  CLIParametersChar["Variation"] = "v";
51
52
  CLIParametersChar["VariationPath"] = "p";
53
+ CLIParametersChar["Quiet"] = "q";
52
54
  })(CLIParametersChar || (exports.CLIParametersChar = CLIParametersChar = {}));
53
55
  /* eslint-enable @typescript-eslint/no-duplicate-enum-values */
54
56
  var CLIParametersExample;
@@ -70,6 +72,7 @@ var CLIParametersExample;
70
72
  CLIParametersExample["TestId"] = "listing-50vs50";
71
73
  CLIParametersExample["Urls"] = "url1,url2,url3";
72
74
  CLIParametersExample["Variation"] = "MOBILE";
75
+ CLIParametersExample["Variations"] = "MOBILE,DESKTOP";
73
76
  CLIParametersExample["VariationPath"] = "C:\\Users\\testUser\\variations.csv";
74
77
  })(CLIParametersExample || (exports.CLIParametersExample = CLIParametersExample = {}));
75
78
  exports.CLI_CONFIG_NAME = {
@@ -1,5 +1,8 @@
1
1
  import { CliService } from "./cli-service";
2
+ import { CliContext } from "./cli-service-model";
2
3
  export declare class CliServiceFactory {
4
+ private context?;
3
5
  service?: CliService;
6
+ constructor(context?: CliContext);
4
7
  getService(): CliService;
5
8
  }
@@ -2,11 +2,19 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CliServiceFactory = void 0;
4
4
  const cli_service_1 = require("./cli-service");
5
+ const cli_service_model_1 = require("./cli-service-model");
5
6
  class CliServiceFactory {
7
+ context;
6
8
  service = undefined;
9
+ constructor(context) {
10
+ this.context = context;
11
+ if (!context) {
12
+ this.context = new cli_service_model_1.CliContext(false);
13
+ }
14
+ }
7
15
  getService() {
8
16
  if (!(this.service instanceof cli_service_1.CliService)) {
9
- this.service = new cli_service_1.CliService();
17
+ this.service = new cli_service_1.CliService(this.context.quiet);
10
18
  }
11
19
  return this.service;
12
20
  }
@@ -1,27 +1,35 @@
1
1
  import { table } from "@oclif/core/lib/cli-ux/styled/table";
2
+ import { Options } from "cli-progress";
3
+ export declare class CliContext {
4
+ readonly quiet: boolean;
5
+ constructor(quiet?: boolean);
6
+ }
2
7
  export declare enum CliActionStatus {
3
8
  COMPLETED = "completed",
4
9
  FAILED = "failed",
5
10
  SKIPPED = "skipped"
6
11
  }
7
12
  export interface CliServiceInterface {
13
+ code(code: string, buffered?: boolean): void;
8
14
  codeStyle(code: string): string;
9
- write(message: string, buffered?: boolean): void;
10
- spacer(): void;
11
- writeSuccess(message: string, buffered?: boolean): void;
12
- writeWarning(message: string, buffered?: boolean): void;
13
- writeError(message: string, buffered?: boolean): void;
14
15
  comment(message: string, buffered?: boolean): void;
15
- code(code: string, buffered?: boolean): void;
16
+ confirm(message: string, defaultAnswer: boolean): Promise<boolean>;
17
+ endAction(status?: CliActionStatus): void;
18
+ exit(code: number): void;
16
19
  prompt(message: string, options?: {
17
- validator?: any;
18
20
  defaultAnswer?: any;
21
+ validator?: any;
19
22
  }): Promise<string>;
20
- confirm(message: string, defaultAnswer: boolean): Promise<boolean>;
21
23
  select(message: string, choices: any): Promise<string>;
24
+ spacer(): void;
22
25
  startAction(message: string): void;
23
- endAction(status?: CliActionStatus): void;
24
- writeBuffer(): void;
26
+ startProgress(total: number, start?: number, payload?: object, config?: Options): void;
27
+ stopProgress(): void;
25
28
  table<T extends Record<string, unknown>>(data: T[], columns: table.Columns<T>, options?: table.Options): void;
26
- exit(code: number): void;
29
+ updateProgress(current: number, payload?: object): void;
30
+ write(message: string, buffered?: boolean): void;
31
+ writeBuffer(): void;
32
+ writeError(message: string, buffered?: boolean): void;
33
+ writeSuccess(message: string, buffered?: boolean): void;
34
+ writeWarning(message: string, buffered?: boolean): void;
27
35
  }
@@ -1,6 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CliActionStatus = void 0;
3
+ exports.CliActionStatus = exports.CliContext = void 0;
4
+ class CliContext {
5
+ quiet;
6
+ constructor(quiet = false) {
7
+ this.quiet = quiet;
8
+ }
9
+ }
10
+ exports.CliContext = CliContext;
4
11
  var CliActionStatus;
5
12
  (function (CliActionStatus) {
6
13
  CliActionStatus["COMPLETED"] = "completed";
@@ -1,8 +1,9 @@
1
1
  import chalk from "chalk";
2
- import { CliActionStatus, CliServiceInterface } from "./cli-service-model";
3
2
  import { table } from "@oclif/core/lib/cli-ux/styled/table";
3
+ import { Options } from "cli-progress";
4
+ import { CliActionStatus, CliServiceInterface } from "./cli-service-model";
4
5
  export declare class CliService implements CliServiceInterface {
5
- private buffer;
6
+ private readonly quiet;
6
7
  style: chalk.Chalk & chalk.ChalkFunction & {
7
8
  supportsColor: false | chalk.ColorSupport;
8
9
  Level: chalk.Level;
@@ -14,24 +15,30 @@ export declare class CliService implements CliServiceInterface {
14
15
  supportsColor: false | chalk.ColorSupport;
15
16
  };
16
17
  };
18
+ private buffer;
19
+ private progressBar?;
20
+ constructor(quiet?: boolean);
21
+ code(code: string, buffered?: boolean): void;
17
22
  codeStyle(code: string): string;
18
- write(message: string, buffered?: boolean): void;
19
- spacer(): void;
20
- writeSuccess(message: string, buffered?: boolean): void;
21
- writeWarning(message: string, buffered?: boolean): void;
22
- writeError(message: string, buffered?: boolean): void;
23
23
  comment(message: string, buffered?: boolean): void;
24
- code(code: string, buffered?: boolean): void;
24
+ confirm(message: string, defaultAnswer?: boolean): Promise<boolean>;
25
+ endAction(status?: CliActionStatus): void;
26
+ exit(code?: number): void;
25
27
  prompt(message: string, options?: {
26
- validator?: any;
27
28
  defaultAnswer?: any;
29
+ validator?: any;
28
30
  }): Promise<string>;
29
- confirm(message: string, defaultAnswer?: boolean): Promise<boolean>;
30
31
  select(message: string, choices: any): Promise<string>;
32
+ spacer(): void;
31
33
  startAction(message: string): void;
32
- endAction(status?: CliActionStatus): void;
33
- writeBuffer(): void;
34
+ startProgress(total: number, start?: number, payload?: object, config?: Options): void;
35
+ stopProgress(): void;
34
36
  table<T extends Record<string, unknown>>(data: T[], columns: table.Columns<T>, options?: table.Options): void;
35
- exit(code?: number): void;
37
+ updateProgress(current: number, payload?: object): void;
38
+ write(message: string, buffered?: boolean): void;
39
+ writeBuffer(): void;
40
+ writeError(message: string, buffered?: boolean): void;
41
+ writeSuccess(message: string, buffered?: boolean): void;
42
+ writeWarning(message: string, buffered?: boolean): void;
36
43
  private getFormattedMessage;
37
44
  }