@devquest/cli 1.1.2 → 1.1.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.
@@ -17,13 +17,13 @@ function runStage(stageOrder, cwd) {
17
17
  try { userApp = require('./src/index'); }
18
18
  catch(e: any) { console.error('[!] Falha ao importar src/index.ts: ' + e.message); process.exit(1); }
19
19
 
20
- function assert(condition: boolean, failMsg: string, expected?: any, got?: any) {
20
+ const chalk = require('chalk');
21
+ function assert(condition, failMsg, expected, got) {
21
22
  if (!condition) {
22
- console.error('\\n❌ FALHA DE ASSERÇÃO');
23
- console.error('📝 ' + failMsg);
24
- if (expected !== undefined) console.error('🎯 Esperado : ' + String(expected));
25
- if (got !== undefined) console.error('💥 Recebido : ' + String(got));
26
- console.error('');
23
+ console.error('\\n' + chalk.bgRed.white.bold(' ❌ FALHA DE ASSERÇÃO ') + '\\n');
24
+ console.error(chalk.yellow('📝 Resumo: ') + failMsg + '\\n');
25
+ console.error(chalk.bgBlue.white.bold(' 🎯 ESPERADO ') + '\\n' + chalk.blue(expected) + '\\n');
26
+ console.error(chalk.bgMagenta.white.bold(' 💥 RECEBIDO ') + '\\n' + chalk.magenta(got) + '\\n');
27
27
  process.exit(1);
28
28
  }
29
29
  }
@@ -92,13 +92,13 @@ function runStage(stageOrder, cwd) {
92
92
  try { userApp = require('./src/index'); }
93
93
  catch(e: any) { console.error('[!] Erro de importação: ' + e.message); process.exit(1); }
94
94
 
95
- function assert(condition: boolean, failMsg: string, expected?: any, got?: any) {
95
+ const chalk = require('chalk');
96
+ function assert(condition, failMsg, expected, got) {
96
97
  if (!condition) {
97
- console.error('\\n❌ FALHA DE ASSERÇÃO');
98
- console.error('📝 ' + failMsg);
99
- if (expected !== undefined) console.error('🎯 Esperado : ' + String(expected));
100
- if (got !== undefined) console.error('💥 Recebido : ' + String(got));
101
- console.error('');
98
+ console.error('\\n' + chalk.bgRed.white.bold(' ❌ FALHA DE ASSERÇÃO ') + '\\n');
99
+ console.error(chalk.yellow('📝 Resumo: ') + failMsg + '\\n');
100
+ console.error(chalk.bgBlue.white.bold(' 🎯 ESPERADO ') + '\\n' + chalk.blue(expected) + '\\n');
101
+ console.error(chalk.bgMagenta.white.bold(' 💥 RECEBIDO ') + '\\n' + chalk.magenta(got) + '\\n');
102
102
  process.exit(1);
103
103
  }
104
104
  }
@@ -141,13 +141,13 @@ function runStage(stageOrder, cwd) {
141
141
  try { userApp = require('./src/index'); }
142
142
  catch(e: any) { console.error('[!] Erro de importação: ' + e.message); process.exit(1); }
143
143
 
144
- function assert(condition: boolean, failMsg: string, expected?: any, got?: any) {
144
+ const chalk = require('chalk');
145
+ function assert(condition, failMsg, expected, got) {
145
146
  if (!condition) {
146
- console.error('\\n❌ FALHA DE ASSERÇÃO');
147
- console.error('📝 ' + failMsg);
148
- if (expected !== undefined) console.error('🎯 Esperado : ' + String(expected));
149
- if (got !== undefined) console.error('💥 Recebido : ' + String(got));
150
- console.error('');
147
+ console.error('\\n' + chalk.bgRed.white.bold(' ❌ FALHA DE ASSERÇÃO ') + '\\n');
148
+ console.error(chalk.yellow('📝 Resumo: ') + failMsg + '\\n');
149
+ console.error(chalk.bgBlue.white.bold(' 🎯 ESPERADO ') + '\\n' + chalk.blue(expected) + '\\n');
150
+ console.error(chalk.bgMagenta.white.bold(' 💥 RECEBIDO ') + '\\n' + chalk.magenta(got) + '\\n');
151
151
  process.exit(1);
152
152
  }
153
153
  }
@@ -17,13 +17,13 @@ function runStage(stageOrder, cwd) {
17
17
  const fs = require('fs');
18
18
  const path = require('path');
19
19
 
20
- function assert(condition: boolean, failMsg: string, expected?: any, got?: any) {
20
+ const chalk = require('chalk');
21
+ function assert(condition, failMsg, expected, got) {
21
22
  if (!condition) {
22
- console.error('\\n❌ FALHA DE ASSERÇÃO');
23
- console.error('📝 ' + failMsg);
24
- if (expected !== undefined) console.error('🎯 Esperado : ' + String(expected));
25
- if (got !== undefined) console.error('💥 Recebido : ' + String(got));
26
- console.error('');
23
+ console.error('\\n' + chalk.bgRed.white.bold(' ❌ FALHA DE ASSERÇÃO ') + '\\n');
24
+ console.error(chalk.yellow('📝 Resumo: ') + failMsg + '\\n');
25
+ console.error(chalk.bgBlue.white.bold(' 🎯 ESPERADO ') + '\\n' + chalk.blue(expected) + '\\n');
26
+ console.error(chalk.bgMagenta.white.bold(' 💥 RECEBIDO ') + '\\n' + chalk.magenta(got) + '\\n');
27
27
  process.exit(1);
28
28
  }
29
29
  }
@@ -36,12 +36,11 @@ async function testStage1(cwd) {
36
36
  return false;
37
37
  }
38
38
  if (runValid.stdout.trim() !== sampleContent.trim()) {
39
- console.log(chalk_1.default.red(`\nErro: O conteúdo impresso no stdout não coincide exatamente com o esperado.`));
40
- console.log(chalk_1.default.bgGreen.black('\n ESPERADO (Correct Content) '));
41
- console.log(chalk_1.default.green(sampleContent));
42
- console.log(chalk_1.default.bgRed.black('\n RECEBIDO (Your Output) '));
43
- console.log(chalk_1.default.red(runValid.stdout));
44
- console.log(chalk_1.default.yellow(`\n💡 Dica: Verifique se você não está imprimindo mensagens de depuração ou espaços extras.`));
39
+ console.error('\n' + chalk_1.default.bgRed.white.bold(' FALHA DE ASSERÇÃO ') + '\n');
40
+ console.error(chalk_1.default.yellow('📝 Resumo: ') + 'O conteúdo impresso no stdout não coincide exatamente com o esperado.\n');
41
+ console.error(chalk_1.default.bgBlue.white.bold(' 🎯 ESPERADO ') + '\n' + chalk_1.default.blue(sampleContent) + '\n');
42
+ console.error(chalk_1.default.bgMagenta.white.bold(' 💥 RECEBIDO ') + '\n' + chalk_1.default.magenta(runValid.stdout) + '\n');
43
+ console.log(chalk_1.default.yellow(`💡 Dica: Verifique se você não está imprimindo mensagens de depuração ou espaços extras.`));
45
44
  return false;
46
45
  }
47
46
  console.log(chalk_1.default.green(`✅ Conteúdo lido e impresso corretamente.`));
@@ -16,14 +16,14 @@ function runStage(stageOrder, cwd) {
16
16
  const fs = require('fs');
17
17
  const path = require('path');
18
18
  const { execSync } = require('child_process');
19
+ const chalk = require('chalk');
19
20
 
20
- function assert(condition: boolean, failMsg: string, expected?: any, got?: any) {
21
+ function assert(condition, failMsg, expected, got) {
21
22
  if (!condition) {
22
- console.error('\\n❌ FALHA DE ASSERÇÃO');
23
- console.error('📝 ' + failMsg);
24
- if (expected !== undefined) console.error('🎯 Esperado : ' + String(expected));
25
- if (got !== undefined) console.error('💥 Recebido : ' + String(got));
26
- console.error('');
23
+ console.error('\\n' + chalk.bgRed.white.bold(' ❌ FALHA DE ASSERÇÃO ') + '\\n');
24
+ console.error(chalk.yellow('📝 Resumo: ') + failMsg + '\\n');
25
+ console.error(chalk.bgBlue.white.bold(' 🎯 ESPERADO ') + '\\n' + chalk.blue(expected) + '\\n');
26
+ console.error(chalk.bgMagenta.white.bold(' 💥 RECEBIDO ') + '\\n' + chalk.magenta(got) + '\\n');
27
27
  process.exit(1);
28
28
  }
29
29
  }
@@ -56,7 +56,7 @@ function runStage(stageOrder, cwd) {
56
56
  return stdout.toString().includes('PASS');
57
57
  }
58
58
  catch (err) {
59
- console.log(chalk_1.default.red(err.stderr?.toString().trim() || err.stdout?.toString().trim() || err.message));
59
+ console.log(err.stdout?.toString().trim() || err.stderr?.toString().trim() || err.message);
60
60
  return false;
61
61
  }
62
62
  finally {
@@ -72,14 +72,14 @@ function runStage(stageOrder, cwd) {
72
72
  const path = require('path');
73
73
  const zlib = require('zlib');
74
74
  const { execSync } = require('child_process');
75
+ const chalk = require('chalk');
75
76
 
76
- function assert(condition: boolean, failMsg: string, expected?: any, got?: any) {
77
+ function assert(condition, failMsg, expected, got) {
77
78
  if (!condition) {
78
- console.error('\\n❌ FALHA DE ASSERÇÃO');
79
- console.error('📝 ' + failMsg);
80
- if (expected !== undefined) console.error('🎯 Esperado : ' + String(expected));
81
- if (got !== undefined) console.error('💥 Recebido : ' + String(got));
82
- console.error('');
79
+ console.error('\\n' + chalk.bgRed.white.bold(' ❌ FALHA DE ASSERÇÃO ') + '\\n');
80
+ console.error(chalk.yellow('📝 Resumo: ') + failMsg + '\\n');
81
+ console.error(chalk.bgBlue.white.bold(' 🎯 ESPERADO ') + '\\n' + chalk.blue(expected) + '\\n');
82
+ console.error(chalk.bgMagenta.white.bold(' 💥 RECEBIDO ') + '\\n' + chalk.magenta(got) + '\\n');
83
83
  process.exit(1);
84
84
  }
85
85
  }
@@ -117,7 +117,7 @@ function runStage(stageOrder, cwd) {
117
117
  return stdout.toString().includes('PASS');
118
118
  }
119
119
  catch (err) {
120
- console.log(chalk_1.default.red(err.stderr?.toString().trim() || err.stdout?.toString().trim() || err.message));
120
+ console.log(err.stdout?.toString().trim() || err.stderr?.toString().trim() || err.message);
121
121
  return false;
122
122
  }
123
123
  finally {
@@ -125,5 +125,6 @@ function runStage(stageOrder, cwd) {
125
125
  fs_1.default.unlinkSync(testFilePath);
126
126
  }
127
127
  }
128
+ console.log(chalk_1.default.yellow(`⚠️ Nenhuma suite implementada ainda para Stage ${stageOrder} deste desafio. Bypass (Aprovado).`));
128
129
  return true;
129
130
  }
@@ -8,38 +8,43 @@ const child_process_1 = require("child_process");
8
8
  const chalk_1 = __importDefault(require("chalk"));
9
9
  async function runStage(stageOrder, cwd) {
10
10
  if (stageOrder === 1) {
11
- console.log(chalk_1.default.blue(`[Stage 1: HTTP Server] Rodando TCP Connection Tests...`));
11
+ console.log(chalk_1.default.blue(`[Stage 1: HTTP Server] Verificando resposta "Hello, World!" na porta 3000...`));
12
12
  return new Promise(async (resolve) => {
13
13
  let child = null;
14
14
  try {
15
- console.log(chalk_1.default.gray(`Iniciando servidor do usário [node dist/index.js]...`));
16
- child = (0, child_process_1.spawn)('node', ['dist/index.js'], { cwd });
17
- await new Promise(r => setTimeout(r, 1500));
18
- console.log(chalk_1.default.gray(`Disparando Requests em rotas conhecidas e desconhecidas...`));
15
+ console.log(chalk_1.default.gray(`Iniciando seu servidor (npx ts-node src/index.ts)...`));
16
+ // Use TS-Node directly for consistency in tests
17
+ child = (0, child_process_1.spawn)('npx', ['ts-node', 'src/index.ts'], { cwd });
18
+ await new Promise(r => setTimeout(r, 2000));
19
19
  let passed = true;
20
- // TestCase 1: Invalid Route
21
20
  try {
22
- const res = await fetch('http://localhost:3000/rota-que-nao-existe');
23
- // The first stage of DevQuest TCP requires returning 200 dynamically by default if implemented simply,
24
- // but normally a baseline server just accepts socket connections.
25
- if (res.status) {
26
- console.log(chalk_1.default.green('✅ Conexão HTTP estabelecida com sucesso!'));
21
+ const res = await fetch('http://localhost:3000/');
22
+ const text = await res.text();
23
+ if (res.status === 200 && text.includes('Hello, World!')) {
24
+ console.log(chalk_1.default.green('✅ Servidor respondeu com 200 OK e "Hello, World!"'));
25
+ }
26
+ else {
27
+ console.error('\n' + chalk_1.default.bgRed.white.bold(' ❌ FALHA DE ASSERÇÃO ') + '\n');
28
+ console.error(chalk_1.default.yellow('📝 Resumo: ') + 'O servidor deve retornar "Hello, World!" com status 200.\n');
29
+ console.error(chalk_1.default.bgBlue.white.bold(' 🎯 ESPERADO ') + '\n' + chalk_1.default.blue('Status: 200, Body: Hello, World!') + '\n');
30
+ console.error(chalk_1.default.bgMagenta.white.bold(' 💥 RECEBIDO ') + '\n' + chalk_1.default.magenta(`Status: ${res.status}, Body: ${text.trim()}`) + '\n');
31
+ passed = false;
27
32
  }
28
33
  }
29
34
  catch (e) {
30
- console.log(chalk_1.default.red('❌ FALHA DE ASSERÇÃO\n📝 O servidor não aceitou a conexão TCP na porta 3000.\n🎯 Esperado : Conexão Open\n💥 Recebido : ECONNREFUSED'));
35
+ console.error('\n' + chalk_1.default.bgRed.white.bold(' ❌ FALHA DE CONEXÃO ') + '\n');
36
+ console.error(chalk_1.default.yellow('📝 Resumo: ') + 'Não foi possível conectar ao servidor na porta 3000.\n');
37
+ console.error(chalk_1.default.bgBlue.white.bold(' 🎯 ESPERADO ') + '\n' + chalk_1.default.blue('Servidor escutando na porta 3000') + '\n');
38
+ console.error(chalk_1.default.bgMagenta.white.bold(' 💥 RECEBIDO ') + '\n' + chalk_1.default.magenta(e.message) + '\n');
31
39
  passed = false;
32
40
  }
33
- // Testcase 2: Valid Param
34
- // HTTP framework challenge stage 1 generally involves simply binding a socket server.
35
- // Once bound, it passes.
36
41
  child.kill();
37
42
  resolve(passed);
38
43
  }
39
44
  catch (e) {
40
45
  if (child)
41
46
  child.kill();
42
- console.log(chalk_1.default.red('❌ Falha fatal ao executar o daemon local.'));
47
+ console.log(chalk_1.default.red('❌ Falha fatal ao executar seu servidor local.'));
43
48
  resolve(false);
44
49
  }
45
50
  });
@@ -16,14 +16,14 @@ function runStage(stageOrder, cwd) {
16
16
  const { execSync } = require('child_process');
17
17
  const fs = require('fs');
18
18
  const path = require('path');
19
+ const chalk = require('chalk');
19
20
 
20
- function assert(condition: boolean, failMsg: string, expected?: any, got?: any) {
21
+ function assert(condition, failMsg, expected, got) {
21
22
  if (!condition) {
22
- console.error('\\n❌ FALHA DE ASSERÇÃO');
23
- console.error('📝 ' + failMsg);
24
- if (expected !== undefined) console.error('🎯 Esperado : ' + String(expected));
25
- if (got !== undefined) console.error('💥 Recebido : ' + String(got));
26
- console.error('');
23
+ console.error('\\n' + chalk.bgRed.white.bold(' ❌ FALHA DE ASSERÇÃO ') + '\\n');
24
+ console.error(chalk.yellow('📝 Resumo: ') + failMsg + '\\n');
25
+ console.error(chalk.bgBlue.white.bold(' 🎯 ESPERADO ') + '\\n' + chalk.blue(expected) + '\\n');
26
+ console.error(chalk.bgMagenta.white.bold(' 💥 RECEBIDO ') + '\\n' + chalk.magenta(got) + '\\n');
27
27
  process.exit(1);
28
28
  }
29
29
  }
@@ -35,13 +35,14 @@ function runStage(stageOrder, cwd) {
35
35
 
36
36
  console.log('-> Testando subcomando: tokenize');
37
37
  const outputTokenize = execSync('npx ts-node src/index.ts tokenize test.lox', { cwd: '${cwd}', stdio: 'pipe' });
38
- assert(outputTokenize.toString().toLowerCase().includes('print') || outputTokenize.toString().toLowerCase().includes('hello'), 'O subcomando tokenize não funcionou.', 'Tokens: PRINT, STRING', outputTokenize.toString());
39
-
40
- console.log('-> Testando subcomando: run');
41
- const outputRun = execSync('npx ts-node src/index.ts run test.lox', { cwd: '${cwd}', stdio: 'pipe' });
42
- // Even if it doesn't run yet, it should at least not crash if implemented properly.
43
- // But we expect it to output 'hello' if implemented.
38
+ const outStr = outputTokenize.toString().toUpperCase();
44
39
 
40
+ assert(outStr.includes('PRINT') || outStr.includes('STRING'),
41
+ 'O subcomando tokenize deve imprimir os tokens encontrados.',
42
+ 'PRINT, STRING "hello" null',
43
+ outStr.trim()
44
+ );
45
+
45
46
  console.log('PASS');
46
47
  if (fs.existsSync(testFile)) fs.unlinkSync(testFile);
47
48
  } catch(e: any) {
@@ -57,7 +58,7 @@ function runStage(stageOrder, cwd) {
57
58
  return stdout.toString().includes('PASS');
58
59
  }
59
60
  catch (err) {
60
- console.log(chalk_1.default.red(err.stderr?.toString().trim() || err.stdout?.toString().trim() || err.message));
61
+ console.log(err.stdout?.toString().trim() || err.stderr?.toString().trim() || err.message);
61
62
  return false;
62
63
  }
63
64
  finally {
@@ -65,5 +66,6 @@ function runStage(stageOrder, cwd) {
65
66
  fs_1.default.unlinkSync(testFilePath);
66
67
  }
67
68
  }
69
+ console.log(chalk_1.default.yellow(`⚠️ Nenhuma suite implementada ainda para Stage ${stageOrder} deste desafio. Bypass (Aprovado).`));
68
70
  return true;
69
71
  }
@@ -8,15 +8,12 @@ const child_process_1 = require("child_process");
8
8
  const chalk_1 = __importDefault(require("chalk"));
9
9
  async function runStage(stageOrder, cwd) {
10
10
  if (stageOrder === 1) {
11
- console.log(chalk_1.default.blue(`[Stage 1: Redis TCP Bind] Verificando servidor TCP escutando na porta 6379...`));
11
+ console.log(chalk_1.default.blue(`[Stage 1: Redis TCP Bind] Verificando servidor TCP na porta 6379...`));
12
12
  return new Promise(async (resolve) => {
13
13
  let child = null;
14
14
  try {
15
- console.log(chalk_1.default.gray(`Iniciando servidor Redis do usuário (node src/index.js)...`));
16
- // Use ts-node -T to run the index.ts directly if that's the setup, or check if dist exists.
17
- // Assuming the Redis template follows the same pattern.
18
- child = (0, child_process_1.spawn)('npx', ['ts-node', '-T', 'src/index.ts'], { cwd });
19
- // Wait for bind
15
+ console.log(chalk_1.default.gray(`Iniciando servidor (npx ts-node src/index.ts)...`));
16
+ child = (0, child_process_1.spawn)('npx', ['ts-node', 'src/index.ts'], { cwd });
20
17
  await new Promise(r => setTimeout(r, 2000));
21
18
  let passed = false;
22
19
  const net = require('net');
@@ -28,29 +25,25 @@ async function runStage(stageOrder, cwd) {
28
25
  client.destroy();
29
26
  resolveSocket();
30
27
  });
31
- client.on('error', (err) => {
32
- rejectSocket(err);
33
- });
28
+ client.on('error', rejectSocket);
34
29
  setTimeout(() => rejectSocket(new Error('Timeout ao conectar')), 1000);
35
30
  });
36
31
  }
37
32
  catch (e) {
38
- console.error('\n❌ FALHA DE ASSERÇÃO');
39
- console.error('📝 O servidor não aceitou conexão TCP na porta 6379.');
40
- console.error('🎯 Esperado : Conexão Estabelecida (Port 6379)');
41
- console.error('💥 Recebido : Erro de Conexão (ECONNREFUSED)');
33
+ console.error('\n' + chalk_1.default.bgRed.white.bold(' ❌ FALHA DE CONEXÃO ') + '\n');
34
+ console.error(chalk_1.default.yellow('📝 Resumo: ') + 'O servidor não aceitou conexão TCP na porta 6379.\n');
35
+ console.error(chalk_1.default.bgBlue.white.bold(' 🎯 ESPERADO ') + '\n' + chalk_1.default.blue('Conexão Estabelecida (Port 6379)') + '\n');
36
+ console.error(chalk_1.default.bgMagenta.white.bold(' 💥 RECEBIDO ') + '\n' + chalk_1.default.magenta(e.message || 'ECONNREFUSED') + '\n');
42
37
  passed = false;
43
38
  }
44
- if (passed) {
45
- console.log(chalk_1.default.green('✅ Conexão TCP na porta 6379 detectada!'));
46
- }
39
+ if (passed)
40
+ console.log(chalk_1.default.green('✅ Conexão TCP na porta 6379 estabelecida!'));
47
41
  child.kill();
48
42
  resolve(passed);
49
43
  }
50
44
  catch (e) {
51
45
  if (child)
52
46
  child.kill();
53
- console.error(chalk_1.default.red(`[!] Erro fatal: ${e.message}`));
54
47
  resolve(false);
55
48
  }
56
49
  });
@@ -60,7 +53,7 @@ async function runStage(stageOrder, cwd) {
60
53
  return new Promise(async (resolve) => {
61
54
  let child = null;
62
55
  try {
63
- child = (0, child_process_1.spawn)('npx', ['ts-node', '-T', 'src/index.ts'], { cwd });
56
+ child = (0, child_process_1.spawn)('npx', ['ts-node', 'src/index.ts'], { cwd });
64
57
  await new Promise(r => setTimeout(r, 2000));
65
58
  let passed = false;
66
59
  const net = require('net');
@@ -69,29 +62,29 @@ async function runStage(stageOrder, cwd) {
69
62
  await new Promise((resolveSocket, rejectSocket) => {
70
63
  let receivedData = '';
71
64
  client.connect(6379, '127.0.0.1', () => {
72
- client.write('PING\\r\\n');
65
+ client.write('PING\r\n');
73
66
  });
74
67
  client.on('data', (data) => {
75
68
  receivedData += data.toString();
76
- if (receivedData.includes('+PONG\\r\\n')) {
69
+ if (receivedData.includes('+PONG')) {
77
70
  passed = true;
78
71
  client.destroy();
79
72
  resolveSocket();
80
73
  }
81
74
  });
82
- client.on('error', (err) => rejectSocket(err));
75
+ client.on('error', rejectSocket);
83
76
  setTimeout(() => rejectSocket(new Error('Timeout ao receber +PONG')), 2000);
84
77
  });
85
78
  }
86
79
  catch (e) {
87
- console.error('\\n❌ FALHA DE ASSERÇÃO');
88
- console.error('📝 O servidor não respondeu com +PONG\\r\\n.');
89
- console.error('🎯 Esperado : +PONG\\r\\n');
90
- console.error('💥 Recebido : ' + (e.message || 'Sem resposta'));
80
+ console.error('\n' + chalk_1.default.bgRed.white.bold(' ❌ FALHA DE PROTOCOLO ') + '\n');
81
+ console.error(chalk_1.default.yellow('📝 Resumo: ') + 'O servidor não respondeu com +PONG\\r\\n ao comando PING.\n');
82
+ console.error(chalk_1.default.bgBlue.white.bold(' 🎯 ESPERADO ') + '\n' + chalk_1.default.blue('+PONG\\r\\n') + '\n');
83
+ console.error(chalk_1.default.bgMagenta.white.bold(' 💥 RECEBIDO ') + '\n' + chalk_1.default.magenta(e.message || 'Sem resposta') + '\n');
91
84
  passed = false;
92
85
  }
93
86
  if (passed)
94
- console.log(chalk_1.default.green('✅ Recebido +PONG\\r\\n do servidor!'));
87
+ console.log(chalk_1.default.green('✅ Recebido +PONG do servidor!'));
95
88
  child.kill();
96
89
  resolve(passed);
97
90
  }
@@ -107,7 +100,7 @@ async function runStage(stageOrder, cwd) {
107
100
  return new Promise(async (resolve) => {
108
101
  let child = null;
109
102
  try {
110
- child = (0, child_process_1.spawn)('npx', ['ts-node', '-T', 'src/index.ts'], { cwd });
103
+ child = (0, child_process_1.spawn)('npx', ['ts-node', 'src/index.ts'], { cwd });
111
104
  await new Promise(r => setTimeout(r, 2000));
112
105
  const net = require('net');
113
106
  let connectedCount = 0;
@@ -120,18 +113,21 @@ async function runStage(stageOrder, cwd) {
120
113
  res();
121
114
  });
122
115
  client.on('error', rej);
123
- setTimeout(() => rej(new Error('Timeout Concorrência')), 2000);
116
+ setTimeout(() => rej(new Error('Timeout de Conexão')), 2000);
124
117
  });
125
118
  }));
126
119
  if (connectedCount === 3) {
127
- console.log(chalk_1.default.green('✅ O servidor lidou com 3 conexões simultâneas sem travar!'));
120
+ console.log(chalk_1.default.green('✅ O servidor lidou com 3 conexões simultâneas!'));
128
121
  clients.forEach(c => c.destroy());
129
122
  child.kill();
130
123
  return resolve(true);
131
124
  }
132
125
  }
133
126
  catch (e) {
134
- console.error('\\n❌ FALHA DE ASSERÇÃO\\n📝 Servidor bloqueou conexões paralelas.');
127
+ console.error('\n' + chalk_1.default.bgRed.white.bold(' ❌ FALHA DE CONCORRÊNCIA ') + '\n');
128
+ console.error(chalk_1.default.yellow('📝 Resumo: ') + 'O servidor bloqueou ou falhou ao aceitar múltiplas conexões paralelas.\n');
129
+ console.error(chalk_1.default.bgBlue.white.bold(' 🎯 ESPERADO ') + '\n' + chalk_1.default.blue('3 Conexões Ativas') + '\n');
130
+ console.error(chalk_1.default.bgMagenta.white.bold(' 💥 RECEBIDO ') + '\n' + chalk_1.default.magenta(`${connectedCount} conexões, Erro: ${e.message}`) + '\n');
135
131
  clients.forEach(c => c.destroy());
136
132
  child.kill();
137
133
  return resolve(false);
@@ -10,31 +10,44 @@ const child_process_1 = require("child_process");
10
10
  const chalk_1 = __importDefault(require("chalk"));
11
11
  function runStage(stageOrder, cwd) {
12
12
  if (stageOrder === 1) {
13
- console.log(chalk_1.default.blue(`[Stage 1: Shell Echo] Verificando comando echo do seu Shell...`));
14
- // O Shell Stage 1 geralmente envolve criar um prompt e lidar com comandos triviais
13
+ console.log(chalk_1.default.blue(`[Stage 1: Shell REPL] Verificando loop REPL e mensagem de erro...`));
15
14
  const testFilePath = path_1.default.join(cwd, '.eval-stage1.ts');
16
15
  const code = `
17
16
  const { execSync } = require('child_process');
18
17
  const fs = require('fs');
18
+ const chalk = require('chalk');
19
19
 
20
- function assert(condition: boolean, failMsg: string, expected?: any, got?: any) {
20
+ function assert(condition, failMsg, expected, got) {
21
21
  if (!condition) {
22
- console.error('\\n❌ FALHA DE ASSERÇÃO');
23
- console.error('📝 ' + failMsg);
24
- if (expected !== undefined) console.error('🎯 Esperado : ' + String(expected));
25
- if (got !== undefined) console.error('💥 Recebido : ' + String(got));
26
- console.error('');
22
+ console.error('\\n' + chalk.bgRed.white.bold(' ❌ FALHA DE ASSERÇÃO ') + '\\n');
23
+ console.error(chalk.yellow('📝 Resumo: ') + failMsg + '\\n');
24
+
25
+ console.error(chalk.bgBlue.white.bold(' 🎯 ESPERADO ') + '\\n' + chalk.blue(expected) + '\\n');
26
+ console.error(chalk.bgMagenta.white.bold(' 💥 RECEBIDO ') + '\\n' + chalk.magenta(got) + '\\n');
27
+
27
28
  process.exit(1);
28
29
  }
29
30
  }
30
31
 
31
32
  async function testSuite() {
32
33
  try {
33
- // Vamos passar 'echo Hello World' para o shell e ver se o output possui Hello World
34
- console.log('-> Injetando comandos via stdin no seu Shell (src/index.ts)...');
35
- const output = execSync('echo "echo Hello World\\nexit 0" | npx ts-node src/index.ts', { cwd: '${cwd}', stdio: 'pipe' });
34
+ // O Estágio 1 do Shell pede para imprimir "$ ", ler o comando e imprimir "<cmd>: command not found"
35
+ console.log('-> Injetando "mycommand" via stdin no seu Shell (src/index.ts)...');
36
+ const output = execSync('echo "mycommand\\nexit 0" | npx ts-node src/index.ts', { cwd: '${cwd}', stdio: 'pipe' });
36
37
 
37
- assert(output.toString().includes('Hello World'), 'O comando echo não funcionou no seu Shell.', 'Hello World', output.toString());
38
+ const content = output.toString();
39
+ assert(content.includes('mycommand: command not found'),
40
+ 'O Shell deve imprimir ": command not found" para comandos desconhecidos no Estágio 1.',
41
+ 'mycommand: command not found',
42
+ content.trim()
43
+ );
44
+
45
+ assert(content.includes('$ '),
46
+ 'O Shell deve exibir o prompt "$ " antes de ler o comando.',
47
+ 'Prompt "$ "',
48
+ content.trim()
49
+ );
50
+
38
51
  console.log('PASS');
39
52
  } catch(e: any) {
40
53
  console.error(e.stderr?.toString() || e.message);
@@ -49,7 +62,7 @@ function runStage(stageOrder, cwd) {
49
62
  return stdout.toString().includes('PASS');
50
63
  }
51
64
  catch (err) {
52
- console.log(chalk_1.default.red(err.stderr?.toString().trim() || err.stdout?.toString().trim() || err.message));
65
+ console.log(err.stdout?.toString().trim() || err.stderr?.toString().trim() || err.message);
53
66
  return false;
54
67
  }
55
68
  finally {
@@ -57,5 +70,6 @@ function runStage(stageOrder, cwd) {
57
70
  fs_1.default.unlinkSync(testFilePath);
58
71
  }
59
72
  }
73
+ console.log(chalk_1.default.yellow(`⚠️ Nenhuma suite implementada ainda para Stage ${stageOrder} deste desafio. Bypass (Aprovado).`));
60
74
  return true;
61
75
  }
@@ -16,13 +16,13 @@ function runStage(stageOrder, cwd) {
16
16
  const { execSync } = require('child_process');
17
17
  const fs = require('fs');
18
18
 
19
- function assert(condition: boolean, failMsg: string, expected?: any, got?: any) {
19
+ const chalk = require('chalk');
20
+ function assert(condition, failMsg, expected, got) {
20
21
  if (!condition) {
21
- console.error('\\n❌ FALHA DE ASSERÇÃO');
22
- console.error('📝 ' + failMsg);
23
- if (expected !== undefined) console.error('🎯 Esperado : ' + String(expected));
24
- if (got !== undefined) console.error('💥 Recebido : ' + String(got));
25
- console.error('');
22
+ console.error('\\n' + chalk.bgRed.white.bold(' ❌ FALHA DE ASSERÇÃO ') + '\\n');
23
+ console.error(chalk.yellow('📝 Resumo: ') + failMsg + '\\n');
24
+ console.error(chalk.bgBlue.white.bold(' 🎯 ESPERADO ') + '\\n' + chalk.blue(expected) + '\\n');
25
+ console.error(chalk.bgMagenta.white.bold(' 💥 RECEBIDO ') + '\\n' + chalk.magenta(got) + '\\n');
26
26
  process.exit(1);
27
27
  }
28
28
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devquest/cli",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "description": "DevQuest CLI - Construa seu próprio Redis, Docker, Git e mais",
5
5
  "main": "dist/index.js",
6
6
  "bin": {