This is an automated email from the ASF dual-hosted git repository.
xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git
The following commit(s) were added to refs/heads/main by this push:
new e387fe8c docs(nodejs): Add CONTRIBUTING docs (#2174)
e387fe8c is described below
commit e387fe8cc5900bb763480697d39561e73eaedaf4
Author: Xuanwo <[email protected]>
AuthorDate: Sun Apr 30 23:30:11 2023 +0800
docs(nodejs): Add CONTRIBUTING docs (#2174)
* docs(nodejs): Add CONTRIBUTING docs
Signed-off-by: Xuanwo <[email protected]>
* Add license header
Signed-off-by: Xuanwo <[email protected]>
* Setup java
Signed-off-by: Xuanwo <[email protected]>
* Link to default
Signed-off-by: Xuanwo <[email protected]>
* Update bindings/nodejs/CONTRIBUTING.md
Co-authored-by: Suyan <[email protected]>
* Remove updata of yarn
Signed-off-by: Xuanwo <[email protected]>
* Fix
Signed-off-by: Xuanwo <[email protected]>
---------
Signed-off-by: Xuanwo <[email protected]>
Co-authored-by: Suyan <[email protected]>
---
.devcontainer/devcontainer.json | 32 ++++-----
.../post_create.sh | 24 ++++++-
CONTRIBUTING.md | 5 +-
README.md | 2 +-
bindings/nodejs/.node-version | 1 +
bindings/nodejs/CONTRIBUTING.md | 78 ++++++++++++++++++++++
bindings/nodejs/README.md | 35 ++--------
rust-toolchain.toml | 2 +-
8 files changed, 124 insertions(+), 55 deletions(-)
diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
index 57f60c91..9709258e 100644
--- a/.devcontainer/devcontainer.json
+++ b/.devcontainer/devcontainer.json
@@ -1,18 +1,18 @@
{
- "name": "OpenDAL",
- "image": "mcr.microsoft.com/devcontainers/rust:bullseye",
- "postCreateCommand": "sudo apt update && sudo apt install -y ruby-dev
libclang-dev python3-dev",
- "customizations": {
- "vscode": {
- "extensions": [
- "rust-lang.rust-analyzer"
- ],
- "settings": {
- "editor.formatOnSave": true,
- "files.exclude": {
- "**/LICENSE": true
- }
- }
- }
- }
+ "name": "OpenDAL",
+ "image": "mcr.microsoft.com/devcontainers/rust:bullseye",
+ "postCreateCommand": "bash .devcontainer/post_create.sh",
+ "customizations": {
+ "vscode": {
+ "extensions": [
+ "rust-lang.rust-analyzer"
+ ],
+ "settings": {
+ "editor.formatOnSave": true,
+ "files.exclude": {
+ "**/LICENSE": true
+ }
+ }
+ }
+ }
}
diff --git a/rust-toolchain.toml b/.devcontainer/post_create.sh
similarity index 56%
copy from rust-toolchain.toml
copy to .devcontainer/post_create.sh
index 870d7eb7..1397aa47 100644
--- a/rust-toolchain.toml
+++ b/.devcontainer/post_create.sh
@@ -1,3 +1,4 @@
+#!/bin/bash
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
@@ -15,6 +16,23 @@
# specific language governing permissions and limitations
# under the License.
-[toolchain]
-channel = "stable"
-components = ["rustfmt", "clippy"]
+set -e
+
+# Update apt repo
+sudo apt update
+
+# Setup for ruby binding
+sudo apt install -y ruby-dev libclang-dev
+
+# Setup for python binding
+sudo apt install -y python3-dev
+
+# Setup for nodejs binding
+curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - && sudo
apt-get install -y nodejs
+sudo corepack enable
+corepack prepare yarn@stable --activate
+
+# Setup for java binding
+sudo apt install -y default-jdk
+echo "export JAVA_HOME=$(readlink -f /usr/bin/java | sed "s:/bin/java::")" |
sudo tee /etc/profile.d/java_home.sh
+sudo ln -s /usr/lib/jvm/default-java /usr/lib/jvm/default
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index b794a14b..624abe8d 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -59,8 +59,6 @@ All pull requests are squash merged. We generally discourage
large pull requests
Currently, OpenDAL uses GitHub Actions to run tests. The workflows are defined
in `.github/workflows`.
-## Next steps
-
## Setup
For small or first-time contributions, we recommend the dev container method.
Prefer to do it yourself? That's fine too!
@@ -94,7 +92,8 @@ cargo 1.69.0 (6e9a83356 2023-04-12)
Some components may require specific setup steps. Please refer to their
respective `CONTRIBUTING` documentation for more details.
-- [core](core/CONTRIBUTING.md)
+- [Core](core/CONTRIBUTING.md)
+- [Node.js Binding](bindings/nodejs/CONTRIBUTING.md)
## Code of Conduct
diff --git a/README.md b/README.md
index 7c0eb3fb..1b494a15 100644
--- a/README.md
+++ b/README.md
@@ -30,7 +30,7 @@ Major components of the project include:
## How to contribute OpenDAL
-- Start with [Contributing Guide](CONTRIBUTING.md)
+- Start with [Contributing Guide](CONTRIBUTING.md).
- Submit [Issues](https://github.com/apache/incubator-opendal/issues/new) for
bug report or feature requests.
- Asking questions in the
[Discussions](https://github.com/apache/incubator-opendal/discussions/new?category=q-a).
- Talk to community at [Discord](https://discord.gg/XQy8yGR2dg).
diff --git a/bindings/nodejs/.node-version b/bindings/nodejs/.node-version
new file mode 100644
index 00000000..3c032078
--- /dev/null
+++ b/bindings/nodejs/.node-version
@@ -0,0 +1 @@
+18
diff --git a/bindings/nodejs/CONTRIBUTING.md b/bindings/nodejs/CONTRIBUTING.md
new file mode 100644
index 00000000..054a8e2a
--- /dev/null
+++ b/bindings/nodejs/CONTRIBUTING.md
@@ -0,0 +1,78 @@
+# Contributing
+
+- [Setup](#setup)
+ - [Using a devcontainer environment](#using-a-devcontainer-environment)
+ - [Bring your own toolbox](#bring-your-own-toolbox)
+- [Build](#build)
+- [Test](#test)
+
+## Setup
+
+Building `nodejs` bindings requires some extra setup.
+
+For small or first-time contributions, we recommend the dev container method.
Prefer to do it yourself? That's fine too!
+
+### Using a dev container environment
+
+OpenDAL provides a pre-configured [dev container](https://containers.dev/)
that could be used in [Github
Codespaces](https://github.com/features/codespaces),
[VSCode](https://code.visualstudio.com/),
[JetBrains](https://www.jetbrains.com/remote-development/gateway/),
[JuptyerLab](https://jupyterlab.readthedocs.io/en/stable/). Please pick up your
favourite runtime environment.
+
+The fastest way is:
+
+[](https://codespaces.new/apache/incubator-opendal?quickstart=1&machine=standardLinux32gb)
+
+### Bring your own toolbox
+
+The `nodejs` binding requires `Node.js@16+` to be built. We recommend using
the latest TLS version for development.
+
+OpenDAL provides a `.node-version` file that specifies the recommended node
versions. You can use any compatible tool to install the correct node version,
such as [fnm](https://github.com/Schniz/fnm).
+
+Alternatively, you can manually install the LTS node by following these steps:
+
+For Ubuntu and Debian:
+
+```shell
+> curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - && sudo
apt-get install -y nodejs
+```
+
+For RHEL, CentOS, CloudLinux, Amazon Linux or Fedora:
+
+```shell
+> curl -fsSL https://rpm.nodesource.com/setup_lts.x | sudo bash -
+```
+
+Afterwards, you will need to enable `corepack` to ensure that `yarn` has been
set up correctly:
+
+```shell
+> sudo corepack enable
+```
+
+To verify that everything is working properly, run `yarn --version`:
+
+```shell
+> yarn --version
+3.4.1
+```
+
+## Build
+
+```bash
+# Install dependencies.
+> yarn
+# Build from source.
+> yarn build
+# Build from source with debug info.
+> yarn build:debug
+```
+
+## Test
+
+We use [`Cucumber`](https://cucumber.io/) for behavior testing. Refer to
[here](https://cucumber.io/docs/guides/overview/) for more information about
`Cucumber`.
+
+```bash
+> yarn test
+............
+
+2 scenarios (2 passed)
+12 steps (12 passed)
+0m00.055s (executing steps: 0m00.004s)
+```
diff --git a/bindings/nodejs/README.md b/bindings/nodejs/README.md
index f57fe91c..07accaaf 100644
--- a/bindings/nodejs/README.md
+++ b/bindings/nodejs/README.md
@@ -2,8 +2,6 @@
## Installation
-### Node.js
-
```shell
npm install opendal
```
@@ -31,35 +29,10 @@ main();
## Contributing
-- Install latest `Rust`
-- Install `Node.js@10+` which fully supported `Node-API`
-
-We are using `corepack` to specific package manager:
-
-```shell
-corepack enable
-```
-
-`corepack` is distributed with Node.js, so you do not need to specifically
look for a way to install it.
-
-### Build
-
-```bash
-# Install dependencies.
-yarn
-# Build from source.
-yarn build
-# Build from source with debug info.
-yarn build:debug
-```
-
-### Test
-
-```bash
-yarn test
-```
-
-We use [`Cucumber`](https://cucumber.io/) for behavior testing. Refer to
[here](https://cucumber.io/docs/guides/overview/) for more information about
`Cucumber`.
+- Start with [Contributing Guide](CONTRIBUTING.md).
+- Submit [Issues](https://github.com/apache/incubator-opendal/issues/new) for
bug report or feature requests.
+- Asking questions in the
[Discussions](https://github.com/apache/incubator-opendal/discussions/new?category=q-a).
+- Talk to community at [Discord](https://discord.gg/XQy8yGR2dg).
## License
diff --git a/rust-toolchain.toml b/rust-toolchain.toml
index 870d7eb7..1ba83454 100644
--- a/rust-toolchain.toml
+++ b/rust-toolchain.toml
@@ -17,4 +17,4 @@
[toolchain]
channel = "stable"
-components = ["rustfmt", "clippy"]
+components = ["rustfmt", "clippy", "rust-analyzer"]