You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by xu...@apache.org on 2023/04/30 14:50:24 UTC

[incubator-opendal] 01/01: docs(nodejs): Add CONTRIBUTING docs

This is an automated email from the ASF dual-hosted git repository.

xuanwo pushed a commit to branch add-contributing
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git

commit 4f90c806de70eba0b54df5e9c9dc09ef1c5b9109
Author: Xuanwo <gi...@xuanwo.io>
AuthorDate: Sun Apr 30 22:50:05 2023 +0800

    docs(nodejs): Add CONTRIBUTING docs
    
    Signed-off-by: Xuanwo <gi...@xuanwo.io>
---
 .devcontainer/devcontainer.json | 32 ++++++++---------
 .devcontainer/post_create.sh    | 17 +++++++++
 CONTRIBUTING.md                 |  5 ++-
 README.md                       |  2 +-
 bindings/nodejs/.node-version   |  1 +
 bindings/nodejs/CONTRIBUTING.md | 79 +++++++++++++++++++++++++++++++++++++++++
 bindings/nodejs/README.md       | 35 +++---------------
 rust-toolchain.toml             |  2 +-
 8 files changed, 121 insertions(+), 52 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/.devcontainer/post_create.sh b/.devcontainer/post_create.sh
new file mode 100644
index 00000000..ab5e630c
--- /dev/null
+++ b/.devcontainer/post_create.sh
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+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
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..9ee06b2f
--- /dev/null
+++ b/bindings/nodejs/CONTRIBUTING.md
@@ -0,0 +1,79 @@
+# 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 devcontainer 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:
+
+[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](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
+> corepack prepare yarn@stable --activate
+```
+
+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"]