Skip to content

Commit

Permalink
build(deps): bump @flex-development/mlly from 1.0.0-alpha.19 to 1.0.0…
Browse files Browse the repository at this point in the history
…-alpha.20

Signed-off-by: Lexus Drumgold <[email protected]>
  • Loading branch information
unicornware committed Dec 30, 2024
1 parent bace4e8 commit cb96350
Show file tree
Hide file tree
Showing 18 changed files with 485 additions and 472 deletions.
1 change: 1 addition & 0 deletions .dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ kaisugi
ksort
lcov
mkbuild
nocase
nvmrc
pkgs
preid
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ convenience of TypeScript users who do not hoist packages, but may need to `impo
### Types

- [`GetCanonicalFileName`](./src/types/get-canonical-file-name.mts)
- [`ReadDirectory`](./src/types/read-directory.mts)

## Related

Expand Down
9 changes: 3 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,8 @@
"tsconfig-utils": "./src/internal/fs.browser.mts",
"default": "./dist/internal/fs.browser.mjs"
},
"node": {
"tsconfig-utils": "./src/internal/fs.node.mts",
"default": "./dist/internal/fs.node.mjs"
},
"default": "./dist/internal/fs.node.mjs"
"node": "fs",
"default": "fs"
},
"#internal/*": {
"tsconfig-utils": "./src/internal/*.mts",
Expand Down Expand Up @@ -128,7 +125,7 @@
},
"dependencies": {
"@flex-development/errnode": "3.1.1",
"@flex-development/mlly": "1.0.0-alpha.19",
"@flex-development/mlly": "1.0.0-alpha.20",
"@flex-development/pathe": "4.0.1",
"@flex-development/pkg-types": "4.1.0",
"@flex-development/tsconfig-types": "5.1.0",
Expand Down
64 changes: 2 additions & 62 deletions src/interfaces/__tests__/file-system.spec-d.mts
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,8 @@ describe('unit-d:interfaces/FileSystem', () => {
expectTypeOf<TestSubject>().toMatchTypeOf<mlly.FileSystem>()
})

describe('readFile', () => {
type Subject = TestSubject['readFile']

it('should match [this: void]', () => {
expectTypeOf<Subject>().thisParameter.toEqualTypeOf<void>()
})

describe('parameters', () => {
it('should be callable with [mlly.ModuleId]', () => {
expectTypeOf<Subject>().parameters.toEqualTypeOf<[mlly.ModuleId]>()
})
})

describe('returns', () => {
it('should return Buffer | string', () => {
expectTypeOf<Subject>().returns.toEqualTypeOf<Buffer | string>()
})
})
})

describe('readdir', () => {
type Subject = TestSubject['readdir']
describe('readdirSync', () => {
type Subject = TestSubject['readdirSync']

it('should match [this: void]', () => {
expectTypeOf<Subject>().thisParameter.toEqualTypeOf<void>()
Expand All @@ -50,44 +30,4 @@ describe('unit-d:interfaces/FileSystem', () => {
})
})
})

describe('realpath', () => {
type Subject = TestSubject['realpath']

it('should match [this: void]', () => {
expectTypeOf<Subject>().thisParameter.toEqualTypeOf<void>()
})

describe('parameters', () => {
it('should be callable with [mlly.ModuleId]', () => {
expectTypeOf<Subject>().parameters.toEqualTypeOf<[mlly.ModuleId]>()
})
})

describe('returns', () => {
it('should return string', () => {
expectTypeOf<Subject>().returns.toEqualTypeOf<string>()
})
})
})

describe('stat', () => {
type Subject = TestSubject['stat']

it('should match [this: void]', () => {
expectTypeOf<Subject>().thisParameter.toEqualTypeOf<void>()
})

describe('parameters', () => {
it('should be callable with [mlly.ModuleId]', () => {
expectTypeOf<Subject>().parameters.toEqualTypeOf<[mlly.ModuleId]>()
})
})

describe('returns', () => {
it('should return mlly.Stats', () => {
expectTypeOf<Subject>().returns.toEqualTypeOf<mlly.Stats>()
})
})
})
})
38 changes: 10 additions & 28 deletions src/interfaces/__tests__/host-parse-config.spec-d.mts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,23 @@
*/

import type TestSubject from '#interfaces/host-parse-config'
import type { ModuleId } from '@flex-development/mlly'
import type { ModuleResolutionHost } from '@flex-development/tsconfig-utils'
import type {
ModuleResolutionHost,
ReadDirectory
} from '@flex-development/tsconfig-utils'
import type ts from 'typescript'

describe('unit-d:interfaces/ParseConfigHost', () => {
it('should extend ModuleResolutionHost', () => {
expectTypeOf<TestSubject>().toMatchTypeOf<ModuleResolutionHost>()
})

it('should match [readDirectory: ReadDirectory]', () => {
expectTypeOf<TestSubject>()
.toHaveProperty('readDirectory')
.toEqualTypeOf<ReadDirectory>
})

it('should match [useCaseSensitiveFileNames: boolean]', () => {
expectTypeOf<TestSubject>()
.toHaveProperty('useCaseSensitiveFileNames')
Expand All @@ -23,30 +31,4 @@ describe('unit-d:interfaces/ParseConfigHost', () => {
expectTypeOf<TestSubject>()
.toMatchTypeOf<Required<Omit<ts.ParseConfigHost, 'trace'>>>()
})

describe('readDirectory', () => {
type Subject = TestSubject['readDirectory']

it('should match [this: void]', () => {
expectTypeOf<Subject>().thisParameter.toEqualTypeOf<void>()
})

describe('parameters', () => {
it('should be callable with [ModuleId, Set<string> | readonly string[] | undefined, Set<string> | readonly string[] | undefined, Set<string> | readonly string[] | undefined, number | null | undefined]', () => {
expectTypeOf<Subject>().parameters.toEqualTypeOf<[
ModuleId,
(Set<string> | readonly string[] | undefined)?,
(Set<string> | readonly string[] | undefined)?,
(Set<string> | readonly string[] | undefined)?,
(number | null | undefined)?
]>()
})
})

describe('returns', () => {
it('should return readonly string[]', () => {
expectTypeOf<Subject>().returns.toEqualTypeOf<readonly string[]>()
})
})
})
})
53 changes: 2 additions & 51 deletions src/interfaces/file-system.mts
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,6 @@ import type * as mlly from '@flex-development/mlly'
* @extends {mlly.FileSystem}
*/
interface FileSystem extends mlly.FileSystem {
/**
* Get the contents of a file.
*
* @see {@linkcode Buffer}
* @see {@linkcode mlly.ModuleId}
*
* @override
*
* @this {void}
*
* @param {mlly.ModuleId} id
* The path or `file:` URL to handle
* @return {Buffer | string}
* File contents
*/
readFile(this: void, id: mlly.ModuleId): Buffer | string

/**
* Read the contents of a directory.
*
Expand All @@ -42,39 +25,7 @@ interface FileSystem extends mlly.FileSystem {
* @return {string[]}
* List of filenames
*/
readdir(this: void, id: mlly.ModuleId): string[]

/**
* Get the resolved pathname of `id`.
*
* @see {@linkcode mlly.ModuleId}
*
* @override
*
* @this {void}
*
* @param {mlly.ModuleId} id
* The path or `file:` URL to handle
* @return {string}
* Canonical pathname of `id`
*/
realpath(this: void, id: mlly.ModuleId): string

/**
* Get information about a directory or file.
*
* @see {@linkcode mlly.ModuleId}
* @see {@linkcode mlly.Stats}
*
* @override
*
* @this {void}
*
* @param {mlly.ModuleId} id
* The path or `file:` URL to handle
* @return {mlly.Stats}
* Info about `id`
*/
stat(this: void, id: mlly.ModuleId): mlly.Stats
readdirSync(this: void, id: mlly.ModuleId): string[]
}

export type { FileSystem as default }
36 changes: 8 additions & 28 deletions src/interfaces/host-parse-config.mts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
/**
* @file Interfaces - ModuleResolutionHost
* @module tsconfig-utils/interfaces/ModuleResolutionHost
* @file Interfaces - ParseConfigHost
* @module tsconfig-utils/interfaces/ParseConfigHost
*/

import type { ModuleId } from '@flex-development/mlly'
import type { ModuleResolutionHost } from '@flex-development/tsconfig-utils'
import type {
ModuleResolutionHost,
ReadDirectory
} from '@flex-development/tsconfig-utils'

/**
* Configuration parser host API.
Expand All @@ -19,31 +21,9 @@ interface ParseConfigHost extends ModuleResolutionHost {
/**
* Get a list of files in a directory.
*
* @see {@linkcode ModuleId}
*
* @this {void}
*
* @param {ModuleId} id
* The directory path or URL to read
* @param {Set<string> | ReadonlyArray<string> | undefined} [extensions]
* List of file extensions to filter for
* @param {Set<string> | ReadonlyArray<string> | undefined} [exclude]
* List of of glob patterns matching files to exclude
* @param {Set<string> | ReadonlyArray<string> | undefined} [include]
* List of of glob patterns matching files to include
* @param {number | null | undefined} [depth]
* Maximum search depth (inclusive)
* @return {ReadonlyArray<string>}
* List of files under directory at `id`
* @see {@linkcode ReadDirectory}
*/
readDirectory(
this: void,
id: ModuleId,
extensions?: Set<string> | readonly string[] | undefined,
exclude?: Set<string> | readonly string[] | undefined,
include?: Set<string> | readonly string[] | undefined,
depth?: number | null | undefined
): readonly string[]
readDirectory: ReadDirectory

/**
* Treat filenames as case-sensitive?
Expand Down
80 changes: 80 additions & 0 deletions src/internal/__tests__/match-files.spec.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/**
* @file Unit Tests - matchFiles
* @module tsconfig-utils/internal/tests/unit/matchFiles
*/

import testSubject from '#internal/match-files'
import toPath from '#internal/to-path'
import createModuleResolutionHost from '#lib/create-module-resolution-host'
import * as mlly from '@flex-development/mlly'
import type { FileSystem } from '@flex-development/tsconfig-utils'
import { alphabetize, identity } from '@flex-development/tutils'
import ts from 'typescript'
import tsconfig from '../../../tsconfig.json' with { type: 'json' }

describe('unit:internal/matchFiles', () => {
it.each<[
id: mlly.ModuleId,
extensions: Set<string> | readonly string[] | undefined,
exclude: Set<string> | readonly string[] | undefined,
include: Set<string> | readonly string[] | undefined,
useCaseSensitiveFileNames?: boolean | null | undefined,
depth?: number | null | undefined,
fs?: FileSystem | null | undefined
]>([
[
new URL('src', mlly.cwd()),
['.cjs', '.cts', '.js', '.json', '.mjs', '.mts', '.ts'],
tsconfig.exclude,
tsconfig.include,
null,
0
],
[
mlly.cwd(),
['.cjs', '.cts', '.js', '.json', '.mjs', '.mts', '.ts'],
tsconfig.exclude,
tsconfig.include
],
[
mlly.cwd(),
['.mjs', '.mts', '.ts'],
tsconfig.exclude,
tsconfig.include,
undefined,
1
]
])('should return list of files under directory at `id` (%#)', (
id,
extensions,
exclude,
include,
useCaseSensitiveFileNames,
depth,
fs
) => {
// Arrange
const expected: readonly string[] = alphabetize(ts.sys.readDirectory(
toPath(id),
extensions ? [...extensions] : undefined,
exclude ? [...exclude] : undefined,
include ? [...include] : undefined,
depth ?? undefined
), identity)

// Act
const result = testSubject(
createModuleResolutionHost(),
id,
extensions,
exclude,
include,
useCaseSensitiveFileNames,
depth,
fs
)

// Expect
expect(result).to.be.an('array').and.eql(expected).and.not.be.frozen
})
})
Loading

0 comments on commit cb96350

Please sign in to comment.