From 059923bd09e6f87936413a13c43153a2250a8b48 Mon Sep 17 00:00:00 2001 From: LongYinan Date: Sun, 3 Dec 2023 18:16:34 +0800 Subject: [PATCH] Init --- .github/workflows/CI.yml | 4 +- Cargo.toml | 3 +- README.md | 138 ++++++++------------------- __test__/.gitignore | 1 + __test__/index.spec.ts | 18 +++- __test__/src.tar | Bin 0 -> 5120 bytes index.d.ts | 24 ++++- index.js | 90 ++++++++--------- npm/android-arm-eabi/README.md | 4 +- npm/android-arm-eabi/package.json | 14 +-- npm/android-arm64/README.md | 4 +- npm/android-arm64/package.json | 14 +-- npm/darwin-arm64/README.md | 4 +- npm/darwin-arm64/package.json | 14 +-- npm/darwin-x64/README.md | 4 +- npm/darwin-x64/package.json | 14 +-- npm/freebsd-x64/README.md | 4 +- npm/freebsd-x64/package.json | 14 +-- npm/linux-arm-gnueabihf/README.md | 4 +- npm/linux-arm-gnueabihf/package.json | 14 +-- npm/linux-arm64-gnu/README.md | 4 +- npm/linux-arm64-gnu/package.json | 20 ++-- npm/linux-arm64-musl/README.md | 4 +- npm/linux-arm64-musl/package.json | 20 ++-- npm/linux-x64-gnu/README.md | 4 +- npm/linux-x64-gnu/package.json | 20 ++-- npm/linux-x64-musl/README.md | 4 +- npm/linux-x64-musl/package.json | 20 ++-- npm/win32-arm64-msvc/README.md | 4 +- npm/win32-arm64-msvc/package.json | 14 +-- npm/win32-ia32-msvc/README.md | 4 +- npm/win32-ia32-msvc/package.json | 14 +-- npm/win32-x64-msvc/README.md | 4 +- npm/win32-x64-msvc/package.json | 14 +-- package.json | 11 ++- simple-test.js | 8 +- src/entry.rs | 44 +++++++++ src/lib.rs | 46 ++++++++- yarn.lock | 21 +++- 39 files changed, 374 insertions(+), 292 deletions(-) create mode 100644 __test__/.gitignore create mode 100644 __test__/src.tar create mode 100644 src/entry.rs diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 545e323..84047b1 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -1,7 +1,7 @@ name: CI env: DEBUG: napi:* - APP_NAME: package-template + APP_NAME: tar MACOSX_DEPLOYMENT_TARGET: '10.13' permissions: contents: write @@ -178,7 +178,7 @@ jobs: version: '13.2' memory: 13G cpu_count: 3 - environment_variables: 'DEBUG RUSTUP_IO_THREADS' + environment_variables: DEBUG RUSTUP_IO_THREADS shell: bash run: | sudo pkg install -y -f curl node libnghttp2 npm diff --git a/Cargo.toml b/Cargo.toml index ba70d50..de6b070 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] authors = ["LongYinan "] edition = "2021" -name = "napi-package-template" +name = "napi-tar" version = "0.1.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -12,6 +12,7 @@ crate-type = ["cdylib"] [dependencies] napi = "2" napi-derive = "2" +tar = "0.4" [build-dependencies] napi-build = "2" diff --git a/README.md b/README.md index 44c65f0..07902c0 100644 --- a/README.md +++ b/README.md @@ -1,105 +1,43 @@ -# `@napi-rs/package-template` - -![https://github.com/napi-rs/package-template/actions](https://github.com/napi-rs/package-template/workflows/CI/badge.svg) - -> Template project for writing node packages with napi-rs. - -# Usage - -1. Click **Use this template**. -2. **Clone** your project. -3. Run `yarn install` to install dependencies. -4. Run `npx napi rename -n [name]` command under the project folder to rename your package. - -## Install this test package - -``` -yarn add @napi-rs/package-template +# `@napi-rs/tar` + +![https://github.com/napi-rs/tar/actions](https://github.com/napi-rs/tar/workflows/CI/badge.svg) +[![install size](https://packagephobia.com/badge?p=@napi-rs/tar)](https://packagephobia.com/result?p=@napi-rs/tar) +[![Downloads](https://img.shields.io/npm/dm/@napi-rs/tar.svg?sanitize=true)](https://npmcharts.com/compare/@napi-rs/tar?minimal=true) + +> Node.js tar binding https://docs.rs/tar/latest/tar/ + +## Usage + +```ts +export class Entries { + [Symbol.iterator](): Iterator +} +export class Entry { + path(): string | null +} +export class Archive { + /** Create a new archive with the underlying path. */ + constructor(path: string) + entries(): Entries + /** + * Unpacks the contents tarball into the specified `dst`. + * + * This function will iterate over the entire contents of this tarball, + * extracting each file in turn to the location specified by the entry's + * path name. + * + * This operation is relatively sensitive in that it will not write files + * outside of the path specified by `dst`. Files in the archive which have + * a '..' in their path are skipped during the unpacking process. + */ + unpack(to: string): void +} ``` -## Support matrix - -### Operating Systems - -| | node14 | node16 | node18 | -| ---------------- | ------ | ------ | ------ | -| Windows x64 | ✓ | ✓ | ✓ | -| Windows x32 | ✓ | ✓ | ✓ | -| Windows arm64 | ✓ | ✓ | ✓ | -| macOS x64 | ✓ | ✓ | ✓ | -| macOS arm64 | ✓ | ✓ | ✓ | -| Linux x64 gnu | ✓ | ✓ | ✓ | -| Linux x64 musl | ✓ | ✓ | ✓ | -| Linux arm gnu | ✓ | ✓ | ✓ | -| Linux arm64 gnu | ✓ | ✓ | ✓ | -| Linux arm64 musl | ✓ | ✓ | ✓ | -| Android arm64 | ✓ | ✓ | ✓ | -| Android armv7 | ✓ | ✓ | ✓ | -| FreeBSD x64 | ✓ | ✓ | ✓ | - -## Ability - -### Build - -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). - -### Test - -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. - -### CI - -With GitHub Actions, each commit and pull request will be built and tested automatically in [`node@14`, `node@16`, `@node18`] x [`macOS`, `Linux`, `Windows`] matrix. You will never be afraid of the native addon broken in these platforms. - -### Release - -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. - -With `GitHub actions`, we can easily prebuild a `binary` for major platforms. And with `N-API`, we should never be afraid of **ABI Compatible**. - -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). - -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. - -`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. - -## Develop requirements - -- Install the latest `Rust` -- Install `Node.js@10+` which fully supported `Node-API` -- Install `yarn@1.x` - -## Test in local - -- yarn -- yarn build -- yarn test - -And you will see: - -```bash -$ ava --verbose - - ✔ sync function from native code - ✔ sleep function from native code (201ms) - ─ - - 2 tests passed -✨ Done in 1.12s. -``` - -## Release package - -Ensure you have set your **NPM_TOKEN** in the `GitHub` project setting. - -In `Settings -> Secrets`, add **NPM_TOKEN** into it. - -When you want to release the package: +## Install this test package ``` -npm version [ | major | minor | patch | premajor | preminor | prepatch | prerelease [--preid=] | from-git] - -git push +yarn add @napi-rs/tar +pnpm install @napi-rs/tar +npm install @napi-rs/tar ``` - -GitHub actions will do the rest job for you. diff --git a/__test__/.gitignore b/__test__/.gitignore new file mode 100644 index 0000000..85de9cf --- /dev/null +++ b/__test__/.gitignore @@ -0,0 +1 @@ +src diff --git a/__test__/index.spec.ts b/__test__/index.spec.ts index 067ac9a..8598e24 100644 --- a/__test__/index.spec.ts +++ b/__test__/index.spec.ts @@ -1,8 +1,18 @@ +import { join } from 'node:path' + import test from 'ava' -import { plus100 } from '../index' +import { Archive } from '../index' + +test('should be able to read archive', (t) => { + const archive = new Archive(join(__dirname, 'src.tar')) + for (const entry of archive.entries()) { + t.is(typeof entry.path(), 'string') + } +}) -test('sync function from native code', (t) => { - const fixture = 42 - t.is(plus100(fixture), fixture + 100) +test('should be able to unpack archive', (t) => { + const archive = new Archive(join(__dirname, 'src.tar')) + archive.unpack(__dirname) + t.pass() }) diff --git a/__test__/src.tar b/__test__/src.tar new file mode 100644 index 0000000000000000000000000000000000000000..2a801cecf5dededbcd574fadb55932774f86f570 GIT binary patch literal 5120 zcmeHJ-B0625a&66#Z)I9wv>jDFQkQns*2uQPlEQLI-NMj9$!{CYioBM&I11T&dl0L z4g!5Cr%K?5WIyNQH?#8_XVZhd7ygFB;n8#od;C8O|HIKl=CmXq98RX=@o+Mn&W>Ps zIGRmodoX=ryF`5Ld}7J8xh>1R&@TiUd^l&^JQT)e8v(X+5U(TeB-0Rg2 z!TC(7+$r_DF7P<4nWWN6&9%wCqPeOp7IlV7-JY9OA1*LQizdbUV-diIuQIfHMMro- zLY8F)XuNG`{O%Jke(qKEoRrx*_3*1r7jztMdjQ%PvpXURK3- z*Mih2ElrSFT5<^B;NSp$vzT~<1PtCl(yF@AegS@gP#dzfXtenXRpJ)|y2O^{hL16plWoHD0siDJvh4Am#JT9r#9g^Y0)Gg*%~w} z1sp({J@zcM1esD2Go{XhmTgyC#q0{H8MsAa@rpr>NN^wSTAc5IoN31caemO59G}IE zj2J_Qc53V(P?A05=uRv+$bXqCNw1xRl#;-c7Mdh>PN_{W`cigWg{jUpX7D9*{tE}2 zE{9+ElN^D(HmTR8fg8;iJu(nbuF#4A600r3T0@zO|D7fVldZvT-XBEKWg6yCv?hmU4{jV{^%LdX_X^VbM?$7^itmu9L{b zlPAF=Q_{eaUt&|IqpZEt8TrZXpgaWl&a42JWVQ=3=|Oc*X`#u*MY6)y;so{wgZ=iH zwm}@_2e@l0Hw1oG^Lr9iwZu(cpDj~#ZtDSty=arx1l`k*F^aqVKKKdWo&drLy=J|GGuR_J=GBRCI?Biu^MfgNHhDbgG~FsEa- zexTL%?#Vti?_Q^UsamHy`iHgYke8OYP^eT?`ldqoTVs(C!SMz)E&#In2i103jD)LY zTGGVTjHL1xidr{e znNfV!O_xa(-N~i94s4kP`lcq2y9`;8`X}~e1?KVlg-)^=Z#HD%Er=7E@ z5Ac56uF0t`qFsZv-R|uYBS0}iauFa5Ln4rsPxVDin$dfP?s0F^!7feRX$LtG10QdB sL+;0C17BWIKN-aXLD$`ZUrcx)T%cfZwS00@ZTcv55Xq-asU7T literal 0 HcmV?d00001 diff --git a/index.d.ts b/index.d.ts index 479b3da..db36fe3 100644 --- a/index.d.ts +++ b/index.d.ts @@ -3,4 +3,26 @@ /* auto-generated by NAPI-RS */ -export function plus100(input: number): number +export class Entries { + [Symbol.iterator](): Iterator +} +export class Entry { + path(): string | null +} +export class Archive { + /** Create a new archive with the underlying path. */ + constructor(path: string) + entries(): Entries + /** + * Unpacks the contents tarball into the specified `dst`. + * + * This function will iterate over the entire contents of this tarball, + * extracting each file in turn to the location specified by the entry's + * path name. + * + * This operation is relatively sensitive in that it will not write files + * outside of the path specified by `dst`. Files in the archive which have + * a '..' in their path are skipped during the unpacking process. + */ + unpack(to: string): void +} diff --git a/index.js b/index.js index 34b2c2b..d4bd263 100644 --- a/index.js +++ b/index.js @@ -32,24 +32,24 @@ switch (platform) { case 'android': switch (arch) { case 'arm64': - localFileExisted = existsSync(join(__dirname, 'package-template.android-arm64.node')) + localFileExisted = existsSync(join(__dirname, 'tar.android-arm64.node')) try { if (localFileExisted) { - nativeBinding = require('./package-template.android-arm64.node') + nativeBinding = require('./tar.android-arm64.node') } else { - nativeBinding = require('@napi-rs/package-template-android-arm64') + nativeBinding = require('@napi-rs/tar-android-arm64') } } catch (e) { loadError = e } break case 'arm': - localFileExisted = existsSync(join(__dirname, 'package-template.android-arm-eabi.node')) + localFileExisted = existsSync(join(__dirname, 'tar.android-arm-eabi.node')) try { if (localFileExisted) { - nativeBinding = require('./package-template.android-arm-eabi.node') + nativeBinding = require('./tar.android-arm-eabi.node') } else { - nativeBinding = require('@napi-rs/package-template-android-arm-eabi') + nativeBinding = require('@napi-rs/tar-android-arm-eabi') } } catch (e) { loadError = e @@ -62,36 +62,36 @@ switch (platform) { case 'win32': switch (arch) { case 'x64': - localFileExisted = existsSync(join(__dirname, 'package-template.win32-x64-msvc.node')) + localFileExisted = existsSync(join(__dirname, 'tar.win32-x64-msvc.node')) try { if (localFileExisted) { - nativeBinding = require('./package-template.win32-x64-msvc.node') + nativeBinding = require('./tar.win32-x64-msvc.node') } else { - nativeBinding = require('@napi-rs/package-template-win32-x64-msvc') + nativeBinding = require('@napi-rs/tar-win32-x64-msvc') } } catch (e) { loadError = e } break case 'ia32': - localFileExisted = existsSync(join(__dirname, 'package-template.win32-ia32-msvc.node')) + localFileExisted = existsSync(join(__dirname, 'tar.win32-ia32-msvc.node')) try { if (localFileExisted) { - nativeBinding = require('./package-template.win32-ia32-msvc.node') + nativeBinding = require('./tar.win32-ia32-msvc.node') } else { - nativeBinding = require('@napi-rs/package-template-win32-ia32-msvc') + nativeBinding = require('@napi-rs/tar-win32-ia32-msvc') } } catch (e) { loadError = e } break case 'arm64': - localFileExisted = existsSync(join(__dirname, 'package-template.win32-arm64-msvc.node')) + localFileExisted = existsSync(join(__dirname, 'tar.win32-arm64-msvc.node')) try { if (localFileExisted) { - nativeBinding = require('./package-template.win32-arm64-msvc.node') + nativeBinding = require('./tar.win32-arm64-msvc.node') } else { - nativeBinding = require('@napi-rs/package-template-win32-arm64-msvc') + nativeBinding = require('@napi-rs/tar-win32-arm64-msvc') } } catch (e) { loadError = e @@ -102,35 +102,35 @@ switch (platform) { } break case 'darwin': - localFileExisted = existsSync(join(__dirname, 'package-template.darwin-universal.node')) + localFileExisted = existsSync(join(__dirname, 'tar.darwin-universal.node')) try { if (localFileExisted) { - nativeBinding = require('./package-template.darwin-universal.node') + nativeBinding = require('./tar.darwin-universal.node') } else { - nativeBinding = require('@napi-rs/package-template-darwin-universal') + nativeBinding = require('@napi-rs/tar-darwin-universal') } break } catch {} switch (arch) { case 'x64': - localFileExisted = existsSync(join(__dirname, 'package-template.darwin-x64.node')) + localFileExisted = existsSync(join(__dirname, 'tar.darwin-x64.node')) try { if (localFileExisted) { - nativeBinding = require('./package-template.darwin-x64.node') + nativeBinding = require('./tar.darwin-x64.node') } else { - nativeBinding = require('@napi-rs/package-template-darwin-x64') + nativeBinding = require('@napi-rs/tar-darwin-x64') } } catch (e) { loadError = e } break case 'arm64': - localFileExisted = existsSync(join(__dirname, 'package-template.darwin-arm64.node')) + localFileExisted = existsSync(join(__dirname, 'tar.darwin-arm64.node')) try { if (localFileExisted) { - nativeBinding = require('./package-template.darwin-arm64.node') + nativeBinding = require('./tar.darwin-arm64.node') } else { - nativeBinding = require('@napi-rs/package-template-darwin-arm64') + nativeBinding = require('@napi-rs/tar-darwin-arm64') } } catch (e) { loadError = e @@ -144,12 +144,12 @@ switch (platform) { if (arch !== 'x64') { throw new Error(`Unsupported architecture on FreeBSD: ${arch}`) } - localFileExisted = existsSync(join(__dirname, 'package-template.freebsd-x64.node')) + localFileExisted = existsSync(join(__dirname, 'tar.freebsd-x64.node')) try { if (localFileExisted) { - nativeBinding = require('./package-template.freebsd-x64.node') + nativeBinding = require('./tar.freebsd-x64.node') } else { - nativeBinding = require('@napi-rs/package-template-freebsd-x64') + nativeBinding = require('@napi-rs/tar-freebsd-x64') } } catch (e) { loadError = e @@ -159,23 +159,23 @@ switch (platform) { switch (arch) { case 'x64': if (isMusl()) { - localFileExisted = existsSync(join(__dirname, 'package-template.linux-x64-musl.node')) + localFileExisted = existsSync(join(__dirname, 'tar.linux-x64-musl.node')) try { if (localFileExisted) { - nativeBinding = require('./package-template.linux-x64-musl.node') + nativeBinding = require('./tar.linux-x64-musl.node') } else { - nativeBinding = require('@napi-rs/package-template-linux-x64-musl') + nativeBinding = require('@napi-rs/tar-linux-x64-musl') } } catch (e) { loadError = e } } else { - localFileExisted = existsSync(join(__dirname, 'package-template.linux-x64-gnu.node')) + localFileExisted = existsSync(join(__dirname, 'tar.linux-x64-gnu.node')) try { if (localFileExisted) { - nativeBinding = require('./package-template.linux-x64-gnu.node') + nativeBinding = require('./tar.linux-x64-gnu.node') } else { - nativeBinding = require('@napi-rs/package-template-linux-x64-gnu') + nativeBinding = require('@napi-rs/tar-linux-x64-gnu') } } catch (e) { loadError = e @@ -184,23 +184,23 @@ switch (platform) { break case 'arm64': if (isMusl()) { - localFileExisted = existsSync(join(__dirname, 'package-template.linux-arm64-musl.node')) + localFileExisted = existsSync(join(__dirname, 'tar.linux-arm64-musl.node')) try { if (localFileExisted) { - nativeBinding = require('./package-template.linux-arm64-musl.node') + nativeBinding = require('./tar.linux-arm64-musl.node') } else { - nativeBinding = require('@napi-rs/package-template-linux-arm64-musl') + nativeBinding = require('@napi-rs/tar-linux-arm64-musl') } } catch (e) { loadError = e } } else { - localFileExisted = existsSync(join(__dirname, 'package-template.linux-arm64-gnu.node')) + localFileExisted = existsSync(join(__dirname, 'tar.linux-arm64-gnu.node')) try { if (localFileExisted) { - nativeBinding = require('./package-template.linux-arm64-gnu.node') + nativeBinding = require('./tar.linux-arm64-gnu.node') } else { - nativeBinding = require('@napi-rs/package-template-linux-arm64-gnu') + nativeBinding = require('@napi-rs/tar-linux-arm64-gnu') } } catch (e) { loadError = e @@ -208,12 +208,12 @@ switch (platform) { } break case 'arm': - localFileExisted = existsSync(join(__dirname, 'package-template.linux-arm-gnueabihf.node')) + localFileExisted = existsSync(join(__dirname, 'tar.linux-arm-gnueabihf.node')) try { if (localFileExisted) { - nativeBinding = require('./package-template.linux-arm-gnueabihf.node') + nativeBinding = require('./tar.linux-arm-gnueabihf.node') } else { - nativeBinding = require('@napi-rs/package-template-linux-arm-gnueabihf') + nativeBinding = require('@napi-rs/tar-linux-arm-gnueabihf') } } catch (e) { loadError = e @@ -234,6 +234,8 @@ if (!nativeBinding) { throw new Error(`Failed to load native binding`) } -const { plus100 } = nativeBinding +const { Entries, Entry, Archive } = nativeBinding -module.exports.plus100 = plus100 +module.exports.Entries = Entries +module.exports.Entry = Entry +module.exports.Archive = Archive diff --git a/npm/android-arm-eabi/README.md b/npm/android-arm-eabi/README.md index 5f3eba9..b1b717e 100644 --- a/npm/android-arm-eabi/README.md +++ b/npm/android-arm-eabi/README.md @@ -1,3 +1,3 @@ -# `@napi-rs/package-template-android-arm-eabi` +# `@napi-rs/tar-android-arm-eabi` -This is the **armv7-linux-androideabi** binary for `@napi-rs/package-template` +This is the **armv7-linux-androideabi** binary for `@napi-rs/tar` diff --git a/npm/android-arm-eabi/package.json b/npm/android-arm-eabi/package.json index 013ab0d..19363fe 100644 --- a/npm/android-arm-eabi/package.json +++ b/npm/android-arm-eabi/package.json @@ -1,17 +1,17 @@ { - "name": "@napi-rs/package-template-android-arm-eabi", - "version": "1.0.0", + "name": "@napi-rs/tar-android-arm-eabi", + "version": "0.0.0", "os": [ "android" ], "cpu": [ "arm" ], - "main": "package-template.android-arm-eabi.node", + "main": "tar.android-arm-eabi.node", "files": [ - "package-template.android-arm-eabi.node" + "tar.android-arm-eabi.node" ], - "description": "Template project for writing node package with napi-rs", + "description": "Node.js tar binding https://docs.rs/tar/latest/tar/", "keywords": [ "napi-rs", "NAPI", @@ -28,5 +28,5 @@ "registry": "https://registry.npmjs.org/", "access": "public" }, - "repository": "git@github.com:napi-rs/package-template.git" -} + "repository": "git@github.com:napi-rs/tar.git" +} \ No newline at end of file diff --git a/npm/android-arm64/README.md b/npm/android-arm64/README.md index 43c27bb..b29e861 100644 --- a/npm/android-arm64/README.md +++ b/npm/android-arm64/README.md @@ -1,3 +1,3 @@ -# `@napi-rs/package-template-android-arm64` +# `@napi-rs/tar-android-arm64` -This is the **aarch64-linux-android** binary for `@napi-rs/package-template` +This is the **aarch64-linux-android** binary for `@napi-rs/tar` diff --git a/npm/android-arm64/package.json b/npm/android-arm64/package.json index 15fb65f..be2c689 100644 --- a/npm/android-arm64/package.json +++ b/npm/android-arm64/package.json @@ -1,17 +1,17 @@ { - "name": "@napi-rs/package-template-android-arm64", - "version": "1.0.0", + "name": "@napi-rs/tar-android-arm64", + "version": "0.0.0", "os": [ "android" ], "cpu": [ "arm64" ], - "main": "package-template.android-arm64.node", + "main": "tar.android-arm64.node", "files": [ - "package-template.android-arm64.node" + "tar.android-arm64.node" ], - "description": "Template project for writing node package with napi-rs", + "description": "Node.js tar binding https://docs.rs/tar/latest/tar/", "keywords": [ "napi-rs", "NAPI", @@ -28,5 +28,5 @@ "registry": "https://registry.npmjs.org/", "access": "public" }, - "repository": "git@github.com:napi-rs/package-template.git" -} + "repository": "git@github.com:napi-rs/tar.git" +} \ No newline at end of file diff --git a/npm/darwin-arm64/README.md b/npm/darwin-arm64/README.md index c082d2b..c087e09 100644 --- a/npm/darwin-arm64/README.md +++ b/npm/darwin-arm64/README.md @@ -1,3 +1,3 @@ -# `@napi-rs/package-template-darwin-arm64` +# `@napi-rs/tar-darwin-arm64` -This is the **aarch64-apple-darwin** binary for `@napi-rs/package-template` +This is the **aarch64-apple-darwin** binary for `@napi-rs/tar` diff --git a/npm/darwin-arm64/package.json b/npm/darwin-arm64/package.json index f598805..45aeb08 100644 --- a/npm/darwin-arm64/package.json +++ b/npm/darwin-arm64/package.json @@ -1,17 +1,17 @@ { - "name": "@napi-rs/package-template-darwin-arm64", - "version": "1.0.0", + "name": "@napi-rs/tar-darwin-arm64", + "version": "0.0.0", "os": [ "darwin" ], "cpu": [ "arm64" ], - "main": "package-template.darwin-arm64.node", + "main": "tar.darwin-arm64.node", "files": [ - "package-template.darwin-arm64.node" + "tar.darwin-arm64.node" ], - "description": "Template project for writing node package with napi-rs", + "description": "Node.js tar binding https://docs.rs/tar/latest/tar/", "keywords": [ "napi-rs", "NAPI", @@ -28,5 +28,5 @@ "registry": "https://registry.npmjs.org/", "access": "public" }, - "repository": "git@github.com:napi-rs/package-template.git" -} + "repository": "git@github.com:napi-rs/tar.git" +} \ No newline at end of file diff --git a/npm/darwin-x64/README.md b/npm/darwin-x64/README.md index 37fd27e..fb719f8 100644 --- a/npm/darwin-x64/README.md +++ b/npm/darwin-x64/README.md @@ -1,3 +1,3 @@ -# `@napi-rs/package-template-darwin-x64` +# `@napi-rs/tar-darwin-x64` -This is the **x86_64-apple-darwin** binary for `@napi-rs/package-template` +This is the **x86_64-apple-darwin** binary for `@napi-rs/tar` diff --git a/npm/darwin-x64/package.json b/npm/darwin-x64/package.json index b3dcdad..1614d1f 100644 --- a/npm/darwin-x64/package.json +++ b/npm/darwin-x64/package.json @@ -1,17 +1,17 @@ { - "name": "@napi-rs/package-template-darwin-x64", - "version": "1.0.0", + "name": "@napi-rs/tar-darwin-x64", + "version": "0.0.0", "os": [ "darwin" ], "cpu": [ "x64" ], - "main": "package-template.darwin-x64.node", + "main": "tar.darwin-x64.node", "files": [ - "package-template.darwin-x64.node" + "tar.darwin-x64.node" ], - "description": "Template project for writing node package with napi-rs", + "description": "Node.js tar binding https://docs.rs/tar/latest/tar/", "keywords": [ "napi-rs", "NAPI", @@ -28,5 +28,5 @@ "registry": "https://registry.npmjs.org/", "access": "public" }, - "repository": "git@github.com:napi-rs/package-template.git" -} + "repository": "git@github.com:napi-rs/tar.git" +} \ No newline at end of file diff --git a/npm/freebsd-x64/README.md b/npm/freebsd-x64/README.md index 1ea628b..6334867 100644 --- a/npm/freebsd-x64/README.md +++ b/npm/freebsd-x64/README.md @@ -1,3 +1,3 @@ -# `@napi-rs/package-template-freebsd-x64` +# `@napi-rs/tar-freebsd-x64` -This is the **x86_64-unknown-freebsd** binary for `@napi-rs/package-template` +This is the **x86_64-unknown-freebsd** binary for `@napi-rs/tar` diff --git a/npm/freebsd-x64/package.json b/npm/freebsd-x64/package.json index e0eb3e5..a022c27 100644 --- a/npm/freebsd-x64/package.json +++ b/npm/freebsd-x64/package.json @@ -1,17 +1,17 @@ { - "name": "@napi-rs/package-template-freebsd-x64", - "version": "1.0.0", + "name": "@napi-rs/tar-freebsd-x64", + "version": "0.0.0", "os": [ "freebsd" ], "cpu": [ "x64" ], - "main": "package-template.freebsd-x64.node", + "main": "tar.freebsd-x64.node", "files": [ - "package-template.freebsd-x64.node" + "tar.freebsd-x64.node" ], - "description": "Template project for writing node package with napi-rs", + "description": "Node.js tar binding https://docs.rs/tar/latest/tar/", "keywords": [ "napi-rs", "NAPI", @@ -28,5 +28,5 @@ "registry": "https://registry.npmjs.org/", "access": "public" }, - "repository": "git@github.com:napi-rs/package-template.git" -} + "repository": "git@github.com:napi-rs/tar.git" +} \ No newline at end of file diff --git a/npm/linux-arm-gnueabihf/README.md b/npm/linux-arm-gnueabihf/README.md index 655eae9..4c79966 100644 --- a/npm/linux-arm-gnueabihf/README.md +++ b/npm/linux-arm-gnueabihf/README.md @@ -1,3 +1,3 @@ -# `@napi-rs/package-template-linux-arm-gnueabihf` +# `@napi-rs/tar-linux-arm-gnueabihf` -This is the **armv7-unknown-linux-gnueabihf** binary for `@napi-rs/package-template` +This is the **armv7-unknown-linux-gnueabihf** binary for `@napi-rs/tar` diff --git a/npm/linux-arm-gnueabihf/package.json b/npm/linux-arm-gnueabihf/package.json index d13ece8..33899c0 100644 --- a/npm/linux-arm-gnueabihf/package.json +++ b/npm/linux-arm-gnueabihf/package.json @@ -1,17 +1,17 @@ { - "name": "@napi-rs/package-template-linux-arm-gnueabihf", - "version": "1.0.0", + "name": "@napi-rs/tar-linux-arm-gnueabihf", + "version": "0.0.0", "os": [ "linux" ], "cpu": [ "arm" ], - "main": "package-template.linux-arm-gnueabihf.node", + "main": "tar.linux-arm-gnueabihf.node", "files": [ - "package-template.linux-arm-gnueabihf.node" + "tar.linux-arm-gnueabihf.node" ], - "description": "Template project for writing node package with napi-rs", + "description": "Node.js tar binding https://docs.rs/tar/latest/tar/", "keywords": [ "napi-rs", "NAPI", @@ -28,5 +28,5 @@ "registry": "https://registry.npmjs.org/", "access": "public" }, - "repository": "git@github.com:napi-rs/package-template.git" -} + "repository": "git@github.com:napi-rs/tar.git" +} \ No newline at end of file diff --git a/npm/linux-arm64-gnu/README.md b/npm/linux-arm64-gnu/README.md index 2601bff..431d5dc 100644 --- a/npm/linux-arm64-gnu/README.md +++ b/npm/linux-arm64-gnu/README.md @@ -1,3 +1,3 @@ -# `@napi-rs/package-template-linux-arm64-gnu` +# `@napi-rs/tar-linux-arm64-gnu` -This is the **aarch64-unknown-linux-gnu** binary for `@napi-rs/package-template` +This is the **aarch64-unknown-linux-gnu** binary for `@napi-rs/tar` diff --git a/npm/linux-arm64-gnu/package.json b/npm/linux-arm64-gnu/package.json index 0b596d8..c8c22f9 100644 --- a/npm/linux-arm64-gnu/package.json +++ b/npm/linux-arm64-gnu/package.json @@ -1,20 +1,17 @@ { - "name": "@napi-rs/package-template-linux-arm64-gnu", - "version": "1.0.0", + "name": "@napi-rs/tar-linux-arm64-gnu", + "version": "0.0.0", "os": [ "linux" ], "cpu": [ "arm64" ], - "libc": [ - "glibc" - ], - "main": "package-template.linux-arm64-gnu.node", + "main": "tar.linux-arm64-gnu.node", "files": [ - "package-template.linux-arm64-gnu.node" + "tar.linux-arm64-gnu.node" ], - "description": "Template project for writing node package with napi-rs", + "description": "Node.js tar binding https://docs.rs/tar/latest/tar/", "keywords": [ "napi-rs", "NAPI", @@ -31,5 +28,8 @@ "registry": "https://registry.npmjs.org/", "access": "public" }, - "repository": "git@github.com:napi-rs/package-template.git" -} + "repository": "git@github.com:napi-rs/tar.git", + "libc": [ + "glibc" + ] +} \ No newline at end of file diff --git a/npm/linux-arm64-musl/README.md b/npm/linux-arm64-musl/README.md index 63c719f..b84299b 100644 --- a/npm/linux-arm64-musl/README.md +++ b/npm/linux-arm64-musl/README.md @@ -1,3 +1,3 @@ -# `@napi-rs/package-template-linux-arm64-musl` +# `@napi-rs/tar-linux-arm64-musl` -This is the **aarch64-unknown-linux-musl** binary for `@napi-rs/package-template` +This is the **aarch64-unknown-linux-musl** binary for `@napi-rs/tar` diff --git a/npm/linux-arm64-musl/package.json b/npm/linux-arm64-musl/package.json index 5ef453d..a8a8a43 100644 --- a/npm/linux-arm64-musl/package.json +++ b/npm/linux-arm64-musl/package.json @@ -1,20 +1,17 @@ { - "name": "@napi-rs/package-template-linux-arm64-musl", - "version": "1.0.0", + "name": "@napi-rs/tar-linux-arm64-musl", + "version": "0.0.0", "os": [ "linux" ], "cpu": [ "arm64" ], - "libc": [ - "musl" - ], - "main": "package-template.linux-arm64-musl.node", + "main": "tar.linux-arm64-musl.node", "files": [ - "package-template.linux-arm64-musl.node" + "tar.linux-arm64-musl.node" ], - "description": "Template project for writing node package with napi-rs", + "description": "Node.js tar binding https://docs.rs/tar/latest/tar/", "keywords": [ "napi-rs", "NAPI", @@ -31,5 +28,8 @@ "registry": "https://registry.npmjs.org/", "access": "public" }, - "repository": "git@github.com:napi-rs/package-template.git" -} + "repository": "git@github.com:napi-rs/tar.git", + "libc": [ + "musl" + ] +} \ No newline at end of file diff --git a/npm/linux-x64-gnu/README.md b/npm/linux-x64-gnu/README.md index 42d28b1..e680a86 100644 --- a/npm/linux-x64-gnu/README.md +++ b/npm/linux-x64-gnu/README.md @@ -1,3 +1,3 @@ -# `@napi-rs/package-template-linux-x64-gnu` +# `@napi-rs/tar-linux-x64-gnu` -This is the **x86_64-unknown-linux-gnu** binary for `@napi-rs/package-template` +This is the **x86_64-unknown-linux-gnu** binary for `@napi-rs/tar` diff --git a/npm/linux-x64-gnu/package.json b/npm/linux-x64-gnu/package.json index a01c26b..b46ddc9 100644 --- a/npm/linux-x64-gnu/package.json +++ b/npm/linux-x64-gnu/package.json @@ -1,20 +1,17 @@ { - "name": "@napi-rs/package-template-linux-x64-gnu", - "version": "1.0.0", + "name": "@napi-rs/tar-linux-x64-gnu", + "version": "0.0.0", "os": [ "linux" ], "cpu": [ "x64" ], - "libc": [ - "glibc" - ], - "main": "package-template.linux-x64-gnu.node", + "main": "tar.linux-x64-gnu.node", "files": [ - "package-template.linux-x64-gnu.node" + "tar.linux-x64-gnu.node" ], - "description": "Template project for writing node package with napi-rs", + "description": "Node.js tar binding https://docs.rs/tar/latest/tar/", "keywords": [ "napi-rs", "NAPI", @@ -31,5 +28,8 @@ "registry": "https://registry.npmjs.org/", "access": "public" }, - "repository": "git@github.com:napi-rs/package-template.git" -} + "repository": "git@github.com:napi-rs/tar.git", + "libc": [ + "glibc" + ] +} \ No newline at end of file diff --git a/npm/linux-x64-musl/README.md b/npm/linux-x64-musl/README.md index 10c2913..023495c 100644 --- a/npm/linux-x64-musl/README.md +++ b/npm/linux-x64-musl/README.md @@ -1,3 +1,3 @@ -# `@napi-rs/package-template-linux-x64-musl` +# `@napi-rs/tar-linux-x64-musl` -This is the **x86_64-unknown-linux-musl** binary for `@napi-rs/package-template` +This is the **x86_64-unknown-linux-musl** binary for `@napi-rs/tar` diff --git a/npm/linux-x64-musl/package.json b/npm/linux-x64-musl/package.json index bf63549..961dc5d 100644 --- a/npm/linux-x64-musl/package.json +++ b/npm/linux-x64-musl/package.json @@ -1,20 +1,17 @@ { - "name": "@napi-rs/package-template-linux-x64-musl", - "version": "1.0.0", + "name": "@napi-rs/tar-linux-x64-musl", + "version": "0.0.0", "os": [ "linux" ], "cpu": [ "x64" ], - "libc": [ - "musl" - ], - "main": "package-template.linux-x64-musl.node", + "main": "tar.linux-x64-musl.node", "files": [ - "package-template.linux-x64-musl.node" + "tar.linux-x64-musl.node" ], - "description": "Template project for writing node package with napi-rs", + "description": "Node.js tar binding https://docs.rs/tar/latest/tar/", "keywords": [ "napi-rs", "NAPI", @@ -31,5 +28,8 @@ "registry": "https://registry.npmjs.org/", "access": "public" }, - "repository": "git@github.com:napi-rs/package-template.git" -} + "repository": "git@github.com:napi-rs/tar.git", + "libc": [ + "musl" + ] +} \ No newline at end of file diff --git a/npm/win32-arm64-msvc/README.md b/npm/win32-arm64-msvc/README.md index a9bc937..ce8e879 100644 --- a/npm/win32-arm64-msvc/README.md +++ b/npm/win32-arm64-msvc/README.md @@ -1,3 +1,3 @@ -# `@napi-rs/package-template-win32-arm64-msvc` +# `@napi-rs/tar-win32-arm64-msvc` -This is the **aarch64-pc-windows-msvc** binary for `@napi-rs/package-template` +This is the **aarch64-pc-windows-msvc** binary for `@napi-rs/tar` diff --git a/npm/win32-arm64-msvc/package.json b/npm/win32-arm64-msvc/package.json index 978b0fa..664dd04 100644 --- a/npm/win32-arm64-msvc/package.json +++ b/npm/win32-arm64-msvc/package.json @@ -1,17 +1,17 @@ { - "name": "@napi-rs/package-template-win32-arm64-msvc", - "version": "1.0.0", + "name": "@napi-rs/tar-win32-arm64-msvc", + "version": "0.0.0", "os": [ "win32" ], "cpu": [ "arm64" ], - "main": "package-template.win32-arm64-msvc.node", + "main": "tar.win32-arm64-msvc.node", "files": [ - "package-template.win32-arm64-msvc.node" + "tar.win32-arm64-msvc.node" ], - "description": "Template project for writing node package with napi-rs", + "description": "Node.js tar binding https://docs.rs/tar/latest/tar/", "keywords": [ "napi-rs", "NAPI", @@ -28,5 +28,5 @@ "registry": "https://registry.npmjs.org/", "access": "public" }, - "repository": "git@github.com:napi-rs/package-template.git" -} + "repository": "git@github.com:napi-rs/tar.git" +} \ No newline at end of file diff --git a/npm/win32-ia32-msvc/README.md b/npm/win32-ia32-msvc/README.md index 1c0e7a3..7c94733 100644 --- a/npm/win32-ia32-msvc/README.md +++ b/npm/win32-ia32-msvc/README.md @@ -1,3 +1,3 @@ -# `@napi-rs/package-template-win32-ia32-msvc` +# `@napi-rs/tar-win32-ia32-msvc` -This is the **i686-pc-windows-msvc** binary for `@napi-rs/package-template` +This is the **i686-pc-windows-msvc** binary for `@napi-rs/tar` diff --git a/npm/win32-ia32-msvc/package.json b/npm/win32-ia32-msvc/package.json index 70d1812..2495641 100644 --- a/npm/win32-ia32-msvc/package.json +++ b/npm/win32-ia32-msvc/package.json @@ -1,17 +1,17 @@ { - "name": "@napi-rs/package-template-win32-ia32-msvc", - "version": "1.0.0", + "name": "@napi-rs/tar-win32-ia32-msvc", + "version": "0.0.0", "os": [ "win32" ], "cpu": [ "ia32" ], - "main": "package-template.win32-ia32-msvc.node", + "main": "tar.win32-ia32-msvc.node", "files": [ - "package-template.win32-ia32-msvc.node" + "tar.win32-ia32-msvc.node" ], - "description": "Template project for writing node package with napi-rs", + "description": "Node.js tar binding https://docs.rs/tar/latest/tar/", "keywords": [ "napi-rs", "NAPI", @@ -28,5 +28,5 @@ "registry": "https://registry.npmjs.org/", "access": "public" }, - "repository": "git@github.com:napi-rs/package-template.git" -} + "repository": "git@github.com:napi-rs/tar.git" +} \ No newline at end of file diff --git a/npm/win32-x64-msvc/README.md b/npm/win32-x64-msvc/README.md index 1acad6c..c69c05d 100644 --- a/npm/win32-x64-msvc/README.md +++ b/npm/win32-x64-msvc/README.md @@ -1,3 +1,3 @@ -# `@napi-rs/package-template-win32-x64-msvc` +# `@napi-rs/tar-win32-x64-msvc` -This is the **x86_64-pc-windows-msvc** binary for `@napi-rs/package-template` +This is the **x86_64-pc-windows-msvc** binary for `@napi-rs/tar` diff --git a/npm/win32-x64-msvc/package.json b/npm/win32-x64-msvc/package.json index 593b1d8..7316ff6 100644 --- a/npm/win32-x64-msvc/package.json +++ b/npm/win32-x64-msvc/package.json @@ -1,17 +1,17 @@ { - "name": "@napi-rs/package-template-win32-x64-msvc", - "version": "1.0.0", + "name": "@napi-rs/tar-win32-x64-msvc", + "version": "0.0.0", "os": [ "win32" ], "cpu": [ "x64" ], - "main": "package-template.win32-x64-msvc.node", + "main": "tar.win32-x64-msvc.node", "files": [ - "package-template.win32-x64-msvc.node" + "tar.win32-x64-msvc.node" ], - "description": "Template project for writing node package with napi-rs", + "description": "Node.js tar binding https://docs.rs/tar/latest/tar/", "keywords": [ "napi-rs", "NAPI", @@ -28,5 +28,5 @@ "registry": "https://registry.npmjs.org/", "access": "public" }, - "repository": "git@github.com:napi-rs/package-template.git" -} + "repository": "git@github.com:napi-rs/tar.git" +} \ No newline at end of file diff --git a/package.json b/package.json index 1e1a6e9..f59b0b1 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,9 @@ { - "name": "@napi-rs/package-template", - "version": "1.0.0", - "description": "Template project for writing node package with napi-rs", + "name": "@napi-rs/tar", + "version": "0.0.0", + "description": "Node.js tar binding https://docs.rs/tar/latest/tar/", "main": "index.js", - "repository": "git@github.com:napi-rs/package-template.git", + "repository": "git@github.com:napi-rs/tar.git", "license": "MIT", "keywords": [ "napi-rs", @@ -18,7 +18,7 @@ "index.js" ], "napi": { - "name": "package-template", + "name": "tar", "triples": { "defaults": true, "additional": [ @@ -61,6 +61,7 @@ "@swc-node/register": "^1.6.8", "@swc/core": "^1.3.95", "@taplo/cli": "^0.5.2", + "@types/node": "^20.10.2", "@typescript-eslint/eslint-plugin": "^6.9.1", "@typescript-eslint/parser": "^6.9.1", "ava": "^5.3.1", diff --git a/simple-test.js b/simple-test.js index fb76fb9..677f15c 100644 --- a/simple-test.js +++ b/simple-test.js @@ -1,5 +1,9 @@ -const { plus100 } = require('./index') +const { Archive } = require('./index') -console.assert(plus100(0) === 100, 'Simple test failed') +const archive = new Archive(__dirname + '/__test__/src.tar') + +for (const entry of archive.entries()) { + console.info(entry.path()) +} console.info('Simple test passed') diff --git a/src/entry.rs b/src/entry.rs new file mode 100644 index 0000000..9057279 --- /dev/null +++ b/src/entry.rs @@ -0,0 +1,44 @@ +use std::fs::File; + +use napi::{bindgen_prelude::SharedReference, iterator::Generator}; +use napi_derive::napi; + +use crate::Archive; + +#[napi(iterator)] +pub struct Entries { + pub(crate) inner: SharedReference>, +} + +#[napi] +impl Generator for Entries { + type Yield = Entry; + type Next = (); + type Return = (); + + fn next(&mut self, _next: Option<()>) -> Option { + let entry = self + .inner + .next()? + .map(|entry| crate::entry::Entry::new(entry)) + .ok()?; + Some(entry) + } +} + +#[napi] +pub struct Entry { + inner: tar::Entry<'static, File>, +} + +#[napi] +impl Entry { + pub fn new(inner: tar::Entry<'static, File>) -> Self { + Self { inner } + } + + #[napi] + pub fn path(&self) -> napi::Result> { + Ok(self.inner.path()?.to_str().map(|s| s.to_owned())) + } +} diff --git a/src/lib.rs b/src/lib.rs index c01cf9e..946fee7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,8 +1,50 @@ #![deny(clippy::all)] +use std::fs::File; + +use napi::bindgen_prelude::{Env, Reference}; use napi_derive::napi; +mod entry; + +#[napi] +pub struct Archive { + inner: tar::Archive, +} + #[napi] -pub fn plus_100(input: u32) -> u32 { - input + 100 +impl Archive { + #[napi(constructor)] + /// Create a new archive with the underlying path. + pub fn new(path: String) -> napi::Result { + let file = File::open(path)?; + let inner = tar::Archive::new(file); + Ok(Self { inner }) + } + + #[napi] + pub fn entries( + &mut self, + this: Reference, + env: Env, + ) -> napi::Result { + let entries = this.share_with(env, |archive| Ok(archive.inner.entries()?))?; + + Ok(crate::entry::Entries { inner: entries }) + } + + #[napi] + /// Unpacks the contents tarball into the specified `dst`. + /// + /// This function will iterate over the entire contents of this tarball, + /// extracting each file in turn to the location specified by the entry's + /// path name. + /// + /// This operation is relatively sensitive in that it will not write files + /// outside of the path specified by `dst`. Files in the archive which have + /// a '..' in their path are skipped during the unpacking process. + pub fn unpack(&mut self, to: String) -> napi::Result<()> { + self.inner.unpack(to)?; + Ok(()) + } } diff --git a/yarn.lock b/yarn.lock index 0dec53c..499a28b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -146,14 +146,15 @@ __metadata: languageName: node linkType: hard -"@napi-rs/package-template@workspace:.": +"@napi-rs/tar@workspace:.": version: 0.0.0-use.local - resolution: "@napi-rs/package-template@workspace:." + resolution: "@napi-rs/tar@workspace:." dependencies: "@napi-rs/cli": "npm:^2.16.4" "@swc-node/register": "npm:^1.6.8" "@swc/core": "npm:^1.3.95" "@taplo/cli": "npm:^0.5.2" + "@types/node": "npm:^20.10.2" "@typescript-eslint/eslint-plugin": "npm:^6.9.1" "@typescript-eslint/parser": "npm:^6.9.1" ava: "npm:^5.3.1" @@ -430,6 +431,15 @@ __metadata: languageName: node linkType: hard +"@types/node@npm:^20.10.2": + version: 20.10.2 + resolution: "@types/node@npm:20.10.2" + dependencies: + undici-types: "npm:~5.26.4" + checksum: c24630d6bdd237f538d69886868fc29abba8c59f58996b6a6267c42e2253a84a18834c09408b3d887ec74f69e6828e25e3d23cf6fa0daac5902afccaf0568d7e + languageName: node + linkType: hard + "@types/semver@npm:^7.5.0": version: 7.5.4 resolution: "@types/semver@npm:7.5.4" @@ -4647,6 +4657,13 @@ __metadata: languageName: node linkType: hard +"undici-types@npm:~5.26.4": + version: 5.26.5 + resolution: "undici-types@npm:5.26.5" + checksum: bb673d7876c2d411b6eb6c560e0c571eef4a01c1c19925175d16e3a30c4c428181fb8d7ae802a261f283e4166a0ac435e2f505743aa9e45d893f9a3df017b501 + languageName: node + linkType: hard + "unique-filename@npm:^3.0.0": version: 3.0.0 resolution: "unique-filename@npm:3.0.0"