From d5e910ebcc6c8d7f055ab0691286722b140ffcd4 Mon Sep 17 00:00:00 2001 From: Lucas Fernandes Nogueira Date: Wed, 6 Jul 2022 10:07:46 -0300 Subject: [PATCH] chore(api): remove `type-fest` (#4605) --- .changes/remove-type-fest.md | 5 +++ tooling/api/package.json | 3 -- tooling/api/src/os.ts | 72 +++++++++++++++++------------------- tooling/api/yarn.lock | 5 --- 4 files changed, 39 insertions(+), 46 deletions(-) create mode 100644 .changes/remove-type-fest.md diff --git a/.changes/remove-type-fest.md b/.changes/remove-type-fest.md new file mode 100644 index 000000000..0b1e77571 --- /dev/null +++ b/.changes/remove-type-fest.md @@ -0,0 +1,5 @@ +--- +"api": patch +--- + +Remove the `type-fest` dependency, changing the OS types to the specific enum instead of allowing any string. diff --git a/tooling/api/package.json b/tooling/api/package.json index 66129bbe8..173bf9d94 100644 --- a/tooling/api/package.json +++ b/tooling/api/package.json @@ -67,8 +67,5 @@ "typedoc": "0.23.5", "typedoc-plugin-markdown": "3.13.3", "typescript": "4.7.4" - }, - "dependencies": { - "type-fest": "2.16.0" } } diff --git a/tooling/api/src/os.ts b/tooling/api/src/os.ts index 0c06fb4ba..e81ae245d 100644 --- a/tooling/api/src/os.ts +++ b/tooling/api/src/os.ts @@ -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 @@ -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({ +async function platform(): Promise { + return invokeTauriCommand({ __tauriModule: 'Os', message: { cmd: 'platform' @@ -91,10 +103,8 @@ async function version(): Promise { * const osType = await type(); * ``` */ -async function type(): Promise< - LiteralUnion<'Linux' | 'Darwin' | 'Windows_NT', string> -> { - return invokeTauriCommand({ +async function type(): Promise { + return invokeTauriCommand({ __tauriModule: 'Os', message: { cmd: 'osType' @@ -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({ +async function arch(): Promise { + return invokeTauriCommand({ __tauriModule: 'Os', message: { cmd: 'arch' @@ -153,3 +148,4 @@ async function tempdir(): Promise { } export { EOL, platform, version, type, arch, tempdir } +export type { Platform, OsType, Arch } diff --git a/tooling/api/yarn.lock b/tooling/api/yarn.lock index 2e14c4416..c54d24bcb 100644 --- a/tooling/api/yarn.lock +++ b/tooling/api/yarn.lock @@ -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"