-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathquickstart.mjs
executable file
·96 lines (83 loc) · 2.02 KB
/
quickstart.mjs
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
#!/usr/bin/env node
import semver from 'semver'
import nextConfig from './next.mjs'
import expressConfig from './express.mjs'
import fastifyConfig from './fastify.mjs'
const requiredVersion = '>=18.3.0'
if (!semver.satisfies(process.versions.node, requiredVersion)) {
console.error(`This script requires Node.js version ${requiredVersion}`)
process.exit(1)
}
// following are in Nodejs 18+
import { parseArgs } from 'node:util'
if (!process.stdout.isTTY) {
const error = new Error(
'Not running on interactive terminal. Exiting Hellō Quickstart.',
)
console.error(error)
process.exit(1)
}
let {
values: {
nextjs,
express,
fastify,
provider_hint,
suffix,
wildcard_domain,
integration,
},
} = parseArgs({
options: {
nextjs: {
type: 'boolean',
},
express: {
type: 'boolean',
},
fastify: {
type: 'boolean',
},
provider_hint: {
type: 'string',
short: 'p',
},
suffix: {
type: 'string',
short: 'x',
},
integration: {
type: 'string',
short: 'i',
},
wildcard_domain: {
type: 'boolean',
short: 'w',
},
},
})
import quickstart from './index.js'
import dotenv from 'dotenv'
const options = {}
if (provider_hint) options.provider_hint = provider_hint
if (suffix) options.suffix = suffix
if (integration) options.integration = integration
if (wildcard_domain) options.wildcard_domain = wildcard_domain
;(async () => {
if (nextjs) {
await nextConfig(options)
process.exit(0)
}
if (express) {
await expressConfig(options)
process.exit(0)
}
if (fastify) {
await fastifyConfig(options)
process.exit(0)
}
// direct invocation
dotenv.config() // .env
const client_id = await quickstart(options)
console.log(`client_id=${client_id}`)
})()