Skip to content

Commit

Permalink
feat(cli): brand new cli tool with both cli and programmatical usage (#…
Browse files Browse the repository at this point in the history
…1492)

BREAKING CHANGE: requires node >= 16 and some cli options have been renamed
  • Loading branch information
forehalo committed Apr 6, 2023
1 parent 7c4dc2a commit a781a4f
Show file tree
Hide file tree
Showing 194 changed files with 8,806 additions and 4,159 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ target
scripts
triples/index.js
rollup.config.js
crates/cli/index.js
2 changes: 1 addition & 1 deletion .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ rules:

overrides:
- files:
- ./cli/**/*.ts
- ./**/*.ts
plugins:
- '@typescript-eslint'
parserOptions:
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/android-armv7.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,10 @@ jobs:
- name: Install dependencies
run: yarn install --immutable --mode=skip-build

- name: 'Build TypeScript'
run: yarn build

- name: Cross build
run: |
export CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER="${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi24-clang"
yarn build:test:android:armv7
yarn build:test -- --target armv7-linux-androideabi
du -sh examples/napi/index.node
${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip examples/napi/index.node
du -sh examples/napi/index.node
5 changes: 1 addition & 4 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@ jobs:
- name: Install dependencies
run: yarn install --immutable --mode=skip-build

- name: 'Build TypeScript'
run: yarn build

- name: Cross build native tests
run: |
export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER="${ANDROID_NDK_LATEST_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android24-clang"
yarn build:test:android
yarn build:test -- --target aarch64-linux-android
6 changes: 2 additions & 4 deletions .github/workflows/asan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,10 @@ jobs:
- name: 'Install dependencies'
run: yarn install --immutable --mode=skip-build

- name: 'Build TypeScript'
run: yarn build

- name: Unit tests with address sanitizer
run: |
yarn build:test:asan
yarn workspace @examples/napi build -- -Z build-std
yarn workspace @examples/compat-mode build -- -Z build-std
LD_PRELOAD=/usr/lib/gcc/x86_64-linux-gnu/9/libasan.so yarn test
env:
RUST_TARGET: x86_64-unknown-linux-gnu
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/bench.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ jobs:
- name: 'Install dependencies'
run: yarn install --immutable --mode=skip-build

- name: 'Build ts'
run: yarn build

- name: 'Build bench'
run: yarn build:bench

Expand Down
10 changes: 0 additions & 10 deletions .github/workflows/cli-binary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,13 @@ jobs:
- name: 'Install dependencies'
run: yarn install --mode=skip-build --immutable

- name: 'Build TypeScript'
run: yarn build

- name: Build and run binary
run: |
yarn workspace binary build
./examples/binary/napi-examples-binary
env:
RUST_BACKTRACE: 1

- name: Pass -p and --cargo-name to build
run: |
node ./cli/scripts/index.js build -p napi-examples-binary --cargo-name napi-examples-binary
./napi-examples-binary
env:
RUST_BACKTRACE: 1

- name: Clear the cargo caches
run: |
cargo install cargo-cache --no-default-features --features ci-autoclean
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/linux-aarch64-musl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,14 @@ jobs:
- name: Install dependencies
run: yarn install --immutable --mode=skip-build

- name: 'Build TypeScript'
run: yarn build

- name: Cross build native tests
uses: addnab/docker-run-action@v3
with:
image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
options: -v ${{ github.workspace }}:/napi-rs -w /napi-rs
run: |
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=aarch64-linux-musl-gcc
yarn workspace compat-mode-examples build --target aarch64-unknown-linux-musl
yarn workspace examples build --target aarch64-unknown-linux-musl
yarn build:test -- --target aarch64-unknown-linux-musl
- run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes

Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/linux-aarch64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,8 @@ jobs:
- name: Install dependencies
run: yarn install --immutable --mode=skip-build

- name: 'Build TypeScript'
run: yarn build

- name: Cross build native tests
run: yarn build:test:aarch64
run: yarn build:test -- --target aarch64-unknown-linux-gnu --cross-compile

- run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes

Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/linux-armv7.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,8 @@ jobs:
- name: Install dependencies
run: yarn install --immutable --mode=skip-build

- name: 'Build TypeScript'
run: yarn build

- name: Cross build native tests
run: yarn build:test:armv7
run: yarn build:test -- --target armv7-unknown-linux-gnueabihf --cross-compile

- run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes

Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/linux-musl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,12 @@ jobs:
- name: 'Install dependencies'
run: yarn install --immutable --mode=skip-build

- name: 'Build TypeScript'
run: yarn build

- name: Setup and run tests
uses: addnab/docker-run-action@v3
with:
image: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
options: -v ${{ github.workspace }}:/napi-rs -w /napi-rs
run: |
cargo check -vvv
yarn build:test
yarn build:test -- --target x86_64-unknown-linux-musl
yarn test
3 changes: 0 additions & 3 deletions .github/workflows/memory-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ jobs:
- name: 'Install dependencies'
run: yarn install --immutable

- name: 'Build TypeScript'
run: yarn build

- name: 'Pull docker image'
run: docker pull node:lts-slim

Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/msrv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ jobs:
- name: 'Install dependencies'
run: yarn install --mode=skip-build --immutable

- name: 'Build TypeScript'
run: yarn build

- name: Check build
uses: actions-rs/cargo@v1
with:
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node: ['14', '16', '18']
node: ['16', '18']
os: [ubuntu-latest, macos-latest, windows-latest]

name: stable - ${{ matrix.os }} - node@${{ matrix.node }}
Expand Down Expand Up @@ -51,9 +51,6 @@ jobs:
- name: 'Install dependencies'
run: yarn install --mode=skip-build --immutable

- name: 'Build TypeScript'
run: yarn build

- name: Check build
uses: actions-rs/cargo@v1
with:
Expand All @@ -62,6 +59,7 @@ jobs:

- name: Unit tests
run: |
yarn test:cli
yarn build:test
yarn test --verbose
yarn tsc -p examples/napi/tsconfig.json --noEmit
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/windows-arm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ jobs:
- name: 'Install dependencies'
run: yarn install --mode=skip-build --immutable

- name: 'Build TypeScript'
run: yarn build

- name: Install
uses: dtolnay/rust-toolchain@stable
with:
Expand All @@ -55,7 +52,9 @@ jobs:
args: --all --bins --examples --tests --target aarch64-pc-windows-msvc -vvv

- name: Build release target
run: cargo build --release --target aarch64-pc-windows-msvc
run: |
yarn workspace @examples/napi build --target aarch64-pc-windows-msvc --release
yarn workspace @examples/compat-mode build --target aarch64-pc-windows-msvc --release
- name: Clear the cargo caches
run: |
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/windows-i686.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ jobs:
run: |
yarn install --mode=skip-build --immutable
- name: 'Build TypeScript'
run: yarn build

- name: Install
uses: dtolnay/rust-toolchain@stable
with:
Expand All @@ -55,6 +52,11 @@ jobs:
command: check
args: --all --bins --examples --tests --target i686-pc-windows-msvc -vvv

- name: Build
run: |
yarn workspace @examples/napi build --target i686-pc-windows-msvc --release
yarn workspace @examples/compat-mode build --target i686-pc-windows-msvc --release
- name: Setup node
uses: actions/setup-node@v3
with:
Expand All @@ -64,8 +66,6 @@ jobs:

- name: Build Tests
run: |
yarn workspace compat-mode-examples build-i686 --release
yarn workspace examples build-i686 --release
yarn test --verbose
node ./node_modules/electron/install.js
yarn test:electron
Expand Down
16 changes: 7 additions & 9 deletions .github/workflows/zig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,15 @@ jobs:
version: 0.10.1
- name: Install dependencies
run: yarn install --immutable --mode=skip-build
- name: 'Build TypeScript'
run: yarn build
- name: Setup node
uses: actions/setup-node@v3
with:
# Testing for compatibility with node v12.x
node-version: 12
- name: install MacOS SDK
if: contains(matrix.target, 'apple')
run: |
curl -L "https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX11.3.sdk.tar.xz" | tar -J -x -C /opt
- name: Cross build native tests
env:
SDKROOT: /opt/MacOSX11.3.sdk
run: |
yarn workspace compat-mode-examples build --target ${{ matrix.target }} --zig
yarn workspace examples build --target ${{ matrix.target }} --zig
yarn build:test -- --target ${{ matrix.target }} --cross-compile
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
Expand Down
21 changes: 0 additions & 21 deletions ava.config.mjs

This file was deleted.

3 changes: 2 additions & 1 deletion bench/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
"version": "1.0.0",
"private": true,
"scripts": {
"build": "node ../cli/scripts/index.js build --js false --release"
"build": "napi-raw build --js false --release"
},
"devDependencies": {
"@napi-rs/cli": "workspace:*",
"benny": "^3.7.1"
}
}
Loading

0 comments on commit a781a4f

Please sign in to comment.