-
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(config): organise types and runtime validations
- Loading branch information
1 parent
903bfc7
commit 3cc9655
Showing
35 changed files
with
403 additions
and
429 deletions.
There are no files selected for viewing
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,12 @@ | ||
import type { Disk } from '../lib/disk'; | ||
import { getContext } from '../lib/get-context'; | ||
import type { Config } from '../lib/get-context/get-config/config'; | ||
import { writeIfChanged } from '../lib/write-if-changed'; | ||
import type { TConfig } from '../types'; | ||
import { fixMismatches } from './fix-mismatches'; | ||
|
||
export function fixMismatchesCli(input: Partial<Config.All>, disk: Disk): void { | ||
export function fixMismatchesCli( | ||
input: Partial<TConfig.Cli>, | ||
disk: Disk, | ||
): void { | ||
writeIfChanged(fixMismatches(getContext(input, disk))); | ||
} |
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,9 @@ | ||
import type { Disk } from '../lib/disk'; | ||
import { getContext } from '../lib/get-context'; | ||
import type { Config } from '../lib/get-context/get-config/config'; | ||
import { writeIfChanged } from '../lib/write-if-changed'; | ||
import type { TConfig } from '../types'; | ||
import { format } from './format'; | ||
|
||
export function formatCli(input: Partial<Config.All>, disk: Disk): void { | ||
export function formatCli(input: Partial<TConfig.Cli>, disk: Disk): void { | ||
writeIfChanged(format(getContext(input, disk))); | ||
} |
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,9 @@ | ||
import type { Disk } from '../lib/disk'; | ||
import { exitIfInvalid } from '../lib/exit-if-invalid'; | ||
import { getContext } from '../lib/get-context'; | ||
import type { Config } from '../lib/get-context/get-config/config'; | ||
import type { TConfig } from '../types'; | ||
import { list } from './list'; | ||
|
||
export function listCli(input: Partial<Config.All>, disk: Disk): void { | ||
export function listCli(input: Partial<TConfig.Cli>, disk: Disk): void { | ||
exitIfInvalid(list(getContext(input, disk))); | ||
} |
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 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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { isBoolean } from 'expect-more'; | ||
import { ALL_DEPENDENCY_TYPES } from '../../../constants'; | ||
import type { TConfig } from '../../../types'; | ||
|
||
export function getDependencyTypes( | ||
fromCli: Partial<TConfig.Cli>, | ||
resolved: TConfig.Public, | ||
): TConfig.Private['dependencyTypes'] { | ||
const dependencyTypes: TConfig.Private['dependencyTypes'] = []; | ||
const hasTypeOverride = | ||
isBoolean(fromCli.dev) || | ||
isBoolean(fromCli.overrides) || | ||
isBoolean(fromCli.peer) || | ||
isBoolean(fromCli.pnpmOverrides) || | ||
isBoolean(fromCli.prod) || | ||
isBoolean(fromCli.resolutions) || | ||
isBoolean(fromCli.workspace); | ||
|
||
if (hasTypeOverride) { | ||
resolved.dev = Boolean(fromCli.dev); | ||
resolved.overrides = Boolean(fromCli.overrides); | ||
resolved.peer = Boolean(fromCli.peer); | ||
resolved.pnpmOverrides = Boolean(fromCli.pnpmOverrides); | ||
resolved.prod = Boolean(fromCli.prod); | ||
resolved.resolutions = Boolean(fromCli.resolutions); | ||
resolved.workspace = Boolean(fromCli.workspace); | ||
} | ||
|
||
resolved.dev && dependencyTypes.push('devDependencies'); | ||
resolved.overrides && dependencyTypes.push('overrides'); | ||
resolved.peer && dependencyTypes.push('peerDependencies'); | ||
resolved.pnpmOverrides && dependencyTypes.push('pnpmOverrides'); | ||
resolved.prod && dependencyTypes.push('dependencies'); | ||
resolved.resolutions && dependencyTypes.push('resolutions'); | ||
resolved.workspace && dependencyTypes.push('workspace'); | ||
|
||
if (dependencyTypes.length === 0) { | ||
dependencyTypes.push(...ALL_DEPENDENCY_TYPES); | ||
} | ||
|
||
return dependencyTypes; | ||
} |
Oops, something went wrong.