@platformatic/runtime 0.41.1 → 0.41.3

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.
@@ -0,0 +1,12 @@
1
+ {
2
+ "$schema": "https://platformatic.dev/schemas/v0.35.0/runtime",
3
+ "entrypoint": "service1",
4
+ "hotReload": true,
5
+ "services": [
6
+ {
7
+ "id": "service1",
8
+ "path": "../monorepo-watch/service1",
9
+ "config": "platformatic.service.json"
10
+ }
11
+ ]
12
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "$schema": "https://platformatic.dev/schemas/v0.20.0/service",
3
+ "server": {
4
+ "hostname": "127.0.0.1",
5
+ "port": 0
6
+ },
7
+ "plugins": {
8
+ "paths": [
9
+ "plugin.js"
10
+ ]
11
+ },
12
+ "watch": false
13
+ }
@@ -0,0 +1,8 @@
1
+ 'use strict'
2
+
3
+ /** @param {import('fastify').FastifyInstance} app */
4
+ module.exports = async function (app) {
5
+ app.get('/', async () => {
6
+ return { hello: 'world' }
7
+ })
8
+ }
package/lib/app.js CHANGED
@@ -85,7 +85,7 @@ class PlatformaticApp {
85
85
 
86
86
  await this.#initializeConfig()
87
87
  this.#originalWatch = this.config.configManager.current.watch
88
- this.config.configManager.current.watch = false
88
+ this.config.configManager.current.watch = { enabled: false }
89
89
 
90
90
  const { configManager } = this.config
91
91
  configManager.update({
@@ -108,7 +108,10 @@ class PlatformaticApp {
108
108
  this.#logAndExit(err)
109
109
  }
110
110
 
111
- if (config.plugins !== undefined) {
111
+ if (
112
+ config.plugins !== undefined &&
113
+ this.#originalWatch?.enabled !== false
114
+ ) {
112
115
  this.#startFileWatching()
113
116
  }
114
117
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/runtime",
3
- "version": "0.41.1",
3
+ "version": "0.41.3",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -24,8 +24,8 @@
24
24
  "standard": "^17.1.0",
25
25
  "tsd": "^0.29.0",
26
26
  "typescript": "^5.1.6",
27
- "@platformatic/sql-graphql": "0.41.1",
28
- "@platformatic/sql-mapper": "0.41.1"
27
+ "@platformatic/sql-graphql": "0.41.3",
28
+ "@platformatic/sql-mapper": "0.41.3"
29
29
  },
30
30
  "dependencies": {
31
31
  "@hapi/topo": "^6.0.2",
@@ -42,12 +42,12 @@
42
42
  "pino": "^8.14.1",
43
43
  "pino-pretty": "^10.0.0",
44
44
  "undici": "^5.22.1",
45
- "@platformatic/composer": "0.41.1",
46
- "@platformatic/config": "0.41.1",
47
- "@platformatic/db": "0.41.1",
48
- "@platformatic/service": "0.41.1",
49
- "@platformatic/telemetry": "0.41.1",
50
- "@platformatic/utils": "0.41.1"
45
+ "@platformatic/composer": "0.41.3",
46
+ "@platformatic/config": "0.41.3",
47
+ "@platformatic/db": "0.41.3",
48
+ "@platformatic/service": "0.41.3",
49
+ "@platformatic/telemetry": "0.41.3",
50
+ "@platformatic/utils": "0.41.3"
51
51
  },
52
52
  "standard": {
53
53
  "ignore": [
package/test/api.test.js CHANGED
@@ -61,7 +61,9 @@ test('should get service config', async (t) => {
61
61
  join(fixturesDir, 'monorepo', 'serviceAppWithLogger', 'plugin.js')
62
62
  ]
63
63
  },
64
- watch: false
64
+ watch: {
65
+ enabled: false
66
+ }
65
67
  })
66
68
  })
67
69
 
@@ -282,3 +282,28 @@ test('watches CommonJS files with hotreload on a single service', { timeout: 300
282
282
 
283
283
  assert.ok(restartedThirdTime)
284
284
  })
285
+
286
+ test('should not watch files if watch = false', async (t) => {
287
+ const tmpDir = await mkdtemp(join(base, 'watch-'))
288
+ t.after(() => saferm(tmpDir))
289
+ t.diagnostic(`using ${tmpDir}`)
290
+ const configFileSrc = join(fixturesDir, 'configs', 'monorepo-watch.json')
291
+ const configFileDst = join(tmpDir, 'configs', 'monorepo-watch.json')
292
+ const appSrc = join(fixturesDir, 'monorepo-watch')
293
+ const appDst = join(tmpDir, 'monorepo-watch')
294
+ const cjsPluginFilePath = join(appDst, 'service1', 'plugin.js')
295
+
296
+ await Promise.all([
297
+ cp(configFileSrc, configFileDst),
298
+ cp(appSrc, appDst, { recursive: true })
299
+ ])
300
+
301
+ await writeFile(cjsPluginFilePath, createCjsLoggingPlugin('v1', false))
302
+ const { child, url } = await start('-c', configFileDst)
303
+ t.after(() => child.kill('SIGINT'))
304
+ await writeFile(cjsPluginFilePath, createCjsLoggingPlugin('v2', true))
305
+ await sleep(5000)
306
+ const res = await request(`${url}/version`)
307
+ const version = await res.body.text()
308
+ assert.strictEqual(version, 'v1')
309
+ })