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/03/17 11:28:50 UTC
[incubator-opendal] branch main updated: ci(bindings/nodejs): Enable formatter (#1665)
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 547fa129 ci(bindings/nodejs): Enable formatter (#1665)
547fa129 is described below
commit 547fa1291dddf4c4249642f942094213ff69b9e1
Author: Suyan <su...@gmail.com>
AuthorDate: Fri Mar 17 19:28:45 2023 +0800
ci(bindings/nodejs): Enable formatter (#1665)
chore(bindings/nodejs): Enable formatter
Signed-off-by: suyanhanx <su...@gmail.com>
---
bindings/nodejs/.prettierignore | 4 +++
bindings/nodejs/README.md | 6 ++--
bindings/nodejs/cucumber.json | 14 ++++-----
bindings/nodejs/package.json | 17 +++++++++++
bindings/nodejs/tests/binding.js | 62 ++++++++++++++++++++--------------------
bindings/nodejs/tsconfig.json | 10 ++-----
bindings/nodejs/yarn.lock | 10 +++++++
licenserc.toml | 1 +
8 files changed, 75 insertions(+), 49 deletions(-)
diff --git a/bindings/nodejs/.prettierignore b/bindings/nodejs/.prettierignore
new file mode 100644
index 00000000..3e7db534
--- /dev/null
+++ b/bindings/nodejs/.prettierignore
@@ -0,0 +1,4 @@
+target
+generated.js
+index.d.ts
+.yarn
diff --git a/bindings/nodejs/README.md b/bindings/nodejs/README.md
index 01a39b6d..8a7f3797 100644
--- a/bindings/nodejs/README.md
+++ b/bindings/nodejs/README.md
@@ -3,6 +3,7 @@
## Installation
### Node.js
+
```shell
npm install opendal
```
@@ -28,16 +29,17 @@ async function main() {
main();
```
-
## Test or 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 Node.js bindings
@@ -48,6 +50,6 @@ yarn build
yarn test
```
-
## License
+
[Apache v2.0](https://www.apache.org/licenses/LICENSE-2.0)
diff --git a/bindings/nodejs/cucumber.json b/bindings/nodejs/cucumber.json
index e488c6fc..ce3a32c8 100644
--- a/bindings/nodejs/cucumber.json
+++ b/bindings/nodejs/cucumber.json
@@ -1,11 +1,7 @@
{
- "default": {
- "publishQuiet": true,
- "paths": [
- "tests/*.feature"
- ],
- "require": [
- "tests/*.js"
- ]
- }
+ "default": {
+ "publishQuiet": true,
+ "paths": ["tests/*.feature"],
+ "require": ["tests/*.js"]
+ }
}
diff --git a/bindings/nodejs/package.json b/bindings/nodejs/package.json
index 98da3420..c46a0fef 100644
--- a/bindings/nodejs/package.json
+++ b/bindings/nodejs/package.json
@@ -37,6 +37,7 @@
"@swc-node/register": "^1.6.2",
"@swc/core": "^1.3.38",
"@types/node": "^18.14.5",
+ "prettier": "^2.8.4",
"typedoc": "^0.23.26",
"typescript": "^5.0.2"
},
@@ -48,10 +49,26 @@
"build": "napi build --platform --release --js generated.js --js-package-name @opendal/lib",
"build:debug": "napi build --platform --js generated.js --js-package-name @opendal/lib",
"docs": "typedoc",
+ "format": "prettier --write .",
"prepublishOnly": "napi prepublish -t npm",
"test": "cucumber-js",
"version": "napi version"
},
+ "prettier": {
+ "overrides": [
+ {
+ "files": "./**/*.{js,ts,mjs}",
+ "options": {
+ "printWidth": 120,
+ "semi": false,
+ "trailingComma": "all",
+ "singleQuote": true,
+ "arrowParens": "always",
+ "parser": "typescript"
+ }
+ }
+ ]
+ },
"packageManager": "yarn@3.4.1+sha224.cca891d4a8671d4898aba3426674bb734dbbf88cef82dd4dacd71c9f",
"resolutions": {
"@napi-rs/cli@^2.14.8": "patch:@napi-rs/cli@npm%3A2.14.8#./.yarn/patches/@napi-rs-cli-npm-2.14.8-71492d0ade.patch"
diff --git a/bindings/nodejs/tests/binding.js b/bindings/nodejs/tests/binding.js
index 435f6fcc..f77a4f79 100644
--- a/bindings/nodejs/tests/binding.js
+++ b/bindings/nodejs/tests/binding.js
@@ -19,58 +19,58 @@
const assert = require('assert')
const { Operator } = require('../index.js')
-const { Given, When, Then, } = require('@cucumber/cucumber')
+const { Given, When, Then } = require('@cucumber/cucumber')
Given('A new OpenDAL Blocking Operator', function () {
- this.op = new Operator("memory")
-});
+ this.op = new Operator('memory')
+})
When('Blocking write path {string} with content {string}', function (path, content) {
- this.op.writeSync(path, content)
-});
+ this.op.writeSync(path, content)
+})
Then('The blocking file {string} should exist', function (path) {
- this.op.statSync(path)
-});
+ this.op.statSync(path)
+})
Then('The blocking file {string} entry mode must be file', function (path) {
- let meta = this.op.statSync(path);
- assert(meta.isFile())
-});
+ let meta = this.op.statSync(path)
+ assert(meta.isFile())
+})
Then('The blocking file {string} content length must be "{int}"', function (path, size) {
- let meta = this.op.statSync(path);
- assert(meta.contentLength == size)
-});
+ let meta = this.op.statSync(path)
+ assert(meta.contentLength == size)
+})
Then('The blocking file {string} must have content {string}', function (path, content) {
- let bs = this.op.readSync(path);
- assert(bs.toString() == content)
-});
+ let bs = this.op.readSync(path)
+ assert(bs.toString() == content)
+})
Given('A new OpenDAL Async Operator', function () {
- this.op = new Operator("memory")
-});
+ this.op = new Operator('memory')
+})
When('Async write path {string} with content {string}', async function (path, content) {
- await this.op.write(path, content)
-});
+ await this.op.write(path, content)
+})
Then('The async file {string} should exist', async function (path) {
- await this.op.stat(path)
-});
+ await this.op.stat(path)
+})
Then('The async file {string} entry mode must be file', async function (path) {
- let meta = await this.op.stat(path);
- assert(meta.isFile())
-});
+ let meta = await this.op.stat(path)
+ assert(meta.isFile())
+})
Then('The async file {string} content length must be "{int}"', async function (path, size) {
- let meta = await this.op.stat(path);
- assert(meta.contentLength == size)
-});
+ let meta = await this.op.stat(path)
+ assert(meta.contentLength == size)
+})
Then('The async file {string} must have content {string}', async function (path, content) {
- let bs = await this.op.read(path);
- assert(bs.toString() == content)
-});
+ let bs = await this.op.read(path)
+ assert(bs.toString() == content)
+})
diff --git a/bindings/nodejs/tsconfig.json b/bindings/nodejs/tsconfig.json
index f391286f..969d7b3d 100644
--- a/bindings/nodejs/tsconfig.json
+++ b/bindings/nodejs/tsconfig.json
@@ -7,12 +7,8 @@
"noUnusedLocals": true,
"noUnusedParameters": true,
"esModuleInterop": true,
- "allowSyntheticDefaultImports": true,
+ "allowSyntheticDefaultImports": true
},
- "include": [
- "."
- ],
- "exclude": [
- "node_modules"
- ]
+ "include": ["."],
+ "exclude": ["node_modules"]
}
diff --git a/bindings/nodejs/yarn.lock b/bindings/nodejs/yarn.lock
index 51b4ca9e..bd989371 100644
--- a/bindings/nodejs/yarn.lock
+++ b/bindings/nodejs/yarn.lock
@@ -891,6 +891,7 @@ __metadata:
"@swc-node/register": ^1.6.2
"@swc/core": ^1.3.38
"@types/node": ^18.14.5
+ prettier: ^2.8.4
typedoc: ^0.23.26
typescript: ^5.0.2
languageName: unknown
@@ -919,6 +920,15 @@ __metadata:
languageName: node
linkType: hard
+"prettier@npm:^2.8.4":
+ version: 2.8.4
+ resolution: "prettier@npm:2.8.4"
+ bin:
+ prettier: bin-prettier.js
+ checksum: c173064bf3df57b6d93d19aa98753b9b9dd7657212e33b41ada8e2e9f9884066bb9ca0b4005b89b3ab137efffdf8fbe0b462785aba20364798ff4303aadda57e
+ languageName: node
+ linkType: hard
+
"progress@npm:^2.0.3":
version: 2.0.3
resolution: "progress@npm:2.0.3"
diff --git a/licenserc.toml b/licenserc.toml
index 22996989..befcb436 100644
--- a/licenserc.toml
+++ b/licenserc.toml
@@ -29,6 +29,7 @@ excludes = [
"**/fixtures/**",
"tests/data/**",
"bindings/nodejs/.npmignore",
+ "bindings/nodejs/.prettierignore",
"bindings/nodejs/generated*.*",
"**/*.node",
"bindings/python/test_requirements.txt",