Skip to content

Commit

Permalink
chore: upgrade dependencies and CI template
Browse files Browse the repository at this point in the history
  • Loading branch information
Brooooooklyn committed Nov 7, 2023
1 parent d7aaa79 commit d9f0c28
Show file tree
Hide file tree
Showing 10 changed files with 3,510 additions and 3,028 deletions.
38 changes: 18 additions & 20 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ jobs:
- uses: goto-bus-stop/setup-zig@v2
if: ${{ matrix.settings.target == 'armv7-unknown-linux-gnueabihf' }}
with:
version: 0.10.1
version: 0.11.0
- name: Setup toolchain
run: ${{ matrix.settings.setup }}
if: ${{ matrix.settings.setup }}
Expand Down Expand Up @@ -164,37 +164,38 @@ jobs:
- uses: actions/checkout@v4
- name: Build
id: build
uses: vmactions/freebsd-vm@v0
uses: cross-platform-actions/action@v0.21.1
env:
DEBUG: napi:*
RUSTUP_HOME: /usr/local/rustup
CARGO_HOME: /usr/local/cargo
RUSTUP_IO_THREADS: 1
with:
envs: DEBUG RUSTUP_HOME CARGO_HOME RUSTUP_IO_THREADS
usesh: true
mem: 3000
prepare: |
pkg install -y -f curl node libnghttp2 npm yarn
operating_system: freebsd
version: '13.2'
memory: 13G
cpu_count: 3
environment_variables: 'DEBUG RUSTUP_IO_THREADS'
shell: bash
run: |
sudo pkg install -y -f curl node libnghttp2 npm yarn
sudo npm install -g yarn --ignore-scripts
curl https://sh.rustup.rs -sSf --output rustup.sh
sh rustup.sh -y --profile minimal --default-toolchain beta
export PATH="/usr/local/cargo/bin:$PATH"
source "$HOME/.cargo/env"
echo "~~~~ rustc --version ~~~~"
rustc --version
echo "~~~~ node -v ~~~~"
node -v
echo "~~~~ yarn --version ~~~~"
yarn --version
run: |
export PATH="/usr/local/cargo/bin:$PATH"
pwd
ls -lah
whoami
env
freebsd-version
yarn install
yarn build
strip -x *.node
yarn test
rm -rf node_modules
rm -rf target
Expand All @@ -218,8 +219,8 @@ jobs:
- host: windows-latest
target: x86_64-pc-windows-msvc
node:
- '16'
- '18'
- '20'
runs-on: ${{ matrix.settings.host }}
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -248,8 +249,8 @@ jobs:
fail-fast: false
matrix:
node:
- '16'
- '18'
- '20'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -279,8 +280,8 @@ jobs:
fail-fast: false
matrix:
node:
- '16'
- '18'
- '20'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -312,9 +313,7 @@ jobs:
fail-fast: false
matrix:
node:
- '14'
- '16'
- '18'
- '20'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -346,7 +345,7 @@ jobs:
yarn test
ls -la
test-linux-aarch64-musl-binding:
name: Test bindings on aarch64-unknown-linux-musl - node@${{ matrix.node }}
name: Test bindings on aarch64-unknown-linux-musl - node@lts
needs:
- build
runs-on: ubuntu-latest
Expand Down Expand Up @@ -386,9 +385,8 @@ jobs:
fail-fast: false
matrix:
node:
- '14'
- '16'
- '18'
- '20'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
874 changes: 0 additions & 874 deletions .yarn/releases/yarn-3.6.4.cjs

This file was deleted.

893 changes: 893 additions & 0 deletions .yarn/releases/yarn-4.0.1.cjs

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
yarnPath: .yarn/releases/yarn-3.6.4.cjs
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-4.0.1.cjs
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ napi = { version = "2", features = ["napi5", "serde-json"] }
napi-derive = { version = "2" }
snap = "1"

[target.'cfg(not(target_os = "linux"))'.dependencies]
[target.'cfg(all(not(target_os = "linux"), not(target_os = "wasi")))'.dependencies]
mimalloc-rust = "0.2"

[target.'cfg(all(target_os = "linux", not(all(target_env = "musl", target_arch = "aarch64"))))'.dependencies]
Expand Down
34 changes: 15 additions & 19 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,42 +1,38 @@
/* tslint:disable */
/* auto-generated by NAPI-RS */
/* eslint-disable */

/* auto-generated by NAPI-RS */
export function compress(input: string | Buffer, options?: EncOptions | undefined | null, signal?: AbortSignal | undefined | null): Promise<Buffer>

export function compressSync(input: string | Buffer, options?: EncOptions | undefined | null): Buffer

export interface DecOptions {
asBuffer?: boolean
/**
* do not use `create_external_buffer` to create the output buffer
* set this option to `true` will make the API slower
* for compatibility with electron >= 21
* see https://www.electronjs.org/blog/v8-memory-cage and https://github.com/electron/electron/issues/35801#issuecomment-1261206333
*/
copyOutputData?: boolean
}

export interface EncOptions {
/**
* do not use `create_external_buffer` to create the output buffer
* for compatibility with electron >= 21
* set this option to `true` will make the API slower
* see https://www.electronjs.org/blog/v8-memory-cage and https://github.com/electron/electron/issues/35801#issuecomment-1261206333
*/
copyOutputData?: boolean
}
export function compressSync(input: string | Buffer, options?: EncOptions | undefined | null): Buffer
export function compress(
input: string | Buffer,
options?: EncOptions | undefined | null,
signal?: AbortSignal | undefined | null,
): Promise<Buffer>

export function uncompress(input: string | Buffer, options?: DecOptions | undefined | null, signal?: AbortSignal | undefined | null): Promise<string | Buffer>

