Skip to content

Commit

Permalink
chore(api): remove type-fest (#4605)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog committed Jul 6, 2022
1 parent fa028eb commit d5e910e
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 46 deletions.
5 changes: 5 additions & 0 deletions .changes/remove-type-fest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"api": patch
---

Remove the `type-fest` dependency, changing the OS types to the specific enum instead of allowing any string.
3 changes: 0 additions & 3 deletions tooling/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,5 @@
"typedoc": "0.23.5",
"typedoc-plugin-markdown": "3.13.3",
"typescript": "4.7.4"
},
"dependencies": {
"type-fest": "2.16.0"
}
}
72 changes: 34 additions & 38 deletions tooling/api/src/os.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,36 @@
* @module
*/

import { LiteralUnion } from 'type-fest'
import { isWindows } from './helpers/os-check'
import { invokeTauriCommand } from './helpers/tauri'

type Platform =
| 'linux'
| 'darwin'
| 'ios'
| 'freebsd'
| 'dragonfly'
| 'netbsd'
| 'openbsd'
| 'solaris'
| 'android'
| 'win32'

type OsType = 'Linux' | 'Darwin' | 'Windows_NT'

type Arch =
| 'x86'
| 'x86_64'
| 'arm'
| 'aarch64'
| 'mips'
| 'mips64'
| 'powerpc'
| 'powerpc64'
| 'riscv64'
| 's390x'
| 'sparc64'

/**
* The operating system-specific end-of-line marker.
* - `\n` on POSIX
Expand All @@ -43,22 +69,8 @@ const EOL = isWindows() ? '\r\n' : '\n'
* const platformName = await platform();
* ```
*/
async function platform(): Promise<
LiteralUnion<
| 'linux'
| 'darwin'
| 'ios'
| 'freebsd'
| 'dragonfly'
| 'netbsd'
| 'openbsd'
| 'solaris'
| 'android'
| 'win32',
string
>
> {
return invokeTauriCommand<string>({
async function platform(): Promise<Platform> {
return invokeTauriCommand<Platform>({
__tauriModule: 'Os',
message: {
cmd: 'platform'
Expand Down Expand Up @@ -91,10 +103,8 @@ async function version(): Promise<string> {
* const osType = await type();
* ```
*/
async function type(): Promise<
LiteralUnion<'Linux' | 'Darwin' | 'Windows_NT', string>
> {
return invokeTauriCommand<string>({
async function type(): Promise<OsType> {
return invokeTauriCommand<OsType>({
__tauriModule: 'Os',
message: {
cmd: 'osType'
Expand All @@ -111,23 +121,8 @@ async function type(): Promise<
* const archName = await arch();
* ```
*/
async function arch(): Promise<
LiteralUnion<
| 'x86'
| 'x86_64'
| 'arm'
| 'aarch64'
| 'mips'
| 'mips64'
| 'powerpc'
| 'powerpc64'
| 'riscv64'
| 's390x'
| 'sparc64',
string
>
> {
return invokeTauriCommand<string>({
async function arch(): Promise<Arch> {
return invokeTauriCommand<Arch>({
__tauriModule: 'Os',
message: {
cmd: 'arch'
Expand All @@ -153,3 +148,4 @@ async function tempdir(): Promise<string> {
}

export { EOL, platform, version, type, arch, tempdir }
export type { Platform, OsType, Arch }
5 changes: 0 additions & 5 deletions tooling/api/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3255,11 +3255,6 @@ type-check@^0.4.0, type-check@~0.4.0:
dependencies:
prelude-ls "^1.2.1"

type-fest@2.16.0:
version "2.16.0"
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-2.16.0.tgz#1250fbd64dafaf4c8e405e393ef3fb16d9651db2"
integrity sha512-qpaThT2HQkFb83gMOrdKVsfCN7LKxP26Yq+smPzY1FqoHRjqmjqHXA7n5Gkxi8efirtbeEUxzfEdePthQWCuHw==

type-fest@^0.20.2:
version "0.20.2"
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.20.2.tgz#1bf207f4b28f91583666cb5fbd327887301cd5f4"
Expand Down

0 comments on commit d5e910e

Please sign in to comment.