/
run.js
98 lines (89 loc) · 2.19 KB
/
run.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
import {
defaultResolveConfig,
build,
start,
watch,
runTestcafe,
merge
} from 'resolve-scripts'
import createAuthModule from 'resolve-module-auth'
import devConfig from './config.dev'
import cloudConfig from './config.cloud'
import prodConfig from './config.prod'
import testFunctionalConfig from './config.test_functional'
import adjustWebpackConfigs from './config.adjust_webpack'
import appConfig from './config.app'
const launchMode = process.argv[2]
void (async () => {
const authModule = createAuthModule([
{
name: 'local-strategy',
createStrategy: 'domain/auth/create_strategy.js',
logoutRoute: {
path: 'auth/local/logout',
method: 'GET'
},
routes: [
{
path: 'auth/local/register',
method: 'POST',
callback: 'domain/auth/route_register_callback.js'
},
{
path: 'auth/local/login',
method: 'POST',
callback: 'domain/auth/route_login_callback.js'
}
]
}
])
switch (launchMode) {
case 'dev': {
await watch(
merge(defaultResolveConfig, appConfig, devConfig, authModule),
adjustWebpackConfigs.bind(null, devConfig)
)
break
}
case 'build': {
await build(
merge(defaultResolveConfig, appConfig, prodConfig, authModule),
adjustWebpackConfigs.bind(null, prodConfig)
)
break
}
case 'cloud': {
await build(
merge(defaultResolveConfig, appConfig, cloudConfig, authModule),
adjustWebpackConfigs.bind(null, authModule)
)
break
}
case 'start': {
await start(
merge(defaultResolveConfig, appConfig, prodConfig, authModule)
)
break
}
case 'test:functional': {
await runTestcafe({
resolveConfig: merge(
defaultResolveConfig,
appConfig,
testFunctionalConfig,
authModule
),
functionalTestsDir: 'test/functional',
browser: process.argv[3]
})
break
}
default: {
throw new Error('Unknown option')
}
}
})().catch(error => {
// eslint-disable-next-line no-console
console.log(error)
process.exit(1)
})