Skip to content

Commit f9b2560

Browse files
author
Daisuke Baba
committed
Initial
0 parents  commit f9b2560

File tree

12 files changed

+321
-0
lines changed

12 files changed

+321
-0
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules
2+
*.map
3+
dist
4+
!gulpfile.js
5+
*.tgz
6+
*.log
7+
.node-version

.jshintrc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"node": true,
3+
"browser": false,
4+
"mocha": true,
5+
"esnext": true,
6+
"module": true,
7+
"bitwise": true,
8+
"camelcase": true,
9+
"curly": true,
10+
"eqeqeq": true,
11+
"immed": true,
12+
"indent": 2,
13+
"latedef": true,
14+
"newcap": true,
15+
"noarg": true,
16+
"quotmark": "single",
17+
"undef": true,
18+
"unused": true,
19+
"strict": true,
20+
"globals" : {
21+
}
22+
}

.npmignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.git
2+
.node-red
3+
node_modules
4+
images
5+
src
6+
tests
7+
.gitignore
8+
.npmignore
9+
.jshintrc
10+
.travis.yml
11+
gulpfile.js
12+
*.tgz
13+
*.zip
14+
*.log
15+
.dockerignore
16+
.node-version

.travis.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
language: node_js
2+
node_js:
3+
- 4.7
4+
5+
addons:
6+
apt:
7+
sources:
8+
- ubuntu-toolchain-r-test
9+
packages:
10+
- g++-4.8
11+
- bluez
12+
13+
sudo: require
14+
15+
install:
16+
- if [[ $TRAVIS_OS_NAME == "linux" ]]; then export CXX=g++-4.8; fi
17+
- $CXX --version
18+
- npm install --unsafe-perm
19+
- npm install

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2017 CANDY LINE INC.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Whitespace-only changes.

gulpfile.js

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
const gulp = require('gulp');
2+
const util = require("gulp-util");
3+
const babel = require('gulp-babel');
4+
const browserify = require('browserify');
5+
const babelify = require('babelify');
6+
const uglify = require('gulp-uglify');
7+
const del = require('del');
8+
const source = require('vinyl-source-stream');
9+
const buffer = require('vinyl-buffer');
10+
const jshint = require('gulp-jshint');
11+
const mocha = require('gulp-mocha');
12+
const sourcemaps = require('gulp-sourcemaps');
13+
const gulpif = require('gulp-if');
14+
const htmlmin = require('gulp-htmlmin');
15+
const cleancss = require('gulp-clean-css');
16+
const less = require('gulp-less');
17+
const manifest = require('gulp-manifest');
18+
const shim = require('browserify-shim');
19+
const yaml = require('gulp-yaml');
20+
21+
const minified = process.env.NODE_ENV === 'production';
22+
const sourcemapEnabled = process.env.NODE_ENV !== 'production';
23+
24+
gulp.task('lint', () => {
25+
return gulp.src([
26+
'./tests/**/*.js',
27+
'./src/**/*.js'
28+
])
29+
.pipe(jshint())
30+
.pipe(jshint.reporter('jshint-stylish'))
31+
.pipe(jshint.reporter('fail'));
32+
});
33+
34+
gulp.task('clean', () => {
35+
return del([
36+
'dist/*',
37+
'./dist',
38+
'!node_modules/**/*',
39+
'./*.tgz',
40+
]);
41+
});
42+
43+
gulp.task('i18n', () => {
44+
return gulp.src([
45+
'./src/locales/**/*.{yaml,yml}'
46+
])
47+
.pipe(yaml({ safe: true }))
48+
.pipe(gulp.dest('./dist/locales'));
49+
});
50+
51+
gulp.task('assets', ['i18n'], () => {
52+
return gulp.src([
53+
'./src/**/*.{less,ico,png,json,yaml,yml}',
54+
'!./src/locales/**/*.{yaml,yml}'
55+
])
56+
.pipe(gulp.dest('./dist'));
57+
});
58+
59+
gulp.task('js', ['assets'], () => {
60+
return browserify({
61+
entries: './src/generic-ble.js',
62+
debug: true
63+
})
64+
.transform(babelify, {
65+
minified: minified,
66+
compact: minified,
67+
presets: ["es2015"],
68+
plugins: ['add-module-exports'],
69+
sourceMaps: sourcemapEnabled,
70+
}).on('error', util.log)
71+
.transform(shim, {
72+
global: true
73+
}).on('error', util.log)
74+
.bundle()
75+
.pipe(source('generic-ble.js'))
76+
.pipe(buffer())
77+
.pipe(gulpif(sourcemapEnabled, sourcemaps.init({loadMaps: true}), util.noop()))
78+
.pipe(uglify({
79+
mangle: minified,
80+
compress: {
81+
dead_code: true,
82+
drop_debugger: true,
83+
properties: true,
84+
unused: true,
85+
toplevel: true,
86+
if_return: true,
87+
drop_console: !sourcemapEnabled,
88+
conditionals: true,
89+
unsafe_math: true,
90+
unsafe: true
91+
},
92+
}))
93+
.pipe(gulpif(sourcemapEnabled, sourcemaps.write(), util.noop()))
94+
.pipe(gulp.dest('./dist'));
95+
});
96+
97+
gulp.task('less', () => {
98+
return gulp.src('./src/**/*.less')
99+
.pipe(gulpif(sourcemapEnabled, sourcemaps.init(), util.noop()))
100+
.pipe(less())
101+
.pipe(cleancss({compatibility: 'ie8'}))
102+
.pipe(gulpif(sourcemapEnabled, sourcemaps.write(), util.noop()))
103+
.pipe(gulp.dest('./dist'));
104+
});
105+
106+
gulp.task('html', () => {
107+
return gulp.src('./src/**/*.html')
108+
.pipe(htmlmin({collapseWhitespace:true, conservativeCollapse:true}))
109+
.pipe(gulp.dest('./dist'));
110+
});
111+
112+
gulp.task('build', ['lint', 'js', 'less', 'html', 'assets'], () => {
113+
gulp.src(['./dist/*'], { base: './dist' })
114+
.pipe(gulp.dest('./dist'));
115+
});
116+
117+
gulp.task('testAssets', () => {
118+
return gulp.src('./tests/**/*.{css,less,ico,png,html,json,yaml,yml}')
119+
.pipe(gulp.dest('./dist'));
120+
});
121+
122+
gulp.task('testJs', ['build'], () => {
123+
return gulp.src('./tests/**/*.js')
124+
.pipe(sourcemaps.init())
125+
.pipe(babel({
126+
presets: ['es2015'],
127+
plugins: ['add-module-exports']
128+
}))
129+
.pipe(sourcemaps.write('.'))
130+
.pipe(gulp.dest('./dist'));
131+
});
132+
133+
gulp.task('test', ['testJs', 'testAssets'], () => {
134+
return gulp.src([
135+
'./dist/**/*.test.js',
136+
], {read: false})
137+
.pipe(mocha({
138+
require: ['source-map-support/register'],
139+
reporter: 'spec'
140+
}))
141+
.once('error', () => process.exit(1))
142+
.once('end', () => process.exit())
143+
});
144+
145+
gulp.task('default', ['build']);

