|
1 | 1 | # Hyper-FS |
2 | 2 |
|
3 | | -# Development |
| 3 | +<p align="center"> |
| 4 | + <img src="https://img.shields.io/badge/Written%20in-Rust-orange?style=flat-square" alt="Written in Rust"> |
| 5 | + <img src="https://img.shields.io/npm/v/hyper-fs?style=flat-square" alt="NPM Version"> |
| 6 | + <img src="https://img.shields.io/npm/l/hyper-fs?style=flat-square" alt="License"> |
| 7 | +</p> |
4 | 8 |
|
5 | | -1. Run `pnpm install` to install dependencies. |
6 | | -2. Edit files in `/src` |
7 | | -3. Run `pnpm build` to build the lib could be invoked by Node.js |
8 | | -4. Run `pnpm test` to check if everything is ok |
| 9 | +<p align="center"> |
| 10 | + A high-performance, drop-in replacement for Node.js <code>fs</code> module, powered by Rust. |
| 11 | +</p> |
9 | 12 |
|
10 | | -## Install this test package |
| 13 | +## Installation (β οΈ Not Ready Yet) |
11 | 14 |
|
12 | 15 | ```bash |
13 | | -yarn add @napi-rs/package-template |
| 16 | +npm install hyper-fs |
| 17 | +# or |
| 18 | +pnpm add hyper-fs |
14 | 19 | ``` |
15 | 20 |
|
16 | | -## Ability |
| 21 | +## Status & Roadmap |
17 | 22 |
|
18 | | -### Build |
| 23 | +We are rewriting `fs` APIs one by one. |
19 | 24 |
|
20 | | -After `yarn build/npm run build` command, you can see `package-template.[darwin|win32|linux].node` file in project root. This is the native addon built from [lib.rs](./src/lib.rs). |
| 25 | +> **Legend** |
| 26 | +> |
| 27 | +> - β
: Fully Supported |
| 28 | +> - π§: Partially Supported / WIP |
| 29 | +> - β¨οΌNew feature from hyper-fs |
| 30 | +> - β: Not Supported Yet |
21 | 31 |
|
22 | | -### Test |
| 32 | +### `readdir` |
23 | 33 |
|
24 | | -With [ava](https://github.com/avajs/ava), run `yarn test/npm run test` to testing native addon. You can also switch to another testing framework if you want. |
| 34 | +- **Node.js Arguments**: |
| 35 | + ```ts |
| 36 | + path: string; // β
|
| 37 | + options?: { |
| 38 | + encoding?: string; // β |
| 39 | + withFileTypes?: boolean; // β
|
| 40 | + recursive?: boolean; // β
|
| 41 | + }; |
| 42 | + ``` |
| 43 | +- **Return Type Diff**: `Buffer` return not supported yet. |
| 44 | +- **Performance**: TBD |
| 45 | +- **Supported Version**: TBD |
| 46 | +- **Notes**: |
| 47 | + - β¨ Supports `options.concurrency` to control parallelism. |
25 | 48 |
|
26 | | -### CI |
| 49 | +### `readFile` |
27 | 50 |
|
28 | | -With GitHub Actions, each commit and pull request will be built and tested automatically in [`node@20`, `@node22`] x [`macOS`, `Linux`, `Windows`] matrix. You will never be afraid of the native addon broken in these platforms. |
| 51 | +- **Status**: β |
29 | 52 |
|
30 | | -### Release |
| 53 | +### `writeFile` |
31 | 54 |
|
32 | | -Release native package is very difficult in old days. Native packages may ask developers who use it to install `build toolchain` like `gcc/llvm`, `node-gyp` or something more. |
| 55 | +- **Status**: β |
33 | 56 |
|
34 | | -With `GitHub actions`, we can easily prebuild a `binary` for major platforms. And with `N-API`, we should never be afraid of **ABI Compatible**. |
| 57 | +### `copyFile` |
35 | 58 |
|
36 | | -The other problem is how to deliver prebuild `binary` to users. Downloading it in `postinstall` script is a common way that most packages do it right now. The problem with this solution is it introduced many other packages to download binary that has not been used by `runtime codes`. The other problem is some users may not easily download the binary from `GitHub/CDN` if they are behind a private network (But in most cases, they have a private NPM mirror). |
| 59 | +- **Status**: β |
37 | 60 |
|
38 | | -In this package, we choose a better way to solve this problem. We release different `npm packages` for different platforms. And add it to `optionalDependencies` before releasing the `Major` package to npm. |
| 61 | +### `mkdir` |
39 | 62 |
|
40 | | -`NPM` will choose which native package should download from `registry` automatically. You can see [npm](./npm) dir for details. And you can also run `yarn add @napi-rs/package-template` to see how it works. |
| 63 | +- **Status**: β |
41 | 64 |
|
42 | | -## Develop requirements |
| 65 | +### `rm` |
43 | 66 |
|
44 | | -- Install the latest `Rust` |
45 | | -- Install `Node.js@10+` which fully supported `Node-API` |
46 | | -- Install `yarn@1.x` |
| 67 | +- **Status**: β |
47 | 68 |
|
48 | | -## Test in local |
| 69 | +### `rmdir` |
49 | 70 |
|
50 | | -- yarn |
51 | | -- yarn build |
52 | | -- yarn test |
| 71 | +- **Status**: β |
53 | 72 |
|
54 | | -And you will see: |
| 73 | +### `stat` |
55 | 74 |
|
56 | | -```bash |
57 | | -$ ava --verbose |
| 75 | +- **Status**: β |
58 | 76 |
|
59 | | - β sync function from native code |
60 | | - β sleep function from native code (201ms) |
61 | | - β |
| 77 | +### `lstat` |
62 | 78 |
|
63 | | - 2 tests passed |
64 | | -β¨ Done in 1.12s. |
65 | | -``` |
| 79 | +- **Status**: β |
66 | 80 |
|
67 | | -## Release package |
| 81 | +### `fstat` |
68 | 82 |
|
69 | | -Ensure you have set your **NPM_TOKEN** in the `GitHub` project setting. |
| 83 | +- **Status**: β |
70 | 84 |
|
71 | | -In `Settings -> Secrets`, add **NPM_TOKEN** into it. |
| 85 | +### `access` |
72 | 86 |
|
73 | | -When you want to release the package: |
| 87 | +- **Status**: β |
74 | 88 |
|
75 | | -```bash |
76 | | -npm version [<newversion> | major | minor | patch | premajor | preminor | prepatch | prerelease [--preid=<prerelease-id>] | from-git] |
| 89 | +### `open` |
| 90 | + |
| 91 | +- **Status**: β |
| 92 | + |
| 93 | +### `opendir` |
| 94 | + |
| 95 | +- **Status**: β |
| 96 | + |
| 97 | +### `close` |
| 98 | + |
| 99 | +- **Status**: β |
| 100 | + |
| 101 | +### `unlink` |
| 102 | + |
| 103 | +- **Status**: β |
| 104 | + |
| 105 | +### `rename` |
| 106 | + |
| 107 | +- **Status**: β |
| 108 | + |
| 109 | +### `readlink` |
| 110 | + |
| 111 | +- **Status**: β |
| 112 | + |
| 113 | +### `realpath` |
| 114 | + |
| 115 | +- **Status**: β |
| 116 | + |
| 117 | +### `chmod` |
| 118 | + |
| 119 | +- **Status**: β |
| 120 | + |
| 121 | +### `chown` |
| 122 | + |
| 123 | +- **Status**: β |
| 124 | + |
| 125 | +### `utimes` |
| 126 | + |
| 127 | +- **Status**: β |
| 128 | + |
| 129 | +### `truncate` |
| 130 | + |
| 131 | +- **Status**: β |
| 132 | + |
| 133 | +### `appendFile` |
| 134 | + |
| 135 | +- **Status**: β |
| 136 | + |
| 137 | +### `watch` |
| 138 | + |
| 139 | +- **Status**: β |
| 140 | + |
| 141 | +## Usage |
| 142 | + |
| 143 | +```ts |
| 144 | +import { readdir } from 'hyper-fs' |
| 145 | + |
| 146 | +// Basic usage |
| 147 | +const files = await readdir('./src') |
77 | 148 |
|
78 | | -git push |
| 149 | +// Recursive with file types |
| 150 | +const entries = await readdir('./src', { |
| 151 | + recursive: true, |
| 152 | + withFileTypes: true, |
| 153 | +}) |
79 | 154 | ``` |
80 | 155 |
|
81 | | -GitHub actions will do the rest job for you. |
| 156 | +## License |
82 | 157 |
|
83 | | -> WARN: Don't run `npm publish` manually. |
| 158 | +MIT |
0 commit comments