Skip to content

Commit e7c82dc

Browse files
Merge pull request #203 from particle-iot/feature/sc-135585/particle-api-js-node-22
feat: [sc-135585] particle-api-js Node 22
2 parents f5e44c1 + f09353e commit e7c82dc

32 files changed

+8611
-7018
lines changed

.circleci/config.yml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@ orbs:
44
browser-tools: circleci/[email protected]
55

66
jobs:
7+
lint:
8+
docker:
9+
- image: cimg/node:22.18 # eslint 9.x requires 18+, so we've separated it from the test step
10+
auth:
11+
username: $DOCKERHUB_USERNAME
12+
password: $DOCKERHUB_PASSWORD
13+
steps:
14+
- checkout
15+
- run:
16+
name: NPM install
17+
command: npm ci
18+
- run:
19+
name: Lint
20+
command: npm run lint
721
run-tests:
822
parameters:
923
node-version:
@@ -57,12 +71,19 @@ workflows:
5771
version: 2
5872
test-and-publish:
5973
jobs:
74+
- lint:
75+
context:
76+
- particle-ci-private
77+
# run tests for all branches
78+
filters:
79+
branches:
80+
only: /.*/
6081
- run-tests:
6182
context:
6283
- particle-ci-private
6384
matrix:
6485
parameters:
65-
node-version: ["12.22.12", "14.19.2", "16.20.0"]
86+
node-version: ["16.20.0", "22.18"]
6687
# run tests for all branches and tags
6788
filters:
6889
tags:
@@ -71,6 +92,7 @@ workflows:
7192
only: /.*/
7293
- publish-npm:
7394
requires:
95+
- lint
7496
- run-tests
7597
context:
7698
- particle-ci-private

.eslintrc.js

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

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
16
1+
22

EventStream-e2e-node.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Steps:
77
- Follow the scenarios in EventStream.feature
88
99
*/
10-
10+
'use strict';
1111
const Particle = require('./src/Particle');
1212
const baseUrl = process.env.PARTICLE_API_BASE_URL || 'http://localhost:9090';
1313
const auth = process.env.PARTICLE_API_TOKEN;
@@ -16,19 +16,19 @@ const particle = new Particle({ baseUrl });
1616

1717
/* eslint-disable no-console */
1818
particle.getEventStream({ deviceId: 'mine', auth })
19-
.then(stream => {
20-
console.log('event stream connected');
21-
22-
['event', 'error', 'disconnect', 'reconnect', 'reconnect-success', 'reconnect-error']
23-
.forEach(eventName => {
24-
stream.on(eventName, (arg) => {
25-
console.log(eventName, arg);
26-
});
27-
});
28-
})
29-
.catch((err) => {
30-
console.error(err);
31-
process.exit(1);
32-
});
19+
.then(stream => {
20+
console.log('event stream connected');
21+
22+
['event', 'error', 'disconnect', 'reconnect', 'reconnect-success', 'reconnect-error']
23+
.forEach(eventName => {
24+
stream.on(eventName, (arg) => {
25+
console.log(eventName, arg);
26+
});
27+
});
28+
})
29+
.catch((err) => {
30+
console.error(err);
31+
process.exit(1);
32+
});
3333
/* eslint-enable no-console */
3434

dist/particle.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/particle.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

eslint.config.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { particle } from 'eslint-config-particle';
2+
3+
export default particle({
4+
rootDir: import.meta.dirname,
5+
testGlobals: 'mocha',
6+
globalIgnores: ['dist']
7+
});

fs.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
// In Node, exports the fs module. In the browser, exports undefined due to "./fs": false entry in package.json
2+
'use strict';
23
module.exports = require('fs');

karma.conf.js

Lines changed: 60 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,80 @@
11
// Karma configuration
22
// Generated on Wed Jul 20 2016 12:00:09 GMT-0400 (EDT)
3+
'use strict';
34
const webpackConf = require('./webpack.config.js');
45
const webpack = require('webpack');
56

