Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
mathiask88 committed Dec 27, 2024
1 parent a2221a7 commit db34f29
Show file tree
Hide file tree
Showing 6 changed files with 319 additions and 80 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,31 @@ jobs:
with:
submodules: recursive
fetch-depth: 2

- name: Set up node
uses: actions/setup-node@v4
with:
node-version: 16
architecture: ${{ matrix.arch }}

- name: Install
run: npm install --ignore-scripts

- name: Prebuild
run: npm run prebuild-$BUILD_GROUP
shell: bash

- name: Prepare artifact
run: tar -zcvf $BUILD_GROUP.tar.gz -C prebuilds .
shell: bash

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.BUILD_GROUP }}
path: ${{ env.BUILD_GROUP }}.tar.gz
retention-days: 1

release:
needs: build
permissions:
Expand All @@ -66,13 +72,15 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts

- name: Create GitHub release
uses: docker://antonyurchenko/git-release:v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: artifacts/*/*.tar.gz
args: artifacts/*/*.tar.gz
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@ jobs:
with:
submodules: recursive
fetch-depth: 2

- name: Use node ${{ matrix.node }} ${{ matrix.arch }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
architecture: ${{ matrix.arch }}

- name: Install
run: npm install

- name: Test
run: npm test
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
"license": "MIT",
"readmeFilename": "README.md",
"dependencies": {
"node-gyp-build": "~4.8.0"
"node-gyp-build": "~4.8.4"
},
"devDependencies": {
"node-addon-api": "~7.1.0",
"node-gyp": "^10.0.1",
"prebuildify": "^6.0.0",
"node-addon-api": "~8.3.0",
"node-gyp": "^10.2.0",
"prebuildify": "^6.0.1",
"prebuildify-ci": "^1.0.5",
"prebuildify-cross": "^5.1.0"
"prebuildify-cross": "^5.1.1"
},
"scripts": {
"install": "node-gyp-build",
Expand Down
90 changes: 90 additions & 0 deletions src/node_snap7_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,11 @@ Napi::Value S7Client::ConnectTo(const Napi::CallbackInfo &info) {
Napi::Value S7Client::SetConnectionParams(const Napi::CallbackInfo &info) {
Napi::Env env = info.Env();

if (info.Length() < 3) {
Napi::TypeError::New(env, "Wrong number of arguments").ThrowAsJavaScriptException();
return env.Undefined();
}

if (!info[0].IsString() || !info[1].IsNumber() ||
!info[2].IsNumber()) {
Napi::TypeError::New(env, "Wrong arguments").ThrowAsJavaScriptException();
Expand All @@ -283,6 +288,11 @@ Napi::Value S7Client::SetConnectionParams(const Napi::CallbackInfo &info) {
Napi::Value S7Client::SetConnectionType(const Napi::CallbackInfo &info) {
Napi::Env env = info.Env();

if (info.Length() < 1) {
Napi::TypeError::New(env, "Wrong number of arguments").ThrowAsJavaScriptException();
return env.Undefined();
}

if (!info[0].IsNumber()) {
Napi::TypeError::New(env, "Wrong arguments").ThrowAsJavaScriptException();
return env.Undefined();
Expand All @@ -304,6 +314,11 @@ Napi::Value S7Client::Disconnect(const Napi::CallbackInfo &info) {
Napi::Value S7Client::GetParam(const Napi::CallbackInfo &info) {
Napi::Env env = info.Env();

if (info.Length() < 1) {
Napi::TypeError::New(env, "Wrong number of arguments").ThrowAsJavaScriptException();
return env.Undefined();
}

if (!info[0].IsNumber()) {
Napi::TypeError::New(env, "Wrong arguments").ThrowAsJavaScriptException();
return env.Undefined();
Expand All @@ -325,6 +340,11 @@ Napi::Value S7Client::GetParam(const Napi::CallbackInfo &info) {
Napi::Value S7Client::SetParam(const Napi::CallbackInfo &info) {
Napi::Env env = info.Env();

if (info.Length() < 2) {
Napi::TypeError::New(env, "Wrong number of arguments").ThrowAsJavaScriptException();
return env.Undefined();
}

if (!(info[0].IsNumber() || info[1].IsNumber())) {
Napi::TypeError::New(env, "Wrong arguments").ThrowAsJavaScriptException();
return env.Undefined();
Expand Down Expand Up @@ -961,6 +981,11 @@ Napi::Object S7Client::S7BlocksListToObject(
Napi::Value S7Client::GetAgBlockInfo(const Napi::CallbackInfo &info) {
Napi::Env env = info.Env();

if (info.Length() < 2) {
Napi::TypeError::New(env, "Wrong number of arguments").ThrowAsJavaScriptException();
return env.Undefined();
}

if (!info[0].IsNumber() || !info[1].IsNumber()) {
Napi::TypeError::New(env, "Wrong arguments").ThrowAsJavaScriptException();
return env.Undefined();
Expand Down Expand Up @@ -1024,6 +1049,11 @@ Napi::Object S7Client::S7BlockInfoToObject(PS7BlockInfo BlockInfo) {
Napi::Value S7Client::ListBlocksOfType(const Napi::CallbackInfo &info) {
Napi::Env env = info.Env();

if (info.Length() < 1) {
Napi::TypeError::New(env, "Wrong number of arguments").ThrowAsJavaScriptException();
return env.Undefined();
}

if (!info[0].IsNumber()) {
Napi::TypeError::New(env, "Wrong arguments").ThrowAsJavaScriptException();
return env.Undefined();
Expand Down Expand Up @@ -1056,6 +1086,11 @@ Napi::Array S7Client::S7BlocksOfTypeToArray(
Napi::Value S7Client::Upload(const Napi::CallbackInfo &info) {
Napi::Env env = info.Env();

if (info.Length() < 3) {
Napi::TypeError::New(env, "Wrong number of arguments").ThrowAsJavaScriptException();
return env.Undefined();
}

if (!info[0].IsNumber() || !info[1].IsNumber() || !info[2].IsNumber()) {
Napi::TypeError::New(env, "Wrong arguments").ThrowAsJavaScriptException();
return env.Undefined();
Expand All @@ -1074,6 +1109,11 @@ Napi::Value S7Client::Upload(const Napi::CallbackInfo &info) {
Napi::Value S7Client::FullUpload(const Napi::CallbackInfo &info) {
Napi::Env env = info.Env();

if (info.Length() < 3) {
Napi::TypeError::New(env, "Wrong number of arguments").ThrowAsJavaScriptException();
return env.Undefined();
}

if (!info[0].IsNumber() || !info[1].IsNumber() || !info[2].IsNumber()) {
Napi::TypeError::New(env, "Wrong arguments").ThrowAsJavaScriptException();
return env.Undefined();
Expand All @@ -1092,6 +1132,11 @@ Napi::Value S7Client::FullUpload(const Napi::CallbackInfo &info) {
Napi::Value S7Client::Download(const Napi::CallbackInfo &info) {
Napi::Env env = info.Env();

if (info.Length() < 2) {
Napi::TypeError::New(env, "Wrong number of arguments").ThrowAsJavaScriptException();
return env.Undefined();
}

if (!info[0].IsNumber() || info[1].IsBuffer()) {
Napi::TypeError::New(env, "Wrong arguments").ThrowAsJavaScriptException();
return env.Undefined();
Expand All @@ -1110,6 +1155,11 @@ Napi::Value S7Client::Download(const Napi::CallbackInfo &info) {
Napi::Value S7Client::Delete(const Napi::CallbackInfo &info) {
Napi::Env env = info.Env();

if (info.Length() < 2) {
Napi::TypeError::New(env, "Wrong number of arguments").ThrowAsJavaScriptException();
return env.Undefined();
}

if (!info[0].IsNumber() || !info[1].IsNumber()) {
Napi::TypeError::New(env, "Wrong arguments").ThrowAsJavaScriptException();
return env.Undefined();
Expand All @@ -1126,6 +1176,11 @@ Napi::Value S7Client::Delete(const Napi::CallbackInfo &info) {
Napi::Value S7Client::DBGet(const Napi::CallbackInfo &info) {
Napi::Env env = info.Env();

if (info.Length() < 1) {
Napi::TypeError::New(env, "Wrong number of arguments").ThrowAsJavaScriptException();
return env.Undefined();
}

if (!info[0].IsNumber()) {
Napi::TypeError::New(env, "Wrong arguments").ThrowAsJavaScriptException();
return env.Undefined();
Expand All @@ -1143,6 +1198,11 @@ Napi::Value S7Client::DBGet(const Napi::CallbackInfo &info) {
Napi::Value S7Client::DBFill(const Napi::CallbackInfo &info) {
Napi::Env env = info.Env();

if (info.Length() < 2) {
Napi::TypeError::New(env, "Wrong number of arguments").ThrowAsJavaScriptException();
return env.Undefined();
}

if (!info[0].IsNumber() || !(info[1].IsNumber() || info[1].IsString())) {
Napi::TypeError::New(env, "Wrong arguments").ThrowAsJavaScriptException();
return env.Undefined();
Expand Down Expand Up @@ -1178,6 +1238,11 @@ Napi::Value S7Client::GetPlcDateTime(const Napi::CallbackInfo &info) {
Napi::Value S7Client::SetPlcDateTime(const Napi::CallbackInfo &info) {
Napi::Env env = info.Env();

if (info.Length() < 1) {
Napi::TypeError::New(env, "Wrong number of arguments").ThrowAsJavaScriptException();
return env.Undefined();
}

if (!(info[0].IsObject() || info[0].IsDate())) {
Napi::TypeError::New(env, "Wrong arguments").ThrowAsJavaScriptException();
return env.Undefined();
Expand Down Expand Up @@ -1287,6 +1352,11 @@ Napi::Object S7Client::S7CpInfoToObject(PS7CpInfo CpInfo) {
Napi::Value S7Client::ReadSZL(const Napi::CallbackInfo &info) {
Napi::Env env = info.Env();

if (info.Length() < 2) {
Napi::TypeError::New(env, "Wrong number of arguments").ThrowAsJavaScriptException();
return env.Undefined();
}

if (!(info[0].IsNumber() || info[1].IsNumber())) {
Napi::TypeError::New(env, "Wrong arguments").ThrowAsJavaScriptException();
return env.Undefined();
Expand Down Expand Up @@ -1356,6 +1426,11 @@ Napi::Value S7Client::PlcStop(const Napi::CallbackInfo &info) {
Napi::Value S7Client::CopyRamToRom(const Napi::CallbackInfo &info) {
Napi::Env env = info.Env();

if (info.Length() < 1) {
Napi::TypeError::New(env, "Wrong number of arguments").ThrowAsJavaScriptException();
return env.Undefined();
}

if (!info[0].IsNumber()) {
Napi::TypeError::New(env, "Wrong arguments").ThrowAsJavaScriptException();
return env.Undefined();
Expand All @@ -1371,6 +1446,11 @@ Napi::Value S7Client::CopyRamToRom(const Napi::CallbackInfo &info) {
Napi::Value S7Client::Compress(const Napi::CallbackInfo &info) {
Napi::Env env = info.Env();

if (info.Length() < 1) {
Napi::TypeError::New(env, "Wrong number of arguments").ThrowAsJavaScriptException();
return env.Undefined();
}

if (!info[0].IsNumber()) {
Napi::TypeError::New(env, "Wrong arguments").ThrowAsJavaScriptException();
return env.Undefined();
Expand Down Expand Up @@ -1413,6 +1493,11 @@ Napi::Object S7Client::S7ProtectionToObject(
Napi::Value S7Client::SetSessionPassword(const Napi::CallbackInfo &info) {
Napi::Env env = info.Env();

if (info.Length() < 1) {
Napi::TypeError::New(env, "Wrong number of arguments").ThrowAsJavaScriptException();
return env.Undefined();
}

if (!info[0].IsString()) {
Napi::TypeError::New(env, "Wrong arguments").ThrowAsJavaScriptException();
return env.Undefined();
Expand Down Expand Up @@ -1495,6 +1580,11 @@ Napi::Value S7Client::Connected(const Napi::CallbackInfo &info) {
Napi::Value S7Client::ErrorText(const Napi::CallbackInfo &info) {
Napi::Env env = info.Env();

if (info.Length() < 1) {
Napi::TypeError::New(env, "Wrong number of arguments").ThrowAsJavaScriptException();
return env.Undefined();
}

if (!info[0].IsNumber()) {
Napi::TypeError::New(env, "Wrong arguments").ThrowAsJavaScriptException();
return env.Undefined();
Expand Down
Loading

0 comments on commit db34f29

Please sign in to comment.