-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
51 lines (45 loc) · 1.29 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
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',
'dist',
'html',
'img',
]);
/* 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(), '.dailycal/projects-credentials.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 dailycal-projects:passphrase'),
'to creare a new key set.'
);
gutil.log(e);
// Exit process if keys don't validate
process.exit();
}
gulp.task('default', ['dev']);
gulp.task('render', (cb) => {
runSequence('html', 'img', 'build', cb);
});
gulp.task('preview', (cb) => {
runSequence('render', 'dist', cb);
});
gulp.task('publish', (cb) => {
runSequence('render', 'aws', cb);
});