Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an NPM workspace and use prettier for non-rust source files #852

Merged
merged 7 commits into from
Feb 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
# The following aliases simplify linting the entire workspace
clippy-legacy = "clippy --all-targets --no-default-features -p neon -p neon-runtime -p neon-build -p neon-macros -p tests -p static_tests --features event-handler-api,proc-macros,try-catch-api,legacy-runtime -- -A clippy::missing_safety_doc"
clippy-napi = "clippy --all-targets --no-default-features -p neon -p neon-runtime -p neon-build -p neon-macros -p electron-tests -p napi-tests --features proc-macros,try-catch-api,napi-experimental -- -A clippy::missing_safety_doc"
neon-test = "test --no-default-features --features napi-experimental"
neon-test = "test -p neon -p neon-runtime -p neon-build -p neon-macros -p electron-tests -p napi-tests --no-default-features --features=napi-experimental"
neon-doc = "rustdoc --no-default-features --features=channel-api,napi-experimental,proc-macros,try-catch-api -- --cfg docsrs"
38 changes: 20 additions & 18 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ on:

jobs:
lint:

runs-on: ubuntu-latest

strategy:
Expand All @@ -20,20 +19,23 @@ jobs:
rust-toolchain: [nightly]

steps:
- uses: actions/checkout@v2
- name: Use Rust ${{ matrix.rust-toolchain }}
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust-toolchain }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: install build-essential
run: sudo apt-get install -y build-essential
- name: Formatting
run: cargo fmt --all -- --check
- name: Clippy (N-API)
run: cargo clippy-napi
- name: Clippy (Legacy)
run: cargo clippy-legacy
- uses: actions/checkout@v2
- name: Use Rust ${{ matrix.rust-toolchain }}
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust-toolchain }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: install build-essential
run: sudo apt-get install -y build-essential
- run: npm install
- name: Prettier Formatting
run: npm run prettier:check
- name: Rust Formatting
run: cargo fmt --all -- --check
- name: Clippy (N-API)
run: cargo clippy-napi
- name: Clippy (Legacy)
run: cargo clippy-legacy
34 changes: 17 additions & 17 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ on:

jobs:
build:

runs-on: ubuntu-latest

strategy:
Expand All @@ -20,19 +19,20 @@ jobs:
rust-toolchain: [stable, beta, nightly]

steps:
- uses: actions/checkout@v2
- name: Use Rust ${{ matrix.rust-toolchain }}
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust-toolchain }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: install build-essential
run: sudo apt-get install -y build-essential
- name: run cargo test
run: xvfb-run --auto-servernum cargo neon-test -- --nocapture
- name: run CLI test
working-directory: ./create-neon
run: npm test
- uses: actions/checkout@v2
- name: Use Rust ${{ matrix.rust-toolchain }}
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust-toolchain }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Use npm v8
run: npm install -g npm@8
- name: install build-essential
run: sudo apt-get install -y build-essential
- name: npm install workspace
run: npm install
- name: run tests
run: xvfb-run --auto-servernum npm test -- --nocapture
35 changes: 16 additions & 19 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ on:

jobs:
build:

runs-on: macos-latest

strategy:
Expand All @@ -20,21 +19,19 @@ jobs:
rust-toolchain: [stable, beta, nightly]

steps:
- uses: actions/checkout@v2
- name: Use Rust ${{ matrix.rust-toolchain }}
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust-toolchain }}
target: x86_64-apple-darwin
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
# - name: update node-gyp to latest
# # https://github.com/nodejs/node-gyp/issues/1933#issuecomment-586915535
# run: npm install -g node-gyp@latest
- name: run cargo test
run: cargo neon-test
- name: run CLI test
working-directory: ./create-neon
run: npm test
- uses: actions/checkout@v2
- name: Use Rust ${{ matrix.rust-toolchain }}
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust-toolchain }}
target: x86_64-apple-darwin
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Use npm v8
run: npm install -g npm@8
- name: npm install workspace
run: npm install
- name: run tests
run: npm test
59 changes: 29 additions & 30 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ on:

jobs:
build:

runs-on: windows-latest

strategy:
Expand All @@ -20,32 +19,32 @@ jobs:
rust-toolchain: [stable, beta, nightly]

