Skip to content

Commit 7bd8298

Browse files
authored
Merge pull request #6 from webduinoio/feature/5
Feature/5
2 parents 80bfb50 + f7e2bad commit 7bd8298

15 files changed

+8918
-3025
lines changed

.eslintrc.js

+22-34
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,23 @@
11
module.exports = {
2-
"env": {
3-
"browser": true,
4-
"commonjs": true,
5-
"node": true,
6-
"es6": true
7-
},
8-
"extends": "eslint:recommended",
9-
"parserOptions": {
10-
"ecmaVersion": 6
11-
},
12-
"globals": {
13-
"Paho": false
14-
},
15-
"rules": {
16-
"indent": [
17-
"warn",
18-
2
19-
],
20-
"quotes": [
21-
"warn",
22-
"single",
23-
{ "allowTemplateLiterals": true }
24-
],
25-
"semi": [
26-
"warn",
27-
"always"
28-
],
29-
"no-unused-vars": [
30-
"warn",
31-
{ "vars": "all", "args": "after-used", "ignoreRestSiblings": false }
32-
],
33-
"no-console": "off"
34-
}
35-
};
2+
env: {
3+
browser: true,
4+
commonjs: true,
5+
node: true,
6+
es6: true,
7+
},
8+
extends: "eslint:recommended",
9+
globals: {
10+
Paho: false,
11+
},
12+
rules: {
13+
indent: ["warn", 2],
14+
quotes: ["warn", "single", { allowTemplateLiterals: true }],
15+
semi: ["warn", "always"],
16+
"no-unused-vars": [
17+
"warn",
18+
{ vars: "all", args: "after-used", ignoreRestSiblings: false },
19+
],
20+
"no-console": "off",
21+
"no-prototype-builtins": "warn"
22+
},
23+
};

.github/PULL_REQUEST_TEMPLATE.md

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<!--- Provide a general summary of your changes in the Title above -->
2+
3+
## Description
4+
5+
<!--- Describe your changes in detail -->
6+
7+
[github issue](https://github.com/webduinoio/webduino-js/issues/)
8+
9+
## Motivation and Context
10+
11+
<!--- Why is this change required? What problem does it solve? -->
12+
<!--- If it fixes an open issue, please link to the issue here. -->
13+
14+
## How Has This Been Tested?
15+
16+
<!--- Please describe in detail how you tested your changes. -->
17+
<!--- Include details of your testing environment, the tests you ran to -->
18+
<!--- see how your change affects other areas of the code, etc. -->
19+
20+
## Screenshots (if appropriate)
21+
22+
## Types of changes
23+
24+
<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
25+
26+
- [ ] Bug fix (non-breaking change which fixes an issue)
27+
- [ ] New feature (non-breaking change which adds functionality)
28+
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
29+
30+
## Checklist
31+
32+
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
33+
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
34+
35+
- [ ] My code follows the code style of this project.
36+
- [ ] My change requires a change to the documentation.
37+
- [ ] I have updated the documentation accordingly.
38+
- [ ] I have added tests to cover my changes.
39+
- [ ] All new and existing tests passed.

.tool-versions

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nodejs 16.17.0

CHANGELOG.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6+
7+
## [Unreleased]
8+
9+
### Fixed
10+
11+
- Upgrade the modules in package.json [#5](https://github.com/webduinoio/webduino-js/issues/5)
12+
- fixed security vulnerabilities
13+
14+
15+
[unreleased]: https://github.com/webduinoio/webduino-js/compare/0.6.0...master
16+
[0.6.0]: https://github.com/webduinoio/webduino-js/releases/tag/0.6.0

dist/webduino-all.js

-9
Original file line numberDiff line numberDiff line change
@@ -3069,8 +3069,6 @@ if (typeof exports !== 'undefined') {
30693069
};
30703070
}));
30713071

