@speedkit/cli 2.34.0 → 2.36.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 CHANGED
@@ -1,3 +1,17 @@
1
+ # [2.36.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.35.0...v2.36.0) (2024-06-27)
2
+
3
+
4
+ ### Features
5
+
6
+ * **pop-prewarming:** update shielding configuration ([7aa22b6](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/7aa22b6f7a754fc8cb5fdc01454c4c4167e65035))
7
+
8
+ # [2.35.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.34.0...v2.35.0) (2024-06-21)
9
+
10
+
11
+ ### Features
12
+
13
+ * **customer-config:** add ignore assets ([8774d78](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/8774d78d042ee80937c13cdd38acff84ca5b7e4f))
14
+
1
15
  # [2.34.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.33.0...v2.34.0) (2024-06-21)
2
16
 
3
17
 
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.34.0 linux-x64 node-v20.14.0
24
+ @speedkit/cli/2.36.0 linux-x64 node-v20.15.0
25
25
  $ sk --help [COMMAND]
26
26
  USAGE
27
27
  $ sk COMMAND
@@ -287,7 +287,7 @@ Generate a pop config for the given app
287
287
 
288
288
  ```
289
289
  USAGE
290
- $ sk generate-pop-config APP [-c <value>] [-d] [-p <value>] [-t <value>] [-r]
290
+ $ sk generate-pop-config APP [-c <value>] [-d] [-p <value>] [-t <value>] [-r] [-s]
291
291
 
292
292
  ARGUMENTS
293
293
  APP The customers appName
@@ -298,6 +298,7 @@ FLAGS
298
298
  deployment will be skipped or forced.
299
299
  -p, --pop-limit=<value> [default: 5] The maximal pop count which should prewarmed.
300
300
  -r, --use-rum Compute the pop statistics based on RUM. Otherwise the real Speed Kit traffic is used.
301
+ -s, --force-shield Force a shield based prewarming config.
301
302
  -t, --traffic-share=<value> [default: 5] The minimum traffic share in percent a pop must have to be actually
302
303
  prewarmed.
303
304
 
@@ -11,6 +11,7 @@ export default class GeneratePopConfig extends Command {
11
11
  "pop-limit": import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces").CustomOptions>;
12
12
  "traffic-share": import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces").CustomOptions>;
13
13
  "use-rum": import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
14
+ "force-shield": import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
14
15
  };
15
16
  createPopPrewarmingCode(popConfig: string): Promise<string>;
16
17
  deployPrewarmingConfig(app: string, config: string, deploy: boolean | undefined): Promise<void>;
@@ -40,6 +40,11 @@ const SHIELDS = [
40
40
  pop: "HKG",
41
41
  shield: "Hongkong Shield",
42
42
  },
43
+ {
44
+ condition: ({ pop }) => ["NRT", "ITM", "TYO", "HND"].includes(pop),
45
+ pop: "NRT",
46
+ shield: "Tokyo Shield",
47
+ },
43
48
  {
44
49
  condition: ({ region }) => region === "Asia-South",
45
50
  pop: "DEL",
@@ -109,6 +114,11 @@ class GeneratePopConfig extends core_1.Command {
109
114
  default: false,
110
115
  description: "Compute the pop statistics based on RUM. Otherwise the real Speed Kit traffic is used.",
111
116
  }),
117
+ "force-shield": core_1.Flags.boolean({
118
+ char: "s",
119
+ default: false,
120
+ description: "Force a shield based prewarming config.",
121
+ }),
112
122
  };
113
123
  async createPopPrewarmingCode(popConfig) {
114
124
  const revalidationTemplate = await (0, file_helper_1.readLocalFile)(__dirname, "../templates/speedKit.Revalidated.js");
@@ -136,13 +146,13 @@ class GeneratePopConfig extends core_1.Command {
136
146
  }
137
147
  }
138
148
  async run() {
139
- const { args: { app }, flags: { coverage, deploy, "pop-limit": popLimit, "traffic-share": minimalShare, "use-rum": useRum, }, } = await this.parse(GeneratePopConfig);
149
+ const { args: { app }, flags: { coverage, deploy, "pop-limit": popLimit, "traffic-share": minimalShare, "use-rum": useRum, "force-shield": forceShield, }, } = await this.parse(GeneratePopConfig);
140
150
  // @todo refactor businessCode from this command to src/pop-config/pop-config-service
141
151
  const popConfigService = await new pop_config_1.PopConfigFactory().getService();
142
152
  const result = await popConfigService.getUsedPopsPerOrigin(app, useRum);
143
153
  const originStats = this.generateOriginStats(result).filter((stats) => stats.hits > 1000);
144
- this.printStats(originStats, coverage / 100, minimalShare / 100, popLimit);
145
- const popConfig = this.generatePopConfig(originStats, coverage / 100, minimalShare / 100, popLimit);
154
+ this.printStats(originStats, coverage / 100, minimalShare / 100, popLimit, forceShield);
155
+ const popConfig = this.generatePopConfig(originStats, coverage / 100, minimalShare / 100, popLimit, forceShield);
146
156
  await this.deployPrewarmingConfig(app, popConfig, deploy);
147
157
  }
148
158
  byHitsDesc(a, b) {
@@ -202,10 +212,10 @@ class GeneratePopConfig extends core_1.Command {
202
212
  }))
203
213
  .sort(this.byHitsDesc);
204
214
  }
205
- generatePopConfig(originStats, coverage, minimalShare, popLimit) {
215
+ generatePopConfig(originStats, coverage, minimalShare, popLimit, forceShield) {
206
216
  const originConfigs = { DEFAULT: [] };
207
217
  for (const originStat of originStats) {
208
- originConfigs[originStat.origin] = this.generatePrewarmingConfig(originStat, coverage, minimalShare, popLimit).pops.map((pop) => "POP." + pop);
218
+ originConfigs[originStat.origin] = this.generatePrewarmingConfig(originStat, coverage, minimalShare, popLimit, forceShield).pops.map((pop) => "POP." + pop);
209
219
  }
210
220
  const serializedConfig = JSON.stringify(originConfigs, null, " ")
211
221
  .replaceAll(/"(POP.*?)"/g, "$1")
@@ -262,10 +272,10 @@ const ORIGIN_POPS = ${serializedConfig}`;
262
272
  }
