Skip to content

Commit

Permalink
Merge pull request #6 from webduinoio/feature/5
Browse files Browse the repository at this point in the history
Feature/5
  • Loading branch information
GoGoPenguin authored Aug 19, 2022
2 parents 80bfb50 + f7e2bad commit 7bd8298
Show file tree
Hide file tree
Showing 15 changed files with 8,918 additions and 3,025 deletions.
56 changes: 22 additions & 34 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,23 @@
module.exports = {
"env": {
"browser": true,
"commonjs": true,
"node": true,
"es6": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 6
},
"globals": {
"Paho": false
},
"rules": {
"indent": [
"warn",
2
],
"quotes": [
"warn",
"single",
{ "allowTemplateLiterals": true }
],
"semi": [
"warn",
"always"
],
"no-unused-vars": [
"warn",
{ "vars": "all", "args": "after-used", "ignoreRestSiblings": false }
],
"no-console": "off"
}
};
env: {
browser: true,
commonjs: true,
node: true,
es6: true,
},
extends: "eslint:recommended",
globals: {
Paho: false,
},
rules: {
indent: ["warn", 2],
quotes: ["warn", "single", { allowTemplateLiterals: true }],
semi: ["warn", "always"],
"no-unused-vars": [
"warn",
{ vars: "all", args: "after-used", ignoreRestSiblings: false },
],
"no-console": "off",
"no-prototype-builtins": "warn"
},
};
39 changes: 39 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!--- Provide a general summary of your changes in the Title above -->

## Description

<!--- Describe your changes in detail -->

[github issue](https://github.com/webduinoio/webduino-js/issues/)

## Motivation and Context

<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here. -->

## How Has This Been Tested?

<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, the tests you ran to -->
<!--- see how your change affects other areas of the code, etc. -->

## Screenshots (if appropriate)

## Types of changes

<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)

## Checklist

<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->

- [ ] My code follows the code style of this project.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [ ] I have added tests to cover my changes.
- [ ] All new and existing tests passed.
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodejs 16.17.0
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Changelog

All notable changes to this project will be documented in this file.

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).

## [Unreleased]

### Fixed

- Upgrade the modules in package.json [#5](https://github.com/webduinoio/webduino-js/issues/5)
- fixed security vulnerabilities


[unreleased]: https://github.com/webduinoio/webduino-js/compare/0.6.0...master
[0.6.0]: https://github.com/webduinoio/webduino-js/releases/tag/0.6.0
9 changes: 0 additions & 9 deletions dist/webduino-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -3069,8 +3069,6 @@ if (typeof exports !== 'undefined') {
};
}));

/* global Promise:true */

