Revert "nit" and "bump jest and fix yargs typing"

This reverts commit b737c40931.
This reverts commit 8eb05ded9b.
This commit is contained in:
Ronan Jouchet 2022-07-23 19:20:24 -04:00
parent b737c40931
commit 9db7ad050a
3 changed files with 2656 additions and 915 deletions

3551
npm-shrinkwrap.json generated

File diff suppressed because it is too large Load Diff

View File

@ -80,14 +80,13 @@
"@types/node": "14.14.20",
"@types/page-icon": "^0.3.4",
"@types/tmp": "^0.2.1",
"@types/yargs": "^17.0.10",
"@typescript-eslint/eslint-plugin": "^5.3.0",
"@typescript-eslint/parser": "^5.3.0",
"electron": "^18.3.5",
"eslint": "^8.1.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"jest": "^28.1.3",
"jest": "^27.0.6",
"playwright": "^1.21.1",
"prettier": "^2.3.2",
"rimraf": "^3.0.2",

View File

@ -18,19 +18,6 @@ import { RawOptions } from '../shared/src/options/model';
import { parseJson } from './utils/parseUtils';
import { buildUniversalApp } from './build/buildNativefierApp';
// @types/yargs@17.x started pretending yargs.argv can be a promise:
// https://github.com/DefinitelyTyped/DefinitelyTyped/blob/8e17f9ca957a06040badb53ae7688fbb74229ccf/types/yargs/index.d.ts#L73
// Dunno in which case it happens, but it doesn't for us! So, having to await
// (and end up having to flag sync code as async) would be useless and annoying.
// So, copy-pastaing and axing the Promise half of yargs's type definition,
// to have a *non*-promise type. Maybe that's wrong. If it is, this type should
// be dropped, and extra async-ness should be added where needed.
type YargsArgvSync<T> = {
[key in keyof yargs.Arguments<T> as
| key
| yargs.CamelCaseKey<key>]: yargs.Arguments<T>[key];
};
export function initArgs(argv: string[]): yargs.Argv<RawOptions> {
const sanitizedArgs = sanitizeArgs(argv);
const args = yargs(sanitizedArgs)
@ -547,7 +534,7 @@ export function initArgs(argv: string[]): yargs.Argv<RawOptions> {
// We must access argv in order to get yargs to actually process args
// Do this now to go ahead and get any errors out of the way
args.argv as YargsArgvSync<RawOptions>;
args.argv;
return args as yargs.Argv<RawOptions>;
}
@ -557,7 +544,7 @@ function decorateYargOptionGroup(value: string): string {
}
export function parseArgs(args: yargs.Argv<RawOptions>): RawOptions {
const parsed = { ...(args.argv as YargsArgvSync<RawOptions>) };
const parsed = { ...args.argv };
// In yargs, the _ property of the parsed args is an array of the positional args
// https://github.com/yargs/yargs/blob/master/docs/examples.md#and-non-hyphenated-options-too-just-use-argv_
// So try to extract the targetUrl and outputDirectory from these