Skip to content

Commit

Permalink
feat(interfaces): WorkspacesConfig
Browse files Browse the repository at this point in the history
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
  • Loading branch information
unicornware committed Dec 1, 2022
1 parent 28d68fd commit 154c209
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/interfaces/__tests__/workspaces-config.spec-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* @file Unit Tests - WorkspacesConfig
* @module pkg-types/interfaces/tests/WorkspacesConfig
*/

import type TestSubject from '../workspaces-config'

describe('unit:interfaces/WorkspacesConfig', () => {
it('should allow empty object', () => {
assertType<TestSubject>({})
})

it('should allow object that only has nohoist rules', () => {
assertType<TestSubject>({ nohoist: ['react-native', 'react-native/**'] })
})

it('should allow object that only has workspace rules', () => {
assertType<TestSubject>({ packages: ['packages/*'] })
})

it('should allow object with nohoist and workspace rules', () => {
assertType<Required<TestSubject>>({
nohoist: ['**/react-native', '**/react-native/**'],
packages: ['packages/*']
})
})
})
1 change: 1 addition & 0 deletions src/interfaces/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
export type { default as BugsObject } from './bugs-object'
export type { default as DependencyMeta } from './dependency-meta'
export type { default as PeerDependencyMeta } from './peer-dependency-meta'
export type { default as WorkspacesConfig } from './workspaces-config'
30 changes: 30 additions & 0 deletions src/interfaces/workspaces-config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* @file Interfaces - WorkspacesConfig
* @module pkg-types/interfaces/WorkspacesConfig
*/

/**
* Yarn Workspaces configuration.
*
* @see https://classic.yarnpkg.com/docs/workspaces
* @see https://yarnpkg.com/features/workspaces
*/
interface WorkspacesConfig {
/**
* [Glob patterns][1] matching module paths to prevent from being hoisted.
*
* [1]: https://github.com/isaacs/minimatch
*
* @see https://classic.yarnpkg.com/blog/2018/02/15/nohoist
*/
nohoist?: string[]

/**
* [Glob patterns][1] matching all directories that should become workspaces.
*
* [1]: https://github.com/isaacs/minimatch
*/
packages?: string[]
}

export type { WorkspacesConfig as default }

0 comments on commit 154c209

Please sign in to comment.