matterbridge 3.7.6-dev-20260427-e3ea997 → 3.7.6-dev-20260429-f05fd2a
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/CHANGELOG.md +3 -1
- package/package.json +11 -11
- package/scripts/mb-run.mjs +357 -19
package/CHANGELOG.md
CHANGED
|
@@ -72,11 +72,13 @@ These classes will run as threads in the next releases:
|
|
|
72
72
|
- [dockerversion]: Add snack bar message if a new Docker image exist.
|
|
73
73
|
- [matter]: Add [Matter.js 0.17 changes from 0.16](Matter.js%200.17.md).
|
|
74
74
|
- [scripts]: Add scripts\install-experimental.mjs and scripts\npm-link.mjs.
|
|
75
|
+
- [threads]: Add a check on the worker result and fix cleanup for errors.
|
|
76
|
+
- [promises]: Enforce `@typescript-eslint/no-floating-promises` rule.
|
|
75
77
|
|
|
76
78
|
### Changed
|
|
77
79
|
|
|
78
80
|
- [package]: Update dependencies.
|
|
79
|
-
- [package]: Bump `typescript-eslint` to v.8.59.
|
|
81
|
+
- [package]: Bump `typescript-eslint` to v.8.59.1.
|
|
80
82
|
- [jest]: Increase test timeout to 30 seconds in CI workflows.
|
|
81
83
|
- [frontend]: Bump `frontend` version to v.3.4.13.
|
|
82
84
|
- [frontend]: Update dependencies.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "matterbridge",
|
|
3
|
-
"version": "3.7.6-dev-
|
|
3
|
+
"version": "3.7.6-dev-20260429-f05fd2a",
|
|
4
4
|
"description": "Matterbridge plugin manager for Matter",
|
|
5
5
|
"author": "https://github.com/Luligu",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -134,19 +134,19 @@
|
|
|
134
134
|
"README-SERVICE.md"
|
|
135
135
|
],
|
|
136
136
|
"dependencies": {
|
|
137
|
-
"@matterbridge/core": "3.7.6-dev-
|
|
138
|
-
"@matterbridge/dgram": "3.7.6-dev-
|
|
139
|
-
"@matterbridge/jest-utils": "3.7.6-dev-
|
|
140
|
-
"@matterbridge/thread": "3.7.6-dev-
|
|
141
|
-
"@matterbridge/types": "3.7.6-dev-
|
|
142
|
-
"@matterbridge/utils": "3.7.6-dev-
|
|
143
|
-
"@matterbridge/vitest-utils": "3.7.6-dev-
|
|
137
|
+
"@matterbridge/core": "3.7.6-dev-20260429-f05fd2a",
|
|
138
|
+
"@matterbridge/dgram": "3.7.6-dev-20260429-f05fd2a",
|
|
139
|
+
"@matterbridge/jest-utils": "3.7.6-dev-20260429-f05fd2a",
|
|
140
|
+
"@matterbridge/thread": "3.7.6-dev-20260429-f05fd2a",
|
|
141
|
+
"@matterbridge/types": "3.7.6-dev-20260429-f05fd2a",
|
|
142
|
+
"@matterbridge/utils": "3.7.6-dev-20260429-f05fd2a",
|
|
143
|
+
"@matterbridge/vitest-utils": "3.7.6-dev-20260429-f05fd2a"
|
|
144
144
|
},
|
|
145
145
|
"build": {
|
|
146
146
|
"version": "3.7.6",
|
|
147
|
-
"sha": "
|
|
148
|
-
"sha7": "
|
|
149
|
-
"event": "
|
|
147
|
+
"sha": "d7f022fc56d0d713f3bce22700c6ccfd61f11769",
|
|
148
|
+
"sha7": "d7f022f",
|
|
149
|
+
"event": "schedule",
|
|
150
150
|
"workflow": "Publish to npm and trigger docker builds",
|
|
151
151
|
"type": "branch",
|
|
152
152
|
"name": "dev",
|
package/scripts/mb-run.mjs
CHANGED
|
@@ -8,6 +8,9 @@ import process from 'node:process';
|
|
|
8
8
|
// It may be executed from other repos/packages, so do not assume the script's own path.
|
|
9
9
|
const repoRoot = process.cwd();
|
|
10
10
|
const isWindows = process.platform === 'win32';
|
|
11
|
+
const scriptVersion = '1.0.0';
|
|
12
|
+
let dryRunMode = false;
|
|
13
|
+
let verboseCommands = false;
|
|
11
14
|
|
|
12
15
|
const BIN_ENTRYPOINTS = {
|
|
13
16
|
tsc: ['typescript', 'bin/tsc'],
|
|
@@ -34,21 +37,27 @@ class ExitError extends Error {
|
|
|
34
37
|
* Prints CLI usage text.
|
|
35
38
|
*/
|
|
36
39
|
function printUsage() {
|
|
40
|
+
const title = `${brightCyan('mb-run')} ${brightBlack('version')} ${brightWhite(scriptVersion)}`;
|
|
41
|
+
const usageLine = `${brightYellow('Usage:')} ${green('mb-run')} [--reset] [--clean] [--build|--build-production] [--watch] [--test] [--lint|--lint-fix] [--format|--format-check] [--dry-run] [--version [dev|edge|git|local|next|alpha|beta]]`;
|
|
37
42
|
const msg = `\
|
|
38
|
-
|
|
43
|
+
${title}
|
|
39
44
|
|
|
40
45
|
Runs the same operations as the package.json scripts in the current working directory, but executes the local
|
|
41
46
|
binaries in node_modules/.bin directly (does not call npm scripts).
|
|
42
47
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
-
|
|
47
|
-
- --
|
|
48
|
-
- --
|
|
49
|
-
- --
|
|
50
|
-
- --
|
|
51
|
-
- --
|
|
48
|
+
${usageLine}
|
|
49
|
+
|
|
50
|
+
${brightYellow('Notes:')}
|
|
51
|
+
- ${cyan('Multiple flags')} are run in this order: ${brightBlack('reset → clean → build/build-production → test → lint → format → watch')}
|
|
52
|
+
- ${green('--reset')} empties .cache/ and node_modules/ (keeps directories for devcontainer named volumes), then runs npm install and build
|
|
53
|
+
- ${green('--test')} sets NODE_OPTIONS="--experimental-vm-modules --no-warnings" like the existing scripts
|
|
54
|
+
- ${green('--lint-fix')} runs eslint with --fix
|
|
55
|
+
- ${green('--format-check')} runs prettier with --check
|
|
56
|
+
- ${green('--build')} prefers per-workspace tsconfig.build.json when present
|
|
57
|
+
- ${green('--build-production')} prefers tsconfig.build.production.json, else tsconfig.build.json, else tsconfig.json
|
|
58
|
+
- ${green('--dry-run')} logs intended actions without changing files or executing commands
|
|
59
|
+
- ${green('--version')} updates versions for the current package and all configured workspaces
|
|
60
|
+
- ${green('--verbose')} prints each external command before it is executed
|
|
52
61
|
`;
|
|
53
62
|
|
|
54
63
|
console.log(msg);
|
|
@@ -59,10 +68,10 @@ Notes:
|
|
|
59
68
|
*/
|
|
60
69
|
function printVersionUsage() {
|
|
61
70
|
const msg = [
|
|
62
|
-
'Usage: mb-run --version [dev|edge|git|local|next|alpha|beta]
|
|
63
|
-
'Updates package.json + package-lock.json (current package and workspaces) version to
|
|
64
|
-
'
|
|
65
|
-
|
|
71
|
+
`${brightYellow('Usage:')} ${green('mb-run')} ${green('--version')} [dev|edge|git|local|next|alpha|beta]`,
|
|
72
|
+
`${cyan('Updates')} package.json + package-lock.json (current package and workspaces) version to:`,
|
|
73
|
+
` ${brightBlack('<baseVersion>-<dev|edge|git|local|next|alpha|beta>-<yyyymmdd>-<7charSha>')}`,
|
|
74
|
+
`Or with no tag, strips the suffix back to ${brightBlack('<baseVersion>')}.`,
|
|
66
75
|
].join('\n');
|
|
67
76
|
|
|
68
77
|
console.log(msg);
|
|
@@ -97,6 +106,80 @@ function formatYyyymmdd(date) {
|
|
|
97
106
|
return `${year}${month}${day}`;
|
|
98
107
|
}
|
|
99
108
|
|
|
109
|
+
/**
|
|
110
|
+
* Formats a command argument for verbose logging.
|
|
111
|
+
*
|
|
112
|
+
* @param {string} arg Argument value.
|
|
113
|
+
* @returns {string} Formatted argument.
|
|
114
|
+
*/
|
|
115
|
+
function formatCommandArg(arg) {
|
|
116
|
+
if (arg === '') return '""';
|
|
117
|
+
return /[\s"]/u.test(arg) ? JSON.stringify(arg) : arg;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Returns whether action logging should be printed.
|
|
122
|
+
*
|
|
123
|
+
* @returns {boolean} True when actions should be logged.
|
|
124
|
+
*/
|
|
125
|
+
function shouldLogActions() {
|
|
126
|
+
return verboseCommands || dryRunMode;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Formats the shared action log prefix.
|
|
131
|
+
*
|
|
132
|
+
* @returns {string} Colored log prefix.
|
|
133
|
+
*/
|
|
134
|
+
function logPrefix() {
|
|
135
|
+
return dryRunMode ? `${green('[mb-run]')} ${reverse(magenta('[dry]'))}` : green('[mb-run]');
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Prints a command when --verbose is enabled.
|
|
140
|
+
*
|
|
141
|
+
* @param {string} command Executable.
|
|
142
|
+
* @param {string[]} args CLI args.
|
|
143
|
+
* @param {string} [cwd] Working directory.
|
|
144
|
+
*/
|
|
145
|
+
function logCommand(command, args, cwd = repoRoot) {
|
|
146
|
+
if (!shouldLogActions()) return;
|
|
147
|
+
console.log(`${logPrefix()} ${cyan(cwd)}>${[command, ...args].map(formatCommandArg).join(' ') ? ` ${[command, ...args].map(formatCommandArg).join(' ')}` : ''}`);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Prints a delete operation when --verbose is enabled.
|
|
152
|
+
*
|
|
153
|
+
* @param {string} targetPath Path being removed.
|
|
154
|
+
*/
|
|
155
|
+
function logDelete(targetPath) {
|
|
156
|
+
if (!shouldLogActions()) return;
|
|
157
|
+
const resolvedPath = path.resolve(targetPath);
|
|
158
|
+
console.log(`${logPrefix()} ${cyan(path.dirname(resolvedPath))}> ${brightRed('delete')} ${formatCommandArg(path.basename(resolvedPath))}`);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Prints a directory creation operation when actions are being logged.
|
|
163
|
+
*
|
|
164
|
+
* @param {string} dirPath Directory being created.
|
|
165
|
+
*/
|
|
166
|
+
function logCreateDir(dirPath) {
|
|
167
|
+
if (!shouldLogActions()) return;
|
|
168
|
+
const resolvedPath = path.resolve(dirPath);
|
|
169
|
+
console.log(`${logPrefix()} ${cyan(path.dirname(resolvedPath))}> ${brightYellow('mkdir')} ${formatCommandArg(path.basename(resolvedPath))}`);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Prints a file write operation when actions are being logged.
|
|
174
|
+
*
|
|
175
|
+
* @param {string} filePath File being written.
|
|
176
|
+
*/
|
|
177
|
+
function logWriteFile(filePath) {
|
|
178
|
+
if (!shouldLogActions()) return;
|
|
179
|
+
const resolvedPath = path.resolve(filePath);
|
|
180
|
+
console.log(`${logPrefix()} ${cyan(path.dirname(resolvedPath))}> ${brightYellow('write')} ${formatCommandArg(path.basename(resolvedPath))}`);
|
|
181
|
+
}
|
|
182
|
+
|
|
100
183
|
/**
|
|
101
184
|
* Returns a 7-char git SHA from the current repo.
|
|
102
185
|
*
|
|
@@ -104,6 +187,7 @@ function formatYyyymmdd(date) {
|
|
|
104
187
|
* @returns {string} sha7.
|
|
105
188
|
*/
|
|
106
189
|
function shortSha7FromGit(cwd) {
|
|
190
|
+
logCommand('git', ['rev-parse', '--short=7', 'HEAD'], cwd);
|
|
107
191
|
const out = execFileSync('git', ['rev-parse', '--short=7', 'HEAD'], {
|
|
108
192
|
cwd,
|
|
109
193
|
encoding: 'utf8',
|
|
@@ -300,9 +384,7 @@ async function updateWorkspaceDependencyVersions(targetVersion) {
|
|
|
300
384
|
if (!workspaceNames.has(depName)) continue;
|
|
301
385
|
if (depName === selfName) continue;
|
|
302
386
|
|
|
303
|
-
const
|
|
304
|
-
const prefix = current.startsWith('~') ? '~' : '^';
|
|
305
|
-
const nextRange = `${prefix}${targetVersion}`;
|
|
387
|
+
const nextRange = targetVersion;
|
|
306
388
|
if (deps[depName] !== nextRange) {
|
|
307
389
|
deps[depName] = nextRange;
|
|
308
390
|
changed = true;
|
|
@@ -311,6 +393,8 @@ async function updateWorkspaceDependencyVersions(targetVersion) {
|
|
|
311
393
|
}
|
|
312
394
|
|
|
313
395
|
if (changed) {
|
|
396
|
+
logWriteFile(packageJsonPath);
|
|
397
|
+
if (dryRunMode) return;
|
|
314
398
|
await writeFile(packageJsonPath, `${JSON.stringify(pkg, null, 2)}\n`, 'utf8');
|
|
315
399
|
}
|
|
316
400
|
}),
|
|
@@ -414,10 +498,11 @@ async function runWorkspaceBuild(options) {
|
|
|
414
498
|
* @returns {Promise<void>} Resolves when the tool exits successfully.
|
|
415
499
|
*/
|
|
416
500
|
async function runBin(binName, args, options = {}) {
|
|
417
|
-
await assertBinExists(binName);
|
|
418
|
-
|
|
419
501
|
const entry = entrypointPath(binName);
|
|
420
502
|
if (entry) {
|
|
503
|
+
logCommand(process.execPath, [entry, ...args]);
|
|
504
|
+
if (dryRunMode) return;
|
|
505
|
+
await assertBinExists(binName);
|
|
421
506
|
const child = spawn(process.execPath, [entry, ...args], {
|
|
422
507
|
stdio: 'inherit',
|
|
423
508
|
env: { ...process.env, ...options.env },
|
|
@@ -434,6 +519,9 @@ async function runBin(binName, args, options = {}) {
|
|
|
434
519
|
return;
|
|
435
520
|
}
|
|
436
521
|
|
|
522
|
+
logCommand(binPath(binName), args);
|
|
523
|
+
if (dryRunMode) return;
|
|
524
|
+
await assertBinExists(binName);
|
|
437
525
|
const child = isWindows
|
|
438
526
|
? spawn('cmd.exe', ['/d', '/s', '/c', binPath(binName), ...args], {
|
|
439
527
|
stdio: 'inherit',
|
|
@@ -461,6 +549,8 @@ async function runBin(binName, args, options = {}) {
|
|
|
461
549
|
* @returns {Promise<void>} Resolves when removed.
|
|
462
550
|
*/
|
|
463
551
|
async function removePath(targetPath) {
|
|
552
|
+
logDelete(targetPath);
|
|
553
|
+
if (dryRunMode) return;
|
|
464
554
|
await rm(targetPath, { recursive: true, force: true });
|
|
465
555
|
}
|
|
466
556
|
|
|
@@ -471,6 +561,8 @@ async function removePath(targetPath) {
|
|
|
471
561
|
* @returns {Promise<void>} Resolves when the directory exists.
|
|
472
562
|
*/
|
|
473
563
|
async function ensureDir(dirPath) {
|
|
564
|
+
logCreateDir(dirPath);
|
|
565
|
+
if (dryRunMode) return;
|
|
474
566
|
await mkdir(dirPath, { recursive: true });
|
|
475
567
|
}
|
|
476
568
|
|
|
@@ -481,6 +573,10 @@ async function ensureDir(dirPath) {
|
|
|
481
573
|
* @returns {Promise<void>} Resolves when emptied.
|
|
482
574
|
*/
|
|
483
575
|
async function emptyDir(dirPath) {
|
|
576
|
+
if (dryRunMode && !(await fileExists(dirPath))) {
|
|
577
|
+
logCreateDir(dirPath);
|
|
578
|
+
return;
|
|
579
|
+
}
|
|
484
580
|
await ensureDir(dirPath);
|
|
485
581
|
const entries = await readdir(dirPath, { withFileTypes: true });
|
|
486
582
|
await Promise.all(
|
|
@@ -567,6 +663,7 @@ async function cleanWorkspaceArtifacts(parentDir, options = { ensureDirs: false
|
|
|
567
663
|
.map(async (d) => {
|
|
568
664
|
const wsRoot = path.join(parentDir, d.name);
|
|
569
665
|
await Promise.all([
|
|
666
|
+
removePath(path.join(wsRoot, 'build')),
|
|
570
667
|
removePath(path.join(wsRoot, 'dist')),
|
|
571
668
|
removePath(path.join(wsRoot, 'dist-jest')),
|
|
572
669
|
removePath(path.join(wsRoot, 'coverage')),
|
|
@@ -594,6 +691,7 @@ async function commonClean(options) {
|
|
|
594
691
|
await removeTsBuildInfo(repoRoot);
|
|
595
692
|
|
|
596
693
|
await Promise.all([
|
|
694
|
+
removePath(path.join(repoRoot, 'build')),
|
|
597
695
|
removePath(path.join(repoRoot, 'dist')),
|
|
598
696
|
removePath(path.join(repoRoot, 'dist-jest')),
|
|
599
697
|
removePath(path.join(repoRoot, 'coverage')),
|
|
@@ -645,6 +743,8 @@ async function cleanOnly() {
|
|
|
645
743
|
async function runCommand(command, args, options = {}) {
|
|
646
744
|
const resolvedCommand = isWindows && path.extname(command) === '' ? `${command}.cmd` : command;
|
|
647
745
|
const isCmdShim = isWindows && ['.cmd', '.bat'].includes(path.extname(resolvedCommand).toLowerCase());
|
|
746
|
+
logCommand(resolvedCommand, args, options.cwd);
|
|
747
|
+
if (dryRunMode) return;
|
|
648
748
|
const child = isCmdShim
|
|
649
749
|
? spawn('cmd.exe', ['/d', '/s', '/c', resolvedCommand, ...args], {
|
|
650
750
|
stdio: 'inherit',
|
|
@@ -698,12 +798,17 @@ async function main() {
|
|
|
698
798
|
'--lint-fix',
|
|
699
799
|
'--format',
|
|
700
800
|
'--format-check',
|
|
801
|
+
'--dry-run',
|
|
701
802
|
'--reset',
|
|
702
803
|
'--version',
|
|
804
|
+
'--verbose',
|
|
703
805
|
'--help',
|
|
704
806
|
'-h',
|
|
705
807
|
]);
|
|
706
808
|
|
|
809
|
+
dryRunMode = rawArgs.includes('--dry-run');
|
|
810
|
+
verboseCommands = rawArgs.includes('--verbose');
|
|
811
|
+
|
|
707
812
|
const versionIndex = rawArgs.indexOf('--version');
|
|
708
813
|
const candidateVersionArg = versionIndex >= 0 ? rawArgs[versionIndex + 1] : undefined;
|
|
709
814
|
const rawVersionTag = typeof candidateVersionArg === 'string' && !candidateVersionArg.startsWith('-') ? candidateVersionArg : undefined;
|
|
@@ -817,3 +922,236 @@ try {
|
|
|
817
922
|
console.error(error instanceof Error ? error.message : error);
|
|
818
923
|
process.exitCode = exitCode;
|
|
819
924
|
}
|
|
925
|
+
|
|
926
|
+
/**
|
|
927
|
+
* Returns whether ANSI output should be used.
|
|
928
|
+
*
|
|
929
|
+
* @returns {boolean} True when ANSI output is enabled.
|
|
930
|
+
*/
|
|
931
|
+
function shouldUseAnsi() {
|
|
932
|
+
if (process.env.NO_COLOR) return false;
|
|
933
|
+
if (process.env.TERM === 'dumb') return false;
|
|
934
|
+
return Boolean(process.stdout?.isTTY);
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
/**
|
|
938
|
+
* Wraps text with an ANSI style when enabled.
|
|
939
|
+
*
|
|
940
|
+
* @param {string} open Opening ANSI code.
|
|
941
|
+
* @param {string} close Closing ANSI code.
|
|
942
|
+
* @param {string} text Text to style.
|
|
943
|
+
* @returns {string} Styled or plain text.
|
|
944
|
+
*/
|
|
945
|
+
function wrapAnsi(open, close, text) {
|
|
946
|
+
return shouldUseAnsi() ? `${open}${text}${close}` : text;
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
/**
|
|
950
|
+
* Applies reverse-video ANSI styling.
|
|
951
|
+
*
|
|
952
|
+
* @param {string} text Text to style.
|
|
953
|
+
* @returns {string} Styled text.
|
|
954
|
+
*/
|
|
955
|
+
function reverse(text) {
|
|
956
|
+
return wrapAnsi('\u001B[7m', '\u001B[27m', text);
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
/**
|
|
960
|
+
* Applies black ANSI styling.
|
|
961
|
+
*
|
|
962
|
+
* @param {string} text Text to style.
|
|
963
|
+
* @returns {string} Styled text.
|
|
964
|
+
*/
|
|
965
|
+
function black(text) {
|
|
966
|
+
return wrapAnsi('\u001B[30m', '\u001B[39m', text);
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
/**
|
|
970
|
+
* Applies red ANSI styling.
|
|
971
|
+
*
|
|
972
|
+
* @param {string} text Text to style.
|
|
973
|
+
* @returns {string} Styled text.
|
|
974
|
+
*/
|
|
975
|
+
function red(text) {
|
|
976
|
+
return wrapAnsi('\u001B[31m', '\u001B[39m', text);
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
/**
|
|
980
|
+
* Applies green ANSI styling.
|
|
981
|
+
*
|
|
982
|
+
* @param {string} text Text to style.
|
|
983
|
+
* @returns {string} Styled text.
|
|
984
|
+
*/
|
|
985
|
+
function green(text) {
|
|
986
|
+
return wrapAnsi('\u001B[32m', '\u001B[39m', text);
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
/**
|
|
990
|
+
* Applies yellow ANSI styling.
|
|
991
|
+
*
|
|
992
|
+
* @param {string} text Text to style.
|
|
993
|
+
* @returns {string} Styled text.
|
|
994
|
+
*/
|
|
995
|
+
function yellow(text) {
|
|
996
|
+
return wrapAnsi('\u001B[33m', '\u001B[39m', text);
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
/**
|
|
1000
|
+
* Applies blue ANSI styling.
|
|
1001
|
+
*
|
|
1002
|
+
* @param {string} text Text to style.
|
|
1003
|
+
* @returns {string} Styled text.
|
|
1004
|
+
*/
|
|
1005
|
+
function blue(text) {
|
|
1006
|
+
return wrapAnsi('\u001B[34m', '\u001B[39m', text);
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
/**
|
|
1010
|
+
* Applies magenta ANSI styling.
|
|
1011
|
+
*
|
|
1012
|
+
* @param {string} text Text to style.
|
|
1013
|
+
* @returns {string} Styled text.
|
|
1014
|
+
*/
|
|
1015
|
+
function magenta(text) {
|
|
1016
|
+
return wrapAnsi('\u001B[35m', '\u001B[39m', text);
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
/**
|
|
1020
|
+
* Applies cyan ANSI styling.
|
|
1021
|
+
*
|
|
1022
|
+
* @param {string} text Text to style.
|
|
1023
|
+
* @returns {string} Styled text.
|
|
1024
|
+
*/
|
|
1025
|
+
function cyan(text) {
|
|
1026
|
+
return wrapAnsi('\u001B[36m', '\u001B[39m', text);
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
/**
|
|
1030
|
+
* Applies white ANSI styling.
|
|
1031
|
+
*
|
|
1032
|
+
* @param {string} text Text to style.
|
|
1033
|
+
* @returns {string} Styled text.
|
|
1034
|
+
*/
|
|
1035
|
+
function white(text) {
|
|
1036
|
+
return wrapAnsi('\u001B[37m', '\u001B[39m', text);
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
/**
|
|
1040
|
+
* Applies bright black ANSI styling.
|
|
1041
|
+
*
|
|
1042
|
+
* @param {string} text Text to style.
|
|
1043
|
+
* @returns {string} Styled text.
|
|
1044
|
+
*/
|
|
1045
|
+
function brightBlack(text) {
|
|
1046
|
+
return wrapAnsi('\u001B[90m', '\u001B[39m', text);
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
/**
|
|
1050
|
+
* Applies bright red ANSI styling.
|
|
1051
|
+
*
|
|
1052
|
+
* @param {string} text Text to style.
|
|
1053
|
+
* @returns {string} Styled text.
|
|
1054
|
+
*/
|
|
1055
|
+
function brightRed(text) {
|
|
1056
|
+
return wrapAnsi('\u001B[91m', '\u001B[39m', text);
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
/**
|
|
1060
|
+
* Applies bright green ANSI styling.
|
|
1061
|
+
*
|
|
1062
|
+
* @param {string} text Text to style.
|
|
1063
|
+
* @returns {string} Styled text.
|
|
1064
|
+
*/
|
|
1065
|
+
function brightGreen(text) {
|
|
1066
|
+
return wrapAnsi('\u001B[92m', '\u001B[39m', text);
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
/**
|
|
1070
|
+
* Applies bright yellow ANSI styling.
|
|
1071
|
+
*
|
|
1072
|
+
* @param {string} text Text to style.
|
|
1073
|
+
* @returns {string} Styled text.
|
|
1074
|
+
*/
|
|
1075
|
+
function brightYellow(text) {
|
|
1076
|
+
return wrapAnsi('\u001B[93m', '\u001B[39m', text);
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
/**
|
|
1080
|
+
* Applies bright blue ANSI styling.
|
|
1081
|
+
*
|
|
1082
|
+
* @param {string} text Text to style.
|
|
1083
|
+
* @returns {string} Styled text.
|
|
1084
|
+
*/
|
|
1085
|
+
function brightBlue(text) {
|
|
1086
|
+
return wrapAnsi('\u001B[94m', '\u001B[39m', text);
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
/**
|
|
1090
|
+
* Applies bright magenta ANSI styling.
|
|
1091
|
+
*
|
|
1092
|
+
* @param {string} text Text to style.
|
|
1093
|
+
* @returns {string} Styled text.
|
|
1094
|
+
*/
|
|
1095
|
+
function brightMagenta(text) {
|
|
1096
|
+
return wrapAnsi('\u001B[95m', '\u001B[39m', text);
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
/**
|
|
1100
|
+
* Applies bright cyan ANSI styling.
|
|
1101
|
+
*
|
|
1102
|
+
* @param {string} text Text to style.
|
|
1103
|
+
* @returns {string} Styled text.
|
|
1104
|
+
*/
|
|
1105
|
+
function brightCyan(text) {
|
|
1106
|
+
return wrapAnsi('\u001B[96m', '\u001B[39m', text);
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
/**
|
|
1110
|
+
* Applies bright white ANSI styling.
|
|
1111
|
+
*
|
|
1112
|
+
* @param {string} text Text to style.
|
|
1113
|
+
* @returns {string} Styled text.
|
|
1114
|
+
*/
|
|
1115
|
+
function brightWhite(text) {
|
|
1116
|
+
return wrapAnsi('\u001B[97m', '\u001B[39m', text);
|
|
1117
|
+
}
|
|
1118
|
+
|
|
1119
|
+
/**
|
|
1120
|
+
* Saves the current cursor position.
|
|
1121
|
+
*
|
|
1122
|
+
* @returns {string} ANSI cursor save sequence.
|
|
1123
|
+
*/
|
|
1124
|
+
function savePos() {
|
|
1125
|
+
return shouldUseAnsi() ? '\u001B[s' : '';
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
/**
|
|
1129
|
+
* Restores the saved cursor position and clears everything after it.
|
|
1130
|
+
*
|
|
1131
|
+
* @returns {string} ANSI cursor restore and clear sequence.
|
|
1132
|
+
*/
|
|
1133
|
+
function restorePos() {
|
|
1134
|
+
return shouldUseAnsi() ? '\u001B[u\u001B[J' : '';
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
export {
|
|
1138
|
+
black,
|
|
1139
|
+
blue,
|
|
1140
|
+
brightBlack,
|
|
1141
|
+
brightBlue,
|
|
1142
|
+
brightCyan,
|
|
1143
|
+
brightGreen,
|
|
1144
|
+
brightMagenta,
|
|
1145
|
+
brightRed,
|
|
1146
|
+
brightWhite,
|
|
1147
|
+
brightYellow,
|
|
1148
|
+
cyan,
|
|
1149
|
+
green,
|
|
1150
|
+
magenta,
|
|
1151
|
+
red,
|
|
1152
|
+
restorePos,
|
|
1153
|
+
reverse,
|
|
1154
|
+
savePos,
|
|
1155
|
+
white,
|
|
1156
|
+
yellow,
|
|
1157
|
+
};
|