@robinpath/cli 1.74.0 → 1.75.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/README.md +111 -111
- package/dist/cli.mjs +1 -1
- package/modules/_helpers.js +33 -33
- package/modules/assert.js +270 -270
- package/modules/buffer.js +245 -245
- package/modules/child.js +176 -176
- package/modules/crypto.js +352 -352
- package/modules/dns.js +146 -146
- package/modules/events.js +174 -174
- package/modules/file.js +361 -361
- package/modules/http.js +268 -268
- package/modules/index.js +76 -76
- package/modules/net.js +189 -189
- package/modules/os.js +219 -219
- package/modules/path.js +162 -162
- package/modules/process.js +214 -214
- package/modules/stream.js +322 -322
- package/modules/string_decoder.js +106 -106
- package/modules/timer.js +167 -167
- package/modules/tls.js +264 -264
- package/modules/tty.js +169 -169
- package/modules/url.js +189 -189
- package/modules/util.js +275 -275
- package/modules/zlib.js +126 -126
- package/package.json +1 -1
package/modules/tty.js
CHANGED
|
@@ -1,169 +1,169 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Native tty module for RobinPath.
|
|
3
|
-
* Terminal/TTY detection and capabilities — needed by supports-color, chalk, etc.
|
|
4
|
-
*/
|
|
5
|
-
import { isatty } from 'node:tty';
|
|
6
|
-
import { toNum, requireArgs } from './_helpers.js';
|
|
7
|
-
|
|
8
|
-
export const TtyFunctions = {
|
|
9
|
-
|
|
10
|
-
isatty: (args) => {
|
|
11
|
-
requireArgs('tty.isatty', args, 1);
|
|
12
|
-
const fd = toNum(args[0], 1);
|
|
13
|
-
return isatty(fd);
|
|
14
|
-
},
|
|
15
|
-
|
|
16
|
-
isStdinTTY: () => process.stdin?.isTTY === true,
|
|
17
|
-
|
|
18
|
-
isStdoutTTY: () => process.stdout?.isTTY === true,
|
|
19
|
-
|
|
20
|
-
isStderrTTY: () => process.stderr?.isTTY === true,
|
|
21
|
-
|
|
22
|
-
columns: () => process.stdout?.columns || 80,
|
|
23
|
-
|
|
24
|
-
rows: () => process.stdout?.rows || 24,
|
|
25
|
-
|
|
26
|
-
size: () => ({
|
|
27
|
-
columns: process.stdout?.columns || 80,
|
|
28
|
-
rows: process.stdout?.rows || 24
|
|
29
|
-
}),
|
|
30
|
-
|
|
31
|
-
hasColors: (args) => {
|
|
32
|
-
const count = args[0] ? toNum(args[0], 16) : 16;
|
|
33
|
-
if (process.stdout?.hasColors) {
|
|
34
|
-
return process.stdout.hasColors(count);
|
|
35
|
-
}
|
|
36
|
-
// Fallback: detect from env
|
|
37
|
-
const env = process.env;
|
|
38
|
-
if (env.NO_COLOR) return false;
|
|
39
|
-
if (env.FORCE_COLOR) return true;
|
|
40
|
-
if (env.TERM === 'dumb') return false;
|
|
41
|
-
if (process.platform === 'win32') return true;
|
|
42
|
-
if (env.CI) return true;
|
|
43
|
-
if (env.COLORTERM === 'truecolor' || env.COLORTERM === '24bit') return count <= 16777216;
|
|
44
|
-
if (env.TERM_PROGRAM === 'iTerm.app') return count <= 256;
|
|
45
|
-
if (/256color/i.test(env.TERM || '')) return count <= 256;
|
|
46
|
-
return count <= 16;
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
colorDepth: () => {
|
|
50
|
-
if (process.stdout?.getColorDepth) {
|
|
51
|
-
return process.stdout.getColorDepth();
|
|
52
|
-
}
|
|
53
|
-
const env = process.env;
|
|
54
|
-
if (env.NO_COLOR) return 1;
|
|
55
|
-
if (env.COLORTERM === 'truecolor' || env.COLORTERM === '24bit') return 24;
|
|
56
|
-
if (process.platform === 'win32') return 4;
|
|
57
|
-
if (/256color/i.test(env.TERM || '')) return 8;
|
|
58
|
-
return 4;
|
|
59
|
-
},
|
|
60
|
-
|
|
61
|
-
supportsColor: () => {
|
|
62
|
-
const env = process.env;
|
|
63
|
-
if (env.NO_COLOR) return false;
|
|
64
|
-
if (env.FORCE_COLOR) return true;
|
|
65
|
-
if (env.TERM === 'dumb') return false;
|
|
66
|
-
if (process.platform === 'win32') return true;
|
|
67
|
-
if (process.stdout?.isTTY) return true;
|
|
68
|
-
if (env.CI) return true;
|
|
69
|
-
return false;
|
|
70
|
-
},
|
|
71
|
-
|
|
72
|
-
getWindowSize: () => {
|
|
73
|
-
if (process.stdout?.getWindowSize) {
|
|
74
|
-
const [cols, rows] = process.stdout.getWindowSize();
|
|
75
|
-
return { columns: cols, rows };
|
|
76
|
-
}
|
|
77
|
-
return {
|
|
78
|
-
columns: process.stdout?.columns || 80,
|
|
79
|
-
rows: process.stdout?.rows || 24
|
|
80
|
-
};
|
|
81
|
-
},
|
|
82
|
-
|
|
83
|
-
clearLine: (args) => {
|
|
84
|
-
const dir = args[0] ? toNum(args[0], 0) : 0;
|
|
85
|
-
if (process.stdout?.clearLine) {
|
|
86
|
-
process.stdout.clearLine(dir);
|
|
87
|
-
return true;
|
|
88
|
-
}
|
|
89
|
-
return false;
|
|
90
|
-
},
|
|
91
|
-
|
|
92
|
-
cursorTo: (args) => {
|
|
93
|
-
requireArgs('tty.cursorTo', args, 1);
|
|
94
|
-
const x = toNum(args[0], 0);
|
|
95
|
-
const y = args[1] != null ? toNum(args[1]) : undefined;
|
|
96
|
-
if (process.stdout?.cursorTo) {
|
|
97
|
-
process.stdout.cursorTo(x, y);
|
|
98
|
-
return true;
|
|
99
|
-
}
|
|
100
|
-
return false;
|
|
101
|
-
},
|
|
102
|
-
|
|
103
|
-
moveCursor: (args) => {
|
|
104
|
-
requireArgs('tty.moveCursor', args, 2);
|
|
105
|
-
const dx = toNum(args[0], 0);
|
|
106
|
-
const dy = toNum(args[1], 0);
|
|
107
|
-
if (process.stdout?.moveCursor) {
|
|
108
|
-
process.stdout.moveCursor(dx, dy);
|
|
109
|
-
return true;
|
|
110
|
-
}
|
|
111
|
-
return false;
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
export const TtyFunctionMetadata = {
|
|
116
|
-
isatty: {
|
|
117
|
-
description: 'Check if a file descriptor is a TTY',
|
|
118
|
-
parameters: [{ name: 'fd', dataType: 'number', description: 'File descriptor (0=stdin, 1=stdout, 2=stderr)', formInputType: 'number', required: true }],
|
|
119
|
-
returnType: 'boolean', returnDescription: 'true if TTY', example: 'tty.isatty 1'
|
|
120
|
-
},
|
|
121
|
-
isStdinTTY: { description: 'Check if stdin is a TTY', parameters: [], returnType: 'boolean', returnDescription: 'true if TTY', example: 'tty.isStdinTTY' },
|
|
122
|
-
isStdoutTTY: { description: 'Check if stdout is a TTY', parameters: [], returnType: 'boolean', returnDescription: 'true if TTY', example: 'tty.isStdoutTTY' },
|
|
123
|
-
isStderrTTY: { description: 'Check if stderr is a TTY', parameters: [], returnType: 'boolean', returnDescription: 'true if TTY', example: 'tty.isStderrTTY' },
|
|
124
|
-
columns: { description: 'Get terminal width in columns', parameters: [], returnType: 'number', returnDescription: 'Column count', example: 'tty.columns' },
|
|
125
|
-
rows: { description: 'Get terminal height in rows', parameters: [], returnType: 'number', returnDescription: 'Row count', example: 'tty.rows' },
|
|
126
|
-
size: { description: 'Get terminal size {columns, rows}', parameters: [], returnType: 'object', returnDescription: '{columns, rows}', example: 'tty.size' },
|
|
127
|
-
hasColors: {
|
|
128
|
-
description: 'Check if terminal supports N colors',
|
|
129
|
-
parameters: [{ name: 'count', dataType: 'number', description: 'Number of colors to check (default: 16)', formInputType: 'number', required: false, defaultValue: '16' }],
|
|
130
|
-
returnType: 'boolean', returnDescription: 'true if supported', example: 'tty.hasColors 256'
|
|
131
|
-
},
|
|
132
|
-
colorDepth: { description: 'Get terminal color depth in bits', parameters: [], returnType: 'number', returnDescription: 'Color depth (1, 4, 8, or 24)', example: 'tty.colorDepth' },
|
|
133
|
-
supportsColor: { description: 'Check if terminal supports color output', parameters: [], returnType: 'boolean', returnDescription: 'true if color supported', example: 'tty.supportsColor' },
|
|
134
|
-
getWindowSize: { description: 'Get terminal window size', parameters: [], returnType: 'object', returnDescription: '{columns, rows}', example: 'tty.getWindowSize' },
|
|
135
|
-
clearLine: {
|
|
136
|
-
description: 'Clear the current terminal line',
|
|
137
|
-
parameters: [{ name: 'direction', dataType: 'number', description: '-1=left, 0=entire, 1=right', formInputType: 'number', required: false, defaultValue: '0' }],
|
|
138
|
-
returnType: 'boolean', returnDescription: 'true if cleared', example: 'tty.clearLine 0'
|
|
139
|
-
},
|
|
140
|
-
cursorTo: {
|
|
141
|
-
description: 'Move cursor to position',
|
|
142
|
-
parameters: [
|
|
143
|
-
{ name: 'x', dataType: 'number', description: 'Column position', formInputType: 'number', required: true },
|
|
144
|
-
{ name: 'y', dataType: 'number', description: 'Row position', formInputType: 'number', required: false }
|
|
145
|
-
],
|
|
146
|
-
returnType: 'boolean', returnDescription: 'true if moved', example: 'tty.cursorTo 0 5'
|
|
147
|
-
},
|
|
148
|
-
moveCursor: {
|
|
149
|
-
description: 'Move cursor relative to current position',
|
|
150
|
-
parameters: [
|
|
151
|
-
{ name: 'dx', dataType: 'number', description: 'Horizontal offset', formInputType: 'number', required: true },
|
|
152
|
-
{ name: 'dy', dataType: 'number', description: 'Vertical offset', formInputType: 'number', required: true }
|
|
153
|
-
],
|
|
154
|
-
returnType: 'boolean', returnDescription: 'true if moved', example: 'tty.moveCursor 1 -1'
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
export const TtyModuleMetadata = {
|
|
159
|
-
description: 'TTY: terminal detection, color support, cursor control, window size',
|
|
160
|
-
methods: Object.keys(TtyFunctions)
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
export default {
|
|
164
|
-
name: 'tty',
|
|
165
|
-
functions: TtyFunctions,
|
|
166
|
-
functionMetadata: TtyFunctionMetadata,
|
|
167
|
-
moduleMetadata: TtyModuleMetadata,
|
|
168
|
-
global: false
|
|
169
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* Native tty module for RobinPath.
|
|
3
|
+
* Terminal/TTY detection and capabilities — needed by supports-color, chalk, etc.
|
|
4
|
+
*/
|
|
5
|
+
import { isatty } from 'node:tty';
|
|
6
|
+
import { toNum, requireArgs } from './_helpers.js';
|
|
7
|
+
|
|
8
|
+
export const TtyFunctions = {
|
|
9
|
+
|
|
10
|
+
isatty: (args) => {
|
|
11
|
+
requireArgs('tty.isatty', args, 1);
|
|
12
|
+
const fd = toNum(args[0], 1);
|
|
13
|
+
return isatty(fd);
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
isStdinTTY: () => process.stdin?.isTTY === true,
|
|
17
|
+
|
|
18
|
+
isStdoutTTY: () => process.stdout?.isTTY === true,
|
|
19
|
+
|
|
20
|
+
isStderrTTY: () => process.stderr?.isTTY === true,
|
|
21
|
+
|
|
22
|
+
columns: () => process.stdout?.columns || 80,
|
|
23
|
+
|
|
24
|
+
rows: () => process.stdout?.rows || 24,
|
|
25
|
+
|
|
26
|
+
size: () => ({
|
|
27
|
+
columns: process.stdout?.columns || 80,
|
|
28
|
+
rows: process.stdout?.rows || 24
|
|
29
|
+
}),
|
|
30
|
+
|
|
31
|
+
hasColors: (args) => {
|
|
32
|
+
const count = args[0] ? toNum(args[0], 16) : 16;
|
|
33
|
+
if (process.stdout?.hasColors) {
|
|
34
|
+
return process.stdout.hasColors(count);
|
|
35
|
+
}
|
|
36
|
+
// Fallback: detect from env
|
|
37
|
+
const env = process.env;
|
|
38
|
+
if (env.NO_COLOR) return false;
|
|
39
|
+
if (env.FORCE_COLOR) return true;
|
|
40
|
+
if (env.TERM === 'dumb') return false;
|
|
41
|
+
if (process.platform === 'win32') return true;
|
|
42
|
+
if (env.CI) return true;
|
|
43
|
+
if (env.COLORTERM === 'truecolor' || env.COLORTERM === '24bit') return count <= 16777216;
|
|
44
|
+
if (env.TERM_PROGRAM === 'iTerm.app') return count <= 256;
|
|
45
|
+
if (/256color/i.test(env.TERM || '')) return count <= 256;
|
|
46
|
+
return count <= 16;
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
colorDepth: () => {
|
|
50
|
+
if (process.stdout?.getColorDepth) {
|
|
51
|
+
return process.stdout.getColorDepth();
|
|
52
|
+
}
|
|
53
|
+
const env = process.env;
|
|
54
|
+
if (env.NO_COLOR) return 1;
|
|
55
|
+
if (env.COLORTERM === 'truecolor' || env.COLORTERM === '24bit') return 24;
|
|
56
|
+
if (process.platform === 'win32') return 4;
|
|
57
|
+
if (/256color/i.test(env.TERM || '')) return 8;
|
|
58
|
+
return 4;
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
supportsColor: () => {
|
|
62
|
+
const env = process.env;
|
|
63
|
+
if (env.NO_COLOR) return false;
|
|
64
|
+
if (env.FORCE_COLOR) return true;
|
|
65
|
+
if (env.TERM === 'dumb') return false;
|
|
66
|
+
if (process.platform === 'win32') return true;
|
|
67
|
+
if (process.stdout?.isTTY) return true;
|
|
68
|
+
if (env.CI) return true;
|
|
69
|
+
return false;
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
getWindowSize: () => {
|
|
73
|
+
if (process.stdout?.getWindowSize) {
|
|
74
|
+
const [cols, rows] = process.stdout.getWindowSize();
|
|
75
|
+
return { columns: cols, rows };
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
columns: process.stdout?.columns || 80,
|
|
79
|
+
rows: process.stdout?.rows || 24
|
|
80
|
+
};
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
clearLine: (args) => {
|
|
84
|
+
const dir = args[0] ? toNum(args[0], 0) : 0;
|
|
85
|
+
if (process.stdout?.clearLine) {
|
|
86
|
+
process.stdout.clearLine(dir);
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
return false;
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
cursorTo: (args) => {
|
|
93
|
+
requireArgs('tty.cursorTo', args, 1);
|
|
94
|
+
const x = toNum(args[0], 0);
|
|
95
|
+
const y = args[1] != null ? toNum(args[1]) : undefined;
|
|
96
|
+
if (process.stdout?.cursorTo) {
|
|
97
|
+
process.stdout.cursorTo(x, y);
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
return false;
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
moveCursor: (args) => {
|
|
104
|
+
requireArgs('tty.moveCursor', args, 2);
|
|
105
|
+
const dx = toNum(args[0], 0);
|
|
106
|
+
const dy = toNum(args[1], 0);
|
|
107
|
+
if (process.stdout?.moveCursor) {
|
|
108
|
+
process.stdout.moveCursor(dx, dy);
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export const TtyFunctionMetadata = {
|
|
116
|
+
isatty: {
|
|
117
|
+
description: 'Check if a file descriptor is a TTY',
|
|
118
|
+
parameters: [{ name: 'fd', dataType: 'number', description: 'File descriptor (0=stdin, 1=stdout, 2=stderr)', formInputType: 'number', required: true }],
|
|
119
|
+
returnType: 'boolean', returnDescription: 'true if TTY', example: 'tty.isatty 1'
|
|
120
|
+
},
|
|
121
|
+
isStdinTTY: { description: 'Check if stdin is a TTY', parameters: [], returnType: 'boolean', returnDescription: 'true if TTY', example: 'tty.isStdinTTY' },
|
|
122
|
+
isStdoutTTY: { description: 'Check if stdout is a TTY', parameters: [], returnType: 'boolean', returnDescription: 'true if TTY', example: 'tty.isStdoutTTY' },
|
|
123
|
+
isStderrTTY: { description: 'Check if stderr is a TTY', parameters: [], returnType: 'boolean', returnDescription: 'true if TTY', example: 'tty.isStderrTTY' },
|
|
124
|
+
columns: { description: 'Get terminal width in columns', parameters: [], returnType: 'number', returnDescription: 'Column count', example: 'tty.columns' },
|
|
125
|
+
rows: { description: 'Get terminal height in rows', parameters: [], returnType: 'number', returnDescription: 'Row count', example: 'tty.rows' },
|
|
126
|
+
size: { description: 'Get terminal size {columns, rows}', parameters: [], returnType: 'object', returnDescription: '{columns, rows}', example: 'tty.size' },
|
|
127
|
+
hasColors: {
|
|
128
|
+
description: 'Check if terminal supports N colors',
|
|
129
|
+
parameters: [{ name: 'count', dataType: 'number', description: 'Number of colors to check (default: 16)', formInputType: 'number', required: false, defaultValue: '16' }],
|
|
130
|
+
returnType: 'boolean', returnDescription: 'true if supported', example: 'tty.hasColors 256'
|
|
131
|
+
},
|
|
132
|
+
colorDepth: { description: 'Get terminal color depth in bits', parameters: [], returnType: 'number', returnDescription: 'Color depth (1, 4, 8, or 24)', example: 'tty.colorDepth' },
|
|
133
|
+
supportsColor: { description: 'Check if terminal supports color output', parameters: [], returnType: 'boolean', returnDescription: 'true if color supported', example: 'tty.supportsColor' },
|
|
134
|
+
getWindowSize: { description: 'Get terminal window size', parameters: [], returnType: 'object', returnDescription: '{columns, rows}', example: 'tty.getWindowSize' },
|
|
135
|
+
clearLine: {
|
|
136
|
+
description: 'Clear the current terminal line',
|
|
137
|
+
parameters: [{ name: 'direction', dataType: 'number', description: '-1=left, 0=entire, 1=right', formInputType: 'number', required: false, defaultValue: '0' }],
|
|
138
|
+
returnType: 'boolean', returnDescription: 'true if cleared', example: 'tty.clearLine 0'
|
|
139
|
+
},
|
|
140
|
+
cursorTo: {
|
|
141
|
+
description: 'Move cursor to position',
|
|
142
|
+
parameters: [
|
|
143
|
+
{ name: 'x', dataType: 'number', description: 'Column position', formInputType: 'number', required: true },
|
|
144
|
+
{ name: 'y', dataType: 'number', description: 'Row position', formInputType: 'number', required: false }
|
|
145
|
+
],
|
|
146
|
+
returnType: 'boolean', returnDescription: 'true if moved', example: 'tty.cursorTo 0 5'
|
|
147
|
+
},
|
|
148
|
+
moveCursor: {
|
|
149
|
+
description: 'Move cursor relative to current position',
|
|
150
|
+
parameters: [
|
|
151
|
+
{ name: 'dx', dataType: 'number', description: 'Horizontal offset', formInputType: 'number', required: true },
|
|
152
|
+
{ name: 'dy', dataType: 'number', description: 'Vertical offset', formInputType: 'number', required: true }
|
|
153
|
+
],
|
|
154
|
+
returnType: 'boolean', returnDescription: 'true if moved', example: 'tty.moveCursor 1 -1'
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
export const TtyModuleMetadata = {
|
|
159
|
+
description: 'TTY: terminal detection, color support, cursor control, window size',
|
|
160
|
+
methods: Object.keys(TtyFunctions)
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
export default {
|
|
164
|
+
name: 'tty',
|
|
165
|
+
functions: TtyFunctions,
|
|
166
|
+
functionMetadata: TtyFunctionMetadata,
|
|
167
|
+
moduleMetadata: TtyModuleMetadata,
|
|
168
|
+
global: false
|
|
169
|
+
};
|