Skip to content

Commit 3fd5792

Browse files
committed
chore: update package metadata, improve type definitions, and enhance README documentation
1 parent bc92d92 commit 3fd5792

File tree

7 files changed

+71
-71
lines changed

7 files changed

+71
-71
lines changed

.github/workflows/CI.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ jobs:
152152
- name: Install dependencies
153153
run: pnpm install
154154
- name: Download artifacts
155-
uses: actions/download-artifact@v6
155+
uses: actions/download-artifact@v4
156156
with:
157157
name: bindings-${{ matrix.settings.target }}
158158
path: .
@@ -208,7 +208,7 @@ jobs:
208208
pnpm config set supportedArchitectures.libc "[\"current\", \"musl\", \"gnu\"]" --json
209209
pnpm install
210210
- name: Download artifacts
211-
uses: actions/download-artifact@v6
211+
uses: actions/download-artifact@v4
212212
with:
213213
name: bindings-${{ matrix.target }}
214214
path: .
@@ -252,7 +252,7 @@ jobs:
252252
- name: create npm dirs
253253
run: pnpm napi create-npm-dirs
254254
- name: Download all artifacts
255-
uses: actions/download-artifact@v4 # v4 is standard, v6 is user specific maybe? keeping consistent with other edits
255+
uses: actions/download-artifact@v4
256256
with:
257257
path: artifacts
258258
- name: Move artifacts

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
[package]
3-
authors = ["LongYinan <lynweklm@gmail.com>"]
3+
authors = []
44
edition = "2021"
55
name = "hyper_fs"
66
version = "0.1.0"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
A high-performance, drop-in replacement for Node.js <code>fs</code> module, powered by Rust.
1111
</p>
1212

13-
## Installation (⚠️ Not Ready Yet)
13+
## Installation
1414

1515
```bash
1616
npm install hyper-fs

README.zh-CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
由 Rust 驱动的高性能 Node.js <code>fs</code> 模块「即插即用」替代品。
1313
</p>
1414

15-
## 安装(⚠️ 暂未就绪)
15+
## 安装
1616

1717
```bash
1818
npm install hyper-fs

__test__/glob.spec.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,25 +47,16 @@ test('globSync: should support exclude option', (t) => {
4747
t.true(filteredFiles.length < allFiles.length)
4848
})
4949

