Skip to content

Commit

Permalink
[cli-dev-mode/optimizer] omit pageLoadAssetSizeLimit from cache and s…
Browse files Browse the repository at this point in the history
…upport --verbose logging
  • Loading branch information
spalger committed Mar 30, 2021
1 parent 34b021c commit 497f561
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 11 deletions.
2 changes: 2 additions & 0 deletions packages/kbn-cli-dev-mode/src/cli_dev_mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export type SomeCliArgs = Pick<
CliArgs,
| 'quiet'
| 'silent'
| 'verbose'
| 'disableOptimizer'
| 'watch'
| 'oss'
Expand Down Expand Up @@ -148,6 +149,7 @@ export class CliDevMode {
dist: cliArgs.dist,
quiet: !!cliArgs.quiet,
silent: !!cliArgs.silent,
verbose: !!cliArgs.verbose,
watch: cliArgs.watch,
});
}
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-cli-dev-mode/src/optimizer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const defaultOptions: Options = {
pluginScanDirs: ['/some-scan-path'],
quiet: true,
silent: true,
verbose: false,
repoRoot: '/app',
runExamples: true,
watch: true,
Expand Down
2 changes: 2 additions & 0 deletions packages/kbn-cli-dev-mode/src/optimizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export interface Options {
repoRoot: string;
quiet: boolean;
silent: boolean;
verbose: boolean;
watch: boolean;
cache: boolean;
dist: boolean;
Expand Down Expand Up @@ -80,6 +81,7 @@ export class Optimizer {

const { flags: levelFlags } = parseLogLevel(
pickLevelFromFlags({
verbose: options.verbose,
quiet: options.quiet,
silent: options.silent,
})
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-config/src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface CliArgs {
/** @deprecated */
quiet?: boolean;
silent?: boolean;
verbose?: boolean;
watch: boolean;
basePath: boolean;
oss: boolean;
Expand Down
3 changes: 2 additions & 1 deletion packages/kbn-optimizer/src/common/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Fs from 'fs';

import { BundleCache } from './bundle_cache';
import { UnknownVals } from './ts_helpers';
import { omit } from './obj_helpers';
import { includes, ascending, entriesToObject } from './array_helpers';

const VALID_BUNDLE_TYPES = ['plugin' as const, 'entry' as const];
Expand Down Expand Up @@ -90,7 +91,7 @@ export class Bundle {
*/
createCacheKey(files: string[], mtimes: Map<string, number | undefined>): unknown {
return {
spec: this.toSpec(),
spec: omit(this.toSpec(), ['pageLoadAssetSizeLimit']),
mtimes: entriesToObject(
files.map((p) => [p, mtimes.get(p)] as const).sort(ascending((e) => e[0]))
),
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-optimizer/src/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ export * from './array_helpers';
export * from './event_stream_helpers';
export * from './parse_path';
export * from './theme_tags';
export * from './obj_helpers';
17 changes: 17 additions & 0 deletions packages/kbn-optimizer/src/common/obj_helpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

export function omit<T, K extends keyof T>(obj: T, keys: K[]): Omit<T, K> {
const result: any = {};
for (const [key, value] of Object.entries(obj) as any) {
if (!keys.includes(key)) {
result[key] = value;
}
}
return result as Omit<T, K>;
}
11 changes: 1 addition & 10 deletions packages/kbn-optimizer/src/optimizer/optimizer_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
ThemeTag,
ThemeTags,
parseThemeTags,
omit,
} from '../common';

import { findKibanaPlatformPlugins, KibanaPlatformPlugin } from './kibana_platform_plugins';
Expand All @@ -40,16 +41,6 @@ function pickMaxWorkerCount(dist: boolean) {
return Math.max(maxWorkers, 2);
}

function omit<T, K extends keyof T>(obj: T, keys: K[]): Omit<T, K> {
const result: any = {};
for (const [key, value] of Object.entries(obj) as any) {
if (!keys.includes(key)) {
result[key] = value;
}
}
return result as Omit<T, K>;
}

interface Options {
/** absolute path to root of the repo/build */
repoRoot: string;
Expand Down
1 change: 1 addition & 0 deletions src/cli/serve/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ export default function (program) {
// no longer supported
quiet: !!opts.quiet,
silent: !!opts.silent,
verbose: !!opts.verbose,
watch: !!opts.watch,
runExamples: !!opts.runExamples,
// We want to run without base path when the `--run-examples` flag is given so that we can use local
Expand Down

0 comments on commit 497f561

Please sign in to comment.