Skip to content

Commit

Permalink
inline getMetrics logic which isn't shared anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
spalger committed Feb 5, 2021
1 parent 6645d0c commit b722e38
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 26 deletions.
14 changes: 10 additions & 4 deletions packages/kbn-optimizer/src/limits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
*/

import Fs from 'fs';
import Path from 'path';

import dedent from 'dedent';
import Yaml from 'js-yaml';
import { createFailError, ToolingLog } from '@kbn/dev-utils';
import { createFailError, ToolingLog, CiStatsMetrics } from '@kbn/dev-utils';

import { OptimizerConfig, getMetrics, Limits } from './optimizer';
import { OptimizerConfig, Limits } from './optimizer';

const LIMITS_PATH = require.resolve('../limits.yml');
const DEFAULT_BUDGET = 15000;
Expand Down Expand Up @@ -76,13 +77,18 @@ interface UpdateBundleLimitsOptions {

export function updateBundleLimits({ log, config, dropMissing }: UpdateBundleLimitsOptions) {
const limits = readLimits();
const metrics = getMetrics(config);
const metrics: CiStatsMetrics = config.bundles
.map((bundle) =>
JSON.parse(Fs.readFileSync(Path.resolve(bundle.outputDir, 'metrics.json'), 'utf-8'))
)
.flat()
.sort((a, b) => a.id.localeCompare(b.id));

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

for (const metric of metrics.sort((a, b) => a.id.localeCompare(b.id))) {
for (const metric of metrics) {
if (metric.group === 'page load bundle size') {
const existingLimit = limits.pageLoadAssetSize?.[metric.id];
pageLoadAssetSize[metric.id] =
Expand Down
21 changes: 0 additions & 21 deletions packages/kbn-optimizer/src/optimizer/get_output_stats.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/kbn-optimizer/src/optimizer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@ export * from './watch_bundles_for_changes';
export * from './run_workers';
export * from './bundle_cache';
export * from './handle_optimizer_completion';
export * from './get_output_stats';

0 comments on commit b722e38

Please sign in to comment.