-
Notifications
You must be signed in to change notification settings - Fork 20
/
gulpfile.js
49 lines (45 loc) · 1.37 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
const replace = require('gulp-replace')
const { src, dest } = require('gulp')
const keyMap = {
'~~CHANGE_ME_PUBLIC_KEY~~':
'69876357:testpublickey_DEMOPUBLICKEY95me92597fd28tGD4r5',
'~~CHANGE_ME_USER~~': '69876357',
'~~CHANGE_ME_PASSWORD~~': 'testpassword_DEMOPRIVATEKEY23G4475zXZQ2UA5x7M',
'~~CHANGE_ME_ENDPOINT~~': 'https://static.lyra.com',
'~~CHANGE_ME_HMAC_SHA256_KEY~~': '38453613e7f44dc58732bad3dca2bca3',
'~~CHANGE_ME_ENDPOINT_NO_HTTPS~~': 'api.lyra.com'
}
function replaceKeys() {
let stream = src([
'./examples_build/**/*.html',
'./examples_build/**/*.js',
'!./examples_build/**/node_modules/**/*.js'
])
Object.entries(keyMap).forEach(([key, value]) => {
stream = stream.pipe(replace(key, value))
})
return stream.pipe(dest('./examples_build/'))
}
function devReplaceKeys() {
let reverse
if (~process.argv.indexOf('--restore')) {
reverse = true
}
let stream = src(
[
'./examples/**/*.html',
'./examples/**/*.js',
'./examples/**/*.ts',
'./examples/**/*.vue',
'./examples/**/*.svelte',
'!./examples/**/node_modules/**'
],
{ base: './' }
)
Object.entries(keyMap).forEach(([key, value]) => {
stream = stream.pipe(reverse ? replace(value, key) : replace(key, value))
})
return stream.pipe(dest('./'))
}
exports.replaceKeys = replaceKeys
exports.devReplaceKeys = devReplaceKeys