@speedkit/cli 2.4.1 → 2.6.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/README.md CHANGED
@@ -74,7 +74,7 @@ $ npm install -g @speedkit/cli
74
74
  $ sk COMMAND
75
75
  running command...
76
76
  $ sk (--version)
77
- @speedkit/cli/2.4.1 linux-x64 node-v20.11.1
77
+ @speedkit/cli/2.6.0 linux-x64 node-v20.11.1
78
78
  $ sk --help [COMMAND]
79
79
  USAGE
80
80
  $ sk COMMAND
@@ -95,16 +95,6 @@ USAGE
95
95
  * [`sk login [APP]`](#sk-login-app)
96
96
  * [`sk onboarding CUSTOMERPATH`](#sk-onboarding-customerpath)
97
97
  * [`sk param-diff PAGEURL`](#sk-param-diff-pageurl)
98
- * [`sk plugins`](#sk-plugins)
99
- * [`sk plugins:install PLUGIN...`](#sk-pluginsinstall-plugin)
100
- * [`sk plugins:inspect PLUGIN...`](#sk-pluginsinspect-plugin)
101
- * [`sk plugins:install PLUGIN...`](#sk-pluginsinstall-plugin-1)
102
- * [`sk plugins:link PLUGIN`](#sk-pluginslink-plugin)
103
- * [`sk plugins:uninstall PLUGIN...`](#sk-pluginsuninstall-plugin)
104
- * [`sk plugins reset`](#sk-plugins-reset)
105
- * [`sk plugins:uninstall PLUGIN...`](#sk-pluginsuninstall-plugin-1)
106
- * [`sk plugins:uninstall PLUGIN...`](#sk-pluginsuninstall-plugin-2)
107
- * [`sk plugins update`](#sk-plugins-update)
108
98
  * [`sk pop-prewarm APP`](#sk-pop-prewarm-app)
109
99
  * [`sk prewarm APP PATH`](#sk-prewarm-app-path)
110
100
  * [`sk pull CUSTOMERPATH`](#sk-pull-customerpath)
@@ -407,266 +397,6 @@ EXAMPLES
407
397
  $ sk prewarm https://www.decathlon.de/ -h
408
398
  ```
409
399
 
410
- ## `sk plugins`
411
-
412
- List installed plugins.
413
-
414
- ```
415
- USAGE
416
- $ sk plugins [--json] [--core]
417
-
418
- FLAGS
419
- --core Show core plugins.
420
-
421
- GLOBAL FLAGS
422
- --json Format output as json.
423
-
424
- DESCRIPTION
425
- List installed plugins.
426
-
427
- EXAMPLES
428
- $ sk plugins
429
- ```
430
-
431
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.2/src/commands/plugins/index.ts)_
432
-
433
- ## `sk plugins:install PLUGIN...`
434
-
435
- Installs a plugin into the CLI.
436
-
437
- ```
438
- USAGE
439
- $ sk plugins add plugins:install PLUGIN...
440
-
441
- ARGUMENTS
442
- PLUGIN Plugin to install.
443
-
444
- FLAGS
445
- -f, --force Run yarn install with force flag.
446
- -h, --help Show CLI help.
447
- -s, --silent Silences yarn output.
448
- -v, --verbose Show verbose yarn output.
449
-
450
- DESCRIPTION
451
- Installs a plugin into the CLI.
452
- Can be installed from npm or a git url.
453
-
454
- Installation of a user-installed plugin will override a core plugin.
455
-
456
- e.g. If you have a core plugin that has a 'hello' command, installing a user-installed plugin with a 'hello' command
457
- will override the core plugin implementation. This is useful if a user needs to update core plugin functionality in
458
- the CLI without the need to patch and update the whole CLI.
459
-
460
-
461
- ALIASES
462
- $ sk plugins add
463
-
464
- EXAMPLES
465
- $ sk plugins:install myplugin
466
-
467
- $ sk plugins:install https://github.com/someuser/someplugin
468
-
469
- $ sk plugins:install someuser/someplugin
470
- ```
471
-
472
- ## `sk plugins:inspect PLUGIN...`
473
-
474
- Displays installation properties of a plugin.
475
-
476
- ```
477
- USAGE
478
- $ sk plugins inspect PLUGIN...
479
-
480
- ARGUMENTS
481
- PLUGIN [default: .] Plugin to inspect.
482
-
483
- FLAGS
484
- -h, --help Show CLI help.
485
- -v, --verbose
486
-
487
- GLOBAL FLAGS
488
- --json Format output as json.
489
-
490
- DESCRIPTION
491
- Displays installation properties of a plugin.
492
-
493
- EXAMPLES
494
- $ sk plugins:inspect myplugin
495
- ```
496
-
497
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.2/src/commands/plugins/inspect.ts)_
498
-
499
- ## `sk plugins:install PLUGIN...`
500
-
501
- Installs a plugin into the CLI.
502
-
503
- ```
504
- USAGE
505
- $ sk plugins install PLUGIN...
506
-
507
- ARGUMENTS
508
- PLUGIN Plugin to install.
509
-
510
- FLAGS
511
- -f, --force Run yarn install with force flag.
512
- -h, --help Show CLI help.
513
- -s, --silent Silences yarn output.
514
- -v, --verbose Show verbose yarn output.
515
-
516
- DESCRIPTION
517
- Installs a plugin into the CLI.
518
- Can be installed from npm or a git url.
519
-
520
- Installation of a user-installed plugin will override a core plugin.
521
-
522
- e.g. If you have a core plugin that has a 'hello' command, installing a user-installed plugin with a 'hello' command
523
- will override the core plugin implementation. This is useful if a user needs to update core plugin functionality in
524
- the CLI without the need to patch and update the whole CLI.
525
-
526
-
527
- ALIASES
528
- $ sk plugins add
529
-
530
- EXAMPLES
531
- $ sk plugins:install myplugin
532
-
533
- $ sk plugins:install https://github.com/someuser/someplugin
534
-
535
- $ sk plugins:install someuser/someplugin
536
- ```
537
-
538
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.2/src/commands/plugins/install.ts)_
539
-
540
- ## `sk plugins:link PLUGIN`
541
-
542
- Links a plugin into the CLI for development.
543
-
544
- ```
545
- USAGE
546
- $ sk plugins link PLUGIN
547
-
548
- ARGUMENTS
549
- PATH [default: .] path to plugin
550
-
551
- FLAGS
552
- -h, --help Show CLI help.
553
- -v, --verbose
554
- --[no-]install Install dependencies after linking the plugin.
555
-
556
- DESCRIPTION
557
- Links a plugin into the CLI for development.
558
- Installation of a linked plugin will override a user-installed or core plugin.
559
-
560
- e.g. If you have a user-installed or core plugin that has a 'hello' command, installing a linked plugin with a 'hello'
561
- command will override the user-installed or core plugin implementation. This is useful for development work.
562
-
563
-
564
- EXAMPLES
565
- $ sk plugins:link myplugin
566
- ```
567
-
568
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.2/src/commands/plugins/link.ts)_
569
-
570
- ## `sk plugins:uninstall PLUGIN...`
571
-
572
- Removes a plugin from the CLI.
573
-
574
- ```
575
- USAGE
576
- $ sk plugins remove plugins:uninstall PLUGIN...
577
-
578
- ARGUMENTS
579
- PLUGIN plugin to uninstall
580
-
581
- FLAGS
582
- -h, --help Show CLI help.
583
- -v, --verbose
584
-
585
- DESCRIPTION
586
- Removes a plugin from the CLI.
587
-
588
- ALIASES
589
- $ sk plugins unlink
590
- $ sk plugins remove
591
- ```
592
-
593
- ## `sk plugins reset`
594
-
595
- Remove all user-installed and linked plugins.
596
-
597
- ```
598
- USAGE
599
- $ sk plugins reset
600
- ```
601
-
602
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.2/src/commands/plugins/reset.ts)_
603
-
604
- ## `sk plugins:uninstall PLUGIN...`
605
-
606
- Removes a plugin from the CLI.
607
-
608
- ```
609
- USAGE
610
- $ sk plugins uninstall PLUGIN...
611
-
612
- ARGUMENTS
613
- PLUGIN plugin to uninstall
614
-
615
- FLAGS
616
- -h, --help Show CLI help.
617
- -v, --verbose
618
-
619
- DESCRIPTION
620
- Removes a plugin from the CLI.
621
-
622
- ALIASES
623
- $ sk plugins unlink
624
- $ sk plugins remove
625
- ```
626
-
627
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.2/src/commands/plugins/uninstall.ts)_
628
-
629
- ## `sk plugins:uninstall PLUGIN...`
630
-
631
- Removes a plugin from the CLI.
632
-
633
- ```
634
- USAGE
635
- $ sk plugins unlink plugins:uninstall PLUGIN...
636
-
637
- ARGUMENTS
638
- PLUGIN plugin to uninstall
639
-
640
- FLAGS
641
- -h, --help Show CLI help.
642
- -v, --verbose
643
-
644
- DESCRIPTION
645
- Removes a plugin from the CLI.
646
-
647
- ALIASES
648
- $ sk plugins unlink
649
- $ sk plugins remove
650
- ```
651
-
652
- ## `sk plugins update`
653
-
654
- Update installed plugins.
655
-
656
- ```
657
- USAGE
658
- $ sk plugins update [-h] [-v]
659
-
660
- FLAGS
661
- -h, --help Show CLI help.
662
- -v, --verbose
663
-
664
- DESCRIPTION
665
- Update installed plugins.
666
- ```
667
-
668
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.2/src/commands/plugins/update.ts)_
669
-
670
400
  ## `sk pop-prewarm APP`
671
401
 
672
402
  Pre-warm Fastly PoPs
@@ -26,6 +26,7 @@ export declare class DocumentHandlerServer {
26
26
  private createDataBaseMock;
27
27
  private createNodeVmContext;
28
28
  private createRequireMock;
29
+ private createFetchMock;
29
30
  private createProcessPartial;
30
31
  /**
31
32
  * Fetches and returns the latest dynamic fetcher from the code repository. If a new version is available online it is
@@ -7,14 +7,9 @@ const required_file_not_found_error_1 = tslib_1.__importDefault(require("./error
7
7
  const database_mock_1 = tslib_1.__importDefault(require("./templates/database-mock"));
8
8
  const vm = tslib_1.__importStar(require("vm"));
9
9
  const vm_error_1 = require("../onboarding/error/vm-error");
10
+ const path_1 = tslib_1.__importDefault(require("path"));
11
+ const files_1 = require("../../models/files");
10
12
  // documentHandlerDependencies
11
- var parse5 = require('parse5');
12
- var parse5Htmlparser2TreeAdapter = require('parse5-htmlparser2-tree-adapter');
13
- var domSerializer = require('dom-serializer');
14
- var domhandler = require('domhandler');
15
- var domelementtype = require('domelementtype');
16
- var domutils = require('domutils');
17
- var cssSelect = require('css-select');
18
13
  var fetch = require('node-fetch');
19
14
  class DocumentHandlerServer {
20
15
  customerConfig;
@@ -84,11 +79,6 @@ class DocumentHandlerServer {
84
79
  return `${this.getContextVars()} ${docHandler} ${docHandlerConfig}`;
85
80
  }
86
81
  async getDocumentHandler() {
87
- // todo use fetchRemoteFile from integration api
88
- if (!this.files.hasFile(document_handler_runtime_context_1.LOCAL_DOCUMENT_HANDLER)) {
89
- const response = await fetch(document_handler_runtime_context_1.LATEST_DOCUMENT_HANDLER_URL);
90
- return await response.text();
91
- }
92
82
  return this.files.getByName(document_handler_runtime_context_1.LOCAL_DOCUMENT_HANDLER).getContent();
93
83
  }
94
84
  async getDynamicFetcher() {
@@ -97,7 +87,7 @@ class DocumentHandlerServer {
97
87
  const response = await fetch(document_handler_runtime_context_1.LATEST_DYNAMIC_FETCHER_URL);
98
88
  return await this.bundleDynamicFetcher({ 'dynamic-fetcher': 'https://www.baqend.com/speed-kit/latest/' }, await response.text());
99
89
  }
100
- return this.files.getByName(document_handler_runtime_context_1.LOCAL_DYNAMIC_FETCHER).getContent();
90
+ return this.files.getByName(files_1.INTEGRATION_FILES.CUSTOM.DYNAMIC_FETCHER).getContent();
101
91
  }
102
92
  async getDynamicFetcherConfig() {
103
93
  return this.files.getByName(document_handler_runtime_context_1.LOCAL_DYNAMIC_FETCHER_CONFIG).getContent();
@@ -145,7 +135,7 @@ class DocumentHandlerServer {
145
135
  process: this.createProcessPartial(),
146
136
  require: this.createRequireMock(),
147
137
  'URL': URL,
148
- 'fetch': fetch,
138
+ 'fetch': this.createFetchMock(),
149
139
  'Buffer': Buffer,
150
140
  };
151
141
  if (this.verboseLevel) {
@@ -159,40 +149,31 @@ class DocumentHandlerServer {
159
149
  return { baqend: { message: { RevalidateAssets: () => true } } };
160
150
  }
161
151
  if (module.includes('fetch')) {
162
- return async (url, options) => {
163
- if (this.verboseLevel) {
164
- this.cli.writeWarning(`[documentHandler.fetch]: ${url}`);
165
- }
166
- return fetch(url, options);
167
- };
168
- }
169
- if (module.includes('css-select')) {
170
- return cssSelect;
171
- }
172
- if (module.includes('domutils')) {
173
- return domutils;
174
- }
175
- if (module.includes('domelementtype')) {
176
- return domelementtype;
177
- }
178
- if (module.includes('domhandler')) {
179
- return domhandler;
180
- }
181
- if (module.includes('dom-serializer')) {
182
- return domSerializer;
183
- }
184
- if (module.includes('parse5-htmlparser2-tree-adapter')) {
185
- return parse5Htmlparser2TreeAdapter;
152
+ return this.createFetchMock();
186
153
  }
187
- if (module.includes('parse5')) {
188
- return parse5;
189
- }
190
- const moduleFileName = module.split('/')?.pop();
154
+ const fileExtension = path_1.default.extname(module);
155
+ const moduleFileName = path_1.default.basename(module, fileExtension);
191
156
  if (this.files.hasFile(moduleFileName)) {
192
157
  const vmContext = { module: { exports: {} }, exports: {}, ...this.createNodeVmContext() };
193
158
  vm.runInNewContext(this.files.getByName(moduleFileName).getContent(), vmContext);
194
159
  return { ...vmContext.module.exports, ...vmContext.exports };
195
160
  }
161
+ try {
162
+ const outerModule = require(module);
163
+ return outerModule;
164
+ }
165
+ catch (error) {
166
+ this.cli.writeError(`[documentHandler] could not load module: ${module}`);
167
+ this.cli.writeError(error.message);
168
+ }
169
+ };
170
+ }
171
+ createFetchMock() {
172
+ return async (url, options) => {
173
+ if (this.verboseLevel) {
174
+ this.cli.writeWarning(`[documentHandler.fetch]: ${url}`);
175
+ }
176
+ return fetch(url, options);
196
177
  };
197
178
  }
198
179
  createProcessPartial() {
@@ -210,9 +191,6 @@ class DocumentHandlerServer {
210
191
  * @returns {Promise<string>} a Promise which resolves to the latest dynamic fetcher
211
192
  */
212
193
  async bundleDynamicFetcher(basePaths, dynamicFetcher) {
213
- const IMPORT_PATHS = {
214
- 'dynamicFetcher': 'https://www.baqend.com/speed-kit/latest/',
215
- };
216
194
  return this.bundler.bundle({
217
195
  basePaths: basePaths,
218
196
  entryPoints: { "dynamicFetcher.js": dynamicFetcher },
@@ -21,6 +21,7 @@ export declare class OnboardingContext {
21
21
  readonly DEFAULT_SW_PATH = "https://www.baqend.com/speed-kit/latest/sw.js";
22
22
  readonly DEFAULT_SNIPPET_PATH = "https://www.baqend.com/speed-kit/latest/snippet.js";
23
23
  readonly DEFAULT_DF_PATH = "https://www.baqend.com/speed-kit/latest/dynamic-fetcher.js";
24
+ readonly DEFAULT_DOCUMENT_HANDLER_PATH = "https://www.baqend.com/speed-kit-handler/latest/DocumentHandler.js";
24
25
  constructor(customerPath: string, configName: string, local: boolean, verboseLevel?: boolean);
25
26
  }
26
27
  export type awsCredentials = {
@@ -43,6 +43,7 @@ class OnboardingContext {
43
43
  DEFAULT_SW_PATH = 'https://www.baqend.com/speed-kit/latest/sw.js';
44
44
  DEFAULT_SNIPPET_PATH = 'https://www.baqend.com/speed-kit/latest/snippet.js';
45
45
  DEFAULT_DF_PATH = 'https://www.baqend.com/speed-kit/latest/dynamic-fetcher.js';
46
+ DEFAULT_DOCUMENT_HANDLER_PATH = 'https://www.baqend.com/speed-kit-handler/latest/DocumentHandler.js';
46
47
  constructor(customerPath, configName, local, verboseLevel) {
47
48
  this.customerPath = customerPath;
48
49
  this.configName = configName;
@@ -128,6 +128,10 @@ class OnboardingServiceFactory {
128
128
  name: files_1.INTEGRATION_FILES.CUSTOM.LOADER,
129
129
  recipe: new external_recipe_1.ExternalRecipe(this.context.DEFAULT_SNIPPET_PATH, externalFileReader)
130
130
  },
131
+ {
132
+ name: files_1.INTEGRATION_FILES.CUSTOM.DOCUMENT_HANDLER,
133
+ recipe: new external_recipe_1.ExternalRecipe(this.context.DEFAULT_DOCUMENT_HANDLER_PATH, externalFileReader)
134
+ },
131
135
  ]);
132
136
  }
133
137
  getConfigApi(app) {
@@ -696,5 +696,5 @@
696
696
  ]
697
697
  }
698
698
  },
699
- "version": "2.4.1"
699
+ "version": "2.6.0"
700
700
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@speedkit/cli",
3
3
  "description": "Speed Kit CLI",
4
- "version": "2.4.1",
4
+ "version": "2.6.0",
5
5
  "author": {
6
6
  "name": "Baqend.com",
7
7
  "email": "info@baqend.com"
@@ -46,14 +46,17 @@
46
46
  "commands": "./dist/commands",
47
47
  "bin": "sk",
48
48
  "dirname": "speed-kit-cli",
49
- "version": "2.0.0",
50
49
  "plugins": [
50
+ "@oclif/plugin-warn-if-update-available",
51
51
  "@oclif/plugin-help",
52
- "@oclif/plugin-plugins",
53
52
  "@oclif/plugin-not-found",
54
53
  "@oclif/plugin-autocomplete"
55
54
  ],
56
- "topicSeparator": " "
55
+ "topicSeparator": " ",
56
+ "warn-if-update-available": {
57
+ "timeoutInDays": 0,
58
+ "frequency": 0
59
+ }
57
60
  },
58
61
  "main": "dist/index.js",
59
62
  "types": "dist/index.d.ts",
@@ -65,7 +68,7 @@
65
68
  "@oclif/plugin-autocomplete": "^3.0",
66
69
  "@oclif/plugin-help": "^6.0",
67
70
  "@oclif/plugin-not-found": "^3.0",
68
- "@oclif/plugin-plugins": "^4.1",
71
+ "@oclif/plugin-warn-if-update-available": "^3.0",
69
72
  "axios": "^1.4.0",
70
73
  "baqend": "^3.4",
71
74
  "chalk": "^4",