├── .travis.yml ├── test ├── spec │ └── spec-myproject.js └── karma.conf.js ├── dist ├── project.min.js └── project.js ├── .editorconfig ├── .gitignore ├── src └── project.js ├── .jshintrc ├── package.json ├── LICENSE ├── README.md └── gulpfile.js /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "0.10" 4 | - "0.11" 5 | before_script: 6 | - npm install -g gulp 7 | script: gulp 8 | -------------------------------------------------------------------------------- /test/spec/spec-myproject.js: -------------------------------------------------------------------------------- 1 | describe('My module', function () { 2 | 3 | describe('init', function () { 4 | it('should include the MYPROJECT module', function () { 5 | expect(!!MYPROJECT).toBe(true); 6 | }); 7 | }); 8 | 9 | }); 10 | -------------------------------------------------------------------------------- /dist/project.min.js: -------------------------------------------------------------------------------- 1 | /*! gulp-oss v0.0.1 | (c) 2014 @toddmotto | https://github.com/project */ 2 | !function(e,t){"function"==typeof define&&define.amd?define(t):"object"==typeof exports?module.exports=t:e.MYPROJECT=t()}(this,function(){"use strict";var e={};return e.init=function(){},e}); -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org/ 2 | 3 | root = true 4 | 5 | [*] 6 | indent_style = space 7 | indent_size = 2 8 | end_of_line = lf 9 | charset = utf-8 10 | trim_trailing_whitespace = true 11 | insert_final_newline = true 12 | 13 | [*.md] 14 | trim_trailing_whitespace = false 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Node 2 | node_modules 3 | 4 | # Generated 5 | .sass-cache/ 6 | *.sublime-* 7 | 8 | ## OS X 9 | .DS_Store 10 | .AppleDouble 11 | .LSOverride 12 | Icon 13 | ._* 14 | .Spotlight-V100 15 | .Trashes 16 | 17 | ## Windows 18 | Thumbs.db 19 | ehthumbs.db 20 | Desktop.ini 21 | $RECYCLE.BIN/ 22 | -------------------------------------------------------------------------------- /test/karma.conf.js: -------------------------------------------------------------------------------- 1 | module.exports = function (config) { 2 | config.set({ 3 | basePath : '', 4 | autoWatch : true, 5 | frameworks: ['jasmine'], 6 | browsers : ['PhantomJS'], 7 | plugins : [ 8 | 'karma-spec-reporter', 9 | 'karma-phantomjs-launcher', 10 | 'karma-jasmine' 11 | ], 12 | reporters : ['spec'] 13 | }); 14 | }; 15 | -------------------------------------------------------------------------------- /src/project.js: -------------------------------------------------------------------------------- 1 | (function (root, factory) { 2 | if (typeof define === 'function' && define.amd) { 3 | define(factory); 4 | } else if (typeof exports === 'object') { 5 | module.exports = factory; 6 | } else { 7 | root.MYPROJECT = factory(); 8 | } 9 | })(this, function () { 10 | 11 | 'use strict'; 12 | 13 | var exports = {}; 14 | 15 | exports.init = function () {}; 16 | 17 | return exports; 18 | 19 | }); 20 | -------------------------------------------------------------------------------- /dist/project.js: -------------------------------------------------------------------------------- 1 | /*! gulp-oss v0.0.1 | (c) 2014 @toddmotto | https://github.com/project */ 2 | (function (root, factory) { 3 | if (typeof define === 'function' && define.amd) { 4 | define(factory); 5 | } else if (typeof exports === 'object') { 6 | module.exports = factory; 7 | } else { 8 | root.MYPROJECT = factory(); 9 | } 10 | })(this, function () { 11 | 12 | 'use strict'; 13 | 14 | var exports = {}; 15 | 16 | exports.init = function () {}; 17 | 18 | return exports; 19 | 20 | }); 21 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "node": true, 3 | "browser": true, 4 | "esnext": true, 5 | "bitwise": true, 6 | "camelcase": true, 7 | "curly": true, 8 | "eqeqeq": true, 9 | "immed": true, 10 | "indent": 2, 11 | "latedef": true, 12 | "newcap": true, 13 | "noempty" : true, 14 | "nonbsp" : true, 15 | "noarg": true, 16 | "quotmark": "single", 17 | "regexp": true, 18 | "undef": true, 19 | "unused": false, 20 | "evil" : true, 21 | "strict": false, 22 | "trailing": true, 23 | "smarttabs": true, 24 | "globals" : { 25 | "define": true, 26 | "exports": true 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gulp-oss", 3 | "version": "0.0.1", 4 | "description": "My Gulp.js boilerplate for creating new JavaScript projects", 5 | "author": "@toddmotto", 6 | "license": "MIT", 7 | "homepage": "https://github.com/project", 8 | "devDependencies": { 9 | "gulp": "~3.7.0", 10 | "gulp-uglify": "~0.3.0", 11 | "gulp-rename": "~1.1.0", 12 | "gulp-clean": "^0.2.4", 13 | "gulp-plumber": "~0.6.2", 14 | "gulp-header": "^1.0.2", 15 | "gulp-jshint": "^1.6.1", 16 | "jshint-stylish": "^0.2.0", 17 | "gulp-karma": "0.0.4", 18 | "karma": "^0.12.16", 19 | "karma-jasmine": "~0.2.0", 20 | "karma-phantomjs-launcher": "^0.1.4", 21 | "karma-spec-reporter": "0.0.13" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | LICENSE 2 | 3 | The MIT License 4 | 5 | Copyright (c) 2014 Conditionizr (Todd Motto, Mark Goodyear) 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GulpOSS 2 | 3 | My Gulp.js boilerplate for creating new JavaScript projects! Use if you will, if so here's a brief intro as to what it does. 4 | 5 | This boilerplate does the following: 6 | 7 | * Provides a [UMD](https://github.com/umdjs/umd) wrapper for JavaScript modules, `project.js` (rename to suit) 8 | * Lints `src/*.js` 9 | * Adds a copyright banner to outputted files, configurable 10 | * Compiles a `*.js` and `*.min.js` version of the `src/*.js` file 11 | * Cleans the `dist` directory each time files compiled 12 | * Boots a Karma server, runs Jasmine unit tests on `src/*.js` file 13 | * Evalutes Jasmine tests using PhantomJS (headless WebKit) 14 | * Prints tests on the command line 15 | * Ships with `.travis.yml` which runs `gulp` on [TravisCI](https://travis-ci.org) 16 | 17 | ### Dependencies 18 | 19 | * [PhantomJS](http://phantomjs.org), best installed using [Brew](http://brew.sh) 20 | * [Node.js](http://nodejs.org) 21 | * [Gulp](http://gulpjs.com) `npm install -g gulp` 22 | 23 | ### How to use 24 | 25 | Inside `gulpfile.js` you'll see the following, rename the `scripts: []` file to your desired name: 26 | 27 | ```js 28 | var paths = { 29 | output : 'dist/', 30 | scripts : [ 31 | 'src/project.js' 32 | ], 33 | test: [ 34 | 'test/spec/**/*.js' 35 | ] 36 | }; 37 | ``` 38 | 39 | Inside `package.json` you'll be able to change the names of the project. 40 | 41 | Inside `project.js` is the UMD setup which returns an Object from the module, an enhanced Module pattern. Rename `root.MYPROJECT` to suit. 42 | 43 | Inside `spec-myproject.js` is an example `describe()` to setup the first [Jasmine](http://jasmine.github.io) unit test. 44 | 45 | Run `npm install` and `gulp` to get going. 46 | -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | var gulp = require('gulp'), 2 | karma = require('gulp-karma'), 3 | jshint = require('gulp-jshint'), 4 | stylish = require('jshint-stylish'), 5 | header = require('gulp-header'), 6 | uglify = require('gulp-uglify'), 7 | plumber = require('gulp-plumber'), 8 | clean = require('gulp-clean'), 9 | rename = require('gulp-rename'), 10 | package = require('./package.json'); 11 | 12 | var paths = { 13 | output : 'dist/', 14 | scripts : [ 15 | 'src/project.js' 16 | ], 17 | test: [ 18 | 'test/spec/**/*.js' 19 | ] 20 | }; 21 | 22 | var banner = [ 23 | '/*! ', 24 | '<%= package.name %> ', 25 | 'v<%= package.version %> | ', 26 | '(c) ' + new Date().getFullYear() + ' <%= package.author %> |', 27 | ' <%= package.homepage %>', 28 | ' */', 29 | '\n' 30 | ].join(''); 31 | 32 | gulp.task('scripts', ['clean'], function() { 33 | return gulp.src(paths.scripts) 34 | .pipe(plumber()) 35 | .pipe(header(banner, { package : package })) 36 | .pipe(gulp.dest('dist/')) 37 | .pipe(rename({ suffix: '.min' })) 38 | .pipe(uglify()) 39 | .pipe(header(banner, { package : package })) 40 | .pipe(gulp.dest('dist/')); 41 | }); 42 | 43 | gulp.task('lint', function () { 44 | return gulp.src(paths.scripts) 45 | .pipe(plumber()) 46 | .pipe(jshint()) 47 | .pipe(jshint.reporter('jshint-stylish')); 48 | }); 49 | 50 | gulp.task('clean', function () { 51 | return gulp.src(paths.output, { read: false }) 52 | .pipe(plumber()) 53 | .pipe(clean()); 54 | }); 55 | 56 | gulp.task('test', function() { 57 | return gulp.src(paths.scripts.concat(paths.test)) 58 | .pipe(plumber()) 59 | .pipe(karma({ configFile: 'test/karma.conf.js' })) 60 | .on('error', function(err) { throw err; }); 61 | }); 62 | 63 | gulp.task('default', [ 64 | 'lint', 65 | 'clean', 66 | 'scripts', 67 | 'test' 68 | ]); 69 | --------------------------------------------------------------------------------