wattpm 3.32.0-alpha.0 → 3.32.0

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/bin/cli.js CHANGED
@@ -1,11 +1,24 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { checkNodeVersionForApplications, setExecutableId, setExecutableName } from '@platformatic/foundation'
3
+ // Enable compile cache before loading any modules (Node.js 22.1.0+)
4
+ import { homedir } from 'node:os'
5
+ import { join } from 'node:path'
6
+
7
+ try {
8
+ const { enableCompileCache } = await import('node:module')
9
+ if (typeof enableCompileCache === 'function') {
10
+ enableCompileCache(join(homedir(), '.cache', 'platformatic', 'compile-cache'))
11
+ }
12
+ } catch {
13
+ // Compile cache not available, continue without it
14
+ }
15
+
16
+ // Load wattpm via dynamic import so all modules benefit from compile cache
17
+ const { checkNodeVersionForApplications, setExecutableId, setExecutableName } = await import('@platformatic/foundation')
4
18
 
5
19
  checkNodeVersionForApplications()
6
20
  setExecutableId('wattpm')
7
21
  setExecutableName('Watt')
8
22
 
9
- // Use await import here so that we can throw a proper error on unsupported Node.js version
10
23
  const { main } = await import('../index.js')
11
24
  await main()
@@ -2,6 +2,7 @@ import { RuntimeApiClient, getMatchingRuntime } from '@platformatic/control'
2
2
  import { ensureLoggableError, logFatalError, parseArgs } from '@platformatic/foundation'
3
3
  import { bold } from 'colorette'
4
4
  import { writeFile } from 'node:fs/promises'
5
+ import { resolve } from 'node:path'
5
6
 
6
7
  export async function pprofStartCommand (logger, args) {
7
8
  const client = new RuntimeApiClient()
@@ -81,7 +82,8 @@ export async function pprofStopCommand (logger, args) {
81
82
  const { positionals, values } = parseArgs(
82
83
  args,
83
84
  {
84
- type: { type: 'string', short: 't', default: 'cpu' }
85
+ type: { type: 'string', short: 't', default: 'cpu' },
86
+ dir: { type: 'string', short: 'd' }
85
87
  },
86
88
  false
87
89
  )
@@ -98,6 +100,7 @@ export async function pprofStopCommand (logger, args) {
98
100
  // Get application ID from remaining positional arguments or use all applications
99
101
  const applicationId = remainingPositionals[0]
100
102
  const timestamp = new Date().toISOString().replace(/:/g, '-').replace(/\./g, '-')
103
+ const outputDir = values.dir || process.cwd()
101
104
 
102
105
  const options = { type }
103
106
 
@@ -110,22 +113,24 @@ export async function pprofStopCommand (logger, args) {
110
113
 
111
114
  const profileData = await client.stopApplicationProfiling(runtime.pid, applicationId, options)
112
115
  const filename = `pprof-${type}-${applicationId}-${timestamp}.pb`
113
- await writeFile(filename, Buffer.from(profileData))
116
+ const filepath = resolve(outputDir, filename)
117
+ await writeFile(filepath, Buffer.from(profileData))
114
118
  logger.info(
115
- `${type.toUpperCase()} profiling stopped for application ${bold(applicationId)}, profile saved to ${bold(filename)}`
119
+ `${type.toUpperCase()} profiling stopped for application ${bold(applicationId)}, profile saved to ${bold(filepath)}`
116
120
  )
117
- logger.info(`Run ${bold(`npx @platformatic/flame generate ${filename}`)} to generate the flamegraph`)
121
+ logger.info(`Run ${bold(`npx @platformatic/flame generate ${filepath}`)} to generate the flamegraph`)
118
122
  } else {
119
123
  // Stop profiling for all applications
120
124
  for (const application of runtimeApplications) {
121
125
  try {
122
126
  const profileData = await client.stopApplicationProfiling(runtime.pid, application.id, options)
123
127
  const filename = `pprof-${type}-${application.id}-${timestamp}.pb`
124
- await writeFile(filename, Buffer.from(profileData))
128
+ const filepath = resolve(outputDir, filename)
129
+ await writeFile(filepath, Buffer.from(profileData))
125
130
  logger.info(
126
- `${type.toUpperCase()} profiling stopped for application ${bold(application.id)}, profile saved to ${bold(filename)}`
131
+ `${type.toUpperCase()} profiling stopped for application ${bold(application.id)}, profile saved to ${bold(filepath)}`
127
132
  )
128
- logger.info(`Run ${bold(`npx @platformatic/flame generate ${filename}`)} to generate the flamegraph`)
133
+ logger.info(`Run ${bold(`npx @platformatic/flame generate ${filepath}`)} to generate the flamegraph`)
129
134
  } catch (error) {
130
135
  logger.warn(`Failed to stop profiling for application ${application.id}: ${error.message}`)
131
136
  }
@@ -173,6 +178,10 @@ export const help = {
173
178
  {
174
179
  name: '--node-modules-source-maps, -n',
175
180
  description: 'Comma-separated list of node_modules packages to load source maps from (e.g., "next,@next/next-server")'
181
+ },
182
+ {
183
+ name: '--dir, -d',
184
+ description: 'Directory to save the profile data to (default: current working directory). Only used with "stop" subcommand.'
176
185
  }
177
186
  ],
178
187
  args: [
@@ -199,6 +208,7 @@ export const help = {
199
208
  ' wattpm pprof start --type=cpu --source-maps my-app # Start CPU profiling with source maps\n' +
200
209
  ' wattpm pprof start -s -n next,@next/next-server my-app # Profile with Next.js source maps\n' +
201
210
  ' wattpm pprof stop --type=cpu my-app # Stop CPU profiling\n' +
202
- ' wattpm pprof stop --type=heap my-app # Stop heap profiling'
211
+ ' wattpm pprof stop --type=heap my-app # Stop heap profiling\n' +
212
+ ' wattpm pprof stop --dir=/tmp/profiles my-app # Save profile to specific directory'
203
213
  }
204
214
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wattpm",
3
- "version": "3.32.0-alpha.0",
3
+ "version": "3.32.0",
4
4
  "description": "The Node.js Application Server",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -29,9 +29,9 @@
29
29
  "pino-pretty": "^13.0.0",
30
30
  "split2": "^4.2.0",
31
31
  "table": "^6.8.2",
32
- "@platformatic/foundation": "3.32.0-alpha.0",
33
- "@platformatic/control": "3.32.0-alpha.0",
34
- "@platformatic/runtime": "3.32.0-alpha.0"
32
+ "@platformatic/control": "3.32.0",
33
+ "@platformatic/foundation": "3.32.0",
34
+ "@platformatic/runtime": "3.32.0"
35
35
  },
36
36
  "devDependencies": {
37
37
  "cleaner-spec-reporter": "^0.5.0",
@@ -42,7 +42,7 @@
42
42
  "neostandard": "^0.12.0",
43
43
  "typescript": "^5.5.4",
44
44
  "undici": "^7.0.0",
45
- "@platformatic/node": "3.32.0-alpha.0"
45
+ "@platformatic/node": "3.32.0"
46
46
  },
47
47
  "engines": {
48
48
  "node": ">=22.19.0"
package/schema.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://schemas.platformatic.dev/wattpm/3.32.0-alpha.0.json",
2
+ "$id": "https://schemas.platformatic.dev/wattpm/3.32.0.json",
3
3
  "$schema": "http://json-schema.org/draft-07/schema#",
4
4
  "title": "Platformatic Runtime Config",
5
5
  "type": "object",
@@ -208,16 +208,6 @@
208
208
  "type": "string"
209
209
  }
210
210
  ]
211
- },
212
- "noHeapCheck": {
213
- "anyOf": [
214
- {
215
- "type": "boolean"
216
- },
217
- {
218
- "type": "string"
219
- }
220
- ]
221
211
  }
222
212
  },
223
213
  "additionalProperties": false
@@ -342,6 +332,28 @@
342
332
  }
343
333
  }
