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 ff5ca9e commit de37ac6
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 46 deletions.
18 changes: 9 additions & 9 deletions packages/cli/src/lib/global/options/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { param as verbose, get as getVerbose } from './verbose';
import { param as rc, get as getRcPath } from '../rc-json/options/rc';
import { param as interactive, get as getInteractive } from './interactive';
import { CoreOptions } from './types';
import { verbose, get as getVerbose } from './verbose';
import { rcPath, get as getRcPath } from '../rc-json/options/rc';
import { interactive, get as getInteractive } from './interactive';
import { Options } from 'yargs';

export const GLOBAL_OPTIONS_YARGS_CFG: CoreOptions = {
...verbose,
...rc,
...interactive
};
export const GLOBAL_OPTIONS_YARGS_CFG = {
verbose,
rcPath,
interactive
} satisfies Record<string, Options>;

export const globalOptions = {
getVerbose,
Expand Down
19 changes: 8 additions & 11 deletions packages/cli/src/lib/global/options/interactive.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
import { argv } from 'yargs';
import { Param } from './interactive.model';
import { argv, Options } from 'yargs';
import { getEnvPreset } from '../../pre-set';

function getDefaultByCliMode(): boolean {
return getEnvPreset().interactive as boolean;
}
export const param: Param = {
interactive: {
alias: 'i',
type: 'boolean',
description: 'When false questions are skipped with the values from the suggestions. This is useful for CI integrations.',
default: getDefaultByCliMode()
}
};
export const interactive = {
alias: 'i',
type: 'boolean',
description: 'When false questions are skipped with the values from the suggestions. This is useful for CI integrations.',
default: getDefaultByCliMode()
} satisfies Options;

// We don't rely on yargs option normalization features as this can happen before cli bootstrap
export function get(): boolean {
const { interactive, i } = argv as any as {interactive?: boolean, i?: boolean};
return interactive !== undefined ? Boolean(interactive) : i !== undefined ? Boolean(i) : param.interactive.default;
return interactive !== undefined ? Boolean(interactive) : i !== undefined ? Boolean(i) : getDefaultByCliMode();
}
23 changes: 9 additions & 14 deletions packages/cli/src/lib/global/options/verbose.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
import { argv } from 'yargs';
import { Param } from './verbose.model';
import { GlobalOptionsArgv } from './types';
import { argv, Options } from 'yargs';
import { getEnvPreset } from '../../pre-set';


export const param: Param = {
verbose: {
alias: 'v',
type: 'boolean',
description: 'Run with verbose logging',
default: getEnvPreset().verbose
}
};
export const verbose = {
alias: 'v',
type: 'boolean',
description: 'Run with verbose logging',
default: getEnvPreset().verbose
} satisfies Options;

// We don't rely on yargs option normalization features as this can happen before cli bootstrap
export function get(): boolean {
const {verbose} = argv as unknown as GlobalOptionsArgv;
return verbose;
const {verbose} = argv as unknown as {verbose?: boolean};
return !!verbose;
}
20 changes: 8 additions & 12 deletions packages/cli/src/lib/global/rc-json/options/rc.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
import { argv } from 'yargs';
import { Param } from './rc.model';
import { argv, Options } from 'yargs';
import { getEnvPreset } from '../../../pre-set';
import { GlobalOptionsArgv } from '../../options/types';

export const param: Param = {
rcPath: {
alias: 'p',
type: 'string',
description: 'Path to user-flow.config.json. e.g. `./user-flowrc.json`',
default: getEnvPreset().rcPath
}
};
export const rcPath = {
alias: 'p',
type: 'string',
description: 'Path to user-flow.config.json. e.g. `./user-flowrc.json`',
default: getEnvPreset().rcPath
} satisfies Options;

// We don't rely on yargs option normalization features as this can happen before cli bootstrap
export function get(): string {
const { rcPath } = argv as unknown as GlobalOptionsArgv;
const { rcPath } = argv as unknown as { rcPath: string };
return rcPath as string
}

0 comments on commit de37ac6

Please sign in to comment.