@wix/origami-site-express 1.0.0 → 1.0.2

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
- process.exit(1)
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
- process.exit(1)
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": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Run an exported Wix origami site on Node with Express and Vite.",
5
5
  "type": "module",
6
6
  "files": [
@@ -27,12 +27,14 @@
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.5.0"
36
38
  },
37
39
  "peerDependencies": {
38
40
  "@wix/origami-site": "^1.0.0"
@@ -65,5 +67,5 @@
65
67
  ]
66
68
  }
67
69
  },
68
- "falconPackageHash": "82d2b0fe1dee3c5c66e610cb98f442e08e7948b8c03158b370cae74e"
70
+ "falconPackageHash": "659aabfadbee36f1cd3556a802ba62429965c23b7ee50cf31c5e18fd"
69
71
  }
@@ -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
- const stop = async () => {
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
- process.exit(0)
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
  }