@platformatic/watt-extra 1.14.3 → 1.14.4

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.
package/lib/watt.js CHANGED
@@ -162,8 +162,10 @@ class Watt {
162
162
 
163
163
  const runtime = await create(this.#appDir, null, {
164
164
  isProduction: true,
165
- transform: async (config) => {
166
- config = await transform(config)
165
+ transform: async (config, schema, options) => {
166
+ // Forward schema and options: the runtime's transform reads isProduction
167
+ // from options, and defaults watch to !isProduction when it is missing.
168
+ config = await transform(config, schema, options)
167
169
 
168
170
  this.#config = config
169
171
  this.#originalConfig = structuredClone(config)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/watt-extra",
3
- "version": "1.14.3",
3
+ "version": "1.14.4",
4
4
  "description": "The Platformatic runtime manager",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -0,0 +1,54 @@
1
+ import assert from 'node:assert'
2
+ import { test } from 'node:test'
3
+ import { join, dirname } from 'node:path'
4
+ import { fileURLToPath } from 'node:url'
5
+
6
+ import { randomUUID } from 'node:crypto'
7
+ import { setUpEnvironment, startICC, installDeps } from './helper.js'
8
+ import { start } from '../index.js'
9
+
10
+ const __filename = fileURLToPath(import.meta.url)
11
+ const __dirname = dirname(__filename)
12
+
13
+ // watt-extra always starts the runtime with isProduction: true, so the runtime
14
+ // must resolve watch to false. The runtime defaults watch to !isProduction, and
15
+ // reads isProduction from the options passed to its transform, so a transform
16
+ // that does not forward them silently enables file watching in production.
17
+ // This needs a @platformatic/runtime app: a single-application config instead
18
+ // goes through wrapInRuntimeConfig, which never calls the custom transform.
19
+ test('should disable file watching in production', async (t) => {
20
+ const appName = 'test-app'
21
+ const applicationId = randomUUID()
22
+ const applicationPath = join(__dirname, 'fixtures', 'runtime-service')
23
+
24
+ await installDeps(t, applicationPath)
25
+
26
+ const icc = await startICC(t, {
27
+ applicationId,
28
+ port: 3011
29
+ })
30
+
31
+ setUpEnvironment({
32
+ PLT_APP_NAME: appName,
33
+ PLT_APP_DIR: applicationPath,
34
+ PLT_ICC_URL: icc.iccUrl,
35
+ PLT_CONTROL_PLANE_URL: 'http://127.0.0.1:3012',
36
+ PLT_APP_PORT: 3053,
37
+ PLT_METRICS_PORT: 9102
38
+ })
39
+
40
+ const app = await start()
41
+
42
+ t.after(async () => {
43
+ await app.close()
44
+ await icc.close()
45
+ })
46
+
47
+ const mainConfig = app.watt.runtime.getRuntimeConfig(true)
48
+
49
+ assert.strictEqual(mainConfig.watch, false)
50
+
51
+ for (const application of mainConfig.applications ?? []) {
52
+ assert.strictEqual(application.watch, false, `application ${application.id} must not watch files`)
53
+ }
54
+ })