-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
55 lines (48 loc) · 1.36 KB
/
gulpfile.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
const env = require('gulp-env');
const runSequence = require('run-sequence');
const fs = require('fs-extra');
const os = require('os');
const path = require('path');
const SecureKeys = require('secure-keys');
const gutil = require('gulp-util');
const envFile = require('node-env-file');
const gulp = require('./gulp')([
'aws',
'archie',
'build',
'dev',
'data',
'data-watch',
'dist',
'html',
'img',
'img-watch',
]);
/* Add secure keys to environment */
envFile(path.join(__dirname, '.env'), { overwrite: true }); // Adds PASSPHRASE to env
const secure = new SecureKeys({ secret: process.env.PASSPHRASE });
const keysPath = path.join(os.homedir(), '.maroon/interactives.json');
const keysObj = fs.readJsonSync(keysPath);
try {
env.set(secure.decrypt(keysObj));
} catch (e) {
gutil.log(
gutil.colors.bgRed('PASSPHRASE ERROR:'),
'Could not validate keys. Correct PASSPHRASE in .env or run',
gutil.colors.cyan('yo politico-interactives:passphrase'),
'to creare a new key set.'
);
gutil.log(e);
// Exit process if keys don't validate
process.exit();
}
gulp.task('default', ['dev', 'img-watch', 'data-watch']);
gulp.task('render', (cb) => {
runSequence('html', 'img', 'data', 'build', cb);
});
gulp.task('preview', (cb) => {
runSequence('render', 'dist', cb);
});
gulp.task('publish', (cb) => {
runSequence('render', 'aws', cb);
});