From a6b42c7aa4a99596a84f831a14bf795365b59119 Mon Sep 17 00:00:00 2001 From: Lexus Drumgold Date: Wed, 30 Nov 2022 18:59:30 -0500 Subject: [PATCH] feat(types): `OS` Signed-off-by: Lexus Drumgold --- src/types/__tests__/os.spec-d.ts | 72 ++++++++++++++++++++++++++++++++ src/types/index.ts | 1 + src/types/os.ts | 25 +++++++++++ 3 files changed, 98 insertions(+) create mode 100644 src/types/__tests__/os.spec-d.ts create mode 100644 src/types/os.ts diff --git a/src/types/__tests__/os.spec-d.ts b/src/types/__tests__/os.spec-d.ts new file mode 100644 index 00000000..1023a061 --- /dev/null +++ b/src/types/__tests__/os.spec-d.ts @@ -0,0 +1,72 @@ +/** + * @file Unit Tests - OS + * @module pkg-types/types/tests/OS + */ + +import type TestSubject from '../os' + +describe('unit:types/OS', () => { + it('should allow "aix"', () => { + assertType('aix') + }) + + it('should allow "darwin"', () => { + assertType('darwin') + }) + + it('should allow "freebsd"', () => { + assertType('freebsd') + }) + + it('should allow "linux"', () => { + assertType('linux') + }) + + it('should allow "openbsd"', () => { + assertType('openbsd') + }) + + it('should allow "sunos"', () => { + assertType('sunos') + }) + + it('should allow "ppc64"', () => { + assertType('ppc64') + }) + + it('should allow "win32"', () => { + assertType('win32') + }) + + it('should allow "!aix"', () => { + assertType('!aix') + }) + + it('should allow "!darwin"', () => { + assertType('!darwin') + }) + + it('should allow "!freebsd"', () => { + assertType('!freebsd') + }) + + it('should allow "!linux"', () => { + assertType('!linux') + }) + + it('should allow "!openbsd"', () => { + assertType('!openbsd') + }) + + it('should allow "!sunos"', () => { + assertType('!sunos') + }) + + it('should allow "!ppc64"', () => { + assertType('!ppc64') + }) + + it('should allow "!win32"', () => { + assertType('!win32') + }) +}) diff --git a/src/types/index.ts b/src/types/index.ts index 205cc0dd..80f56971 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -8,6 +8,7 @@ export type { default as CPU } from './cpu' export type { default as Engine } from './engine' export type { default as ExportCondition } from './export-condition' export type { default as HoistingLimits } from './hoisiting-limits' +export type { default as OS } from './os' export type { default as Registry } from './registry' export type { default as Type } from './type' export type { default as TypesVersions } from './types-versions' diff --git a/src/types/os.ts b/src/types/os.ts new file mode 100644 index 00000000..1ef2eb8c --- /dev/null +++ b/src/types/os.ts @@ -0,0 +1,25 @@ +/** + * @file Type Definitions - OS + * @module pkg-types/types/OS + */ + +import type { EmptyString, LiteralUnion } from '@flex-development/tutils' + +/** + * Operating system platforms a package runs on. + * + * @see https://docs.npmjs.com/cli/configuring-npm/package-json#os + * @see https://yarnpkg.com/configuration/manifest#os + */ +type OS = LiteralUnion< + | `${EmptyString | '!'}aix` + | `${EmptyString | '!'}darwin` + | `${EmptyString | '!'}freebsd` + | `${EmptyString | '!'}linux` + | `${EmptyString | '!'}openbsd` + | `${EmptyString | '!'}sunos` + | `${EmptyString | '!'}win32`, + string +> + +export type { OS as default }