Skip to content

Commit

Permalink
Update project layout/build to use insin/templates/react-module
Browse files Browse the repository at this point in the history
  • Loading branch information
insin committed Jan 1, 2015
1 parent d7cba07 commit 52cb8cf
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 70 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
node_modules
index.js
lib
node_modules
4 changes: 2 additions & 2 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
demo
dist
node_modules
src
.gitignore
.jshintrc
.npmignore
bootstrap-example.png
gulpfile.js
index.jsx
gulpfile.js
4 changes: 3 additions & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Copyright (c) 2014 Jonny Buchanan
## react-filtered-multiselect

Copyright (c) 2015 Jonny Buchanan

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
91 changes: 46 additions & 45 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,73 +1,74 @@
var beep = require('beepbeep')
var browserify = require('browserify')
var del = require('del')
var gulp = require('gulp')
var source = require('vinyl-source-stream')

var header = require('gulp-header')
var jshint = require('gulp-jshint')
var react = require('gulp-react')
var rename = require('gulp-rename')
var plumber = require('gulp-plumber')
var react = require('gulp-react')
var streamify = require('gulp-streamify')
var uglify = require('gulp-uglify')
var gutil = require('gulp-util')

var pkg = require('./package.json')
var srcHeader = '/**\n\
* <%= pkg.name %> <%= pkg.version %> - https://github.com/insin/<%= pkg.name %>\n\
* MIT Licensed\n\
var devBuild = gutil.env.production ? '' : ' (dev build at ' + (new Date()).toUTCString() + ')'
var distHeader = '/*!\n\
* <%= pkg.name %> <%= pkg.version %><%= devBuild %> - <%= pkg.homepage %>\n\
* <%= pkg.license %> Licensed\n\
*/\n'

gulp.task('transpile-jsx', function() {
return gulp.src('./index.jsx')
.pipe(react({
harmony: true
}))
.pipe(gulp.dest('./'))
var jsSrcPaths = './src/**/*.js*'
var jsLibPaths = './lib/**/*.js'

gulp.task('clean-dist', function(cb) {
del('./dist/*.js', cb)
})

gulp.task('lint', ['transpile-jsx'], function() {
return gulp.src('./build/*.js')
gulp.task('clean-lib', function(cb) {
del(jsLibPaths, cb)
})

gulp.task('transpile-js', ['clean-lib'], function() {
return gulp.src(jsSrcPaths)
.pipe(plumber())
.pipe(react({harmony: true}))
.pipe(gulp.dest('./lib'))
})

gulp.task('lint-js', ['transpile-js'], function() {
return gulp.src(jsLibPaths)
.pipe(jshint('./.jshintrc'))
.pipe(jshint.reporter('jshint-stylish'))
})

var broken = false
var needsFixed = false

gulp.task('browserify', ['lint'], function() {
var b = browserify('./index.js', {
detectGlobals: false
, standalone: 'FilteredMultiSelect'
gulp.task('bundle-js', ['clean-dist', 'lint-js'], function() {
var b = browserify(pkg.main, {
debug: !!gutil.env.debug
, standalone: pkg.standalone
, detectGlobals: false
})
b.transform('browserify-shim')

return b.bundle()
.on('error', function(err) {
gutil.log(err.message)
beep(2, 0)
broken = true
this.emit('end')
})
.on('end', function() {
if (broken) {
needsFixed = true
}
else if (needsFixed) {
beep()
needsFixed = false
}
broken = false
})
.pipe(source('react-filtered-multiselect.js'))
.pipe(streamify(header(srcHeader, {pkg: pkg})))
.pipe(gulp.dest('./dist'))
.pipe(rename('react-filtered-multiselect.min.js'))
.pipe(streamify(uglify()))
.pipe(streamify(header(srcHeader, {pkg: pkg})))
var stream = b.bundle()
.pipe(source(pkg.name + '.js'))
.pipe(streamify(header(distHeader, {pkg: pkg, devBuild: devBuild})))
.pipe(gulp.dest('./dist'))

if (gutil.env.production) {
stream = stream
.pipe(rename(pkg.name + '.min.js'))
.pipe(streamify(uglify()))
.pipe(streamify(header(distHeader, {pkg: pkg, devBuild: devBuild})))
.pipe(gulp.dest('./dist'))
}

return stream
})

gulp.task('watch', function() {
gulp.watch('./index.jsx', ['browserify'])
gulp.watch(jsSrcPaths, ['bundle-js'])
})

gulp.task('default', ['browserify', 'watch'])
gulp.task('default', ['bundle-js', 'watch'])
49 changes: 29 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,49 @@
"name": "react-filtered-multiselect",
"description": "Filtered multi-select React component",
"version": "0.3.0",
"main": "./lib/index.js",
"homepage": "https://github.com/insin/react-filtered-multiselect",
"standalone": "FilteredMultiSelect",
"license": "MIT",
"author": "Jonny Buchanan <jonathan.buchanan@gmail.com> (https://github.com/insin)",
"keywords": [
"react",
"react-component",
"filtered",
"multiselect",
"select-multiple"
],
"main": "./index.js",
"repository": {
"type": "git",
"url": "http://github.com/insin/react-filtered-multiselect.git"
},
"dependencies": {
},
"peerDependencies": {
"react": ">=0.12.0"
},
"devDependencies": {
"beepbeep": "^1.2.0",
"browserify": "^6.3.2",
"browserify-shim": "^3.8.0",
"browserify": "^7.1.0",
"browserify-shim": "^3.8.1",
"del": "^1.1.1",
"gulp": "^3.8.10",
"gulp-header": "^1.2.2",
"gulp-jshint": "^1.9.0",
"gulp-plumber": "^0.6.6",
"gulp-react": "^2.0.0",
"gulp-rename": "^1.2.0",
"gulp-streamify": "0.0.5",
"gulp-uglify": "^1.0.1",
"gulp-uglify": "^1.0.2",
"gulp-util": "^3.0.1",
"jshint-stylish": "^1.0.0",
"vinyl-source-stream": "^1.0.0"
},
"peerDependencies": {
"react": ">=0.12.0"
"scripts": {
"debug": "gulp --debug",
"dist": "gulp bundle-js --production",
"watch": "gulp"
},
"scripts": {},
"browserify-shim": {
"react": "global:React"
}
},
"repository": {
"type": "git",
"url": "http://github.com/insin/react-filtered-multiselect.git"
},
"keywords": [
"react",
"react-component",
"filtered",
"multiselect",
"select-multiple"
]
}
File renamed without changes.

0 comments on commit 52cb8cf

Please sign in to comment.