diff --git a/.eslintrc.json b/.eslintrc.json
index 2910c32d..4cb1ac2f 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -8,23 +8,16 @@
"root": true,
"extends": [
"eslint:recommended",
- "plugin:@typescript-eslint/recommended",
- "plugin:prettier/recommended"
+ "plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint"
],
"rules": {
- "prettier/prettier": [
- "error",
- {
- "printWidth": 100,
- "tabWidth": 4
- }
- ],
"no-cond-assign": "off",
"no-empty-function": "off",
+ "@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-non-null-assertion": "off",
diff --git a/.github/workflows/manual-release.yaml b/.github/workflows/manual-release.yaml
deleted file mode 100644
index 6fe1408d..00000000
--- a/.github/workflows/manual-release.yaml
+++ /dev/null
@@ -1,160 +0,0 @@
-name: Manual Release
-on:
- workflow_dispatch:
- inputs:
- version-level:
- description: 'Select Version Level'
- required: true
- type: choice
- options:
- - alpha # Increase the alpha pre-version (x.y.z-alpha.M)
- - beta # Increase the beta pre-version (x.y.z-beta.M)
- - patch # Increase the patch version (x.y.z)
- - minor # Increase the minor version (x.y.0)
- - major # Increase the major version (x.0.0)
- - release # Remove the pre-version, ie remove alpha/beta/rc (x.y.z)
- - rc # Increase the rc pre-version (x.y.z-rc.M)
-
-jobs:
- release:
- runs-on: ubuntu-latest
- outputs:
- version: ${{ env.NEW_VERSION }}
- steps:
- - uses: actions/checkout@v4
- with:
- fetch-depth: 0
- submodules: recursive
- ssh-key: ${{ secrets.PUBLISHER_SSH_KEY }}
-
- - uses: DeterminateSystems/nix-installer-action@v4
- - uses: DeterminateSystems/magic-nix-cache-action@v2
-
- - name: Install NodeJS v22
- uses: actions/setup-node@v4
- with:
- node-version: 22
- cache: 'npm'
-
- - run: nix develop -c rainix-rs-prelude
-
- - name: Run rainix-rs-test
- run: nix develop -c rainix-rs-test
-
- - name: Build JS Bindings
- run: nix develop -c build-js-bindings
-
- - name: Run JS Tests
- run: nix develop -c test-js-bindings
-
- - name: Git Config
- run: |
- git config --global user.email "${{ secrets.CI_GIT_EMAIL }}"
- git config --global user.name "${{ secrets.CI_GIT_USER }}"
-
- - name: Publish to crates.io
- run: nix develop -c cargo release --no-confirm --execute --no-tag --workspace ${{ inputs.version-level }}
- env:
- CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
-
- # set npm version to rust crate version
- - name: Set Version
- run: echo "NEW_VERSION=$(nix develop -c npm version $(node ./scripts/version.js) --no-git-tag-version)" >> $GITHUB_ENV
-
- # Commit changes and tag
- - name: Commit And Tag
- run: |
- git add "package.json"
- git add "package-lock.json"
- git commit -m "Release ${{ env.NEW_VERSION }}"
- git tag ${{ env.NEW_VERSION }}
-
- # Push the commit to remote
- - name: Push Changes To Remote
- run: |
- git push origin
- git push -u origin ${{ env.NEW_VERSION }}
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-
- # Create npm package tarball to put in release files
- - name: Create NPM Package Tarball
- run: echo "NPM_PACKAGE=$(nix develop -c npm pack --silent)" >> $GITHUB_ENV
-
- - name: Rename NPM Package Tarball
- run: mv ${{ env.NPM_PACKAGE }} dotrain_npm_package_${{ env.NEW_VERSION }}.tgz
-
- # publish to npm
- - name: Publish To NPM
- uses: JS-DevTools/npm-publish@v1
- with:
- token: ${{ secrets.NPM_TOKEN }}
- access: public
-
- # Create gitHub release with npm tarball
- - name: Create GitHub Release
- id: gh_release
- uses: softprops/action-gh-release@v2
- with:
- tag_name: ${{ env.NEW_VERSION }}
- name: Release ${{ env.NEW_VERSION }}
- files: dotrain_npm_package_${{ env.NEW_VERSION }}.tgz
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-
-
- release_bin:
- name: Release dotrain cli ${{ matrix.platform }}_${{ matrix.arch }} bin
- needs: release
- runs-on: ${{ matrix.runner }}
- strategy:
- fail-fast: false
- matrix:
- include:
- - runner: ubuntu-22.04
- target: x86_64-unknown-linux-gnu
- platform: linux
- arch: x86_64
- # - runner: ubuntu-22.04
- # target: aarch64-unknown-linux-gnu
- # platform: linux
- # arch: arm64
- - runner: macos-13
- target: x86_64-apple-darwin
- platform: darwin
- arch: x86_64
- - runner: macos-14
- target: aarch64-apple-darwin
- platform: darwin
- arch: arm64
-
- steps:
- - uses: actions/checkout@v4
- with:
- fetch-depth: 0
- submodules: recursive
- ssh-key: ${{ secrets.PUBLISHER_SSH_KEY }}
-
- - uses: DeterminateSystems/nix-installer-action@v4
- - uses: DeterminateSystems/magic-nix-cache-action@v2
-
- - name: Git Config
- run: |
- git config --global user.email "${{ secrets.CI_GIT_EMAIL }}"
- git config --global user.name "${{ secrets.CI_GIT_USER }}"
-
- - name: Pull Release Commit
- run: git pull origin
-
- - name: Build Bin
- run: nix develop -c cargo build -r --features cli --bin dotrain --target "${{ matrix.target }}"
-
- - run: cp ./target/${{ matrix.target }}/release/dotrain ./dotrain_cli_${{ needs.release.outputs.version }}_${{ matrix.platform }}_${{ matrix.arch }}
-
- - name: Add Bin To Release
- uses: softprops/action-gh-release@v2
- with:
- tag_name: ${{ needs.release.outputs.version }}
- files: dotrain_cli_${{ needs.release.outputs.version }}_${{ matrix.platform }}_${{ matrix.arch }}
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/.github/workflows/package-release.yaml b/.github/workflows/package-release.yaml
new file mode 100644
index 00000000..46e8b9c0
--- /dev/null
+++ b/.github/workflows/package-release.yaml
@@ -0,0 +1,16 @@
+name: Package Release
+on:
+ push:
+ branches:
+ - main
+jobs:
+ release:
+ # Auto-publishes the dotrain crates to crates.io and the @rainlanguage/dotrain
+ # npm package on every merge to main, version-bumped in lockstep by the shared
+ # rainix-autopublish reusable — the same merge-driven model every other rain repo
+ # uses. Replaces the old manual `workflow_dispatch` release.
+ uses: rainlanguage/rainix/.github/workflows/rainix-autopublish.yaml@main
+ with:
+ crates: dotrain dotrain-lsp
+ npm-package: "@rainlanguage/dotrain"
+ secrets: inherit
diff --git a/.github/workflows/pr-assessment.yaml b/.github/workflows/pr-assessment.yaml
index 71c5461a..18e484f4 100644
--- a/.github/workflows/pr-assessment.yaml
+++ b/.github/workflows/pr-assessment.yaml
@@ -3,7 +3,6 @@ on:
pull_request:
types:
- closed
-
jobs:
assess-pr-size-on-merge:
uses: rainlanguage/github-chore/.github/workflows/pr-assessment.yml@main
diff --git a/.github/workflows/rainix.yaml b/.github/workflows/rainix.yaml
index ca3eeb49..05b0ce0b 100644
--- a/.github/workflows/rainix.yaml
+++ b/.github/workflows/rainix.yaml
@@ -1,38 +1,25 @@
-name: Rainix CI
+name: rainix-rs
on: [push]
-
jobs:
- rainix:
- strategy:
- matrix:
- os: [ubuntu-latest, macos-latest]
- task: [rainix-rs-test, rainix-rs-artifacts]
- include:
- # We don't need to do rust static analysis on multiple platforms
- - os: ubuntu-latest
- task: rainix-rs-static
- fail-fast: false
- runs-on: ${{ matrix.os }}
-
+ static:
+ uses: rainlanguage/rainix/.github/workflows/rainix-rs-static.yaml@main
+ secrets: inherit
+ test:
+ uses: rainlanguage/rainix/.github/workflows/rainix-rs-test.yaml@main
+ secrets: inherit
+ js-bindings:
+ runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v4
+ # Shared rainix nix + cachix CI preamble (checkout, nix-quick-install,
+ # Cachix, cache-nix-action) — the pinned action SHAs live once in the
+ # composite, matching every rainix reusable. The build/test/docs commands
+ # below are dotrain-specific flake devShell tasks (npm + wasm-bindgen CLI
+ # over the js-api crate, mocha tests, api-extractor docs), so there is no
+ # rainix reusable workflow that runs them; only the preamble is shared.
+ - uses: rainlanguage/rainix/.github/actions/nix-cachix-setup@main
with:
- submodules: recursive
- fetch-depth: 0
-
- - uses: DeterminateSystems/nix-installer-action@v4
- - uses: DeterminateSystems/magic-nix-cache-action@v2
-
- - run: nix develop -c rainix-rs-prelude
-
- - name: Run ${{ matrix.task }}
- run: nix develop -c ${{ matrix.task }}
-
- - name: Build JS Bindings
- run: nix develop -c build-js-bindings
-
- - name: Run JS Tests
- run: nix develop -c test-js-bindings
-
- - name: Test JS Doc Generation
- run: nix develop -c js-bindings-docs
\ No newline at end of file
+ cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
+ - uses: rainlanguage/rainix/.github/actions/rust-cache@main
+ - run: nix develop -c build-js-bindings
+ - run: nix develop -c test-js-bindings
+ - run: nix develop -c js-bindings-docs
diff --git a/.rustfmt.toml b/.rustfmt.toml
index 8ebbb394..e0fbe31e 100644
--- a/.rustfmt.toml
+++ b/.rustfmt.toml
@@ -3,4 +3,4 @@ reorder_imports = false
reorder_modules = false
# group_imports = "StdExternalCrate"
# imports_layout = "HorizontalVertical"
-# unstable_features = true
\ No newline at end of file
+# unstable_features = true
diff --git a/Cargo.lock b/Cargo.lock
index 866edc80..a74dd600 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1,6 +1,6 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
-version = 3
+version = 4
[[package]]
name = "addr2line"
@@ -2842,26 +2842,14 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "wasm-bindgen"
-version = "0.2.90"
+version = "0.2.122"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b1223296a201415c7fad14792dbefaace9bd52b62d33453ade1c5b5f07555406"
+checksum = "3ed04576f974d2b2fba0f38c51dbc5518011e38c36bf1143164be765528fd409"
dependencies = [
"cfg-if",
- "wasm-bindgen-macro",
-]
-
-[[package]]
-name = "wasm-bindgen-backend"
-version = "0.2.90"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fcdc935b63408d58a32f8cc9738a0bffd8f05cc7c002086c6ef20b7312ad9dcd"
-dependencies = [
- "bumpalo",
- "log",
"once_cell",
- "proc-macro2",
- "quote",
- "syn 2.0.48",
+ "rustversion",
+ "wasm-bindgen-macro",
"wasm-bindgen-shared",
]
@@ -2879,9 +2867,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro"
-version = "0.2.90"
+version = "0.2.122"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3e4c238561b2d428924c49815533a8b9121c664599558a5d9ec51f8a1740a999"
+checksum = "916151b09da36bd82f6615cbf3a419e2f0ba23a03c6160e8e92eb6bd4aa1dec6"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
@@ -2889,22 +2877,25 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro-support"
-version = "0.2.90"
+version = "0.2.122"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bae1abb6806dc1ad9e560ed242107c0f6c84335f1749dd4e8ddb012ebd5e25a7"
+checksum = "299047362ccbfce148b67ab7e73349f77748e00c8296f9542adfad2ad82c5c5e"
dependencies = [
+ "bumpalo",
"proc-macro2",
"quote",
"syn 2.0.48",
- "wasm-bindgen-backend",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-shared"
-version = "0.2.90"
+version = "0.2.122"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4d91413b1c31d7539ba5ef2451af3f0b833a005eb27a631cec32bc0635a8602b"
+checksum = "9a929b2c61f11ba3e9bc35b50c1f25cb38e0e892c0c231ae2b8cf78d5dad4437"
+dependencies = [
+ "unicode-ident",
+]
[[package]]
name = "web-sys"
diff --git a/README.md b/README.md
index 8500780a..bc19bb24 100644
--- a/README.md
+++ b/README.md
@@ -1,34 +1,67 @@

# **Rain Language Composer and LSP**
-The Rain language server protocol ([LSP](https://microsoft.github.io/language-server-protocol/)) services implementation (language services) and .rain composer written in rust and made available for NodeJs and broswers through [wasm-bindgen](https://rustwasm.github.io/docs/wasm-bindgen/) in Typescript/Javascript which makes it well suited for editors and IDEs (as it is used in Rainlang vscode and codemirror language extension).
-- Dotrain specs can be found [here](https://github.com/rainlanguage/specs/blob/main/dotrain.md)
-- Rainlang specs can be found [here](https://github.com/rainlanguage/specs/blob/main/rainlang.md)
-- Dotrain has been implemented for vscode and codemirror, see [rainlang-vscode](https://github.com/rainlanguage/rainlang-vscode) and [rainlang-codemirror](https://github.com/rainlanguage/rainlang-codemirror) repositories for more details.
-- Dotrain vscode extension can be found [here](https://marketplace.visualstudio.com/items?itemName=rainprotocol.rainlang-vscode).
-The primary goal of the Rain language is to make smart contract development accessible for as many people as possible. This is fundamentally grounded in our belief that accessibility is the difference between theoretical and practical decentralisation. There are many people who would like to participate in authoring and auditing crypto code but currently cannot. When someone wants/needs to do something but cannot, then they delegate to someone who can, this is by definition centralisation.
-
-For more info and details, please read this [article](https://hackmd.io/@REJeq0MuTUiqnjx9w5SsUA/HJj9s-nfi#Rainlang-has-a-spectrum-of-representations-from-concise-gtexplicit)
-
-If you find an issue or you want to propose an improvement, please feel free to post it on: [issues](https://github.com/rainlanguage/dotrain/issues)
+The Rain language server protocol
+([LSP](https://microsoft.github.io/language-server-protocol/)) services
+implementation (language services) and .rain composer written in rust and made
+available for NodeJs and broswers through
+[wasm-bindgen](https://rustwasm.github.io/docs/wasm-bindgen/) in
+Typescript/Javascript which makes it well suited for editors and IDEs (as it is
+used in Rainlang vscode and codemirror language extension).
+
+- Dotrain specs can be found
+ [here](https://github.com/rainlanguage/specs/blob/main/dotrain.md)
+- Rainlang specs can be found
+ [here](https://github.com/rainlanguage/specs/blob/main/rainlang.md)
+- Dotrain has been implemented for vscode and codemirror, see
+ [rainlang-vscode](https://github.com/rainlanguage/rainlang-vscode) and
+ [rainlang-codemirror](https://github.com/rainlanguage/rainlang-codemirror)
+ repositories for more details.
+- Dotrain vscode extension can be found
+ [here](https://marketplace.visualstudio.com/items?itemName=rainprotocol.rainlang-vscode).
+
+The primary goal of the Rain language is to make smart contract development
+accessible for as many people as possible. This is fundamentally grounded in our
+belief that accessibility is the difference between theoretical and practical
+decentralisation. There are many people who would like to participate in
+authoring and auditing crypto code but currently cannot. When someone
+wants/needs to do something but cannot, then they delegate to someone who can,
+this is by definition centralisation.
+
+For more info and details, please read this
+[article](https://hackmd.io/@REJeq0MuTUiqnjx9w5SsUA/HJj9s-nfi#Rainlang-has-a-spectrum-of-representations-from-concise-gtexplicit)
+
+If you find an issue or you want to propose an improvement, please feel free to
+post it on: [issues](https://github.com/rainlanguage/dotrain/issues)
---
+
# **Tutorial**
+
## **Javascript/Typescript**
+
To get started, install the package:
+
```bash
npm install @rainlanguage/dotrain
```
+
or
+
```bash
yarn add @rainlanguage/dotrain
```
+
```typescript
// imports
-import { RainLanguageServices, MetaStore, TextDocumentItem } from "@rainlanguage/dotrain";
+import {
+ MetaStore,
+ RainLanguageServices,
+ TextDocumentItem,
+} from "@rainlanguage/dotrain";
// instantiate a MetaStore which is a in-memory CAS for Rain metadata
const metaStore = new MetaStore();
@@ -38,7 +71,7 @@ const textDocument = TextDocumentItem.create(
"file:///file-name.rain",
"rainlang",
0,
- "some dotrain text"
+ "some dotrain text",
);
// initiating the services (metaStore is optional)
@@ -48,23 +81,34 @@ const langServices = new RainLanguageServices(metaStore);
const diagnostics = await langServices.doValidate(textDocument);
// instantiate a new RainDocument
-const rainDocument = await langServices.newRainDocument(textDocument)
+const rainDocument = await langServices.newRainDocument(textDocument);
// composing a RainDocument to get rainlang string
-const rainlangText = await rainDocument.compose(["entrypoint-1" , "entrypoint-2"]);
+const rainlangText = await rainDocument.compose([
+ "entrypoint-1",
+ "entrypoint-2",
+]);
```
+
## **Rust**
+
## dotrain crate
+
To get started, install the package:
+
```bash
cargo add dotrain
```
### Features
-- `cli`: A [clap](https://docs.rs/clap/latest/clap/) based module (CLI app) for functionalities of this library, this features is required for building the **binary**
-- `js-api`: includes wrappers around main structs and functionalities to provide an API through [wasm-bindgen](https://rustwasm.github.io/docs/wasm-bindgen/)
+
+- `cli`: A [clap](https://docs.rs/clap/latest/clap/) based module (CLI app) for
+ functionalities of this library, this features is required for building the
+ **binary**
+- `js-api`: includes wrappers around main structs and functionalities to provide
+ an API through [wasm-bindgen](https://rustwasm.github.io/docs/wasm-bindgen/)
@@ -83,16 +127,21 @@ let rain_document = RainDocument::new(text, Some(meta_store));
// compose this instance of RainDocument to get rainlang string
let rainlang_text = rain_document.compose(&vec!["entrypoint1", "entrypoint2"], None)?;
```
+
## dotrain_lsp crate
+
To get started, install the package:
+
```bash
cargo add dotrain-lsp
```
### Features
-- `js-api`: includes wrappers around main structs and functionalities to provide an API through [wasm-bindgen](https://rustwasm.github.io/docs/wasm-bindgen/)
+
+- `js-api`: includes wrappers around main structs and functionalities to provide
+ an API through [wasm-bindgen](https://rustwasm.github.io/docs/wasm-bindgen/)
```rust
use std::sync::{Arc, RwLock};
@@ -122,41 +171,60 @@ let diagnostics = lang_services.do_validate(&text_document, true);
```
## CLI
-The CLI app can be built using nix (requires nix package manager to be installed):
+
+The CLI app can be built using nix (requires nix package manager to be
+installed):
+
```bash
nix build github:rainlanguage/dotrain
```
+
or installed with the following command from cargo:
+
```bash
cargo install dotrain
```
-this will install the dotrain binary in your path which then can be used to compose .rain files and generate outputs.
+this will install the dotrain binary in your path which then can be used to
+compose .rain files and generate outputs.
### Examples
+
composes a .rain file with specified entrypoints
+
```bash
dotrain compose --input path/to/some.rain --entrypoints first --entrypoints second
```
+
optionally, path to `rainconfig.json` can be provided:
+
```bash
dotrain -c path/to/rainconfig.json --input path/to/some.rain --entrypoints first --entrypoints second
```
+
-Dotrain cli is also available in [Rain CLI app](https://github.com/rainlanguage/rain.cli) which can be easily run with nix:
+Dotrain cli is also available in
+[Rain CLI app](https://github.com/rainlanguage/rain.cli) which can be easily run
+with nix:
+
```bash
nix run github:rainlanguage/rain.cli -- --help
```
+
## **rainconfig**
-Configuration details for .rain composer (source files and subgraphs).
-Following command will print info about rainconfig and its fields:
+
+Configuration details for .rain composer (source files and subgraphs). Following
+command will print info about rainconfig and its fields:
+
```bash
dotrain rainconfig
```
+
Here is an example of a `rainconfig.json`:
+
```json
{
"include": ["./folder1", "./folder2"],
@@ -169,19 +237,27 @@ Here is an example of a `rainconfig.json`:
```
## **Building JS/TS Bindings**
+
From the root of this repo, simply run the following to build the js bindings:
+
```bash
nix develop -c build-js-bindings
```
-This will build the rust library with `wasm32-unknown-unknown` target in release mode with `js-api` feature enabled and then generates bindings using `wasm-bindgen-cli` into `./dist` directory by encoding the wasm binary into a json as importing json is native in js/ts and eliminates the need for using fetch/fs operations when loading the wasm module.
+This will build the rust library with `wasm32-unknown-unknown` target in release
+mode with `js-api` feature enabled and then generates bindings using
+`wasm-bindgen-cli` into `./dist` directory by encoding the wasm binary into a
+json as importing json is native in js/ts and eliminates the need for using
+fetch/fs operations when loading the wasm module.
To generate js/ts documents:
+
```bash
nix develop -c js-bindings-docs
```
To run tests:
+
```bash
nix develop -c test-js-bindings
-```
\ No newline at end of file
+```
diff --git a/crates/dotrain/Cargo.toml b/crates/dotrain/Cargo.toml
index 8bd32dce..8d5571e9 100644
--- a/crates/dotrain/Cargo.toml
+++ b/crates/dotrain/Cargo.toml
@@ -9,7 +9,13 @@ repository.workspace = true
[features]
cli = ["dep:tracing", "dep:tracing-subscriber", "dep:clap", "dep:tokio"]
-js-api = ["dep:js-sys", "dep:wasm-bindgen", "dep:serde-wasm-bindgen", "dep:wasm-bindgen-futures", "dep:tsify"]
+js-api = [
+ "dep:js-sys",
+ "dep:wasm-bindgen",
+ "dep:serde-wasm-bindgen",
+ "dep:wasm-bindgen-futures",
+ "dep:tsify",
+]
[lib]
name = "dotrain"
@@ -46,7 +52,10 @@ js-sys = { version = "0.3", optional = true }
wasm-bindgen = { version = "0.2", optional = true }
serde-wasm-bindgen = { version = "0.6", optional = true }
wasm-bindgen-futures = { version = "0.4", optional = true }
-tsify = { version = "0.4", default-features = false, features = ["wasm-bindgen", "js"], optional = true }
+tsify = { version = "0.4", default-features = false, features = [
+ "wasm-bindgen",
+ "js",
+], optional = true }
[lints.clippy]
all = "warn"
diff --git a/crates/dotrain/src/cli/mod.rs b/crates/dotrain/src/cli/mod.rs
index 5cf9e912..ec481f85 100644
--- a/crates/dotrain/src/cli/mod.rs
+++ b/crates/dotrain/src/cli/mod.rs
@@ -5,7 +5,7 @@
//! and options while underlying functions handle each scenario
use std::path::PathBuf;
-use clap::{Parser, Subcommand, command};
+use clap::{Parser, Subcommand};
use crate::parser::{Rebind, parse_cli_key_val};
mod compose;
diff --git a/crates/dotrain/src/composer/mod.rs b/crates/dotrain/src/composer/mod.rs
index 65aea9b3..42ca017f 100644
--- a/crates/dotrain/src/composer/mod.rs
+++ b/crates/dotrain/src/composer/mod.rs
@@ -120,6 +120,7 @@ impl RainDocument {
impl RainDocument {
/// builds composing targets sourcemaps
+ #[allow(mismatched_lifetime_syntaxes)]
pub(crate) fn build_targets_sourcemap(
&self,
entrypoints: &[&str],
diff --git a/crates/dotrain/src/js_api/raindocument.rs b/crates/dotrain/src/js_api/raindocument.rs
index 65547a7c..9758aacd 100644
--- a/crates/dotrain/src/js_api/raindocument.rs
+++ b/crates/dotrain/src/js_api/raindocument.rs
@@ -8,7 +8,7 @@ use super::{
types::ast::{Problem, Import, Comment, Binding},
},
};
-use serde_wasm_bindgen::{Error, to_value, from_value};
+use serde_wasm_bindgen::{to_value, from_value};
use wasm_bindgen::{
JsValue,
convert::*,
@@ -235,9 +235,8 @@ impl From for JsValue {
}
}
impl TryFromJsValue for Rebind {
- type Error = Error;
- fn try_from_js_value(value: JsValue) -> Result {
- from_value(value)
+ fn try_from_js_value_ref(value: &JsValue) -> Option {
+ from_value(value.clone()).ok()
}
}
impl VectorFromWasmAbi for Rebind {
diff --git a/crates/dotrain/src/parser/raindocument/mod.rs b/crates/dotrain/src/parser/raindocument/mod.rs
index eed0956e..1a834b6d 100644
--- a/crates/dotrain/src/parser/raindocument/mod.rs
+++ b/crates/dotrain/src/parser/raindocument/mod.rs
@@ -449,7 +449,7 @@ mod tests {
0,
None,
);
- let statements = vec![ParsedItem(
+ let statements = [ParsedItem(
"0x6518ec1930d8846b093dcff41a6ee6f6352c72b82e48584cce741a9e8a6d6184".to_owned(),
[17, 83],
)];
diff --git a/crates/dotrain/src/types/ast.rs b/crates/dotrain/src/types/ast.rs
index f7c63ee5..9831c70c 100644
--- a/crates/dotrain/src/types/ast.rs
+++ b/crates/dotrain/src/types/ast.rs
@@ -220,6 +220,7 @@ pub struct QuoteBindingItem {
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
#[cfg_attr(feature = "js-api", derive(Tsify), tsify(into_wasm_abi, from_wasm_abi))]
+#[allow(clippy::large_enum_variant)]
pub enum BindingItem {
Elided(ElidedBindingItem),
Literal(LiteralBindingItem),
@@ -329,6 +330,7 @@ impl NamespaceLeaf {
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(untagged)]
#[cfg_attr(feature = "js-api", derive(Tsify), tsify(into_wasm_abi, from_wasm_abi))]
+#[allow(clippy::large_enum_variant)]
pub enum NamespaceItem {
Leaf(NamespaceLeaf),
Node(Namespace),
diff --git a/crates/dotrain/src/types/impls.rs b/crates/dotrain/src/types/impls.rs
index c385b464..c7d840fb 100644
--- a/crates/dotrain/src/types/impls.rs
+++ b/crates/dotrain/src/types/impls.rs
@@ -1,5 +1,5 @@
use super::ast::*;
-use serde_wasm_bindgen::{Error, to_value, from_value};
+use serde_wasm_bindgen::{to_value, from_value};
use wasm_bindgen::{
JsValue,
convert::*,
@@ -19,9 +19,8 @@ impl From for JsValue {
}
}
impl TryFromJsValue for Problem {
- type Error = Error;
- fn try_from_js_value(value: JsValue) -> Result {
- from_value(value)
+ fn try_from_js_value_ref(value: &JsValue) -> Option {
+ from_value(value.clone()).ok()
}
}
impl VectorFromWasmAbi for Problem {
@@ -49,9 +48,8 @@ impl From for JsValue {
}
}
impl TryFromJsValue for ParsedItem {
- type Error = Error;
- fn try_from_js_value(value: JsValue) -> Result {
- from_value(value)
+ fn try_from_js_value_ref(value: &JsValue) -> Option {
+ from_value(value.clone()).ok()
}
}
impl VectorFromWasmAbi for ParsedItem {
@@ -79,9 +77,8 @@ impl From for JsValue {
}
}
impl TryFromJsValue for Comment {
- type Error = Error;
- fn try_from_js_value(value: JsValue) -> Result {
- from_value(value)
+ fn try_from_js_value_ref(value: &JsValue) -> Option {
+ from_value(value.clone()).ok()
}
}
impl VectorFromWasmAbi for Comment {
@@ -109,9 +106,8 @@ impl From for JsValue {
}
}
impl TryFromJsValue for Import {
- type Error = Error;
- fn try_from_js_value(value: JsValue) -> Result {
- from_value(value)
+ fn try_from_js_value_ref(value: &JsValue) -> Option {
+ from_value(value.clone()).ok()
}
}
impl VectorFromWasmAbi for Import {
@@ -139,9 +135,8 @@ impl From for JsValue {
}
}
impl TryFromJsValue for Binding {
- type Error = Error;
- fn try_from_js_value(value: JsValue) -> Result {
- from_value(value)
+ fn try_from_js_value_ref(value: &JsValue) -> Option {
+ from_value(value.clone()).ok()
}
}
impl VectorFromWasmAbi for Binding {
@@ -169,9 +164,8 @@ impl From for JsValue {
}
}
impl TryFromJsValue for RainlangSource {
- type Error = Error;
- fn try_from_js_value(value: JsValue) -> Result {
- from_value(value)
+ fn try_from_js_value_ref(value: &JsValue) -> Option {
+ from_value(value.clone()).ok()
}
}
impl VectorFromWasmAbi for RainlangSource {
diff --git a/crates/lsp/Cargo.toml b/crates/lsp/Cargo.toml
index c8d0d187..ba81dddb 100644
--- a/crates/lsp/Cargo.toml
+++ b/crates/lsp/Cargo.toml
@@ -14,7 +14,7 @@ js-api = [
"dep:wasm-bindgen",
"dep:serde-wasm-bindgen",
"dep:wasm-bindgen-futures",
- "dep:tsify"
+ "dep:tsify",
]
[lib]
@@ -32,7 +32,10 @@ js-sys = { version = "0.3", optional = true }
wasm-bindgen = { version = "0.2", optional = true }
serde-wasm-bindgen = { version = "0.6", optional = true }
wasm-bindgen-futures = { version = "0.4", optional = true }
-tsify = { version = "0.4", default-features = false, features = ["js", "wasm-bindgen"], optional = true }
+tsify = { version = "0.4", default-features = false, features = [
+ "js",
+ "wasm-bindgen",
+], optional = true }
[lints.clippy]
all = "warn"
diff --git a/flake.lock b/flake.lock
index 9ff59b74..d1fcdb1a 100644
--- a/flake.lock
+++ b/flake.lock
@@ -1,5 +1,21 @@
{
"nodes": {
+ "flake-compat": {
+ "flake": false,
+ "locked": {
+ "lastModified": 1767039857,
+ "narHash": "sha256-vNpUSpF5Nuw8xvDLj2KCwwksIbjua2LZCqhV1LNRDns=",
+ "owner": "NixOS",
+ "repo": "flake-compat",
+ "rev": "5edf11c44bc78a0d334f6334cdaf7d60d732daab",
+ "type": "github"
+ },
+ "original": {
+ "owner": "NixOS",
+ "repo": "flake-compat",
+ "type": "github"
+ }
+ },
"flake-utils": {
"inputs": {
"systems": "systems"
@@ -23,11 +39,11 @@
"systems": "systems_2"
},
"locked": {
- "lastModified": 1705309234,
- "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=",
+ "lastModified": 1731533236,
+ "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
- "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26",
+ "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
@@ -56,11 +72,11 @@
"systems": "systems_3"
},
"locked": {
- "lastModified": 1687171271,
- "narHash": "sha256-BJlq+ozK2B1sJDQXS3tzJM5a+oVZmi1q0FlBK/Xqv7M=",
+ "lastModified": 1731533236,
+ "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
- "rev": "abfb11bd1aec8ced1c9bb9adfe68018230f4fb3c",
+ "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
@@ -69,59 +85,64 @@
"type": "github"
}
},
- "flake-utils_5": {
+ "foundry": {
"inputs": {
- "systems": "systems_4"
+ "flake-utils": "flake-utils_3",
+ "nixpkgs": "nixpkgs"
},
"locked": {
- "lastModified": 1681202837,
- "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=",
- "owner": "numtide",
- "repo": "flake-utils",
- "rev": "cfacdce06f30d2b68473a46042957675eebb3401",
+ "lastModified": 1778486972,
+ "narHash": "sha256-iuy/TbK9AbghEld2VSFuxyAF30LkOGUUdtrvixLfE7M=",
+ "owner": "shazow",
+ "repo": "foundry.nix",
+ "rev": "db117ae95a77b9ead24137c3ccb28896ae4fa4ec",
"type": "github"
},
"original": {
- "owner": "numtide",
- "repo": "flake-utils",
+ "owner": "shazow",
+ "repo": "foundry.nix",
"type": "github"
}
},
- "foundry": {
+ "git-hooks-nix": {
"inputs": {
- "flake-utils": "flake-utils_3",
- "nixpkgs": "nixpkgs"
+ "flake-compat": "flake-compat",
+ "gitignore": "gitignore",
+ "nixpkgs": "nixpkgs_2"
},
"locked": {
- "lastModified": 1705216422,
- "narHash": "sha256-kIAi+aqJoOVhpQP5DWRDdNsrfBMn+GsCwiuwJhG4w/g=",
- "owner": "shazow",
- "repo": "foundry.nix",
- "rev": "9ecf12199280f738eaaad2d1224e54403dbdf426",
+ "lastModified": 1778507602,
+ "narHash": "sha256-kTwur1wV+01SdqskVMSo6JMEpg71ps3HpbFY2GsflKs=",
+ "owner": "cachix",
+ "repo": "git-hooks.nix",
+ "rev": "61ab0e80d9c7ab14c256b5b453d8b3fb0189ba0a",
"type": "github"
},
"original": {
- "owner": "shazow",
- "repo": "foundry.nix",
- "rev": "9ecf12199280f738eaaad2d1224e54403dbdf426",
+ "owner": "cachix",
+ "repo": "git-hooks.nix",
"type": "github"
}
},
- "naersk": {
+ "gitignore": {
"inputs": {
- "nixpkgs": "nixpkgs_3"
+ "nixpkgs": [
+ "rainix",
+ "git-hooks-nix",
+ "nixpkgs"
+ ]
},
"locked": {
- "lastModified": 1686572087,
- "narHash": "sha256-jXTut7ZSYqLEgm/nTk7TuVL2ExahTip605bLINklAnQ=",
- "owner": "nix-community",
- "repo": "naersk",
- "rev": "8507af04eb40c5520bd35d9ce6f9d2342cea5ad1",
+ "lastModified": 1709087332,
+ "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
+ "owner": "hercules-ci",
+ "repo": "gitignore.nix",
+ "rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
"type": "github"
},
"original": {
- "owner": "nix-community",
- "repo": "naersk",
+ "owner": "hercules-ci",
+ "repo": "gitignore.nix",
"type": "github"
}
},
@@ -141,41 +162,42 @@
},
"nixpkgs_2": {
"locked": {
- "lastModified": 1705061183,
- "narHash": "sha256-+AbYDMee1f3yP2IzGemiFOyTI4z+r+YJNcdn0LA6Qb0=",
- "owner": "nixos",
+ "lastModified": 1770073757,
+ "narHash": "sha256-Vy+G+F+3E/Tl+GMNgiHl9Pah2DgShmIUBJXmbiQPHbI=",
+ "owner": "NixOS",
"repo": "nixpkgs",
- "rev": "9e68f1146cacc5f45b6646e73c54c88c73e8df12",
+ "rev": "47472570b1e607482890801aeaf29bfb749884f6",
"type": "github"
},
"original": {
- "owner": "nixos",
+ "owner": "NixOS",
+ "ref": "nixpkgs-unstable",
"repo": "nixpkgs",
- "rev": "9e68f1146cacc5f45b6646e73c54c88c73e8df12",
"type": "github"
}
},
"nixpkgs_3": {
"locked": {
- "lastModified": 1687518131,
- "narHash": "sha256-KirltRIc4SFfk8bTNudIqgKAALH5oqpW3PefmkfWK5M=",
- "owner": "NixOS",
+ "lastModified": 1778656924,
+ "narHash": "sha256-lKVrom9wOmpC3i7m+uBoGaBdW0PfH3QbLRG1XmuC6YA=",
+ "owner": "nixos",
"repo": "nixpkgs",
- "rev": "3d8a93602bc54ece7a4e689d9aea1a574e2bbc24",
+ "rev": "4ba039de0909446943c07e2b42bd2f0f4507072e",
"type": "github"
},
"original": {
- "id": "nixpkgs",
- "type": "indirect"
+ "owner": "nixos",
+ "repo": "nixpkgs",
+ "type": "github"
}
},
"nixpkgs_4": {
"locked": {
- "lastModified": 1687518131,
- "narHash": "sha256-KirltRIc4SFfk8bTNudIqgKAALH5oqpW3PefmkfWK5M=",
+ "lastModified": 1744536153,
+ "narHash": "sha256-awS2zRgF4uTwrOKwwiJcByDzDOdo3Q1rPZbiHQg/N38=",
"owner": "NixOS",
"repo": "nixpkgs",
- "rev": "3d8a93602bc54ece7a4e689d9aea1a574e2bbc24",
+ "rev": "18dd725c29603f582cf1900e0d25f9f1063dbf11",
"type": "github"
},
"original": {
@@ -187,11 +209,11 @@
},
"nixpkgs_5": {
"locked": {
- "lastModified": 1681358109,
- "narHash": "sha256-eKyxW4OohHQx9Urxi7TQlFBTDWII+F+x2hklDOQPB50=",
+ "lastModified": 1777641297,
+ "narHash": "sha256-WNGcmeOZ8Tr9dq6ztCspYbzWFswr2mPebM9LpsfGxPk=",
"owner": "NixOS",
"repo": "nixpkgs",
- "rev": "96ba1c52e54e74c3197f4d43026b3f3d92e83ff9",
+ "rev": "c6d65881c5624c9cae5ea6cedef24699b0c0a4c0",
"type": "github"
},
"original": {
@@ -201,44 +223,25 @@
"type": "github"
}
},
- "rain": {
- "inputs": {
- "flake-utils": "flake-utils_4",
- "naersk": "naersk",
- "nixpkgs": "nixpkgs_4"
- },
- "locked": {
- "lastModified": 1700476138,
- "narHash": "sha256-cpKb/QMQQgoV4xiEI/TSEW48v/8MxvGA9Q9BK75DnH4=",
- "owner": "rainprotocol",
- "repo": "rain.cli",
- "rev": "6a912680be6d967fd6114aafab793ebe8503d27b",
- "type": "github"
- },
- "original": {
- "owner": "rainprotocol",
- "repo": "rain.cli",
- "type": "github"
- }
- },
"rainix": {
"inputs": {
"flake-utils": "flake-utils_2",
"foundry": "foundry",
- "nixpkgs": "nixpkgs_2",
- "rain": "rain",
- "rust-overlay": "rust-overlay"
+ "git-hooks-nix": "git-hooks-nix",
+ "nixpkgs": "nixpkgs_3",
+ "rust-overlay": "rust-overlay",
+ "solc": "solc"
},
"locked": {
- "lastModified": 1706606004,
- "narHash": "sha256-hzQNxK84OnaJ8GzG5g+iNTmvGn8HSPE6Fz0cqkt29Dg=",
- "owner": "rainprotocol",
+ "lastModified": 1780287289,
+ "narHash": "sha256-eZ74zj6VwotSmT1kXImwA2yX0el0pZthcgNjg7j/AyQ=",
+ "owner": "rainlanguage",
"repo": "rainix",
- "rev": "c7a063d7492c609d6ad07b5e1af059c5fe72e198",
+ "rev": "f22d4dcaca61717e33eac65e7b09b9a82f604c1f",
"type": "github"
},
"original": {
- "owner": "rainprotocol",
+ "owner": "rainlanguage",
"repo": "rainix",
"type": "github"
}
@@ -251,15 +254,14 @@
},
"rust-overlay": {
"inputs": {
- "flake-utils": "flake-utils_5",
- "nixpkgs": "nixpkgs_5"
+ "nixpkgs": "nixpkgs_4"
},
"locked": {
- "lastModified": 1706580650,
- "narHash": "sha256-e6q4Pn1dp3NoQJdMYdyNdDHU5IRBW9i3bHSJ3jThEL0=",
+ "lastModified": 1778642276,
+ "narHash": "sha256-bhk4lawR4ZnFhPtamB5WkCyvfgyZmsEUbWfT/3FRxFY=",
"owner": "oxalica",
"repo": "rust-overlay",
- "rev": "39e20b3c02caa91c9970beef325a04975d83d77f",
+ "rev": "77265d2dc1e61b2abfd3b1d6609dbb66fe75e0a5",
"type": "github"
},
"original": {
@@ -268,22 +270,39 @@
"type": "github"
}
},
- "systems": {
+ "solc": {
+ "inputs": {
+ "flake-utils": "flake-utils_4",
+ "nixpkgs": "nixpkgs_5",
+ "solc-macos-amd64-list-json": "solc-macos-amd64-list-json"
+ },
"locked": {
- "lastModified": 1681028828,
- "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
- "owner": "nix-systems",
- "repo": "default",
- "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
+ "lastModified": 1777817996,
+ "narHash": "sha256-iI71iUhD7THLibl3w1JcQEhHmTwZMxChi70RTe33BAo=",
+ "owner": "hellwolf",
+ "repo": "solc.nix",
+ "rev": "e3cf898cb804d5c0e5474b378a300fe8942e67d6",
"type": "github"
},
"original": {
- "owner": "nix-systems",
- "repo": "default",
+ "owner": "hellwolf",
+ "repo": "solc.nix",
"type": "github"
}
},
- "systems_2": {
+ "solc-macos-amd64-list-json": {
+ "flake": false,
+ "locked": {
+ "narHash": "sha256-zzwwHA2qPotv7yp8mK7+y9BZhm7ytuFeCJVvKBBdBn4=",
+ "type": "file",
+ "url": "https://github.com/argotorg/solc-bin/raw/902dfaf/macosx-amd64/list.json"
+ },
+ "original": {
+ "type": "file",
+ "url": "https://github.com/argotorg/solc-bin/raw/902dfaf/macosx-amd64/list.json"
+ }
+ },
+ "systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
@@ -298,7 +317,7 @@
"type": "github"
}
},
- "systems_3": {
+ "systems_2": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
@@ -313,7 +332,7 @@
"type": "github"
}
},
- "systems_4": {
+ "systems_3": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
diff --git a/flake.nix b/flake.nix
index 2be59344..1a6bb0b0 100644
--- a/flake.nix
+++ b/flake.nix
@@ -1,88 +1,82 @@
{
+ description = "Flake for development workflows.";
+
inputs = {
flake-utils.url = "github:numtide/flake-utils";
- rainix.url = "github:rainprotocol/rainix";
+ rainix.url = "github:rainlanguage/rainix";
};
- outputs = { self, flake-utils, rainix }:
-
- flake-utils.lib.eachDefaultSystem (system:
- let
- pkgs = rainix.pkgs.${system};
- in rec {
- packages = {
- build-bin = (pkgs.makeRustPlatform{
- rustc = rainix.rust-toolchain.${system};
- cargo = rainix.rust-toolchain.${system};
- }).buildRustPackage {
- src = ./.;
- doCheck = false;
- name = "dotrain";
- cargoLock.lockFile = ./Cargo.lock;
- # allows for git deps to be resolved without the need to specify their outputHash
- cargoLock.allowBuiltinFetchGit = true;
- buildPhase = ''
- cargo build --release --bin dotrain --features cli
- '';
- installPhase = ''
- mkdir -p $out/bin
- cp target/release/dotrain $out/bin/
- '';
- buildInputs = with pkgs; [
- openssl
- ];
- nativeBuildInputs = with pkgs; [
- pkg-config
- ] ++ lib.optionals stdenv.isDarwin [
- darwin.apple_sdk.frameworks.SystemConfiguration
- ];
- };
+ outputs =
+ { flake-utils, rainix, ... }:
+ flake-utils.lib.eachDefaultSystem (
+ system:
+ let
+ pkgs = rainix.pkgs.${system};
+ in
+ rec {
+ packages = {
+ build-bin =
+ (pkgs.makeRustPlatform {
+ rustc = rainix.rust-toolchain.${system};
+ cargo = rainix.rust-toolchain.${system};
+ }).buildRustPackage
+ {
+ src = ./.;
+ doCheck = false;
+ name = "dotrain";
+ cargoLock.lockFile = ./Cargo.lock;
+ cargoLock.allowBuiltinFetchGit = true;
+ buildPhase = ''
+ cargo build --release --bin dotrain --features cli
+ '';
+ installPhase = ''
+ mkdir -p $out/bin
+ cp target/release/dotrain $out/bin/
+ '';
+ buildInputs = with pkgs; [ openssl ];
+ nativeBuildInputs =
+ with pkgs;
+ [ pkg-config ] ++ lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.SystemConfiguration ];
+ };
- build-js-bindings = rainix.mkTask.${system} {
- name = "build-js-bindings";
- body = ''
- set -euxo pipefail
- npm install
- npm run build
- '';
- };
+ build-js-bindings = rainix.mkTask.${system} {
+ name = "build-js-bindings";
+ body = ''
+ set -euxo pipefail
+ npm install
+ npm run build
+ '';
+ };
- test-js-bindings = rainix.mkTask.${system} {
- name = "test-js-bindings";
- body = ''
- set -euxo pipefail
- npm test
- '';
- };
+ test-js-bindings = rainix.mkTask.${system} {
+ name = "test-js-bindings";
+ body = ''
+ set -euxo pipefail
+ npm test
+ '';
+ };
- js-bindings-docs = rainix.mkTask.${system} {
- name = "js-bindings-docs";
- body = ''
- set -euxo pipefail
- npm run docgen
- '';
- };
- } // rainix.packages.${system};
+ js-bindings-docs = rainix.mkTask.${system} {
+ name = "js-bindings-docs";
+ body = ''
+ set -euxo pipefail
+ npm run docgen
+ '';
+ };
+ }
+ // rainix.packages.${system};
- # # For `nix build` & `nix run`:
- defaultPackage = packages.build-bin;
+ defaultPackage = packages.build-bin;
- # For `nix develop`:
- devShells.default = pkgs.mkShell {
- packages = [
- packages.build-js-bindings
- packages.test-js-bindings
- packages.js-bindings-docs
- packages.rainix-rs-prelude
- packages.rainix-rs-static
- packages.rainix-rs-test
- packages.rainix-rs-artifacts
- ];
- buildInputs = rainix.devShells.${system}.default.buildInputs;
- nativeBuildInputs = rainix.devShells.${system}.default.nativeBuildInputs ++ (with pkgs; [
- wasm-bindgen-cli
- ]);
- };
- }
- );
-}
\ No newline at end of file
+ devShells.default = pkgs.mkShell {
+ inherit (rainix.devShells.${system}.rust-node-shell) shellHook;
+ packages = [
+ packages.build-js-bindings
+ packages.test-js-bindings
+ packages.js-bindings-docs
+ ];
+ inputsFrom = [ rainix.devShells.${system}.rust-node-shell ];
+ };
+ }
+ );
+}
diff --git a/package-lock.json b/package-lock.json
index 18f5e5cc..c9aa2789 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -22,10 +22,7 @@
"@typescript-eslint/parser": "^5.42.0",
"copyfiles": "^2.4.1",
"eslint": "^8.26.0",
- "eslint-config-prettier": "^9.1.0",
- "eslint-plugin-prettier": "^5.1.1",
"mocha": "^10.1.0",
- "prettier": "^3.1.1",
"ts-node": "^10.9.1",
"typescript": "^4.8.4"
},
@@ -426,18 +423,6 @@
"node": ">=8.0.0"
}
},
- "node_modules/@pkgr/core": {
- "version": "0.1.1",
- "resolved": "https://registry.npmjs.org/@pkgr/core/-/core-0.1.1.tgz",
- "integrity": "sha512-cq8o4cWH0ibXh9VGi5P20Tu9XF/0fFXl9EUinr9QfTM7a7p0oTA4iJRCQWppXR1Pg8dSM0UCItCkPwsk9qWWYA==",
- "dev": true,
- "engines": {
- "node": "^12.20.0 || ^14.18.0 || >=16.0.0"
- },
- "funding": {
- "url": "https://opencollective.com/unts"
- }
- },
"node_modules/@princjef/api-documenter": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@princjef/api-documenter/-/api-documenter-1.0.2.tgz",
@@ -1297,48 +1282,6 @@
"url": "https://opencollective.com/eslint"
}
},
- "node_modules/eslint-config-prettier": {
- "version": "9.1.0",
- "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-9.1.0.tgz",
- "integrity": "sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw==",
- "dev": true,
- "bin": {
- "eslint-config-prettier": "bin/cli.js"
- },
- "peerDependencies": {
- "eslint": ">=7.0.0"
- }
- },
- "node_modules/eslint-plugin-prettier": {
- "version": "5.1.3",
- "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-5.1.3.tgz",
- "integrity": "sha512-C9GCVAs4Eq7ZC/XFQHITLiHJxQngdtraXaM+LoUFoFp/lHNl2Zn8f3WQbe9HvTBBQ9YnKFB0/2Ajdqwo5D1EAw==",
- "dev": true,
- "dependencies": {
- "prettier-linter-helpers": "^1.0.0",
- "synckit": "^0.8.6"
- },
- "engines": {
- "node": "^14.18.0 || >=16.0.0"
- },
- "funding": {
- "url": "https://opencollective.com/eslint-plugin-prettier"
- },
- "peerDependencies": {
- "@types/eslint": ">=8.0.0",
- "eslint": ">=8.0.0",
- "eslint-config-prettier": "*",
- "prettier": ">=3.0.0"
- },
- "peerDependenciesMeta": {
- "@types/eslint": {
- "optional": true
- },
- "eslint-config-prettier": {
- "optional": true
- }
- }
- },
"node_modules/eslint-scope": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz",
@@ -1472,12 +1415,6 @@
"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==",
"dev": true
},
- "node_modules/fast-diff": {
- "version": "1.3.0",
- "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.3.0.tgz",
- "integrity": "sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==",
- "dev": true
- },
"node_modules/fast-glob": {
"version": "3.3.2",
"resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz",
@@ -2462,33 +2399,6 @@
"node": ">= 0.8.0"
}
},
- "node_modules/prettier": {
- "version": "3.2.4",
- "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.2.4.tgz",
- "integrity": "sha512-FWu1oLHKCrtpO1ypU6J0SbK2d9Ckwysq6bHj/uaCP26DxrPpppCLQRGVuqAxSTvhF00AcvDRyYrLNW7ocBhFFQ==",
- "dev": true,
- "bin": {
- "prettier": "bin/prettier.cjs"
- },
- "engines": {
- "node": ">=14"
- },
- "funding": {
- "url": "https://github.com/prettier/prettier?sponsor=1"
- }
- },
- "node_modules/prettier-linter-helpers": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz",
- "integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==",
- "dev": true,
- "dependencies": {
- "fast-diff": "^1.1.2"
- },
- "engines": {
- "node": ">=6.0.0"
- }
- },
"node_modules/process-nextick-args": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
@@ -2806,22 +2716,6 @@
"url": "https://github.com/sponsors/ljharb"
}
},
- "node_modules/synckit": {
- "version": "0.8.8",
- "resolved": "https://registry.npmjs.org/synckit/-/synckit-0.8.8.tgz",
- "integrity": "sha512-HwOKAP7Wc5aRGYdKH+dw0PRRpbO841v2DENBtjnR5HFWoiNByAl7vrx3p0G/rCyYXQsrxqtX48TImFtPcIHSpQ==",
- "dev": true,
- "dependencies": {
- "@pkgr/core": "^0.1.0",
- "tslib": "^2.6.2"
- },
- "engines": {
- "node": "^14.18.0 || >=16.0.0"
- },
- "funding": {
- "url": "https://opencollective.com/unts"
- }
- },
"node_modules/text-table": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz",
diff --git a/package.json b/package.json
index 111996e4..a62d25c5 100644
--- a/package.json
+++ b/package.json
@@ -55,10 +55,7 @@
"@typescript-eslint/parser": "^5.42.0",
"copyfiles": "^2.4.1",
"eslint": "^8.26.0",
- "eslint-config-prettier": "^9.1.0",
- "eslint-plugin-prettier": "^5.1.1",
"mocha": "^10.1.0",
- "prettier": "^3.1.1",
"ts-node": "^10.9.1",
"typescript": "^4.8.4"
},
diff --git a/scripts/prepare.js b/scripts/prepare.js
index a7e9b906..3b5a2b0d 100644
--- a/scripts/prepare.js
+++ b/scripts/prepare.js
@@ -45,8 +45,8 @@ fs.writeFileSync("./dist/esm/index.d.ts", dts);
// prepare cjs
let cjs = fs.readFileSync("./temp/node/dotrain_lsp.js", { encoding: "utf-8" });
cjs = cjs.replace(
- `const path = require('path').join(__dirname, 'dotrain_lsp_bg.wasm');
-const bytes = require('fs').readFileSync(path);`,
+ `const wasmPath = \`\${__dirname}/dotrain_lsp_bg.wasm\`;
+const wasmBytes = require('fs').readFileSync(wasmPath);`,
`
/**
* Method to be used as Tagged Templates to activate embedded rainlang in
@@ -70,7 +70,7 @@ module.exports = {
const { Buffer } = require('buffer');
const wasmB64 = require('../wasm.json');
-const bytes = Buffer.from(wasmB64.wasm, 'base64');`,
+const wasmBytes = Buffer.from(wasmB64.wasm, 'base64');`,
);
cjs = cjs.replace("const { TextDecoder, TextEncoder } = require(`util`);", "");
cjs = "/* this file is auto-generated, do not modify */\n" + cjs;
@@ -107,8 +107,8 @@ import { Buffer } from 'buffer';
import wasmB64 from '../wasm.json';
const bytes = Buffer.from(wasmB64.wasm, 'base64');
-const wasmModule = new WebAssembly.Module(bytes);
-const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
+wasmModule = new WebAssembly.Module(bytes);
+wasmInstance = new WebAssembly.Instance(wasmModule, imports);
wasm = wasmInstance.exports;`;
esm = esm.replaceAll("imports.wbg", "imports.__wbindgen_placeholder__");
esm = "/* this file is auto-generated, do not modify */\n" + esm;
diff --git a/test/completion.test.ts b/test/completion.test.ts
index b510e16a..b93d661d 100644
--- a/test/completion.test.ts
+++ b/test/completion.test.ts
@@ -13,6 +13,7 @@ async function testCompletion(
position: Position,
expectedCompletions: CompletionItem[] | null,
services: RainLanguageServices,
+ unordered = false,
) {
const actualCompletions = services.doComplete(
TextDocumentItem.create("file:///completion.test.rain", "rainlang", 1, text),
@@ -22,10 +23,23 @@ async function testCompletion(
if (expectedCompletions === null) assert.ok(actualCompletions === undefined);
else {
assert.ok(actualCompletions?.length == expectedCompletions?.length);
- expectedCompletions.forEach((item, i) => {
- assert.equal(actualCompletions[i].label, item.label);
- assert.equal(actualCompletions[i].kind, item.kind);
- });
+ // Namespace items come from an unordered map, so their suggestion order
+ // is not significant; compare them as a set keyed by label.
+ if (unordered) {
+ const byLabel = (a: CompletionItem, b: CompletionItem) =>
+ a.label < b.label ? -1 : a.label > b.label ? 1 : 0;
+ const actual = [...actualCompletions].sort(byLabel);
+ const expected = [...expectedCompletions].sort(byLabel);
+ expected.forEach((item, i) => {
+ assert.equal(actual[i].label, item.label);
+ assert.equal(actual[i].kind, item.kind);
+ });
+ } else {
+ expectedCompletions.forEach((item, i) => {
+ assert.equal(actualCompletions[i].label, item.label);
+ assert.equal(actualCompletions[i].kind, item.kind);
+ });
+ }
}
}
@@ -128,6 +142,7 @@ _: .`;
Position.create(5, 4),
items.filter((v) => v.label !== "Dispair"),
services,
+ true,
);
});
@@ -156,6 +171,7 @@ _: .r`;
Position.create(5, 5),
items.filter((v) => v.label !== "Dispair"),
services,
+ true,
);
});
});