-
Notifications
You must be signed in to change notification settings - Fork 0
/
Assemblefile.js
103 lines (90 loc) · 3.41 KB
/
Assemblefile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
'use strict';
// Connected to globbing patterns
function extend(a, b) {
for (var key in b) {
if (b.hasOwnProperty(key)) {
a[key] = b[key];
}
}
return a;
}
var assemble = require('assemble'),
typogr = require('gulp-typogr'),
gp = require('gulp-load-plugins')(),
// sitemap = require('gulp-sitemap'),
// inlineCss = require('gulp-inline-css'),
// pleeease = require('gulp-pleeease'),
extname = require('gulp-extname'),
git = require('gulp-git'),
bump = require('gulp-bump'),
filter = require('gulp-filter'),
tagVersion = require('gulp-tag-version'),
permalinks = require('./lib/permalinks'),
browserSync = require('browser-sync'),
reload = browserSync.reload,
config = require('./config'),
buildDir = config.pkg.config.buildDir,
system = config.site.assemble.system,
content = config.site.assemble.content,
// [fix] - Replace once the globbing pattern works
// helpers = system.helpers + '/{,*/}helper-**.js',
path = require('path'),
glob = require('glob'),
helperFiles = glob.sync(system.root + '/' + system.helpers + '/{,*/}helper-**.js'),
helpers = helperFiles.reduce(function (acc, fp) {
return extend(acc, require(path.resolve(fp)));
}, {});
// Load system - These three should be broken out and put in assemble-system
assemble.layouts(system.root + '/' + system.layouts + '/**.hbs');
assemble.helpers(helpers);
assemble.helper('moment', require('helper-moment'));
assemble.partials(system.root + '/' + system.partials + '/**/**.hbs');
assemble.data(system.root + '/data/**/*.{yaml,json}');
assemble.option(config.site.assemble.options);
assemble.option('site', config.site.site);
assemble.option('env', config.env);
assemble.option('media', config.media);
assemble.task('pages', ['jshint'], function () {
var baseContentDir = content.root + '/pages';
assemble.src(baseContentDir + '/**/*.md')
.pipe(typogr())
.pipe(extname())
.pipe(permalinks())
.pipe(assemble.dest('.tmp'));
});
assemble.task('resources', function () {
assemble.copy('resources/**/*', buildDir);
});
function bumpAndTag(importance) {
// get all the files to bump version in
return assemble.src(['./package.json'], {layout: null})
// bump the version number in those files
.pipe(bump({type: importance}))
// save it back to filesystem
.pipe(assemble.dest('./'))
// commit the changed version number
.pipe(git.commit('Bump site version'))
// read only one file to get the version number
.pipe(filter('package.json'))
// **tag it in the repository**
.pipe(tagVersion());
}
assemble.task('patch', function () { return bumpAndTag('patch'); });
assemble.task('feature', function () { return bumpAndTag('minor'); });
assemble.task('release', function () { return bumpAndTag('major'); });
assemble.task('clean', require('del').bind(null, ['.tmp', buildDir]));
assemble.task('jshint', function () {
return assemble.src(
[
'assets/scripts/**/*.js',
'*.js',
'templates/helpers/**/*.js'
]
)
.pipe(reload({stream: true, once: true}))
.pipe(gp.jshint())
.pipe(gp.jshint.reporter('jshint-stylish'))
.pipe(gp.if(! browserSync.active, gp.jshint.reporter('fail')));
});
assemble.task('assets', ['jshint']);
assemble.task('default', ['pages', 'assets', 'resources']);