Skip to content

Commit 8840db0

Browse files
authored
chore: modernize the package (#450)
1 parent c1b0aa3 commit 8840db0

45 files changed

Lines changed: 2130 additions & 9719 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/codeql-analysis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525

2626
steps:
2727
- name: Checkout repository
28-
uses: actions/checkout@v2
28+
uses: actions/checkout@v6
2929
with:
3030
# We must fetch at least the immediate parents so that if this is
3131
# a pull request then we can checkout the head.
@@ -38,14 +38,14 @@ jobs:
3838

3939
# Initializes the CodeQL tools for scanning.
4040
- name: Initialize CodeQL
41-
uses: github/codeql-action/init@v1
41+
uses: github/codeql-action/init@v4
4242
with:
4343
languages: ${{ matrix.language }}
4444

4545
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
4646
# If this step fails, then you should remove it and run the build manually (see below)
4747
- name: Autobuild
48-
uses: github/codeql-action/autobuild@v1
48+
uses: github/codeql-action/autobuild@v4
4949

5050
# ℹ️ Command-line programs to run using the OS shell.
5151
# 📚 https://git.io/JvXDl
@@ -59,4 +59,4 @@ jobs:
5959
# make release
6060

6161
- name: Perform CodeQL Analysis
62-
uses: github/codeql-action/analyze@v1
62+
uses: github/codeql-action/analyze@v4

.github/workflows/dependabot-automerge.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
runs-on: ubuntu-latest
1515
steps:
1616
- name: Checkout code
17-
uses: actions/checkout@v2
17+
uses: actions/checkout@v6
1818

1919
- name: Check if PR should be auto-merged
2020
uses: ahmadnassri/action-dependabot-auto-merge@v2
Lines changed: 91 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,81 @@
1+
# This is a composition of lint and test scripts
2+
13
name: Test and Release
24

35
# Run this job on all pushes and pull requests
46
# as well as tags with a semantic version
57
on:
6-
push:
7-
branches:
8-
- master
9-
tags:
10-
# normal versions
11-
- "v[0-9]+.[0-9]+.[0-9]+"
12-
# pre-releases
13-
- "v[0-9]+.[0-9]+.[0-9]+-**"
14-
pull_request: {}
8+
push:
9+
branches:
10+
- master
11+
tags:
12+
# normal versions
13+
- "v[0-9]+.[0-9]+.[0-9]+"
14+
# pre-releases
15+
- "v[0-9]+.[0-9]+.[0-9]+-**"
16+
pull_request: {}
17+
18+
permissions:
19+
id-token: write # Required for publishing with OIDC
20+
contents: write # Required for creating releases
1521

1622
jobs:
1723
# Performs quick checks before the expensive test runs
1824
check-and-lint:
19-
if: contains(github.event.head_commit.message, '[skip ci]') == false
20-
2125
runs-on: ubuntu-latest
2226
strategy:
2327
matrix:
24-
node-version: [16.x]
28+
node-version: [24]
2529

2630
steps:
27-
- uses: actions/checkout@v3
28-
- name: Use Node.js ${{ matrix.node-version }}
29-
uses: actions/setup-node@v3
30-
with:
31-
node-version: ${{ matrix.node-version }}
32-
cache: 'npm'
31+
- uses: actions/checkout@v6
32+
- name: Use Node.js ${{ matrix.node-version }}
33+
uses: actions/setup-node@v6
34+
with:
35+
node-version: ${{ matrix.node-version }}
36+
cache: 'npm'
3337

34-
- name: Install dependencies
35-
run: npm ci
38+
- name: Install dependencies
39+
run: npm ci
3640

37-
- name: Lint TypeScript code
38-
run: npm run lint
41+
- name: Lint TypeScript code
42+
run: npm run lint
3943

40-
- name: Compile TypeScript code
41-
run: npm run build
44+
- name: Compile TypeScript code
45+
run: npm run build
4246

4347
# ===================
4448

4549
# Runs unit tests on all supported node versions and OSes
4650
unit-tests:
47-
if: contains(github.event.head_commit.message, '[skip ci]') == false
48-
49-
runs-on: ${{ matrix.os }}
51+
runs-on: ubuntu-latest
5052
strategy:
5153
matrix:
52-
node-version: [12.x, 14.x, 16.x, 18.x]
53-
os: [ubuntu-latest]
54+
node-version: [22, 24]
5455

5556
steps:
56-
- uses: actions/checkout@v3
57-
- name: Use Node.js ${{ matrix.node-version }}
58-
uses: actions/setup-node@v3
59-
with:
60-
node-version: ${{ matrix.node-version }}
61-
cache: 'npm'
62-
63-
- name: Install dependencies
64-
run: npm ci
65-
66-
- name: Run component tests
67-
run: npm run test:ts
68-
env:
69-
CI: true
57+
- uses: actions/checkout@v6
58+
- name: Use Node.js ${{ matrix.node-version }}
59+
uses: actions/setup-node@v6
60+
with:
61+
node-version: ${{ matrix.node-version }}
62+
cache: 'npm'
63+
64+
- name: Install dependencies
65+
run: npm ci
66+
67+
- name: Run component tests
68+
# Some tests are flaky, try them 3 times if necessary
69+
run: npm run test:ts || npm run test:ts || npm run test:ts
70+
env:
71+
CI: true
7072

7173
# ===================
7274

7375
# Deploys the final package to NPM
7476
deploy:
7577
# Trigger this step only when a commit on master is tagged with a version number
7678
if: |
77-
contains(github.event.head_commit.message, '[skip ci]') == false &&
7879
github.event_name == 'push' &&
7980
startsWith(github.ref, 'refs/tags/v')
8081
@@ -83,51 +84,51 @@ jobs:
8384
runs-on: ubuntu-latest
8485
strategy:
8586
matrix:
86-
node-version: [16.x]
87+
node-version: [24]
8788

8889
steps:
89-
- name: Checkout code
90-
uses: actions/checkout@v3
91-
92-
- name: Use Node.js ${{ matrix.node-version }}
93-
uses: actions/setup-node@v3
94-
with:
95-
node-version: ${{ matrix.node-version }}
96-
cache: 'npm'
97-
98-
- name: Extract the version and commit body from the tag
99-
id: extract_release
100-
# The body may be multiline, therefore we need to escape some characters
101-
run: |
102-
VERSION="${{ github.ref }}"
103-
VERSION=${VERSION##*/v}
104-
echo "::set-output name=VERSION::$VERSION"
105-
BODY=$(git show -s --format=%b)
106-
BODY="${BODY//'%'/'%25'}"
107-
BODY="${BODY//$'\n'/'%0A'}"
108-
BODY="${BODY//$'\r'/'%0D'}"
109-
echo "::set-output name=BODY::$BODY"
110-
111-
- name: Install dependencies
112-
run: npm ci
113-
114-
- name: Create a clean build
115-
run: npm run build
116-
117-
- name: Publish package to npm
118-
run: |
119-
npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
120-
npm whoami
121-
npm publish
122-
123-
- name: Create Github Release
124-
uses: actions/create-release@v1
125-
env:
126-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
127-
with:
128-
tag_name: ${{ github.ref }}
129-
release_name: Release v${{ steps.extract_release.outputs.VERSION }}
130-
draft: false
131-
# Prerelease versions create prereleases on Github
132-
prerelease: ${{ contains(steps.extract_release.outputs.VERSION, '-') }}
133-
body: ${{ steps.extract_release.outputs.BODY }}
90+
- name: Checkout code
91+
uses: actions/checkout@v6
92+
93+
- name: Use Node.js ${{ matrix.node-version }}
94+
uses: actions/setup-node@v6
95+
with:
96+
node-version: ${{ matrix.node-version }}
97+
cache: 'npm'
98+
99+
- name: Extract the version and commit body from the tag
100+
id: extract_release
101+
# The body may be multiline, therefore we need to escape some characters
102+
run: |
103+
VERSION="${{ github.ref }}"
104+
VERSION=${VERSION##*/v}
105+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
106+
EOF=$(od -An -N6 -x /dev/urandom | tr -d ' ')
107+
BODY=$(git show -s --format=%b)
108+
echo "BODY<<$EOF" >> $GITHUB_OUTPUT
109+
echo "$BODY" >> $GITHUB_OUTPUT
110+
echo "$EOF" >> $GITHUB_OUTPUT
111+
if [[ $VERSION == *"-"* ]] ; then
112+
echo "TAG=--tag next" >> $GITHUB_OUTPUT
113+
fi
114+
115+
- name: Install dependencies
116+
run: npm ci
117+
118+
- name: Create a clean build
119+
run: npm run build
120+
121+
- name: Publish package to npm
122+
run: npm publish ${{ steps.extract_release.outputs.TAG }}
123+
124+
- name: Create Github Release
125+
uses: softprops/action-gh-release@v2
126+
env:
127+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
128+
with:
129+
tag_name: ${{ github.ref }}
130+
name: Release v${{ steps.extract_release.outputs.VERSION }}
131+
draft: false
132+
# Prerelease versions create prereleases on Github
133+
prerelease: ${{ contains(steps.extract_release.outputs.VERSION, '-') }}
134+
body: ${{ steps.extract_release.outputs.BODY }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ ClientBin/
193193
*.pfx
194194
*.publishsettings
195195
node_modules/
196+
build/
196197
orleans.codegen.cs
197198

198199
# Since there are multiple workflows, uncomment next line to ignore bower_components

.lgtm.yml

Lines changed: 0 additions & 9 deletions
This file was deleted.

.mocharc.json

Lines changed: 0 additions & 8 deletions
This file was deleted.

.npmignore

Lines changed: 0 additions & 18 deletions
This file was deleted.

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Clientside implementation of the CoAP protocol with DTLS support
1010

1111
## Usage
1212
```ts
13-
const coap = require("node-coap-client").CoapClient;
13+
import { CoapClient as coap } from "node-coap-client";
1414
```
1515
The CoAP client provides the following public methods:
1616

@@ -174,6 +174,13 @@ To only reset connections and requests for a specific hostname, pass the hostnam
174174
PLACEHOLDER for next version:
175175
### __WORK IN PROGRESS__
176176
-->
177+
### __WORK IN PROGRESS__
178+
* Node.js 22+ is now required
179+
* This package is now pure ESM
180+
* Replaced Mocha/Chai/Sinon with Vitest
181+
* Replaced TSLint with Oxlint
182+
* Bumped `node-dtls-client` to v2
183+
177184
### 2.1.0 (2023-01-26)
178185
* (AlCalzone) Updated the `node-dtls-client` dependency for proper Electron support
179186

0 commit comments

Comments
 (0)