@platformatic/control 3.0.0-alpha.1 → 3.0.0-alpha.2

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/control.js DELETED
@@ -1,85 +0,0 @@
1
- #! /usr/bin/env node
2
-
3
- const { join } = require('node:path')
4
- const { parseArgs } = require('node:util')
5
- const commist = require('commist')
6
- const helpMe = require('help-me')
7
-
8
- const runtimeMetricsCommand = require('./lib/metrics')
9
- const getRuntimesCommand = require('./lib/ps')
10
- const getRuntimesEnvCommand = require('./lib/env')
11
- const getRuntimeServicesCommand = require('./lib/services')
12
- const getRuntimeConfigCommand = require('./lib/config')
13
- const stopRuntimeCommand = require('./lib/stop')
14
- const reloadRuntimeCommand = require('./lib/reload')
15
- const restartRuntimeCommand = require('./lib/restart')
16
- const injectRuntimeCommand = require('./lib/inject')
17
- const streamRuntimeLogsCommand = require('./lib/logs')
18
-
19
- const help = helpMe({
20
- dir: join(__dirname, 'help'),
21
- ext: '.txt',
22
- })
23
-
24
- const program = commist({ maxDistance: 2 })
25
-
26
- program.register('ps', wrapCommand(getRuntimesCommand))
27
- program.register('stop', wrapCommand(stopRuntimeCommand))
28
- program.register('reload', wrapCommand(reloadRuntimeCommand))
29
- program.register('restart', wrapCommand(restartRuntimeCommand))
30
- program.register('logs', wrapCommand(streamRuntimeLogsCommand))
31
- program.register('metrics', wrapCommand(runtimeMetricsCommand))
32
- program.register('env', wrapCommand(getRuntimesEnvCommand))
33
- program.register('services', wrapCommand(getRuntimeServicesCommand))
34
- program.register('config', wrapCommand(getRuntimeConfigCommand))
35
- program.register('inject', wrapCommand(injectRuntimeCommand))
36
- program.register('help', help.toStdout)
37
-
38
- async function runControl (argv) {
39
- if (argv.length === 0) {
40
- help.toStdout()
41
- return {}
42
- }
43
-
44
- const args = parseArgs({
45
- args: argv,
46
- options: {
47
- version: { type: 'boolean', short: 'v' },
48
- },
49
- strict: false,
50
- }).values
51
-
52
- if (args.version && argv[0] !== 'inject') {
53
- const packageJson = require(join(__dirname, 'package.json'))
54
- console.log(packageJson.version)
55
- process.exit(0)
56
- }
57
-
58
- const output = await program.parseAsync(argv)
59
- return { output }
60
- }
61
-
62
- if (require.main === module) {
63
- runControl(process.argv.slice(2))
64
- }
65
-
66
- function wrapCommand (fn) {
67
- return async function (...args) {
68
- try {
69
- return await fn(...args)
70
- } catch (err) {
71
- console.log(err.message)
72
- }
73
- }
74
- }
75
-
76
- module.exports = {
77
- runControl,
78
- getRuntimesCommand,
79
- getRuntimesEnvCommand,
80
- getRuntimeServicesCommand,
81
- stopRuntimeCommand,
82
- restartRuntimeCommand,
83
- injectRuntimeCommand,
84
- streamRuntimeLogsCommand,
85
- }
package/help/config.txt DELETED
@@ -1,16 +0,0 @@
1
- Prints runtime or runtime service config file
2
-
3
- ``` bash
4
- $ platformatic ctl config -n runtime-name
5
- ```
6
-
7
- Options:
8
-
9
- * `-p, --pid <number>` - The process id of the runtime.
10
- * `-n, --name <string>` - The name of the runtime.
11
-
12
- The `config` command uses the Platformatic Runtime Management API. To enable it
13
- set the `managementApi` option to `true` in the runtime configuration file.
14
-
15
- To get the list of runtimes with enabled management API use the
16
- `platformatic ctl ps` command.
package/help/env.txt DELETED
@@ -1,16 +0,0 @@
1
- Lists platformatic runtime application environment variables
2
-
3
- ``` bash
4
- $ platformatic ctl env -n runtime-name
5
- ```
6
-
7
- Options:
8
-
9
- * `-p, --pid <number>` - The process id of the runtime.
10
- * `-n, --name <string>` - The name of the runtime.
11
-
12
- The `env` command uses the Platformatic Runtime Management API. To enable it
13
- set the `managementApi` option to `true` in the runtime configuration file.
14
-
15
- To get the list of runtimes with enabled management API use the
16
- `platformatic ctl ps` command.
package/help/help.txt DELETED
@@ -1,11 +0,0 @@
1
- Available commands:
2
-
3
- * `ps` - lists all platformatic runtime applications.
4
- * `stop` - stops a platformatic runtime application.
5
- * `restart` - restarts all platformatic runtime services.
6
- * `reload` - reloads all platformatic runtime services.
7
- * `services` - lists the runtime services.
8
- * `config` - prints runtime or runtime service config file.
9
- * `env` - lists the runtime environment variables.
10
- * `logs` - shows the runtime logs.
11
- * `inject` - injects a request to the runtime service.
package/help/inject.txt DELETED
@@ -1,30 +0,0 @@
1
- Injects a request to the platformatic runtime service.
2
-
3
- ``` bash
4
- $ platformatic ctl inject -n runtime-name /hello
5
- -X POST
6
- -H "Content-Type: application/json"
7
- -d '{"key": "value"}'
8
- ```
9
-
10
- Options:
11
-
12
- * `-p, --pid <number>` - The process id of the runtime.
13
- * `-n, --name <string>` - The name of the runtime.
14
- * `-s, --service <string>` - The name of the runtime service.
15
- * `-X, --request <string>` - The request HTTP method. Default is `GET`.
16
- * `-H, --header <string>` - The request header. Can be used multiple times.
17
- * `-d, --data <string>` - The request data.
18
- * `-i, --include <boolean>` - Include the response headers in the output. Default is `false`.
19
- * `-v, --verbose <boolean>` - Make the operation more talkative. Default is `false`.
20
- * `-o, --output <file>` - Write the response to the specified file.
21
-
22
- The `inject` command sends a request to the runtime service and prints the
23
- response to the standard output. If the `--service` option is not specified the
24
- request is sent to the runtime entrypoint.
25
-
26
- The `inject` command uses the Platformatic Runtime Management API. To enable it
27
- set the `managementApi` option to `true` in the runtime configuration file.
28
-
29
- To get the list of runtimes with enabled management API use the
30
- `platformatic ctl ps` command.
package/help/logs.txt DELETED
@@ -1,21 +0,0 @@
1
- Streams logs from the platformatic runtime application.
2
-
3
- ``` bash
4
- $ platformatic ctl logs -n runtime-name
5
- ```
6
-
7
- Options:
8
-
9
- * `-p, --pid <number>` - The process id of the runtime.
10
- * `-n, --name <string>` - The name of the runtime.
11
- * `-l, --level <string>` - The pino log level to stream. Default is `info`.
12
- * `-s, --service <string>` - The name of the service to stream logs from.
13
- * `--pretty <boolean>` - Pretty print the logs. Default is `true`.
14
-
15
- If `--service` is not specified, the command will stream logs from all services.
16
-
17
- The `logs` command uses the Platformatic Runtime Management API. To enable it
18
- set the `managementApi` option to `true` in the runtime configuration file.
19
-
20
- To get the list of runtimes with enabled management API use the
21
- `platformatic ctl ps` command.
package/help/metrics.txt DELETED
@@ -1,14 +0,0 @@
1
- Get metrics from the platformatic runtime application.
2
-
3
- ``` bash
4
- $ platformatic ctl metrics
5
- ```
6
-
7
- Options:
8
-
9
- * `-p, --pid <number>` - The process id of the runtime.
10
- * `-f, --format <string>` - The format of the metrics, which should be either `text` or `json` (default to `json`).
11
-
12
- If `--pid` is not specified, the command will get metrics from the first available matching runtime.
13
-
14
- To see the list of all available control commands, run `platformatic ctl help`.
package/help/ps.txt DELETED
@@ -1,10 +0,0 @@
1
- Lists all running platformatic runtime applications.
2
-
3
- ``` bash
4
- $ platformatic ctl ps
5
- ```
6
-
7
- To see the list of all available control commands, run `platformatic ctl help`.
8
-
9
- The `ps` command uses the Platformatic Runtime Management API. To enable it
10
- set the `managementApi` option to `true` in the runtime configuration file.
package/help/reload.txt DELETED
@@ -1,19 +0,0 @@
1
- Reloads a platformatic runtime application.
2
-
3
- ``` bash
4
- $ platformatic ctl reload -n runtime-name
5
- ```
6
-
7
- Options:
8
-
9
- * `-p, --pid <number>` - The process id of the runtime to reload.
10
- * `-n, --name <string>` - The name of the runtime to reload.
11
-
12
- The difference between `reload` and `restart` is that `reload` does not kill
13
- the runtime process. It stops and starts all the runtime services.
14
-
15
- The `reload` command uses the Platformatic Runtime Management API. To enable it
16
- set the `managementApi` option to `true` in the runtime configuration file.
17
-
18
- To get the list of runtimes with enabled management API use the
19
- `platformatic ctl ps` command.
package/help/restart.txt DELETED
@@ -1,16 +0,0 @@
1
- Restarts a platformatic runtime application.
2
-
3
- ``` bash
4
- $ platformatic ctl restart -n runtime-name
5
- ```
6
-
7
- Options:
8
-
9
- * `-p, --pid <number>` - The process id of the runtime to restart.
10
- * `-n, --name <string>` - The name of the runtime to restart.
11
-
12
- The `restart` command uses the Platformatic Runtime Management API. To enable it
13
- set the `managementApi` option to `true` in the runtime configuration file.
14
-
15
- To get the list of runtimes with enabled management API use the
16
- `platformatic ctl ps` command.
package/help/services.txt DELETED
@@ -1,16 +0,0 @@
1
- Lists the platformatic runtime services.
2
-
3
- ``` bash
4
- $ platformatic ctl services -n runtime-name
5
- ```
6
-
7
- Options:
8
-
9
- * `-p, --pid <number>` - The process id of the runtime.
10
- * `-n, --name <string>` - The name of the runtime.
11
-
12
- The `services` command uses the Platformatic Runtime Management API. To enable it
13
- set the `managementApi` option to `true` in the runtime configuration file.
14
-
15
- To get the list of runtimes with enabled management API use the
16
- `platformatic ctl ps` command.
package/help/stop.txt DELETED
@@ -1,16 +0,0 @@
1
- Stops a platformatic runtime application.
2
-
3
- ``` bash
4
- $ platformatic ctl stop -n runtime-name
5
- ```
6
-
7
- Options:
8
-
9
- * `-p, --pid <number>` - The process id of the runtime to stop.
10
- * `-n, --name <string>` - The name of the runtime to stop.
11
-
12
- The `stop` command uses the Platformatic Runtime Management API. To enable it
13
- set the `managementApi` option to `true` in the runtime configuration file.
14
-
15
- To get the list of runtimes with enabled management API use the
16
- `platformatic ctl ps` command.
package/index.d.ts DELETED
@@ -1,151 +0,0 @@
1
- import { ChildProcess } from "node:child_process";
2
- import BodyReadable from "undici/types/readable";
3
- import { FastifyError } from "@fastify/error";
4
- import { Readable } from "node:stream";
5
- import { HttpHeader } from 'fastify/types/utils'
6
- import WebSocket from "ws";
7
-
8
- declare namespace control {
9
- class WebSocketStream extends Readable {
10
- constructor(url: string);
11
- ws: WebSocket;
12
- }
13
-
14
- interface Runtime {
15
- pid: number,
16
- cwd: string,
17
- argv: string[],
18
- uptimeSeconds: number,
19
- execPath: string,
20
- nodeVersion: string,
21
- projectDir: string,
22
- packageName: string | null,
23
- packageVersion: string | null,
24
- url: string | null,
25
- platformaticVersion: string
26
- }
27
-
28
- interface RuntimeServices {
29
- entrypoint: string,
30
- production: boolean,
31
- services: ({
32
- id: string;
33
- type: string;
34
- status: string;
35
- version: string;
36
- localUrl: string;
37
- entrypoint: boolean;
38
- url?: string;
39
- workers?: number;
40
- dependencies: {
41
- id: string;
42
- url: string;
43
- local: boolean;
44
- }[];
45
- } | {
46
- id: string;
47
- status: string;
48
- })[]
49
- }
50
-
51
- interface MetricValue {
52
- value: number,
53
- labels: {
54
- route?: string,
55
- quantile?: number,
56
- method?: string,
57
- status_code?: number,
58
- telemetry_id?: string,
59
- type?: string,
60
- space?: string,
61
- version?: string,
62
- major?: number,
63
- minor?: number,
64
- patch?: number,
65
- le?: number | string,
66
- kind?: string,
67
- serviceId: string,
68
- workerId?: number
69
- },
70
- metricName?: string,
71
- exemplar?: unknown
72
- }
73
-
74
- interface Metric {
75
- help: string,
76
- name: string,
77
- type: string,
78
- values: MetricValue[],
79
- aggregator: string
80
- }
81
-
82
- export class RuntimeApiClient {
83
- getMatchingRuntime(options?: { pid?: string; name?: string }): Promise<Runtime>;
84
- getRuntimes(): Promise<Runtime[]>;
85
- getRuntimeMetadata(pid: number): Promise<Runtime>;
86
- getRuntimeServices(pid: number): Promise<RuntimeServices>;
87
- getRuntimeConfig(pid: number): Promise<void>;
88
- getRuntimeServiceConfig(pid: number, serviceId?: string): Promise<void>;
89
- getRuntimeEnv(pid: number): Promise<void>;
90
- getRuntimeOpenapi(pid: number, serviceId: string): Promise<unknown>;
91
- getRuntimeServiceEnv(pid: number, serviceId: string): Promise<unknown>;
92
- reloadRuntime(pid: number, options?: object): Promise<ChildProcess>;
93
- restartRuntime(pid: number): Promise<void>;
94
- stopRuntime(pid: number): Promise<void>;
95
- getRuntimeMetrics<T extends { format?: "text" | "json" }>(
96
- pid: number,
97
- options?: T
98
- ): Promise<T extends { format: "text" } ? string : Metric[]>;
99
- getRuntimeLiveMetricsStream(pid: number): WebSocketStream;
100
- getRuntimeLiveLogsStream(
101
- pid: number,
102
- startLogIndex?: number
103
- ): WebSocketStream;
104
- getRuntimeLogsStream(
105
- pid: number,
106
- logsId: string,
107
- options?: { runtimePID?: number }
108
- ): Promise<BodyReadable>;
109
- getRuntimeAllLogsStream(
110
- pid: number,
111
- options?: { runtimePID?: number }
112
- ): Promise<BodyReadable>;
113
- getRuntimeLogIndexes(
114
- pid: number,
115
- options?: { all?: boolean }
116
- ): Promise<unknown>;
117
- injectRuntime(
118
- pid: number,
119
- serviceId: string,
120
- options: {
121
- url: string;
122
- method: string;
123
- headers: object;
124
- body: unknown;
125
- }
126
- ): Promise<{ headers: Record<string, HttpHeader>, statusCode: number, body: unknown }>;
127
- close(): Promise<void>;
128
- }
129
-
130
- export module errors {
131
- export const RuntimeNotFound: FastifyError;
132
- export const ServiceNotFound: FastifyError;
133
- export const MissingRequestURL: FastifyError;
134
- export const FailedToGetRuntimeMetadata: FastifyError;
135
- export const FailedToGetRuntimeServices: FastifyError;
136
- export const FailedToGetRuntimeEnv: FastifyError;
137
- export const FailedToGetRuntimeOpenapi: FastifyError;
138
- export const FailedToStreamRuntimeLogs: FastifyError;
139
- export const FailedToStopRuntime: FastifyError;
140
- export const FailedToReloadRuntime: FastifyError;
141
- export const FailedToGetRuntimeConfig: FastifyError;
142
- export const FailedToGetRuntimeServiceEnv: FastifyError;
143
- export const FailedToGetRuntimeServiceConfig: FastifyError;
144
- export const FailedToGetRuntimeHistoryLogs: FastifyError;
145
- export const FailedToGetRuntimeAllLogs: FastifyError;
146
- export const FailedToGetRuntimeLogIndexes: FastifyError;
147
- export const FailedToGetRuntimeMetrics: FastifyError;
148
- }
149
- }
150
-
151
- export = control;
package/index.js DELETED
@@ -1,9 +0,0 @@
1
- 'use strict'
2
-
3
- const RuntimeApiClient = require('./lib/runtime-api-client')
4
- const errors = require('./lib/errors')
5
-
6
- module.exports = {
7
- RuntimeApiClient,
8
- errors
9
- }
package/index.test-d.ts DELETED
@@ -1,63 +0,0 @@
1
- import { expectAssignable, expectError, expectType } from 'tsd'
2
- import { errors, Metric, Runtime, RuntimeApiClient, RuntimeServices } from '.'
3
- import { FastifyError } from '@fastify/error'
4
-
5
- // RuntimeApiClient
6
- let runtime = {} as Runtime
7
- let service = {} as RuntimeServices
8
- let metric = {} as Metric
9
- const api = new RuntimeApiClient()
10
- expectType<Promise<Runtime>>(api.getMatchingRuntime())
11
- expectType<Promise<Metric[]>>(api.getRuntimeMetrics(runtime.pid))
12
- expectType<Promise<Metric[]>>(api.getRuntimeMetrics(runtime.pid, {}))
13
- expectType<Promise<Metric[]>>(api.getRuntimeMetrics(runtime.pid, { format: 'json' }))
14
- expectType<Promise<string>>(api.getRuntimeMetrics(runtime.pid, { format: 'text' }))
15
- expectType<Promise<Runtime[]>>(api.getRuntimes())
16
-
17
- async () => {
18
- const result = await api.injectRuntime(0, '', { body: {}, headers: {}, method: 'PUT', url: '/foo' })
19
-
20
- expectType<unknown>(result.body)
21
- expectType<number>(result.statusCode)
22
- expectAssignable<Record<string, unknown>>(result.headers)
23
- return result
24
- }
25
-
26
- const [service1] = service.services
27
- expectType<Promise<unknown>>(api.getRuntimeOpenapi(runtime.pid, service1.id))
28
- expectType<string[]>(runtime.argv)
29
- expectType<number>(runtime.uptimeSeconds)
30
- expectType<string | null>(runtime.packageVersion)
31
- expectType<Promise<{
32
- entrypoint: string,
33
- production: boolean,
34
- services: RuntimeServices['services']
35
- }>>(api.getRuntimeServices(45))
36
- expectType<string>(service1.id)
37
- expectType<string>(service1.status)
38
-
39
- if ('url' in service1) {
40
- expectType<string | undefined>(service1.url)
41
- expectType<number | undefined>(service1.workers)
42
- }
43
-
44
- expectType<string>(metric.aggregator)
45
- expectType<string>(metric.values[0].labels.serviceId)
46
- expectType<number | undefined>(metric.values[0].labels?.quantile)
47
- expectType<string | undefined>(metric.values[0].labels?.route)
48
- expectType<string | undefined>(metric.values[0].labels?.method)
49
- expectType<number | undefined>(metric.values[0].labels?.status_code)
50
- expectType<string | undefined>(metric.values[0].labels?.telemetry_id)
51
- expectType<number | undefined>(metric.values[0].labels?.workerId)
52
- expectType<string | undefined>(metric.values[0].metricName)
53
- expectType<unknown | undefined>(metric.values[0].exemplar)
54
- expectType<Promise<void>>(api.close())
55
-
56
- // errors
57
- expectType<FastifyError>(errors.FailedToGetRuntimeAllLogs)
58
- expectType<FastifyError>(errors.FailedToGetRuntimeConfig)
59
- expectType<FastifyError>(errors.FailedToGetRuntimeEnv)
60
- expectType<FastifyError>(errors.FailedToGetRuntimeOpenapi)
61
- expectType<FastifyError>(errors.FailedToGetRuntimeHistoryLogs)
62
- expectError<string>(errors.FailedToGetRuntimeHistoryLogs)
63
- expectError<number>(errors.FailedToGetRuntimeHistoryLogs)
package/lib/config.js DELETED
@@ -1,29 +0,0 @@
1
- 'use strict'
2
-
3
- const { parseArgs } = require('node:util')
4
- const RuntimeApiClient = require('./runtime-api-client')
5
-
6
- async function getRuntimeConfigCommand (argv) {
7
- const args = parseArgs({
8
- args: argv,
9
- options: {
10
- pid: { type: 'string', short: 'p' },
11
- name: { type: 'string', short: 'n' },
12
- service: { type: 'string', short: 's' },
13
- },
14
- strict: false,
15
- }).values
16
-
17
- const client = new RuntimeApiClient()
18
- const runtime = await client.getMatchingRuntime(args)
19
-
20
- const config = args.service
21
- ? await client.getRuntimeServiceConfig(runtime.pid, args.service)
22
- : await client.getRuntimeConfig(runtime.pid)
23
-
24
- console.log(JSON.stringify(config, null, 2))
25
-
26
- await client.close()
27
- }
28
-
29
- module.exports = getRuntimeConfigCommand
package/lib/env.js DELETED
@@ -1,29 +0,0 @@
1
- 'use strict'
2
-
3
- const { parseArgs } = require('node:util')
4
- const RuntimeApiClient = require('./runtime-api-client')
5
-
6
- async function getRuntimeEnvCommand (argv) {
7
- const args = parseArgs({
8
- args: argv,
9
- options: {
10
- pid: { type: 'string', short: 'p' },
11
- name: { type: 'string', short: 'n' },
12
- },
13
- strict: false,
14
- }).values
15
-
16
- const client = new RuntimeApiClient()
17
- const runtime = await client.getMatchingRuntime(args)
18
-
19
- const runtimeEnv = await client.getRuntimeEnv(runtime.pid)
20
- let output = ''
21
- for (const key in runtimeEnv) {
22
- output += `${key}=${runtimeEnv[key]}\n`
23
- }
24
- console.log(output)
25
-
26
- await client.close()
27
- }
28
-
29
- module.exports = getRuntimeEnvCommand
package/lib/inject.js DELETED
@@ -1,102 +0,0 @@
1
- 'use strict'
2
-
3
- const { parseArgs } = require('node:util')
4
- const { writeFile } = require('node:fs/promises')
5
- const RuntimeApiClient = require('./runtime-api-client')
6
- const errors = require('./errors')
7
-
8
- async function injectRuntimeCommand (argv) {
9
- const { values: args, positionals } = parseArgs({
10
- args: argv,
11
- options: {
12
- pid: { type: 'string', short: 'p' },
13
- name: { type: 'string', short: 'n' },
14
- service: { type: 'string', short: 's' },
15
- request: { type: 'string', short: 'X', default: 'GET' },
16
- header: { type: 'string', short: 'H', multiple: true },
17
- data: { type: 'string', short: 'd' },
18
- include: { type: 'boolean', short: 'i', default: false },
19
- verbose: { type: 'boolean', short: 'v', default: false },
20
- output: { type: 'string', short: 'o' },
21
- },
22
- strict: false,
23
- })
24
-
25
- const client = new RuntimeApiClient()
26
- const runtime = await client.getMatchingRuntime(args)
27
-
28
- let serviceId = args.service
29
- if (!serviceId) {
30
- const runtimeServices = await client.getRuntimeServices(runtime.pid)
31
- serviceId = runtimeServices.entrypoint
32
- }
33
-
34
- if (positionals.length === 0) {
35
- throw errors.MissingRequestURL()
36
- }
37
-
38
- let result = ''
39
-
40
- const fullUrl = new URL(positionals[0], runtime.url)
41
- const injectPath = fullUrl.href.slice(runtime.url.length)
42
-
43
- const method = args.request
44
- const body = args.data
45
-
46
- if (args.verbose) {
47
- result += `> ${method} ${injectPath} HTTP/1.1\n`
48
- }
49
-
50
- const headers = {}
51
- for (const header of args.header || []) {
52
- const [name, value] = header.split(':')
53
- headers[name] = value
54
-
55
- if (args.verbose) {
56
- result += `> ${name}: ${value}\n`
57
- }
58
- }
59
-
60
- if (args.verbose && args.header.length > 0) {
61
- result += '> \n'
62
- }
63
-
64
- const injectOptions = { url: injectPath, method, headers, body }
65
-
66
- const response = await client.injectRuntime(runtime.pid, serviceId, injectOptions)
67
-
68
- if (args.verbose) {
69
- result += `< HTTP/1.1 ${response.statusCode}\n`
70
- }
71
- if (args.include) {
72
- result += `HTTP/1.1 ${response.statusCode}\n`
73
- }
74
-
75
- for (const header in response.headers) {
76
- if (args.verbose) {
77
- result += `< ${header}: ${response.headers[header]}\n`
78
- }
79
- if (args.include) {
80
- result += `${header}: ${response.headers[header]}\n`
81
- }
82
- }
83
-
84
- if (args.verbose) {
85
- result += '< \n'
86
- }
87
- if (args.include) {
88
- result += '\n'
89
- }
90
-
91
- result += await response.body.text()
92
-
93
- if (args.output) {
94
- await writeFile(args.output, result)
95
- } else {
96
- console.log(result)
97
- }
98
-
99
- await client.close()
100
- }
101
-
102
- module.exports = injectRuntimeCommand