Skip to content

Commit 31f2ec4

Browse files
fix: migrate yargs and fix typing
2 parents a092381 + a5e7b7e commit 31f2ec4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+437
-705
lines changed

package-lock.json

Lines changed: 9 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"@puppeteer/replay": "^1.3.1",
2424
"@types/concurrently": "^7.0.0",
2525
"@types/puppeteer": "^5.4.7",
26-
"@types/yargs": "^17.0.9",
26+
"@types/yargs": "^17.0.32",
2727
"concurrently": "^7.1.0",
2828
"enquirer": "^2.3.6",
2929
"lighthouse": "^9.6.7",
@@ -33,7 +33,8 @@
3333
"puppeteer": "^19.0.0",
3434
"rxjs": "^7.8.1",
3535
"ts-node": "10.9.1",
36-
"tslib": "^2.3.1"
36+
"tslib": "^2.3.1",
37+
"yargs": "^17.7.2"
3738
},
3839
"devDependencies": {
3940
"@code-pushup/cli": "^0.25.6",

packages/cli/jest.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,4 @@ export default {
1414
transformIgnorePatterns: ['/node_modules/(?!markdown-table/.*)'],
1515
moduleFileExtensions: ['ts', 'js', 'html'],
1616
coverageDirectory: '../../coverage/packages/cli',
17-
testTimeout: 40_000,
1817
};

packages/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"dependencies": {
2323
"ts-node": "10.9.1",
2424
"tslib": "^2.3.1",
25-
"yargs": ">=15.4.1",
25+
"yargs": "^17.7.2",
2626
"typescript": "^4.6.3",
2727
"lighthouse": "^9.6.7",
2828
"puppeteer": "^19.0.0",
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import {RcJsonAsArgv} from "../../types";
1+
import { logVerbose } from '../../core/loggin';
2+
import { readBudgets } from './utils/budgets';
23

3-
import {logVerbose} from "../../core/loggin";
4-
import {readBudgets} from "./utils/budgets";
5-
6-
export async function runAssertCommand(argv: RcJsonAsArgv) {
4+
export async function runAssertCommand(): Promise<void> {
75
logVerbose(readBudgets());
86
return Promise.resolve();
97
}

packages/cli/src/lib/commands/assert/index.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
11
import { YargsCommandObject } from '../../core/yargs/types';
2-
import { logVerbose } from '../../core/loggin/index';
3-
import { readBudgets } from './utils/budgets';
2+
import { logVerbose } from '../../core/loggin';
43
import { readFile } from '../../core/file';
5-
import { getCollectCommandOptionsFromArgv } from '../collect/utils/params';
6-
import { RcJson } from '../../types';
74
import { generateMdReport } from './utils/md-report';
85

96
export const assertCommand: YargsCommandObject = {
107
command: 'assert',
118
description: 'Setup .user-flowrc.json',
129
module: {
13-
handler: async (argv: any) => {
10+
handler: async () => {
1411
logVerbose(`run "assert" as a yargs command`);
15-
const cfg = getCollectCommandOptionsFromArgv(argv);
1612
const json = JSON.parse(readFile('./packages/cli/docs/raw/order-coffee.uf.json').toString());
1713
const mdReport = generateMdReport(json);
1814
console.log('md report', mdReport);
19-
// await run(cfg);
2015
}
2116
}
2217
};
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { SharedFlagsSettings } from 'lighthouse/types/lhr/settings';
2+
import { Options } from 'yargs';
3+
4+
const budgets = {
5+
alias: 'j',
6+
type: 'array',
7+
string: true,
8+
description: 'Performance budgets (RC file only)'
9+
} satisfies Options;
10+
11+
const budgetPath = {
12+
alias: 'k',
13+
type: 'string',
14+
description: 'Path to budgets.json'
15+
} satisfies Options;
16+
17+
export const assertOptions = {
18+
budgetPath,
19+
budgets
20+
} satisfies Record<string, Options>;
21+
22+
// @TODO this type has overlap with the one in rc-json.ts we should fix that and only have one
23+
export type AssertRcOptions = {
24+
budgetPath?: string,
25+
budgets?: SharedFlagsSettings['budgets']
26+
}
27+
export type AssertArgvOptions = AssertRcOptions;

packages/cli/src/lib/commands/assert/options/budgetPath.constant.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/cli/src/lib/commands/assert/options/budgetPath.model.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.

packages/cli/src/lib/commands/assert/options/budgetPath.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)