50-
test('globSync: should respect git_ignore (default: true)', (t) => {
51-
// 'target' directory is usually gitignored in Rust projects
52-
// Note: This test assumes 'target' directory exists and is ignored.
53-
// If running in a fresh clone without build, target might not exist.
54-
// We can skip if target doesn't exist, or just check node_modules which is definitely ignored?
55-
// node_modules is ignored by default in many setups but strict gitignore check depends on .gitignore file.
56-
57-
// Let's assume 'target' exists because we built the project
50+
test('globSync: should respect gitIgnore (default: true)', (t) => {
51+
// When gitIgnore: true (default), files in .gitignore are excluded.
52+
// When gitIgnore: false, they are included.
5853
const ignoredFiles = globSync('target/**/*.d', { cwd: CWD })
59-
// Should be empty or very few if ignored (actually cargo ignores target/)
60-
// But wait, standard_filters includes .ignore and .gitignore.
61-
62-
// If we force git_ignore: false, we should see files
63-
const includedFiles = globSync('target/**/*.d', { cwd: CWD, git_ignore: false })
54+
const includedFiles = globSync('target/**/*.d', { cwd: CWD, gitIgnore: false })
6455

6556
if (includedFiles.length > 0) {
6657
t.true(ignoredFiles.length < includedFiles.length, 'Should find fewer files when respecting gitignore')
6758
} else {
68-
t.pass('Target directory empty or not present, skipping git_ignore comparison')
59+
t.pass('Target directory empty or not present, skipping gitIgnore comparison')
6960
}
7061
})
7162

index.d.ts

Lines changed: 46 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -45,35 +45,35 @@ export declare class Stats {
4545
get birthtime(): Date
4646
}
4747

48-
export declare function access(path: string, mode?: number | undefined | null): Promise<unknown>
48+
export declare function access(path: string, mode?: number | undefined | null): Promise<void>
4949

5050
export declare function accessSync(path: string, mode?: number | undefined | null): void
5151

5252
export declare function appendFile(
5353
path: string,
5454
data: string | Buffer,
5555
options?: WriteFileOptions | undefined | null,
56-
): Promise<unknown>
56+
): Promise<void>
5757

5858
export declare function appendFileSync(
5959
path: string,
6060
data: string | Buffer,
6161
options?: WriteFileOptions | undefined | null,
6262
): void
6363

64-
export declare function chmod(path: string, mode: number): Promise<unknown>
64+
export declare function chmod(path: string, mode: number): Promise<void>
6565

6666
export declare function chmodSync(path: string, mode: number): void
6767

68-
export declare function chown(path: string, uid: number, gid: number): Promise<unknown>
68+
export declare function chown(path: string, uid: number, gid: number): Promise<void>
6969

7070
export declare function chownSync(path: string, uid: number, gid: number): void
7171

72-
export declare function copyFile(src: string, dest: string, mode?: number | undefined | null): Promise<unknown>
72+
export declare function copyFile(src: string, dest: string, mode?: number | undefined | null): Promise<void>
7373

7474
export declare function copyFileSync(src: string, dest: string, mode?: number | undefined | null): void
7575

76-
export declare function cp(src: string, dest: string, options?: CpOptions | undefined | null): Promise<unknown>
76+
export declare function cp(src: string, dest: string, options?: CpOptions | undefined | null): Promise<void>
7777

7878
export interface CpOptions {
7979
recursive?: boolean
@@ -91,17 +91,21 @@ export interface CpOptions {
9191

9292
export declare function cpSync(src: string, dest: string, options?: CpOptions | undefined | null): void
9393

94-
export declare function exists(path: string): Promise<unknown>
94+
export declare function exists(path: string): Promise<boolean>
9595

9696
export declare function existsSync(path: string): boolean
9797

98-
export declare function glob(pattern: string, options?: GlobOptions | undefined | null): Promise<unknown>
98+
export declare function glob(
99+
pattern: string,
100+
options?: GlobOptions | undefined | null,
101+
): Promise<Array<string> | Array<Dirent>>
99102

100103
export interface GlobOptions {
101104
cwd?: string
102105
withFileTypes?: boolean
103106
exclude?: Array<string>
104107
concurrency?: number
108+
/** Respect .gitignore / .ignore files (default: true) */
105109
gitIgnore?: boolean
106110
}
107111

@@ -110,15 +114,15 @@ export declare function globSync(
110114
options?: GlobOptions | undefined | null,
111115
): Array<string> | Array<Dirent>
112116

113-
export declare function link(existingPath: string, newPath: string): Promise<unknown>
117+
export declare function link(existingPath: string, newPath: string): Promise<void>
114118

115119
export declare function linkSync(existingPath: string, newPath: string): void
116120

117-
export declare function lstat(path: string): Promise<unknown>
121+
export declare function lstat(path: string): Promise<Stats>
118122

119123
export declare function lstatSync(path: string): Stats
120124

121-
export declare function mkdir(path: string, options?: MkdirOptions | undefined | null): Promise<unknown>
125+
export declare function mkdir(path: string, options?: MkdirOptions | undefined | null): Promise<string | null>
122126

123127
export interface MkdirOptions {
124128
recursive?: boolean
@@ -127,29 +131,19 @@ export interface MkdirOptions {
127131

128132
export declare function mkdirSync(path: string, options?: MkdirOptions | undefined | null): string | null
129133

130-
export declare function mkdtemp(prefix: string): Promise<unknown>
134+
export declare function mkdtemp(prefix: string): Promise<string>
131135

132136
export declare function mkdtempSync(prefix: string): string
133137

134-
export declare function readdir(path: string, options?: ReaddirOptions | undefined | null): Promise<unknown>
135-
136-
/** * Reads the contents of a directory.
137-
* @param {string | Buffer | URL} path
138-
* @param {string | {
139-
* encoding?: string;
140-
* withFileTypes?: boolean;
141-
* recursive?: boolean;
142-
* }} [options]
143-
* @param {(
144-
* err?: Error,
145-
* files?: string[] | Buffer[] | Dirent[]
146-
* ) => any} callback
147-
* @returns {void}
148-
*/
138+
export declare function readdir(
139+
path: string,
140+
options?: ReaddirOptions | undefined | null,
141+
): Promise<Array<string> | Array<Dirent>>
142+
149143
export interface ReaddirOptions {
150144
/**
151145
* File name encoding. 'utf8' (default) returns strings.
152-
* 'buffer' returns Buffer objects for each name.
146+
* 'buffer' returns Buffer objects for each name (not yet supported, treated as 'utf8').
153147
* Other values are treated as 'utf8'.
154148
*/
155149
encoding?: string
@@ -164,7 +158,7 @@ export declare function readdirSync(
164158
options?: ReaddirOptions | undefined | null,
165159
): Array<string> | Array<Dirent>
166160

167-
export declare function readFile(path: string, options?: ReadFileOptions | undefined | null): Promise<unknown>
161+
export declare function readFile(path: string, options?: ReadFileOptions | undefined | null): Promise<string | Buffer>
168162

169163
export interface ReadFileOptions {
170164
encoding?: string
@@ -173,21 +167,21 @@ export interface ReadFileOptions {
173167

174168
export declare function readFileSync(path: string, options?: ReadFileOptions | undefined | null): string | Buffer
175169

176-
export declare function readlink(path: string): Promise<unknown>
170+
export declare function readlink(path: string): Promise<string>
177171

178172
export declare function readlinkSync(path: string): string
179173

180-
export declare function realpath(path: string): Promise<unknown>
174+
export declare function realpath(path: string): Promise<string>
181175

182176
export declare function realpathSync(path: string): string
183177

184-
export declare function rename(oldPath: string, newPath: string): Promise<unknown>
178+
export declare function rename(oldPath: string, newPath: string): Promise<void>
185179

186180
export declare function renameSync(oldPath: string, newPath: string): void
187181

188-
export declare function rm(path: string, options?: RmOptions | undefined | null): Promise<unknown>
182+
export declare function rm(path: string, options?: RmOptions | undefined | null): Promise<void>
189183

190-
export declare function rmdir(path: string): Promise<unknown>
184+
export declare function rmdir(path: string): Promise<void>
191185

192186
export declare function rmdirSync(path: string): void
193187

@@ -197,8 +191,7 @@ export declare function rmdirSync(path: string): void
197191
* - `force`: When true, silently ignore errors when path does not exist.
198192
* - `recursive`: When true, remove directory and all its contents.
199193
* - `maxRetries`: If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or `EPERM` error is
200-
* encountered, Node.js retries the operation with a linear backoff of `retryDelay` ms longer on
201-
* each try. This option represents the number of retries.
194+
* encountered, retries with a linear backoff of `retryDelay` ms on each try.
202195
* - `retryDelay`: The amount of time in milliseconds to wait between retries (default 100ms).
203196
* - `concurrency` (hyper-fs extension): Number of parallel threads for recursive removal.
204197
*/
@@ -212,31 +205,41 @@ export interface RmOptions {
212205

213206
export declare function rmSync(path: string, options?: RmOptions | undefined | null): void
214207

215-
export declare function stat(path: string): Promise<unknown>
208+
export declare function stat(path: string): Promise<Stats>
216209

217210
export declare function statSync(path: string): Stats
218211

219-
export declare function symlink(target: string, path: string, symlinkType?: string | undefined | null): Promise<unknown>
212+
export declare function symlink(
213+
target: string,
214+
path: string,
215+
/** On Windows: 'file' | 'dir' | 'junction'. Ignored on Unix. */
216+
symlinkType?: string | undefined | null,
217+
): Promise<void>
220218

221-
export declare function symlinkSync(target: string, path: string, symlinkType?: string | undefined | null): void
219+
export declare function symlinkSync(
220+
target: string,
221+
path: string,
222+
/** On Windows: 'file' | 'dir' | 'junction'. Ignored on Unix. */
223+
symlinkType?: string | undefined | null,
224+
): void
222225

223-
export declare function truncate(path: string, len?: number | undefined | null): Promise<unknown>
226+
export declare function truncate(path: string, len?: number | undefined | null): Promise<void>
224227

225228
export declare function truncateSync(path: string, len?: number | undefined | null): void
226229

227-
export declare function unlink(path: string): Promise<unknown>
230+
export declare function unlink(path: string): Promise<void>
228231

229232
export declare function unlinkSync(path: string): void
230233

231-
export declare function utimes(path: string, atime: number, mtime: number): Promise<unknown>
234+
export declare function utimes(path: string, atime: number, mtime: number): Promise<void>
232235

233236
export declare function utimesSync(path: string, atime: number, mtime: number): void
234237

235238
export declare function writeFile(
236239
path: string,
237240
data: string | Buffer,
238241
options?: WriteFileOptions | undefined | null,
239-
): Promise<unknown>
242+
): Promise<void>
240243

241244
export interface WriteFileOptions {
242245
encoding?: string

package.json

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
11
{
22
"name": "hyper-fs",
33
"version": "0.0.1",
4-
"description": "Template project for writing node package with napi-rs",
4+
"description": "High-performance drop-in replacement for Node.js fs module, powered by Rust",
55
"main": "index.js",
66
"repository": {
77
"type": "git",
8-
"url": "git+ssh://git@github.com/napi-rs/package-template.git"
8+
"url": "git+https://github.com/hyper-fs/hyper-fs.git"
99
},
1010
"license": "MIT",
1111
"browser": "browser.js",
1212
"keywords": [
13+
"fs",
14+
"filesystem",
15+
"file-system",
16+
"performance",
17+
"rust",
18+
"napi",
1319
"napi-rs",
14-
"NAPI",
15-
"N-API",
16-
"Rust",
17-
"node-addon",
18-
"node-addon-api"
20+
"native",
21+
"readdir",
22+
"glob",
23+
"readFile",
24+
"writeFile"
1925
],
2026
"files": [
2127
"index.d.ts",
@@ -32,7 +38,7 @@
3238
]
3339
},
3440
"engines": {
35-
"node": ">= 10.16.0 < 11 || >= 11.8.0 < 12 || >= 12.0.0"
41+
"node": ">= 18.0.0"
3642
},
3743
"publishConfig": {
3844
"registry": "https://registry.npmjs.org/",

0 commit comments

Comments
 (0)