@wix/origami-site-express 0.1.6 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { sendAndExit } from '@wix/origami-bi'
|
|
2
3
|
import * as commands from '../src/index.js'
|
|
3
4
|
|
|
4
5
|
const [command] = process.argv.slice(2)
|
|
5
6
|
if (!Object.hasOwn(commands, command)) {
|
|
6
7
|
console.error(`Usage: origami-site-express <${Object.keys(commands).join(' | ')}>`)
|
|
7
|
-
|
|
8
|
+
await sendAndExit(1)
|
|
8
9
|
}
|
|
9
10
|
try {
|
|
10
11
|
await commands[command]({ root: process.cwd() })
|
|
11
12
|
} catch (error) {
|
|
12
13
|
console.error(error instanceof Error ? error.stack ?? error.message : error)
|
|
13
|
-
|
|
14
|
+
await sendAndExit(1)
|
|
14
15
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/origami-site-express",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Run an exported Wix origami site on Node with Express and Vite.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -27,20 +27,22 @@
|
|
|
27
27
|
"scripts": {
|
|
28
28
|
"build": "tsc --noEmit",
|
|
29
29
|
"lint": "oxlint .",
|
|
30
|
-
"test": "node --test test/*.spec.js"
|
|
30
|
+
"test": "node --test test/*.spec.js",
|
|
31
|
+
"typecheck": "tsc --noEmit"
|
|
31
32
|
},
|
|
32
33
|
"dependencies": {
|
|
33
34
|
"@vitejs/plugin-react": "^6.1.1",
|
|
34
35
|
"express": "^5.2.1",
|
|
35
|
-
"vite": "^8.1.0"
|
|
36
|
+
"vite": "^8.1.0",
|
|
37
|
+
"@wix/origami-bi": "0.4.0"
|
|
36
38
|
},
|
|
37
39
|
"peerDependencies": {
|
|
38
|
-
"@wix/origami-site": "^
|
|
40
|
+
"@wix/origami-site": "^1.0.0"
|
|
39
41
|
},
|
|
40
42
|
"devDependencies": {
|
|
41
43
|
"@types/express": "^5.0.0",
|
|
42
44
|
"@types/node": "^22.0.0",
|
|
43
|
-
"@wix/origami-site": "
|
|
45
|
+
"@wix/origami-site": "1.0.0",
|
|
44
46
|
"typescript": "^6.0.3"
|
|
45
47
|
},
|
|
46
48
|
"publishUnscoped": false,
|
|
@@ -65,5 +67,5 @@
|
|
|
65
67
|
]
|
|
66
68
|
}
|
|
67
69
|
},
|
|
68
|
-
"falconPackageHash": "
|
|
70
|
+
"falconPackageHash": "da38d260c5089baab7ab838871669465455cd38eaa906f7c44d68552"
|
|
69
71
|
}
|
package/src/server/lifecycle.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { currentRow, sendAndExit } from '@wix/origami-bi'
|
|
1
2
|
/** Listens, prints the one ready line, and shuts down on SIGTERM/SIGINT. No host means every interface.
|
|
2
3
|
* @param {import('node:http').Server} server @param {{ port: number, host?: string | undefined, onClose: () => Promise<unknown> }} options */
|
|
3
4
|
export async function serve(server, { port, host, onClose }) {
|
|
@@ -7,8 +8,10 @@ export async function serve(server, { port, host, onClose }) {
|
|
|
7
8
|
const shown = !host || address.address === '::' || address.address === '0.0.0.0' ? 'localhost'
|
|
8
9
|
: address.family === 'IPv6' ? `[${address.address}]` : address.address
|
|
9
10
|
console.log(`origami-site-express ready http://${shown}:${address.port}`)
|
|
11
|
+
const run = currentRow()?.run
|
|
10
12
|
let stopping = false
|
|
11
|
-
|
|
13
|
+
/** @param {'SIGINT' | 'SIGTERM' | 'SIGHUP'} signal */
|
|
14
|
+
const stop = async (signal) => {
|
|
12
15
|
if (stopping) return
|
|
13
16
|
stopping = true
|
|
14
17
|
const closed = new Promise(resolve => server.close(resolve))
|
|
@@ -17,8 +20,10 @@ export async function serve(server, { port, host, onClose }) {
|
|
|
17
20
|
try { await onClose() } catch (error) { console.error('[origami]', error) }
|
|
18
21
|
await closed
|
|
19
22
|
clearTimeout(force)
|
|
20
|
-
|
|
23
|
+
run?.closeAllRows(signal)
|
|
24
|
+
await sendAndExit(0, run ? { run } : {})
|
|
21
25
|
}
|
|
22
|
-
process.once('SIGTERM', stop)
|
|
23
|
-
process.once('SIGINT', stop)
|
|
26
|
+
process.once('SIGTERM', () => stop('SIGTERM'))
|
|
27
|
+
process.once('SIGINT', () => stop('SIGINT'))
|
|
28
|
+
process.once('SIGHUP', () => stop('SIGHUP'))
|
|
24
29
|
}
|