wattpm 3.38.1 → 3.40.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
@@ -14,11 +14,9 @@ try {
14
14
  }
15
15
 
16
16
  // Load wattpm via dynamic import so all modules benefit from compile cache
17
- const { checkNodeVersionForApplications, setExecutableId, setExecutableName } = await import('@platformatic/foundation')
17
+ const { checkNodeVersionForApplications, createCLIContext } = await import('@platformatic/foundation')
18
18
 
19
19
  checkNodeVersionForApplications()
20
- setExecutableId('wattpm')
21
- setExecutableName('Watt')
22
20
 
23
21
  const { main } = await import('../index.js')
24
- await main()
22
+ await main.call(createCLIContext('wattpm', 'Watt'))
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { createCliLogger, getExecutableId, logFatalError, parseArgs, setVerbose } from '@platformatic/foundation'
1
+ import { createCliLogger, logFatalError, parseArgs } from '@platformatic/foundation'
2
2
  import { loadApplicationsCommands } from '@platformatic/runtime'
3
3
  import * as colorette from 'colorette'
4
4
  import { bold } from 'colorette'
@@ -15,12 +15,11 @@ 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'
19
18
 
20
19
  export * from './lib/schema.js'
21
20
 
22
21
  export async function main () {
23
- globalThis.platformatic = { executable: getExecutableId() }
22
+ globalThis.platformatic = { executable: this.executableId }
24
23
 
25
24
  const options = {
26
25
  'no-pretty': {
@@ -48,6 +47,7 @@ export async function main () {
48
47
  const { values, unparsed } = parseArgs(process.argv.slice(2), options)
49
48
 
50
49
  const logger = createCliLogger('info', values['no-pretty'])
50
+ this.logger = logger
51
51
 
52
52
  if (values.version || unparsed[0] === 'version') {
53
53
  console.log(version)
@@ -55,19 +55,19 @@ export async function main () {
55
55
  }
56
56
 
57
57
  if (values.help) {
58
- helpCommand(logger, [])
58
+ helpCommand.call(this, logger, [])
59
59
  return
60
60
  } else if (unparsed.includes('-h') || unparsed.includes('--help')) {
61
- helpCommand(logger, unparsed)
61
+ helpCommand.call(this, logger, unparsed)
62
62
  return
63
63
  }
64
64
 
65
65
  if (values.verbose) {
66
- setVerbose(true)
66
+ this.verbose = true
67
67
  }
68
68
 
69
69
  if (values.socket) {
70
- setSocket(values.socket)
70
+ this.socket = values.socket
71
71
  }
72
72
 
73
73
  let command
@@ -139,7 +139,8 @@ export async function main () {
139
139
  break
140
140
  default:
141
141
  if (requestedCommand) {
142
- const applicationsCommands = await loadApplicationsCommands()
142
+ const applicationsCommands = await loadApplicationsCommands(this.executableName)
143
+ console.log(applicationsCommands)
143
144
  const applicationCommand = applicationsCommands.commands[requestedCommand]
144
145
 
145
146
  if (applicationCommand) {
@@ -154,7 +155,7 @@ export async function main () {
154
155
  if (!command) {
155
156
  logFatalError(
156
157
  logger,
157
- `Unknown command ${bold(requestedCommand)}. Please run ${bold(`"${getExecutableId()} help"`)} to see available commands.`
158
+ `Unknown command ${bold(requestedCommand)}. Please run ${bold(`"${this.executableId} help"`)} to see available commands.`
158
159
  )
159
160
 
160
161
  return
@@ -162,8 +163,12 @@ export async function main () {
162
163
 
163
164
  if (applicationCommandContext) {
164
165
  process.chdir(applicationCommandContext.path)
165
- return command(logger, applicationCommandContext.config, unparsed.slice(1), { colorette, parseArgs, logFatalError })
166
+ return command.call(this, logger, applicationCommandContext.config, unparsed.slice(1), {
167
+ colorette,
168
+ parseArgs,
169
+ logFatalError
170
+ })
166
171
  } else {
167
- await command(logger, unparsed.slice(1))
172
+ await command.call(this, logger, unparsed.slice(1))
168
173
  }
169
174
  }
@@ -19,7 +19,7 @@ export async function adminCommand (logger, args) {
19
19
  false
20
20
  )
21
21
 
22
- return runDelegatedCommand(logger, packageManager, ['@platformatic/watt-admin' + (latest ? '@latest' : '')])
22
+ return runDelegatedCommand(this, logger, packageManager, ['@platformatic/watt-admin' + (latest ? '@latest' : '')])
23
23
  }
24
24
 
25
25
  export const help = {
@@ -3,7 +3,6 @@ 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'
7
6
 
8
7
  async function updateConfigFile (path, update) {
9
8
  const contents = JSON.parse(await readFile(path, 'utf-8'))
@@ -26,7 +25,7 @@ export async function applicationsAddCommand (logger, args) {
26
25
  false
27
26
  )
28
27
 
29
- const client = new RuntimeApiClient({ logger, socket: getSocket() })
28
+ const client = new RuntimeApiClient({ logger, socket: this.socket })
30
29
  try {
31
30
  const [runtime, applications] = await getMatchingRuntime(client, allPositionals)
32
31
  const config = await client.getRuntimeConfig(runtime.pid, true)
@@ -101,7 +100,7 @@ export async function applicationsRemoveCommand (logger, args) {
101
100
  false
102
101
  )
103
102
 
104
- const client = new RuntimeApiClient({ logger, socket: getSocket() })
103
+ const client = new RuntimeApiClient({ logger, socket: this.socket })
105
104
  try {
106
105
  const [runtime, applications] = await getMatchingRuntime(client, positionals)
107
106
 
@@ -32,7 +32,7 @@ export async function buildCommand (logger, args) {
32
32
  )
33
33
  const root = getRoot(positionals)
34
34
 
35
- configurationFile = await findRuntimeConfigurationFile(logger, root, config)
35
+ configurationFile = await findRuntimeConfigurationFile(logger, root, config, true, true, true, this.executableName)
36
36
 
37
37
  /* c8 ignore next 3 - Hard to test */
38
38
  if (!configurationFile) {
@@ -1,10 +1,9 @@
1
- import { getExecutableName, getPackageManager, parseArgs } from '@platformatic/foundation'
1
+ import { getPackageManager, parseArgs } from '@platformatic/foundation'
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'
6
5
 
7
- export async function runDelegatedCommand (logger, packageManager, args) {
6
+ export async function runDelegatedCommand (context, logger, packageManager, args) {
8
7
  if (!packageManager) {
9
8
  packageManager = await getPackageManager(process.cwd())
10
9
  }
@@ -16,7 +15,7 @@ export async function runDelegatedCommand (logger, packageManager, args) {
16
15
  args.unshift('-y')
17
16
  }
18
17
 
19
- const socket = getSocket()
18
+ const socket = context.socket
20
19
  if (socket) {
21
20
  if (packageManager === 'pnpm') {
22
21
  args.push('--', '--socket', socket)
@@ -102,12 +101,12 @@ export async function createCommand (logger, args) {
102
101
  }
103
102
  }
104
103
 
105
- return runDelegatedCommand(logger, packageManager, runArgs)
104
+ return runDelegatedCommand(this, logger, packageManager, runArgs)
106
105
  }
107
106
 
108
107
  const createHelp = {
109
108
  description () {
110
- return `Creates a new ${getExecutableName()} project`
109
+ return `Creates a new ${this.executableName} project`
111
110
  },
112
111
  options: [
113
112
  {
@@ -11,7 +11,6 @@ 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'
15
14
 
16
15
  export async function devCommand (logger, args) {
17
16
  const {
@@ -33,7 +32,7 @@ export async function devCommand (logger, args) {
33
32
  )
34
33
  const root = getRoot(positionals)
35
34
 
36
- const configurationFile = await findRuntimeConfigurationFile(logger, root, config)
35
+ const configurationFile = await findRuntimeConfigurationFile(logger, root, config, true, true, true, this.executableName)
37
36
 
38
37
  /* c8 ignore next 3 - Hard to test */
39
38
  if (!configurationFile) {
@@ -108,7 +107,7 @@ export async function startCommand (logger, args) {
108
107
  )
109
108
 
110
109
  const root = getRoot(positionals)
111
- const configurationFile = await findRuntimeConfigurationFile(logger, root, config)
110
+ const configurationFile = await findRuntimeConfigurationFile(logger, root, config, true, true, true, this.executableName)
112
111
 
113
112
  /* c8 ignore next 3 - Hard to test */
114
113
  if (!configurationFile) {
@@ -132,7 +131,7 @@ export async function startCommand (logger, args) {
132
131
  export async function stopCommand (logger, args) {
133
132
  const { positionals } = parseArgs(args, {}, false)
134
133
 
135
- const client = new RuntimeApiClient({ logger, socket: getSocket() })
134
+ const client = new RuntimeApiClient({ logger, socket: this.socket })
136
135
  try {
137
136
  const [runtime] = await getMatchingRuntime(client, positionals)
138
137
 
@@ -154,7 +153,7 @@ export async function stopCommand (logger, args) {
154
153
  export async function restartCommand (logger, args) {
155
154
  const { positionals } = parseArgs(args, {}, false)
156
155
 
157
- const client = new RuntimeApiClient({ logger, socket: getSocket() })
156
+ const client = new RuntimeApiClient({ logger, socket: this.socket })
158
157
  try {
159
158
  const [runtime, applications] = await getMatchingRuntime(client, positionals)
160
159
 
@@ -180,7 +179,7 @@ export async function restartCommand (logger, args) {
180
179
  export async function reloadCommand (logger, args) {
181
180
  const { positionals } = parseArgs(args, {}, false)
182
181
 
183
- const client = new RuntimeApiClient({ logger, socket: getSocket() })
182
+ const client = new RuntimeApiClient({ logger, socket: this.socket })
184
183
  try {
185
184
  const [runtime] = await getMatchingRuntime(client, positionals)
186
185
 
@@ -1,9 +1,9 @@
1
- import { getExecutableId, getExecutableName, logFatalError, logo } from '@platformatic/foundation'
1
+ import { logFatalError, logo } from '@platformatic/foundation'
2
2
  import { loadApplicationsCommands } from '@platformatic/runtime'
3
3
  import { bold } from 'colorette'
4
4
 
5
- function sanitizeHelp (raw) {
6
- return (typeof raw === 'function' ? raw() : raw).trim()
5
+ function sanitizeHelp (context, raw) {
6
+ return (typeof raw === 'function' ? raw.call(context) : raw).trim()
7
7
  }
8
8
 
9
9
  async function loadCommands () {
@@ -31,14 +31,14 @@ async function loadCommands () {
31
31
  return commands
32
32
  }
33
33
 
34
- export async function showGeneralHelp (logger) {
34
+ export async function showGeneralHelp (context, logger) {
35
35
  if (typeof logger !== 'function') {
36
36
  logger = console.log
37
37
  }
38
38
 
39
- const executableId = getExecutableId()
39
+ const executableId = context.executableId
40
40
  const commands = Object.values(await loadCommands())
41
- const applicationsCommands = Object.values((await loadApplicationsCommands()).help)
41
+ const applicationsCommands = Object.values((await loadApplicationsCommands(context.executableName)).help)
42
42
 
43
43
  const options = [
44
44
  { usage: '-V, --version', description: `Show ${executableId} version` },
@@ -50,7 +50,7 @@ export async function showGeneralHelp (logger) {
50
50
  { usage: '--help', description: 'Show this help' }
51
51
  ]
52
52
 
53
- logger(logo())
53
+ logger(logo.call(context))
54
54
  logger(`\nUsage: ${executableId} [options] [command]\n`)
55
55
 
56
56
  // Compute the maximum length of options or commands
@@ -64,32 +64,34 @@ export async function showGeneralHelp (logger) {
64
64
  // Print all options
65
65
  logger('Options:\n')
66
66
  for (const { usage, description } of options) {
67
- logger(` ${usage.padEnd(maximumLength, ' ')} ${sanitizeHelp(description)}`)
67
+ logger(` ${usage.padEnd(maximumLength, ' ')} ${sanitizeHelp(context, description)}`)
68
68
  }
69
69
  logger('')
70
70
 
71
71
  // Print all commands
72
72
  logger('Commands:\n')
73
73
  for (const { usage, description } of commands) {
74
- logger(` ${usage.padEnd(maximumLength, ' ')} ${sanitizeHelp(description)}`)
74
+ logger(` ${usage.padEnd(maximumLength, ' ')} ${sanitizeHelp(context, description)}`)
75
75
  }
76
76
  logger('')
77
77
 
78
78
  if (applicationsCommands.length) {
79
79
  logger('Applications Commands:\n')
80
80
  for (const { usage, description } of applicationsCommands) {
81
- logger(` ${usage.padEnd(maximumLength, ' ')} ${sanitizeHelp(description)})`)
81
+ logger(` ${usage.padEnd(maximumLength, ' ')} ${sanitizeHelp(context, description)})`)
82
82
  }
83
83
  logger('')
84
84
  }
85
85
  }
86
86
 
87
- export function showHelp (command, logger) {
87
+ export function showHelp (context, command, logger) {
88
88
  if (typeof logger !== 'function') {
89
89
  logger = console.log
90
90
  }
91
91
 
92
- logger(`\nUsage: ${getExecutableId()} ${sanitizeHelp(command.usage)}\n\n${sanitizeHelp(command.description)}.\n`)
92
+ logger(
93
+ `\nUsage: ${context.executableId} ${sanitizeHelp(context, command.usage)}\n\n${sanitizeHelp(context, command.description)}.\n`
94
+ )
93
95
 
94
96
  let { options, args } = command
95
97
  options ??= []
@@ -102,7 +104,7 @@ export function showHelp (command, logger) {
102
104
  if (options.length) {
103
105
  logger('Options:\n')
104
106
  for (const { usage, description } of options) {
105
- logger(` ${usage.padEnd(maximumLength, ' ')} ${sanitizeHelp(description)}`)
107
+ logger(` ${usage.padEnd(maximumLength, ' ')} ${sanitizeHelp(context, description)}`)
106
108
  }
107
109
  logger('')
108
110
  }
@@ -111,13 +113,13 @@ export function showHelp (command, logger) {
111
113
  if (args.length) {
112
114
  logger('Arguments:\n')
113
115
  for (const { name, description } of args) {
114
- logger(` ${name.padEnd(maximumLength, ' ')} ${sanitizeHelp(description)}`)
116
+ logger(` ${name.padEnd(maximumLength, ' ')} ${sanitizeHelp(context, description)}`)
115
117
  }
116
118
  logger('')
117
119
  }
118
120
 
119
121
  if (command.footer) {
120
- logger(sanitizeHelp(command.footer) + '\n')
122
+ logger(sanitizeHelp(context, command.footer) + '\n')
121
123
  }
122
124
  }
123
125
 
@@ -125,38 +127,38 @@ export async function helpCommand (logger, args) {
125
127
  const command = args?.[0]
126
128
 
127
129
  if (!command) {
128
- return showGeneralHelp()
130
+ return showGeneralHelp(this)
129
131
  }
130
132
 
131
133
  const commands = await loadCommands()
132
134
  if (!commands[command]) {
133
- const applicationsCommands = (await loadApplicationsCommands()).help
135
+ const applicationsCommands = (await loadApplicationsCommands(this.executableName)).help
134
136
 
135
137
  if (applicationsCommands[command]) {
136
138
  // If the command is an application command, we show the help for that command
137
- return showHelp(applicationsCommands[command])
139
+ return showHelp(this, applicationsCommands[command])
138
140
  }
139
141
 
140
142
  return logFatalError(
141
143
  logger,
142
- `Unknown command ${bold(command)}. Please run ${bold(`"${getExecutableId()} help"`)} to see available commands.`
144
+ `Unknown command ${bold(command)}. Please run ${bold(`"${this.executableId} help"`)} to see available commands.`
143
145
  )
144
146
  }
145
147
 
146
- showHelp(commands[command])
148
+ showHelp(this, commands[command])
147
149
  }
148
150
 
149
151
  export const help = {
150
152
  help: {
151
153
  usage: 'help [command]',
152
154
  description () {
153
- return `Show help about ${getExecutableName()} or one of its commands`
155
+ return `Show help about ${this.executableName} or one of its commands`
154
156
  }
155
157
  },
156
158
  version: {
157
159
  usage: 'version',
158
160
  description () {
159
- return `Show current ${getExecutableName()} version`
161
+ return `Show current ${this.executableName} version`
160
162
  }
161
163
  }
162
164
  }
@@ -1,14 +1,13 @@
1
1
  import { getMatchingRuntime, RuntimeApiClient } from '@platformatic/control'
2
- import { ensureLoggableError, isVerbose, logFatalError, parseArgs } from '@platformatic/foundation'
2
+ import { ensureLoggableError, logFatalError, parseArgs } from '@platformatic/foundation'
3
3
  import { createWriteStream } from 'node:fs'
4
4
  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'
9
8
 
10
- function appendOutput (logger, stream, fullOutput, line) {
11
- if (isVerbose()) {
9
+ function appendOutput (verbose, logger, stream, fullOutput, line) {
10
+ if (verbose) {
12
11
  logger.info(line)
13
12
  }
14
13
 
@@ -18,7 +17,8 @@ function appendOutput (logger, stream, fullOutput, line) {
18
17
  }
19
18
 
20
19
  export async function injectCommand (logger, args) {
21
- const verbose = isVerbose()
20
+ const verbose = this.verbose
21
+
22
22
  const {
23
23
  values: { method, path: url, header: rawHeaders, data, 'data-file': file, output, 'full-output': fullOutput },
24
24
  positionals: allPositionals
@@ -71,7 +71,7 @@ export async function injectCommand (logger, args) {
71
71
  )
72
72
 
73
73
  const outputStream = output ? createWriteStream(resolve(process.cwd(), output)) : process.stdout
74
- const client = new RuntimeApiClient({ logger, socket: getSocket() })
74
+ const client = new RuntimeApiClient({ logger, socket: this.socket })
75
75
  try {
76
76
  const [runtime, positionals] = await getMatchingRuntime(client, allPositionals)
77
77
  let application = positionals[0]
@@ -89,25 +89,25 @@ export async function injectCommand (logger, args) {
89
89
  }
90
90
 
91
91
  // Track request
92
- appendOutput(logger, outputStream, fullOutput, `> ${method} ${url} HTTP/1.1`)
92
+ appendOutput(verbose, logger, outputStream, fullOutput, `> ${method} ${url} HTTP/1.1`)
93
93
 
94
94
  for (const [name, value] of Object.entries(headers)) {
95
- appendOutput(logger, outputStream, fullOutput, `> ${name}: ${value}`)
95
+ appendOutput(verbose, logger, outputStream, fullOutput, `> ${name}: ${value}`)
96
96
  }
97
97
 
98
- appendOutput(logger, outputStream, fullOutput, '>')
98
+ appendOutput(verbose, logger, outputStream, fullOutput, '>')
99
99
 
100
100
  // Perform the request
101
101
  const response = await client.injectRuntime(runtime.pid, application, { url, method, headers, body })
102
102
 
103
103
  // Track response
104
- appendOutput(logger, outputStream, fullOutput, `< HTTP/1.1 ${response.statusCode}`)
104
+ appendOutput(verbose, logger, outputStream, fullOutput, `< HTTP/1.1 ${response.statusCode}`)
105
105
 
106
106
  for (const [name, value] of Object.entries(response.headers)) {
107
- appendOutput(logger, outputStream, fullOutput, `< ${name}: ${value}`)
107
+ appendOutput(verbose, logger, outputStream, fullOutput, `< ${name}: ${value}`)
108
108
  }
109
109
 
110
- appendOutput(logger, outputStream, fullOutput, '<')
110
+ appendOutput(verbose, logger, outputStream, fullOutput, '<')
111
111
 
112
112
  // Show the response
113
113
  const responseBody = await response.body.text()
@@ -3,7 +3,6 @@ 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'
7
6
 
8
7
  const ONE_DAY = 3600 * 24
9
8
  const ONE_HOUR = 3600
@@ -62,7 +61,7 @@ function formatDuration (duration) {
62
61
  }
63
62
 
64
63
  export async function psCommand (logger) {
65
- const client = new RuntimeApiClient({ logger, socket: getSocket() })
64
+ const client = new RuntimeApiClient({ logger, socket: this.socket })
66
65
  try {
67
66
  const runtimes = await client.getRuntimes()
68
67
 
@@ -93,7 +92,7 @@ export async function psCommand (logger) {
93
92
 
94
93
  export async function applicationsCommand (logger, args) {
95
94
  const { positionals } = parseArgs(args, {}, false)
96
- const client = new RuntimeApiClient({ logger, socket: getSocket() })
95
+ const client = new RuntimeApiClient({ logger, socket: this.socket })
97
96
 
98
97
  try {
99
98
  const [runtime] = await getMatchingRuntime(client, positionals)
@@ -131,7 +130,7 @@ export async function envCommand (logger, args) {
131
130
  const { values, positionals: allPositionals } = parseArgs(args, { table: { type: 'boolean', short: 't' } }, false)
132
131
 
133
132
  let application
134
- const client = new RuntimeApiClient({ logger, socket: getSocket() })
133
+ const client = new RuntimeApiClient({ logger, socket: this.socket })
135
134
  try {
136
135
  const [runtime, positionals] = await getMatchingRuntime(client, allPositionals)
137
136
  application = positionals[0]
@@ -177,7 +176,7 @@ export async function configCommand (logger, args) {
177
176
  const { positionals: allPositionals } = parseArgs(args, {}, false)
178
177
 
179
178
  let application
180
- const client = new RuntimeApiClient({ logger, socket: getSocket() })
179
+ const client = new RuntimeApiClient({ logger, socket: this.socket })
181
180
  try {
182
181
  const [runtime, positionals] = await getMatchingRuntime(client, allPositionals)
183
182
  application = positionals[0]
@@ -1,10 +1,9 @@
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'
5
4
 
6
5
  export async function metricsCommand (logger, args) {
7
- const client = new RuntimeApiClient({ logger, socket: getSocket() })
6
+ const client = new RuntimeApiClient({ logger, socket: this.socket })
8
7
  try {
9
8
  const { values, positionals } = parseArgs(args, { format: { type: 'string', short: 'f', default: 'json' } }, false)
10
9
 
@@ -3,10 +3,9 @@ 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'
7
6
 
8
- export async function pprofStartCommand (logger, args) {
9
- const client = new RuntimeApiClient({ logger, socket: getSocket() })
7
+ export async function pprofStartCommand (context, logger, args) {
8
+ const client = new RuntimeApiClient({ logger, socket: context.socket })
10
9
 
11
10
  try {
12
11
  const { positionals, values } = parseArgs(
@@ -76,8 +75,8 @@ export async function pprofStartCommand (logger, args) {
76
75
  }
77
76
  }
78
77
 
79
- export async function pprofStopCommand (logger, args) {
80
- const client = new RuntimeApiClient({ logger, socket: getSocket() })
78
+ export async function pprofStopCommand (context, logger, args) {
79
+ const client = new RuntimeApiClient({ logger, socket: context.socket })
81
80
 
82
81
  try {
83
82
  const { positionals, values } = parseArgs(
@@ -155,9 +154,9 @@ export async function pprofCommand (logger, args) {
155
154
 
156
155
  switch (subcommand) {
157
156
  case 'start':
158
- return pprofStartCommand(logger, restArgs)
157
+ return pprofStartCommand(this, logger, restArgs)
159
158
  case 'stop':
160
- return pprofStopCommand(logger, restArgs)
159
+ return pprofStopCommand(this, logger, restArgs)
161
160
  default:
162
161
  return logFatalError(logger, `Please provide a pprof subcommand between ${bold('start')} and ${bold('stop')}.`)
163
162
  }
@@ -3,7 +3,6 @@ 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'
7
6
 
8
7
  const tableConfig = {
9
8
  /* c8 ignore next */
@@ -16,7 +15,7 @@ const tableConfig = {
16
15
  export async function replCommand (logger, args) {
17
16
  const { positionals: allPositionals } = parseArgs(args, {}, false)
18
17
 
19
- const client = new RuntimeApiClient({ logger, socket: getSocket() })
18
+ const client = new RuntimeApiClient({ logger, socket: this.socket })
20
19
  try {
21
20
  const [runtime, positionals] = await getMatchingRuntime(client, allPositionals)
22
21
  let application = positionals[0]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wattpm",
3
- "version": "3.38.1",
3
+ "version": "3.40.0",
4
4
  "description": "The Node.js Application Server",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -30,9 +30,9 @@
30
30
  "pino-pretty": "^13.0.0",
31
31
  "split2": "^4.2.0",
32
32
  "table": "^6.8.2",
33
- "@platformatic/control": "3.38.1",
34
- "@platformatic/foundation": "3.38.1",
35
- "@platformatic/runtime": "3.38.1"
33
+ "@platformatic/control": "3.40.0",
34
+ "@platformatic/foundation": "3.40.0",
35
+ "@platformatic/runtime": "3.40.0"
36
36
  },
37
37
  "devDependencies": {
38
38
  "cleaner-spec-reporter": "^0.5.0",
@@ -44,7 +44,7 @@
44
44
  "neostandard": "^0.12.0",
45
45
  "typescript": "^5.5.4",
46
46
  "undici": "^7.0.0",
47
- "@platformatic/node": "3.38.1"
47
+ "@platformatic/node": "3.40.0"
48
48
  },
49
49
  "engines": {
50
50
  "node": ">=22.19.0"
package/schema.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://schemas.platformatic.dev/wattpm/3.38.1.json",
2
+ "$id": "https://schemas.platformatic.dev/wattpm/3.40.0.json",
3
3
  "$schema": "http://json-schema.org/draft-07/schema#",
4
4
  "title": "Platformatic Runtime Config",
5
5
  "type": "object",
@@ -354,6 +354,29 @@
354
354
  "additionalProperties": false
355
355
  }
356
356
  ]
357
+ },
358
+ "management": {
359
+ "anyOf": [
360
+ {
361
+ "type": "boolean"
362
+ },
363
+ {
364
+ "type": "object",
365
+ "properties": {
366
+ "enabled": {
367
+ "type": "boolean",
368
+ "default": true
369
+ },
370
+ "operations": {
371
+ "type": "array",
372
+ "items": {
373
+ "type": "string"
374
+ }
375
+ }
376
+ },
377
+ "additionalProperties": false
378
+ }
379
+ ]
357
380
  }
358
381
  }
359
382
  }
@@ -690,6 +713,29 @@
690
713
  "additionalProperties": false
691
714
  }
692
715
  ]
716
+ },
717
+ "management": {
718
+ "anyOf": [
719
+ {
720
+ "type": "boolean"
721
+ },
722
+ {
723
+ "type": "object",
724
+ "properties": {
725
+ "enabled": {
726
+ "type": "boolean",
727
+ "default": true
728
+ },
729
+ "operations": {
730
+ "type": "array",
731
+ "items": {
732
+ "type": "string"
733
+ }
734
+ }
735
+ },
736
+ "additionalProperties": false
737
+ }
738
+ ]
693
739
  }
694
740
  }
695
741
  }
@@ -1024,6 +1070,29 @@
1024
1070
  "additionalProperties": false
1025
1071
  }
1026
1072
  ]
1073
+ },
1074
+ "management": {
1075
+ "anyOf": [
1076
+ {
1077
+ "type": "boolean"
1078
+ },
1079
+ {
1080
+ "type": "object",
1081
+ "properties": {
1082
+ "enabled": {
1083
+ "type": "boolean",
1084
+ "default": true
1085
+ },
1086
+ "operations": {
1087
+ "type": "array",
1088
+ "items": {
1089
+ "type": "string"
1090
+ }
1091
+ }
1092
+ },
1093
+ "additionalProperties": false
1094
+ }
1095
+ ]
1027
1096
  }
1028
1097
  }
1029
1098
  }
@@ -1358,6 +1427,29 @@
1358
1427
  "additionalProperties": false
1359
1428
  }
1360
1429
  ]
1430
+ },
1431
+ "management": {
1432
+ "anyOf": [
1433
+ {
1434
+ "type": "boolean"
1435
+ },
1436
+ {
1437
+ "type": "object",
1438
+ "properties": {
1439
+ "enabled": {
1440
+ "type": "boolean",
1441
+ "default": true
1442
+ },
1443
+ "operations": {
1444
+ "type": "array",
1445
+ "items": {
1446
+ "type": "string"
1447
+ }
1448
+ }
1449
+ },
1450
+ "additionalProperties": false
1451
+ }
1452
+ ]
1361
1453
  }
1362
1454
  }
1363
1455
  }
@@ -1578,6 +1670,26 @@
1578
1670
  "type": "object",
1579
1671
  "additionalProperties": true
1580
1672
  },
1673
+ "openTelemetryExporter": {
1674
+ "type": "object",
1675
+ "properties": {
1676
+ "protocol": {
1677
+ "type": "string",
1678
+ "enum": [
1679
+ "grpc",
1680
+ "http"
1681
+ ]
1682
+ },
1683
+ "url": {
1684
+ "type": "string"
1685
+ }
1686
+ },
1687
+ "required": [
1688
+ "protocol",
1689
+ "url"
1690
+ ],
1691
+ "additionalProperties": false
1692
+ },
1581
1693
  "captureStdio": {
1582
1694
  "type": "boolean",
1583
1695
  "default": true
@@ -2081,6 +2193,29 @@
2081
2193
  ],
2082
2194
  "default": true
2083
2195
  },
2196
+ "management": {
2197
+ "anyOf": [
2198
+ {
2199
+ "type": "boolean"
2200
+ },
2201
+ {
2202
+ "type": "object",
2203
+ "properties": {
2204
+ "enabled": {
2205
+ "type": "boolean",
2206
+ "default": true
2207
+ },
2208
+ "operations": {
2209
+ "type": "array",
2210
+ "items": {
2211
+ "type": "string"
2212
+ }
2213
+ }
2214
+ },
2215
+ "additionalProperties": false
2216
+ }
2217
+ ]
2218
+ },
2084
2219
  "metrics": {
2085
2220
  "anyOf": [
2086
2221
  {
package/lib/utils.js DELETED
@@ -1,9 +0,0 @@
1
- let socket
2
-
3
- export function setSocket (value) {
4
- socket = value
5
- }
6
-
7
- export function getSocket () {
8
- return socket
9
- }