From 5aed7ee0bcb8d7005b722825b71e30b1edad5cd9 Mon Sep 17 00:00:00 2001 From: Rob Eisenberg Date: Fri, 6 Feb 2015 17:00:09 -0500 Subject: [PATCH] chore(all): new build, contrib and lint --- .jshintrc | 3 + CONTRIBUTING.md | 3 + README.md | 4 - build/6to5-options.js | 23 ++++++ build/paths.js | 14 ++++ build/tasks/build.js | 37 +++++++++ build/tasks/clean.js | 9 +++ build/tasks/dev.js | 10 +++ build/tasks/doc.js | 14 ++++ build/tasks/lint.js | 10 +++ build/tasks/prepare-release.js | 35 +++++++++ gulpfile.js | 132 +-------------------------------- package.json | 3 +- 13 files changed, 161 insertions(+), 136 deletions(-) create mode 100644 .jshintrc create mode 100644 CONTRIBUTING.md create mode 100644 build/6to5-options.js create mode 100644 build/paths.js create mode 100644 build/tasks/build.js create mode 100644 build/tasks/clean.js create mode 100644 build/tasks/dev.js create mode 100644 build/tasks/doc.js create mode 100644 build/tasks/lint.js create mode 100644 build/tasks/prepare-release.js diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..a5aaaed --- /dev/null +++ b/.jshintrc @@ -0,0 +1,3 @@ +{ + "esnext": true +} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..78b6fb5 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,3 @@ +# Contributing + +We'd love for you to contribute and to make this project even better than it is today! If this interests you, please begin by reading [our contributing guidelines](https://github.com/DurandalProject/about/blob/master/CONTRIBUTING.md). The contributing document will provide you with all the information you need to get started. Once you have read that, you will need to also [sign our CLA](http://goo.gl/forms/dI8QDDSyKR) before we can accept a Pull Request from you. More information on the process is included in the [contributor's guide](https://github.com/DurandalProject/about/blob/master/CONTRIBUTING.md). diff --git a/README.md b/README.md index 77cd60b..5a5ea9e 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,3 @@ To run the unit tests, first ensure that you have followed the steps above in or ```shell karma start ``` - -## Contributing - -We'd love for you to contribute to our source code and to make this project even better than it is today! If this interests you, please begin by reading [our contributing guidelines](https://github.com/DurandalProject/about/blob/master/CONTRIBUTING.md). The contributing document will provide you with all the information you need to get started. Once you have read that, you will need to also [sign our CLA](http://goo.gl/forms/dI8QDDSyKR) before we can accepts a Pull Request from you. More information on the process is including in the [contributor's guide](https://github.com/DurandalProject/about/blob/master/CONTRIBUTING.md). \ No newline at end of file diff --git a/build/6to5-options.js b/build/6to5-options.js new file mode 100644 index 0000000..6cf460d --- /dev/null +++ b/build/6to5-options.js @@ -0,0 +1,23 @@ +module.exports = { + filename: '', + filenameRelative: '', + blacklist: [], + whitelist: [], + modules: '', + sourceMap: true, + sourceMapName: '', + sourceRoot: '', + moduleRoot: '', + moduleIds: false, + experimental: false, + format: { + comments: false, + compact: false, + indent: { + parentheses: true, + adjustMultilineComment: true, + style: " ", + base: 0 + } + } +}; diff --git a/build/paths.js b/build/paths.js new file mode 100644 index 0000000..7e99344 --- /dev/null +++ b/build/paths.js @@ -0,0 +1,14 @@ +var path = require('path'); + +var appRoot = 'src/'; + +module.exports = { + root: appRoot, + source: appRoot + '**/*.js', + html: appRoot + '**/*.html', + style: 'styles/**/*.css', + output: 'dist/', + doc:'./doc', + e2eSpecsSrc: 'test/e2e/src/*.js', + e2eSpecsDist: 'test/e2e/dist/' +}; diff --git a/build/tasks/build.js b/build/tasks/build.js new file mode 100644 index 0000000..3d9cf4b --- /dev/null +++ b/build/tasks/build.js @@ -0,0 +1,37 @@ +var gulp = require('gulp'); +var runSequence = require('run-sequence'); +var to5 = require('gulp-6to5'); +var paths = require('../paths'); +var compilerOptions = require('../6to5-options'); +var assign = Object.assign || require('object.assign'); + +gulp.task('build-es6', function () { + return gulp.src(paths.source) + .pipe(gulp.dest(paths.output + 'es6')); +}); + +gulp.task('build-commonjs', function () { + return gulp.src(paths.source) + .pipe(to5(assign({}, compilerOptions, {modules:'common'}))) + .pipe(gulp.dest(paths.output + 'commonjs')); +}); + +gulp.task('build-amd', function () { + return gulp.src(paths.source) + .pipe(to5(assign({}, compilerOptions, {modules:'amd'}))) + .pipe(gulp.dest(paths.output + 'amd')); +}); + +gulp.task('build-system', function () { + return gulp.src(paths.source) + .pipe(to5(assign({}, compilerOptions, {modules:'system'}))) + .pipe(gulp.dest(paths.output + 'system')); +}); + +gulp.task('build', function(callback) { + return runSequence( + 'clean', + ['build-es6', 'build-commonjs', 'build-amd', 'build-system'], + callback + ); +}); diff --git a/build/tasks/clean.js b/build/tasks/clean.js new file mode 100644 index 0000000..800cb0b --- /dev/null +++ b/build/tasks/clean.js @@ -0,0 +1,9 @@ +var gulp = require('gulp'); +var paths = require('../paths'); +var del = require('del'); +var vinylPaths = require('vinyl-paths'); + +gulp.task('clean', function() { + return gulp.src([paths.output]) + .pipe(vinylPaths(del)); +}); diff --git a/build/tasks/dev.js b/build/tasks/dev.js new file mode 100644 index 0000000..2d8c619 --- /dev/null +++ b/build/tasks/dev.js @@ -0,0 +1,10 @@ +var gulp = require('gulp'); +var tools = require('aurelia-tools'); + +gulp.task('update-own-deps', function(){ + tools.updateOwnDependenciesFromLocalRepositories(); +}); + +gulp.task('build-dev-env', function () { + tools.buildDevEnv(); +}); diff --git a/build/tasks/doc.js b/build/tasks/doc.js new file mode 100644 index 0000000..ea027cb --- /dev/null +++ b/build/tasks/doc.js @@ -0,0 +1,14 @@ +var gulp = require('gulp'); +var tools = require('aurelia-tools'); +var paths = require('../paths'); +var yuidoc = require('gulp-yuidoc'); + +gulp.task('doc-generate', function(){ + return gulp.src(paths.source) + .pipe(yuidoc.parser(null, 'api.json')) + .pipe(gulp.dest(paths.doc)); +}); + +gulp.task('doc', ['doc-generate'], function(){ + tools.transformAPIModel(paths.doc); +}); diff --git a/build/tasks/lint.js b/build/tasks/lint.js new file mode 100644 index 0000000..d10253f --- /dev/null +++ b/build/tasks/lint.js @@ -0,0 +1,10 @@ +var gulp = require('gulp'); +var paths = require('../paths'); +var jshint = require('gulp-jshint'); +var stylish = require('jshint-stylish'); + +gulp.task('lint', function() { + return gulp.src(paths.source) + .pipe(jshint()) + .pipe(jshint.reporter(stylish)); +}); diff --git a/build/tasks/prepare-release.js b/build/tasks/prepare-release.js new file mode 100644 index 0000000..d875326 --- /dev/null +++ b/build/tasks/prepare-release.js @@ -0,0 +1,35 @@ +var gulp = require('gulp'); +var runSequence = require('run-sequence'); +var paths = require('../paths'); +var changelog = require('conventional-changelog'); +var fs = require('fs'); +var bump = require('gulp-bump'); + +gulp.task('bump-version', function(){ + return gulp.src(['./package.json']) + .pipe(bump({type:'patch'})) //major|minor|patch|prerelease + .pipe(gulp.dest('./')); +}); + +gulp.task('changelog', function(callback) { + var pkg = JSON.parse(fs.readFileSync('./package.json', 'utf-8')); + + return changelog({ + repository: pkg.repository.url, + version: pkg.version, + file: paths.doc + '/CHANGELOG.md' + }, function(err, log) { + fs.writeFileSync(paths.doc + '/CHANGELOG.md', log); + }); +}); + +gulp.task('prepare-release', function(callback){ + return runSequence( + 'build', + 'lint', + 'bump-version', + 'doc', + 'changelog', + callback + ); +}); diff --git a/gulpfile.js b/gulpfile.js index 5feebec..978fd98 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,131 +1 @@ -var gulp = require('gulp'); -var runSequence = require('run-sequence'); -var del = require('del'); -var vinylPaths = require('vinyl-paths'); -var to5 = require('gulp-6to5'); -var jshint = require('gulp-jshint'); -var stylish = require('jshint-stylish'); -var yuidoc = require("gulp-yuidoc"); -var changelog = require('conventional-changelog'); -var assign = Object.assign || require('object.assign'); -var fs = require('fs'); -var bump = require('gulp-bump'); -var tools = require('aurelia-tools'); - -var path = { - source:'src/**/*.js', - output:'dist/', - doc:'./doc' -}; - -var compilerOptions = { - filename: '', - filenameRelative: '', - blacklist: [], - whitelist: [], - modules: '', - sourceMap: true, - sourceMapName: '', - sourceFileName: '', - sourceRoot: '', - moduleRoot: '', - moduleIds: false, - experimental: false, - format: { - comments: false, - compact: false, - indent: { - parentheses: true, - adjustMultilineComment: true, - style: " ", - base: 0 - } - } -}; - -var jshintConfig = {esnext:true}; - -gulp.task('clean', function() { - return gulp.src([path.output]) - .pipe(vinylPaths(del)); -}); - -gulp.task('build-es6', function () { - return gulp.src(path.source) - .pipe(gulp.dest(path.output + 'es6')); -}); - -gulp.task('build-commonjs', function () { - return gulp.src(path.source) - .pipe(to5(assign({}, compilerOptions, {modules:'common'}))) - .pipe(gulp.dest(path.output + 'commonjs')); -}); - -gulp.task('build-amd', function () { - return gulp.src(path.source) - .pipe(to5(assign({}, compilerOptions, {modules:'amd'}))) - .pipe(gulp.dest(path.output + 'amd')); -}); - -gulp.task('build-system', function () { - return gulp.src(path.source) - .pipe(to5(assign({}, compilerOptions, {modules:'system'}))) - .pipe(gulp.dest(path.output + 'system')); -}); - -gulp.task('lint', function() { - return gulp.src(path.source) - .pipe(jshint(jshintConfig)) - .pipe(jshint.reporter(stylish)); -}); - -gulp.task('doc-generate', function(){ - return gulp.src(path.source) - .pipe(yuidoc.parser(null, 'api.json')) - .pipe(gulp.dest(path.doc)); -}); - -gulp.task('doc', ['doc-generate'], function(){ - tools.transformAPIModel(path.doc); -}); - -gulp.task('bump-version', function(){ - return gulp.src(['./bower.json', './package.json']) - .pipe(bump({type:'patch'})) //major|minor|patch|prerelease - .pipe(gulp.dest('./')); -}); - -gulp.task('changelog', function(callback) { - var pkg = JSON.parse(fs.readFileSync('./package.json', 'utf-8')); - - return changelog({ - repository: pkg.repository.url, - version: pkg.version, - file: path.doc + '/CHANGELOG.md' - }, function(err, log) { - fs.writeFileSync(path.doc + '/CHANGELOG.md', log); - }); -}); - -gulp.task('build', function(callback) { - return runSequence( - 'clean', - ['build-es6', 'build-commonjs', 'build-amd', 'build-system'], - callback - ); -}); - -gulp.task('update-own-deps', function(){ - tools.updateOwnDependenciesFromLocalRepositories(); -}); - -gulp.task('prepare-release', function(callback){ - return runSequence( - 'build', - 'lint', - 'bump-version', - 'doc', - 'changelog', - callback - ); -}); +require('require-dir')('build/tasks'); diff --git a/package.json b/package.json index bfcbdc4..cc5bc6c 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ } }, "devDependencies": { - "aurelia-tools": "git://github.com/aurelia/tools.git", + "aurelia-tools": "^0.1.0", "conventional-changelog": "0.0.11", "del": "^1.1.0", "gulp": "^3.8.10", @@ -48,6 +48,7 @@ "karma-jasmine": "^0.3.2", "karma-jspm": "^1.0.1", "object.assign": "^1.0.3", + "require-dir": "^0.1.0", "run-sequence": "^1.0.2", "vinyl-paths": "^1.0.0" },