From e5f4fe56ccd0245e4a19e5f1c9d57cd013464a88 Mon Sep 17 00:00:00 2001 From: Bailey Pearson Date: Wed, 13 Nov 2024 10:11:43 -0700 Subject: [PATCH] feat!(NODE-6542): remove all Rust from mongodb-js/zstd (#29) --- .cargo/config.toml | 5 - .github/dependabot.yml | 19 -- .github/workflows/CI.yml | 389 ------------------------------ .gitignore | 2 - .npmignore | 3 - Cargo.toml | 23 -- bindings.js | 155 ------------ build.rs | 5 - index.d.ts | 5 - index.js | 3 - npm/darwin-arm64/README.md | 3 - npm/darwin-arm64/package.json | 18 -- npm/darwin-x64/README.md | 3 - npm/darwin-x64/package.json | 18 -- npm/linux-arm64-gnu/README.md | 3 - npm/linux-arm64-gnu/package.json | 18 -- npm/linux-arm64-musl/README.md | 3 - npm/linux-arm64-musl/package.json | 21 -- npm/linux-x64-gnu/README.md | 3 - npm/linux-x64-gnu/package.json | 18 -- npm/linux-x64-musl/README.md | 3 - npm/linux-x64-musl/package.json | 21 -- npm/win32-arm64-msvc/README.md | 3 - npm/win32-arm64-msvc/package.json | 18 -- npm/win32-x64-msvc/README.md | 3 - npm/win32-x64-msvc/package.json | 18 -- package-lock.json | 23 -- package.json | 34 --- rustfmt.toml | 1 - src/lib.rs | 75 ------ 30 files changed, 916 deletions(-) delete mode 100644 .cargo/config.toml delete mode 100644 .github/workflows/CI.yml delete mode 100644 Cargo.toml delete mode 100644 bindings.js delete mode 100644 build.rs delete mode 100644 npm/darwin-arm64/README.md delete mode 100644 npm/darwin-arm64/package.json delete mode 100644 npm/darwin-x64/README.md delete mode 100644 npm/darwin-x64/package.json delete mode 100644 npm/linux-arm64-gnu/README.md delete mode 100644 npm/linux-arm64-gnu/package.json delete mode 100644 npm/linux-arm64-musl/README.md delete mode 100644 npm/linux-arm64-musl/package.json delete mode 100644 npm/linux-x64-gnu/README.md delete mode 100644 npm/linux-x64-gnu/package.json delete mode 100644 npm/linux-x64-musl/README.md delete mode 100644 npm/linux-x64-musl/package.json delete mode 100644 npm/win32-arm64-msvc/README.md delete mode 100644 npm/win32-arm64-msvc/package.json delete mode 100644 npm/win32-x64-msvc/README.md delete mode 100644 npm/win32-x64-msvc/package.json delete mode 100644 rustfmt.toml delete mode 100644 src/lib.rs diff --git a/.cargo/config.toml b/.cargo/config.toml deleted file mode 100644 index 2afeb28..0000000 --- a/.cargo/config.toml +++ /dev/null @@ -1,5 +0,0 @@ -[target.aarch64-unknown-linux-gnu] -linker = "aarch64-linux-gnu-gcc" -[target.aarch64-unknown-linux-musl] -linker = "aarch64-linux-musl-gcc" -rustflags = ["-C", "target-feature=-crt-static"] diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 594cfc5..d7b66d1 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -21,28 +21,9 @@ updates: versions: [">=16.0.0"] # we ignore TS as a part of quarterly dependency updates. - dependency-name: "typescript" - # changes to the CLI change the auto generated output - # we maintain the generated output explicitly, so we cannot - # upgrade without also manually updating this file. - - dependency-name: "@napi-rs/cli" allow: - dependency-type: "development" - groups: - development-dependencies: - dependency-type: "development" - applies-to: version-updates - update-types: - - "minor" - - "patch" - - - package-ecosystem: "cargo" # See documentation for possible values - directory: "/" # Location of package manifests - schedule: - interval: "monthly" - allow: - - dependency-type: "development" - groups: development-dependencies: dependency-type: "development" diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml deleted file mode 100644 index 818e307..0000000 --- a/.github/workflows/CI.yml +++ /dev/null @@ -1,389 +0,0 @@ -name: CI -env: - DEBUG: napi:* - APP_NAME: zstd - MACOSX_DEPLOYMENT_TARGET: '10.13' -'on': - push: - branches: - - main - tags-ignore: - - '**' - paths-ignore: - - '**/*.md' - - LICENSE - - '**/*.gitignore' - - .editorconfig - - docs/** - pull_request: null -jobs: - build: - if: "!contains(github.event.head_commit.message, 'skip ci')" - strategy: - fail-fast: false - matrix: - settings: - - host: macos-latest - target: x86_64-apple-darwin - architecture: x64 - build: | - npm run build -- --target x86_64-apple-darwin - strip -x *.node - - host: windows-latest - build: npm run build - target: x86_64-pc-windows-msvc - architecture: x64 - - host: ubuntu-latest - target: x86_64-unknown-linux-gnu - architecture: x64 - docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine-zig - build: >- - set -e && - rustup target add x86_64-unknown-linux-gnu && - npm run build -- --target x86_64-unknown-linux-gnu --zig --zig-abi-suffix 2.12 && - llvm-strip -x *.node - - host: ubuntu-latest - target: x86_64-unknown-linux-musl - docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine - build: set -e && npm run build && strip *.node - - host: macos-latest - architecture: x64 - target: aarch64-apple-darwin - build: | - sudo rm -Rf /Library/Developer/CommandLineTools/SDKs/*; - export CC=$(xcrun -f clang); - export CXX=$(xcrun -f clang++); - SYSROOT=$(xcrun --sdk macosx --show-sdk-path); - export CFLAGS="-isysroot $SYSROOT -isystem $SYSROOT"; - npm run build -- --target aarch64-apple-darwin - strip -x *.node - - host: ubuntu-latest - architecture: x64 - target: aarch64-unknown-linux-gnu - docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine-zig - build: >- - set -e && - rustup target add aarch64-unknown-linux-gnu && - npm run build -- --target aarch64-unknown-linux-gnu --zig --zig-abi-suffix 2.17 && - llvm-strip -x *.node - - host: ubuntu-latest - target: aarch64-unknown-linux-musl - docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine - build: |- - set -e && - rustup target add aarch64-unknown-linux-musl && - npm run build -- --target aarch64-unknown-linux-musl && - /aarch64-linux-musl-cross/bin/aarch64-linux-musl-strip *.node - name: stable - ${{ matrix.settings.target }} - node@20 - runs-on: ${{ matrix.settings.host }} - steps: - - uses: actions/checkout@v3 - - name: Setup node - uses: actions/setup-node@v3 - with: - node-version: 20 - check-latest: true - cache: npm - architecture: ${{ matrix.settings.architecture }} - - name: Install - uses: actions-rs/toolchain@v1 - if: ${{ !matrix.settings.docker }} - with: - profile: minimal - override: true - toolchain: stable - target: ${{ matrix.settings.target }} - - name: Generate Cargo.lock - uses: actions-rs/cargo@v1 - if: ${{ !matrix.settings.docker }} - with: - command: generate-lockfile - - name: Cache cargo registry - uses: actions/cache@v3 - with: - path: ~/.cargo/registry - key: ${{ matrix.settings.target }}-cargo-registry - - name: Cache cargo index - uses: actions/cache@v3 - with: - path: ~/.cargo/git - key: ${{ matrix.settings.target }}-cargo-index - - name: Cache NPM dependencies - uses: actions/cache@v3 - with: - path: node_modules - key: npm-cache-build-${{ matrix.settings.target }}-node@16 - - name: Setup toolchain - run: ${{ matrix.settings.setup }} - if: ${{ matrix.settings.setup }} - shell: bash - - name: Install dependencies - run: npm clean-install --ignore-scripts - - name: Build in docker - uses: addnab/docker-run-action@v3 - if: ${{ matrix.settings.docker }} - with: - image: ${{ matrix.settings.docker }} - options: -v ${{ env.HOME }}/.cargo/git:/root/.cargo/git -v ${{ env.HOME }}/.cargo/registry:/root/.cargo/registry -v ${{ github.workspace }}:/build -w /build - run: ${{ matrix.settings.build }} - - - name: 'Build' - run: ${{ matrix.settings.build }} - if: ${{ !matrix.settings.docker }} - shell: bash - - name: Upload artifact - uses: actions/upload-artifact@v4 - with: - name: bindings-${{ matrix.settings.target }} - path: ${{ env.APP_NAME }}.*.node - if-no-files-found: error - test-macOS-windows-binding: - name: Test bindings on ${{ matrix.settings.target }} - node@${{ matrix.node }} - needs: - - build - strategy: - fail-fast: false - matrix: - settings: - - host: windows-latest - target: x86_64-pc-windows-msvc - node: - - '12' - - '14' - - '16' - - '18' - - '20' - runs-on: ${{ matrix.settings.host }} - steps: - - uses: actions/checkout@v3 - - name: Setup node - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node }} - check-latest: true - cache: npm - - name: Cache NPM dependencies - uses: actions/cache@v3 - with: - path: node_modules - key: npm-cache-test-${{ matrix.settings.target }}-${{ matrix.node }}-${{ hashFiles('package-lock.json') }} - - name: Install dependencies - run: npm clean-install --ignore-scripts - - name: Download artifacts - uses: actions/download-artifact@v4 - with: - name: bindings-${{ matrix.settings.target }} - path: . - - name: List packages - run: ls -R . - shell: bash - - name: Test bindings - run: npm test - test-linux-x64-gnu-binding: - name: Test bindings on Linux-x64-gnu - node@${{ matrix.node }} - needs: - - build - strategy: - fail-fast: false - matrix: - node: - - '12' - - '14' - - '16' - - '18' - - '20' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Setup node - uses: actions/setup-node@v2 - with: - node-version: ${{ matrix.node }} - check-latest: true - cache: npm - - name: Cache NPM dependencies - uses: actions/cache@v2 - with: - path: node_modules - key: npm-cache-test-linux-x64-gnu-${{ matrix.node }}-${{ hashFiles('package-lock.json') }} - - name: Install dependencies - run: npm clean-install --ignore-scripts - - name: Download artifacts - uses: actions/download-artifact@v4 - with: - name: bindings-x86_64-unknown-linux-gnu - path: . - - name: List packages - run: ls -R . - shell: bash - - name: Test bindings - run: docker run --rm -v $(pwd):/build -w /build node:${{ matrix.node }}-slim npm test - test-linux-x64-musl-binding: - name: Test bindings on x86_64-unknown-linux-musl - node@${{ matrix.node }} - needs: - - build - strategy: - fail-fast: false - matrix: - node: - - '12' - - '14' - - '16' - - '18' - - '20' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Setup node - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node }} - check-latest: true - cache: npm - - name: Cache NPM dependencies - uses: actions/cache@v3 - with: - path: node_modules - key: npm-cache-test-x86_64-unknown-linux-musl-${{ matrix.node }}-${{ hashFiles('package-lock.json') }} - - name: Install dependencies - run: npm clean-install --ignore-scripts - - name: Download artifacts - uses: actions/download-artifact@v4 - with: - name: bindings-x86_64-unknown-linux-musl - path: . - - name: List packages - run: ls -R . - shell: bash - - name: Test bindings - run: docker run --rm -v $(pwd):/build -w /build node:${{ matrix.node }}-alpine npm test - test-linux-aarch64-gnu-binding: - name: Test bindings on aarch64-unknown-linux-gnu - node@${{ matrix.node }} - needs: - - build - strategy: - fail-fast: false - matrix: - node: - - '12' - - '14' - - '16' - - '18' - - '20' - runs-on: ubuntu-latest - steps: - - run: docker run --rm --privileged multiarch/qemu-user-static:register --reset - - uses: actions/checkout@v3 - - name: Download artifacts - uses: actions/download-artifact@v4 - with: - name: bindings-aarch64-unknown-linux-gnu - path: . - - name: List packages - run: ls -R . - shell: bash - - name: Cache NPM dependencies - uses: actions/cache@v3 - with: - path: node_modules - key: npm-cache-test-linux-aarch64-gnu-${{ matrix.node }}-${{ hashFiles('package-lock.json') }} - - name: Install dependencies - run: npm clean-install --ignore-scripts - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - with: - platforms: arm64 - - name: Run Emulator - run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - - name: Setup and run tests - uses: addnab/docker-run-action@v3 - with: - image: node:${{ matrix.node }}-slim - options: '--platform linux/arm64 -v ${{ github.workspace }}:/build -w /build' - run: | - set -e - npm test - ls -la - test-linux-aarch64-musl-binding: - name: Test bindings on aarch64-unknown-linux-musl - node@${{ matrix.node }} - needs: - - build - runs-on: ubuntu-latest - steps: - - run: docker run --rm --privileged multiarch/qemu-user-static:register --reset - - uses: actions/checkout@v3 - - name: Download artifacts - uses: actions/download-artifact@v4 - with: - name: bindings-aarch64-unknown-linux-musl - path: . - - name: List packages - run: ls -R . - shell: bash - - name: Cache NPM dependencies - uses: actions/cache@v3 - with: - path: node_modules - key: npm-cache-test-linux-aarch64-musl-${{ matrix.node }}-${{ hashFiles('package-lock.json') }} - - name: Install dependencies - run: npm clean-install --ignore-scripts - - name: Setup and run tests - uses: addnab/docker-run-action@v3 - with: - image: multiarch/alpine:aarch64-latest-stable - options: '-v ${{ github.workspace }}:/build -w /build' - run: | - set -e - apk add nodejs npm - npm test - publish: - name: Publish - runs-on: ubuntu-latest - needs: - - test-macOS-windows-binding - - test-linux-x64-gnu-binding - - test-linux-x64-musl-binding - - test-linux-aarch64-gnu-binding - - test-linux-aarch64-musl-binding - steps: - - uses: actions/checkout@v3 - - name: Setup node - uses: actions/setup-node@v3 - with: - node-version: 16 - check-latest: true - cache: npm - - name: Cache NPM dependencies - uses: actions/cache@v3 - with: - path: node_modules - key: npm-cache-ubuntu-latest-${{ hashFiles('package-lock.json') }} - restore-keys: | - npm-cache- - - name: Install dependencies - run: npm clean-install --ignore-scripts - - name: Download all artifacts - uses: actions/download-artifact@v4 - with: - path: artifacts - - name: Move artifacts - run: npm run artifacts - - name: List packages - run: ls -R ./npm - shell: bash - - name: Publish - run: | - if git log -1 --pretty=%B | grep "^chore(release): [0-9]\+\.[0-9]\+\.[0-9]\+$"; - then - echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc - npm publish --access public - elif git log -1 --pretty=%B | grep "^chore(release): [0-9]\+\.[0-9]\+\.[0-9]\+"; - then - echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc - npm publish --tag next --access public - else - echo "Not a release, skipping publish" - fi - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.gitignore b/.gitignore index 62e04d4..fd45b04 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,6 @@ lib-cov *.pid *.gz *.node -target/ .DS_Store .vscode @@ -19,4 +18,3 @@ node_modules build npm-debug.log -Cargo.lock diff --git a/.npmignore b/.npmignore index f96abe0..1061647 100644 --- a/.npmignore +++ b/.npmignore @@ -1,6 +1,3 @@ -target -Cargo.lock -.cargo .github npm .eslintrc diff --git a/Cargo.toml b/Cargo.toml deleted file mode 100644 index c041c0a..0000000 --- a/Cargo.toml +++ /dev/null @@ -1,23 +0,0 @@ -[package] -edition = "2021" -name = "mongodb-js_zstd" -version = "0.0.0" - -[lib] -crate-type = ["cdylib"] - -[dependencies] -futures = "0.3" -napi = { version = "2.4.3", default-features = false, features = [ - "napi8", - "async" -] } -napi-derive = "2.4.1" -zstd = "0.11" -zstd-sys = "2.0.8" - -[build-dependencies] -napi-build = "2.0.0" - -[profile.release] -lto = true diff --git a/bindings.js b/bindings.js deleted file mode 100644 index e411226..0000000 --- a/bindings.js +++ /dev/null @@ -1,155 +0,0 @@ -const { existsSync, readFileSync } = require('fs'); -const { join } = require('path'); - -const { platform, arch } = process; - -let nativeBinding = null; -let localFileExisted = false; -let loadError = null; - -function isMusl() { - // For Node 10 - if (!process.report || typeof process.report.getReport !== 'function') { - try { - return readFileSync('/usr/bin/ldd', 'utf8').includes('musl'); - } catch (e) { - return true; - } - } else { - const { glibcVersionRuntime } = process.report.getReport().header; - return !glibcVersionRuntime; - } -} - -switch (platform) { - case 'win32': - switch (arch) { - case 'x64': - localFileExisted = existsSync(join(__dirname, 'zstd.win32-x64-msvc.node')); - try { - if (localFileExisted) { - nativeBinding = require('./zstd.win32-x64-msvc.node'); - } else { - nativeBinding = require('@mongodb-js/zstd-win32-x64-msvc'); - } - } catch (e) { - loadError = e; - } - break; - default: - throw new Error(`Unsupported architecture on Windows: ${arch}`); - } - break; - case 'darwin': - switch (arch) { - case 'x64': - localFileExisted = existsSync(join(__dirname, 'zstd.darwin-x64.node')); - try { - if (localFileExisted) { - nativeBinding = require('./zstd.darwin-x64.node'); - } else { - nativeBinding = require('@mongodb-js/zstd-darwin-x64'); - } - } catch (e) { - loadError = e; - } - break; - case 'arm64': - localFileExisted = existsSync(join(__dirname, 'zstd.darwin-arm64.node')); - try { - if (localFileExisted) { - nativeBinding = require('./zstd.darwin-arm64.node'); - } else { - nativeBinding = require('@mongodb-js/zstd-darwin-arm64'); - } - } catch (e) { - loadError = e; - } - break; - default: - throw new Error(`Unsupported architecture on macOS: ${arch}`); - } - break; - case 'linux': - switch (arch) { - case 'x64': - if (isMusl()) { - localFileExisted = existsSync(join(__dirname, 'zstd.linux-x64-musl.node')); - try { - if (localFileExisted) { - nativeBinding = require('./zstd.linux-x64-musl.node'); - } else { - nativeBinding = require('@mongodb-js/zstd-linux-x64-musl'); - } - } catch (e) { - loadError = e; - } - } else { - localFileExisted = existsSync(join(__dirname, 'zstd.linux-x64-gnu.node')); - try { - if (localFileExisted) { - nativeBinding = require('./zstd.linux-x64-gnu.node'); - } else { - nativeBinding = require('@mongodb-js/zstd-linux-x64-gnu'); - } - } catch (e) { - loadError = e; - } - } - break; - case 'arm64': - if (isMusl()) { - localFileExisted = existsSync(join(__dirname, 'zstd.linux-arm64-musl.node')); - try { - if (localFileExisted) { - nativeBinding = require('./zstd.linux-arm64-musl.node'); - } else { - nativeBinding = require('@mongodb-js/zstd-linux-arm64-musl'); - } - } catch (e) { - loadError = e; - } - } else { - localFileExisted = existsSync(join(__dirname, 'zstd.linux-arm64-gnu.node')); - try { - if (localFileExisted) { - nativeBinding = require('./zstd.linux-arm64-gnu.node'); - } else { - nativeBinding = require('@mongodb-js/zstd-linux-arm64-gnu'); - } - } catch (e) { - loadError = e; - } - } - break; - case 'arm': - localFileExisted = existsSync(join(__dirname, 'zstd.linux-arm-gnueabihf.node')); - try { - if (localFileExisted) { - nativeBinding = require('./zstd.linux-arm-gnueabihf.node'); - } else { - nativeBinding = require('@mongodb-js/zstd-linux-arm-gnueabihf'); - } - } catch (e) { - loadError = e; - } - break; - default: - throw new Error(`Unsupported architecture on Linux: ${arch}`); - } - break; - default: - throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`); -} - -if (!nativeBinding) { - if (loadError) { - throw loadError; - } - throw new Error(`Failed to load native binding`); -} - -const { compress, decompress } = nativeBinding; - -module.exports.compress = compress; -module.exports.decompress = decompress; diff --git a/build.rs b/build.rs deleted file mode 100644 index 1f866b6..0000000 --- a/build.rs +++ /dev/null @@ -1,5 +0,0 @@ -extern crate napi_build; - -fn main() { - napi_build::setup(); -} diff --git a/index.d.ts b/index.d.ts index a56ed6b..563c83c 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,7 +1,2 @@ -/* tslint:disable */ -/* eslint-disable */ - -/* auto-generated by NAPI-RS */ - export declare function compress(data: Buffer, level?: number | undefined | null): Promise export declare function decompress(data: Buffer): Promise diff --git a/index.js b/index.js index 422ca93..0425367 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,3 @@ -// NB: If you update any type signatures to diverge from bindings itself, make -// sure to update how index.d.ts is generated (napi build --dts ...) - const { compress: _compress, decompress: _decompress } = require('./bindings'); // Error objects created via napi don't have JS stacks; wrap them so .stack is present diff --git a/npm/darwin-arm64/README.md b/npm/darwin-arm64/README.md deleted file mode 100644 index 1faeb2e..0000000 --- a/npm/darwin-arm64/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# `@mongodb-js/zstd-darwin-arm64` - -This is the **aarch64-apple-darwin** binary for `@mongodb-js/zstd` diff --git a/npm/darwin-arm64/package.json b/npm/darwin-arm64/package.json deleted file mode 100644 index 15dedea..0000000 --- a/npm/darwin-arm64/package.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "@mongodb-js/zstd-darwin-arm64", - "version": "0.0.0", - "os": [ - "darwin" - ], - "cpu": [ - "arm64" - ], - "main": "zstd.darwin-arm64.node", - "files": [ - "zstd.darwin-arm64.node" - ], - "license": "MIT", - "engines": { - "node": ">= 10" - } -} \ No newline at end of file diff --git a/npm/darwin-x64/README.md b/npm/darwin-x64/README.md deleted file mode 100644 index b76fc49..0000000 --- a/npm/darwin-x64/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# `@mongodb-js/zstd-darwin-x64` - -This is the **x86_64-apple-darwin** binary for `@mongodb-js/zstd` diff --git a/npm/darwin-x64/package.json b/npm/darwin-x64/package.json deleted file mode 100644 index 49eef0f..0000000 --- a/npm/darwin-x64/package.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "@mongodb-js/zstd-darwin-x64", - "version": "0.0.0", - "os": [ - "darwin" - ], - "cpu": [ - "x64" - ], - "main": "zstd.darwin-x64.node", - "files": [ - "zstd.darwin-x64.node" - ], - "license": "MIT", - "engines": { - "node": ">= 10" - } -} \ No newline at end of file diff --git a/npm/linux-arm64-gnu/README.md b/npm/linux-arm64-gnu/README.md deleted file mode 100644 index f369eae..0000000 --- a/npm/linux-arm64-gnu/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# `@mongodb-js/zstd-linux-arm64-gnu` - -This is the **aarch64-unknown-linux-gnu** binary for `@mongodb-js/zstd` diff --git a/npm/linux-arm64-gnu/package.json b/npm/linux-arm64-gnu/package.json deleted file mode 100644 index 2196a37..0000000 --- a/npm/linux-arm64-gnu/package.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "@mongodb-js/zstd-linux-arm64-gnu", - "version": "0.0.0", - "os": [ - "linux" - ], - "cpu": [ - "arm64" - ], - "main": "zstd.linux-arm64-gnu.node", - "files": [ - "zstd.linux-arm64-gnu.node" - ], - "license": "MIT", - "engines": { - "node": ">= 10" - } -} \ No newline at end of file diff --git a/npm/linux-arm64-musl/README.md b/npm/linux-arm64-musl/README.md deleted file mode 100644 index 7547d39..0000000 --- a/npm/linux-arm64-musl/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# `@mongodb-js/zstd-linux-arm64-musl` - -This is the **aarch64-unknown-linux-musl** binary for `@mongodb-js/zstd` diff --git a/npm/linux-arm64-musl/package.json b/npm/linux-arm64-musl/package.json deleted file mode 100644 index 9088e85..0000000 --- a/npm/linux-arm64-musl/package.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "@mongodb-js/zstd-linux-arm64-musl", - "version": "0.0.0", - "os": [ - "linux" - ], - "cpu": [ - "arm64" - ], - "main": "zstd.linux-arm64-musl.node", - "files": [ - "zstd.linux-arm64-musl.node" - ], - "license": "MIT", - "engines": { - "node": ">= 10" - }, - "libc": [ - "musl" - ] -} diff --git a/npm/linux-x64-gnu/README.md b/npm/linux-x64-gnu/README.md deleted file mode 100644 index d976660..0000000 --- a/npm/linux-x64-gnu/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# `@mongodb-js/zstd-linux-x64-gnu` - -This is the **x86_64-unknown-linux-gnu** binary for `@mongodb-js/zstd` diff --git a/npm/linux-x64-gnu/package.json b/npm/linux-x64-gnu/package.json deleted file mode 100644 index 6555ee9..0000000 --- a/npm/linux-x64-gnu/package.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "@mongodb-js/zstd-linux-x64-gnu", - "version": "0.0.0", - "os": [ - "linux" - ], - "cpu": [ - "x64" - ], - "main": "zstd.linux-x64-gnu.node", - "files": [ - "zstd.linux-x64-gnu.node" - ], - "license": "MIT", - "engines": { - "node": ">= 10" - } -} \ No newline at end of file diff --git a/npm/linux-x64-musl/README.md b/npm/linux-x64-musl/README.md deleted file mode 100644 index d656011..0000000 --- a/npm/linux-x64-musl/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# `@mongodb-js/zstd-linux-x64-musl` - -This is the **x86_64-unknown-linux-musl** binary for `@mongodb-js/zstd` diff --git a/npm/linux-x64-musl/package.json b/npm/linux-x64-musl/package.json deleted file mode 100644 index ebcebe2..0000000 --- a/npm/linux-x64-musl/package.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "@mongodb-js/zstd-linux-x64-musl", - "version": "0.0.0", - "os": [ - "linux" - ], - "cpu": [ - "x64" - ], - "main": "zstd.linux-x64-musl.node", - "files": [ - "zstd.linux-x64-musl.node" - ], - "license": "MIT", - "engines": { - "node": ">= 10" - }, - "libc": [ - "musl" - ] -} diff --git a/npm/win32-arm64-msvc/README.md b/npm/win32-arm64-msvc/README.md deleted file mode 100644 index 7df2609..0000000 --- a/npm/win32-arm64-msvc/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# `@mongodb-js/zstd-win32-arm64-msvc` - -This is the **aarch64-pc-windows-msvc** binary for `@mongodb-js/zstd` diff --git a/npm/win32-arm64-msvc/package.json b/npm/win32-arm64-msvc/package.json deleted file mode 100644 index 144a42b..0000000 --- a/npm/win32-arm64-msvc/package.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "@mongodb-js/zstd-win32-arm64-msvc", - "version": "0.0.0", - "os": [ - "win32" - ], - "cpu": [ - "arm64" - ], - "main": "zstd.win32-arm64-msvc.node", - "files": [ - "zstd.win32-arm64-msvc.node" - ], - "license": "MIT", - "engines": { - "node": ">= 10" - } -} \ No newline at end of file diff --git a/npm/win32-x64-msvc/README.md b/npm/win32-x64-msvc/README.md deleted file mode 100644 index 36b3e94..0000000 --- a/npm/win32-x64-msvc/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# `@mongodb-js/zstd-win32-x64-msvc` - -This is the **x86_64-pc-windows-msvc** binary for `@mongodb-js/zstd` diff --git a/npm/win32-x64-msvc/package.json b/npm/win32-x64-msvc/package.json deleted file mode 100644 index 9733820..0000000 --- a/npm/win32-x64-msvc/package.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "@mongodb-js/zstd-win32-x64-msvc", - "version": "0.0.0", - "os": [ - "win32" - ], - "cpu": [ - "x64" - ], - "main": "zstd.win32-x64-msvc.node", - "files": [ - "zstd.win32-x64-msvc.node" - ], - "license": "MIT", - "engines": { - "node": ">= 10" - } -} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 563fa63..4611cfc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,6 @@ "version": "1.2.2", "license": "Apache-2.0", "devDependencies": { - "@napi-rs/cli": "^2.18.2", "chai": "^4.5.0", "mocha": "^10.8.2", "prettier": "^3.3.3", @@ -134,22 +133,6 @@ "node": ">=6.9.0" } }, - "node_modules/@napi-rs/cli": { - "version": "2.18.2", - "resolved": "https://registry.npmjs.org/@napi-rs/cli/-/cli-2.18.2.tgz", - "integrity": "sha512-IXQji3IF5eStxTHe/PxDSRjPrFymYAQ5FbIvqurxzxyWR8nJql9mtvmCP8y2g8tSoW5xhaToLQW0+mO3lUZq4w==", - "dev": true, - "bin": { - "napi": "scripts/index.js" - }, - "engines": { - "node": ">= 10" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/Brooooooklyn" - } - }, "node_modules/@types/minimist": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/@types/minimist/-/minimist-1.2.2.tgz", @@ -3031,12 +3014,6 @@ "integrity": "sha512-H9XAx3hc0BQHY6l+IFSWHDySypcXsvsuLhgYLUGywmJ5pswRVQJUHpOsobnLYp2ZUaUlKiKDrgWWhosOwAEM8Q==", "dev": true }, - "@napi-rs/cli": { - "version": "2.18.2", - "resolved": "https://registry.npmjs.org/@napi-rs/cli/-/cli-2.18.2.tgz", - "integrity": "sha512-IXQji3IF5eStxTHe/PxDSRjPrFymYAQ5FbIvqurxzxyWR8nJql9mtvmCP8y2g8tSoW5xhaToLQW0+mO3lUZq4w==", - "dev": true - }, "@types/minimist": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/@types/minimist/-/minimist-1.2.2.tgz", diff --git a/package.json b/package.json index 1baf724..22865a4 100644 --- a/package.json +++ b/package.json @@ -4,29 +4,12 @@ "main": "index.js", "types": "index.d.ts", "repository": "https://github.com/mongodb-js/zstd", - "napi": { - "name": "zstd", - "package": { - "name": "@mongodb-js/zstd" - }, - "triples": { - "defaults": true, - "additional": [ - "aarch64-apple-darwin", - "aarch64-unknown-linux-gnu", - "aarch64-unknown-linux-musl", - "x86_64-unknown-linux-musl" - ] - } - }, "files": [ - "bindings.js", "index.d.ts", "index.js" ], "license": "Apache-2.0", "devDependencies": { - "@napi-rs/cli": "^2.18.2", "chai": "^4.5.0", "mocha": "^10.8.2", "prettier": "^3.3.3", @@ -35,23 +18,6 @@ "engines": { "node": ">= 10" }, - "prettier": { - "printWidth": 100, - "tabWidth": 2, - "semi": true, - "trailingComma": "none", - "singleQuote": true, - "arrowParens": "avoid" - }, "scripts": { - "artifacts": "napi artifacts", - "build": "napi build --js bindings.js --platform --release", - "build:debug": "napi build --js bindings.js --platform", - "format:js": "prettier --config ./package.json --write *.js", - "format:rs": "cargo fmt", - "prepublishOnly": "napi prepublish -t npm", - "release": "standard-version -i HISTORY.md", - "test": "mocha --recursive test/", - "version": "napi version" } } diff --git a/rustfmt.toml b/rustfmt.toml deleted file mode 100644 index b196eaa..0000000 --- a/rustfmt.toml +++ /dev/null @@ -1 +0,0 @@ -tab_spaces = 2 diff --git a/src/lib.rs b/src/lib.rs deleted file mode 100644 index c10a3e8..0000000 --- a/src/lib.rs +++ /dev/null @@ -1,75 +0,0 @@ -#[macro_use] -extern crate napi_derive; - -use napi::{ - bindgen_prelude::AsyncTask, Env, Error, JsBuffer, JsBufferValue, Ref, Result, Status, Task, -}; -use zstd::stream::{decode_all, encode_all}; - -const DEFAULT_LEVEL: i32 = 3; - -struct Encoder { - data: Ref, - level: i32, -} - -#[napi] -impl Task for Encoder { - type Output = Vec; - type JsValue = JsBuffer; - - fn compute(&mut self) -> Result { - let data: &[u8] = self.data.as_ref(); - encode_all(data, self.level).map_err(|e| Error::new(Status::GenericFailure, format!("{}", e))) - } - - fn resolve(&mut self, env: Env, output: Self::Output) -> Result { - env.create_buffer_with_data(output).map(|b| b.into_raw()) - } - - fn finally(&mut self, env: Env) -> Result<()> { - self.data.unref(env)?; - Ok(()) - } -} - -struct Decoder { - data: Ref, -} - -#[napi] -impl Task for Decoder { - type Output = Vec; - type JsValue = JsBuffer; - - fn compute(&mut self) -> Result { - let data: &[u8] = self.data.as_ref(); - decode_all(data).map_err(|e| Error::new(Status::GenericFailure, format!("{}", e))) - } - - fn resolve(&mut self, env: Env, output: Self::Output) -> Result { - env.create_buffer_with_data(output).map(|b| b.into_raw()) - } - - fn finally(&mut self, env: Env) -> Result<()> { - self.data.unref(env)?; - Ok(()) - } -} - -#[napi] -fn compress(data: JsBuffer, level: Option) -> Result> { - let encoder = Encoder { - data: data.into_ref()?, - level: level.unwrap_or(DEFAULT_LEVEL), - }; - Ok(AsyncTask::new(encoder)) -} - -#[napi] -fn decompress(data: JsBuffer) -> Result> { - let decoder = Decoder { - data: data.into_ref()?, - }; - Ok(AsyncTask::new(decoder)) -}