forked from auth0-extensions/auth0-account-link-extension
-
Notifications
You must be signed in to change notification settings - Fork 6
/
gulpfile.js
58 lines (53 loc) · 1.54 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
const gulp = require('gulp');
const util = require('gulp-util');
const ngrok = require('ngrok');
const nodemon = require('gulp-nodemon');
const { install } = require('./modifyRule');
const managementAdapter = require('./lib/managementAdapter');
const { ManagementClientAdapter, getCurrentConfig } = managementAdapter;
gulp.task('run', () => {
ngrok.connect(3000, (ngrokError, url) => {
if (ngrokError) {
throw ngrokError;
}
nodemon({
script: './index.js',
ext: 'js json',
env: {
EXTENSION_SECRET: 'a-random-secret',
AUTH0_RTA: 'https://auth0.auth0.com',
NODE_ENV: 'development',
WT_URL: url,
PUBLIC_WT_URL: url
},
ignore: [
'assets/app/',
'build/webpack',
'server/data.json',
'client/',
'tests/',
'node_modules/'
]
});
setTimeout(() => {
const publicUrl = `${url.replace('https://', 'http://')}`;
util.log('Public Url:', publicUrl);
util.log('Patching rule on tenant.');
getCurrentConfig().then((config) => {
const adapter = new ManagementClientAdapter(config);
install(adapter, {
extensionURL: publicUrl,
username: 'Development',
clientID: config.AUTH0_CLIENT_ID,
clientSecret: config.AUTH0_CLIENT_SECRET
})
.then(() => {
util.log('Rule patched on tenant.');
})
.catch((error) => {
util.log("Couldn't patch rule in tenant:", error);
});
});
}, 4000);
});
});