-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
83 changed files
with
437 additions
and
705 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
import {RcJsonAsArgv} from "../../types"; | ||
import { logVerbose } from '../../core/loggin'; | ||
import { readBudgets } from './utils/budgets'; | ||
|
||
import {logVerbose} from "../../core/loggin"; | ||
import {readBudgets} from "./utils/budgets"; | ||
|
||
export async function runAssertCommand(argv: RcJsonAsArgv) { | ||
export async function runAssertCommand(): Promise<void> { | ||
logVerbose(readBudgets()); | ||
return Promise.resolve(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { SharedFlagsSettings } from 'lighthouse/types/lhr/settings'; | ||
import { Options } from 'yargs'; | ||
|
||
const budgets = { | ||
alias: 'j', | ||
type: 'array', | ||
string: true, | ||
description: 'Performance budgets (RC file only)' | ||
} satisfies Options; | ||
|
||
const budgetPath = { | ||
alias: 'k', | ||
type: 'string', | ||
description: 'Path to budgets.json' | ||
} satisfies Options; | ||
|
||
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; |
1 change: 0 additions & 1 deletion
1
packages/cli/src/lib/commands/assert/options/budgetPath.constant.ts
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
packages/cli/src/lib/commands/assert/options/budgetPath.model.ts
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
packages/cli/src/lib/commands/assert/options/budgetPath.ts
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
packages/cli/src/lib/commands/assert/options/budgets.model.ts
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
18 changes: 4 additions & 14 deletions
18
packages/cli/src/lib/commands/assert/utils/budgets/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; | ||
|
||
const DEFAULT_ASSERT_BUDGET_PATH = './budget.json'; | ||
|
||
export function readBudgets(budgetPath: string = DEFAULT_ASSERT_BUDGET_PATH): Budget[] { | ||
const budgetsJson = JSON.parse(readFile(budgetPath, {fail: true}) || '{}'); | ||
return budgetsJson; | ||
return JSON.parse(readFile(budgetPath, { fail: true }) || '{}'); | ||
} | ||
|
||
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.`); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,21 @@ | ||
import {RcJson, RcJsonAsArgv} from "../../types"; | ||
import {getCollectCommandOptionsFromArgv} from "./utils/params"; | ||
import {logVerbose} from "../../core/loggin"; | ||
import {run} from "../../core/processing/behaviors"; | ||
import {collectRcJson} from "../init/processes/collect-rc-json"; | ||
import {startServerIfNeededAndExecute} from "./utils/serve-command"; | ||
import {collectReports} from "./processes/collect-reports"; | ||
import { RcJson } from '../../types'; | ||
import { getCollectCommandOptionsFromArgv } from './utils/params'; | ||
import { logVerbose } from '../../core/loggin'; | ||
import { run } from '../../core/processing/behaviors'; | ||
import { collectRcJson } from '../init/processes/collect-rc-json'; | ||
import { startServerIfNeededAndExecute } from './utils/serve-command'; | ||
import { collectReports } from './processes/collect-reports'; | ||
import { CollectCommandOptions } from './options'; | ||
|
||
export async function runCollectCommand(argv: RcJsonAsArgv) { | ||
export async function runCollectCommand(argv: CollectCommandOptions): Promise<void> { | ||
const cfg = getCollectCommandOptionsFromArgv(argv); | ||
logVerbose('Collect options: ', cfg); | ||
await run([ | ||
collectRcJson, | ||
(cfg: RcJson) => | ||
startServerIfNeededAndExecute(() => collectReports(cfg) | ||
.then() | ||
, cfg.collect) | ||
startServerIfNeededAndExecute( | ||
() => collectReports(cfg, argv), | ||
cfg.collect | ||
) | ||
])(cfg); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 0 additions & 8 deletions
8
packages/cli/src/lib/commands/collect/options/awaitServeStdout.model.ts
This file was deleted.
Oops, something went wrong.
24 changes: 7 additions & 17 deletions
24
packages/cli/src/lib/commands/collect/options/awaitServeStdout.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,8 @@ | ||
import { argv } from 'yargs'; | ||
import { Param } from './awaitServeStdout.model'; | ||
import { ArgvOption } from '../../../core/yargs/types'; | ||
import { Options } from 'yargs'; | ||
|
||
// inspired by: https://github.com/GoogleChrome/lighthouse-ci/blob/main/packages/cli/src/collect/collect.js#L28-L98 | ||
export const param: Param = { | ||
awaitServeStdout: { | ||
alias: 'w', | ||
type: 'string', | ||
description: 'A string in stdou resulting from serving the app, to be awaited before start running the tests. e.g. "server running..."', | ||
implies: ['w', 'serveCommand'] | ||
} | ||
}; | ||
|
||
export function get(): string { | ||
const { awaitServeStdout } = argv as any as ArgvOption<Param>; | ||
return awaitServeStdout; | ||
} | ||
export const awaitServeStdout = { | ||
alias: 'w', | ||
type: 'string', | ||
description: 'A string in stdout resulting from serving the app, to be awaited before start running the tests. e.g. "server running..."', | ||
implies: ['w', 'serveCommand'] | ||
} satisfies Options; |
8 changes: 0 additions & 8 deletions
8
packages/cli/src/lib/commands/collect/options/config.model.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,7 @@ | ||
import { argv } from 'yargs'; | ||
import { Param } from './config.model'; | ||
import { LhConfigJson } from '../../../hacky-things/lighthouse'; | ||
import { Options } from 'yargs'; | ||
|
||
export const param: Param = { | ||
config: { | ||
alias: 'l', | ||
type: 'object', | ||
description: 'Lighthouse configuration (RC file only)' | ||
} | ||
}; | ||
|
||
export function get(): string[] { | ||
const { config } = argv as any as { config: LhConfigJson }; | ||
return config as string[]; | ||
} | ||
export const config = { | ||
alias: 'l', | ||
type: 'string', // TODO This should be type object | ||
description: 'Lighthouse configuration (RC file only)' | ||
} satisfies Options; |
8 changes: 0 additions & 8 deletions
8
packages/cli/src/lib/commands/collect/options/configPath.model.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.