wattpm 2.0.0-alpha.21 → 2.0.0-alpha.22

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.
@@ -3,6 +3,7 @@ import { startCommand as pltStartCommand } from '@platformatic/runtime'
3
3
  import { ensureLoggableError } from '@platformatic/utils'
4
4
  import { bold } from 'colorette'
5
5
  import { spawn } from 'node:child_process'
6
+ import { watch } from 'node:fs/promises'
6
7
  import { resolve } from 'node:path'
7
8
  import { findConfigurationFile, getMatchingRuntimeArgs, parseArgs } from '../utils.js'
8
9
 
@@ -12,7 +13,23 @@ export async function devCommand (logger, args) {
12
13
  const root = resolve(process.cwd(), positionals[0] ?? '')
13
14
 
14
15
  const configurationFile = await findConfigurationFile(logger, root)
15
- await pltStartCommand(['-c', configurationFile], true)
16
+ let runtime = await pltStartCommand(['-c', configurationFile], true, true)
17
+
18
+ // Add a watcher on the configurationFile so that we can eventually restart the runtime
19
+ try {
20
+ const watcher = watch(configurationFile, { persistent: false })
21
+ // eslint-disable-next-line no-unused-vars
22
+ for await (const _ of watcher) {
23
+ runtime.logger.info('The configuration file has changed, reloading the application ...')
24
+ await runtime.close()
25
+ runtime = await pltStartCommand(['-c', configurationFile], true, true)
26
+ }
27
+ } catch (err) {
28
+ if (err.name === 'AbortError') {
29
+ return
30
+ }
31
+ throw err
32
+ }
16
33
  }
17
34
 
18
35
  export async function startCommand (logger, args) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wattpm",
3
- "version": "2.0.0-alpha.21",
3
+ "version": "2.0.0-alpha.22",
4
4
  "description": "The Node.js Application Server",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -34,10 +34,10 @@
34
34
  "pino-pretty": "^11.2.2",
35
35
  "split2": "^4.2.0",
36
36
  "table": "^6.8.2",
37
- "@platformatic/control": "2.0.0-alpha.21",
38
- "@platformatic/utils": "2.0.0-alpha.21",
39
- "@platformatic/runtime": "2.0.0-alpha.21",
40
- "@platformatic/config": "2.0.0-alpha.21"
37
+ "@platformatic/config": "2.0.0-alpha.22",
38
+ "@platformatic/control": "2.0.0-alpha.22",
39
+ "@platformatic/utils": "2.0.0-alpha.22",
40
+ "@platformatic/runtime": "2.0.0-alpha.22"
41
41
  },
42
42
  "devDependencies": {
43
43
  "borp": "^0.17.0",
package/schema.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://schemas.platformatic.dev/wattpm/2.0.0-alpha.21.json",
2
+ "$id": "https://schemas.platformatic.dev/wattpm/2.0.0-alpha.22.json",
3
3
  "$schema": "http://json-schema.org/draft-07/schema#",
4
4
  "type": "object",
5
5
  "properties": {