10000 feat: initial wasm/ts/js bindings by baszalmstra · Pull Request #1079 · conda/rattler · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: initial wasm/ts/js bindings #1079

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

Merged
merged 6 commits into from
Feb 20, 2025
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
63 changes: 63 additions & 0 deletions .github/workflows/js-bindings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: JS bindings CI

on:
push:
branches: [ main ]
pull_request:
paths:
# When we change pyproject.toml, we want to ensure that the maturin builds still work
- test-data/**
- crates/**
- Cargo.*

# When something in the bindings themselves changes
- 'js-rattler/**/*'

# Or when this workflow changes
- '.github/workflows/js-bindings.yml'
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
format_lint_test:
name: Format, Lint and Test the JS bindings
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ '20.x' ]

steps:
- uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: clippy, rustfmt
target: wasm32-unknown-unknown

- name: Run rustfmt
uses: actions-rust-lang/rustfmt@v1
with:
manifest-path: js-rattler/Cargo.toml

- name: Run clippy
run: cargo clippy --all-targets
working-directory: js-rattler

- run: npm ci
working-directory: js-rattler
- run: npm run fmt
working-directory: js-rattler
- run: npm run build --if-present
working-directory: js-rattler
- run: npm test
working-directory: js-rattler
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ digest = "0.10.7"
dirs = "6.0.0"
dunce = "1.0.5"
enum_dispatch = "0.3.13"
fs-err = { version = "3.1.0", features = ["tokio"] }
fs-err = { version = "3.1.0" }
fslock = "0.2.1"
futures = "0.3.31"
futures-util = "0.3.31"
Expand Down
12 changes: 6 additions & 6 deletions crates/rattler_conda_types/src/channel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use file_url::directory_path_to_url;
use rattler_redaction::Redact;
use serde::{Deserialize, Serialize, Serializer};
use thiserror::Error;
use typed_path::{Utf8NativePathBuf, Utf8TypedPath, Utf8TypedPathBuf};
use typed_path::{Utf8TypedPath, Utf8TypedPathBuf};
use url::Url;

use super::{ParsePlatformError, Platform};
Expand Down Expand Up @@ -215,7 +215,7 @@ impl Channel {
}
} else if is_path(channel) {
#[cfg(target_arch = "wasm32")]
return Err(ParseChannelError::InvalidPath(path));
return Err(ParseChannelError::InvalidPath(channel.to_string()));

#[cfg(not(target_arch = "wasm32"))]
{
8000 Expand Down Expand Up @@ -313,6 +313,7 @@ impl Channel {
///
/// Panics if the path is not an absolute path or could not be
/// canonicalized.
#[cfg(not(target_arch = "wasm32"))]
pub fn from_directory(path: &Path) -> Self {
let path = if path.is_absolute() {
Cow::Borrowed(path)
Expand Down Expand Up @@ -466,15 +467,14 @@ fn absolute_path(path_str: &str, root_dir: &Path) -> Result<Utf8TypedPathBuf, Pa
let root_dir_str = root_dir
.to_str()
.ok_or_else(|| ParseChannelError::NotUtf8RootDir(root_dir.to_path_buf()))?;
let native_root_dir = Utf8NativePathBuf::from(root_dir_str);

if !native_root_dir.is_absolute() {
let typed_root_dir = Utf8TypedPath::from(root_dir_str);
if !typed_root_dir.is_absolute() {
return Err(ParseChannelError::NonAbsoluteRootDir(
root_dir.to_path_buf(),
));
}

Ok(native_root_dir.to_typed_path().join(path).normalize())
Ok(typed_root_dir.join(path).normalize())
}

#[cfg(test)]
Expand Down
2 changes: 2 additions & 0 deletions js-rattler/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[build]
target = "wasm32-unknown-unknown"
8 changes: 8 additions & 0 deletions js-rattler/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/target
**/*.rs.bk
bin/
pkg/
dist/
node_modules/
wasm-pack.log
!Cargo.lock
7 changes: 7 additions & 0 deletions js-rattler/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"tabWidth": 4,
"semi": true,
"trailingComma": "all",
"useTabs": false,
"plugins": ["prettier-plugin-jsdoc"]
}
Loading
Loading
0