Skip to content

Commit

Permalink
[kbn/optimizer] ignore missing metrics when updating limits with --fo…
Browse files Browse the repository at this point in the history
…cus (#81696)

Co-authored-by: spalger <[email protected]>
  • Loading branch information
Spencer and spalger authored Oct 27, 2020
1 parent b304051 commit 72ff6b8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 5 additions & 1 deletion packages/kbn-optimizer/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,11 @@ run(
await lastValueFrom(update$.pipe(logOptimizerState(log, config)));

if (updateLimits) {
updateBundleLimits(log, config);
updateBundleLimits({
log,
config,
dropMissing: !(focus || filter),
});
}
},
{
Expand Down
12 changes: 10 additions & 2 deletions packages/kbn-optimizer/src/limits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,18 @@ export function validateLimitsForAllBundles(log: ToolingLog, config: OptimizerCo
log.success('limits.yml file valid');
}

export function updateBundleLimits(log: ToolingLog, config: OptimizerConfig) {
interface UpdateBundleLimitsOptions {
log: ToolingLog;
config: OptimizerConfig;
dropMissing: boolean;
}

export function updateBundleLimits({ log, config, dropMissing }: UpdateBundleLimitsOptions) {
const metrics = getMetrics(log, config);

const pageLoadAssetSize: NonNullable<Limits['pageLoadAssetSize']> = {};
const pageLoadAssetSize: NonNullable<Limits['pageLoadAssetSize']> = dropMissing
? {}
: config.limits.pageLoadAssetSize ?? {};

for (const metric of metrics.sort((a, b) => a.id.localeCompare(b.id))) {
if (metric.group === 'page load bundle size') {
Expand Down

0 comments on commit 72ff6b8

Please sign in to comment.