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/30 08:05:43 UTC
[incubator-opendal] branch main updated: chore(bindings/nodejs): Fix generated headers (#1802)
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 3488ec31 chore(bindings/nodejs): Fix generated headers (#1802)
3488ec31 is described below
commit 3488ec31867c2ac392e0c685bcec103f1bdd322f
Author: Xuanwo <gi...@xuanwo.io>
AuthorDate: Thu Mar 30 16:05:36 2023 +0800
chore(bindings/nodejs): Fix generated headers (#1802)
* chore(bindings/nodejs): Fix generated headers
Signed-off-by: Xuanwo <gi...@xuanwo.io>
* Add check for format
Signed-off-by: Xuanwo <gi...@xuanwo.io>
* Fix typo
Signed-off-by: Xuanwo <gi...@xuanwo.io>
---------
Signed-off-by: Xuanwo <gi...@xuanwo.io>
---
.github/workflows/bindings_nodejs.yml | 5 ++++
bindings/nodejs/benchmark/lib.js | 6 ++---
bindings/nodejs/generated.js | 36 ++++++++++++++++++-------
bindings/nodejs/package.json | 4 +--
bindings/nodejs/scripts/header.js | 49 +++++++++++++++++++++++++++++++++++
5 files changed, 86 insertions(+), 14 deletions(-)
diff --git a/.github/workflows/bindings_nodejs.yml b/.github/workflows/bindings_nodejs.yml
index a7861371..b1d93962 100644
--- a/.github/workflows/bindings_nodejs.yml
+++ b/.github/workflows/bindings_nodejs.yml
@@ -59,10 +59,15 @@ jobs:
node-version: ${{ matrix.node }}
cache: yarn
cache-dependency-path: "bindings/nodejs/yarn.lock"
+
- name: Corepack
run: corepack enable
- name: Install dependencies
run: yarn install
+
+ - name: Check format
+ run: yarn run prettier --check .
+
- name: Build
run: yarn build:debug
- name: Test bindings
diff --git a/bindings/nodejs/benchmark/lib.js b/bindings/nodejs/benchmark/lib.js
index 5d985dba..5df3c75d 100644
--- a/bindings/nodejs/benchmark/lib.js
+++ b/bindings/nodejs/benchmark/lib.js
@@ -55,7 +55,7 @@ const client = new S3Client({
module.exports.opendal = {
read: (path) => opendal.read(path),
- write: (path, data) => opendal.write(path, data)
+ write: (path, data) => opendal.write(path, data),
}
module.exports.s3 = {
@@ -73,7 +73,7 @@ module.exports.s3 = {
Bucket: bucket,
})
return client.send(command)
- }
+ },
}
-module.exports.testFiles = testFiles
\ No newline at end of file
+module.exports.testFiles = testFiles
diff --git a/bindings/nodejs/generated.js b/bindings/nodejs/generated.js
index 6d918d7b..bd094f42 100644
--- a/bindings/nodejs/generated.js
+++ b/bindings/nodejs/generated.js
@@ -81,7 +81,9 @@ switch (platform) {
case 'win32':
switch (arch) {
case 'x64':
- localFileExisted = existsSync(join(__dirname, 'opendal.win32-x64-msvc.node'))
+ localFileExisted = existsSync(
+ join(__dirname, 'opendal.win32-x64-msvc.node')
+ )
try {
if (localFileExisted) {
nativeBinding = require('./opendal.win32-x64-msvc.node')
@@ -93,7 +95,9 @@ switch (platform) {
}
break
case 'ia32':
- localFileExisted = existsSync(join(__dirname, 'opendal.win32-ia32-msvc.node'))
+ localFileExisted = existsSync(
+ join(__dirname, 'opendal.win32-ia32-msvc.node')
+ )
try {
if (localFileExisted) {
nativeBinding = require('./opendal.win32-ia32-msvc.node')
@@ -105,7 +109,9 @@ switch (platform) {
}
break
case 'arm64':
- localFileExisted = existsSync(join(__dirname, 'opendal.win32-arm64-msvc.node'))
+ localFileExisted = existsSync(
+ join(__dirname, 'opendal.win32-arm64-msvc.node')
+ )
try {
if (localFileExisted) {
nativeBinding = require('./opendal.win32-arm64-msvc.node')
@@ -144,7 +150,9 @@ switch (platform) {
}
break
case 'arm64':
- localFileExisted = existsSync(join(__dirname, 'opendal.darwin-arm64.node'))
+ localFileExisted = existsSync(
+ join(__dirname, 'opendal.darwin-arm64.node')
+ )
try {
if (localFileExisted) {
nativeBinding = require('./opendal.darwin-arm64.node')
@@ -178,7 +186,9 @@ switch (platform) {
switch (arch) {
case 'x64':
if (isMusl()) {
- localFileExisted = existsSync(join(__dirname, 'opendal.linux-x64-musl.node'))
+ localFileExisted = existsSync(
+ join(__dirname, 'opendal.linux-x64-musl.node')
+ )
try {
if (localFileExisted) {
nativeBinding = require('./opendal.linux-x64-musl.node')
@@ -189,7 +199,9 @@ switch (platform) {
loadError = e
}
} else {
- localFileExisted = existsSync(join(__dirname, 'opendal.linux-x64-gnu.node'))
+ localFileExisted = existsSync(
+ join(__dirname, 'opendal.linux-x64-gnu.node')
+ )
try {
if (localFileExisted) {
nativeBinding = require('./opendal.linux-x64-gnu.node')
@@ -203,7 +215,9 @@ switch (platform) {
break
case 'arm64':
if (isMusl()) {
- localFileExisted = existsSync(join(__dirname, 'opendal.linux-arm64-musl.node'))
+ localFileExisted = existsSync(
+ join(__dirname, 'opendal.linux-arm64-musl.node')
+ )
try {
if (localFileExisted) {
nativeBinding = require('./opendal.linux-arm64-musl.node')
@@ -214,7 +228,9 @@ switch (platform) {
loadError = e
}
} else {
- localFileExisted = existsSync(join(__dirname, 'opendal.linux-arm64-gnu.node'))
+ localFileExisted = existsSync(
+ join(__dirname, 'opendal.linux-arm64-gnu.node')
+ )
try {
if (localFileExisted) {
nativeBinding = require('./opendal.linux-arm64-gnu.node')
@@ -227,7 +243,9 @@ switch (platform) {
}
break
case 'arm':
- localFileExisted = existsSync(join(__dirname, 'opendal.linux-arm-gnueabihf.node'))
+ localFileExisted = existsSync(
+ join(__dirname, 'opendal.linux-arm-gnueabihf.node')
+ )
try {
if (localFileExisted) {
nativeBinding = require('./opendal.linux-arm-gnueabihf.node')
diff --git a/bindings/nodejs/package.json b/bindings/nodejs/package.json
index 79fc7075..92009da7 100644
--- a/bindings/nodejs/package.json
+++ b/bindings/nodejs/package.json
@@ -60,8 +60,8 @@
},
"scripts": {
"artifacts": "napi artifacts",
- "build": "napi build --platform --release --js generated.js",
- "build:debug": "napi build --platform --js generated.js",
+ "build": "napi build --platform --release --js generated.js && node ./scripts/header.js",
+ "build:debug": "napi build --platform --js generated.js && node ./scripts/header.js",
"docs": "typedoc",
"format": "prettier --write .",
"prepublishOnly": "napi prepublish -t npm",
diff --git a/bindings/nodejs/scripts/header.js b/bindings/nodejs/scripts/header.js
new file mode 100644
index 00000000..fd10f52b
--- /dev/null
+++ b/bindings/nodejs/scripts/header.js
@@ -0,0 +1,49 @@
+/*
+ * 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
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+const fs = require('fs')
+
+let files = ['generated.js', 'index.d.ts']
+
+for (path of files) {
+ let data = fs.readFileSync(path, 'utf8')
+ fs.writeFileSync(
+ path,
+ `/*
+ * 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
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+` + data,
+ )
+}