Skip to content

Commit

Permalink
Initial
Browse files Browse the repository at this point in the history
  • Loading branch information
Daisuke Baba committed Jul 2, 2017
0 parents commit f9b2560
Show file tree
Hide file tree
Showing 12 changed files with 321 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
*.map
dist
!gulpfile.js
*.tgz
*.log
.node-version
22 changes: 22 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"node": true,
"browser": false,
"mocha": true,
"esnext": true,
"module": true,
"bitwise": true,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"immed": true,
"indent": 2,
"latedef": true,
"newcap": true,
"noarg": true,
"quotmark": "single",
"undef": true,
"unused": true,
"strict": true,
"globals" : {
}
}
16 changes: 16 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.git
.node-red
node_modules
images
src
tests
.gitignore
.npmignore
.jshintrc
.travis.yml
gulpfile.js
*.tgz
*.zip
*.log
.dockerignore
.node-version
19 changes: 19 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
language: node_js
node_js:
- 4.7

addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-4.8
- bluez

sudo: require

install:
- if [[ $TRAVIS_OS_NAME == "linux" ]]; then export CXX=g++-4.8; fi
- $CXX --version
- npm install --unsafe-perm
- npm install
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2017 CANDY LINE INC.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Empty file added README.md
Empty file.
145 changes: 145 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
const gulp = require('gulp');
const util = require("gulp-util");
const babel = require('gulp-babel');
const browserify = require('browserify');
const babelify = require('babelify');
const uglify = require('gulp-uglify');
const del = require('del');
const source = require('vinyl-source-stream');
const buffer = require('vinyl-buffer');
const jshint = require('gulp-jshint');
const mocha = require('gulp-mocha');
const sourcemaps = require('gulp-sourcemaps');
const gulpif = require('gulp-if');
const htmlmin = require('gulp-htmlmin');
const cleancss = require('gulp-clean-css');
const less = require('gulp-less');
const manifest = require('gulp-manifest');
const shim = require('browserify-shim');
const yaml = require('gulp-yaml');

const minified = process.env.NODE_ENV === 'production';
const sourcemapEnabled = process.env.NODE_ENV !== 'production';

gulp.task('lint', () => {
return gulp.src([
'./tests/**/*.js',
'./src/**/*.js'
])
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'))
.pipe(jshint.reporter('fail'));
});

gulp.task('clean', () => {
return del([
'dist/*',
'./dist',
'!node_modules/**/*',
'./*.tgz',
]);
});

gulp.task('i18n', () => {
return gulp.src([
'./src/locales/**/*.{yaml,yml}'
])
.pipe(yaml({ safe: true }))
.pipe(gulp.dest('./dist/locales'));
});

gulp.task('assets', ['i18n'], () => {
return gulp.src([
'./src/**/*.{less,ico,png,json,yaml,yml}',
'!./src/locales/**/*.{yaml,yml}'
])
.pipe(gulp.dest('./dist'));
});

gulp.task('js', ['assets'], () => {
return browserify({
entries: './src/generic-ble.js',
debug: true
})
.transform(babelify, {
minified: minified,
compact: minified,
presets: ["es2015"],
plugins: ['add-module-exports'],
sourceMaps: sourcemapEnabled,
}).on('error', util.log)
.transform(shim, {
global: true
}).on('error', util.log)
.bundle()
.pipe(source('generic-ble.js'))
.pipe(buffer())
.pipe(gulpif(sourcemapEnabled, sourcemaps.init({loadMaps: true}), util.noop()))
.pipe(uglify({
mangle: minified,
compress: {
dead_code: true,
drop_debugger: true,
properties: true,
unused: true,
toplevel: true,
if_return: true,
drop_console: !sourcemapEnabled,
conditionals: true,
unsafe_math: true,
unsafe: true
},
}))
.pipe(gulpif(sourcemapEnabled, sourcemaps.write(), util.noop()))
.pipe(gulp.dest('./dist'));
});

gulp.task('less', () => {
return gulp.src('./src/**/*.less')
.pipe(gulpif(sourcemapEnabled, sourcemaps.init(), util.noop()))
.pipe(less())
.pipe(cleancss({compatibility: 'ie8'}))
.pipe(gulpif(sourcemapEnabled, sourcemaps.write(), util.noop()))
.pipe(gulp.dest('./dist'));
});