344
334
  }
335
+ },
336
+ "compileCache": {
337
+ "anyOf": [
338
+ {
339
+ "type": "boolean"
340
+ },
341
+ {
342
+ "type": "object",
343
+ "properties": {
344
+ "enabled": {
345
+ "type": "boolean",
346
+ "default": true,
347
+ "description": "Enable Node.js module compile cache for faster startup"
348
+ },
349
+ "directory": {
350
+ "type": "string",
351
+ "description": "Directory to store compile cache. Defaults to .plt/compile-cache in app root"
352
+ }
353
+ },
354
+ "additionalProperties": false
355
+ }
356
+ ]
345
357
  }
346
358
  }
347
359
  }
@@ -532,16 +544,6 @@
532
544
  "type": "string"
533
545
  }
534
546
  ]
535
- },
536
- "noHeapCheck": {
537
- "anyOf": [
538
- {
539
- "type": "boolean"
540
- },
541
- {
542
- "type": "string"
543
- }
544
- ]
545
547
  }
546
548
  },
547
549
  "additionalProperties": false
@@ -666,6 +668,28 @@
666
668
  }
667
669
  }
668
670
  }
671
+ },
672
+ "compileCache": {
673
+ "anyOf": [
674
+ {
675
+ "type": "boolean"
676
+ },
677
+ {
678
+ "type": "object",
679
+ "properties": {
680
+ "enabled": {
681
+ "type": "boolean",
682
+ "default": true,
683
+ "description": "Enable Node.js module compile cache for faster startup"
684
+ },
685
+ "directory": {
686
+ "type": "string",
687
+ "description": "Directory to store compile cache. Defaults to .plt/compile-cache in app root"
688
+ }
689
+ },
690
+ "additionalProperties": false
691
+ }
692
+ ]
669
693
  }
670
694
  }
671
695
  }
@@ -854,16 +878,6 @@
854
878
  "type": "string"
855
879
  }
856
880
  ]
857
- },
858
- "noHeapCheck": {
859
- "anyOf": [
860
- {
861
- "type": "boolean"
862
- },
863
- {
864
- "type": "string"
865
- }
866
- ]
867
881
  }
