icoa-cli 1.3.4 → 1.4.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/dist/index.js +1 -1
- package/dist/repl.js +29 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -36,7 +36,7 @@ ${B} ${B}
|
|
|
36
36
|
${B} ${chalk.white('Sydney, Australia')} ${chalk.gray('Jun 27 - Jul 2, 2026')} ${B}
|
|
37
37
|
${B} ${chalk.cyan.underline('https://icoa2026.au')} ${B}
|
|
38
38
|
${B} ${B}
|
|
39
|
-
${B} ${chalk.gray('CLI-Native Competition Terminal v1.
|
|
39
|
+
${B} ${chalk.gray('CLI-Native Competition Terminal v1.4.0')} ${B}
|
|
40
40
|
${B} ${B}
|
|
41
41
|
${chalk.cyan('╚══════════════════════════════════════════════════════════╝')}
|
|
42
42
|
`;
|
package/dist/repl.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createInterface } from 'node:readline';
|
|
2
|
+
import { spawn } from 'node:child_process';
|
|
2
3
|
import chalk from 'chalk';
|
|
3
4
|
import { isConnected, getConfig } from './lib/config.js';
|
|
4
5
|
import { isActivated, activateToken, isFreeCommand, isDeviceMatch, recordExit, recordResume } from './lib/access.js';
|
|
@@ -116,7 +117,7 @@ export function startRepl(program, resumeMode) {
|
|
|
116
117
|
rl.prompt();
|
|
117
118
|
return;
|
|
118
119
|
}
|
|
119
|
-
// Check if it's a known command
|
|
120
|
+
// Check if it's a known ICOA command or a system command
|
|
120
121
|
const knownCommands = [
|
|
121
122
|
'join', 'activate', 'challenges', 'ch', 'open', 'submit', 'flag',
|
|
122
123
|
'scoreboard', 'sb', 'status', 'time', 'hint', 'hint-b', 'hint-c',
|
|
@@ -124,7 +125,15 @@ export function startRepl(program, resumeMode) {
|
|
|
124
125
|
'lang', 'setup', 'model', 'ctf',
|
|
125
126
|
];
|
|
126
127
|
if (!knownCommands.includes(cmd)) {
|
|
127
|
-
|
|
128
|
+
// Pass through to system shell
|
|
129
|
+
processing = true;
|
|
130
|
+
try {
|
|
131
|
+
await runSystemCommand(input, rl);
|
|
132
|
+
}
|
|
133
|
+
catch {
|
|
134
|
+
console.log(chalk.yellow(` Command failed: ${cmd}`));
|
|
135
|
+
}
|
|
136
|
+
processing = false;
|
|
128
137
|
console.log();
|
|
129
138
|
rl.prompt();
|
|
130
139
|
return;
|
|
@@ -161,6 +170,24 @@ export function startRepl(program, resumeMode) {
|
|
|
161
170
|
realExit(0);
|
|
162
171
|
});
|
|
163
172
|
}
|
|
173
|
+
function runSystemCommand(input, rl) {
|
|
174
|
+
return new Promise((resolve) => {
|
|
175
|
+
// Pause readline so the child process gets full terminal control
|
|
176
|
+
rl.pause();
|
|
177
|
+
const child = spawn(input, {
|
|
178
|
+
shell: true,
|
|
179
|
+
stdio: 'inherit',
|
|
180
|
+
});
|
|
181
|
+
child.on('close', () => {
|
|
182
|
+
rl.resume();
|
|
183
|
+
resolve();
|
|
184
|
+
});
|
|
185
|
+
child.on('error', () => {
|
|
186
|
+
rl.resume();
|
|
187
|
+
resolve();
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
}
|
|
164
191
|
function mapCommand(input) {
|
|
165
192
|
const parts = input.split(/\s+/);
|
|
166
193
|
const cmd = parts[0].toLowerCase();
|