wattpm 2.21.1 → 2.23.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/lib/commands/build.js +12 -9
- package/lib/commands/execution.js +22 -17
- package/lib/commands/external.js +39 -21
- package/lib/commands/init.js +2 -2
- package/lib/commands/inject.js +4 -4
- package/lib/commands/logs.js +5 -5
- package/lib/commands/management.js +11 -10
- package/lib/utils.js +50 -6
- package/package.json +9 -9
- package/schema.json +45 -1
package/lib/commands/build.js
CHANGED
|
@@ -5,7 +5,15 @@ import { execa } from 'execa'
|
|
|
5
5
|
import { existsSync } from 'node:fs'
|
|
6
6
|
import { readFile } from 'node:fs/promises'
|
|
7
7
|
import { resolve } from 'node:path'
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
buildRuntime,
|
|
10
|
+
findConfigurationFile,
|
|
11
|
+
getPackageManager,
|
|
12
|
+
getRoot,
|
|
13
|
+
loadConfigurationFile,
|
|
14
|
+
overrideFatal,
|
|
15
|
+
parseArgs
|
|
16
|
+
} from '../utils.js'
|
|
9
17
|
|
|
10
18
|
// This function will not perform the command if the .npmrc file contains the 'dry-run' flag - This is useful in tests
|
|
11
19
|
async function executeCommand (root, ...args) {
|
|
@@ -33,13 +41,8 @@ export async function installDependencies (logger, root, services, production, p
|
|
|
33
41
|
services = config.services
|
|
34
42
|
}
|
|
35
43
|
|
|
36
|
-
/* c8 ignore next 8 */
|
|
37
44
|
if (!packageManager) {
|
|
38
|
-
|
|
39
|
-
packageManager = 'pnpm'
|
|
40
|
-
} else {
|
|
41
|
-
packageManager = 'npm'
|
|
42
|
-
}
|
|
45
|
+
packageManager = getPackageManager(root)
|
|
43
46
|
}
|
|
44
47
|
|
|
45
48
|
const args = ['install']
|
|
@@ -87,7 +90,7 @@ export async function installDependencies (logger, root, services, production, p
|
|
|
87
90
|
export async function buildCommand (logger, args) {
|
|
88
91
|
const { positionals } = parseArgs(args, {}, false)
|
|
89
92
|
/* c8 ignore next */
|
|
90
|
-
const root =
|
|
93
|
+
const root = getRoot(positionals)
|
|
91
94
|
|
|
92
95
|
const configurationFile = await findConfigurationFile(logger, root)
|
|
93
96
|
|
|
@@ -142,7 +145,7 @@ export async function installCommand (logger, args) {
|
|
|
142
145
|
)
|
|
143
146
|
|
|
144
147
|
/* c8 ignore next */
|
|
145
|
-
const root =
|
|
148
|
+
const root = getRoot(positionals)
|
|
146
149
|
const configurationFile = await findConfigurationFile(logger, root)
|
|
147
150
|
|
|
148
151
|
await installDependencies(logger, root, configurationFile, production, packageManager)
|
|
@@ -4,13 +4,12 @@ import { ensureLoggableError } from '@platformatic/utils'
|
|
|
4
4
|
import { bold } from 'colorette'
|
|
5
5
|
import { spawn } from 'node:child_process'
|
|
6
6
|
import { watch } from 'node:fs/promises'
|
|
7
|
-
import {
|
|
8
|
-
import { findConfigurationFile, getMatchingRuntimeArgs, parseArgs } from '../utils.js'
|
|
7
|
+
import { findConfigurationFile, getMatchingRuntime, getRoot, parseArgs } from '../utils.js'
|
|
9
8
|
|
|
10
9
|
export async function devCommand (logger, args) {
|
|
11
10
|
const { positionals } = parseArgs(args, {}, false)
|
|
12
11
|
/* c8 ignore next */
|
|
13
|
-
const root =
|
|
12
|
+
const root = getRoot(positionals)
|
|
14
13
|
|
|
15
14
|
const configurationFile = await findConfigurationFile(logger, root)
|
|
16
15
|
let runtime = await pltStartCommand(['-c', configurationFile], true, true)
|
|
@@ -27,14 +26,18 @@ export async function devCommand (logger, args) {
|
|
|
27
26
|
}
|
|
28
27
|
|
|
29
28
|
export async function startCommand (logger, args) {
|
|
30
|
-
const { positionals, values } = parseArgs(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
29
|
+
const { positionals, values } = parseArgs(
|
|
30
|
+
args,
|
|
31
|
+
{
|
|
32
|
+
inspect: {
|
|
33
|
+
type: 'boolean',
|
|
34
|
+
short: 'i'
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
false
|
|
38
|
+
)
|
|
36
39
|
/* c8 ignore next */
|
|
37
|
-
const root =
|
|
40
|
+
const root = getRoot(positionals)
|
|
38
41
|
|
|
39
42
|
const configurationFile = await findConfigurationFile(logger, root)
|
|
40
43
|
const cmd = ['--production', '-c', configurationFile]
|
|
@@ -49,7 +52,7 @@ export async function stopCommand (logger, args) {
|
|
|
49
52
|
|
|
50
53
|
try {
|
|
51
54
|
const client = new RuntimeApiClient()
|
|
52
|
-
const runtime = await
|
|
55
|
+
const [runtime] = await getMatchingRuntime(client, positionals)
|
|
53
56
|
|
|
54
57
|
await client.stopRuntime(runtime.pid)
|
|
55
58
|
await client.close()
|
|
@@ -70,7 +73,7 @@ export async function restartCommand (logger, args) {
|
|
|
70
73
|
|
|
71
74
|
try {
|
|
72
75
|
const client = new RuntimeApiClient()
|
|
73
|
-
const runtime = await
|
|
76
|
+
const [runtime] = await getMatchingRuntime(client, positionals)
|
|
74
77
|
|
|
75
78
|
await client.restartRuntime(runtime.pid)
|
|
76
79
|
await client.close()
|
|
@@ -91,7 +94,7 @@ export async function reloadCommand (logger, args) {
|
|
|
91
94
|
|
|
92
95
|
try {
|
|
93
96
|
const client = new RuntimeApiClient()
|
|
94
|
-
const runtime = await
|
|
97
|
+
const [runtime] = await getMatchingRuntime(client, positionals)
|
|
95
98
|
|
|
96
99
|
// Stop the previous runtime
|
|
97
100
|
await client.stopRuntime(runtime.pid)
|
|
@@ -140,10 +143,12 @@ export const help = {
|
|
|
140
143
|
description: 'The directory containing the application (the default is the current directory)'
|
|
141
144
|
}
|
|
142
145
|
],
|
|
143
|
-
options: [
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
146
|
+
options: [
|
|
147
|
+
{
|
|
148
|
+
usage: '-i --inspect',
|
|
149
|
+
description: 'Enables the inspector for each service'
|
|
150
|
+
}
|
|
151
|
+
]
|
|
147
152
|
},
|
|
148
153
|
stop: {
|
|
149
154
|
usage: 'stop [id]',
|
package/lib/commands/external.js
CHANGED
|
@@ -10,6 +10,8 @@ import { defaultServiceJson } from '../defaults.js'
|
|
|
10
10
|
import { version } from '../schema.js'
|
|
11
11
|
import {
|
|
12
12
|
findConfigurationFile,
|
|
13
|
+
getPackageManager,
|
|
14
|
+
getRoot,
|
|
13
15
|
loadConfigurationFile,
|
|
14
16
|
loadRawConfigurationFile,
|
|
15
17
|
overrideFatal,
|
|
@@ -119,7 +121,7 @@ async function fixConfiguration (logger, root) {
|
|
|
119
121
|
}
|
|
120
122
|
}
|
|
121
123
|
|
|
122
|
-
async function importService (logger, configurationFile, id, path, url) {
|
|
124
|
+
async function importService (logger, configurationFile, id, path, url, branch) {
|
|
123
125
|
const config = await loadConfigurationFile(logger, configurationFile)
|
|
124
126
|
const rawConfig = await loadRawConfigurationFile(logger, configurationFile)
|
|
125
127
|
const root = dirname(configurationFile)
|
|
@@ -168,7 +170,13 @@ async function importService (logger, configurationFile, id, path, url) {
|
|
|
168
170
|
rawConfig.web ??= []
|
|
169
171
|
|
|
170
172
|
if (useEnv) {
|
|
171
|
-
|
|
173
|
+
const resolveConfig = { id, path: `{${envVariable}}`, url }
|
|
174
|
+
|
|
175
|
+
if (resolveConfig.url && branch) {
|
|
176
|
+
resolveConfig.gitBranch = branch
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
rawConfig.web.push(resolveConfig)
|
|
172
180
|
|
|
173
181
|
// Make sure the environment variable is not already defined
|
|
174
182
|
if (existsSync(envFile)) {
|
|
@@ -195,13 +203,13 @@ async function importService (logger, configurationFile, id, path, url) {
|
|
|
195
203
|
await saveConfigurationFile(logger, configurationFile, rawConfig)
|
|
196
204
|
}
|
|
197
205
|
|
|
198
|
-
async function importURL (logger, _, configurationFile, rawUrl, id, http) {
|
|
206
|
+
async function importURL (logger, _, configurationFile, rawUrl, id, http, branch) {
|
|
199
207
|
let url = rawUrl
|
|
200
208
|
if (rawUrl.match(/^[a-z0-9-]+\/[a-z0-9-]+$/i)) {
|
|
201
209
|
url = http ? `https://github.com/${rawUrl}.git` : `git@github.com:${rawUrl}.git`
|
|
202
210
|
}
|
|
203
211
|
|
|
204
|
-
await importService(logger, configurationFile, id ?? basename(rawUrl, '.git'), null, url)
|
|
212
|
+
await importService(logger, configurationFile, id ?? basename(rawUrl, '.git'), null, url, branch)
|
|
205
213
|
}
|
|
206
214
|
|
|
207
215
|
async function importLocal (logger, root, configurationFile, path, overridenId) {
|
|
@@ -246,13 +254,8 @@ export async function resolveServices (
|
|
|
246
254
|
) {
|
|
247
255
|
const config = await loadConfigurationFile(logger, configurationFile)
|
|
248
256
|
|
|
249
|
-
/* c8 ignore next 8 */
|
|
250
257
|
if (!packageManager) {
|
|
251
|
-
|
|
252
|
-
packageManager = 'pnpm'
|
|
253
|
-
} else {
|
|
254
|
-
packageManager = 'npm'
|
|
255
|
-
}
|
|
258
|
+
getPackageManager(root)
|
|
256
259
|
}
|
|
257
260
|
|
|
258
261
|
// The services which might be to be resolved are the one that have a URL and either
|
|
@@ -318,13 +321,23 @@ export async function resolveServices (
|
|
|
318
321
|
url = parsed.toString()
|
|
319
322
|
}
|
|
320
323
|
|
|
324
|
+
const cloneArgs = ['clone', url, absolutePath]
|
|
325
|
+
|
|
326
|
+
let branchLabel = ''
|
|
327
|
+
if (service.gitBranch && service.gitBranch !== 'main') {
|
|
328
|
+
cloneArgs.push('--branch', service.gitBranch)
|
|
329
|
+
branchLabel = ` (branch ${bold(service.gitBranch)})`
|
|
330
|
+
}
|
|
331
|
+
|
|
321
332
|
if (username) {
|
|
322
|
-
childLogger.info(
|
|
333
|
+
childLogger.info(
|
|
334
|
+
`Cloning ${bold(service.url)}${branchLabel} as user ${bold(username)} into ${bold(relativePath)} ...`
|
|
335
|
+
)
|
|
323
336
|
} else {
|
|
324
|
-
childLogger.info(`Cloning ${bold(service.url)} into ${bold(relativePath)} ...`)
|
|
337
|
+
childLogger.info(`Cloning ${bold(service.url)}${branchLabel} into ${bold(relativePath)} ...`)
|
|
325
338
|
}
|
|
326
339
|
|
|
327
|
-
await execa('git',
|
|
340
|
+
await execa('git', cloneArgs)
|
|
328
341
|
} catch (error) {
|
|
329
342
|
childLogger.fatal(
|
|
330
343
|
{ error: ensureLoggableError(error) },
|
|
@@ -341,7 +354,7 @@ export async function resolveServices (
|
|
|
341
354
|
|
|
342
355
|
export async function importCommand (logger, args) {
|
|
343
356
|
const {
|
|
344
|
-
values: { id, http },
|
|
357
|
+
values: { id, http, branch },
|
|
345
358
|
positionals
|
|
346
359
|
} = parseArgs(
|
|
347
360
|
args,
|
|
@@ -353,6 +366,10 @@ export async function importCommand (logger, args) {
|
|
|
353
366
|
http: {
|
|
354
367
|
type: 'boolean',
|
|
355
368
|
short: 'h'
|
|
369
|
+
},
|
|
370
|
+
branch: {
|
|
371
|
+
type: 'string',
|
|
372
|
+
short: 'b'
|
|
356
373
|
}
|
|
357
374
|
},
|
|
358
375
|
false
|
|
@@ -370,16 +387,13 @@ export async function importCommand (logger, args) {
|
|
|
370
387
|
/* c8 ignore next */
|
|
371
388
|
return fixConfiguration(logger, '')
|
|
372
389
|
} else if (positionals.length === 1) {
|
|
373
|
-
root =
|
|
390
|
+
root = getRoot()
|
|
374
391
|
rawUrl = positionals[0]
|
|
375
392
|
} else {
|
|
376
|
-
root = positionals
|
|
393
|
+
root = getRoot(positionals)
|
|
377
394
|
rawUrl = positionals[1]
|
|
378
395
|
}
|
|
379
396
|
|
|
380
|
-
/* c8 ignore next */
|
|
381
|
-
root = resolve(process.cwd(), root)
|
|
382
|
-
|
|
383
397
|
const configurationFile = await findConfigurationFile(logger, root)
|
|
384
398
|
|
|
385
399
|
// If the rawUrl exists as local folder, import a local folder, otherwise go for Git.
|
|
@@ -392,7 +406,7 @@ export async function importCommand (logger, args) {
|
|
|
392
406
|
return importLocal(logger, root, configurationFile, local, id)
|
|
393
407
|
}
|
|
394
408
|
|
|
395
|
-
return importURL(logger, root, configurationFile, rawUrl, id, http)
|
|
409
|
+
return importURL(logger, root, configurationFile, rawUrl, id, http, branch)
|
|
396
410
|
}
|
|
397
411
|
|
|
398
412
|
export async function resolveCommand (logger, args) {
|
|
@@ -426,7 +440,7 @@ export async function resolveCommand (logger, args) {
|
|
|
426
440
|
)
|
|
427
441
|
|
|
428
442
|
/* c8 ignore next */
|
|
429
|
-
const root =
|
|
443
|
+
const root = getRoot(positionals)
|
|
430
444
|
const configurationFile = await findConfigurationFile(logger, root)
|
|
431
445
|
|
|
432
446
|
await resolveServices(logger, root, configurationFile, username, password, skipDependencies, packageManager)
|
|
@@ -455,6 +469,10 @@ export const help = {
|
|
|
455
469
|
{
|
|
456
470
|
usage: '-h, --http',
|
|
457
471
|
description: 'Use HTTP URL when expanding GitHub repositories'
|
|
472
|
+
},
|
|
473
|
+
{
|
|
474
|
+
usage: '-b, --branch <branch>',
|
|
475
|
+
description: 'The branch to clone (the default is main)'
|
|
458
476
|
}
|
|
459
477
|
]
|
|
460
478
|
},
|
package/lib/commands/init.js
CHANGED
|
@@ -7,7 +7,7 @@ import { basename, resolve } from 'node:path'
|
|
|
7
7
|
import { defaultConfiguration, defaultPackageJson } from '../defaults.js'
|
|
8
8
|
import { gitignore } from '../gitignore.js'
|
|
9
9
|
import { schema, version } from '../schema.js'
|
|
10
|
-
import { parseArgs, saveConfigurationFile, verbose } from '../utils.js'
|
|
10
|
+
import { getRoot, parseArgs, saveConfigurationFile, verbose } from '../utils.js'
|
|
11
11
|
|
|
12
12
|
export async function initCommand (logger, args) {
|
|
13
13
|
const {
|
|
@@ -26,7 +26,7 @@ export async function initCommand (logger, args) {
|
|
|
26
26
|
)
|
|
27
27
|
|
|
28
28
|
/* c8 ignore next */
|
|
29
|
-
const root =
|
|
29
|
+
const root = getRoot(positionals)
|
|
30
30
|
const web = resolve(root, 'web')
|
|
31
31
|
const configurationFile = resolve(root, 'watt.json')
|
|
32
32
|
|
package/lib/commands/inject.js
CHANGED
|
@@ -5,7 +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 {
|
|
8
|
+
import { getMatchingRuntime, parseArgs, verbose } from '../utils.js'
|
|
9
9
|
|
|
10
10
|
function appendOutput (logger, stream, fullOutput, line) {
|
|
11
11
|
if (verbose) {
|
|
@@ -20,7 +20,7 @@ function appendOutput (logger, stream, fullOutput, line) {
|
|
|
20
20
|
export async function injectCommand (logger, args) {
|
|
21
21
|
const {
|
|
22
22
|
values: { method, path: url, header: rawHeaders, data, 'data-file': file, output, 'full-output': fullOutput },
|
|
23
|
-
positionals
|
|
23
|
+
positionals: allPositionals
|
|
24
24
|
} = parseArgs(
|
|
25
25
|
args,
|
|
26
26
|
{
|
|
@@ -73,8 +73,8 @@ export async function injectCommand (logger, args) {
|
|
|
73
73
|
|
|
74
74
|
try {
|
|
75
75
|
const client = new RuntimeApiClient()
|
|
76
|
-
const runtime = await
|
|
77
|
-
let service = positionals[
|
|
76
|
+
const [runtime, positionals] = await getMatchingRuntime(client, allPositionals)
|
|
77
|
+
let service = positionals[0]
|
|
78
78
|
|
|
79
79
|
if (!service) {
|
|
80
80
|
const servicesInfo = await client.getRuntimeServices(runtime.pid)
|
package/lib/commands/logs.js
CHANGED
|
@@ -2,10 +2,10 @@ import { RuntimeApiClient } from '@platformatic/control'
|
|
|
2
2
|
import { ensureLoggableError } from '@platformatic/utils'
|
|
3
3
|
import pinoPretty from 'pino-pretty'
|
|
4
4
|
import split2 from 'split2'
|
|
5
|
-
import {
|
|
5
|
+
import { getMatchingRuntime, parseArgs } from '../utils.js'
|
|
6
6
|
|
|
7
7
|
export async function logsCommand (logger, args) {
|
|
8
|
-
const { values, positionals } = parseArgs(
|
|
8
|
+
const { values, positionals: allPositionals } = parseArgs(
|
|
9
9
|
args,
|
|
10
10
|
{
|
|
11
11
|
level: { type: 'string', short: 'l', default: 'info' },
|
|
@@ -14,15 +14,15 @@ export async function logsCommand (logger, args) {
|
|
|
14
14
|
false
|
|
15
15
|
)
|
|
16
16
|
|
|
17
|
-
const service = positionals[1]
|
|
18
|
-
|
|
19
17
|
const minimumLevel = logger.levels.values[values.level]
|
|
20
18
|
/* c8 ignore next */
|
|
21
19
|
const output = values.pretty ? pinoPretty({ colorize: true }) : process.stdout
|
|
22
20
|
|
|
21
|
+
let service
|
|
23
22
|
try {
|
|
24
23
|
const client = new RuntimeApiClient()
|
|
25
|
-
const runtime = await
|
|
24
|
+
const [runtime, positionals] = await getMatchingRuntime(client, allPositionals)
|
|
25
|
+
service = positionals[0]
|
|
26
26
|
|
|
27
27
|
const logsStream = client.getRuntimeLiveLogsStream(runtime.pid)
|
|
28
28
|
|
|
@@ -3,7 +3,7 @@ import { ensureLoggableError } from '@platformatic/utils'
|
|
|
3
3
|
import { bold, reset } from 'colorette'
|
|
4
4
|
import { sep } from 'node:path'
|
|
5
5
|
import { getBorderCharacters, table } from 'table'
|
|
6
|
-
import {
|
|
6
|
+
import { getMatchingRuntime, parseArgs } from '../utils.js'
|
|
7
7
|
|
|
8
8
|
const ONE_DAY = 3600 * 24
|
|
9
9
|
const ONE_HOUR = 3600
|
|
@@ -61,7 +61,7 @@ function formatDuration (duration) {
|
|
|
61
61
|
return result.trim()
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
export async function psCommand (logger
|
|
64
|
+
export async function psCommand (logger) {
|
|
65
65
|
try {
|
|
66
66
|
const client = new RuntimeApiClient()
|
|
67
67
|
const runtimes = await client.getRuntimes()
|
|
@@ -95,7 +95,7 @@ export async function servicesCommand (logger, args) {
|
|
|
95
95
|
|
|
96
96
|
try {
|
|
97
97
|
const client = new RuntimeApiClient()
|
|
98
|
-
const runtime = await
|
|
98
|
+
const [runtime] = await getMatchingRuntime(client, positionals)
|
|
99
99
|
const { production, services } = await client.getRuntimeServices(runtime.pid)
|
|
100
100
|
await client.close()
|
|
101
101
|
|
|
@@ -122,13 +122,13 @@ export async function servicesCommand (logger, args) {
|
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
export async function envCommand (logger, args) {
|
|
125
|
-
const { values, positionals } = parseArgs(args, { table: { type: 'boolean', short: 't' } }, false)
|
|
126
|
-
|
|
127
|
-
const service = positionals[1]
|
|
125
|
+
const { values, positionals: allPositionals } = parseArgs(args, { table: { type: 'boolean', short: 't' } }, false)
|
|
128
126
|
|
|
127
|
+
let service
|
|
129
128
|
try {
|
|
130
129
|
const client = new RuntimeApiClient()
|
|
131
|
-
const runtime = await
|
|
130
|
+
const [runtime, positionals] = await getMatchingRuntime(client, allPositionals)
|
|
131
|
+
service = positionals[0]
|
|
132
132
|
|
|
133
133
|
const env = service
|
|
134
134
|
? await client.getRuntimeServiceEnv(runtime.pid, service)
|
|
@@ -166,12 +166,13 @@ export async function envCommand (logger, args) {
|
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
export async function configCommand (logger, args) {
|
|
169
|
-
const { positionals } = parseArgs(args, {}, false)
|
|
170
|
-
const service = positionals[1]
|
|
169
|
+
const { positionals: allPositionals } = parseArgs(args, {}, false)
|
|
171
170
|
|
|
171
|
+
let service
|
|
172
172
|
try {
|
|
173
173
|
const client = new RuntimeApiClient()
|
|
174
|
-
const runtime = await
|
|
174
|
+
const [runtime, positionals] = await getMatchingRuntime(client, allPositionals)
|
|
175
|
+
service = positionals[0]
|
|
175
176
|
|
|
176
177
|
const config = service
|
|
177
178
|
? await client.getRuntimeServiceConfig(runtime.pid, service)
|
package/lib/utils.js
CHANGED
|
@@ -5,10 +5,12 @@ import {
|
|
|
5
5
|
loadConfig as pltConfigLoadConfig,
|
|
6
6
|
Store
|
|
7
7
|
} from '@platformatic/config'
|
|
8
|
+
import { errors } from '@platformatic/control'
|
|
8
9
|
import { platformaticRuntime, buildRuntime as pltBuildRuntime } from '@platformatic/runtime'
|
|
9
10
|
import { bgGreen, black, bold } from 'colorette'
|
|
10
11
|
import { readFile, writeFile } from 'node:fs/promises'
|
|
11
12
|
import { dirname, resolve } from 'node:path'
|
|
13
|
+
import { existsSync } from 'node:fs'
|
|
12
14
|
import { parseArgs as nodeParseArgs } from 'node:util'
|
|
13
15
|
import { pino } from 'pino'
|
|
14
16
|
import pinoPretty from 'pino-pretty'
|
|
@@ -85,16 +87,58 @@ export function parseArgs (args, options, stopAtFirstPositional = true) {
|
|
|
85
87
|
}
|
|
86
88
|
}
|
|
87
89
|
|
|
88
|
-
export function
|
|
89
|
-
|
|
90
|
-
|
|
90
|
+
export function getPackageManager (root) {
|
|
91
|
+
if (existsSync(resolve(root, 'pnpm-lock.yaml'))) {
|
|
92
|
+
return 'pnpm'
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (existsSync(resolve(root, 'yarn.lock'))) {
|
|
96
|
+
return 'yarn'
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return 'npm'
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function getRoot (positionals) {
|
|
103
|
+
let root = process.cwd()
|
|
104
|
+
|
|
105
|
+
if (positionals?.[0]) {
|
|
106
|
+
root = resolve(root, positionals[0])
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return root
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export async function getMatchingRuntime (client, positionals) {
|
|
113
|
+
const runtimes = await client.getRuntimes()
|
|
114
|
+
const pidOrName = positionals[0]
|
|
115
|
+
let runtime
|
|
91
116
|
|
|
117
|
+
// We have an argument to match
|
|
92
118
|
if (pidOrName) {
|
|
93
|
-
|
|
94
|
-
|
|
119
|
+
if (pidOrName.match(/^\d+$/)) {
|
|
120
|
+
const pid = parseInt(pidOrName)
|
|
121
|
+
runtime = runtimes.find(runtime => runtime.pid === pid)
|
|
122
|
+
} else {
|
|
123
|
+
runtime = runtimes.find(runtime => runtime.packageName === pidOrName)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (runtime) {
|
|
127
|
+
return [runtime, positionals.slice(1)]
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// We found no match, find any runtime whose running directory is the current one
|
|
132
|
+
if (!runtime) {
|
|
133
|
+
runtime = runtimes.find(runtime => runtime.cwd === process.cwd())
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (!runtime) {
|
|
137
|
+
throw errors.RuntimeNotFound()
|
|
95
138
|
}
|
|
139
|
+
/* c8 ignore next 2 */
|
|
96
140
|
|
|
97
|
-
return
|
|
141
|
+
return [runtime, positionals]
|
|
98
142
|
}
|
|
99
143
|
|
|
100
144
|
export function serviceToEnvVariable (service) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wattpm",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.23.0",
|
|
4
4
|
"description": "The Node.js Application Server",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -35,21 +35,21 @@
|
|
|
35
35
|
"pino-pretty": "^13.0.0",
|
|
36
36
|
"split2": "^4.2.0",
|
|
37
37
|
"table": "^6.8.2",
|
|
38
|
-
"@platformatic/
|
|
39
|
-
"@platformatic/
|
|
40
|
-
"@platformatic/
|
|
41
|
-
"@platformatic/runtime": "2.
|
|
42
|
-
"@platformatic/
|
|
38
|
+
"@platformatic/basic": "2.23.0",
|
|
39
|
+
"@platformatic/control": "2.23.0",
|
|
40
|
+
"@platformatic/config": "2.23.0",
|
|
41
|
+
"@platformatic/runtime": "2.23.0",
|
|
42
|
+
"@platformatic/utils": "2.23.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"borp": "^0.19.0",
|
|
46
46
|
"eslint": "9",
|
|
47
|
-
"inspector-client": "^0.
|
|
47
|
+
"inspector-client": "^0.2.0",
|
|
48
48
|
"json-schema-to-typescript": "^15.0.0",
|
|
49
|
-
"neostandard": "^0.
|
|
49
|
+
"neostandard": "^0.12.0",
|
|
50
50
|
"typescript": "^5.5.4",
|
|
51
51
|
"undici": "^7.0.0",
|
|
52
|
-
"@platformatic/node": "2.
|
|
52
|
+
"@platformatic/node": "2.23.0"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
55
|
"test": "npm run lint && borp --concurrency=1 --timeout=300000",
|
package/schema.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$id": "https://schemas.platformatic.dev/wattpm/2.
|
|
2
|
+
"$id": "https://schemas.platformatic.dev/wattpm/2.23.0.json",
|
|
3
3
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
4
|
"type": "object",
|
|
5
5
|
"properties": {
|
|
@@ -192,6 +192,10 @@
|
|
|
192
192
|
"url": {
|
|
193
193
|
"type": "string"
|
|
194
194
|
},
|
|
195
|
+
"gitBranch": {
|
|
196
|
+
"type": "string",
|
|
197
|
+
"default": "main"
|
|
198
|
+
},
|
|
195
199
|
"useHttp": {
|
|
196
200
|
"type": "boolean"
|
|
197
201
|
},
|
|
@@ -296,6 +300,19 @@
|
|
|
296
300
|
}
|
|
297
301
|
},
|
|
298
302
|
"additionalProperties": false
|
|
303
|
+
},
|
|
304
|
+
"env": {
|
|
305
|
+
"type": "object",
|
|
306
|
+
"additionalProperties": {
|
|
307
|
+
"type": "string"
|
|
308
|
+
}
|
|
309
|
+
},
|
|
310
|
+
"envfile": {
|
|
311
|
+
"type": "string"
|
|
312
|
+
},
|
|
313
|
+
"sourceMaps": {
|
|
314
|
+
"type": "boolean",
|
|
315
|
+
"default": false
|
|
299
316
|
}
|
|
300
317
|
}
|
|
301
318
|
}
|
|
@@ -345,6 +362,10 @@
|
|
|
345
362
|
"url": {
|
|
346
363
|
"type": "string"
|
|
347
364
|
},
|
|
365
|
+
"gitBranch": {
|
|
366
|
+
"type": "string",
|
|
367
|
+
"default": "main"
|
|
368
|
+
},
|
|
348
369
|
"useHttp": {
|
|
349
370
|
"type": "boolean"
|
|
350
371
|
},
|
|
@@ -449,6 +470,19 @@
|
|
|
449
470
|
}
|
|
450
471
|
},
|
|
451
472
|
"additionalProperties": false
|
|
473
|
+
},
|
|
474
|
+
"env": {
|
|
475
|
+
"type": "object",
|
|
476
|
+
"additionalProperties": {
|
|
477
|
+
"type": "string"
|
|
478
|
+
}
|
|
479
|
+
},
|
|
480
|
+
"envfile": {
|
|
481
|
+
"type": "string"
|
|
482
|
+
},
|
|
483
|
+
"sourceMaps": {
|
|
484
|
+
"type": "boolean",
|
|
485
|
+
"default": false
|
|
452
486
|
}
|
|
453
487
|
}
|
|
454
488
|
}
|
|
@@ -1113,6 +1147,16 @@
|
|
|
1113
1147
|
"resolvedServicesBasePath": {
|
|
1114
1148
|
"type": "string",
|
|
1115
1149
|
"default": "external"
|
|
1150
|
+
},
|
|
1151
|
+
"env": {
|
|
1152
|
+
"type": "object",
|
|
1153
|
+
"additionalProperties": {
|
|
1154
|
+
"type": "string"
|
|
1155
|
+
}
|
|
1156
|
+
},
|
|
1157
|
+
"sourceMaps": {
|
|
1158
|
+
"type": "boolean",
|
|
1159
|
+
"default": false
|
|
1116
1160
|
}
|
|
1117
1161
|
},
|
|
1118
1162
|
"anyOf": [
|