@speedkit/cli 2.56.0 → 2.57.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 +15 -0
- package/README.md +1 -1
- package/dist/commands/build-prewarm-query.js +1 -2
- package/dist/commands/generate-pop-config.d.ts +10 -0
- package/dist/commands/generate-pop-config.js +31 -1
- package/dist/services/pop-config/pop-config-service.js +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
# [2.57.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.56.1...v2.57.0) (2024-09-17)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **pop-prewarming:** support static url prefixes before the country specific codes ([926fd02](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/926fd02c01877e2059739b01bea7af2fd7be56b5))
|
|
7
|
+
|
|
8
|
+
## [2.56.1](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.56.0...v2.56.1) (2024-09-16)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* remove breaking comma ([acb2d22](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/acb2d226356725f8da2ede03c5041b29dd8ddf01))
|
|
14
|
+
* remove uadevice from prewarmQuery ([52b91f7](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/52b91f770f7e2a815e05f4e94dbd3d2458418d62))
|
|
15
|
+
|
|
1
16
|
# [2.56.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.55.0...v2.56.0) (2024-09-10)
|
|
2
17
|
|
|
3
18
|
|
package/README.md
CHANGED
|
@@ -26,8 +26,7 @@ class BuildPrewarmQuery extends core_1.Command {
|
|
|
26
26
|
return `
|
|
27
27
|
select url
|
|
28
28
|
from (
|
|
29
|
-
select regexp_replace(regexp_replace(${parameterReplaceFilter}, '(^[^&?]*)&','$1?'), '\\?$','') as url
|
|
30
|
-
uadevice
|
|
29
|
+
select regexp_replace(regexp_replace(${parameterReplaceFilter}, '(^[^&?]*)&','$1?'), '\\?$','') as url
|
|
31
30
|
from live.rum.pi
|
|
32
31
|
where app = '${app}'
|
|
33
32
|
and date >= '${date}'
|
|
@@ -17,6 +17,16 @@ export default class GeneratePopConfig extends Command {
|
|
|
17
17
|
deployPrewarmingConfig(app: string, config: string, deploy: boolean | undefined): Promise<void>;
|
|
18
18
|
run(): Promise<void>;
|
|
19
19
|
private byHitsDesc;
|
|
20
|
+
/**
|
|
21
|
+
* Comparator function to sort OriginStats objects by their origin property in descending order.
|
|
22
|
+
* The comparison is primarily done based on the depth of the path (number of slashes).
|
|
23
|
+
* If the path depth is the same for both objects, a secondary comparison is done based on the path.
|
|
24
|
+
*
|
|
25
|
+
* @param a - The first OriginStats object to compare.
|
|
26
|
+
* @param b - The second OriginStats object to compare.
|
|
27
|
+
* @return Returns a negative number if `a` should appear before `b`, a positive number if `a` should appear after `b`, or zero if the objects are equivalent.
|
|
28
|
+
*/
|
|
29
|
+
private byOriginDesc;
|
|
20
30
|
private computeCoverageAndShare;
|
|
21
31
|
private generateOriginStats;
|
|
22
32
|
private generatePopConfig;
|
|
@@ -150,7 +150,22 @@ class GeneratePopConfig extends core_1.Command {
|
|
|
150
150
|
// @todo refactor businessCode from this command to src/pop-config/pop-config-service
|
|
151
151
|
const popConfigService = await new pop_config_1.PopConfigFactory().getService();
|
|
152
152
|
const result = await popConfigService.getUsedPopsPerOrigin(app, useRum);
|
|
153
|
-
const originStats = this.generateOriginStats(result)
|
|
153
|
+
const originStats = this.generateOriginStats(result)
|
|
154
|
+
.filter((stats) => {
|
|
155
|
+
if (stats.hits < 100)
|
|
156
|
+
return false;
|
|
157
|
+
try {
|
|
158
|
+
const url = new URL(stats.origin);
|
|
159
|
+
const isDevelopmentDomain = url.hostname.includes("localhost") ||
|
|
160
|
+
url.hostname.includes(".local") ||
|
|
161
|
+
url.port !== "";
|
|
162
|
+
return !isDevelopmentDomain;
|
|
163
|
+
}
|
|
164
|
+
catch {
|
|
165
|
+
return false; // unparsable origin
|
|
166
|
+
}
|
|
167
|
+
})
|
|
168
|
+
.sort(this.byOriginDesc); // make the pop config order deterministic
|
|
154
169
|
this.printStats(originStats, coverage / 100, minimalShare / 100, popLimit, forceShield);
|
|
155
170
|
const popConfig = this.generatePopConfig(originStats, coverage / 100, minimalShare / 100, popLimit, forceShield);
|
|
156
171
|
await this.deployPrewarmingConfig(app, popConfig, deploy);
|
|
@@ -158,6 +173,21 @@ class GeneratePopConfig extends core_1.Command {
|
|
|
158
173
|
byHitsDesc(a, b) {
|
|
159
174
|
return b.hits - a.hits;
|
|
160
175
|
}
|
|
176
|
+
/**
|
|
177
|
+
* Comparator function to sort OriginStats objects by their origin property in descending order.
|
|
178
|
+
* The comparison is primarily done based on the depth of the path (number of slashes).
|
|
179
|
+
* If the path depth is the same for both objects, a secondary comparison is done based on the path.
|
|
180
|
+
*
|
|
181
|
+
* @param a - The first OriginStats object to compare.
|
|
182
|
+
* @param b - The second OriginStats object to compare.
|
|
183
|
+
* @return Returns a negative number if `a` should appear before `b`, a positive number if `a` should appear after `b`, or zero if the objects are equivalent.
|
|
184
|
+
*/
|
|
185
|
+
byOriginDesc(a, b) {
|
|
186
|
+
const pathDepth = b.origin.match(/\//g).length - a.origin.match(/\//g).length;
|
|
187
|
+
if (pathDepth !== 0)
|
|
188
|
+
return pathDepth;
|
|
189
|
+
return a.origin < b.origin ? -1 : 1;
|
|
190
|
+
}
|
|
161
191
|
computeCoverageAndShare(totalHits, segmentedStats) {
|
|
162
192
|
segmentedStats = segmentedStats.sort(this.byHitsDesc);
|
|
163
193
|
let segmentHits = 0;
|
|
@@ -10,7 +10,7 @@ class PopConfigService {
|
|
|
10
10
|
const query = `
|
|
11
11
|
with data as (select *,
|
|
12
12
|
coalesce('https://' || url_extract_host(assetUrl) ||
|
|
13
|
-
regexp_extract(url_extract_path(assetUrl), '(?i)
|
|
13
|
+
regexp_extract(url_extract_path(assetUrl), '(?i)((/\\w+)?/[a-z]{2}([-/_][a-z]{2})*/)', 0),
|
|
14
14
|
'Unknown') as originWithPrefix
|
|
15
15
|
from fastly.logs
|
|
16
16
|
where date between ? and ?
|
package/oclif.manifest.json
CHANGED