package.json

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
{
2+
"name": "node-red-contrib-generic-ble",
3+
"version": "1.0.0",
4+
"description": "Node-RED nodes for generic BLE devices",
5+
"license": "MIT",
6+
"repository": {
7+
"type": "git",
8+
"url": "https://github.com/CANDY-LINE/node-red-contrib-generic-ble.git"
9+
},
10+
"author": "Daisuke Baba <[email protected]>",
11+
"bugs": {
12+
"url": "https://github.com/CANDY-LINE/node-red-contrib-generic-ble/issues"
13+
},
14+
"scripts": {
15+
"build": "gulp build",
16+
"test": "gulp test",
17+
"clean": "gulp clean",
18+
"prepublish": "gulp build"
19+
},
20+
"homepage": "https://github.com/CANDY-LINE/node-red-contrib-generic-ble#readme",
21+
"keywords": [
22+
"node-red",
23+
"bluetooth",
24+
"BLE",
25+
"bluetooth low energy",
26+
"bluetooth smart",
27+
"CANDY RED",
28+
"CANDY EGG"
29+
],
30+
"browserify-shim": {
31+
},
32+
"devDependencies": {
33+
"node-red": "^0.16.2",
34+
"babel": "^6.23.0",
35+
"babel-cli": "^6.24.0",
36+
"babel-plugin-add-module-exports": "^0.2.1",
37+
"babel-plugin-transform-runtime": "^6.23.0",
38+
"babel-preset-babili": "0.0.12",
39+
"babel-preset-es2015": "^6.24.0",
40+
"babelify": "^7.3.0",
41+
"browserify": "^14.3.0",
42+
"browserify-shim": "^3.8.14",
43+
"chai": "^3.3.0",
44+
"del": "^2.2.2",
45+
"gulp": "^3.9.1",
46+
"gulp-babel": "^6.1.2",
47+
"gulp-clean-css": "^2.4.0",
48+
"gulp-cli": "^1.2.2",
49+
"gulp-header": "^1.8.8",
50+
"gulp-htmlmin": "^3.0.0",
51+
"gulp-if": "^2.0.2",
52+
"gulp-jshint": "^2.0.4",
53+
"gulp-less": "^3.3.0",
54+
"gulp-manifest": "^0.1.1",
55+
"gulp-mocha": "^4.3.0",
56+
"gulp-resources": "^0.5.0",
57+
"gulp-sourcemaps": "^2.5.1",
58+
"gulp-uglify": "^2.1.2",
59+
"gulp-util": "^3.0.8",
60+
"gulp-yaml": "^1.0.1",
61+
"jshint": "^2.9.1",
62+
"jshint-stylish": "^2.0.1",
63+
"mocha": "^3.0.2",
64+
"sinon": "^2.1.0",
65+
"supertest": "^1.1.0",
66+
"vinyl-buffer": "^1.0.0",
67+
"vinyl-source-stream": "^1.1.0"
68+
},
69+
"dependencies": {
70+
"noble": "^1.8.1",
71+
"source-map-support": "^0.4.2",
72+
"lru-cache": "^4.0.0"
73+
},
74+
"node-red": {
75+
"nodes": {
76+
"generic-ble": "dist/generic-ble.js"
77+
}
78+
}
79+
}

src/generic-ble.js

Whitespace-only changes.

src/locales/en-US/generic-ble.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<script type="text/x-red" data-help-name="Generic BLE in">
2+
</script>
3+
4+
<script type="text/x-red" data-help-name="Generic BLE out">
5+
</script>
6+
7+
<script type="text/x-red" data-help-name="Generic BLE">
8+
</script>

0 commit comments

Comments
 (0)