diff --git a/Gruntfile.js b/Gruntfile.js index 7b57f6385..6430c3665 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,139 +1,11 @@ module.exports = function(grunt) { - var path = require('path'); + var config = require('./config.json'); - // Project configuration. - grunt.initConfig({ - pkg: grunt.file.readJSON('package.json'), - concat: { - options: { - stripBanners: true, - banner: '/* \n * <%= pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy") %> \n * \n * <%= pkg.author %>, and the web community.\n * Licensed under the <%= pkg.license %> license. \n * \n * Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice. \n *\n */\n\n', - }, - patternlab: { - src: './builder/patternlab.js', - dest: './builder/patternlab.js' - }, - object_factory: { - src: './builder/object_factory.js', - dest: './builder/object_factory.js' - }, - lineage: { - src: './builder/lineage_hunter.js', - dest: './builder/lineage_hunter.js' - }, - media_hunter: { - src: './builder/media_hunter.js', - dest: './builder/media_hunter.js' - }, - patternlab_grunt: { - src: './builder/patternlab_grunt.js', - dest: './builder/patternlab_grunt.js' - }, - patternlab_gulp: { - src: './builder/patternlab_gulp.js', - dest: './builder/patternlab_gulp.js' - }, - parameter_hunter: { - src: './builder/parameter_hunter.js', - dest: './builder/parameter_hunter.js' - }, - pattern_exporter: { - src: './builder/pattern_exporter.js', - dest: './builder/pattern_exporter.js' - }, - pattern_assembler: { - src: './builder/pattern_assembler.js', - dest: './builder/pattern_assembler.js' - }, - pseudopattern_hunter: { - src: './builder/pseudopattern_hunter.js', - dest: './builder/pseudopattern_hunter.js' - }, - list_item_hunter: { - src: './builder/list_item_hunter.js', - dest: './builder/list_item_hunter.js' - }, - style_modifier_hunter: { - src: './builder/style_modifier_hunter.js', - dest: './builder/style_modifier_hunter.js' - } - }, - copy: { - main: { - files: [ - { expand: true, cwd: path.resolve(paths().source.js), src: '*.js', dest: path.resolve(paths().public.js) }, - { expand: true, cwd: path.resolve(paths().source.css), src: '*.css', dest: path.resolve(paths().public.css) }, - { expand: true, cwd: path.resolve(paths().source.images), src: ['**/*.png', '**/*.jpg', '**/*.gif', '**/*.jpeg'], dest: path.resolve(paths().public.images) }, - { expand: true, cwd: path.resolve(paths().source.fonts), src: '*', dest: path.resolve(paths().public.fonts) }, - { expand: true, cwd: path.resolve(paths().source.data), src: 'annotations.js', dest: path.resolve(paths().public.data) } - ] - }, - styleguide: { - files: [ - { expand: true, cwd: path.resolve(paths().source.styleguide), src: ['*.*', '**/*.*'], dest: path.resolve(paths().public.styleguide) } - ] - } - }, - watch: { - all: { - files: [ - path.resolve(paths().source.css + '**/*.css'), - path.resolve(paths().source.styleguide + 'css/*.css'), - path.resolve(paths().source.patterns + '**/*.mustache'), - path.resolve(paths().source.patterns + '**/*.json'), - path.resolve(paths().source.fonts + '/*'), - path.resolve(paths().source.images + '/*'), - path.resolve(paths().source.data + '*.json') - ], - tasks: ['default', 'bsReload:css'] - } - }, - nodeunit: { - all: ['test/*_tests.js'] - }, - browserSync: { - dev: { - options: { - server: path.resolve(paths().public.root), - watchTask: true, - watchOptions: { - ignoreInitial: true, - ignored: '*.html' - }, - plugins: [ - { - module: 'bs-html-injector', - options: { - files: [path.resolve(paths().public.root + '/index.html'), path.resolve(paths().public.styleguide + '/styleguide.html')] - } - } - ] - } - } - }, - bsReload: { - css: path.resolve(paths().public.root + '**/*.css') - } - }); + grunt.initConfig({}); - function paths () { - return require('./config.json').paths; - } - - // load all grunt tasks - require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks); - - //load the patternlab task - grunt.task.loadTasks('./builder/'); - - grunt.registerTask('default', ['patternlab', 'copy:main', 'copy:styleguide']); - - //travis CI task - grunt.registerTask('travis', ['nodeunit', 'patternlab']); - - grunt.registerTask('serve', ['patternlab', 'copy:main', 'copy:styleguide', 'browserSync', 'watch:all']); - - grunt.registerTask('build', ['nodeunit', 'concat']); + // Load grunt tasks to the current grunt and inject the local configuration + require('./builder/grunt-build')(grunt, config); + grunt.registerTask('default', ['patternlab', 'copy:pl_main', 'copy:pl_styleguide']); }; diff --git a/README.md b/README.md index 97b7fed55..edca6b088 100644 --- a/README.md +++ b/README.md @@ -22,37 +22,34 @@ Make sure you are running your terminal/command line session as administrator. T ### Choose Your Adventure! Now Vanilla, Grunt & Gulp -This repository ships with two `package.json` files, a `Gruntfile.js`, and a `gulpfile.js`. The default is grunt currently. The core builder is not dependent on either. +This repository ships a `Gruntfile.js`, and a `gulpfile.js`. The default is grunt currently. The core builder and tests are not dependent on either. ### Getting Started - Grunt To run patternlab-node using grunt, do the following in the directory you downloaded and extracted the zipped release: 1. Run `npm install` from the command line -2. Optionally, delete `package.gulp.json`, `gulpfile.js`, and `builder/patternlab_gulp.js` files if you are certain you don't need it. -* Not deleting `builder/patternlab_gulp.js` may cause a harmless error when running grunt. Delete it. -3. Run `grunt` or `grunt serve` from the command line +2. Optionally, delete `gulpfile.js`, `builder/gulp-core.js`, `builder/gulp-build.js` and `builder/gulp-extra.js` files if you are certain you don't need it. +3. Run `grunt` or `grunt pl:serve` from the command line -This creates all patterns, the styleguide, and the pattern lab site. It's strongly recommended to run `grunt serve` to have BrowserSync spin up and serve the files to you. +This creates all patterns, the styleguide, and the pattern lab site. It's strongly recommended to run `grunt pl:serve` to have BrowserSync spin up and serve the files to you. ### Getting Started - Gulp To run patternlab-node using gulp, you need to swap out the default grunt configuration. Do the following in the directory you downloaded and extracted the zipped release: -1. Rename `package.json` to `package.grunt.json` or delete it if you don't intend on going back -2. Rename `package.gulp.json` to `package.json` -3. Run `npm install` from the command line -4. Run `gulp` or `gulp serve` from the command line +1. Run `npm install` from the command line +2. Optionally, delete `Gruntfile.js`, `builder/grunt-core.js` and `builder/grunt-build.js` files if you are certain you don't need it. +4. Run `gulp` or `gulp pl:serve` from the command line -This creates all patterns, the styleguide, and the pattern lab site. It's strongly recommended to run `gulp serve` to have BrowserSync spin up and serve the files to you. +This creates all patterns, the styleguide, and the pattern lab site. It's strongly recommended to run `gulp pl:serve` to have BrowserSync spin up and serve the files to you. ### There and Back Again, or Switching Between Grunt and Gulp It's not expected to toggle between the two build systems, but for those migrating between the two configs, here's some general guidelines: -* Make sure your `package.json` files are correct per the Getting Started sections. -* Run `npm cache clear` before installation -* Delete the contents of `./node_modules` if you want a cleaner installation. +* Don't delete any files related to grunt or gulp. That's it! +* The `package.json` includes all dependencies for gulp **and** grunt so you can switch between the two without doing anything. * Regarding speed, Gulp is faster. BrowserSync takes a bit longer than the old static server to spin up, but its capabilities far outweigh the startup cost. ### Upgrading @@ -78,7 +75,7 @@ Get more information about patternlab-node, pattern lab in general, and where to ### Further Configuration ##### Watching Changes -To have patternlab-node watch for changes to either a mustache template, data, or stylesheets, run `grunt|gulp watch` or `grunt|gulp serve`. The `Gruntfile|Gulpfile` governs what is watched. It should be easy to add scss or whatever preprocessor you fancy. +To have patternlab-node watch for changes to either a mustache template, data, or stylesheets, run `grunt watch|gulp pl:connect` or `grunt|gulp pl:serve`. The `Gruntfile|Gulpfile` governs what is watched. It should be easy to add scss or whatever preprocessor you fancy. ##### Configurable Paths Pattern Lab Node ships with a particular source and public workflow intended to separate the code you work on with the code generated for consumption elsewhere. If you wish to change any paths, you may do so within `config.json`. The contents are here: diff --git a/builder/grunt-build.js b/builder/grunt-build.js new file mode 100644 index 000000000..7228057db --- /dev/null +++ b/builder/grunt-build.js @@ -0,0 +1,167 @@ +/* + * patternlab-node - v1.1.0 - 2016 + * + * Brian Muenzenmeyer, and the web community. + * Licensed under the MIT license. + * + * Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice. + * + */ + +// IMPORTANT: Remember that `./` matches the root of the grunt file that requires this one! +// However, this does not apply to the `require('...')` +module.exports = function(grunt, config) { + var path = require('path'); + + // Load CORE tasks + require('./grunt-core')(grunt, config); + + // Load all grunt tasks + require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks); + + // Project configuration. + grunt.config.merge({ + pkg: grunt.file.readJSON('package.json'), + concat: { + options: { + stripBanners: true, + banner: '/* \n * <%= pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy") %> \n * \n * <%= pkg.author %>, and the web community.\n * Licensed under the <%= pkg.license %> license. \n * \n * Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice. \n *\n */\n\n', + }, + pl_patternlab: { + src: './builder/patternlab.js', + dest: './builder/patternlab.js' + }, + pl_object_factory: { + src: './builder/object_factory.js', + dest: './builder/object_factory.js' + }, + pl_lineage: { + src: './builder/lineage_hunter.js', + dest: './builder/lineage_hunter.js' + }, + pl_media_hunter: { + src: './builder/media_hunter.js', + dest: './builder/media_hunter.js' + }, + pl_patternlab_grunt: { + src: './builder/patternlab_grunt.js', + dest: './builder/patternlab_grunt.js' + }, + pl_patternlab_gulp: { + src: './builder/patternlab_gulp.js', + dest: './builder/patternlab_gulp.js' + }, + pl_parameter_hunter: { + src: './builder/parameter_hunter.js', + dest: './builder/parameter_hunter.js' + }, + pl_pattern_exporter: { + src: './builder/pattern_exporter.js', + dest: './builder/pattern_exporter.js' + }, + pl_pattern_assembler: { + src: './builder/pattern_assembler.js', + dest: './builder/pattern_assembler.js' + }, + pl_pseudopattern_hunter: { + src: './builder/pseudopattern_hunter.js', + dest: './builder/pseudopattern_hunter.js' + }, + pl_list_item_hunter: { + src: './builder/list_item_hunter.js', + dest: './builder/list_item_hunter.js' + }, + pl_style_modifier_hunter: { + src: './builder/style_modifier_hunter.js', + dest: './builder/style_modifier_hunter.js' + } + }, + copy: { + pl_main: { + files: [ + { + expand: true, + cwd: path.resolve(config.paths.source.js), + src: '*.js', + dest: path.resolve(config.paths.public.js) + }, + { + expand: true, + cwd: path.resolve(config.paths.source.css), + src: '*.css', + dest: path.resolve(config.paths.public.css) + }, + { + expand: true, + cwd: path.resolve(config.paths.source.images), + src: ['**/*.png', '**/*.jpg', '**/*.gif', '**/*.jpeg'], + dest: path.resolve(config.paths.public.images) + }, + { + expand: true, + cwd: path.resolve(config.paths.source.fonts), + src: '*', + dest: path.resolve(config.paths.public.fonts) + }, + { + expand: true, + cwd: path.resolve(config.paths.source.data), + src: 'annotations.js', + dest: path.resolve(config.paths.public.data) + } + ] + }, + pl_styleguide: { + files: [ + { + expand: true, + cwd: path.resolve(config.paths.source.styleguide), + src: ['*.*', '**/*.*'], + dest: path.resolve(config.paths.public.styleguide) + } + ] + } + }, + watch: { + pl_all: { + files: [ + path.resolve(config.paths.source.css + '**/*.css'), + path.resolve(config.paths.source.styleguide + 'css/*.css'), + path.resolve(config.paths.source.patterns + '**/*.mustache'), + path.resolve(config.paths.source.patterns + '**/*.json'), + path.resolve(config.paths.source.fonts + '/*'), + path.resolve(config.paths.source.images + '/*'), + path.resolve(config.paths.source.data + '*.json') + ], + tasks: ['default', 'bsReload:pl_css'] + } + }, + browserSync: { + pl_dev: { + options: { + server: path.resolve(config.paths.public.root), + watchTask: true, + watchOptions: { + ignoreInitial: true, + ignored: '*.html' + }, + plugins: [ + { + module: 'bs-html-injector', + options: { + files: [path.resolve(config.paths.public.root + '/index.html'), path.resolve(config.paths.public.styleguide + '/styleguide.html')] + } + } + ] + } + } + }, + bsReload: { + pl_css: path.resolve(config.paths.public.root + '**/*.css') + } + }); + + grunt.registerTask('pl:serve', ['patternlab', 'copy:pl_main', 'copy:pl_styleguide', 'browserSync', 'watch:pl_all']); + + grunt.registerTask('pl:build', ['concat']); +}; \ No newline at end of file diff --git a/builder/grunt-core.js b/builder/grunt-core.js new file mode 100644 index 000000000..b5f1fa5a4 --- /dev/null +++ b/builder/grunt-core.js @@ -0,0 +1,37 @@ +/* + * patternlab-node - v1.1.0 - 2016 + * + * Brian Muenzenmeyer, and the web community. + * Licensed under the MIT license. + * + * Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice. + * + */ + +// IMPORTANT: Remember that `./` matches the root of the grunt file that requires this one! +// However, this does not apply to the `require('...')` +module.exports = function(grunt, config) { + var patternlab = require('./patternlab.js')(config); + + grunt.registerTask('patternlab', 'create design systems with atomic design', function(arg) { + if(arguments.length === 0){ + patternlab.build(true); + } + + if(arg && arg === 'v'){ + patternlab.version(); + } + + if(arg && arg === "only_patterns"){ + patternlab.build_patterns_only(true); + } + + if(arg && arg === "help"){ + patternlab.help(); + } + + if(arg && (arg !== "v" && arg !=="only_patterns" && arg !=="help")){ + patternlab.help(); + } + }); +}; \ No newline at end of file diff --git a/builder/gulp-build.js b/builder/gulp-build.js new file mode 100644 index 000000000..00f047883 --- /dev/null +++ b/builder/gulp-build.js @@ -0,0 +1,100 @@ +/* + * patternlab-node - v1.1.0 - 2016 + * + * Brian Muenzenmeyer, and the web community. + * Licensed under the MIT license. + * + * Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice. + * + */ + +// IMPORTANT: Remember that `./` matches the root of the gulp file that requires this one! +// However, this does not apply to the `require('...')` +module.exports = function(gulp, config) { + var path = require('path'), + browserSync = require('browser-sync').create(); + + // Load CORE tasks + require('./gulp-core')(gulp, config); + + // COPY TASKS + + // JS copy + gulp.task('pl:cp:js', function(){ + return gulp.src('**/*.js', {cwd: path.resolve(config.paths.source.js)} ) + .pipe(gulp.dest(path.resolve(config.paths.public.js))); + }); + + // Images copy + gulp.task('pl:cp:img', function(){ + return gulp.src( + [ '**/*.gif', '**/*.png', '**/*.jpg', '**/*.jpeg' ], + {cwd: path.resolve(config.paths.source.images)} ) + .pipe(gulp.dest(path.resolve(config.paths.public.images))); + }); + + // Fonts copy + gulp.task('pl:cp:font', function(){ + return gulp.src('*', {cwd: path.resolve(config.paths.source.fonts)}) + .pipe(gulp.dest(path.resolve(config.paths.public.images))); + }); + + // Data copy + gulp.task('pl:cp:data', function(){ + return gulp.src('annotations.js', {cwd: path.resolve(config.paths.source.data)}) + .pipe(gulp.dest(path.resolve(config.paths.public.data))); + }); + + // CSS Copy + gulp.task('pl:cp:css', function(){ + return gulp.src(path.resolve(config.paths.source.css, 'style.css')) + .pipe(gulp.dest(path.resolve(config.paths.public.css))) + .pipe(browserSync.stream()); + }); + + // Styleguide Copy + gulp.task('pl:cp:styleguide', function(){ + return gulp.src( + [ '**/*'], + {cwd: path.resolve(config.paths.source.styleguide)} ) + .pipe(gulp.dest(path.resolve(config.paths.public.styleguide))) + .pipe(browserSync.stream()); + }); + + //server and watch tasks + gulp.task('pl:connect', ['pl:lab'], function(){ + browserSync.init({ + server: { + baseDir: path.resolve(config.paths.public.root) + } + }); + gulp.watch(path.resolve(config.paths.source.css, '**/*.css'), ['pl:cp:css']); + + gulp.watch(path.resolve(config.paths.source.styleguide, '**/*.*'), ['pl:cp:styleguide']); + + gulp.watch( + [ + path.resolve(config.paths.source.patterns, '**/*.mustache'), + path.resolve(config.paths.source.patterns, '**/*.json'), + path.resolve(config.paths.source.data, '*.json'), + path.resolve(config.paths.source.fonts + '/*'), + path.resolve(config.paths.source.images + '/*'), + path.resolve(config.paths.source.data + '*.json') + ], + ['pl:lab-pipe'], + function () { browserSync.reload(); } + ); + + }); + + gulp.task('pl:lab-pipe', ['pl:lab'], function(cb){ + cb(); + browserSync.reload(); + }); + + gulp.task('pl:assets', ['pl:cp:js', 'pl:cp:img', 'pl:cp:font', 'pl:cp:data', 'pl:cp:css', 'pl:cp:styleguide' ]); + gulp.task('pl:prelab', ['pl:clean', 'pl:assets']); + gulp.task('pl:lab', ['pl:prelab', 'patternlab'], function(cb){cb();}); + gulp.task('pl:patterns', ['patternlab:only_patterns']); + gulp.task('pl:serve', ['pl:lab', 'pl:connect']); +}; \ No newline at end of file diff --git a/builder/gulp-core.js b/builder/gulp-core.js new file mode 100644 index 000000000..f76047595 --- /dev/null +++ b/builder/gulp-core.js @@ -0,0 +1,41 @@ +/* + * patternlab-node - v1.1.0 - 2016 + * + * Brian Muenzenmeyer, and the web community. + * Licensed under the MIT license. + * + * Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice. + * + */ + +// IMPORTANT: Remember that `./` matches the root of the gulp file that requires this one! +// However, this does not apply to the `require('...')` +module.exports = function(gulp, config) { + var patternlab = require('./patternlab.js')(config), + del = require('del'), + path = require('path'); + + //clean patterns dir + gulp.task('pl:clean', function(cb) { + del.sync([path.resolve(config.paths.public.patterns, '*')], {force: true}); + cb(); + }); + + gulp.task('patternlab', ['pl:clean'], function(cb) { + patternlab.build(false); + cb(); + }); + + gulp.task('patternlab:v', function() { + patternlab.version(); + }); + + gulp.task('patternlab:only_patterns', ['pl:clean'], function(cb) { + patternlab.build_patterns_only(false); + cb(); + }); + + gulp.task('patternlab:help', function() { + patternlab.help(); + }); +}; \ No newline at end of file diff --git a/builder/gulp-extra.js b/builder/gulp-extra.js new file mode 100644 index 000000000..aaf93a8f4 --- /dev/null +++ b/builder/gulp-extra.js @@ -0,0 +1,38 @@ +/* + * patternlab-node - v1.1.0 - 2016 + * + * Brian Muenzenmeyer, and the web community. + * Licensed under the MIT license. + * + * Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice. + * + */ + +// IMPORTANT: Remember that `./` matches the root of the gulp file that requires this one! +// However, this does not apply to the `require('...')` +module.exports = function(gulp, config) { + var pkg = require('./../package.json'), + eol = require('os').EOL, + strip_banner = require('gulp-strip-banner'), + header = require('gulp-header'); + + var banner = [ '/* ', + ' * <%= pkg.name %> - v<%= pkg.version %> - <%= today %>', + ' * ', + ' * <%= pkg.author %>, and the web community.', + ' * Licensed under the <%= pkg.license %> license.', + ' * ', + ' * Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.', + ' * ', ' */', '', ''].join(eol); + + //build the banner + gulp.task('pl:banner', function(){ + return gulp.src(['./builder/*.js']) + .pipe(strip_banner()) + .pipe(header(banner, { + pkg : pkg, + today : new Date().getFullYear() } + )) + .pipe(gulp.dest('./builder')); + }); +}; \ No newline at end of file diff --git a/builder/patternlab_grunt.js b/builder/patternlab_grunt.js deleted file mode 100644 index 5d1f1c6bb..000000000 --- a/builder/patternlab_grunt.js +++ /dev/null @@ -1,40 +0,0 @@ -/* - * patternlab-node - v1.1.0 - 2016 - * - * Brian Muenzenmeyer, and the web community. - * Licensed under the MIT license. - * - * Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice. - * - */ - -var patternlab_engine = require('./patternlab.js'); - -module.exports = function(grunt) { - grunt.registerTask('patternlab', 'create design systems with atomic design', function(arg) { - - var patternlab = patternlab_engine(); - - if(arguments.length === 0){ - patternlab.build(true); - } - - if(arg && arg === 'v'){ - patternlab.version(); - } - - if(arg && arg === "only_patterns"){ - patternlab.build_patterns_only(true); - } - - if(arg && arg === "help"){ - patternlab.help(); - } - - if(arg && (arg !== "v" && arg !=="only_patterns" && arg !=="help")){ - patternlab.help(); - } - - }); - -}; diff --git a/builder/patternlab_gulp.js b/builder/patternlab_gulp.js deleted file mode 100644 index 71789185f..000000000 --- a/builder/patternlab_gulp.js +++ /dev/null @@ -1,36 +0,0 @@ -/* - * patternlab-node - v1.1.0 - 2016 - * - * Brian Muenzenmeyer, and the web community. - * Licensed under the MIT license. - * - * Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice. - * - */ - -var patternlab_engine = require('./patternlab.js'); - -module.exports = function(gulp) { - - gulp.task('patternlab', ['clean'], function(cb){ - var patternlab = patternlab_engine(); - patternlab.build(false); - cb(); - }); - - gulp.task('patternlab:version', function(){ - var patternlab = patternlab_engine(); - patternlab.version(); - }); - - gulp.task('patternlab:only_patterns', ['clean'], function(){ - var patternlab = patternlab_engine(); - patternlab.build_patterns_only(false); - }); - - gulp.task('patternlab:help', function(){ - var patternlab = patternlab_engine(); - patternlab.help(); - }); - -}; diff --git a/gulpfile.js b/gulpfile.js index f8ad52f35..32bc28a46 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,153 +1,9 @@ -// Special thanks to oscar-g (https://github.com/oscar-g) for starting this at https://github.com/oscar-g/patternlab-node/tree/dev-gulp +var gulp = require('gulp'), + config = require('./config.json'); -var pkg = require('./package.json'), - gulp = require('gulp'), - path = require('path'), - eol = require('os').EOL, - del = require('del'), - strip_banner = require('gulp-strip-banner'), - header = require('gulp-header'), - nodeunit = require('gulp-nodeunit'), - browserSync = require('browser-sync').create(); +// Load gulp-build tasks to the current gulp and inject the local configuration +require('./builder/gulp-build')(gulp, config); +// Load gulp-extra tasks to the current gulp and inject the local configuration +require('./builder/gulp-extra')(gulp, config); -require('gulp-load')(gulp); -var banner = [ '/** ', - ' * <%= pkg.name %> - v<%= pkg.version %> - <%= today %>', - ' * ', - ' * <%= pkg.author %>, and the web community.', - ' * Licensed under the <%= pkg.license %> license.', - ' * ', - ' * Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.', - ' * ', ' **/'].join(eol); - -function paths () { - return require('./config.json').paths; -} - -//load patternlab-node tasks -gulp.loadTasks(__dirname+'/builder/patternlab_gulp.js'); - -//clean patterns dir -gulp.task('clean', function(cb){ - del.sync([path.resolve(paths().public.patterns, '*')], {force: true}); - cb(); -}); - -//build the banner -gulp.task('banner', function(){ - return gulp.src([ - './builder/patternlab.js', - './builder/object_factory.js', - './builder/lineage_hunter.js', - './builder/media_hunter.js', - './builder/patternlab_grunt.js', - './builder/patternlab_gulp.js', - './builder/parameter_hunter.js', - './builder/pattern_exporter.js', - './builder/pattern_assembler.js', - './builder/pseudopattern_hunter.js', - './builder/list_item_hunter.js', - './builder/style_modifier_hunter.js' - ]) - .pipe(strip_banner()) - .pipe(header( banner, { - pkg : pkg, - today : new Date().getFullYear() } - )) - .pipe(gulp.dest('./builder')); -}); - - -// COPY TASKS - -// JS copy -gulp.task('cp:js', function(){ - return gulp.src('**/*.js', {cwd: path.resolve(paths().source.js)} ) - .pipe(gulp.dest(path.resolve(paths().public.js))); -}); - -// Images copy -gulp.task('cp:img', function(){ - return gulp.src( - [ '**/*.gif', '**/*.png', '**/*.jpg', '**/*.jpeg' ], - {cwd: path.resolve(paths().source.images)} ) - .pipe(gulp.dest(path.resolve(paths().public.images))); -}); - -// Fonts copy -gulp.task('cp:font', function(){ - return gulp.src('*', {cwd: path.resolve(paths().source.fonts)}) - .pipe(gulp.dest(path.resolve(paths().public.images))); -}); - -// Data copy -gulp.task('cp:data', function(){ - return gulp.src('annotations.js', {cwd: path.resolve(paths().source.data)}) - .pipe(gulp.dest(path.resolve(paths().public.data))); -}); - -// CSS Copy -gulp.task('cp:css', function(){ - return gulp.src(path.resolve(paths().source.css, 'style.css')) - .pipe(gulp.dest(path.resolve(paths().public.css))) - .pipe(browserSync.stream()); -}); - -// Styleguide Copy -gulp.task('cp:styleguide', function(){ - return gulp.src( - [ '**/*'], - {cwd: path.resolve(paths().source.styleguide)} ) - .pipe(gulp.dest(path.resolve(paths().public.styleguide))) - .pipe(browserSync.stream());; -}); - -//server and watch tasks -gulp.task('connect', ['lab'], function(){ - browserSync.init({ - server: { - baseDir: path.resolve(paths().public.root) - } - }); - gulp.watch(path.resolve(paths().source.css, '**/*.css'), ['cp:css']); - - gulp.watch(path.resolve(paths().source.styleguide, '**/*.*'), ['cp:styleguide']); - - gulp.watch( - [ - path.resolve(paths().source.patterns, '**/*.mustache'), - path.resolve(paths().source.patterns, '**/*.json'), - path.resolve(paths().source.data, '*.json'), - path.resolve(paths().source.fonts + '/*'), - path.resolve(paths().source.images + '/*'), - path.resolve(paths().source.data + '*.json'), - ], - ['lab-pipe'], - function () { browserSync.reload(); } - ); - -}); - -//unit test -gulp.task('nodeunit', function(){ - return gulp.src('./test/**/*_tests.js') - .pipe(nodeunit()); -}); - - -gulp.task('lab-pipe', ['lab'], function(cb){ - cb(); - browserSync.reload(); -}); - -gulp.task('default', ['lab']); - -gulp.task('assets', ['cp:js', 'cp:img', 'cp:font', 'cp:data', 'cp:css', 'cp:styleguide' ]); -gulp.task('prelab', ['clean', 'assets']); -gulp.task('lab', ['prelab', 'patternlab'], function(cb){cb();}); -gulp.task('patterns', ['patternlab:only_patterns']); -gulp.task('serve', ['lab', 'connect']); -gulp.task('travis', ['lab', 'nodeunit']); - -gulp.task('version', ['patternlab:version']); -gulp.task('help', ['patternlab:help']); +gulp.task('default', ['pl:lab']); \ No newline at end of file diff --git a/package.gulp.json b/package.gulp.json deleted file mode 100644 index fb73bd7c7..000000000 --- a/package.gulp.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "name": "patternlab-node", - "description": "Pattern Lab is a collection of tools to help you create atomic design systems. This is the node command line interface (CLI).", - "version": "1.1.0", - "main": "./builder/patternlab.js", - "dependencies": { - "del": "^2.2.0", - "diveSync": "^0.3.0", - "fs-extra": "^0.26.5", - "glob": "^6.0.4", - "html-entities": "^1.2.0", - "mustache": "^2.2.1" - }, - "devDependencies": { - "browser-sync": "^2.11.1", - "gulp": "^3.9.0", - "gulp-connect": "^2.3.1", - "gulp-copy": "0.0.2", - "gulp-header": "^1.7.1", - "gulp-load": "^0.1.1", - "gulp-nodeunit": "0.0.5", - "gulp-strip-banner": "0.0.2" - }, - "keywords": [ - "Pattern Lab", - "Atomic Web Design", - "Node", - "Grunt", - "Gulp", - "Javascript" - ], - "repository": { - "type": "git", - "url": "git://github.com/pattern-lab/patternlab-node.git" - }, - "bugs": "https://github.com/pattern-lab/patternlab-node/issues", - "author": "Brian Muenzenmeyer", - "license": "MIT", - "scripts": { - "test": "grunt travis --verbose" - }, - "engines": { - "node": ">=0.1" - } -} diff --git a/package.json b/package.json index 24043cfb5..20b6cbbb7 100644 --- a/package.json +++ b/package.json @@ -9,16 +9,24 @@ "glob": "^6.0.1", "html-entities": "^1.2.0", "matchdep": "^1.0.0", - "mustache": "^2.2.0" + "mustache": "^2.2.1", + "del": "^2.2.0" }, "devDependencies": { + "browser-sync": "^2.11.1", "bs-html-injector": "^3.0.0", "grunt": "~0.4.5", - "grunt-contrib-concat": "^0.5.1", "grunt-browser-sync": "^2.2.0", + "grunt-contrib-concat": "^0.5.1", "grunt-contrib-copy": "^0.8.2", - "grunt-contrib-nodeunit": "^0.4.1", - "grunt-contrib-watch": "^0.6.1" + "grunt-contrib-watch": "^0.6.1", + "gulp": "^3.9.0", + "gulp-connect": "^2.3.1", + "gulp-copy": "0.0.2", + "gulp-header": "^1.7.1", + "gulp-load": "^0.1.1", + "gulp-strip-banner": "0.0.2", + "nodeunit": "^0.9.1" }, "keywords": [ "Pattern Lab", @@ -36,7 +44,7 @@ "author": "Brian Muenzenmeyer", "license": "MIT", "scripts": { - "test": "grunt travis --verbose" + "test": "node_modules/nodeunit/bin/nodeunit test" }, "engines": { "node": ">=0.1"