-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
115 lines (96 loc) · 2.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
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
/* eslint camelcase: "warn" */
const {promisify} = require('util');
let {pipeline} = require('stream');
const {ManagementClient} = require('auth0');
const {series, src, dest} = require('gulp');
const del = require('del');
const responsive = require('gulp-responsive');
pipeline = promisify(pipeline);
const x1 = {suffix: '@1x'};
const x2 = {suffix: '@2x'};
const mobileImageWidth = 512;
const tabletImageWidth = 768;
const desktopImageWidth = 1024;
const mobile = {
width: mobileImageWidth,
rename: (rename) => rename
};
const tablet = {
width: tabletImageWidth,
rename: ({suffix, ...rest}) => ({
suffix: `-medium${suffix}`,
...rest
})
};
const desktop = {
width: desktopImageWidth,
rename: ({suffix, ...rest}) => ({
suffix: `-wide${suffix}`,
...rest
})
};
const portrait = ({width, ...rest}) => ({
...rest,
width,
height: width * (16 / 9)
});
const landscape = ({width, ...rest}) => ({
...rest,
width,
height: width * (9 / 16)
});
const regular = ({rename, ...rest}) => ({
...rest,
rename: rename(x1)
});
const retina = ({rename, width, height, ...rest}) => ({
...rest,
width: width * 2,
height: height ? height * 2 : height,
quality: 40,
rename: rename(x2)
});
const grayscale = (rest) => ({
...rest,
grayscale: true
});
const banners = [
grayscale(regular(portrait(mobile))),
grayscale(retina(portrait(mobile))),
grayscale(regular(landscape(tablet))),
grayscale(retina(landscape(tablet))),
grayscale(regular(landscape(desktop))),
grayscale(retina(landscape(desktop)))
];
function images() {
return pipeline(
src('./assets/**/*.jpg'),
responsive({
'banners/brown-book-page.jpg': banners,
'banners/brown-wooden-church-bench.jpg': banners,
'banners/brown-wooden-church-pew.jpg': banners,
'banners/church-under-blue-sky.jpg': banners
}),
dest('static')
);
}
function cleanImages() {
return del('static/banners');
}
const management = new ManagementClient({
domain: process.env.AUTH0_ISSUER_BASE_URL,
clientId: process.env.AUTH0_CLIENT_ID,
clientSecret: process.env.AUTH0_CLIENT_SECRET,
scope: 'read:users update:users update:users_app_metadata'
});
async function updateUser() {
await management.updateUser(
{id: 'auth0|ID'},
{
given_name: '',
family_name: ''
}
);
}
exports.images = series(cleanImages, images);
exports.updateUser = updateUser;