Skip to content
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
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
# Let GitHub languages ignores MDX files
*.mdx linguist-documentation

# NAPI-RS owns these generated files; keep regeneration deterministic on Windows.
packages/rstack/binding.cjs text eol=lf
packages/rstack/binding.d.cts text eol=lf
6 changes: 6 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ jobs:
- name: Build Packages
run: node --run build

- name: Check Rust Format
run: cargo fmt --all -- --check

- name: Lint Rust
run: cargo clippy --workspace --all-targets --locked -- -D warnings

- name: Lint
run: node --run lint

Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,17 @@ jobs:
- name: Build Packages
run: node --run build

- name: Run Rust Tests
run: cargo test --workspace --locked

- name: Build Native Binding
run: pnpm --filter rstack build:native:release

- name: Test Native Binding
run: pnpm --filter rstack test:native

- name: Check Generated Native Files
run: git diff --exit-code -- packages/rstack/binding.cjs packages/rstack/binding.d.cts

- name: Run Test
run: node --run test
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ dist-*/
test-results
doc_build

# Rust / NAPI-RS
/target/
/artifacts/
/packages/rstack/*.node
/packages/rstack/npm/

# Temp files
test-temp-*
TODO.md
Expand Down
277 changes: 277 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[workspace]
members = ["crates/rstack-binding"]
resolver = "2"

[workspace.package]
edition = "2021"
license = "MIT"
repository = "https://github.com/rstackjs/rstack-cli"
rust-version = "1.88"

[workspace.dependencies]
napi = { version = "3.12.0", default-features = false, features = ["napi9"] }
napi-build = "2.4.0"
napi-derive = "3.6.2"

[profile.release]
lto = true
strip = "symbols"
18 changes: 18 additions & 0 deletions crates/rstack-binding/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
name = "rstack-binding"
version = "0.1.0"
edition.workspace = true
license.workspace = true
repository.workspace = true
rust-version.workspace = true
publish = false

[lib]
crate-type = ["cdylib"]

[dependencies]
napi.workspace = true
napi-derive.workspace = true

[build-dependencies]
napi-build.workspace = true
3 changes: 3 additions & 0 deletions crates/rstack-binding/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
napi_build::setup();
}
18 changes: 18 additions & 0 deletions crates/rstack-binding/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#![deny(clippy::all)]

use napi_derive::napi;

#[napi]
pub fn native_ping(input: String) -> String {
format!("pong:{input}")
}

#[cfg(test)]
mod tests {
use super::native_ping;

#[test]
fn formats_ping_response() {
assert_eq!(native_ping("rstack".to_string()), "pong:rstack");
}
}
1 change: 1 addition & 0 deletions cspell.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default {
'coverage',
'doc_build',
'node_modules',
'packages/rstack/binding.cjs',
'packages/rstack/THIRD_PARTY_NOTICES.md',
'pnpm-lock.yaml',
],
Expand Down
Loading