263
273
  return { edgeCoverage, pops, requiresShielding: true, shieldCoverage };
264
274
  }
265
- generatePrewarmingConfig(originStat, coverage, minimalShare, popLimit) {
275
+ generatePrewarmingConfig(originStat, coverage, minimalShare, popLimit, forceShield) {
266
276
  // Use shields if we need to prewar more than 5 pops to achieve the coverage
267
277
  const useShieldPrewarming = originStat.pops[popLimit - 1]?.coverage < coverage;
268
- if (useShieldPrewarming) {
278
+ if (useShieldPrewarming || forceShield) {
269
279
  return this.generatePopListByShields(originStat, coverage, minimalShare, popLimit);
270
280
  }
271
281
  return this.generatePopListByPops(originStat, coverage, minimalShare);
@@ -279,7 +289,7 @@ const ORIGIN_POPS = ${serializedConfig}`;
279
289
  }
280
290
  return { pop: s.pop, shield: s.shield };
281
291
  }
282
- printStats(originStats, coverage, minimalShare, popLimit) {
292
+ printStats(originStats, coverage, minimalShare, popLimit, forceShield) {
283
293
  let shieldingRequired = false;
284
294
  for (const originStat of originStats) {
285
295
  this.log(`${originStat.origin} ${originStat.hits}`);
@@ -303,7 +313,7 @@ const ORIGIN_POPS = ${serializedConfig}`;
303
313
  if (popStats.coverage >= coverage || popStats.share < minimalShare)
304
314
  break;
305
315
  }
306
- const config = this.generatePrewarmingConfig(originStat, coverage, minimalShare, popLimit);
316
+ const config = this.generatePrewarmingConfig(originStat, coverage, minimalShare, popLimit, forceShield);
307
317
  this.log(" --------------------");
308
318
  if (config.requiresShielding)
309
319
  this.log(" Final shield coverage: " +
@@ -93,14 +93,21 @@ const config = {
93
93
  walkPreRenderedElements(document);
94
94
  {{/if}}
95
95
  },
96
- {{#if isPlentymarkets}}
97
- stripComments: false, // Plentymarkets specific
98
- {{/if}}
99
- {{#if isShopify}}
100
- delayScriptPath: "/apps/speed-kit/speed-kit-dom-ready.js", // Shopify specific
101
- {{else}}
102
- delayScriptPath: "/speed-kit-dom-ready.js",
103
- {{/if}}
96
+ {{#if isPlentymarkets}}
97
+ stripComments: false, // Plentymarkets specific
98
+ {{/if}}
99
+ {{#if addPreRendering}}
100
+ ignoreAssets: [
101
+ // keep aligned with dynamicBlockConfig.assetChangeDetection.ignoreAssets
102
+ ],
103
+ {{else}}
104
+ ignoreAssets: [],
105
+ {{/if}}
106
+ {{#if isShopify}}
107
+ delayScriptPath: "/apps/speed-kit/speed-kit-dom-ready.js", // Shopify specific
108
+ {{else}}
109
+ delayScriptPath: "/speed-kit-dom-ready.js",
110
+ {{/if}}
104
111
  executeDeploymentDetection: true,
105
112
  {{#unless addPreRendering}}
106
113
  {{#if removeLazyLoading}}
@@ -37,6 +37,14 @@
37
37
  dynamicScriptExecution: true, // Shopify specific
38
38
  // => as some async external scripts are injected more or less randomly into the html, destroying the order of local & remote scripts
39
39
  {{/if}}
40
+ {{#if addPreRendering}}
41
+ assetChangeDetection: {
42
+ ignore: [
43
+ // keep aligned with DocumentHandler's config.ignoreAssets
44
+ ],
45
+ },
46
+ {{/if}}
47
+
40
48
  blocks: [
41
49
  // TODO: adjust/replace this exemplary list
42
50
  {{#if addPreRendering}}
@@ -378,6 +378,13 @@
378
378
  "name": "use-rum",
379
379
  "allowNo": false,
380
380
  "type": "boolean"
381
+ },
382
+ "force-shield": {
383
+ "char": "s",
384
+ "description": "Force a shield based prewarming config.",
385
+ "name": "force-shield",
386
+ "allowNo": false,
387
+ "type": "boolean"
381
388
  }
382
389
  },
383
390
  "hasDynamicHelp": false,
@@ -681,5 +688,5 @@
681
688
  ]
682
689
  }
683
690
  },
684
- "version": "2.34.0"
691
+ "version": "2.36.0"
685
692
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@speedkit/cli",
3
3
  "description": "Speed Kit CLI",
4
- "version": "2.34.0",
4
+ "version": "2.36.0",
5
5
  "author": {
6
6
  "name": "Baqend.com",
7
7
  "email": "info@baqend.com"