File System
File System
The File System utilities offer a way to organize and query file-system data in renoun. It is a powerful tool that allows you to define a schema for file exports and query those exports using a simple API.
To get started with the File System API, instantiate the Directory class to target a set of files and directories from the file system. You can then use the getEntry / getDirectory / getFile methods to query a specific descendant file or directory:
import { Directory } from 'renoun'
const posts = new Directory({
path: 'posts',
loader: {
mdx: (path) => import(`./posts/${path}.mdx`),
},
})
Here we are creating a new Directory instance that targets the posts directory relative to the working directory. We are also specifying a loader for the mdx file extension that will be used to load the file contents using the bundler.
Referencing protocol paths
The Directory and File constructors accept protocol-prefixed paths that resolve using internal resolvers before the adapters interact with the file system. The only supported protocol currently is workspace:, which resolves paths relative to the workspace root instead of the current working directory.
This is helpful when using renoun from a nested package (for example apps/site) but you need to reference files located in another workspace folder (like examples):
import { Directory } from 'renoun'
const examples = new Directory({
path: 'workspace:examples',
})
If the current working directory is apps/site, the example above resolves to ../../examples internally while remaining ./examples when run from the workspace root.
Querying file system entries
import { Directory } from 'renoun'
const posts = new Directory({
path: 'posts',
loader: {
mdx: (path) => import(`./posts/${path}.mdx`),
},
})
export default async function Page({ slug }: { slug: string }) {
const post = await posts.getFile(slug, 'mdx')
const Content = await post.getExportValue('default')
return <Content />
}
You can query the entries within the directory to help with generating navigations and index pages. For example, we can filter to only mdx file extensions to generate an index page of links to all posts using the getEntries method:
import { Directory, withSchema } from 'renoun'
interface PostType {
frontmatter: {
title: string
date: Date
}
}
const posts = new Directory({
path: 'posts',
filter: '*.mdx',
loader: {
mdx: withSchema<PostType>((path) => import(`./posts/${path}.mdx`)),
},
})
export default async function Page() {
const allPosts = await posts.getEntries()
return (
<>
<h1>Blog</h1>
<ul>
{allPosts.map(async (post) => {
const pathname = post.getPathname()
const frontmatter = await post.getExportValue('frontmatter')
return (
<li key={pathname}>
<a href={pathname}>{frontmatter.title}</a>
</li>
)
})}
</ul>
</>
)
}
File selection criteria
When querying files using getFile or getEntry, the file system follows a specific priority order to resolve ambiguous paths:
-
Sibling files over directories
: When both a file and a directory exist with the same base name (e.g.,
integrations.mdxandintegrations/), the sibling file is preferred over the directory. This ensures thatgetEntry('integrations')returnsintegrations.mdxrather than theintegrations/directory. -
Base files over files with modifiers
: When multiple files share the same base name but have different modifiers (e.g.,
Reference.tsxandReference.examples.tsx), the base file without a modifier is preferred. -
Extension matching
: When an extension is specified in the query (e.g.,
getFile('button', 'tsx')), only files matching that extension are considered. -
Directory representatives
: If a directory is selected, the file system looks for a representative file within that directory in this order:
-
A file with the same name as the directory (e.g.,
Button/Button.tsx) -
An
indexfile (e.g.,Button/index.tsx) -
A
readmefile (e.g.,Button/readme.md)
-
A file with the same name as the directory (e.g.,
import { Directory, MemoryFileSystem } from 'renoun'
const directory = new Directory({ path: 'posts' })
// Example: When both integrations.mdx and integrations/ exist
const entry = await directory.getEntry('integrations')
// Returns: integrations.mdx (sibling file, not the directory)
// Example: When both Reference.tsx and Reference.examples.tsx exist
const file = await directory.getFile('Reference')
// Returns: Reference.tsx (base file without modifier)
Type checking file exports
To improve type safety, you can utilize the withSchema helper to specify the schema for the file’s exports:
import { Directory, withSchema } from 'renoun'
interface PostType {
frontmatter: {
title: string
date: Date
}
}
const posts = new Directory({
path: 'posts',
loader: {
mdx: withSchema<PostType>((path) => import(`./posts/${path}.mdx`)),
},
})
Now when we call JavaScript#getExportValue and JavaScriptExport#getRuntimeValue we will have stronger type checking and autocomplete.
Working with globbed module maps
When using bundler utilities like import.meta.glob, you can return a loader map from the loader option to reuse the globbed modules:
/// <reference types="vite/client" />
import { Directory, withSchema } from 'renoun'
interface PostType {
frontmatter: {
title: string
date: Date
}
}
const posts = new Directory({
path: 'posts',
loader: () => {
const mdxModules = import.meta.glob('./posts/**/*.mdx')
return {
mdx: withSchema<PostType>((path) => mdxModules[`./posts/${path}.mdx`]),
}
},
})
The loader factory executes once and returns the extension-to-loader map, so the globbed modules are reused across all files in the directory. If the glob returns loader functions themselves, they will automatically be called and awaited for you.
Schema Validation
You can also apply schema validation using libraries that follow the Standard Schema Spec like Zod, Valibot, or Arktype to ensure file exports conform to a specific schema:
import { Directory, withSchema } from 'renoun'
import { z } from 'zod'
const posts = new Directory({
path: 'posts',
loader: {
mdx: withSchema(
{
frontmatter: z.object({
title: z.string(),
date: z.date(),
}),
},
(path) => import(`./posts/${path}.mdx`)
),
},
})
Alternatively, you can define a schema yourself using both TypeScript types and custom validation functions:
import { Directory, withSchema } from 'renoun'
interface PostType {
frontmatter: {
title: string
date: Date
}
}
const posts = new Directory({
path: 'posts',
loader: {
mdx: withSchema<PostType>(
{
frontmatter: (value) => {
if (typeof value.title !== 'string') {
throw new Error('Title is required')
}
if (!(value.date instanceof Date)) {
throw new Error('Date is required')
}
return value
},
},
(path) => import(`./posts/${path}.mdx`)
),
},
})
The file system utilities are not limited to MDX files and can be used with any file type. By organizing content and source code into structured collections, you can easily generate static pages and manage complex routing and navigations.
Using GitHostFileSystem
The GitHostFileSystem adapter lets you mirror files from a remote Git provider into memory so they can be queried just like local entries. It accepts the repository coordinates and optional filters and then streams the tarball for the requested ref.
import { Directory, GitHostFileSystem } from 'renoun'
const repoFs = new GitHostFileSystem({
repository: 'souporserious/renoun',
ref: 'main',
})
const docs = new Directory({
path: '.',
fileSystem: repoFs,
})
Avoiding rate limits
Git providers apply very small anonymous rate limits (for example, GitHub only allows 60 unauthenticated requests per hour). Passing an access token to GitHostFileSystem raises those limits dramatically and unlocks the more efficient metadata paths that renoun uses internally.
-
GitHub
– create a
classic personal access token
with the
reposcope for private repositories or no scopes for public repositories. -
GitLab
– use a
personal access token
with the
read_apiscope. - Bitbucket – supply an app password with read access.
Provide the token via the token option, ideally by reading from an environment variable so it is not committed to source control:
import { GitHostFileSystem } from 'renoun'
const repoFs = new GitHostFileSystem({
repository: 'souporserious/renoun',
token: process.env.GITHUB_TOKEN,
})
When a token is supplied, renoun batches GraphQL blame queries and reuses cached metadata to keep requests to a minimum. Without a token the file system falls back to higher-volume REST sampling, so authenticated requests are the easiest way to prevent rate limiting during development and CI.
API Reference
Constructor
new FileSystem(options)Parameters
| Parameter | Type | Default Value |
|---|---|---|
| options | FileSystemOptions | {} |
Methods
| Method | Type | Modifiers | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| getProjectOptions | () => ProjectOptions | abstract | |||||||||||||||
ReturnsProjectOptions | |||||||||||||||||
| getAbsolutePath | (path: string) => string | abstract | |||||||||||||||
Parameters
Returnsstring | |||||||||||||||||
| getRelativePathToWorkspace | (path: string) => string | abstract | |||||||||||||||
Parameters
Returnsstring | |||||||||||||||||
| getPathname | (path: PathLike, options: { basePath?: string; rootPath?: string; }) => string | — | |||||||||||||||
Parameters
Returnsstring | |||||||||||||||||
| readDirectorySync | (path?: string) => Array<…> | abstract | |||||||||||||||
Parameters
ReturnsArray<DirectoryEntry> | |||||||||||||||||
| readDirectory | (path?: string) => Promise<…> | abstract | |||||||||||||||
Parameters
ReturnsPromise<Array<DirectoryEntry>>Modifiersasync | |||||||||||||||||
| readFileSync | (path: string) => string | abstract | |||||||||||||||
Parameters
Returnsstring | |||||||||||||||||
| readFile | (path: string) => Promise<…> | abstract | |||||||||||||||
Parameters
ReturnsPromise<string>Modifiersasync | |||||||||||||||||
| readFileBinarySync | (path: string) => Uint8Array<…> | abstract | |||||||||||||||
Parameters
ReturnsUint8Array<ArrayBufferLike> | |||||||||||||||||
| readFileBinary | (path: string) => Promise<…> | abstract | |||||||||||||||
Parameters
ReturnsPromise<Uint8Array<ArrayBufferLike>>Modifiersasync | |||||||||||||||||
| readFileStream | (path: string) => FileReadableStream | abstract | |||||||||||||||
Parameters
ReturnsFileReadableStream | |||||||||||||||||
| writeFileSync | (path: string, content: FileSystemWriteFileContent) => void | abstract | |||||||||||||||
Parameters
Returnsvoid | |||||||||||||||||
| writeFile | (path: string, content: FileSystemWriteFileContent) => Promise<…> | abstract | |||||||||||||||
Parameters
ReturnsPromise<void>Modifiersasync | |||||||||||||||||
| writeFileStream | (path: string) => FileWritableStream | abstract | |||||||||||||||
Parameters
ReturnsFileWritableStream | |||||||||||||||||
| fileExistsSync | (path: string) => boolean | abstract | |||||||||||||||
Check synchronously if a file exists at the given path. Parameters
Returnsboolean | |||||||||||||||||
| fileExists | (path: string) => Promise<…> | — | |||||||||||||||
Parameters
ReturnsPromise<boolean>Modifiersasync | |||||||||||||||||
| getFileLastModifiedMsSync | (path: string) => number | undefined | abstract | |||||||||||||||
Get the last modified timestamp of a file or directory in milliseconds.
Implementations should return Parameters
Returnsnumber | undefined | |||||||||||||||||
| getFileLastModifiedMs | (path: string) => Promise<…> | — | |||||||||||||||
Parameters
ReturnsPromise<number | undefined>Modifiersasync | |||||||||||||||||
| deleteFileSync | (path: string) => void | abstract | |||||||||||||||
Parameters
Returnsvoid | |||||||||||||||||
| deleteFile | (path: string) => Promise<…> | abstract | |||||||||||||||
Parameters
ReturnsPromise<void>Modifiersasync | |||||||||||||||||
| shouldStripInternal | () => boolean | — | |||||||||||||||
Whether compilerOptions.stripInternal is enabled in the active tsconfig. Returnsboolean | |||||||||||||||||
| isFilePathExcludedFromTsConfig | (filePath: string, isDirectory: boolean) => boolean | — | |||||||||||||||
Parameters
Returnsboolean | |||||||||||||||||
| isFilePathGitIgnored | (filePath: string) => boolean | abstract | |||||||||||||||
Parameters
Returnsboolean | |||||||||||||||||
| getFileExports | (filePath: string) => Promise<…> | — | |||||||||||||||
Parameters
ReturnsPromise<Array<ModuleExport>>Modifiersasync | |||||||||||||||||
| getFileExportMetadata | (name: string, filePath: string, position: number, kind: SyntaxKind) => Promise<…> | — | |||||||||||||||
Parameters
ReturnsPromise<{ name: string; environment: string; jsDocMetadata: { description?: string; tags?: { name: string; text?: string; }[]; } | undefined; location: DeclarationLocation; }>Modifiersasync | |||||||||||||||||
| getFileExportText | (filePath: string, position: number, kind: SyntaxKind, includeDependencies?: boolean) => Promise<…> | — | |||||||||||||||
Parameters
ReturnsPromise<string>Modifiersasync | |||||||||||||||||
| getFileExportStaticValue | (filePath: string, position: number, kind: SyntaxKind) => Promise<…> | — | |||||||||||||||
Parameters
ReturnsPromise<unknown>Modifiersasync | |||||||||||||||||
| resolveTypeAtLocation | (filePath: string, position: number, kind: SyntaxKind, filter?: TypeFilter | undefined) => Promise<…> | — | |||||||||||||||
Parameters
ReturnsPromise<Kind | undefined>Modifiersasync | |||||||||||||||||
Constructor
new GitHostFileSystem(options)Parameters
| Parameter | Type | Default Value |
|---|---|---|
| options | GitHostFileSystemOptions | — |
Methods
| Method | Type | Modifiers | ||||||
|---|---|---|---|---|---|---|---|---|
| clearCache | () => void | — | ||||||
Returnsvoid | ||||||||
| getGitFileMetadata | (path: string) => Promise<…> | — | ||||||
Parameters
ReturnsPromise<GitMetadata>Modifiersasync | ||||||||
| readDirectory | (path: string) => Promise<…> | — | ||||||
Parameters
ReturnsPromise<Array<DirectoryEntry>>Modifiersasync | ||||||||
| readDirectorySync | () => Array<…> | — | ||||||
ReturnsArray<DirectoryEntry> | ||||||||
| readFile | (path: string) => Promise<…> | — | ||||||
Parameters
ReturnsPromise<string>Modifiersasync | ||||||||
| readFileBinary | (path: string) => Promise<…> | — | ||||||
Parameters
ReturnsPromise<Uint8Array<ArrayBufferLike>>Modifiersasync | ||||||||
| readFileSync | () => string | — | ||||||
Returnsstring | ||||||||
| isFilePathGitIgnored | () => boolean | — | ||||||
Returnsboolean | ||||||||
| isFilePathExcludedFromTsConfig | () => boolean | — | ||||||
Returnsboolean | ||||||||
Extends
MemoryFileSystemUtility type that infers the schema output from validator functions or a Standard Schema.
Type Parameters
| Parameter | Constraint | Default |
|---|---|---|
Exports | — | — |
Type
InferModuleExports<Exports>Overload 1
Provides type inference for the module loader.
Type Parameters
| Parameter | Constraint | Default |
|---|---|---|
Types | ModuleExports<any> | — |
Returns
ModuleLoaderWithSchema<Types, false>Overload 2
A function that resolves the module runtime.
Type Parameters
| Parameter | Constraint | Default |
|---|---|---|
Types | ModuleExports<any> | — |
Parameters
| Parameter | Type | Default Value |
|---|---|---|
| runtime | ModuleRuntimeLoader<unknown> | — |
Returns
ModuleLoaderWithSchema<Types, true>Overload 3
A schema that follows the Standard Schema Spec like Zod, Valibot, and Arktype or custom validation functions to ensure file exports conform to a specific schema.
Type Parameters
| Parameter | Constraint | Default |
|---|---|---|
Types | ModuleExports<any> | never |
Schema | ModuleExports<any> | ModuleExports<any> |
Parameters
| Parameter | Type | Default Value |
|---|---|---|
| schema | IsNever<Types> extends true ? Schema : Partial<ModuleExportValidators<NoInfer<Types>>> | — |
| runtime | ModuleRuntimeLoader<IsNever<Types> extends true ? NoInfer<Schema> : NoInfer<Types>> | — |
Returns
ModuleLoaderWithSchema<IsNever<Types> extends true ? Schema : ModuleExportValidators<NoInfer<Types>>, false>Front matter parsed from the markdown file. When using the default
loaders this is populated automatically (if present), and custom
loaders can further narrow this shape via withSchema.
Type
FrontMatterDefault module types for common file extensions.
Properties
| Property | Type | Modifiers |
|---|---|---|
| md | { default: MDXContent; frontMatter?: FrontMatter; } | — |
| mdx | { default: MDXContent; frontMatter?: FrontMatter; } | — |
| json | JSONObject | — |
Infer extension types for all loaders in a module.
Type Parameters
| Parameter | Constraint | Default |
|---|---|---|
Loaders | ModuleLoaders | — |
Index Signatures
| Key | Type | Modifiers |
|---|---|---|
key: string | InferModuleLoaderTypes<Loaders[string]> | — |
Extract keys from runtime‑capable loaders.
Type Parameters
| Parameter | Constraint | Default |
|---|---|---|
Loaders | — | — |
Type
LoadersWithRuntimeKeys<Loaders>Error for when a file is not found.
Constructor
new FileNotFoundError(path, extension?, context?)Parameters
| Parameter | Type | Default Value |
|---|---|---|
| path | string | Array<string> | — |
| extension? | any | — |
| context? | { directoryPath?: string; absoluteDirectoryPath?: string; rootPath?: string; nearestCandidates?: string[]; } | — |
Extends
ErrorType
Directory<DirectoryTypes, WithDefaultTypes<DirectoryTypes>, ModuleLoaders, DirectoryFilter<FileSystemEntry<WithDefaultTypes<DirectoryTypes>, undefined>, WithDefaultTypes<DirectoryTypes>>> | FileWithExtension<DirectoryTypes, Extension>Options for the File#getPathname and File#getPathnameSegments methods.
Properties
| Property | Type | Modifiers |
|---|---|---|
| includeBasePathname? | boolean | — |
Whether to include the configured | ||
| includeDirectoryNamedSegment? | boolean | — |
Whether to include the directory named segment in the pathname segments e.g. | ||
Options for a file in the file system.
Type Parameters
| Parameter | Constraint | Default |
|---|---|---|
Types | Record<string, any> | Record<string, any> |
Path | string | string |
Properties
| Property | Type | Modifiers |
|---|---|---|
| path | Path | URL | — |
| basePathname? | string | null | — |
| slugCasing? | SlugCasing | — |
| depth? | number | — |
| directory? | PathLike | Directory<Types, WithDefaultTypes<Types>, ModuleLoaders, DirectoryFilter<FileSystemEntry<Types, undefined>, Types>> | — |
A file in the file system.
Constructor
new File<DirectoryTypes, Path, Extension>(options)Type Parameters
| Parameter | Constraint | Default |
|---|---|---|
DirectoryTypes | Record<string, any> | Record<string, any> |
Path | string | string |
Extension | string | ExtractFileExtension<Path> |
Parameters
| Parameter | Type | Default Value |
|---|---|---|
| options | FileOptions<DirectoryTypes, Path> | — |
Methods
| Method | Type | Modifiers | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| getName | () => string | — | ||||||||||||
The intrinsic name of the file. Returnsstring | ||||||||||||||
| getBaseName | () => string | — | ||||||||||||
The base name of the file e.g. Returnsstring | ||||||||||||||
| getModifierName | () => string | undefined | — | ||||||||||||
The modifier name of the file if defined e.g. Returnsstring | undefined | ||||||||||||||
| getTitle | () => string | — | ||||||||||||
The base file name formatted as a title. Returnsstring | ||||||||||||||
| getOrder | () => string | undefined | — | ||||||||||||
The order of the file if defined. Returnsstring | undefined | ||||||||||||||
| getExtension | () => Extension | — | ||||||||||||
The extension of the file if defined. ReturnsExtension | ||||||||||||||
| getDepth | () => number | — | ||||||||||||
Get the depth of the file starting from the root directory. Returnsnumber | ||||||||||||||
| getSlug | () => string | — | ||||||||||||
Get the slug of the file. Returnsstring | ||||||||||||||
| getPathname | (options?: FilePathnameOptions | undefined) => string | — | ||||||||||||
Get the path of this file formatted for routes. The configured Parameters
Returnsstring | ||||||||||||||
| getPathnameSegments | (options?: FilePathnameOptions | undefined) => Array<…> | — | ||||||||||||
Get the route path segments for this file. Parameters
ReturnsArray<string> | ||||||||||||||
| getRelativePathToRoot | () => string | — | ||||||||||||
Get the file path relative to the root directory. Returnsstring | ||||||||||||||
| getRelativePathToWorkspace | () => string | — | ||||||||||||
Get the file path relative to the workspace root. Returnsstring | ||||||||||||||
| getAbsolutePath | () => string | — | ||||||||||||
Get the absolute file system path. Returnsstring | ||||||||||||||
| getBlameUrl | (options?: (Pick<…> & { repository?: RepositoryConfig | string | Repository; }) | undefined) => string | — | ||||||||||||
Get the URL to the file git blame for the configured git repository. Parameters
Returnsstring | ||||||||||||||
| getEditUrl | (options?: (Pick<…> & { repository?: RepositoryConfig | string | Repository; }) | undefined) => string | — | ||||||||||||
Get the edit URL to the file source for the configured git repository. Parameters
Returnsstring | ||||||||||||||
| getHistoryUrl | (options?: (Pick<…> & { repository?: RepositoryConfig | string | Repository; }) | undefined) => string | — | ||||||||||||
Get the URL to the file history for the configured git repository. Parameters
Returnsstring | ||||||||||||||
| getRawUrl | (options?: (Pick<…> & { repository?: RepositoryConfig | string | Repository; }) | undefined) => string | — | ||||||||||||
Get the URL to the raw file contents for the configured git repository. Parameters
Returnsstring | ||||||||||||||
| getSourceUrl | (options?: (Pick<…> & { repository?: RepositoryConfig | string | Repository; }) | undefined) => string | — | ||||||||||||
Get the URL to the file source for the configured git repository. Parameters
Returnsstring | ||||||||||||||
| getReleaseUrl | (options?: SourceReleaseUrlOptions | undefined) => Promise<…> | — | ||||||||||||
Get a release URL for the configured git repository. Parameters
ReturnsPromise<string>Modifiersasync | ||||||||||||||
| getRelease | (options?: SourceReleaseOptions | undefined) => Promise<…> | — | ||||||||||||
Retrieve metadata about a release for the configured git repository. Parameters
ReturnsPromise<Release>Modifiersasync | ||||||||||||||
| getEditorUri | (options?: Omit<…> | undefined) => string | — | ||||||||||||
Get the URI to the file source code for the configured editor. Parameters
Returnsstring | ||||||||||||||
| getFirstCommitDate | () => Promise<…> | — | ||||||||||||
Get the first local git commit date of the file. ReturnsPromise<Date | undefined>Modifiersasync | ||||||||||||||
| getLastCommitDate | () => Promise<…> | — | ||||||||||||
Get the last local git commit date of the file. ReturnsPromise<Date | undefined>Modifiersasync | ||||||||||||||
| getAuthors | () => Promise<…> | — | ||||||||||||
Get the local git authors of the file. ReturnsPromise<Array<GitAuthor>>Modifiersasync | ||||||||||||||
| getParent | () => Directory<…> | — | ||||||||||||
Get the parent directory containing this file. ReturnsDirectory<DirectoryTypes, WithDefaultTypes<DirectoryTypes>, ModuleLoaders, DirectoryFilter<FileSystemEntry<WithDefaultTypes<DirectoryTypes>, undefined>, WithDefaultTypes<DirectoryTypes>>> | ||||||||||||||
| getSiblings | <GroupTypes>(options?: { collection?: Collection<…>; includeDirectoryNamedSegment?: boolean; }) => Promise<…> | — | ||||||||||||
Get the previous and next sibling entries (files or directories) of the parent directory. If the file is an index or readme file, the siblings will be retrieved from the parent directory. Type Parameters
Parameters
ReturnsPromise<[FileSystemEntry<DirectoryTypes, undefined> | undefined, FileSystemEntry<DirectoryTypes, undefined> | undefined]>Modifiersasync | ||||||||||||||
| getText | () => Promise<…> | — | ||||||||||||
Get the source text of this file. ReturnsPromise<string>Modifiersasync | ||||||||||||||
| getBinary | () => Promise<…> | — | ||||||||||||
Get the binary contents of this file. ReturnsPromise<Uint8Array<ArrayBufferLike>>Modifiersasync | ||||||||||||||
| getArrayBuffer | () => Promise<…> | — | ||||||||||||
Get the contents of this file as an ArrayBuffer. ReturnsPromise<ArrayBuffer>Modifiersasync | ||||||||||||||
| getStream | () => FileReadableStream | — | ||||||||||||
Get a readable stream for this file. ReturnsFileReadableStream | ||||||||||||||
| write | (content: FileSystemWriteFileContent) => Promise<…> | — | ||||||||||||
Write content to this file. Parameters
ReturnsPromise<void>Modifiersasync | ||||||||||||||
| writeStream | () => FileWritableStream | — | ||||||||||||
Create a writable stream for this file. ReturnsFileWritableStream | ||||||||||||||
| delete | () => Promise<…> | — | ||||||||||||
Delete this file from the file system. ReturnsPromise<void>Modifiersasync | ||||||||||||||
| exists | () => Promise<…> | — | ||||||||||||
Check if this file exists in the file system. ReturnsPromise<boolean>Modifiersasync | ||||||||||||||
Type
string | number | boolean | nullType
JSONPrimitive | Array<JSONValue> | JSONObjectIndex Signatures
| Key | Type | Modifiers |
|---|---|---|
Key: string | JSONValue | — |
Type Parameters
| Parameter | Constraint | Default |
|---|---|---|
Data | Record<string, any> | JSONObject |
DirectoryTypes | Record<string, any> | Record<string, any> |
Path | string | string |
Properties
| Property | Type | Modifiers |
|---|---|---|
| schema? | StandardSchemaV1<Data, Data> | (value: unknown) => Data | — |
Type Parameters
| Parameter | Constraint | Default |
|---|---|---|
Data | — | — |
Path | string | — |
Type
JSONPathValue<Data, Path>Type
JSONPropertyPath<Data>A JSON file in the file system.
Constructor
new JSONFile<Data, DirectoryTypes, Path, Extension>(fileOptions)Type Parameters
| Parameter | Constraint | Default |
|---|---|---|
Data | Record<string, any> | JSONObject |
DirectoryTypes | Record<string, any> | Record<string, any> |
Path | string | string |
Extension | string | ExtractFileExtension<Path> |
Parameters
| Parameter | Type | Default Value |
|---|---|---|
| fileOptions | JSONFileOptions<Data, DirectoryTypes, Path> | — |
Methods
| Method | Type | Modifiers | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| get | () => Promise<…> (+1 overload) | — | ||||||||||||
Overload 1Get a value from the JSON data using dot notation. Returns ReturnsPromise<Data>ModifiersasyncOverload 2Type Parameters
Parameters
ReturnsPromise<JSONPathValueWithSegments<Data, JSONPathSegments<Path>>>Modifiersasync | ||||||||||||||
Extends
File<DirectoryTypes, Path, Extension>Error for when a module export cannot be found.
Constructor
new ModuleExportNotFoundError(path, name, className)Parameters
| Parameter | Type | Default Value |
|---|---|---|
| path | string | — |
| name | string | — |
| className | string | — |
Extends
ErrorA JavaScript file export.
Constructor
new JavaScriptModuleExport<Value>(name, file, loader?, slugCasing?)Type Parameters
| Parameter | Constraint | Default |
|---|---|---|
Value | — | — |
Parameters
| Parameter | Type | Default Value |
|---|---|---|
| name | string | — |
| file | JavaScriptFile<any, Record<string, any>, string, string> | — |
| loader? | ModuleLoader<any> | undefined | — |
| slugCasing? | SlugCasing | undefined | — |
Methods
| Method | Type | Modifiers | |||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| init | <Value>(name: string, file: JavaScriptFile<…>, loader?: ModuleLoader<…> | undefined, slugCasing?: SlugCasing | undefined) => Promise<…> | static | |||||||||||||||||||||
Type Parameters
Parameters
ReturnsPromise<JavaScriptModuleExport<Value>>Modifiersasync | |||||||||||||||||||||||
| getStaticMetadata | () => Promise<…> | protected | |||||||||||||||||||||
ReturnsPromise<{ name: string; environment: string; jsDocMetadata: { description?: string; tags?: { name: string; text?: string; }[]; } | undefined; location: DeclarationLocation; } | undefined>Modifiersasync | |||||||||||||||||||||||
| getSlug | () => string | — | |||||||||||||||||||||
Get the slug of the file export. Returnsstring | |||||||||||||||||||||||
| getName | () => string | — | |||||||||||||||||||||
Get the name of the export. Default exports will use the file name or declaration name if available. Returnsstring | |||||||||||||||||||||||
| getTitle | () => string | — | |||||||||||||||||||||
The export name formatted as a title. Returnsstring | |||||||||||||||||||||||
| getDescription | () => undefined | string | — | |||||||||||||||||||||
Get the JS Doc description of the export. Returnsundefined | string | |||||||||||||||||||||||
| getTags | () => undefined | Array<…> | — | |||||||||||||||||||||
Get the JS Doc tags of the export. Returnsundefined | Array<{ name: string; text?: string; }> | |||||||||||||||||||||||
| getEnvironment | () => undefined | string | — | |||||||||||||||||||||
Get the environment of the export. Returnsundefined | string | |||||||||||||||||||||||
| getText | ({
includeDependencies,
}: { includeDependencies?: boolean; }) => Promise<…> | — | |||||||||||||||||||||
Get the source text of the export, optionally including dependencies. Note, including dependencies can be expensive to calculate, only use when necessary. Parameters
ReturnsPromise<string>Modifiersasync | |||||||||||||||||||||||
| getPosition | () => undefined | DeclarationPosition | — | |||||||||||||||||||||
Get the start and end position of the export in the file system. Returnsundefined | DeclarationPosition | |||||||||||||||||||||||
| getEditUrl | (options?: (Pick<…> & { repository?: RepositoryConfig | string | Repository; }) | undefined) => string | — | |||||||||||||||||||||
Get the edit URL to the file export source for the configured git repository. Parameters
Returnsstring | |||||||||||||||||||||||
| getSourceUrl | (options?: (Pick<…> & { repository?: RepositoryConfig | string | Repository; }) | undefined) => string | — | |||||||||||||||||||||
Get the URL to the file export source for the configured git repository. Parameters
Returnsstring | |||||||||||||||||||||||
| getReleaseUrl | (options?: SourceReleaseUrlOptions | undefined) => Promise<…> | — | |||||||||||||||||||||
Parameters
ReturnsPromise<string>Modifiersasync | |||||||||||||||||||||||
| getRelease | (options?: SourceReleaseOptions | undefined) => Promise<…> | — | |||||||||||||||||||||
Parameters
ReturnsPromise<Release>Modifiersasync | |||||||||||||||||||||||
| getEditorUri | (options?: Omit<…> | undefined) => string | — | |||||||||||||||||||||
Get the URI to the file export source code for the configured editor. Parameters
Returnsstring | |||||||||||||||||||||||
| getType | (filter?: TypeFilter | undefined) => Promise<…> | — | |||||||||||||||||||||
Get the resolved type of the export. Parameters
ReturnsPromise<Kind | undefined>Modifiersasync | |||||||||||||||||||||||
| getStaticValue | () => Promise<…> | — | |||||||||||||||||||||
Attempt to return a literal value for this export if it can be determined statically. ReturnsPromise<Value>Modifiersasync | |||||||||||||||||||||||
| getRuntimeValue | () => Promise<…> | — | |||||||||||||||||||||
Get the runtime value of the export. An error will be thrown if the export is not found or the configured schema validation for this file extension fails. ReturnsPromise<Value>Modifiersasync | |||||||||||||||||||||||
| getValue | () => Promise<…> | — | |||||||||||||||||||||
Get the value of this export, preferring a static value and falling back to runtime if available. ReturnsPromise<Value>Modifiersasync | |||||||||||||||||||||||
Options for a JavaScript file in the file system.
Type Parameters
| Parameter | Constraint | Default |
|---|---|---|
Types | Record<string, any> | — |
DirectoryTypes | Record<string, any> | — |
Path | string | — |
Properties
| Property | Type | Modifiers |
|---|---|---|
| loader? | ModuleLoader<Types> | — |
A JavaScript file in the file system.
Constructor
new JavaScriptFile<Types, DirectoryTypes, Path, Extension>({
loader,
...fileOptions
})Type Parameters
| Parameter | Constraint | Default |
|---|---|---|
Types | InferDefaultModuleTypes<Path> | — |
DirectoryTypes | Record<string, any> | Record<string, any> |
Path | string | string |
Extension | string | ExtractFileExtension<Path> |
Parameters
| Parameter | Type | Default Value |
|---|---|---|
| { loader, ...fileOptions } | JavaScriptFileOptions<Types, DirectoryTypes, Path> | — |
Methods
| Method | Type | Modifiers | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| parseExportValue | (name: string, value: any) => any | — | ||||||||||||
Parse and validate an export value using the configured schema if available. Parameters
Returnsany | ||||||||||||||
| getExports | () => Promise<…> | — | ||||||||||||
Get all exports from the JavaScript file. ReturnsPromise<Array<JavaScriptModuleExport<Types[Extract<keyof Types, string>]>>>Modifiersasync | ||||||||||||||
| getExport | <ExportName>(name: ExportName) => Promise<…> | — | ||||||||||||
Get a JavaScript file export by name. Type Parameters
Parameters
ReturnsPromise<JavaScriptModuleExport<Types[ExportName]>>Modifiersasync | ||||||||||||||
| getNamedExport | <ExportName>(name: ExportName) => Promise<…> | — | ||||||||||||
Get a named export from the JavaScript file. Type Parameters
Parameters
ReturnsPromise<JavaScriptModuleExport<Types[ExportName]>>Modifiersasync | ||||||||||||||
| getDefaultExport | (this: Types extends { default: infer _DefaultType; } ? JavaScriptFile<…> : never) => Promise<…> | — | ||||||||||||
Get the default export from the JavaScript file. This TypeTypes extends { default: infer _DefaultType; } ? JavaScriptFile<Types, DirectoryTypes, Path, Extension> : neverReturnsPromise<JavaScriptModuleExport<Types extends { default: infer DefaultType; } ? DefaultType : never>>Modifiersasync | ||||||||||||||
| getExportLocation | (name: string) => Promise<…> | — | ||||||||||||
Get the start position of an export in the JavaScript file. Parameters
ReturnsPromise<ModuleExport | undefined>Modifiersasync | ||||||||||||||
| getExportValue | <ExportName>(name: ExportName) => Promise<…> | — | ||||||||||||
Get the runtime value of an export in the JavaScript file. Type Parameters
Parameters
ReturnsPromise<Types[ExportName]>Modifiersasync | ||||||||||||||
| getHeadings | () => Promise<…> | — | ||||||||||||
Get headings derived from the file exports. ReturnsPromise<Headings>Modifiersasync | ||||||||||||||
| hasExport | (name: string) => Promise<…> | — | ||||||||||||
Check if an export exists in the JavaScript file statically or at runtime. Parameters
ReturnsPromise<boolean>Modifiersasync | ||||||||||||||
Extends
File<DirectoryTypes, Path, Extension>An MDX file export.
Constructor
new MDXModuleExport<Value>(name, file, loader?, slugCasing?)Type Parameters
| Parameter | Constraint | Default |
|---|---|---|
Value | — | — |
Parameters
| Parameter | Type | Default Value |
|---|---|---|
| name | string | — |
| file | MDXFile<any, Record<string, any>, string, string> | — |
| loader? | ModuleLoader<any> | undefined | — |
| slugCasing? | SlugCasing | undefined | — |
Methods
| Method | Type | Modifiers | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| getName | () => string | — | |||||||||
Returnsstring | |||||||||||
| getTitle | () => string | — | |||||||||
Returnsstring | |||||||||||
| getSlug | () => string | — | |||||||||
Returnsstring | |||||||||||
| getEditorUri | (options?: Omit<…> | undefined) => string | — | |||||||||
Parameters
Returnsstring | |||||||||||
| getEditUrl | (options?: (Pick<…> & { repository?: RepositoryConfig | string | Repository; }) | undefined) => string | — | |||||||||
Parameters
Returnsstring | |||||||||||
| getSourceUrl | (options?: (Pick<…> & { repository?: RepositoryConfig | string | Repository; }) | undefined) => string | — | |||||||||
Parameters
Returnsstring | |||||||||||
| getReleaseUrl | (options?: SourceReleaseUrlOptions | undefined) => Promise<…> | — | |||||||||
Parameters
ReturnsPromise<string>Modifiersasync | |||||||||||
| getRelease | (options?: SourceReleaseOptions | undefined) => Promise<…> | — | |||||||||
Parameters
ReturnsPromise<Release>Modifiersasync | |||||||||||
| parseExportValue | (name: string, value: any) => any | — | |||||||||
Parse and validate an export value using the configured schema if available. Parameters
Returnsany | |||||||||||
| getStaticValue | () => Promise<…> | — | |||||||||
Attempt to return a literal value for this export if it can be determined statically. ReturnsPromise<Value>Modifiersasync | |||||||||||
| getRuntimeValue | () => Promise<…> | — | |||||||||
Get the runtime value of the export. An error will be thrown if the export is not found or the configured schema validation for the MDX file fails. ReturnsPromise<Value>Modifiersasync | |||||||||||
| getValue | () => Promise<…> | — | |||||||||
Get the value of this export, preferring a static value and falling back to runtime if available. ReturnsPromise<Value>Modifiersasync | |||||||||||
Options for an MDX file in the file system.
Type Parameters
| Parameter | Constraint | Default |
|---|---|---|
Types | Record<string, any> | — |
DirectoryTypes | Record<string, any> | — |
Path | string | — |
Properties
| Property | Type | Modifiers |
|---|---|---|
| loader? | ModuleLoader<{ default: MDXContent; } & Types> | — |
An MDX file in the file system.
Constructor
new MDXFile<Types, DirectoryTypes, Path, Extension>({
loader,
...fileOptions
})Type Parameters
| Parameter | Constraint | Default |
|---|---|---|
Types | Record<string, any> | { default: MDXContent; } |
DirectoryTypes | Record<string, any> | Record<string, any> |
Path | string | string |
Extension | string | ExtractFileExtension<Path> |
Parameters
| Parameter | Type | Default Value |
|---|---|---|
| { loader, ...fileOptions } | MDXFileOptions<{ default: MDXContent; } & Types, DirectoryTypes, Path> | — |
Methods
| Method | Type | Modifiers | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| getText | () => Promise<…> | — | ||||||||||||
ReturnsPromise<string>Modifiersasync | ||||||||||||||
| getFrontMatter | () => Promise<…> | — | ||||||||||||
ReturnsPromise<Record<string, unknown> | undefined>Modifiersasync | ||||||||||||||
| getChatGPTUrl | () => Promise<…> | — | ||||||||||||
ReturnsPromise<string>Modifiersasync | ||||||||||||||
| getClaudeUrl | () => Promise<…> | — | ||||||||||||
ReturnsPromise<string>Modifiersasync | ||||||||||||||
| getExports | () => Promise<…> | — | ||||||||||||
ReturnsPromise<Array<MDXModuleExport<any>>>Modifiersasync | ||||||||||||||
| getExport | <ExportName>(name: ExportName) => Promise<…> | — | ||||||||||||
Type Parameters
Parameters
ReturnsPromise<MDXModuleExport<({ default: MDXContent; } & Types)[ExportName]>>Modifiersasync | ||||||||||||||
| getNamedExport | <ExportName>(name: ExportName) => Promise<…> | — | ||||||||||||
Get a named export from the MDX file. Type Parameters
Parameters
ReturnsPromise<MDXModuleExport<Types[ExportName]>>Modifiersasync | ||||||||||||||
| getDefaultExport | () => Promise<…> | — | ||||||||||||
Get the default export from the MDX file. ReturnsPromise<MDXContent>Modifiersasync | ||||||||||||||
| getContent | () => Promise<…> | — | ||||||||||||
Get the rendered MDX content. ReturnsPromise<MDXContent>Modifiersasync | ||||||||||||||
| getHeadings | () => Promise<…> | — | ||||||||||||
Get headings parsed from the MDX content. ReturnsPromise<Headings>Modifiersasync | ||||||||||||||
| hasExport | (name: string) => Promise<…> | — | ||||||||||||
Check if an export exists at runtime in the MDX file. Parameters
ReturnsPromise<boolean>Modifiersasync | ||||||||||||||
| getExportValue | <ExportName>(name: ExportName) => Promise<…> | — | ||||||||||||
Get the runtime value of an export in the MDX file. Type Parameters
Parameters
ReturnsPromise<({ default: MDXContent; } & Types)[ExportName]>Modifiersasync | ||||||||||||||
| getStaticExportValue | (name: string) => Promise<…> | — | ||||||||||||
Attempt to return a literal value for a named export if it can be determined statically. Parameters
ReturnsPromise<unknown>Modifiersasync | ||||||||||||||
Extends
File<DirectoryTypes, Path, Extension>Options for a Markdown file in the file system.
Type Parameters
| Parameter | Constraint | Default |
|---|---|---|
Types | Record<string, any> | — |
DirectoryTypes | Record<string, any> | — |
Path | string | — |
Properties
| Property | Type | Modifiers |
|---|---|---|
| loader? | ModuleLoader<{ default: MDXContent; } & Types> | — |
A Markdown file in the file system.
Constructor
new MarkdownFile<Types, DirectoryTypes, Path, Extension>({
loader,
...fileOptions
})Type Parameters
| Parameter | Constraint | Default |
|---|---|---|
Types | Record<string, any> | { default: MDXContent; } |
DirectoryTypes | Record<string, any> | Record<string, any> |
Path | string | string |
Extension | string | ExtractFileExtension<Path> |
Parameters
| Parameter | Type | Default Value |
|---|---|---|
| { loader, ...fileOptions } | MarkdownFileOptions<{ default: MDXContent; } & Types, DirectoryTypes, Path> | — |
Methods
| Method | Type | Modifiers | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| getText | () => Promise<…> | — | ||||||||||||
ReturnsPromise<string>Modifiersasync | ||||||||||||||
| getFrontMatter | () => Promise<…> | — | ||||||||||||
ReturnsPromise<Record<string, unknown> | undefined>Modifiersasync | ||||||||||||||
| getChatGPTUrl | () => Promise<…> | — | ||||||||||||
ReturnsPromise<string>Modifiersasync | ||||||||||||||
| getClaudeUrl | () => Promise<…> | — | ||||||||||||
ReturnsPromise<string>Modifiersasync | ||||||||||||||
| getContent | () => Promise<…> | — | ||||||||||||
Get the rendered markdown content. ReturnsPromise<MDXContent>Modifiersasync | ||||||||||||||
| getHeadings | () => Promise<…> | — | ||||||||||||
Get headings parsed from the markdown content. ReturnsPromise<Headings>Modifiersasync | ||||||||||||||
| getExportValue | <ExportName>(name: ExportName) => Promise<…> | — | ||||||||||||
Get the runtime value of an export in the Markdown file. (Permissive signature for union compatibility.) Type Parameters
Parameters
ReturnsPromise<({ default: MDXContent; } & Types)[ExportName]>Modifiersasync | ||||||||||||||
Extends
File<DirectoryTypes, Path, Extension>Type
(entry: FileSystemEntry<Types>) => entry is Entry | (entry: FileSystemEntry<Types>) => Promise<boolean> | boolean | stringType Parameters
| Parameter | Constraint | Default |
|---|---|---|
Types | InferModuleLoadersTypes<Loaders> | any |
LoaderTypes | Types | any |
Loaders | ModuleLoaders | ModuleLoaders |
Filter | DirectoryFilter<FileSystemEntry<LoaderTypes, undefined>, LoaderTypes> | DirectoryFilter<FileSystemEntry<LoaderTypes, undefined>, LoaderTypes> |
Properties
| Property | Type | Modifiers |
|---|---|---|
| path? | PathLike | — |
Directory path in the workspace. | ||
| filter? | Filter | — |
Filter entries with a minimatch pattern or predicate. | ||
| loader? | Loaders | () => Loaders | — |
Extension loaders with or without | ||
| basePathname? | string | null | — |
Base route prepended to descendant | ||
| tsConfigPath? | string | — |
Uses the closest | ||
| slugCasing? | SlugCasing | — |
Slug casing applied to route segments. | ||
| fileSystem? | FileSystem | — |
Custom file‑system adapter. | ||
| sort? | SortDescriptor<ResolveDirectoryFilterEntries<Filter, LoaderTypes>> | — |
Sort callback applied at each directory depth. | ||
| repository? | Repository | RepositoryConfig | string | — |
The repository used to generate source URLs. | ||
A directory containing files and subdirectories in the file system.
Constructor
new Directory<Types, LoaderTypes, Loaders, Filter>(options?)Type Parameters
| Parameter | Constraint | Default |
|---|---|---|
Types | InferModuleLoadersTypes<Loaders> | — |
LoaderTypes | WithDefaultTypes<Types> | WithDefaultTypes<Types> |
Loaders | ModuleLoaders | ModuleLoaders |
Filter | DirectoryFilter<FileSystemEntry<LoaderTypes, undefined>, LoaderTypes> | DirectoryFilter<FileSystemEntry<LoaderTypes, undefined>, LoaderTypes> |
Parameters
| Parameter | Type | Default Value |
|---|---|---|
| options? | DirectoryOptions<Types, LoaderTypes, Loaders, Filter> | — |
Methods
| Method | Type | Modifiers | |||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| getFilterPatternKind | () => "recursive" | "shallow" | null | — | |||||||||||||||||||||||||||||||||
Returns the glob filter pattern kind for this directory if defined. Returns"recursive" | "shallow" | null | |||||||||||||||||||||||||||||||||||
| getFileSystem | () => FileSystem | — | |||||||||||||||||||||||||||||||||
Get the file system for this directory. ReturnsFileSystem | |||||||||||||||||||||||||||||||||||
| getRepository | (repository?: RepositoryConfig | string | Repository) => Repository | — | |||||||||||||||||||||||||||||||||
Get the Parameters
ReturnsRepository | |||||||||||||||||||||||||||||||||||
| getDepth | () => number | — | |||||||||||||||||||||||||||||||||
Get the depth of the directory starting from the root directory. Returnsnumber | |||||||||||||||||||||||||||||||||||
| getFile | <Path, Extension>(path: Path) => Promise<…> (+1 overload) | — | |||||||||||||||||||||||||||||||||
Overload 1Get a file at the specified If the file is not found, an error will be thrown. Use Type Parameters
Parameters
ReturnsPromise<Extension extends string ? IsJavaScriptLikeExtension<Extension> extends true ? JavaScriptFile<LoaderTypes[Extension], LoaderTypes, string, Extension> : Extension extends "mdx" ? MDXFile<LoaderTypes["mdx"], LoaderTypes, string, Extension> : Extension extends "md" ? MarkdownFile<LoaderTypes["md"], LoaderTypes, string, Extension> : Extension extends "json" ? JSONFile<JSONExtensionType<LoaderTypes>, LoaderTypes, string, Extension> : File<LoaderTypes, Path, Extension> : File<LoaderTypes, string, string>>ModifiersasyncOverload 2Type Parameters
Parameters
ReturnsPromise<Extension extends string ? IsJavaScriptLikeExtension<Extension> extends true ? JavaScriptFile<LoaderTypes[Extension], LoaderTypes, string, Extension> : Extension extends "mdx" ? MDXFile<LoaderTypes["mdx"], LoaderTypes, string, Extension> : Extension extends "md" ? MarkdownFile<LoaderTypes["md"], LoaderTypes, string, Extension> : Extension extends "json" ? JSONFile<JSONExtensionType<LoaderTypes>, LoaderTypes, string, Extension> : File<LoaderTypes, Extension, ExtractFileExtension<Extension>> : File<LoaderTypes, string, string>>Modifiersasync | |||||||||||||||||||||||||||||||||||
| getDirectory | (path: string | Array<…>) => Promise<…> | — | |||||||||||||||||||||||||||||||||
Get a directory at the specified Parameters
ReturnsPromise<Directory<LoaderTypes, WithDefaultTypes<LoaderTypes>, ModuleLoaders, DirectoryFilter<FileSystemEntry<WithDefaultTypes<LoaderTypes>, undefined>, WithDefaultTypes<LoaderTypes>>>>Modifiersasync | |||||||||||||||||||||||||||||||||||
| getEntry | (path: string | Array<…>) => Promise<…> | — | |||||||||||||||||||||||||||||||||
Get a directory or file at the specified
Parameters
ReturnsPromise<FileSystemEntry<LoaderTypes, undefined>>Modifiersasync | |||||||||||||||||||||||||||||||||||
| invalidateSnapshots | () => void | — | |||||||||||||||||||||||||||||||||
Returnsvoid | |||||||||||||||||||||||||||||||||||
| getEntries | (options?: { recursive?: Filter extends string ? Filter extends `**${string}` ? boolean : undefined : boolean; includeDirectoryNamedFiles?: boolean; includeIndexAndReadmeFiles?: boolean; includeGitIgnoredFiles?: boolean; includeTsConfigExcludedFiles?: boolean; }) => Promise<…> | — | |||||||||||||||||||||||||||||||||
Retrieves all entries (files and directories) within the current directory
that are not excluded by Git ignore rules or the closest Parameters
ReturnsPromise<Array<Filter extends string ? Filter extends `**${string}` ? Directory<LoaderTypes, WithDefaultTypes<LoaderTypes>, ModuleLoaders, DirectoryFilter<FileSystemEntry<WithDefaultTypes<LoaderTypes>, undefined>, WithDefaultTypes<LoaderTypes>>> | FileWithExtension<LoaderTypes, ExtractFileExtension<Filter>> : FileWithExtension<LoaderTypes, ExtractFileExtension<Filter>> : Filter extends DirectoryFilter<infer FilteredEntry extends FileSystemEntry<any, undefined>, LoaderTypes> ? FilteredEntry : FileSystemEntry<LoaderTypes, undefined>>>Modifiersasync | |||||||||||||||||||||||||||||||||||
| getRootPath | () => string | — | |||||||||||||||||||||||||||||||||
Get the root directory path. Returnsstring | |||||||||||||||||||||||||||||||||||
| getParent | () => Directory<…> | — | |||||||||||||||||||||||||||||||||
Get the parent directory containing this directory. ReturnsDirectory<any, any, any, DirectoryFilter<FileSystemEntry<any, undefined>, any>> | |||||||||||||||||||||||||||||||||||
| getSiblings | <GroupTypes>(options?: { collection?: Collection<…>; }) => Promise<…> | — | |||||||||||||||||||||||||||||||||
Get the previous and next sibling entries (files or directories) of the parent directory. Type Parameters
Parameters
ReturnsPromise<[FileSystemEntry<LoaderTypes, undefined> | undefined, FileSystemEntry<LoaderTypes, undefined> | undefined]>Modifiersasync | |||||||||||||||||||||||||||||||||||
| getSlug | () => string | — | |||||||||||||||||||||||||||||||||
Get the slug of this directory. Returnsstring | |||||||||||||||||||||||||||||||||||
| getName | () => string | — | |||||||||||||||||||||||||||||||||
Get the base name of this directory. Returnsstring | |||||||||||||||||||||||||||||||||||
| getBaseName | () => string | — | |||||||||||||||||||||||||||||||||
Get the base name of this directory. Returnsstring | |||||||||||||||||||||||||||||||||||
| getTitle | () => string | — | |||||||||||||||||||||||||||||||||
The directory name formatted as a title. Returnsstring | |||||||||||||||||||||||||||||||||||
| getPathname | (options?: { includeBasePathname?: boolean; }) => string | — | |||||||||||||||||||||||||||||||||
Get a URL-friendly path to this directory. Parameters
Returnsstring | |||||||||||||||||||||||||||||||||||
| getPathnameSegments | (options?: { includeBasePathname?: boolean; }) => Array<…> | — | |||||||||||||||||||||||||||||||||
Get the route path segments to this directory. Parameters
ReturnsArray<string> | |||||||||||||||||||||||||||||||||||
| getRelativePathToRoot | () => string | — | |||||||||||||||||||||||||||||||||
Get the relative path of this directory to the root directory. Returnsstring | |||||||||||||||||||||||||||||||||||
| getRelativePathToWorkspace | () => string | — | |||||||||||||||||||||||||||||||||
Get the relative path of the directory to the workspace. Returnsstring | |||||||||||||||||||||||||||||||||||
| getAbsolutePath | () => string | — | |||||||||||||||||||||||||||||||||
Get the absolute path of this directory. Returnsstring | |||||||||||||||||||||||||||||||||||
| getHistoryUrl | (options?: (Pick<…> & { repository?: RepositoryConfig | string | Repository; }) | undefined) => string | — | |||||||||||||||||||||||||||||||||
Get the URL to the directory history for the configured git repository. Parameters
Returnsstring | |||||||||||||||||||||||||||||||||||
| getSourceUrl | (options?: (Pick<…> & { repository?: RepositoryConfig | string | Repository; }) | undefined) => string | — | |||||||||||||||||||||||||||||||||
Get the URL to the directory source for the configured git repository. Parameters
Returnsstring | |||||||||||||||||||||||||||||||||||
| getReleaseUrl | (options?: SourceReleaseUrlOptions | undefined) => Promise<…> | — | |||||||||||||||||||||||||||||||||
Get a release URL for the configured git repository. Parameters
ReturnsPromise<string>Modifiersasync | |||||||||||||||||||||||||||||||||||
| getRelease | (options?: SourceReleaseOptions | undefined) => Promise<…> | — | |||||||||||||||||||||||||||||||||
Retrieve metadata about a release for the configured git repository. Parameters
ReturnsPromise<Release>Modifiersasync | |||||||||||||||||||||||||||||||||||
| getEditorUri | (options?: Pick<…> | undefined) => string | — | |||||||||||||||||||||||||||||||||
Get the URI to the directory source code for the configured editor. Parameters
Returnsstring | |||||||||||||||||||||||||||||||||||
| getFirstCommitDate | () => Promise<…> | — | |||||||||||||||||||||||||||||||||
Get the first local git commit date of this directory. ReturnsPromise<Date | undefined>Modifiersasync | |||||||||||||||||||||||||||||||||||
| getLastCommitDate | () => Promise<…> | — | |||||||||||||||||||||||||||||||||
Get the last local git commit date of this directory. ReturnsPromise<Date | undefined>Modifiersasync | |||||||||||||||||||||||||||||||||||
| getAuthors | () => Promise<…> | — | |||||||||||||||||||||||||||||||||
Get the local git authors of this directory. ReturnsPromise<Array<GitAuthor>>Modifiersasync | |||||||||||||||||||||||||||||||||||
| hasEntry | (entry: FileSystemEntry<…> | undefined) => boolean | — | |||||||||||||||||||||||||||||||||
Checks if this directory contains the provided entry. Parameters
Returnsboolean | |||||||||||||||||||||||||||||||||||
| hasFile | <ExtensionType, Extension>(entry: FileSystemEntry<…> | undefined, extension?: Extension | Array<…>) => boolean | — | |||||||||||||||||||||||||||||||||
Checks if this directory contains the provided file. Type Parameters
Parameters
Returnsboolean | |||||||||||||||||||||||||||||||||||
Options for a Collection.
Type Parameters
| Parameter | Constraint | Default |
|---|---|---|
Entries | Array<FileSystemEntry<any, undefined>> | — |
Properties
| Property | Type | Modifiers |
|---|---|---|
| entries | Entries | — |
A group of file system entries.
Constructor
new Collection<Types, Entries, Loaders>(options)Type Parameters
| Parameter | Constraint | Default |
|---|---|---|
Types | InferModuleLoadersTypes<Loaders> | — |
Entries | Array<FileSystemEntry<any, undefined>> | Array<FileSystemEntry<any, undefined>> |
Loaders | ModuleLoaders | {} | ModuleLoaders |
Parameters
| Parameter | Type | Default Value |
|---|---|---|
| options | CollectionOptions<Entries> | — |
Methods
| Method | Type | Modifiers | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| getEntries | (options?: { recursive?: boolean; includeIndexAndReadmeFiles?: boolean; }) => Promise<…> | — | |||||||||||||||
Get all entries in the group. Parameters
ReturnsPromise<Entries>Modifiersasync | |||||||||||||||||
| getEntry | (path: string | Array<…>) => Promise<…> | — | |||||||||||||||
Get an entry in the group by its path. Parameters
ReturnsPromise<FileSystemEntry<Types, undefined>>Modifiersasync | |||||||||||||||||
| getFile | <Extension>(path: string | Array<…>, extension?: Extension | Array<…>) => Promise<…> | — | |||||||||||||||
Get a file at the specified path and optional extension(s). Type Parameters
Parameters
ReturnsPromise<Extension extends string ? IsJavaScriptLikeExtension<Extension> extends true ? JavaScriptFile<Types[Extension], Record<string, any>, string, string> : Extension extends "mdx" ? MDXFile<Types["mdx"], Record<string, any>, string, string> : Extension extends "md" ? MarkdownFile<Types["md"], Record<string, any>, string, string> : File<Types, string, string> : File<Types, string, string>>Modifiersasync | |||||||||||||||||
| getDirectory | (path: string | Array<…>) => Promise<…> | — | |||||||||||||||
Get a directory at the specified path. Parameters
ReturnsPromise<Directory<Types, WithDefaultTypes<Types>, ModuleLoaders, DirectoryFilter<FileSystemEntry<WithDefaultTypes<Types>, undefined>, WithDefaultTypes<Types>>>>Modifiersasync | |||||||||||||||||
Determines if a FileSystemEntry is a Directory.
Type Parameters
| Parameter | Constraint | Default |
|---|---|---|
Types | Record<string, any> | — |
Parameters
| Parameter | Type | Default Value |
|---|---|---|
| entry | FileSystemEntry<Types, undefined> | Collection<Types, Array<FileSystemEntry<any, undefined>>, {}> | undefined | — |
Returns
booleanType
FileWithExtension<Types, Extension>Type
ExtensionUnion | Array<ExtensionUnion>Determines if a FileSystemEntry is a File and optionally narrows the
result based on the provided extensions.
Type Parameters
| Parameter | Constraint | Default |
|---|---|---|
Types | Record<string, any> | — |
Extension | LoadersToExtensions<Types, StringUnion<keyof Types>> | — |
Parameters
| Parameter | Type | Default Value |
|---|---|---|
| entry | FileSystemEntry<Types, undefined> | undefined | — |
| extension? | Extension | — |
Returns
booleanDetermines if a FileSystemEntry is a JavaScriptFile.
Type Parameters
| Parameter | Constraint | Default |
|---|---|---|
FileTypes | Record<string, any> | — |
DirectoryTypes | Record<string, any> | Record<string, any> |
Parameters
| Parameter | Type | Default Value |
|---|---|---|
| entry | FileSystemEntry<DirectoryTypes, undefined> | undefined | — |
Returns
booleanDetermines if a FileSystemEntry is a MarkdownFile.
Type Parameters
| Parameter | Constraint | Default |
|---|---|---|
FileTypes | Record<string, any> | — |
DirectoryTypes | Record<string, any> | Record<string, any> |
Parameters
| Parameter | Type | Default Value |
|---|---|---|
| entry | FileSystemEntry<DirectoryTypes, undefined> | undefined | — |
Returns
booleanDetermines if a FileSystemEntry is a JSONFile.
Type Parameters
| Parameter | Constraint | Default |
|---|---|---|
FileTypes | Record<string, any> | — |
DirectoryTypes | Record<string, any> | Record<string, any> |
Parameters
| Parameter | Type | Default Value |
|---|---|---|
| entry | FileSystemEntry<DirectoryTypes, undefined> | undefined | — |
Returns
booleanDetermines if a FileSystemEntry is an MDXFile.
Type Parameters
| Parameter | Constraint | Default |
|---|---|---|
FileTypes | Record<string, any> | — |
DirectoryTypes | Record<string, any> | Record<string, any> |
Parameters
| Parameter | Type | Default Value |
|---|---|---|
| entry | FileSystemEntry<DirectoryTypes, undefined> | undefined | — |
Returns
booleanAttempts to resolve a file from a FileSystemEntry, preferring index and
readme for directories. The result can be optionally narrowed by extension.
Type Parameters
| Parameter | Constraint | Default |
|---|---|---|
Types | Record<string, any> | — |
Extension | keyof Types & string | string |
Parameters
| Parameter | Type | Default Value |
|---|---|---|
| entry | FileSystemEntry<Types, undefined> | — |
| extension? | Extension | ReadonlyArray<Extension> | — |
Returns
Promise<FileWithExtension<Types, Extension> | undefined>Modifiers
asyncType
ValidSortKey<EntryTypes<Entry>> | SortKeyExtractor<Entry> | SortDescriptorObject<EntryTypes<Entry>, Entry, ValidSortKey<EntryTypes<Entry>> | SortKeyExtractor<Entry>>Compiles a set of sort descriptors into a sort function.
Type Parameters
| Parameter | Constraint | Default |
|---|---|---|
ExtensionTypes | Record<string, any> | — |
Parameters
| Parameter | Type | Default Value |
|---|---|---|
| entries | Array<FileSystemEntry<ExtensionTypes, undefined>> | — |
| descriptor | SortDescriptor<any> | — |
Returns
Promise<void>Modifiers
asyncType Parameters
| Parameter | Constraint | Default |
|---|---|---|
Entry | FileSystemEntry<any, undefined> | — |
Key | SortKeyExtractor<Entry> | SortKeyExtractor<Entry> |
Parameters
| Parameter | Type | Default Value |
|---|---|---|
| key | Key | — |
| compare? | (a: ExtractComparable<Key>, b: ExtractComparable<Key>) => number | — |
Returns
SortDescriptorObject<any, Entry, Key>A file system that stores files in memory.
Constructor
new MemoryFileSystem(files)Parameters
| Parameter | Type | Default Value |
|---|---|---|
| files | { [path: string]: MemoryFileContent; } | — |
Methods
| Method | Type | Modifiers | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| createFile | (path: string, content: MemoryFileContent) => void | — | ||||||||||||||||||||||||
Parameters
Returnsvoid | ||||||||||||||||||||||||||
| getProjectOptions | () => ProjectOptions | — | ||||||||||||||||||||||||
Returns
| ||||||||||||||||||||||||||
| transpileFile | (path: string) => Promise<…> | — | ||||||||||||||||||||||||
Parameters
ReturnsPromise<string>Modifiersasync | ||||||||||||||||||||||||||
| getAbsolutePath | (path: string) => string | — | ||||||||||||||||||||||||
Parameters
Returnsstring | ||||||||||||||||||||||||||
| getRelativePathToWorkspace | (path: string) => string | — | ||||||||||||||||||||||||
Parameters
Returnsstring | ||||||||||||||||||||||||||
| getFiles | () => Map<…> | — | ||||||||||||||||||||||||
ReturnsMap<string, MemoryFileEntry> | ||||||||||||||||||||||||||
| getFileEntry | (path: string) => MemoryFileEntry | undefined | — | ||||||||||||||||||||||||
Parameters
ReturnsMemoryFileEntry | undefined | ||||||||||||||||||||||||||
| readDirectorySync | (path: string) => Array<…> | — | ||||||||||||||||||||||||
Parameters
ReturnsArray<DirectoryEntry> | ||||||||||||||||||||||||||
| readDirectory | (path: string) => Promise<…> | — | ||||||||||||||||||||||||
Parameters
ReturnsPromise<Array<DirectoryEntry>>Modifiersasync | ||||||||||||||||||||||||||
| readFileSync | (path: string) => string | — | ||||||||||||||||||||||||
Parameters
Returnsstring | ||||||||||||||||||||||||||
| readFile | (path: string) => Promise<…> | — | ||||||||||||||||||||||||
Parameters
ReturnsPromise<string>Modifiersasync | ||||||||||||||||||||||||||
| readFileBinarySync | (path: string) => Uint8Array<…> | — | ||||||||||||||||||||||||
Parameters
ReturnsUint8Array<ArrayBufferLike> | ||||||||||||||||||||||||||
| readFileBinary | (path: string) => Promise<…> | — | ||||||||||||||||||||||||
Parameters
ReturnsPromise<Uint8Array<ArrayBufferLike>>Modifiersasync | ||||||||||||||||||||||||||
| readFileStream | (path: string) => FileReadableStream | — | ||||||||||||||||||||||||
Parameters
ReturnsFileReadableStream | ||||||||||||||||||||||||||
| writeFileSync | (path: string, content: FileSystemWriteFileContent) => void | — | ||||||||||||||||||||||||
Parameters
Returnsvoid | ||||||||||||||||||||||||||
| writeFile | (path: string, content: FileSystemWriteFileContent) => Promise<…> | — | ||||||||||||||||||||||||
Parameters
ReturnsPromise<void>Modifiersasync | ||||||||||||||||||||||||||
| writeFileStream | (path: string) => FileWritableStream | — | ||||||||||||||||||||||||
Parameters
ReturnsFileWritableStream | ||||||||||||||||||||||||||
| fileExistsSync | (path: string) => boolean | — | ||||||||||||||||||||||||
Parameters
Returnsboolean | ||||||||||||||||||||||||||
| fileExists | (path: string) => Promise<…> | — | ||||||||||||||||||||||||
Parameters
ReturnsPromise<boolean>Modifiersasync | ||||||||||||||||||||||||||
| deleteFileSync | (path: string) => void | — | ||||||||||||||||||||||||
Parameters
Returnsvoid | ||||||||||||||||||||||||||
| deleteFile | (path: string) => Promise<…> | — | ||||||||||||||||||||||||
Parameters
ReturnsPromise<void>Modifiersasync | ||||||||||||||||||||||||||
| isFilePathGitIgnored | (filePath: string) => boolean | — | ||||||||||||||||||||||||
Parameters
Returnsboolean | ||||||||||||||||||||||||||
| getFileLastModifiedMsSync | (_path: string) => number | undefined | — | ||||||||||||||||||||||||
Parameters
Returnsnumber | undefined | ||||||||||||||||||||||||||
| getFileLastModifiedMs | (path: string) => Promise<…> | — | ||||||||||||||||||||||||
Parameters
ReturnsPromise<number | undefined>Modifiersasync | ||||||||||||||||||||||||||
Extends
FileSystemConstructor
new NodeFileSystem(options)Parameters
| Parameter | Type | Default Value |
|---|---|---|
| options | FileSystemOptions | {} |
Methods
| Method | Type | Modifiers | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| getProjectOptions | () => { tsConfigFilePath: string; } | — | |||||||||
Returns
| |||||||||||
| getAbsolutePath | (path: string) => string | — | |||||||||
Parameters
Returnsstring | |||||||||||
| getRelativePathToWorkspace | (path: string) => string | — | |||||||||
Parameters
Returnsstring | |||||||||||
| readDirectorySync | (path: string) => Array<…> | — | |||||||||
Parameters
ReturnsArray<DirectoryEntry> | |||||||||||
| readDirectory | (path: string) => Promise<…> | — | |||||||||
Parameters
ReturnsPromise<Array<DirectoryEntry>>Modifiersasync | |||||||||||
| readFileSync | (path: string) => string | — | |||||||||
Parameters
Returnsstring | |||||||||||
| readFile | (path: string) => Promise<…> | — | |||||||||
Parameters
ReturnsPromise<string>Modifiersasync | |||||||||||
| readFileBinarySync | (path: string) => Uint8Array<…> | — | |||||||||
Parameters
ReturnsUint8Array<ArrayBufferLike> | |||||||||||
| readFileBinary | (path: string) => Promise<…> | — | |||||||||
Parameters
ReturnsPromise<Uint8Array<ArrayBufferLike>>Modifiersasync | |||||||||||
| readFileStream | (path: string) => FileReadableStream | — | |||||||||
Parameters
ReturnsFileReadableStream | |||||||||||
| writeFileSync | (path: string, content: FileSystemWriteFileContent) => void | — | |||||||||
Parameters
Returnsvoid | |||||||||||
| writeFile | (path: string, content: FileSystemWriteFileContent) => Promise<…> | — | |||||||||
Parameters
ReturnsPromise<void>Modifiersasync | |||||||||||
| writeFileStream | (path: string) => FileWritableStream | — | |||||||||
Parameters
ReturnsFileWritableStream | |||||||||||
| fileExistsSync | (path: string) => boolean | — | |||||||||
Parameters
Returnsboolean | |||||||||||
| fileExists | (path: string) => Promise<…> | — | |||||||||
Parameters
ReturnsPromise<boolean>Modifiersasync | |||||||||||
| deleteFileSync | (path: string) => void | — | |||||||||
Parameters
Returnsvoid | |||||||||||
| deleteFile | (path: string) => Promise<…> | — | |||||||||
Parameters
ReturnsPromise<void>Modifiersasync | |||||||||||
| isFilePathGitIgnored | (filePath: string) => boolean | — | |||||||||
Parameters
Returnsboolean | |||||||||||
| getFileLastModifiedMsSync | (path: string) => number | undefined | — | |||||||||
Parameters
Returnsnumber | undefined | |||||||||||
| getFileLastModifiedMs | (path: string) => Promise<…> | — | |||||||||
Parameters
ReturnsPromise<number | undefined>Modifiersasync | |||||||||||
Extends
FileSystemConstructor
new Repository(repository)Parameters
| Parameter | Type | Default Value |
|---|---|---|
| repository | RepositoryConfig | string | — |
Methods
| Method | Type | Modifiers | ||||||
|---|---|---|---|---|---|---|---|---|
| toString | () => string | — | ||||||
Returns the string representation of the repository. Returnsstring | ||||||||
| getIssueUrl | (options: GetIssueUrlOptions) => string | — | ||||||
Constructs a new issue URL for the repository. Parameters
Returnsstring | ||||||||
| getFileUrl | (options: GetFileUrlOptions) => string | — | ||||||
Constructs a URL for a file in the repository. Parameters
Returnsstring | ||||||||
| getDirectoryUrl | (options: GetDirectoryUrlOptions) => string | — | ||||||
Constructs a URL for a directory in the repository. Parameters
Returnsstring | ||||||||
| getRelease | (options?: GetReleaseOptions | undefined) => Promise<…> | — | ||||||
Retrieve metadata about a release for the repository. Parameters
ReturnsPromise<Release>Modifiersasync | ||||||||
| getReleaseUrl | (options?: GetReleaseUrlOptions | undefined) => Promise<…> | — | ||||||
Retrieve a URL associated with a release (asset, archive, compare, or HTML). Parameters
ReturnsPromise<string>Modifiersasync | ||||||||