steps:
- uses: actions/checkout@v2
- name: Use Rust ${{ matrix.rust-toolchain }}
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust-toolchain }}
target: x86_64-pc-windows-msvc
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Use npm v6
if: ${{ matrix.node-version == '16.x' }}
run: npm install -g npm@6
- name: Install libclang
uses: KyleMayes/install-llvm-action@01144dc97b1e2693196c3056414a44f15180648b
with:
version: "10"
directory: ${{ runner.temp }}/llvm
# - name: update node-gyp to latest
# # https://github.com/nodejs/node-gyp/issues/1933#issuecomment-586915535
# run: npm install -g node-gyp@latest
- run: npm config set msvs_version 2019
- name: run cargo test
run: cargo neon-test
env:
LIBCLANG_PATH: ${{ runner.temp }}/llvm/bin
- name: run CLI test
working-directory: ./create-neon
run: npm test
- uses: actions/checkout@v2
- name: Use Rust ${{ matrix.rust-toolchain }}
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust-toolchain }}
target: x86_64-pc-windows-msvc
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install libclang
uses: KyleMayes/install-llvm-action@01144dc97b1e2693196c3056414a44f15180648b
with:
version: "10"
directory: ${{ runner.temp }}/llvm
- name: Use npm v8
# Windows bug in npm 8.4
# https://github.com/npm/cli/issues/4341
run: npm -g i npm@~8.3
- name: Update header files
run: npx node-gyp install
- name: Configure MSVS version
run: npm config set msvs_version 2022
- name: npm install workspace
run: npm install
env:
LIBCLANG_PATH: ${{ runner.temp }}/llvm/bin
- name: run tests
run: npm test
7 changes: 7 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.git/
cli/lib/
test/cli/lib/
node_modules/
create-neon/dist/
target/
artifacts.json
48 changes: 39 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,30 @@ Rust bindings for writing safe and fast native Node.js modules.

## Getting started

Once you have the [platform dependencies](https://neon-bindings.com/docs/quick-start) installed, getting started is as simple as:
Once you have the [platform dependencies](https://neon-bindings.com/docs/quick-start) installed, getting started is as
simple as:

```
$ npm init neon my-project
```

Then see the [Hello World guide](https://neon-bindings.com/docs/hello-world/) for writing your first Hello World in Neon!
Then see the [Hello World guide](https://neon-bindings.com/docs/hello-world/) for writing your first Hello World in
Neon!

_**Note:** This will create a new project with the `napi-backend` and some documentation may not be up to date._

## Docs

See our [Neon fundamentals docs](https://neon-bindings.com/docs/intro) and our [API docs](https://docs.rs/neon/latest/neon).
See our [Neon fundamentals docs](https://neon-bindings.com/docs/intro) and
our [API docs](https://docs.rs/neon/latest/neon).

## Node-API (formerly N-API) Migration Guide

We've ported Neon to a new backend based on [Node-API (formerly N-API)](https://nodejs.org/api/n-api.html), which will be the basis for Neon 1.0.
We've ported Neon to a new backend based on [Node-API (formerly N-API)](https://nodejs.org/api/n-api.html), which will
be the basis for Neon 1.0.

**Read the new [migration guide](https://github.com/neon-bindings/neon/blob/main/MIGRATION_GUIDE.md)** to learn how to port your Neon projects to N-API!
**Read the new [migration guide](https://github.com/neon-bindings/neon/blob/main/MIGRATION_GUIDE.md)** to learn how to
port your Neon projects to N-API!

## Platform Support

Expand All @@ -44,7 +49,8 @@ We've ported Neon to a new backend based on [Node-API (formerly N-API)](https://
| ------- | ------- | ------- |
| ✓ | ✓ | ✓ |

Support for [LTS versions of Node](https://github.com/nodejs/LTS#release-schedule) and current are expected. If you're using a different version of Node and believe it should be supported, let us know.
Support for [LTS versions of Node](https://github.com/nodejs/LTS#release-schedule) and current are expected. If you're
using a different version of Node and believe it should be supported, let us know.

### Rust

Expand Down Expand Up @@ -82,13 +88,37 @@ For more examples, see our [examples repo](https://github.com/neon-bindings/exam

The Neon community is just getting started and there's tons of fun to be had. Come play! :)

The [Rust Bindings community Slack](https://rust-bindings.slack.com) is open to all; use [the Slackin app](https://rust-bindings-slackin.herokuapp.com) to receive an invitation.
The [Rust Bindings community Slack](https://rust-bindings.slack.com) is open to all;
use [the Slackin app](https://rust-bindings-slackin.herokuapp.com) to receive an invitation.

### Testing Neon

The Neon project is both an [NPM workspace](https://docs.npmjs.com/cli/v8/using-npm/workspaces) and
a [Cargo workspace](https://doc.rust-lang.org/cargo/reference/workspaces.html). The full suite of tests may be executed
by installing and testing the NPM workspace.

```sh
npm install
npm test
```

Individual JavaScript packages may be tested with an `npm` workspace command:

```
npm --workspace=create-neon test
```

Individual Rust crates may be tested with a `cargo` workspace command:

```
cargo test -p neon-build
```

## License

Licensed under either of

* Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
* Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)

at your option.
15 changes: 10 additions & 5 deletions cli/bin/cli.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
#!/usr/bin/env node

require('make-promises-safe');
var CLI = require('../lib/cli.js').default;
require("make-promises-safe");
var CLI = require("../lib/cli.js").default;
var cli = new CLI(process.argv, process.cwd());
cli.exec()
.then(function() { process.exit(0); })
.catch(function() { process.exit(1); });
cli
.exec()
.then(function () {
process.exit(0);
})
.catch(function () {
process.exit(1);
});
Loading