icoa-cli 1.4.2 → 1.4.4
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/dist/index.js +4 -3
- package/dist/lib/theme.d.ts +2 -0
- package/dist/lib/theme.js +52 -0
- package/dist/repl.js +4 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -14,6 +14,7 @@ import { registerSetupCommand } from './commands/setup.js';
|
|
|
14
14
|
import { getConfig, saveConfig } from './lib/config.js';
|
|
15
15
|
import { startRepl } from './repl.js';
|
|
16
16
|
import { checkTerminal } from './lib/terminal.js';
|
|
17
|
+
import { setTerminalTheme } from './lib/theme.js';
|
|
17
18
|
// Banner: each line between ║ ║ = exactly 58 visible chars
|
|
18
19
|
const B = chalk.cyan('║');
|
|
19
20
|
const BANNER = `
|
|
@@ -36,7 +37,7 @@ ${B} ${B}
|
|
|
36
37
|
${B} ${chalk.white('Sydney, Australia')} ${chalk.gray('Jun 27 - Jul 2, 2026')} ${B}
|
|
37
38
|
${B} ${chalk.cyan.underline('https://icoa2026.au')} ${B}
|
|
38
39
|
${B} ${B}
|
|
39
|
-
${B} ${chalk.gray('CLI-Native Competition Terminal v1.4.
|
|
40
|
+
${B} ${chalk.gray('CLI-Native Competition Terminal v1.4.4')} ${B}
|
|
40
41
|
${B} ${B}
|
|
41
42
|
${chalk.cyan('╚══════════════════════════════════════════════════════════╝')}
|
|
42
43
|
`;
|
|
@@ -61,8 +62,8 @@ program
|
|
|
61
62
|
.description('ICOA CLI — CLI-Native CTF Competition Terminal')
|
|
62
63
|
.option('--resume', 'Resume previous session')
|
|
63
64
|
.action((opts) => {
|
|
64
|
-
// Force black background
|
|
65
|
-
|
|
65
|
+
// Force hacker theme: black background + green text
|
|
66
|
+
setTerminalTheme();
|
|
66
67
|
console.log(BANNER);
|
|
67
68
|
checkTerminal();
|
|
68
69
|
// If running interactively (no extra args or --resume), start REPL
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { execSync } from 'node:child_process';
|
|
2
|
+
import { platform } from 'node:os';
|
|
3
|
+
export function setTerminalTheme() {
|
|
4
|
+
const os = platform();
|
|
5
|
+
if (os === 'darwin') {
|
|
6
|
+
// macOS Terminal.app: use AppleScript to change colors
|
|
7
|
+
try {
|
|
8
|
+
execSync(`osascript -e '
|
|
9
|
+
tell application "Terminal"
|
|
10
|
+
set bg to {0, 0, 0}
|
|
11
|
+
set fg to {0, 65535, 16896}
|
|
12
|
+
set background color of selected tab of front window to bg
|
|
13
|
+
set normal text color of selected tab of front window to fg
|
|
14
|
+
set cursor color of selected tab of front window to fg
|
|
15
|
+
end tell
|
|
16
|
+
'`, { stdio: 'ignore' });
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
// Fallback to ANSI if AppleScript fails (e.g. not Terminal.app)
|
|
20
|
+
process.stdout.write('\x1b[0m\x1b[40m\x1b[38;2;0;255;65m\x1b[2J\x1b[H');
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
// Linux / Windows: ANSI escape codes
|
|
25
|
+
process.stdout.write('\x1b[0m\x1b[40m\x1b[38;2;0;255;65m\x1b[2J\x1b[H');
|
|
26
|
+
}
|
|
27
|
+
// Clear screen
|
|
28
|
+
process.stdout.write('\x1b[2J\x1b[H');
|
|
29
|
+
}
|
|
30
|
+
export function resetTerminalTheme() {
|
|
31
|
+
const os = platform();
|
|
32
|
+
if (os === 'darwin') {
|
|
33
|
+
try {
|
|
34
|
+
// Reset to macOS Terminal.app default profile colors
|
|
35
|
+
execSync(`osascript -e '
|
|
36
|
+
tell application "Terminal"
|
|
37
|
+
set bg to {65535, 65535, 65535}
|
|
38
|
+
set fg to {0, 0, 0}
|
|
39
|
+
set background color of selected tab of front window to bg
|
|
40
|
+
set normal text color of selected tab of front window to fg
|
|
41
|
+
set cursor color of selected tab of front window to fg
|
|
42
|
+
end tell
|
|
43
|
+
'`, { stdio: 'ignore' });
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
process.stdout.write('\x1b[0m\x1b[2J\x1b[H');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
process.stdout.write('\x1b[0m\x1b[2J\x1b[H');
|
|
51
|
+
}
|
|
52
|
+
}
|
package/dist/repl.js
CHANGED
|
@@ -3,6 +3,7 @@ import { spawn } from 'node:child_process';
|
|
|
3
3
|
import chalk from 'chalk';
|
|
4
4
|
import { isConnected, getConfig } from './lib/config.js';
|
|
5
5
|
import { isActivated, activateToken, isFreeCommand, isDeviceMatch, recordExit, recordResume } from './lib/access.js';
|
|
6
|
+
import { resetTerminalTheme } from './lib/theme.js';
|
|
6
7
|
const INTERCEPT = '__REPL_NO_EXIT__';
|
|
7
8
|
export function startRepl(program, resumeMode) {
|
|
8
9
|
const config = getConfig();
|
|
@@ -51,7 +52,7 @@ export function startRepl(program, resumeMode) {
|
|
|
51
52
|
const rl = createInterface({
|
|
52
53
|
input: process.stdin,
|
|
53
54
|
output: process.stdout,
|
|
54
|
-
prompt: chalk.
|
|
55
|
+
prompt: chalk.green('icoa> '),
|
|
55
56
|
terminal: true,
|
|
56
57
|
});
|
|
57
58
|
let processing = false;
|
|
@@ -68,7 +69,7 @@ export function startRepl(program, resumeMode) {
|
|
|
68
69
|
if (input === 'exit' || input === 'quit' || input === 'q') {
|
|
69
70
|
recordExit();
|
|
70
71
|
console.log(chalk.gray(' Session saved. Use ') + chalk.white('icoa --resume') + chalk.gray(' to continue.'));
|
|
71
|
-
|
|
72
|
+
resetTerminalTheme();
|
|
72
73
|
realExit(0);
|
|
73
74
|
return;
|
|
74
75
|
}
|
|
@@ -168,7 +169,7 @@ export function startRepl(program, resumeMode) {
|
|
|
168
169
|
});
|
|
169
170
|
rl.on('close', () => {
|
|
170
171
|
recordExit();
|
|
171
|
-
|
|
172
|
+
resetTerminalTheme();
|
|
172
173
|
realExit(0);
|
|
173
174
|
});
|
|
174
175
|
}
|