@devicecloud.dev/dcd 5.16.0-beta.1 → 5.16.0-beta.3
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/README.md +3 -3
- package/dist/commands/artifacts.js +2 -1
- package/dist/commands/cloud.js +1 -4
- package/dist/commands/live.js +2 -2
- package/dist/commands/login.js +2 -2
- package/dist/commands/status.js +0 -1
- package/dist/mcp/context.js +2 -1
- package/dist/methods.js +0 -1
- package/dist/services/execution-plan.service.js +0 -2
- package/dist/services/moropo.service.js +0 -1
- package/dist/services/results-polling.service.js +0 -2
- package/dist/services/test-submission.service.js +0 -1
- package/dist/utils/cli.js +3 -7
- package/dist/utils/config-store.js +0 -2
- package/dist/utils/device-output.js +2 -2
- package/dist/utils/progress.js +0 -3
- package/dist/utils/styling.d.ts +21 -8
- package/dist/utils/styling.js +82 -23
- package/package.json +3 -12
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ On Windows:
|
|
|
16
16
|
irm https://get.devicecloud.dev/install.ps1 | iex
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
Or via npm if you already have Node 22+:
|
|
19
|
+
Or via npm if you already have Node 22.8+:
|
|
20
20
|
|
|
21
21
|
```sh-session
|
|
22
22
|
$ npm install -g @devicecloud.dev/dcd
|
|
@@ -105,7 +105,7 @@ $ claude mcp add --scope user devicecloud -- dcd mcp
|
|
|
105
105
|
$ codex mcp add devicecloud -- dcd mcp
|
|
106
106
|
```
|
|
107
107
|
|
|
108
|
-
If you use the npm package instead of the standalone binary, the command is `npx` with `"args": ["-y", "@devicecloud.dev/dcd", "mcp"]`. That needs Node 22 or newer on the app's PATH, and it checks npm each time it starts.
|
|
108
|
+
If you use the npm package instead of the standalone binary, the command is `npx` with `"args": ["-y", "@devicecloud.dev/dcd", "mcp"]`. That needs Node 22.8 or newer on the app's PATH, and it checks npm each time it starts.
|
|
109
109
|
|
|
110
110
|
It signs in the same way as the CLI: with your `dcd login` session, which it renews as it runs, or with `DEVICE_CLOUD_API_KEY`. Point it at a non-prod environment with `DCD_API_URL` (https, or plain http to `localhost` only).
|
|
111
111
|
|
|
@@ -168,7 +168,7 @@ Run `npx e2e run` with `DEVICE_CLOUD_API_KEY` set. The provider uploads `appPath
|
|
|
168
168
|
|
|
169
169
|
## Development
|
|
170
170
|
|
|
171
|
-
Requires Node 22+ and [pnpm](https://pnpm.io). `pnpm install` builds the CLI and installs the git hooks automatically.
|
|
171
|
+
Requires Node 22.8+ and [pnpm](https://pnpm.io). `pnpm install` builds the CLI and installs the git hooks automatically.
|
|
172
172
|
|
|
173
173
|
```sh-session
|
|
174
174
|
$ pnpm install # install deps, build, set up git hooks
|
|
@@ -5,6 +5,7 @@ import { downloadsSucceeded, ReportDownloadService, reportFormatDeprecation, } f
|
|
|
5
5
|
import { resolveAuth } from '../utils/auth.js';
|
|
6
6
|
import { CliError, logger, validateEnum } from '../utils/cli.js';
|
|
7
7
|
import { resolveApiUrl } from '../utils/config-store.js';
|
|
8
|
+
import { forStderr } from '../utils/styling.js';
|
|
8
9
|
import { ui } from '../utils/ui.js';
|
|
9
10
|
const DOWNLOAD_OPTIONS = ['ALL', 'FAILED'];
|
|
10
11
|
const REPORT_OPTIONS = ['allure', 'html', 'html-detailed', 'junit'];
|
|
@@ -79,7 +80,7 @@ export const artifactsCommand = defineCommand({
|
|
|
79
80
|
// deprecation notice nor the API's submit warning reaches it.
|
|
80
81
|
const deprecation = reportFormatDeprecation(report);
|
|
81
82
|
if (deprecation) {
|
|
82
|
-
process.stderr.write(`${ui.deprecation(deprecation)}\n`);
|
|
83
|
+
process.stderr.write(`${forStderr(ui.deprecation(deprecation))}\n`);
|
|
83
84
|
}
|
|
84
85
|
const auth = await resolveAuth({ apiKeyFlag });
|
|
85
86
|
if (downloadArtifacts && report) {
|
package/dist/commands/cloud.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable complexity */
|
|
2
1
|
import { defineCommand } from 'citty';
|
|
3
2
|
import { existsSync } from 'node:fs';
|
|
4
3
|
import * as path from 'node:path';
|
|
@@ -37,7 +36,6 @@ process.on('warning', (warning) => {
|
|
|
37
36
|
warning.message.includes('punycode')) {
|
|
38
37
|
return;
|
|
39
38
|
}
|
|
40
|
-
// eslint-disable-next-line no-console
|
|
41
39
|
console.warn(warning.stack ?? `${warning.name}: ${warning.message}`);
|
|
42
40
|
});
|
|
43
41
|
const DOWNLOAD_OPTIONS = ['ALL', 'FAILED'];
|
|
@@ -75,7 +73,6 @@ export const cloudCommand = defineCommand({
|
|
|
75
73
|
description: 'The flow file to run against the app, e.g. test.yaml',
|
|
76
74
|
},
|
|
77
75
|
},
|
|
78
|
-
// eslint-disable-next-line complexity
|
|
79
76
|
async run({ args, rawArgs }) {
|
|
80
77
|
const cliVersion = getCliVersion();
|
|
81
78
|
const deviceValidationService = new DeviceValidationService();
|
|
@@ -716,7 +713,7 @@ export const cloudCommand = defineCommand({
|
|
|
716
713
|
if (!results?.length) {
|
|
717
714
|
throw new CliError('No tests created: ' + message);
|
|
718
715
|
}
|
|
719
|
-
out(`${ui.success('Submitted')} ${colors.dim(message)}`);
|
|
716
|
+
out(message ? `${ui.success('Submitted')} ${colors.dim(message)}` : ui.success('Submitted'));
|
|
720
717
|
const testNames = results
|
|
721
718
|
.map((r) => r.test_file_name)
|
|
722
719
|
.sort((a, b) => a.localeCompare(b))
|
package/dist/commands/live.js
CHANGED
|
@@ -7,7 +7,7 @@ import { ApiGateway } from '../gateways/api-gateway.js';
|
|
|
7
7
|
import { resolveAuth } from '../utils/auth.js';
|
|
8
8
|
import { CliError, logger, validateEnum, wantsJson } from '../utils/cli.js';
|
|
9
9
|
import { resolveApiUrl } from '../utils/config-store.js';
|
|
10
|
-
import { colors, formatUrl } from '../utils/styling.js';
|
|
10
|
+
import { colors, formatUrl, forStderr } from '../utils/styling.js';
|
|
11
11
|
import { ui } from '../utils/ui.js';
|
|
12
12
|
const PLATFORM_OPTIONS = ['android', 'ios'];
|
|
13
13
|
/** Printed to stderr by every `dcd live` command. */
|
|
@@ -600,7 +600,7 @@ export const liveCommand = defineCommand({
|
|
|
600
600
|
subCommands,
|
|
601
601
|
// Runs before any subcommand. On stderr, so --json output is unchanged.
|
|
602
602
|
setup() {
|
|
603
|
-
process.stderr.write(`${LIVE_DEPRECATION}\n`);
|
|
603
|
+
process.stderr.write(`${forStderr(LIVE_DEPRECATION)}\n`);
|
|
604
604
|
},
|
|
605
605
|
// citty's runCommand does not early-return after dispatching to a
|
|
606
606
|
// subcommand — it still invokes the parent `run` afterwards. So when a
|
package/dist/commands/login.js
CHANGED
|
@@ -41,7 +41,7 @@ import { canPrompt } from '../utils/ci.js';
|
|
|
41
41
|
import { CliError, logger } from '../utils/cli.js';
|
|
42
42
|
import { readConfig, writeConfig } from '../utils/config-store.js';
|
|
43
43
|
import { fetchOrgs, selectOrg } from '../utils/orgs.js';
|
|
44
|
-
import { colors } from '../utils/styling.js';
|
|
44
|
+
import { colors, forStderr } from '../utils/styling.js';
|
|
45
45
|
import { ui } from '../utils/ui.js';
|
|
46
46
|
const LOGIN_TIMEOUT_MS = 10 * 60 * 1000;
|
|
47
47
|
// 1s feels snappy after the user clicks "Authorize" in the browser. The api
|
|
@@ -90,7 +90,7 @@ export const loginCommand = defineCommand({
|
|
|
90
90
|
// stderr (the user still needs the URL) and stdout gets only the result.
|
|
91
91
|
const say = (m) => {
|
|
92
92
|
if (json)
|
|
93
|
-
process.stderr.write(`${m}\n`);
|
|
93
|
+
process.stderr.write(`${forStderr(m)}\n`);
|
|
94
94
|
else
|
|
95
95
|
logger.log(m);
|
|
96
96
|
};
|
package/dist/commands/status.js
CHANGED
|
@@ -52,7 +52,6 @@ export const statusCommand = defineCommand({
|
|
|
52
52
|
description: 'UUID of the upload to check status for',
|
|
53
53
|
},
|
|
54
54
|
},
|
|
55
|
-
// eslint-disable-next-line complexity
|
|
56
55
|
async run({ args }) {
|
|
57
56
|
const apiKeyFlag = args['api-key'];
|
|
58
57
|
const apiUrl = resolveApiUrl(args['api-url']);
|
package/dist/mcp/context.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { isAuthExpiring, resolveAuth } from '../utils/auth.js';
|
|
2
2
|
import { resolveApiUrl } from '../utils/config-store.js';
|
|
3
|
+
import { forStderr } from '../utils/styling.js';
|
|
3
4
|
/** Write a line to stderr. Safe under stdio transport; stdout is reserved. */
|
|
4
5
|
export function logStderr(message) {
|
|
5
|
-
process.stderr.write(`${message}\n`);
|
|
6
|
+
process.stderr.write(`${forStderr(message)}\n`);
|
|
6
7
|
}
|
|
7
8
|
let cached = null;
|
|
8
9
|
/**
|
package/dist/methods.js
CHANGED
|
@@ -70,7 +70,6 @@ export const compressFilesFromRelativePath = async (basePath, files, commonRoot)
|
|
|
70
70
|
return zipToBuffer(zipfile);
|
|
71
71
|
};
|
|
72
72
|
export const verifyAppZip = async (zipPath) => {
|
|
73
|
-
// eslint-disable-next-line new-cap
|
|
74
73
|
const zip = await new StreamZip.async({
|
|
75
74
|
file: zipPath,
|
|
76
75
|
storeEntries: true,
|
|
@@ -382,7 +382,6 @@ export async function plan(options) {
|
|
|
382
382
|
: new Error(`Workspace does not contain any Flows: ${path.resolve(normalizedInput)}`);
|
|
383
383
|
throw error;
|
|
384
384
|
}
|
|
385
|
-
// eslint-disable-next-line unicorn/no-array-reduce
|
|
386
385
|
const configPerFlowFile = unfilteredFlowFiles.reduce((acc, filePath) => {
|
|
387
386
|
const { config } = readTestYamlFileAsJson(filePath);
|
|
388
387
|
acc[filePath] = config;
|
|
@@ -408,7 +407,6 @@ export async function plan(options) {
|
|
|
408
407
|
throw new Error(`Include / Exclude tags did not match any Flows:\n\nInclude Tags:\n${allIncludeTags.join('\n')}\n\nExclude Tags:\n${allExcludeTags.join('\n')}`);
|
|
409
408
|
}
|
|
410
409
|
const allFiles = await Promise.all(allFlows.map((filePath) => checkDependencies(filePath))).then((results) => [...new Set(results.flat())]);
|
|
411
|
-
// eslint-disable-next-line unicorn/no-array-reduce
|
|
412
410
|
const pathsByName = allFlows.reduce((acc, filePath) => {
|
|
413
411
|
const config = configPerFlowFile[filePath];
|
|
414
412
|
const name = config?.name || path.parse(filePath).name;
|
|
@@ -98,7 +98,6 @@ export class MoropoService {
|
|
|
98
98
|
await pipeline(source, fs.createWriteStream(zipPath));
|
|
99
99
|
}
|
|
100
100
|
async extractZipFile(zipPath, extractPath) {
|
|
101
|
-
// eslint-disable-next-line new-cap
|
|
102
101
|
const zip = new StreamZip.async({ file: zipPath });
|
|
103
102
|
await zip.extract(null, extractPath);
|
|
104
103
|
await zip.close();
|
|
@@ -167,7 +167,6 @@ export class ResultsPollingService {
|
|
|
167
167
|
ticker?.unref?.();
|
|
168
168
|
try {
|
|
169
169
|
// Poll in a loop until all tests complete
|
|
170
|
-
// eslint-disable-next-line no-constant-condition
|
|
171
170
|
while (true) {
|
|
172
171
|
try {
|
|
173
172
|
nextPollAt = null;
|
|
@@ -313,7 +312,6 @@ export class ResultsPollingService {
|
|
|
313
312
|
},
|
|
314
313
|
},
|
|
315
314
|
...(hasFailedTests && {
|
|
316
|
-
// eslint-disable-next-line camelcase
|
|
317
315
|
fail_reason: {
|
|
318
316
|
get(row) {
|
|
319
317
|
return row.status === 'FAILED' && row.fail_reason
|
|
@@ -223,7 +223,6 @@ export class TestSubmissionService {
|
|
|
223
223
|
return paths.map((p) => this.normalizeFilePath(p, commonRoot));
|
|
224
224
|
}
|
|
225
225
|
parseKeyValuePairs(pairs) {
|
|
226
|
-
// eslint-disable-next-line unicorn/no-array-reduce
|
|
227
226
|
return pairs.reduce((acc, cur) => {
|
|
228
227
|
const [key, ...value] = cur.split('=');
|
|
229
228
|
// handle case where value includes an equals sign
|
package/dist/utils/cli.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import { readFileSync } from 'node:fs';
|
|
10
10
|
import { stripVTControlCharacters } from 'node:util';
|
|
11
11
|
import { telemetry } from '../services/telemetry.service.js';
|
|
12
|
-
import { symbols } from './styling.js';
|
|
12
|
+
import { forStderr, symbols } from './styling.js';
|
|
13
13
|
// Resolve version at runtime. The bun-compiled binary can't read package.json
|
|
14
14
|
// off disk (it isn't bundled next to the embedded module), so the build stamps
|
|
15
15
|
// the version in via `bun --define __DCD_CLI_VERSION__` (see
|
|
@@ -51,16 +51,13 @@ export class CliError extends Error {
|
|
|
51
51
|
}
|
|
52
52
|
export const logger = {
|
|
53
53
|
log(message) {
|
|
54
|
-
// eslint-disable-next-line no-console
|
|
55
54
|
console.log(message);
|
|
56
55
|
},
|
|
57
56
|
warn(message) {
|
|
58
|
-
|
|
59
|
-
console.warn(symbols.warning + ' ' + message);
|
|
57
|
+
console.warn(forStderr(symbols.warning + ' ' + message));
|
|
60
58
|
},
|
|
61
59
|
json(value) {
|
|
62
60
|
// The one stdout write under --json; everything else is gated off.
|
|
63
|
-
// eslint-disable-next-line no-console
|
|
64
61
|
console.log(JSON.stringify(value, null, 2));
|
|
65
62
|
},
|
|
66
63
|
error(message, opts = {}) {
|
|
@@ -74,8 +71,7 @@ export const logger = {
|
|
|
74
71
|
else {
|
|
75
72
|
// The literal "Error:" prefix is important for tests and for grep-friendly
|
|
76
73
|
// CI logs — it survives color stripping and matches /error/i assertions.
|
|
77
|
-
|
|
78
|
-
console.error(symbols.error + ' Error: ' + text);
|
|
74
|
+
console.error(forStderr(symbols.error + ' Error: ' + text));
|
|
79
75
|
}
|
|
80
76
|
return logger.fail(message, opts.exit ?? 1);
|
|
81
77
|
},
|
|
@@ -33,7 +33,6 @@ export function readConfig() {
|
|
|
33
33
|
const raw = readFileSync(p, 'utf8');
|
|
34
34
|
const parsed = JSON.parse(raw);
|
|
35
35
|
if (parsed.version !== CONFIG_SCHEMA_VERSION) {
|
|
36
|
-
// eslint-disable-next-line no-console
|
|
37
36
|
console.warn(`Warning: config at ${p} was written by an incompatible CLI version (config version ${parsed.version}); ignoring it. Run \`dcd login\` to recreate it.`);
|
|
38
37
|
return null;
|
|
39
38
|
}
|
|
@@ -42,7 +41,6 @@ export function readConfig() {
|
|
|
42
41
|
catch {
|
|
43
42
|
// Surface the corruption instead of silently behaving as logged-out, so
|
|
44
43
|
// downstream "Not authenticated" errors aren't mystifying.
|
|
45
|
-
// eslint-disable-next-line no-console
|
|
46
44
|
console.warn(`Warning: could not parse config at ${p}; treating as logged out. Run \`dcd login\` to recreate it.`);
|
|
47
45
|
return null;
|
|
48
46
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { stripVTControlCharacters } from 'node:util';
|
|
2
2
|
import { DeviceApiError, DeviceGateway } from '../gateways/device-gateway.js';
|
|
3
3
|
import { CliError, logger } from './cli.js';
|
|
4
|
-
import { colors, formatUrl } from './styling.js';
|
|
4
|
+
import { colors, formatUrl, forStderr } from './styling.js';
|
|
5
5
|
import { ui } from './ui.js';
|
|
6
6
|
/**
|
|
7
7
|
* Exit codes for `dcd device` (dcd docs/device-v1-plan.md, section 4.2).
|
|
@@ -102,7 +102,7 @@ export async function runDeviceCommand(json, fn) {
|
|
|
102
102
|
export function deviceProgress(json) {
|
|
103
103
|
return (message) => {
|
|
104
104
|
if (!json)
|
|
105
|
-
process.stderr.write(`${message}\n`);
|
|
105
|
+
process.stderr.write(`${forStderr(message)}\n`);
|
|
106
106
|
};
|
|
107
107
|
}
|
|
108
108
|
/**
|
package/dist/utils/progress.js
CHANGED
|
@@ -90,7 +90,6 @@ class Action {
|
|
|
90
90
|
this.current = null;
|
|
91
91
|
this._status = '';
|
|
92
92
|
if (line) {
|
|
93
|
-
// eslint-disable-next-line no-console
|
|
94
93
|
console.log(line);
|
|
95
94
|
}
|
|
96
95
|
}
|
|
@@ -100,14 +99,12 @@ class Action {
|
|
|
100
99
|
if (line === this._lastPrinted)
|
|
101
100
|
return;
|
|
102
101
|
this._lastPrinted = line;
|
|
103
|
-
// eslint-disable-next-line no-console
|
|
104
102
|
console.log(line);
|
|
105
103
|
}
|
|
106
104
|
}
|
|
107
105
|
export const ux = {
|
|
108
106
|
action: new Action(),
|
|
109
107
|
info(message) {
|
|
110
|
-
// eslint-disable-next-line no-console
|
|
111
108
|
console.log(message);
|
|
112
109
|
},
|
|
113
110
|
};
|
package/dist/utils/styling.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Centralized styling utilities for CLI output
|
|
3
3
|
* Provides consistent, developer-friendly visual formatting
|
|
4
|
+
*
|
|
5
|
+
* Text is styled only when stdout takes colour (see {@link takesColour}); text
|
|
6
|
+
* bound for stderr goes through {@link forStderr}. The escape codes come from
|
|
7
|
+
* `util.inspect.colors`, the table Node's `styleText` reads, and are applied
|
|
8
|
+
* by {@link style}.
|
|
4
9
|
*/
|
|
5
10
|
/** Strip ANSI color escape sequences for visible-width calculations. */
|
|
6
11
|
export declare const stripAnsi: (s: string) => string;
|
|
@@ -23,15 +28,23 @@ export declare const symbols: {
|
|
|
23
28
|
* Color utility functions for semantic styling
|
|
24
29
|
*/
|
|
25
30
|
export declare const colors: {
|
|
26
|
-
readonly bold:
|
|
27
|
-
readonly dim:
|
|
28
|
-
readonly error:
|
|
29
|
-
readonly highlight:
|
|
30
|
-
readonly info:
|
|
31
|
-
readonly success:
|
|
32
|
-
readonly url:
|
|
33
|
-
readonly warning:
|
|
31
|
+
readonly bold: (text: string) => string;
|
|
32
|
+
readonly dim: (text: string) => string;
|
|
33
|
+
readonly error: (text: string) => string;
|
|
34
|
+
readonly highlight: (text: string) => string;
|
|
35
|
+
readonly info: (text: string) => string;
|
|
36
|
+
readonly success: (text: string) => string;
|
|
37
|
+
readonly url: (text: string) => string;
|
|
38
|
+
readonly warning: (text: string) => string;
|
|
34
39
|
};
|
|
40
|
+
/**
|
|
41
|
+
* Prepare styled text for stderr. The palette above follows stdout, so when
|
|
42
|
+
* stdout is a terminal but stderr is not (`dcd cloud 2> err.log`), the colour
|
|
43
|
+
* codes are stripped here to keep the file plain.
|
|
44
|
+
* @param text - Text that may carry colour codes from {@link colors} or {@link symbols}
|
|
45
|
+
* @returns The text, without colour codes unless stderr takes colour
|
|
46
|
+
*/
|
|
47
|
+
export declare function forStderr(text: string): string;
|
|
35
48
|
/**
|
|
36
49
|
* Structural glyphs that give the CLI its tree-shaped layout. `section` marks a
|
|
37
50
|
* top-level heading; `branch` opens the group of detail rows beneath it.
|
package/dist/utils/styling.js
CHANGED
|
@@ -1,40 +1,100 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { inspect } from 'node:util';
|
|
2
2
|
import { findEnvByApiUrl } from '../config/environments.js';
|
|
3
3
|
/**
|
|
4
4
|
* Centralized styling utilities for CLI output
|
|
5
5
|
* Provides consistent, developer-friendly visual formatting
|
|
6
|
+
*
|
|
7
|
+
* Text is styled only when stdout takes colour (see {@link takesColour}); text
|
|
8
|
+
* bound for stderr goes through {@link forStderr}. The escape codes come from
|
|
9
|
+
* `util.inspect.colors`, the table Node's `styleText` reads, and are applied
|
|
10
|
+
* by {@link style}.
|
|
6
11
|
*/
|
|
7
12
|
/** Strip ANSI color escape sequences for visible-width calculations. */
|
|
8
13
|
// eslint-disable-next-line no-control-regex -- matches ANSI escape sequences
|
|
9
14
|
export const stripAnsi = (s) => s.replace(/\u001B\[[0-9;]*m/g, '');
|
|
15
|
+
/**
|
|
16
|
+
* Whether `stream` takes colour, by the rule Node's `styleText` applies:
|
|
17
|
+
* `FORCE_COLOR` decides when set; otherwise the stream must be a terminal
|
|
18
|
+
* whose colour depth (which folds in `NO_COLOR`, `NODE_DISABLE_COLORS` and
|
|
19
|
+
* `TERM=dumb`) is above monochrome.
|
|
20
|
+
*/
|
|
21
|
+
function takesColour(stream) {
|
|
22
|
+
const force = process.env.FORCE_COLOR;
|
|
23
|
+
if (force !== undefined)
|
|
24
|
+
return ['', '1', '2', '3', 'true'].includes(force);
|
|
25
|
+
return (stream.isTTY === true &&
|
|
26
|
+
(typeof stream.getColorDepth !== 'function' || stream.getColorDepth() > 2));
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Apply `format` to `text` when stdout takes colour.
|
|
30
|
+
*
|
|
31
|
+
* This is not left to `util.styleText`, because its output differs across the
|
|
32
|
+
* runtimes the CLI ships on: bun 1.3 (which compiles the standalone binaries)
|
|
33
|
+
* and Node before 22.20 drop the outer colour after a nested span, and bun 1.3
|
|
34
|
+
* and Node before 22.8 colour even when the stream can't show it. The rules
|
|
35
|
+
* here are the ones chalk applied, so output is the same everywhere:
|
|
36
|
+
* - an inner span that ends this style's colour re-opens it, so text after
|
|
37
|
+
* the span keeps the outer colour;
|
|
38
|
+
* - each line is closed and re-opened, so a line read on its own (a CI log, a
|
|
39
|
+
* pager) still carries its colour;
|
|
40
|
+
* - an empty string stays empty.
|
|
41
|
+
*
|
|
42
|
+
* Anything but a string is printed as `String(value)`, never fatal: the types
|
|
43
|
+
* may call a value a string that an API sent as null or a number.
|
|
44
|
+
*/
|
|
45
|
+
function style(format, text) {
|
|
46
|
+
const s = String(text);
|
|
47
|
+
const codes = inspect.colors[format];
|
|
48
|
+
if (s === '' || !codes || !takesColour(process.stdout))
|
|
49
|
+
return s;
|
|
50
|
+
const open = `\u001B[${codes[0]}m`;
|
|
51
|
+
const close = `\u001B[${codes[1]}m`;
|
|
52
|
+
const body = s
|
|
53
|
+
.replaceAll(close, close + open)
|
|
54
|
+
.replaceAll(/\r?\n/g, (lineBreak) => close + lineBreak + open);
|
|
55
|
+
return open + body + close;
|
|
56
|
+
}
|
|
57
|
+
const paint = (format) => (text) => style(format, text);
|
|
58
|
+
const cyan = paint('cyan');
|
|
59
|
+
const underline = paint('underline');
|
|
10
60
|
/**
|
|
11
61
|
* Status symbols with associated colors
|
|
12
62
|
*/
|
|
13
63
|
export const symbols = {
|
|
14
|
-
cancelled:
|
|
15
|
-
deprecation:
|
|
16
|
-
error:
|
|
17
|
-
info:
|
|
18
|
-
pending:
|
|
19
|
-
queued:
|
|
20
|
-
running:
|
|
21
|
-
success:
|
|
22
|
-
unknown:
|
|
23
|
-
warning:
|
|
64
|
+
cancelled: style('gray', '⊘'),
|
|
65
|
+
deprecation: style('red', '⚠'),
|
|
66
|
+
error: style('red', '✗'),
|
|
67
|
+
info: style('blue', 'ℹ'),
|
|
68
|
+
pending: style('yellow', '⏸'),
|
|
69
|
+
queued: style('gray', '⏳'),
|
|
70
|
+
running: style('blue', '▶'),
|
|
71
|
+
success: style('green', '✓'),
|
|
72
|
+
unknown: style('gray', '?'),
|
|
73
|
+
warning: style('yellow', '⚠'),
|
|
24
74
|
};
|
|
25
75
|
/**
|
|
26
76
|
* Color utility functions for semantic styling
|
|
27
77
|
*/
|
|
28
78
|
export const colors = {
|
|
29
|
-
bold:
|
|
30
|
-
dim:
|
|
31
|
-
error:
|
|
32
|
-
highlight:
|
|
33
|
-
info:
|
|
34
|
-
success:
|
|
35
|
-
url:
|
|
36
|
-
warning:
|
|
79
|
+
bold: paint('bold'),
|
|
80
|
+
dim: paint('gray'),
|
|
81
|
+
error: paint('red'),
|
|
82
|
+
highlight: cyan,
|
|
83
|
+
info: paint('blue'),
|
|
84
|
+
success: paint('green'),
|
|
85
|
+
url: (text) => cyan(underline(text)),
|
|
86
|
+
warning: paint('yellow'),
|
|
37
87
|
};
|
|
88
|
+
/**
|
|
89
|
+
* Prepare styled text for stderr. The palette above follows stdout, so when
|
|
90
|
+
* stdout is a terminal but stderr is not (`dcd cloud 2> err.log`), the colour
|
|
91
|
+
* codes are stripped here to keep the file plain.
|
|
92
|
+
* @param text - Text that may carry colour codes from {@link colors} or {@link symbols}
|
|
93
|
+
* @returns The text, without colour codes unless stderr takes colour
|
|
94
|
+
*/
|
|
95
|
+
export function forStderr(text) {
|
|
96
|
+
return takesColour(process.stderr) ? text : stripAnsi(text);
|
|
97
|
+
}
|
|
38
98
|
/**
|
|
39
99
|
* Structural glyphs that give the CLI its tree-shaped layout. `section` marks a
|
|
40
100
|
* top-level heading; `branch` opens the group of detail rows beneath it.
|
|
@@ -119,7 +179,7 @@ export function formatId(id) {
|
|
|
119
179
|
*/
|
|
120
180
|
export function formatTestSummary(summary) {
|
|
121
181
|
const parts = [
|
|
122
|
-
|
|
182
|
+
colors.bold(`${summary.completed}/${summary.total}`),
|
|
123
183
|
colors.success(`✓ ${summary.passed}`),
|
|
124
184
|
colors.error(`✗ ${summary.failed}`),
|
|
125
185
|
colors.info(`▶ ${summary.running}`),
|
|
@@ -135,7 +195,6 @@ export function formatTestSummary(summary) {
|
|
|
135
195
|
*/
|
|
136
196
|
export function table(rows, columns, options = {}) {
|
|
137
197
|
const printLine = options.printLine ?? ((line) => {
|
|
138
|
-
// eslint-disable-next-line no-console
|
|
139
198
|
console.log(line);
|
|
140
199
|
});
|
|
141
200
|
const keys = Object.keys(columns);
|
|
@@ -146,8 +205,8 @@ export function table(rows, columns, options = {}) {
|
|
|
146
205
|
const visibleLen = stripAnsi(s).length;
|
|
147
206
|
return s + ' '.repeat(Math.max(0, width - visibleLen));
|
|
148
207
|
};
|
|
149
|
-
printLine(headers.map((h, i) => pad(
|
|
150
|
-
printLine(widths.map((w) =>
|
|
208
|
+
printLine(headers.map((h, i) => pad(colors.bold(h), widths[i])).join(' '));
|
|
209
|
+
printLine(widths.map((w) => colors.dim('─'.repeat(w))).join(' '));
|
|
151
210
|
for (const row of cells) {
|
|
152
211
|
printLine(row.map((c, i) => pad(c, widths[i])).join(' '));
|
|
153
212
|
}
|
package/package.json
CHANGED
|
@@ -8,8 +8,7 @@
|
|
|
8
8
|
"@clack/prompts": "^1.6.0",
|
|
9
9
|
"@modelcontextprotocol/sdk": "^1.31.0",
|
|
10
10
|
"@supabase/supabase-js": "^2.108.2",
|
|
11
|
-
"bplist-parser": "^0.
|
|
12
|
-
"chalk": "^6.0.0",
|
|
11
|
+
"bplist-parser": "^0.6.0",
|
|
13
12
|
"citty": "^0.2.2",
|
|
14
13
|
"js-yaml": "^5.2.2",
|
|
15
14
|
"node-stream-zip": "^1.15.0",
|
|
@@ -29,7 +28,6 @@
|
|
|
29
28
|
"chai": "^6.2.2",
|
|
30
29
|
"eslint": "^10.15.0",
|
|
31
30
|
"eslint-config-prettier": "^10.1.8",
|
|
32
|
-
"eslint-plugin-unicorn": "^79.0.0",
|
|
33
31
|
"husky": "^9.1.7",
|
|
34
32
|
"mocha": "^12.0.0",
|
|
35
33
|
"prettier": "^3.8.4",
|
|
@@ -38,7 +36,7 @@
|
|
|
38
36
|
"typescript-eslint": "^8.73.0"
|
|
39
37
|
},
|
|
40
38
|
"engines": {
|
|
41
|
-
"node": ">=22.
|
|
39
|
+
"node": ">=22.8.0"
|
|
42
40
|
},
|
|
43
41
|
"files": [
|
|
44
42
|
"/dist"
|
|
@@ -66,7 +64,7 @@
|
|
|
66
64
|
"test:unit": "node scripts/test-runner.mjs --unit",
|
|
67
65
|
"typecheck": "tsc --noEmit -p tsconfig.test.json"
|
|
68
66
|
},
|
|
69
|
-
"version": "5.16.0-beta.
|
|
67
|
+
"version": "5.16.0-beta.3",
|
|
70
68
|
"bugs": {
|
|
71
69
|
"url": "https://discord.gg/gm3mJwcNw8"
|
|
72
70
|
},
|
|
@@ -93,13 +91,6 @@
|
|
|
93
91
|
"overrides": {
|
|
94
92
|
"minimatch@>=10.0.0 <11.0.1": "11.0.1",
|
|
95
93
|
"glob@>=9.0.0 <14.0.2": "14.0.2"
|
|
96
|
-
},
|
|
97
|
-
"auditConfig": {
|
|
98
|
-
"ignoreGhsas": [
|
|
99
|
-
"GHSA-frvp-7c67-39w9",
|
|
100
|
-
"GHSA-vfj7-8cjw-p6xm",
|
|
101
|
-
"GHSA-fc5q-39xc-vjpf"
|
|
102
|
-
]
|
|
103
94
|
}
|
|
104
95
|
}
|
|
105
96
|
}
|