-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
assemblefile.js
174 lines (143 loc) · 4.65 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
'use strict';
var utils = require('./lib/utils');
module.exports = function(app) {
var browserSync = utils.browserSync.create();
app.use(utils.questions());
app.use(utils.watch());
app.option('layout', 'default');
app.helper('json', require('./lib/helpers/json'));
var cwd = utils.memo(process.cwd())
var paths = {
src: cwd('src'),
dest: cwd('_gh_pages')
};
paths.data = paths.src('data');
paths.templates = paths.src('templates');
app.task('default', ['clean', 'copy', 'less', 'build']);
app.task('dev', app.series('default', app.parallel(['serve', 'watch'])));
app.task('data', function(cb) {
app.data(paths.data('*.json').path);
cb();
});
app.task('load', ['data'], function(cb) {
app.layouts(paths.templates('layouts/*.hbs').path);
app.partials(paths.templates('partials/*.hbs').path);
app.pages(paths.templates('pages/*.hbs').path);
cb();
});
app.task('build', ['load', 'warn'], function() {
return app.toStream('pages')
.pipe(app.renderFile())
.pipe(utils.extname())
.pipe(app.dest(paths.dest()))
.pipe(browserSync.stream());
});
app.task('copy', ['copy-*']);
app.task('copy-img', function() {
return app.copy('**/*', paths.dest('img').path, {cwd: paths.src('img').path})
.pipe(browserSync.stream());
});
app.task('copy-js', function() {
return app.copy('**/*', paths.dest('js').path, {cwd: paths.src('js').path})
.pipe(browserSync.stream());
});
app.task('copy-bootstrap', function() {
return app.copy([
'node_modules/bootstrap/dist/**/*',
'!**/npm.js',
'!**/bootstrap-theme.*',
'!**/*.map'
],
paths.dest('vendor/bootstrap').path);
});
app.task('copy-jquery', function() {
return app.copy([
'node_modules/jquery/dist/jquery.js',
'node_modules/jquery/dist/jquery.min.js'
],
paths.dest('vendor/jquery').path);
});
app.task('copy-font-awesome', function() {
return app.copy([
'node_modules/font-awesome/**',
'!node_modules/font-awesome/**/*.map',
'!node_modules/font-awesome/.npmignore',
'!node_modules/font-awesome/*.txt',
'!node_modules/font-awesome/*.md',
'!node_modules/font-awesome/*.json'
],
paths.dest('vendor/font-awesome').path);
});
app.task('clean', function(cb) {
utils.del(paths.dest(), cb);
});
app.task('cleanPublish', function(cb) {
utils.del('./.publish', {force: true}, cb);
});
app.task('less', function() {
return app.src('site.less', {cwd: paths.src('less').path})
.pipe(utils.less())
.pipe(app.dest(paths.dest('css')))
.pipe(browserSync.stream());
});
app.task('push', function() {
return app.src(paths.dest('**/*').path)
.pipe(utils.ghPages());
});
app.task('deploy', app.series(['push', 'cleanPublish']));
app.task('serve', function(cb) {
browserSync.init({
port: 8080,
startPath: 'index.html',
server: {
baseDir: paths.dest()
}
}, cb);
});
app.task('watch', function() {
app.watch([paths.src('**/*').path], ['default']);
});
app.task('warn', function(cb) {
if (typeof app.get('cache.data.site.services.invite') === 'undefined') {
console.log();
console.log('[WARNING]:', 'Run `$ assemble webtask-invite` to create the slack invitation service and add the service url to the site data.');
console.log();
}
if (typeof app.get('cache.data.site.services.users') === 'undefined') {
console.log();
console.log('[WARNING]:', 'Run `$ assemble webtask-users` to create the slack user badge service and add the service url to the site data.');
console.log();
}
cb();
});
app.task('webtasks', ['webtask-*']);
app.task('webtask-invite', ['data'], function(cb) {
taskCreate('Creating slack invite webtask:', app.cache.data.questions.invite, createInvite)(cb);
});
app.task('webtask-users', ['data'], function(cb) {
taskCreate('Creating slack users webtask:', app.cache.data.questions.users, createUsers)(cb);
});
function taskCreate(msg, questions, fn) {
return function(cb) {
console.log();
console.log(msg);
console.log();
var keys = Object.keys(questions);
keys.forEach(function(key) {
app.question(key, questions[key]);
});
app.ask(keys, {save: false}, function(err, answers) {
if(err) return cb(err);
console.log();
answers.datafile = paths.data('site.json').path;
fn(answers, cb);
});
};
}
function createInvite(options, cb) {
utils.create(app, 'invite', {}, options, cb);
}
function createUsers(options, cb) {
utils.create(app, 'users', {}, options, cb);
}
};