-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Tech] Type-check Legendary commands (#2918)
- Loading branch information
1 parent
6b788e2
commit e111423
Showing
26 changed files
with
488 additions
and
200 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
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { NonEmptyString } from './base' | ||
|
||
interface AuthCommand { | ||
subcommand: 'auth' | ||
'--import'?: true | ||
'--code'?: NonEmptyString | ||
'--token'?: NonEmptyString | ||
'--sid'?: NonEmptyString | ||
'--delete'?: true | ||
'--disable-webview'?: true | ||
} | ||
|
||
export default AuthCommand |
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,37 @@ | ||
import { z } from 'zod' | ||
import path from 'path' | ||
import { hasGame } from '../library' | ||
|
||
export const LegendaryAppName = z | ||
.string() | ||
.refine((val) => hasGame(val), { | ||
message: 'AppName was not found on account' | ||
}) | ||
.brand('LegendaryAppName') | ||
export type LegendaryAppName = z.infer<typeof LegendaryAppName> | ||
|
||
export const LegendaryPlatform = z.enum(['Win32', 'Windows', 'Mac'] as const) | ||
export type LegendaryPlatform = z.infer<typeof LegendaryPlatform> | ||
|
||
export const NonEmptyString = z.string().min(1).brand('NonEmptyString') | ||
export type NonEmptyString = z.infer<typeof NonEmptyString> | ||
|
||
export const Path = z | ||
.string() | ||
.refine((val) => path.parse(val).root, 'Path is not valid') | ||
.brand('Path') | ||
export type Path = z.infer<typeof Path> | ||
|
||
export const PositiveInteger = z | ||
.number() | ||
.int() | ||
.positive() | ||
.brand('PositiveInteger') | ||
export type PositiveInteger = z.infer<typeof PositiveInteger> | ||
|
||
export const URL = z.string().url().brand('URL') | ||
export type URL = z.infer<typeof URL> | ||
|
||
// FIXME: This doesn't feel right | ||
export const URI = z.union([Path, URL]) | ||
export type URI = z.infer<typeof URI> |
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,6 @@ | ||
interface CleanupCommand { | ||
subcommand: 'cleanup' | ||
'--keep-manifests'?: true | ||
} | ||
|
||
export default CleanupCommand |
23 changes: 23 additions & 0 deletions
23
src/backend/storeManagers/legendary/commands/eos_overlay.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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { z } from 'zod' | ||
import { LegendaryAppName, NonEmptyString, Path } from './base' | ||
|
||
const EosOverlayAction = z.enum([ | ||
'install', | ||
'update', | ||
'remove', | ||
'enable', | ||
'disable', | ||
'info' | ||
] as const) | ||
type EosOverlayAction = z.infer<typeof EosOverlayAction> | ||
|
||
interface EosOverlayCommand { | ||
subcommand: 'eos-overlay' | ||
action: EosOverlayAction | ||
'--path'?: Path | ||
'--prefix'?: Path | ||
'--app'?: LegendaryAppName | ||
'--bottle'?: NonEmptyString | ||
} | ||
|
||
export default EosOverlayCommand |
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,12 @@ | ||
import { LegendaryAppName, LegendaryPlatform, Path } from './base' | ||
|
||
interface ImportCommand { | ||
subcommand: 'import' | ||
appName: LegendaryAppName | ||
installationDirectory: Path | ||
'--disable-check'?: true | ||
'--with-dlcs'?: true | ||
'--platform'?: LegendaryPlatform | ||
} | ||
|
||
export default ImportCommand |
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,11 @@ | ||
import { LegendaryAppName, LegendaryPlatform } from './base' | ||
|
||
interface InfoCommand { | ||
subcommand: 'info' | ||
appName: LegendaryAppName | ||
'--offline'?: true | ||
'--json'?: true | ||
'--platform'?: LegendaryPlatform | ||
} | ||
|
||
export default InfoCommand |
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,48 @@ | ||
import { | ||
PositiveInteger, | ||
LegendaryAppName, | ||
NonEmptyString, | ||
Path, | ||
URL, | ||
URI, | ||
LegendaryPlatform | ||
} from './base' | ||
|
||
interface InstallCommand { | ||
subcommand: 'install' | 'download' | 'update' | 'repair' | ||
appName: LegendaryAppName | ||
sdlList?: NonEmptyString[] | ||
'--base-path'?: Path | ||
'--game-folder'?: NonEmptyString | ||
'--max-shared-memory'?: PositiveInteger | ||
'--max-workers'?: PositiveInteger | ||
'--manifest'?: URI | ||
'--old-manifest'?: URI | ||
'--delta-manifest'?: URI | ||
'--base-url'?: URL | ||
'--force'?: true | ||
'--disable-patching'?: true | ||
'--download-only'?: true | ||
'--no-install'?: true | ||
'--update-only'?: true | ||
'--dlm-debug'?: true | ||
'--platform'?: LegendaryPlatform | ||
'--prefix'?: NonEmptyString | ||
'--exclude'?: NonEmptyString | ||
'--enable-reordering'?: true | ||
'--dl-timeout'?: PositiveInteger | ||
'--save-path'?: Path | ||
'--repair'?: true | ||
'--repair-and-update'?: true | ||
'--ignore-free-space'?: true | ||
'--disable-delta-manifests'?: true | ||
'--reset-sdl'?: true | ||
'--skip-sdl'?: true | ||
'--disable-sdl'?: true | ||
'--preferred-cdn'?: NonEmptyString | ||
'--no-https'?: true | ||
'--with-dlcs'?: true | ||
'--skip-dlcs'?: true | ||
} | ||
|
||
export default InstallCommand |
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,26 @@ | ||
import { LegendaryAppName, NonEmptyString, Path } from './base' | ||
|
||
interface LaunchCommand { | ||
subcommand: 'launch' | ||
appName: LegendaryAppName | ||
extraArguments?: string | ||
'--offline'?: true | ||
'--skip-version-check'?: true | ||
'--override-username'?: NonEmptyString | ||
'--dry-run'?: true | ||
'--language'?: NonEmptyString | ||
'--wrapper'?: NonEmptyString | ||
'--set-defaults'?: true | ||
'--reset-defaults'?: true | ||
'--override-exe'?: Path | ||
'--origin'?: true | ||
'--json'?: true | ||
'--wine'?: Path | ||
'--wine-prefix'?: Path | ||
'--no-wine'?: true | ||
'--crossover'?: true | ||
'--crossover-app'?: Path | ||
'--crossover-bottle'?: NonEmptyString | ||
} | ||
|
||
export default LaunchCommand |
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,16 @@ | ||
import { LegendaryPlatform } from './base' | ||
|
||
interface ListCommand { | ||
subcommand: 'list' | ||
'--platform'?: LegendaryPlatform | ||
'--include-ue'?: true | ||
'-T'?: true | ||
'--third-party'?: true | ||
'--include-non-installable'?: true | ||
'--csv'?: true | ||
'--tsv'?: true | ||
'--json'?: true | ||
'--force-refresh'?: true | ||
} | ||
|
||
export default ListCommand |
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,10 @@ | ||
import { LegendaryAppName, Path } from './base' | ||
|
||
interface MoveCommand { | ||
subcommand: 'move' | ||
appName: LegendaryAppName | ||
newBasePath: Path | ||
'--skip-move'?: true | ||
} | ||
|
||
export default MoveCommand |
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,7 @@ | ||
interface StatusCommand { | ||
subcommand: 'status' | ||
'--offline'?: true | ||
'--json'?: true | ||
} | ||
|
||
export default StatusCommand |
15 changes: 15 additions & 0 deletions
15
src/backend/storeManagers/legendary/commands/sync_saves.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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { LegendaryAppName, Path } from './base' | ||
|
||
interface SyncSavesCommand { | ||
subcommand: 'sync-saves' | ||
appName: LegendaryAppName | ||
'--skip-upload'?: true | ||
'--skip-download'?: true | ||
'--force-upload'?: true | ||
'--force-download'?: true | ||
'--save-path'?: Path | ||
'--disable-filters'?: true | ||
'--accept-path'?: true | ||
} | ||
|
||
export default SyncSavesCommand |
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,9 @@ | ||
import { LegendaryAppName } from './base' | ||
|
||
interface UninstallCommand { | ||
subcommand: 'uninstall' | ||
appName: LegendaryAppName | ||
'--keep-files'?: true | ||
} | ||
|
||
export default UninstallCommand |
Oops, something went wrong.