67
module.exports = function karmaCfg(config){
7-
config.set({
8-
// base path that will be used to resolve all patterns (eg. files, exclude)
9-
basePath: '',
8+
config.set({
9+
// base path that will be used to resolve all patterns (eg. files, exclude)
10+
basePath: '',
1011

11-
// frameworks to use
12-
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
13-
frameworks: ['webpack', 'mocha', 'chai'],
12+
// frameworks to use
13+
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
14+
frameworks: ['webpack', 'mocha', 'chai'],
1415

15-
// list of files / patterns to load in the browser
16-
files: [
17-
'dist/particle.min.js',
18-
'test/*.spec.js',
19-
'test/*.integration.js'
20-
],
16+
// list of files / patterns to load in the browser
17+
files: [
18+
'dist/particle.min.js',
19+
'test/*.spec.js',
20+
'test/*.integration.js'
21+
],
2122

22-
// list of files to exclude
23-
exclude: [
24-
],
23+
// list of files to exclude
24+
exclude: [
25+
],
2526

26-
// preprocess matching files before serving them to the browser
27-
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
28-
preprocessors: {
29-
'src/**/*.js': ['webpack'],
30-
'test/**/*.js': ['webpack']
31-
},
27+
// preprocess matching files before serving them to the browser
28+
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
29+
preprocessors: {
30+
'src/**/*.js': ['webpack'],
31+
'test/**/*.js': ['webpack']
32+
},
3233

33-
// Transform test files to a single browser consumable file
34-
webpack: {
35-
mode: 'development',
36-
target: 'web',
37-
devtool: 'inline-source-map',
38-
output: webpackConf.output,
39-
externals: webpackConf.externals,
40-
resolve: webpackConf.resolve,
41-
plugins: [
42-
new webpack.ProvidePlugin({ Buffer: ['buffer', 'Buffer'] }),
43-
new webpack.EnvironmentPlugin({
44-
SKIP_AGENT_TEST: process.env.SKIP_AGENT_TEST || false
45-
})
46-
]
47-
},
34+
// Transform test files to a single browser consumable file
35+
webpack: {
36+
mode: 'development',
37+
target: 'web',
38+
devtool: 'inline-source-map',
39+
output: webpackConf.output,
40+
externals: webpackConf.externals,
41+
resolve: webpackConf.resolve,
42+
plugins: [
43+
new webpack.ProvidePlugin({ Buffer: ['buffer', 'Buffer'] }),
44+
new webpack.EnvironmentPlugin({
45+
SKIP_AGENT_TEST: process.env.SKIP_AGENT_TEST || false
46+
})
47+
]
48+
},
4849

49-
// test results reporter to use
50-
// possible values: 'dots', 'progress'
51-
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
52-
reporters: ['progress', 'coverage'],
50+
// test results reporter to use
51+
// possible values: 'dots', 'progress'
52+
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
53+
reporters: ['progress', 'coverage'],
5354

54-
// web server port
55-
port: 9876,
55+
// web server port
56+
port: 9876,
5657

57-
// enable / disable colors in the output (reporters and logs)
58-
colors: true,
58+
// enable / disable colors in the output (reporters and logs)
59+
colors: true,
5960

60-
// level of logging
61-
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
62-
logLevel: config.LOG_INFO,
61+
// level of logging
62+
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
63+
logLevel: config.LOG_INFO,
6364

64-
// enable / disable watching file and executing tests whenever any file changes
65-
autoWatch: true,
65+
// enable / disable watching file and executing tests whenever any file changes
66+
autoWatch: true,
6667

67-
// start these browsers
68-
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
69-
browsers: ['Firefox'],
68+
// start these browsers
69+
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
70+
browsers: ['Firefox'],
7071

71-
// Continuous Integration mode
72-
// if true, Karma captures browsers, runs the tests and exits
73-
singleRun: false,
72+
// Continuous Integration mode
73+
// if true, Karma captures browsers, runs the tests and exits
74+
singleRun: false,
7475

75-
// Concurrency level
76-
// how many browser should be started simultaneous
77-
concurrency: Infinity
78-
});
76+
// Concurrency level
77+
// how many browser should be started simultaneous
78+
concurrency: Infinity
79+
});
7980
};

0 commit comments

Comments
 (0)