gulp.task('html', () => {
return gulp.src('./src/**/*.html')
.pipe(htmlmin({collapseWhitespace:true, conservativeCollapse:true}))
.pipe(gulp.dest('./dist'));
});

gulp.task('build', ['lint', 'js', 'less', 'html', 'assets'], () => {
gulp.src(['./dist/*'], { base: './dist' })
.pipe(gulp.dest('./dist'));
});

gulp.task('testAssets', () => {
return gulp.src('./tests/**/*.{css,less,ico,png,html,json,yaml,yml}')
.pipe(gulp.dest('./dist'));
});

gulp.task('testJs', ['build'], () => {
return gulp.src('./tests/**/*.js')
.pipe(sourcemaps.init())
.pipe(babel({
presets: ['es2015'],
plugins: ['add-module-exports']
}))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('./dist'));
});

gulp.task('test', ['testJs', 'testAssets'], () => {
return gulp.src([
'./dist/**/*.test.js',
], {read: false})
.pipe(mocha({
require: ['source-map-support/register'],
reporter: 'spec'
}))
.once('error', () => process.exit(1))
.once('end', () => process.exit())
});

gulp.task('default', ['build']);
79 changes: 79 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
"name": "node-red-contrib-generic-ble",
"version": "1.0.0",
"description": "Node-RED nodes for generic BLE devices",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/CANDY-LINE/node-red-contrib-generic-ble.git"
},
"author": "Daisuke Baba <[email protected]>",
"bugs": {
"url": "https://github.com/CANDY-LINE/node-red-contrib-generic-ble/issues"
},
"scripts": {
"build": "gulp build",
"test": "gulp test",
"clean": "gulp clean",
"prepublish": "gulp build"
},
"homepage": "https://github.com/CANDY-LINE/node-red-contrib-generic-ble#readme",
"keywords": [
"node-red",
"bluetooth",
"BLE",
"bluetooth low energy",
"bluetooth smart",
"CANDY RED",
"CANDY EGG"
],
"browserify-shim": {
},
"devDependencies": {
"node-red": "^0.16.2",
"babel": "^6.23.0",
"babel-cli": "^6.24.0",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-babili": "0.0.12",
"babel-preset-es2015": "^6.24.0",
"babelify": "^7.3.0",
"browserify": "^14.3.0",
"browserify-shim": "^3.8.14",
"chai": "^3.3.0",
"del": "^2.2.2",
"gulp": "^3.9.1",
"gulp-babel": "^6.1.2",
"gulp-clean-css": "^2.4.0",
"gulp-cli": "^1.2.2",
"gulp-header": "^1.8.8",
"gulp-htmlmin": "^3.0.0",
"gulp-if": "^2.0.2",
"gulp-jshint": "^2.0.4",
"gulp-less": "^3.3.0",
"gulp-manifest": "^0.1.1",
"gulp-mocha": "^4.3.0",
"gulp-resources": "^0.5.0",
"gulp-sourcemaps": "^2.5.1",
"gulp-uglify": "^2.1.2",
"gulp-util": "^3.0.8",
"gulp-yaml": "^1.0.1",
"jshint": "^2.9.1",
"jshint-stylish": "^2.0.1",
"mocha": "^3.0.2",
"sinon": "^2.1.0",
"supertest": "^1.1.0",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0"
},
"dependencies": {
"noble": "^1.8.1",
"source-map-support": "^0.4.2",
"lru-cache": "^4.0.0"
},
"node-red": {
"nodes": {
"generic-ble": "dist/generic-ble.js"
}
}
}
Empty file added src/generic-ble.js
Empty file.
8 changes: 8 additions & 0 deletions src/locales/en-US/generic-ble.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<script type="text/x-red" data-help-name="Generic BLE in">
</script>

<script type="text/x-red" data-help-name="Generic BLE out">
</script>

<script type="text/x-red" data-help-name="Generic BLE">
</script>
4 changes: 4 additions & 0 deletions src/locales/en-US/generic-ble.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Message Resources for English (fallback language)
generic-ble:
label:
node: Generic BLE
Empty file added tests/generic-ble.test.js
Empty file.

0 comments on commit f9b2560

Please sign in to comment.