Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(bindings/nodejs): Fix generated headers #1802

Merged
merged 3 commits into from
Mar 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/bindings_nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,15 @@ jobs:
node-version: ${{ matrix.node }}
cache: yarn
cache-dependency-path: "bindings/nodejs/yarn.lock"

- name: Corepack
Xuanwo marked this conversation as resolved.
Show resolved Hide resolved
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
Expand Down
6 changes: 3 additions & 3 deletions bindings/nodejs/benchmark/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -73,7 +73,7 @@ module.exports.s3 = {
Bucket: bucket,
})
return client.send(command)
}
},
}

module.exports.testFiles = testFiles
module.exports.testFiles = testFiles
36 changes: 27 additions & 9 deletions bindings/nodejs/generated.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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')
Expand All @@ -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')
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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')
Expand All @@ -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')
Expand All @@ -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')
Expand All @@ -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')
Expand All @@ -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')
Expand Down
4 changes: 2 additions & 2 deletions bindings/nodejs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
49 changes: 49 additions & 0 deletions bindings/nodejs/scripts/header.js
Original file line number Diff line number Diff line change
@@ -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,
)
}