wattpm 3.35.0 → 3.36.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/index.js +9 -0
- package/lib/commands/applications.js +3 -2
- package/lib/commands/create.js +10 -0
- package/lib/commands/execution.js +4 -3
- package/lib/commands/help.js +4 -0
- package/lib/commands/inject.js +2 -1
- package/lib/commands/management.js +5 -4
- package/lib/commands/metrics.js +2 -1
- package/lib/commands/pprof.js +7 -4
- package/lib/commands/repl.js +9 -16
- package/lib/utils.js +9 -0
- package/package.json +7 -5
- package/schema.json +5 -1
package/index.js
CHANGED
|
@@ -15,6 +15,7 @@ import { metricsCommand } from './lib/commands/metrics.js'
|
|
|
15
15
|
import { pprofCommand } from './lib/commands/pprof.js'
|
|
16
16
|
import { replCommand } from './lib/commands/repl.js'
|
|
17
17
|
import { version } from './lib/schema.js'
|
|
18
|
+
import { setSocket } from './lib/utils.js'
|
|
18
19
|
|
|
19
20
|
export * from './lib/schema.js'
|
|
20
21
|
|
|
@@ -30,6 +31,10 @@ export async function main () {
|
|
|
30
31
|
short: 'v',
|
|
31
32
|
type: 'boolean'
|
|
32
33
|
},
|
|
34
|
+
socket: {
|
|
35
|
+
short: 'S',
|
|
36
|
+
type: 'string'
|
|
37
|
+
},
|
|
33
38
|
version: {
|
|
34
39
|
short: 'V',
|
|
35
40
|
type: 'boolean'
|
|
@@ -61,6 +66,10 @@ export async function main () {
|
|
|
61
66
|
setVerbose(true)
|
|
62
67
|
}
|
|
63
68
|
|
|
69
|
+
if (values.socket) {
|
|
70
|
+
setSocket(values.socket)
|
|
71
|
+
}
|
|
72
|
+
|
|
64
73
|
let command
|
|
65
74
|
const requestedCommand = unparsed[0] || 'help'
|
|
66
75
|
let applicationCommandContext
|
|
@@ -3,6 +3,7 @@ import { ensureLoggableError, logFatalError, parseArgs } from '@platformatic/fou
|
|
|
3
3
|
import { bold } from 'colorette'
|
|
4
4
|
import { readFile, stat, writeFile } from 'node:fs/promises'
|
|
5
5
|
import { basename, isAbsolute, relative, resolve } from 'node:path'
|
|
6
|
+
import { getSocket } from '../utils.js'
|
|
6
7
|
|
|
7
8
|
async function updateConfigFile (path, update) {
|
|
8
9
|
const contents = JSON.parse(await readFile(path, 'utf-8'))
|
|
@@ -25,7 +26,7 @@ export async function applicationsAddCommand (logger, args) {
|
|
|
25
26
|
false
|
|
26
27
|
)
|
|
27
28
|
|
|
28
|
-
const client = new RuntimeApiClient()
|
|
29
|
+
const client = new RuntimeApiClient({ logger, socket: getSocket() })
|
|
29
30
|
try {
|
|
30
31
|
const [runtime, applications] = await getMatchingRuntime(client, allPositionals)
|
|
31
32
|
const config = await client.getRuntimeConfig(runtime.pid, true)
|
|
@@ -100,7 +101,7 @@ export async function applicationsRemoveCommand (logger, args) {
|
|
|
100
101
|
false
|
|
101
102
|
)
|
|
102
103
|
|
|
103
|
-
const client = new RuntimeApiClient()
|
|
104
|
+
const client = new RuntimeApiClient({ logger, socket: getSocket() })
|
|
104
105
|
try {
|
|
105
106
|
const [runtime, applications] = await getMatchingRuntime(client, positionals)
|
|
106
107
|
|
package/lib/commands/create.js
CHANGED
|
@@ -2,6 +2,7 @@ import { getExecutableName, getPackageManager, parseArgs } from '@platformatic/f
|
|
|
2
2
|
import { bold } from 'colorette'
|
|
3
3
|
import { spawn } from 'node:child_process'
|
|
4
4
|
import { platform } from 'node:os'
|
|
5
|
+
import { getSocket } from '../utils.js'
|
|
5
6
|
|
|
6
7
|
export async function runDelegatedCommand (logger, packageManager, args) {
|
|
7
8
|
if (!packageManager) {
|
|
@@ -15,6 +16,15 @@ export async function runDelegatedCommand (logger, packageManager, args) {
|
|
|
15
16
|
args.unshift('-y')
|
|
16
17
|
}
|
|
17
18
|
|
|
19
|
+
const socket = getSocket()
|
|
20
|
+
if (socket) {
|
|
21
|
+
if (packageManager === 'pnpm') {
|
|
22
|
+
args.push('--', '--socket', socket)
|
|
23
|
+
} else {
|
|
24
|
+
args.push('--socket', socket)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
18
28
|
logger.info(`Running ${bold(runner)} ${bold(args.join(' '))} ...`)
|
|
19
29
|
|
|
20
30
|
const options = { stdio: 'inherit' }
|
|
@@ -11,6 +11,7 @@ import { create } from '@platformatic/runtime'
|
|
|
11
11
|
import { bold } from 'colorette'
|
|
12
12
|
import { spawn } from 'node:child_process'
|
|
13
13
|
import { createInterface } from 'node:readline'
|
|
14
|
+
import { getSocket } from '../utils.js'
|
|
14
15
|
|
|
15
16
|
export async function devCommand (logger, args) {
|
|
16
17
|
const {
|
|
@@ -130,7 +131,7 @@ export async function startCommand (logger, args) {
|
|
|
130
131
|
export async function stopCommand (logger, args) {
|
|
131
132
|
const { positionals } = parseArgs(args, {}, false)
|
|
132
133
|
|
|
133
|
-
const client = new RuntimeApiClient()
|
|
134
|
+
const client = new RuntimeApiClient({ logger, socket: getSocket() })
|
|
134
135
|
try {
|
|
135
136
|
const [runtime] = await getMatchingRuntime(client, positionals)
|
|
136
137
|
|
|
@@ -152,7 +153,7 @@ export async function stopCommand (logger, args) {
|
|
|
152
153
|
export async function restartCommand (logger, args) {
|
|
153
154
|
const { positionals } = parseArgs(args, {}, false)
|
|
154
155
|
|
|
155
|
-
const client = new RuntimeApiClient()
|
|
156
|
+
const client = new RuntimeApiClient({ logger, socket: getSocket() })
|
|
156
157
|
try {
|
|
157
158
|
const [runtime, applications] = await getMatchingRuntime(client, positionals)
|
|
158
159
|
|
|
@@ -178,7 +179,7 @@ export async function restartCommand (logger, args) {
|
|
|
178
179
|
export async function reloadCommand (logger, args) {
|
|
179
180
|
const { positionals } = parseArgs(args, {}, false)
|
|
180
181
|
|
|
181
|
-
const client = new RuntimeApiClient()
|
|
182
|
+
const client = new RuntimeApiClient({ logger, socket: getSocket() })
|
|
182
183
|
try {
|
|
183
184
|
const [runtime] = await getMatchingRuntime(client, positionals)
|
|
184
185
|
|
package/lib/commands/help.js
CHANGED
|
@@ -43,6 +43,10 @@ export async function showGeneralHelp (logger) {
|
|
|
43
43
|
const options = [
|
|
44
44
|
{ usage: '-V, --version', description: `Show ${executableId} version` },
|
|
45
45
|
{ usage: '-v, --verbose', description: 'Show more information' },
|
|
46
|
+
{
|
|
47
|
+
usage: '-S, --socket <path>',
|
|
48
|
+
description: 'Path for the control socket. If not specified, the default platform-specific location is used.'
|
|
49
|
+
},
|
|
46
50
|
{ usage: '--help', description: 'Show this help' }
|
|
47
51
|
]
|
|
48
52
|
|
package/lib/commands/inject.js
CHANGED
|
@@ -5,6 +5,7 @@ import { readFile } from 'node:fs/promises'
|
|
|
5
5
|
import { resolve } from 'node:path'
|
|
6
6
|
import { finished } from 'node:stream/promises'
|
|
7
7
|
import { setTimeout as sleep } from 'node:timers/promises'
|
|
8
|
+
import { getSocket } from '../utils.js'
|
|
8
9
|
|
|
9
10
|
function appendOutput (logger, stream, fullOutput, line) {
|
|
10
11
|
if (isVerbose()) {
|
|
@@ -70,7 +71,7 @@ export async function injectCommand (logger, args) {
|
|
|
70
71
|
)
|
|
71
72
|
|
|
72
73
|
const outputStream = output ? createWriteStream(resolve(process.cwd(), output)) : process.stdout
|
|
73
|
-
const client = new RuntimeApiClient()
|
|
74
|
+
const client = new RuntimeApiClient({ logger, socket: getSocket() })
|
|
74
75
|
try {
|
|
75
76
|
const [runtime, positionals] = await getMatchingRuntime(client, allPositionals)
|
|
76
77
|
let application = positionals[0]
|
|
@@ -3,6 +3,7 @@ import { ensureLoggableError, logFatalError, parseArgs } from '@platformatic/fou
|
|
|
3
3
|
import { bold, reset } from 'colorette'
|
|
4
4
|
import { sep } from 'node:path'
|
|
5
5
|
import { getBorderCharacters, table } from 'table'
|
|
6
|
+
import { getSocket } from '../utils.js'
|
|
6
7
|
|
|
7
8
|
const ONE_DAY = 3600 * 24
|
|
8
9
|
const ONE_HOUR = 3600
|
|
@@ -61,7 +62,7 @@ function formatDuration (duration) {
|
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
export async function psCommand (logger) {
|
|
64
|
-
const client = new RuntimeApiClient()
|
|
65
|
+
const client = new RuntimeApiClient({ logger, socket: getSocket() })
|
|
65
66
|
try {
|
|
66
67
|
const runtimes = await client.getRuntimes()
|
|
67
68
|
|
|
@@ -92,7 +93,7 @@ export async function psCommand (logger) {
|
|
|
92
93
|
|
|
93
94
|
export async function applicationsCommand (logger, args) {
|
|
94
95
|
const { positionals } = parseArgs(args, {}, false)
|
|
95
|
-
const client = new RuntimeApiClient()
|
|
96
|
+
const client = new RuntimeApiClient({ logger, socket: getSocket() })
|
|
96
97
|
|
|
97
98
|
try {
|
|
98
99
|
const [runtime] = await getMatchingRuntime(client, positionals)
|
|
@@ -130,7 +131,7 @@ export async function envCommand (logger, args) {
|
|
|
130
131
|
const { values, positionals: allPositionals } = parseArgs(args, { table: { type: 'boolean', short: 't' } }, false)
|
|
131
132
|
|
|
132
133
|
let application
|
|
133
|
-
const client = new RuntimeApiClient()
|
|
134
|
+
const client = new RuntimeApiClient({ logger, socket: getSocket() })
|
|
134
135
|
try {
|
|
135
136
|
const [runtime, positionals] = await getMatchingRuntime(client, allPositionals)
|
|
136
137
|
application = positionals[0]
|
|
@@ -176,7 +177,7 @@ export async function configCommand (logger, args) {
|
|
|
176
177
|
const { positionals: allPositionals } = parseArgs(args, {}, false)
|
|
177
178
|
|
|
178
179
|
let application
|
|
179
|
-
const client = new RuntimeApiClient()
|
|
180
|
+
const client = new RuntimeApiClient({ logger, socket: getSocket() })
|
|
180
181
|
try {
|
|
181
182
|
const [runtime, positionals] = await getMatchingRuntime(client, allPositionals)
|
|
182
183
|
application = positionals[0]
|
package/lib/commands/metrics.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { getMatchingRuntime, RuntimeApiClient } from '@platformatic/control'
|
|
2
2
|
import { ensureLoggableError, logFatalError, parseArgs } from '@platformatic/foundation'
|
|
3
3
|
import { bold } from 'colorette'
|
|
4
|
+
import { getSocket } from '../utils.js'
|
|
4
5
|
|
|
5
6
|
export async function metricsCommand (logger, args) {
|
|
6
|
-
const client = new RuntimeApiClient()
|
|
7
|
+
const client = new RuntimeApiClient({ logger, socket: getSocket() })
|
|
7
8
|
try {
|
|
8
9
|
const { values, positionals } = parseArgs(args, { format: { type: 'string', short: 'f', default: 'json' } }, false)
|
|
9
10
|
|
package/lib/commands/pprof.js
CHANGED
|
@@ -3,9 +3,10 @@ import { ensureLoggableError, logFatalError, parseArgs } from '@platformatic/fou
|
|
|
3
3
|
import { bold } from 'colorette'
|
|
4
4
|
import { writeFile } from 'node:fs/promises'
|
|
5
5
|
import { resolve } from 'node:path'
|
|
6
|
+
import { getSocket } from '../utils.js'
|
|
6
7
|
|
|
7
8
|
export async function pprofStartCommand (logger, args) {
|
|
8
|
-
const client = new RuntimeApiClient()
|
|
9
|
+
const client = new RuntimeApiClient({ logger, socket: getSocket() })
|
|
9
10
|
|
|
10
11
|
try {
|
|
11
12
|
const { positionals, values } = parseArgs(
|
|
@@ -76,7 +77,7 @@ export async function pprofStartCommand (logger, args) {
|
|
|
76
77
|
}
|
|
77
78
|
|
|
78
79
|
export async function pprofStopCommand (logger, args) {
|
|
79
|
-
const client = new RuntimeApiClient()
|
|
80
|
+
const client = new RuntimeApiClient({ logger, socket: getSocket() })
|
|
80
81
|
|
|
81
82
|
try {
|
|
82
83
|
const { positionals, values } = parseArgs(
|
|
@@ -177,11 +178,13 @@ export const help = {
|
|
|
177
178
|
},
|
|
178
179
|
{
|
|
179
180
|
name: '--node-modules-source-maps, -n',
|
|
180
|
-
description:
|
|
181
|
+
description:
|
|
182
|
+
'Comma-separated list of node_modules packages to load source maps from (e.g., "next,@next/next-server")'
|
|
181
183
|
},
|
|
182
184
|
{
|
|
183
185
|
name: '--dir, -d',
|
|
184
|
-
description:
|
|
186
|
+
description:
|
|
187
|
+
'Directory to save the profile data to (default: current working directory). Only used with "stop" subcommand.'
|
|
185
188
|
}
|
|
186
189
|
],
|
|
187
190
|
args: [
|
package/lib/commands/repl.js
CHANGED
|
@@ -3,6 +3,7 @@ import { ensureLoggableError, logFatalError, parseArgs } from '@platformatic/fou
|
|
|
3
3
|
import { bold } from 'colorette'
|
|
4
4
|
import { createInterface } from 'node:readline'
|
|
5
5
|
import { getBorderCharacters, table } from 'table'
|
|
6
|
+
import { getSocket } from '../utils.js'
|
|
6
7
|
|
|
7
8
|
const tableConfig = {
|
|
8
9
|
/* c8 ignore next */
|
|
@@ -15,7 +16,7 @@ const tableConfig = {
|
|
|
15
16
|
export async function replCommand (logger, args) {
|
|
16
17
|
const { positionals: allPositionals } = parseArgs(args, {}, false)
|
|
17
18
|
|
|
18
|
-
const client = new RuntimeApiClient()
|
|
19
|
+
const client = new RuntimeApiClient({ logger, socket: getSocket() })
|
|
19
20
|
try {
|
|
20
21
|
const [runtime, positionals] = await getMatchingRuntime(client, allPositionals)
|
|
21
22
|
let application = positionals[0]
|
|
@@ -33,12 +34,7 @@ export async function replCommand (logger, args) {
|
|
|
33
34
|
const { id, type, entrypoint } = app
|
|
34
35
|
return [id, type, entrypoint ? 'Yes' : 'No']
|
|
35
36
|
})
|
|
36
|
-
console.log(
|
|
37
|
-
table(
|
|
38
|
-
[[bold('Name'), bold('Type'), bold('Entrypoint')], ...rows],
|
|
39
|
-
tableConfig
|
|
40
|
-
)
|
|
41
|
-
)
|
|
37
|
+
console.log(table([[bold('Name'), bold('Type'), bold('Entrypoint')], ...rows], tableConfig))
|
|
42
38
|
console.log('Usage: wattpm repl <application-name>\n')
|
|
43
39
|
await client.close()
|
|
44
40
|
return
|
|
@@ -60,7 +56,7 @@ export async function replCommand (logger, args) {
|
|
|
60
56
|
})
|
|
61
57
|
|
|
62
58
|
// Forward stdin to WebSocket
|
|
63
|
-
rl.on('line',
|
|
59
|
+
rl.on('line', line => {
|
|
64
60
|
ws.send(line + '\n')
|
|
65
61
|
})
|
|
66
62
|
|
|
@@ -72,7 +68,7 @@ export async function replCommand (logger, args) {
|
|
|
72
68
|
})
|
|
73
69
|
|
|
74
70
|
// Forward WebSocket output to stdout
|
|
75
|
-
ws.on('message',
|
|
71
|
+
ws.on('message', data => {
|
|
76
72
|
process.stdout.write(data.toString())
|
|
77
73
|
})
|
|
78
74
|
|
|
@@ -93,7 +89,7 @@ export async function replCommand (logger, args) {
|
|
|
93
89
|
process.exit(0)
|
|
94
90
|
})
|
|
95
91
|
|
|
96
|
-
ws.on('error',
|
|
92
|
+
ws.on('error', error => {
|
|
97
93
|
logger.error({ error: ensureLoggableError(error) }, 'WebSocket error')
|
|
98
94
|
rl.close()
|
|
99
95
|
client.close()
|
|
@@ -105,11 +101,7 @@ export async function replCommand (logger, args) {
|
|
|
105
101
|
} else if (error.code === 'PLT_CTR_APPLICATION_NOT_FOUND') {
|
|
106
102
|
return logFatalError(logger, 'Cannot find a matching application.')
|
|
107
103
|
} else {
|
|
108
|
-
return logFatalError(
|
|
109
|
-
logger,
|
|
110
|
-
{ error: ensureLoggableError(error) },
|
|
111
|
-
`Cannot start REPL: ${error.message}`
|
|
112
|
-
)
|
|
104
|
+
return logFatalError(logger, { error: ensureLoggableError(error) }, `Cannot start REPL: ${error.message}`)
|
|
113
105
|
}
|
|
114
106
|
}
|
|
115
107
|
}
|
|
@@ -126,7 +118,8 @@ export const help = {
|
|
|
126
118
|
},
|
|
127
119
|
{
|
|
128
120
|
name: 'application',
|
|
129
|
-
description:
|
|
121
|
+
description:
|
|
122
|
+
'The application name (if omitted, auto-connects when single application or lists available applications)'
|
|
130
123
|
}
|
|
131
124
|
],
|
|
132
125
|
footer: `
|
package/lib/utils.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wattpm",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.36.0",
|
|
4
4
|
"description": "The Node.js Application Server",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -25,24 +25,26 @@
|
|
|
25
25
|
"lib"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
+
"@fastify/websocket": "^11.0.0",
|
|
28
29
|
"colorette": "^2.0.20",
|
|
29
30
|
"pino-pretty": "^13.0.0",
|
|
30
31
|
"split2": "^4.2.0",
|
|
31
32
|
"table": "^6.8.2",
|
|
32
|
-
"@platformatic/control": "3.
|
|
33
|
-
"@platformatic/
|
|
34
|
-
"@platformatic/
|
|
33
|
+
"@platformatic/control": "3.36.0",
|
|
34
|
+
"@platformatic/foundation": "3.36.0",
|
|
35
|
+
"@platformatic/runtime": "3.36.0"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
38
|
"cleaner-spec-reporter": "^0.5.0",
|
|
38
39
|
"eslint": "9",
|
|
39
40
|
"execa": "^9.4.0",
|
|
41
|
+
"fastify": "5.7.4",
|
|
40
42
|
"inspector-client": "^0.2.0",
|
|
41
43
|
"json-schema-to-typescript": "^15.0.0",
|
|
42
44
|
"neostandard": "^0.12.0",
|
|
43
45
|
"typescript": "^5.5.4",
|
|
44
46
|
"undici": "^7.0.0",
|
|
45
|
-
"@platformatic/node": "3.
|
|
47
|
+
"@platformatic/node": "3.36.0"
|
|
46
48
|
},
|
|
47
49
|
"engines": {
|
|
48
50
|
"node": ">=22.19.0"
|
package/schema.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$id": "https://schemas.platformatic.dev/wattpm/3.
|
|
2
|
+
"$id": "https://schemas.platformatic.dev/wattpm/3.36.0.json",
|
|
3
3
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
4
|
"title": "Platformatic Runtime Config",
|
|
5
5
|
"type": "object",
|
|
@@ -2070,6 +2070,10 @@
|
|
|
2070
2070
|
}
|
|
2071
2071
|
},
|
|
2072
2072
|
"additionalProperties": false
|
|
2073
|
+
},
|
|
2074
|
+
"socket": {
|
|
2075
|
+
"type": "string",
|
|
2076
|
+
"description": "Custom path for the control socket. If not specified, uses the default platform-specific location."
|
|
2073
2077
|
}
|
|
2074
2078
|
},
|
|
2075
2079
|
"additionalProperties": false
|