3072-
/* global Promise:true */
3073-
30743072
+(function (global, factory) {
30753073
if (typeof exports === 'undefined') {
30763074
factory(global.webduino || {});
@@ -3080,13 +3078,6 @@ if (typeof exports !== 'undefined') {
30803078
}(this, function (scope) {
30813079
'use strict';
30823080

3083-
if (typeof exports !== 'undefined' && typeof Promise === 'undefined') {
3084-
Promise = require('es6-promise').Promise;
3085-
}
3086-
3087-
// source:
3088-
// https://raw.githubusercontent.com/twistdigital/es6-promisify/release/2.0.0/lib/promisify.js
3089-
30903081
// Promise Context object constructor.
30913082
function Context(resolve, reject, custom) {
30923083
this.resolve = resolve;

dist/webduino-all.min.js

+1-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/webduino-base.js

-9
Original file line numberDiff line numberDiff line change
@@ -3069,8 +3069,6 @@ if (typeof exports !== 'undefined') {
30693069
};
30703070
}));
30713071

3072-
/* global Promise:true */
3073-
30743072
+(function (global, factory) {
30753073
if (typeof exports === 'undefined') {
30763074
factory(global.webduino || {});
@@ -3080,13 +3078,6 @@ if (typeof exports !== 'undefined') {
30803078
}(this, function (scope) {
30813079
'use strict';
30823080

3083-
if (typeof exports !== 'undefined' && typeof Promise === 'undefined') {
3084-
Promise = require('es6-promise').Promise;
3085-
}
3086-
3087-
// source:
3088-
// https://raw.githubusercontent.com/twistdigital/es6-promisify/release/2.0.0/lib/promisify.js
3089-
30903081
// Promise Context object constructor.
30913082
function Context(resolve, reject, custom) {
30923083
this.resolve = resolve;

dist/webduino-base.min.js

+1-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/files/src_transport_NodeMqttTransport.js.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ <h1>src/transport/NodeMqttTransport.js <small>File</small></h1>
157157
self._client = mqtt.connect(self._options.server, {
158158
clientId: &#x27;_&#x27; + self._options.device + (self._options.multi ? &#x27;.&#x27; + util.randomId() : &#x27;&#x27;),
159159
username: self._options.login || &#x27;&#x27;,
160-
password: new Buffer(self._options.password || &#x27;&#x27;),
160+
password: Buffer.from(self._options.password || &#x27;&#x27;),
161161
keepalive: NodeMqttTransport.KEEPALIVE_INTERVAL,
162162
reconnectPeriod: self._options.autoReconnect ? NodeMqttTransport.RECONNECT_PERIOD * 1000 : 0,
163163
connectTimeout: NodeMqttTransport.CONNECT_TIMEOUT * 1000
@@ -224,7 +224,7 @@ <h1>src/transport/NodeMqttTransport.js <small>File</small></h1>
224224
}
225225

226226
function sendOut() {
227-
var payload = new Buffer(this._buf);
227+
var payload = Buffer.from(this._buf);
228228
this.isOpen &amp;&amp; this._client.publish(this._options.device + TOPIC.PING, payload, {
229229
qos: 0
230230
});

gulpfile.js

+44-34
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
const gulp = require('gulp');
1+
const { src, dest, watch, series, parallel } = require('gulp');
22
const expect = require('gulp-expect-file');
33
const concat = require('gulp-concat');
44
const uglify = require('gulp-uglify');
55
const shell = require('gulp-shell');
66

7-
const expectFiles = (ary) => {
8-
return gulp.src(ary).pipe(expect(ary));
9-
}
10-
117
const SOURCE_DIR = 'src';
128
const DIST_DIR = 'dist';
139
const base = [
@@ -70,42 +66,56 @@ const modules = [
7066
'src/module/Stepper.js'
7167
];
7268

73-
gulp.task('clean', shell.task([
74-
`rm -rf ${DIST_DIR} docs`
75-
]));
69+
function expectFiles(ary) {
70+
return src(ary).pipe(expect(ary));
71+
}
7672

77-
/**
78-
* NPM alert potential security vulnerabilities.
79-
* yuidocjs seems to be no longer maintained.
80-
* If need the document, run the gulp task.
81-
*/
82-
gulp.task('docs', ['clean'], shell.task([
83-
'npm install --no-save yuidocjs yuidoc-lucid-theme',
84-
'./node_modules/.bin/yuidoc -c yuidoc.json ./src'
85-
]));
73+
function clean() {
74+
return shell.task([
75+
`rm -rf ${DIST_DIR} docs`
76+
])();
77+
}
8678

87-
gulp.task('dev', ['clean'], () => {
88-
expectFiles(base)
79+
function docs() {
80+
return shell.task([
81+
'npm install --no-save yuidocjs yuidoc-lucid-theme',
82+
'./node_modules/.bin/yuidoc -c yuidoc.json ./src'
83+
])();
84+
}
85+
86+
function webduinoBaseJS() {
87+
return expectFiles(base)
8988
.pipe(concat('webduino-base.js'))
90-
.pipe(gulp.dest(DIST_DIR));
91-
expectFiles(base.concat(boards).concat(modules))
92-
.pipe(concat('webduino-all.js'))
93-
.pipe(gulp.dest(DIST_DIR));
94-
});
89+
.pipe(dest(DIST_DIR));
90+
}
9591

96-
gulp.task('prod', ['clean'], () => {
97-
expectFiles(base)
92+
function webduinoBaseMinJS() {
93+
return expectFiles(base)
9894
.pipe(concat('webduino-base.min.js'))
9995
.pipe(uglify())
100-
.pipe(gulp.dest(DIST_DIR));
101-
expectFiles(base.concat(boards).concat(modules))
96+
.pipe(dest(DIST_DIR));
97+
}
98+
99+
function webduinoAllJS() {
100+
return expectFiles(base.concat(boards).concat(modules))
101+
.pipe(concat('webduino-all.js'))
102+
.pipe(dest(DIST_DIR));
103+
}
104+
105+
function webduinoAllMinJS() {
106+
return expectFiles(base.concat(boards).concat(modules))
102107
.pipe(concat('webduino-all.min.js'))
103108
.pipe(uglify())
104-
.pipe(gulp.dest(DIST_DIR));
105-
});
109+
.pipe(dest(DIST_DIR));
110+
}
111+
112+
function watchFiles() {
113+
watch(SOURCE_DIR + '/**/*.js', series(clean, dev));
114+
}
115+
116+
const dev = series(webduinoBaseJS, webduinoAllJS);
106117

107-
gulp.task('watch', () => {
108-
gulp.watch(SOURCE_DIR + '/**/*.js', ['dev']);
109-
});
118+
const prod = series(webduinoBaseMinJS, webduinoAllMinJS);
110119

111-
gulp.task('default', ['docs', 'dev', 'prod']);
120+
exports.watch = watchFiles;
121+
exports.default = series(clean, parallel(docs, dev, prod));

0 commit comments

Comments
 (0)