868
882
  },
869
883
  "additionalProperties": false
@@ -988,6 +1002,28 @@
988
1002
  }
989
1003
  }
990
1004
  }
1005
+ },
1006
+ "compileCache": {
1007
+ "anyOf": [
1008
+ {
1009
+ "type": "boolean"
1010
+ },
1011
+ {
1012
+ "type": "object",
1013
+ "properties": {
1014
+ "enabled": {
1015
+ "type": "boolean",
1016
+ "default": true,
1017
+ "description": "Enable Node.js module compile cache for faster startup"
1018
+ },
1019
+ "directory": {
1020
+ "type": "string",
1021
+ "description": "Directory to store compile cache. Defaults to .plt/compile-cache in app root"
1022
+ }
1023
+ },
1024
+ "additionalProperties": false
1025
+ }
1026
+ ]
991
1027
  }
992
1028
  }
993
1029
  }
@@ -1176,16 +1212,6 @@
1176
1212
  "type": "string"
1177
1213
  }
1178
1214
  ]
1179
- },
1180
- "noHeapCheck": {
1181
- "anyOf": [
1182
- {
1183
- "type": "boolean"
1184
- },
1185
- {
1186
- "type": "string"
1187
- }
1188
- ]
1189
1215
  }
1190
1216
  },
1191
1217
  "additionalProperties": false
@@ -1310,6 +1336,28 @@
1310
1336
  }
1311
1337
  }
1312
1338
  }
1339
+ },
1340
+ "compileCache": {
1341
+ "anyOf": [
1342
+ {
1343
+ "type": "boolean"
1344
+ },
1345
+ {
1346
+ "type": "object",
1347
+ "properties": {
1348
+ "enabled": {
1349
+ "type": "boolean",
1350
+ "default": true,
1351
+ "description": "Enable Node.js module compile cache for faster startup"
1352
+ },
1353
+ "directory": {
1354
+ "type": "string",
1355
+ "description": "Directory to store compile cache. Defaults to .plt/compile-cache in app root"
1356
+ }
1357
+ },
1358
+ "additionalProperties": false
1359
+ }
1360
+ ]
1313
1361
  }
1314
1362
  }
1315
1363
  }
@@ -1389,7 +1437,6 @@
1389
1437
  "properties": {
1390
1438
  "level": {
1391
1439
  "type": "string",
1392
- "default": "info",
1393
1440
  "oneOf": [
1394
1441
  {
1395
1442
  "enum": [
@@ -1536,9 +1583,6 @@
1536
1583
  "default": true
1537
1584
  }
1538
1585
  },
1539
- "required": [
1540
- "level"
1541
- ],
1542
1586
  "default": {},
1543
1587
  "additionalProperties": true
1544
1588
  },
@@ -1834,17 +1878,6 @@
1834
1878
  }
1835
1879
  ],
1836
1880
  "default": 268435456
1837
- },
1838
- "noHeapCheck": {
1839
- "anyOf": [
1840
- {
1841
- "type": "boolean"
1842
- },
1843
- {
1844
- "type": "string"
1845
- }
1846
- ],
1847
- "default": false
1848
1881
  }
1849
1882
  },
1850
1883
  "additionalProperties": false
@@ -1976,6 +2009,26 @@
1976
2009
  },
1977
2010
  "maxCount": {
1978
2011
  "type": "integer"
2012
+ },
2013
+ "origins": {
2014
+ "type": "array",
2015
+ "items": {
2016
+ "type": "string"
2017
+ },
2018
+ "description": "Whitelist of origins to cache. Supports exact strings and regex patterns (e.g., \"/https:\\\\/\\\\/.*\\\\.example\\\\.com/\")."
2019
+ },
2020
+ "cacheByDefault": {
2021
+ "type": "integer",
2022
+ "description": "Default cache duration in seconds for responses without explicit expiration headers."
2023
+ },
2024
+ "type": {
2025
+ "type": "string",
2026
+ "enum": [
2027
+ "shared",
2028
+ "private"
2029
+ ],
2030
+ "default": "shared",
2031
+ "description": "Cache type. \"shared\" caches may be shared between users, \"private\" caches are user-specific."
1979
2032
  }
1980
2033
  }
1981
2034
  }
@@ -2621,6 +2674,28 @@
2621
2674
  "deny"
2622
2675
  ],
2623
2676
  "additionalProperties": false
2677
+ },
2678
+ "compileCache": {
2679
+ "anyOf": [
2680
+ {
2681
+ "type": "boolean"
2682
+ },
2683
+ {
2684
+ "type": "object",
2685
+ "properties": {
2686
+ "enabled": {
2687
+ "type": "boolean",
2688
+ "default": true,
2689
+ "description": "Enable Node.js module compile cache for faster startup"
2690
+ },
2691
+ "directory": {
2692
+ "type": "string",
2693
+ "description": "Directory to store compile cache. Defaults to .plt/compile-cache in app root"
2694
+ }
2695
+ },
2696
+ "additionalProperties": false
2697
+ }
2698
+ ]
2624
2699
  }
2625
2700
  },
2626
2701
  "anyOf": [