This repository has been archived by the owner on Aug 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
dev.mjs
69 lines (62 loc) · 1.9 KB
/
dev.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
#!/usr/bin/env zx
import "zx/globals"
import dotenv from "dotenv"
import { expand } from "dotenv-expand"
import { networkInterfaces } from "os"
const azure = process.argv.includes("--azure")
const out = dotenv.config({ path: azure ? "./.env" : "./local.env" })
if (out.error) throw out.error
const port = process.env.PORT || (process.env.PORT = "7071")
const {
CODESPACE_NAME,
GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN,
CODESANDBOX_HOST,
} = process.env
// GitHub codespaces
if (CODESPACE_NAME && GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN) {
process.env.WEBSITE_HOSTNAME = `${CODESPACE_NAME}-${port}.${GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}`
process.env.WEBSITE_PROTOCOL = "https"
console.warn(
`------------------------------------------------------------------`
)
console.warn(
`- MAKE SURE TO CHANGE THE VISIBILITY OF PORT '${port}' TO 'Public'`
)
console.warn(
`------------------------------------------------------------------`
)
}
// Codesandbox
else if (CODESANDBOX_HOST) {
process.env.WEBSITE_HOSTNAME = CODESANDBOX_HOST
process.env.WEBSITE_PROTOCOL = "https"
}
// local dev
else if (!azure) {
const address = (() => {
const nis = networkInterfaces()
for (const interfaceName in nis) {
const interfaceDetails = nis[interfaceName]
if (interfaceDetails) {
for (const detail of interfaceDetails) {
if (!detail.internal && detail.family === "IPv4") {
return detail.address
}
}
}
}
return null
})()
process.env.WEBSITE_HOSTNAME = `${address}:${port}`
}
expand(out)
if (!azure) {
$`yarn azurite`
console.log(
`- Visual Studio Code Extension connection string:
${process.env.DEVS_CONNECTION_STRING}
`
)
console.log(``)
}
import("./dist/src/index.js")