+(function (global, factory) {
if (typeof exports === 'undefined') {
factory(global.webduino || {});
Expand All @@ -3080,13 +3078,6 @@ if (typeof exports !== 'undefined') {
}(this, function (scope) {
'use strict';

if (typeof exports !== 'undefined' && typeof Promise === 'undefined') {
Promise = require('es6-promise').Promise;
}

// source:
// https://raw.githubusercontent.com/twistdigital/es6-promisify/release/2.0.0/lib/promisify.js

// Promise Context object constructor.
function Context(resolve, reject, custom) {
this.resolve = resolve;
Expand Down
5 changes: 1 addition & 4 deletions dist/webduino-all.min.js

Large diffs are not rendered by default.

9 changes: 0 additions & 9 deletions dist/webduino-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -3069,8 +3069,6 @@ if (typeof exports !== 'undefined') {
};
}));

/* global Promise:true */

+(function (global, factory) {
if (typeof exports === 'undefined') {
factory(global.webduino || {});
Expand All @@ -3080,13 +3078,6 @@ if (typeof exports !== 'undefined') {
}(this, function (scope) {
'use strict';

if (typeof exports !== 'undefined' && typeof Promise === 'undefined') {
Promise = require('es6-promise').Promise;
}

// source:
// https://raw.githubusercontent.com/twistdigital/es6-promisify/release/2.0.0/lib/promisify.js

// Promise Context object constructor.
function Context(resolve, reject, custom) {
this.resolve = resolve;
Expand Down
4 changes: 1 addition & 3 deletions dist/webduino-base.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/files/src_transport_NodeMqttTransport.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ <h1>src/transport/NodeMqttTransport.js <small>File</small></h1>
self._client = mqtt.connect(self._options.server, {
clientId: &#x27;_&#x27; + self._options.device + (self._options.multi ? &#x27;.&#x27; + util.randomId() : &#x27;&#x27;),
username: self._options.login || &#x27;&#x27;,
password: new Buffer(self._options.password || &#x27;&#x27;),
password: Buffer.from(self._options.password || &#x27;&#x27;),
keepalive: NodeMqttTransport.KEEPALIVE_INTERVAL,
reconnectPeriod: self._options.autoReconnect ? NodeMqttTransport.RECONNECT_PERIOD * 1000 : 0,
connectTimeout: NodeMqttTransport.CONNECT_TIMEOUT * 1000
Expand Down Expand Up @@ -224,7 +224,7 @@ <h1>src/transport/NodeMqttTransport.js <small>File</small></h1>
}

function sendOut() {
var payload = new Buffer(this._buf);
var payload = Buffer.from(this._buf);
this.isOpen &amp;&amp; this._client.publish(this._options.device + TOPIC.PING, payload, {
qos: 0
});
Expand Down
78 changes: 44 additions & 34 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
const gulp = require('gulp');
const { src, dest, watch, series, parallel } = require('gulp');
const expect = require('gulp-expect-file');
const concat = require('gulp-concat');
const uglify = require('gulp-uglify');
const shell = require('gulp-shell');

const expectFiles = (ary) => {
return gulp.src(ary).pipe(expect(ary));
}

const SOURCE_DIR = 'src';
const DIST_DIR = 'dist';
const base = [
Expand Down Expand Up @@ -70,42 +66,56 @@ const modules = [
'src/module/Stepper.js'
];

gulp.task('clean', shell.task([
`rm -rf ${DIST_DIR} docs`
]));
function expectFiles(ary) {
return src(ary).pipe(expect(ary));
}

/**
* NPM alert potential security vulnerabilities.
* yuidocjs seems to be no longer maintained.
* If need the document, run the gulp task.
*/
gulp.task('docs', ['clean'], shell.task([
'npm install --no-save yuidocjs yuidoc-lucid-theme',
'./node_modules/.bin/yuidoc -c yuidoc.json ./src'
]));
function clean() {
return shell.task([
`rm -rf ${DIST_DIR} docs`
])();
}

gulp.task('dev', ['clean'], () => {
expectFiles(base)
function docs() {
return shell.task([
'npm install --no-save yuidocjs yuidoc-lucid-theme',
'./node_modules/.bin/yuidoc -c yuidoc.json ./src'
])();
}

function webduinoBaseJS() {
return expectFiles(base)
.pipe(concat('webduino-base.js'))
.pipe(gulp.dest(DIST_DIR));
expectFiles(base.concat(boards).concat(modules))
.pipe(concat('webduino-all.js'))
.pipe(gulp.dest(DIST_DIR));
});
.pipe(dest(DIST_DIR));
}

gulp.task('prod', ['clean'], () => {
expectFiles(base)
function webduinoBaseMinJS() {
return expectFiles(base)
.pipe(concat('webduino-base.min.js'))
.pipe(uglify())
.pipe(gulp.dest(DIST_DIR));
expectFiles(base.concat(boards).concat(modules))
.pipe(dest(DIST_DIR));
}

function webduinoAllJS() {
return expectFiles(base.concat(boards).concat(modules))
.pipe(concat('webduino-all.js'))
.pipe(dest(DIST_DIR));
}

function webduinoAllMinJS() {
return expectFiles(base.concat(boards).concat(modules))
.pipe(concat('webduino-all.min.js'))
.pipe(uglify())
.pipe(gulp.dest(DIST_DIR));
});
.pipe(dest(DIST_DIR));
}

function watchFiles() {
watch(SOURCE_DIR + '/**/*.js', series(clean, dev));
}

const dev = series(webduinoBaseJS, webduinoAllJS);

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

gulp.task('default', ['docs', 'dev', 'prod']);
exports.watch = watchFiles;
exports.default = series(clean, parallel(docs, dev, prod));
Loading

0 comments on commit 7bd8298

Please sign in to comment.