@sanity/runtime-cli 13.2.1 → 13.2.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.
@@ -1,10 +1,10 @@
1
- import chalk from 'chalk';
2
1
  import { isScheduleEvent, } from '../../utils/types.js';
2
+ import { styleText } from '../style-text.js';
3
3
  function formatLabel(label) {
4
- return chalk.dim(`${label}:`);
4
+ return styleText('dim', `${label}:`);
5
5
  }
6
6
  function formatLabeledValue(label, value) {
7
- return `${chalk.dim(`${label}:`)} ${value}`;
7
+ return `${styleText('dim', `${label}:`)} ${value}`;
8
8
  }
9
9
  function arrayifyEvent(event) {
10
10
  if (!event)
@@ -0,0 +1,2 @@
1
+ import { styleText as nodeStyleText } from 'node:util';
2
+ export declare const styleText: typeof nodeStyleText;
@@ -0,0 +1,44 @@
1
+ import { env, stdout } from 'node:process';
2
+ import { styleText as nodeStyleText } from 'node:util';
3
+ function supportsColor() {
4
+ /*
5
+ * https://force-color.org
6
+ * Command-line software which outputs colored text should check for a
7
+ * FORCE_COLOR environment variable. When this variable is present and
8
+ * not an empty string (regardless of its value), it should force the
9
+ * addition of ANSI color.
10
+ *
11
+ * But the sample implementation accounts for when FORCE_COLOR is 0:
12
+ * if (force_color != NULL && force_color[0] != '\0') color = true;
13
+ * So we check for '0' and 'false' as well.
14
+ */
15
+ if (env.FORCE_COLOR !== undefined && env.FORCE_COLOR !== '0' && env.FORCE_COLOR !== 'false') {
16
+ return true;
17
+ }
18
+ /*
19
+ * https://no-color.org
20
+ * Command-line software which adds ANSI color to its output by default
21
+ * should check for a NO_COLOR environment variable that, when present
22
+ * and not an empty string (regardless of its value), prevents the
23
+ * addition of ANSI color.
24
+ */
25
+ if (env.NO_COLOR !== undefined && env.NO_COLOR !== '') {
26
+ return false;
27
+ }
28
+ /*
29
+ * https://nodejs.org/docs/latest/api/cli.html#node_disable_colors1
30
+ * When set, colors will not be used in the REPL.
31
+ */
32
+ if (env.NODE_DISABLE_COLORS !== undefined && env.NODE_DISABLE_COLORS !== '') {
33
+ return false;
34
+ }
35
+ /*
36
+ * If the stdout is a TTY, use colors.
37
+ */
38
+ return typeof stdout?.isTTY === 'boolean' && stdout.isTTY;
39
+ }
40
+ export const styleText = (format, text) => {
41
+ if (!supportsColor())
42
+ return String(text);
43
+ return nodeStyleText(format, text);
44
+ };
@@ -1,7 +1,7 @@
1
1
  import { randomUUID } from 'node:crypto';
2
2
  import { performance } from 'node:perf_hooks';
3
3
  import { env } from 'node:process';
4
- import chalk from 'chalk';
4
+ import { styleText } from './style-text.js';
5
5
  let defaultMaxLength = env.SANITY_TRACE_MAX_LENGTH
6
6
  ? Number.parseInt(env.SANITY_TRACE_MAX_LENGTH, 10)
7
7
  : 500;
@@ -178,8 +178,8 @@ export function createTracedFetch(logger, options) {
178
178
  const method = init?.method || 'GET';
179
179
  const startTime = performance.now();
180
180
  function trace(type, msgTemplate, ...args) {
181
- const arrow = type === 'req' ? '→' : type === 'res' ? '←' : chalk.red('✗');
182
- logger.trace(`${chalk.dim('[%s]')} HTTP ${arrow} ${msgTemplate}`, requestId, ...args);
181
+ const arrow = type === 'req' ? '→' : type === 'res' ? '←' : styleText('red', '✗');
182
+ logger.trace(`${styleText('dim', '[%s]')} HTTP ${arrow} ${msgTemplate}`, requestId, ...args);
183
183
  }
184
184
  // Log request URL
185
185
  trace('req', '%s %s', method, url);
@@ -1933,5 +1933,5 @@
1933
1933
  ]
1934
1934
  }
1935
1935
  },
1936
- "version": "13.2.1"
1936
+ "version": "13.2.3"
1937
1937
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sanity/runtime-cli",
3
3
  "description": "Sanity's Runtime CLI for Blueprints and Functions",
4
- "version": "13.2.1",
4
+ "version": "13.2.3",
5
5
  "author": "Sanity Runtime Team",
6
6
  "type": "module",
7
7
  "license": "MIT",
@@ -102,12 +102,11 @@
102
102
  "@oclif/core": "^4.8.0",
103
103
  "@oclif/plugin-help": "^6.2.36",
104
104
  "@sanity/blueprints": "^0.9.0",
105
- "@sanity/blueprints-parser": "^0.3.0",
105
+ "@sanity/blueprints-parser": "^0.4.0",
106
106
  "@sanity/client": "^7.14.0",
107
107
  "adm-zip": "^0.5.16",
108
108
  "array-treeify": "^0.1.5",
109
109
  "cardinal": "^2.1.1",
110
- "chalk": "^5.6.2",
111
110
  "eventsource": "^4.1.0",
112
111
  "find-up": "^8.0.0",
113
112
  "get-folder-size": "^5.0.0",