Skip to content

Commit

Permalink
fix: remove unnecessary patch type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherPHolder committed Feb 25, 2024
1 parent dc45f93 commit ff5ca9e
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 57 deletions.
8 changes: 8 additions & 0 deletions packages/cli/src/lib/commands/assert/options.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { SharedFlagsSettings } from 'lighthouse/types/lhr/settings';
import { Options } from 'yargs';

const budgets = {
Expand All @@ -17,3 +18,10 @@ export const assertOptions = {
budgetPath,
budgets
} satisfies Record<string, Options>;

// @TODO this type has overlap with the one in rc-json.ts we should fix that and only have one
export type AssertRcOptions = {
budgetPath?: string,
budgets?: SharedFlagsSettings['budgets']
}
export type AssertArgvOptions = AssertRcOptions;

This file was deleted.

8 changes: 0 additions & 8 deletions packages/cli/src/lib/commands/assert/options/budgets.model.ts

This file was deleted.

13 changes: 0 additions & 13 deletions packages/cli/src/lib/commands/assert/options/types.ts

This file was deleted.

14 changes: 2 additions & 12 deletions packages/cli/src/lib/commands/assert/utils/budgets/index.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
import { readFile, writeFile } from '../../../../core/file';
import { logVerbose } from '../../../../core/loggin';
import Budget from 'lighthouse/types/lhr/budget';
import { DEFAULT_ASSERT_BUDGET_PATH } from '../../options/budgetPath.constant';
import { readFile } from '../../../../core/file';
import { DEFAULT_ASSERT_BUDGET_PATH } from '../../constants';

export function readBudgets(budgetPath: string = DEFAULT_ASSERT_BUDGET_PATH): Budget[] {
const budgetsJson = JSON.parse(readFile(budgetPath, {fail: true}) || '{}');
return budgetsJson;
}

export function writeBudgets(config: Budget[], budgetPath: string = DEFAULT_ASSERT_BUDGET_PATH): void {
logVerbose(`Update budgets under ${budgetPath}`);

if (JSON.stringify(readBudgets()) !== JSON.stringify(config)) {
writeFile(budgetPath, JSON.stringify(config));
logVerbose(`New budgets ${JSON.stringify(config)}`);
} else {
logVerbose(`No updates for ${budgetPath} to save.`);
}
}

9 changes: 1 addition & 8 deletions packages/cli/src/lib/commands/collect/options/types.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
import { Param as OpenReport } from './openReport.model';
import { Param as UfPath } from './ufPath.model';
import { Param as Url } from './url.model';
import { Param as ServeCommand } from './serveCommand.model';
import { Param as AwaitServeStdout } from './awaitServeStdout.model';
import { Param as OutPath } from './outPath.model';
import { Param as Format } from './format.model';
import { AssertArgvOptions } from '../../assert/options/types';
import { AssertArgvOptions } from '../../assert/options';
import { LhConfigJson } from '../../../hacky-things/lighthouse';

export type CollectRcOptions = {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/lib/commands/collect/utils/params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
PersistArgvOptions,
PersistRcOptions
} from '../options/types';
import { AssertArgvOptions } from '../../assert/options/types';
import { AssertArgvOptions } from '../../assert/options';
import { CollectOptions } from '../options';


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { detectCliMode } from '../../../../global/cli-mode/cli-mode';
import { CollectArgvOptions } from '../../options/types';
import { getLhConfigFromArgv, mergeLhConfig } from '../config';
import { PersistArgvOptions } from '../../options/types';
import { AssertRcOptions } from '../../../assert/options/types';
import { AssertRcOptions } from '../../../assert/options';

export async function collectFlow(
cliOption: CollectArgvOptions & PersistArgvOptions & AssertRcOptions,
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/lib/commands/init/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CollectRcOptions, PersistRcOptions } from '../collect/options/types';
import { AssertRcOptions } from '../assert/options/types';
import { InitOptions } from './options';
import { AssertRcOptions } from '../assert/options';

export function getInitCommandOptionsFromArgv(argv: InitOptions) {
let {
Expand Down
6 changes: 1 addition & 5 deletions packages/cli/src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
PersistArgvOptions,
PersistRcOptions
} from './commands/collect/options/types';
import { AssertArgvOptions, AssertRcOptions } from './commands/assert/options/types';
import { AssertArgvOptions, AssertRcOptions } from './commands/assert/options';

export type ArgvPreset =
{ rcPath: GlobalOptionsArgv['rcPath'] } &
Expand All @@ -18,8 +18,4 @@ export type RcJson = {
collect: CollectRcOptions;
persist: PersistRcOptions;
assert?: AssertRcOptions;
// eslint-disable-next-line @typescript-eslint/ban-types
} & Object;

export type RcJsonAsArgv = CollectRcOptions & PersistRcOptions & AssertRcOptions;

0 comments on commit ff5ca9e

Please sign in to comment.