export function uncompressSync(input: string | Buffer, options?: DecOptions | undefined | null): string | Buffer
export function uncompress(
input: string | Buffer,
options?: DecOptions | undefined | null,
signal?: AbortSignal | undefined | null,
): Promise<string | Buffer>

104 changes: 76 additions & 28 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/* tslint:disable */
// prettier-ignore
/* eslint-disable */
/* prettier-ignore */

/* auto-generated by NAPI-RS */

const { existsSync, readFileSync } = require('fs')
Expand All @@ -13,18 +11,52 @@ let nativeBinding = null
let localFileExisted = false
let loadError = null

function isMusl() {
// For Node 10
if (!process.report || typeof process.report.getReport !== 'function') {
try {
const lddPath = require('child_process').execSync('which ldd').toString().trim()
return readFileSync(lddPath, 'utf8').includes('musl')
} catch (e) {
const isMusl = () => {
let musl = false
if (process.platform === 'linux') {
musl = isMuslFromFilesystem()
if (musl === null) {
musl = isMuslFromReport()
}
if (musl === null) {
musl = isMuslFromChildProcess()
}
}
return musl
}

const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-')

const isMuslFromFilesystem = () => {
try {
return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl')
} catch {
return null
}
}

const isMuslFromReport = () => {
const report = typeof process.report.getReport === 'function' ? process.report.getReport() : null
if (!report) {
return null
}
if (report.header && report.header.glibcVersionRuntime) {
return false
}
if (Array.isArray(report.sharedObjects)) {
if (report.sharedObjects.some(isFileMusl)) {
return true
}
} else {
const { glibcVersionRuntime } = process.report.getReport().header
return !glibcVersionRuntime
}
return false
}

const isMuslFromChildProcess = () => {
try {
return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl')
} catch (e) {
// If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
return false
}
}

Expand Down Expand Up @@ -62,7 +94,9 @@ switch (platform) {
case 'win32':
switch (arch) {
case 'x64':
localFileExisted = existsSync(join(__dirname, 'snappy.win32-x64-msvc.node'))
localFileExisted = existsSync(
join(__dirname, 'snappy.win32-x64-msvc.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./snappy.win32-x64-msvc.node')
Expand All @@ -74,7 +108,9 @@ switch (platform) {
}
break
case 'ia32':
localFileExisted = existsSync(join(__dirname, 'snappy.win32-ia32-msvc.node'))
localFileExisted = existsSync(
join(__dirname, 'snappy.win32-ia32-msvc.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./snappy.win32-ia32-msvc.node')
Expand All @@ -86,7 +122,9 @@ switch (platform) {
}
break
case 'arm64':
localFileExisted = existsSync(join(__dirname, 'snappy.win32-arm64-msvc.node'))
localFileExisted = existsSync(
join(__dirname, 'snappy.win32-arm64-msvc.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./snappy.win32-arm64-msvc.node')
Expand Down Expand Up @@ -125,7 +163,9 @@ switch (platform) {
}
break
case 'arm64':
localFileExisted = existsSync(join(__dirname, 'snappy.darwin-arm64.node'))
localFileExisted = existsSync(
join(__dirname, 'snappy.darwin-arm64.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./snappy.darwin-arm64.node')
Expand Down Expand Up @@ -159,7 +199,9 @@ switch (platform) {
switch (arch) {
case 'x64':
if (isMusl()) {
localFileExisted = existsSync(join(__dirname, 'snappy.linux-x64-musl.node'))
localFileExisted = existsSync(
join(__dirname, 'snappy.linux-x64-musl.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./snappy.linux-x64-musl.node')
Expand All @@ -170,7 +212,9 @@ switch (platform) {
loadError = e
}
} else {
localFileExisted = existsSync(join(__dirname, 'snappy.linux-x64-gnu.node'))
localFileExisted = existsSync(
join(__dirname, 'snappy.linux-x64-gnu.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./snappy.linux-x64-gnu.node')
Expand All @@ -184,7 +228,9 @@ switch (platform) {
break
case 'arm64':
if (isMusl()) {
localFileExisted = existsSync(join(__dirname, 'snappy.linux-arm64-musl.node'))
localFileExisted = existsSync(
join(__dirname, 'snappy.linux-arm64-musl.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./snappy.linux-arm64-musl.node')
Expand All @@ -195,7 +241,9 @@ switch (platform) {
loadError = e
}
} else {
localFileExisted = existsSync(join(__dirname, 'snappy.linux-arm64-gnu.node'))
localFileExisted = existsSync(
join(__dirname, 'snappy.linux-arm64-gnu.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./snappy.linux-arm64-gnu.node')
Expand All @@ -208,7 +256,9 @@ switch (platform) {
}
break
case 'arm':
localFileExisted = existsSync(join(__dirname, 'snappy.linux-arm-gnueabihf.node'))
localFileExisted = existsSync(
join(__dirname, 'snappy.linux-arm-gnueabihf.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./snappy.linux-arm-gnueabihf.node')
Expand All @@ -234,9 +284,7 @@ if (!nativeBinding) {
throw new Error(`Failed to load native binding`)
}

const { compressSync, compress, uncompressSync, uncompress } = nativeBinding

module.exports.compressSync = compressSync
module.exports.compress = compress
module.exports.uncompressSync = uncompressSync
module.exports.uncompress = uncompress
module.exports.compress = nativeBinding.compress
module.exports.compressSync = nativeBinding.compressSync
module.exports.uncompress = nativeBinding.uncompress
module.exports.uncompressSync = nativeBinding.uncompressSync
Loading

0 comments on commit d9f0c28

Please sign in to comment.