@playwright-test-runner/core 1.0.8 β 1.0.9
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/package.json +2 -1
- package/scripts/postinstall.js +144 -0
- package/scripts/release.js +222 -0
- package/scripts/status-daemon.js +104 -0
- package/scripts/stop-daemon.js +46 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@playwright-test-runner/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"description": "Libreria agnostica per eseguire test Playwright con server Express e UI report",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
"files": [
|
|
43
43
|
"dist",
|
|
44
44
|
"public",
|
|
45
|
+
"scripts",
|
|
45
46
|
"playwright.config.ts"
|
|
46
47
|
],
|
|
47
48
|
"directories": {
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Post-install script
|
|
5
|
+
* Avvia automaticamente il report daemon dopo l'installazione del package
|
|
6
|
+
*
|
|
7
|
+
* Controllo tramite variabili d'ambiente:
|
|
8
|
+
* - PLAYWRIGHT_SKIP_DAEMON=true - Salta completamente l'avvio del daemon
|
|
9
|
+
* - PLAYWRIGHT_DAEMON_AUTO=false - Non avvia il daemon automaticamente
|
|
10
|
+
* - NODE_ENV=production - Non avvia il daemon in produzione
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const { spawn } = require('child_process');
|
|
14
|
+
const path = require('path');
|
|
15
|
+
const fs = require('fs');
|
|
16
|
+
|
|
17
|
+
// Evita di eseguire durante l'installazione della libreria stessa
|
|
18
|
+
const isLibraryInstall = process.cwd().includes('playwright-library') ||
|
|
19
|
+
process.cwd().includes('@playwright-test-runner');
|
|
20
|
+
|
|
21
|
+
if (isLibraryInstall) {
|
|
22
|
+
console.log('π¦ Installazione della libreria in corso, skip post-install...');
|
|
23
|
+
process.exit(0);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Controlli per evitare l'avvio automatico
|
|
27
|
+
const skipDaemon = process.env.PLAYWRIGHT_SKIP_DAEMON === 'true';
|
|
28
|
+
const daemonAuto = process.env.PLAYWRIGHT_DAEMON_AUTO !== 'false'; // Default: true
|
|
29
|
+
const isProduction = process.env.NODE_ENV === 'production';
|
|
30
|
+
const isCIEnvironment = process.env.CI === 'true';
|
|
31
|
+
|
|
32
|
+
if (skipDaemon) {
|
|
33
|
+
console.log('βοΈ PLAYWRIGHT_SKIP_DAEMON=true - Skip avvio daemon');
|
|
34
|
+
process.exit(0);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (!daemonAuto) {
|
|
38
|
+
console.log('βοΈ PLAYWRIGHT_DAEMON_AUTO=false - Avvio manuale richiesto');
|
|
39
|
+
console.log(' Usa: npx playwright-daemon\n');
|
|
40
|
+
process.exit(0);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (isProduction) {
|
|
44
|
+
console.log('π« NODE_ENV=production - Daemon non avviato in produzione');
|
|
45
|
+
console.log(' Per avviarlo comunque: PLAYWRIGHT_DAEMON_AUTO=true npm install');
|
|
46
|
+
console.log(' Oppure manualmente: npx playwright-daemon\n');
|
|
47
|
+
process.exit(0);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (isCIEnvironment) {
|
|
51
|
+
console.log('π« CI=true - Daemon non avviato in ambiente CI/CD');
|
|
52
|
+
console.log(' Per avviarlo comunque: PLAYWRIGHT_DAEMON_AUTO=true npm install\n');
|
|
53
|
+
process.exit(0);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
console.log(`
|
|
57
|
+
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
58
|
+
β β
|
|
59
|
+
β π Playwright Test Runner - Post Install β
|
|
60
|
+
β β
|
|
61
|
+
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
62
|
+
|
|
63
|
+
π¦ Package installato con successo!
|
|
64
|
+
|
|
65
|
+
π Avvio del Report Server in background...
|
|
66
|
+
`);
|
|
67
|
+
|
|
68
|
+
// Determina il percorso del daemon
|
|
69
|
+
const projectRoot = process.env.INIT_CWD || process.cwd();
|
|
70
|
+
const daemonBin = path.join(__dirname, '../dist/daemon-cli.js');
|
|
71
|
+
|
|
72
|
+
// Verifica che il daemon esista
|
|
73
|
+
if (!fs.existsSync(daemonBin)) {
|
|
74
|
+
console.log('β οΈ Daemon non trovato, skip auto-start.');
|
|
75
|
+
console.log(' Usa: npx playwright-daemon per avviarlo manualmente\n');
|
|
76
|
+
process.exit(0);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Crea la cartella tests se non esiste
|
|
80
|
+
const testsDir = path.join(projectRoot, 'tests');
|
|
81
|
+
if (!fs.existsSync(testsDir)) {
|
|
82
|
+
console.log('π Creazione cartella tests...');
|
|
83
|
+
fs.mkdirSync(testsDir, { recursive: true });
|
|
84
|
+
|
|
85
|
+
// Crea un test di esempio
|
|
86
|
+
const exampleTest = `import { test, expect } from '@playwright/test';
|
|
87
|
+
|
|
88
|
+
test('example test', async ({ page }) => {
|
|
89
|
+
await page.goto('https://example.com');
|
|
90
|
+
await expect(page).toHaveTitle(/Example Domain/);
|
|
91
|
+
});
|
|
92
|
+
`;
|
|
93
|
+
|
|
94
|
+
fs.writeFileSync(path.join(testsDir, 'example.spec.ts'), exampleTest);
|
|
95
|
+
console.log('β
Creato file di test di esempio: tests/example.spec.ts\n');
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Avvia il daemon in background
|
|
99
|
+
try {
|
|
100
|
+
const daemon = spawn('node', [daemonBin, '--port', '9324'], {
|
|
101
|
+
detached: true,
|
|
102
|
+
stdio: 'ignore',
|
|
103
|
+
cwd: projectRoot,
|
|
104
|
+
env: {
|
|
105
|
+
...process.env,
|
|
106
|
+
INIT_CWD: projectRoot,
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
daemon.unref(); // Permette al processo parent di uscire
|
|
111
|
+
|
|
112
|
+
console.log(`
|
|
113
|
+
β
Report Server avviato in background!
|
|
114
|
+
|
|
115
|
+
π Report disponibile su:
|
|
116
|
+
β http://localhost:9324
|
|
117
|
+
|
|
118
|
+
π Dashboard:
|
|
119
|
+
β http://localhost:9324/dashboard
|
|
120
|
+
|
|
121
|
+
π‘ Comandi disponibili:
|
|
122
|
+
β’ npx playwright-test - Esegui test e mostra report
|
|
123
|
+
β’ npx playwright-ui - Interfaccia web interattiva
|
|
124
|
+
β’ npx playwright-daemon - Gestisci il daemon server
|
|
125
|
+
|
|
126
|
+
π Test Directory: ${testsDir}
|
|
127
|
+
|
|
128
|
+
π― Prossimi Passi:
|
|
129
|
+
1. Aggiungi i tuoi test nella cartella 'tests/'
|
|
130
|
+
2. Esegui: npx playwright-test
|
|
131
|
+
3. Visualizza i report su http://localhost:9324
|
|
132
|
+
|
|
133
|
+
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
134
|
+
|
|
135
|
+
`);
|
|
136
|
+
|
|
137
|
+
// Salva il PID per future gestioni
|
|
138
|
+
const pidFile = path.join(projectRoot, '.playwright-daemon.pid');
|
|
139
|
+
fs.writeFileSync(pidFile, daemon.pid.toString());
|
|
140
|
+
|
|
141
|
+
} catch (error) {
|
|
142
|
+
console.error('β Errore durante l\'avvio del daemon:', error.message);
|
|
143
|
+
console.log('\nπ‘ Puoi avviarlo manualmente con: npx playwright-daemon\n');
|
|
144
|
+
}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Release Script
|
|
5
|
+
* Gestisce il versioning e la pubblicazione su npm in modo interattivo
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const { execSync, spawn } = require('child_process');
|
|
9
|
+
const readline = require('readline');
|
|
10
|
+
|
|
11
|
+
console.log(`
|
|
12
|
+
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
13
|
+
β β
|
|
14
|
+
β π Playwright Test Runner - Release Script β
|
|
15
|
+
β β
|
|
16
|
+
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
17
|
+
`);
|
|
18
|
+
|
|
19
|
+
// Controlla lo stato git
|
|
20
|
+
function checkGitStatus() {
|
|
21
|
+
try {
|
|
22
|
+
const status = execSync('git status --porcelain', { encoding: 'utf-8' });
|
|
23
|
+
return status.trim() !== '';
|
|
24
|
+
} catch (error) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Leggi la versione corrente
|
|
30
|
+
const packageJson = require('../package.json');
|
|
31
|
+
console.log(`π¦ Versione corrente: ${packageJson.version}\n`);
|
|
32
|
+
|
|
33
|
+
// Controlla se ci sono modifiche non committate
|
|
34
|
+
const hasChanges = checkGitStatus();
|
|
35
|
+
|
|
36
|
+
if (hasChanges) {
|
|
37
|
+
console.log('β οΈ Modifiche non committate rilevate!\n');
|
|
38
|
+
|
|
39
|
+
const rlGit = readline.createInterface({
|
|
40
|
+
input: process.stdin,
|
|
41
|
+
output: process.stdout,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
rlGit.question('Vuoi committare tutte le modifiche ora? (s/n): ', (answer) => {
|
|
45
|
+
if (answer.toLowerCase() === 's' || answer.toLowerCase() === 'y') {
|
|
46
|
+
rlGit.question('Inserisci il messaggio di commit: ', (message) => {
|
|
47
|
+
try {
|
|
48
|
+
execSync('git add .', { stdio: 'inherit' });
|
|
49
|
+
execSync(`git commit -m "${message}"`, { stdio: 'inherit' });
|
|
50
|
+
console.log('\nβ
Modifiche committate!\n');
|
|
51
|
+
rlGit.close();
|
|
52
|
+
// Piccolo delay per lasciare stdio stabilizzarsi
|
|
53
|
+
setTimeout(() => startRelease(), 100);
|
|
54
|
+
} catch (error) {
|
|
55
|
+
console.error('\nβ Errore durante il commit:', error.message);
|
|
56
|
+
rlGit.close();
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
} else {
|
|
61
|
+
console.log('\nβ οΈ Procedo senza creare tag git (solo aggiornamento version in package.json)\n');
|
|
62
|
+
rlGit.close();
|
|
63
|
+
setTimeout(() => startRelease(true), 100); // Skip git tag
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
} else {
|
|
67
|
+
startRelease();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function startRelease(skipGitTag = false) {
|
|
71
|
+
const rl = readline.createInterface({
|
|
72
|
+
input: process.stdin,
|
|
73
|
+
output: process.stdout,
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
console.log('Seleziona il tipo di versione da rilasciare:\n');
|
|
77
|
+
console.log(' 1. PATCH - Bug fix (es: 1.0.2 β 1.0.3)');
|
|
78
|
+
console.log(' 2. MINOR - Nuova feature (es: 1.0.2 β 1.1.0)');
|
|
79
|
+
console.log(' 3. MAJOR - Breaking change (es: 1.0.2 β 2.0.0)');
|
|
80
|
+
console.log(' 4. CUSTOM - Specifica versione manualmente');
|
|
81
|
+
console.log(' 0. ANNULLA\n');
|
|
82
|
+
|
|
83
|
+
rl.question('La tua scelta (1-4): ', (answer) => {
|
|
84
|
+
let versionType;
|
|
85
|
+
|
|
86
|
+
switch (answer.trim()) {
|
|
87
|
+
case '1':
|
|
88
|
+
versionType = 'patch';
|
|
89
|
+
break;
|
|
90
|
+
case '2':
|
|
91
|
+
versionType = 'minor';
|
|
92
|
+
break;
|
|
93
|
+
case '3':
|
|
94
|
+
versionType = 'major';
|
|
95
|
+
break;
|
|
96
|
+
case '4':
|
|
97
|
+
rl.question('Inserisci la versione (es: 2.5.0): ', (customVersion) => {
|
|
98
|
+
rl.close();
|
|
99
|
+
setTimeout(() => executeRelease(customVersion, skipGitTag), 100);
|
|
100
|
+
});
|
|
101
|
+
return;
|
|
102
|
+
case '0':
|
|
103
|
+
console.log('\nβ Operazione annullata\n');
|
|
104
|
+
rl.close();
|
|
105
|
+
process.exit(0);
|
|
106
|
+
return;
|
|
107
|
+
default:
|
|
108
|
+
console.log('\nβ Scelta non valida\n');
|
|
109
|
+
rl.close();
|
|
110
|
+
process.exit(1);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
rl.close();
|
|
115
|
+
setTimeout(() => executeRelease(versionType, skipGitTag), 100);
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function executeRelease(versionType, skipGitTag = false) {
|
|
120
|
+
try {
|
|
121
|
+
console.log('\nβ'.repeat(30));
|
|
122
|
+
console.log(`\nπ Aggiornamento versione (${versionType})...`);
|
|
123
|
+
|
|
124
|
+
// Esegui npm version
|
|
125
|
+
const versionCommand = skipGitTag
|
|
126
|
+
? `npm version ${versionType} --no-git-tag-version`
|
|
127
|
+
: `npm version ${versionType}`;
|
|
128
|
+
|
|
129
|
+
execSync(versionCommand, {
|
|
130
|
+
encoding: 'utf-8',
|
|
131
|
+
stdio: 'inherit',
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
console.log('\nβ
Versione aggiornata con successo!');
|
|
135
|
+
|
|
136
|
+
if (skipGitTag) {
|
|
137
|
+
console.log('β οΈ Tag git NON creato (modifiche non committate)');
|
|
138
|
+
console.log('π‘ Ricordati di committare package.json con la nuova versione\n');
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Aspetta che stdio si stabilizzi dopo execSync
|
|
142
|
+
setTimeout(() => {
|
|
143
|
+
askForPublish(skipGitTag);
|
|
144
|
+
}, 200);
|
|
145
|
+
|
|
146
|
+
} catch (error) {
|
|
147
|
+
console.error('\nβ Errore durante il versioning:', error.message);
|
|
148
|
+
process.exit(1);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function askForPublish(skipGitTag) {
|
|
153
|
+
// Chiedi conferma per la pubblicazione
|
|
154
|
+
const rlConfirm = readline.createInterface({
|
|
155
|
+
input: process.stdin,
|
|
156
|
+
output: process.stdout,
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
rlConfirm.question('\nπ€ Vuoi pubblicare su npm? (s/n): ', (publish) => {
|
|
160
|
+
const shouldPublish = publish.toLowerCase() === 's' || publish.toLowerCase() === 'y';
|
|
161
|
+
|
|
162
|
+
rlConfirm.close();
|
|
163
|
+
|
|
164
|
+
if (shouldPublish) {
|
|
165
|
+
// Usa setTimeout per lasciare che readline si chiuda completamente
|
|
166
|
+
setTimeout(() => {
|
|
167
|
+
console.log('\nβ'.repeat(30));
|
|
168
|
+
console.log('\nπ Eseguo npm login...');
|
|
169
|
+
console.log('π‘ Il browser si aprirΓ per l\'autenticazione');
|
|
170
|
+
console.log(' Premi ENTER quando richiesto, poi completa il login nel browser\n');
|
|
171
|
+
|
|
172
|
+
// Usa spawn invece di execSync per gestire meglio l'interattivitΓ
|
|
173
|
+
const loginProcess = spawn('npm', ['login'], {
|
|
174
|
+
stdio: 'inherit', // Passa stdin, stdout, stderr al processo padre
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
loginProcess.on('close', (code) => {
|
|
178
|
+
if (code !== 0) {
|
|
179
|
+
console.error('\nβ Errore durante il login');
|
|
180
|
+
process.exit(1);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
console.log('\nβ
Login completato con successo!');
|
|
184
|
+
console.log('\nπ Pubblicazione su npm...\n');
|
|
185
|
+
|
|
186
|
+
// Esegui npm publish
|
|
187
|
+
const publishProcess = spawn('npm', ['publish', '--access', 'public'], {
|
|
188
|
+
stdio: 'inherit',
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
publishProcess.on('close', (publishCode) => {
|
|
192
|
+
if (publishCode !== 0) {
|
|
193
|
+
console.error('\nβ Errore durante la pubblicazione');
|
|
194
|
+
process.exit(1);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
console.log('\nβ'.repeat(30));
|
|
198
|
+
console.log('\nβ
Package pubblicato con successo su npm!');
|
|
199
|
+
|
|
200
|
+
if (!skipGitTag) {
|
|
201
|
+
console.log('\nπ‘ Ricordati di pushare il tag su git:');
|
|
202
|
+
console.log(' git push && git push --tags\n');
|
|
203
|
+
} else {
|
|
204
|
+
console.log('\nπ‘ Ricordati di committare e pushare:');
|
|
205
|
+
console.log(' git add package.json');
|
|
206
|
+
console.log(' git commit -m "Release vX.X.X"');
|
|
207
|
+
console.log(' git push\n');
|
|
208
|
+
}
|
|
209
|
+
console.log('β'.repeat(30) + '\n');
|
|
210
|
+
|
|
211
|
+
process.exit(0);
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
}, 300);
|
|
215
|
+
} else {
|
|
216
|
+
console.log('\nβοΈ Pubblicazione saltata');
|
|
217
|
+
console.log('\nπ‘ Per pubblicare manualmente:');
|
|
218
|
+
console.log(' npm login && npm publish --access public\n');
|
|
219
|
+
process.exit(0);
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Status Daemon Script
|
|
5
|
+
* Controlla lo stato del daemon server
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
const path = require('path');
|
|
10
|
+
const http = require('http');
|
|
11
|
+
|
|
12
|
+
const projectRoot = process.env.INIT_CWD || process.cwd();
|
|
13
|
+
const pidFile = path.join(projectRoot, '.playwright-daemon.pid');
|
|
14
|
+
const daemonPort = 9324;
|
|
15
|
+
|
|
16
|
+
console.log('π Controllo stato daemon...\n');
|
|
17
|
+
|
|
18
|
+
// Controlla il file PID
|
|
19
|
+
if (!fs.existsSync(pidFile)) {
|
|
20
|
+
console.log('β Daemon non attivo');
|
|
21
|
+
console.log(' File PID non trovato:', pidFile);
|
|
22
|
+
console.log('\nπ‘ Avvia il daemon con: npx playwright-daemon\n');
|
|
23
|
+
process.exit(0);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const pid = parseInt(fs.readFileSync(pidFile, 'utf-8').trim());
|
|
27
|
+
|
|
28
|
+
// Controlla se il processo Γ¨ attivo
|
|
29
|
+
let processRunning = false;
|
|
30
|
+
try {
|
|
31
|
+
process.kill(pid, 0); // Signal 0 = controlla esistenza
|
|
32
|
+
processRunning = true;
|
|
33
|
+
} catch (e) {
|
|
34
|
+
processRunning = false;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (!processRunning) {
|
|
38
|
+
console.log('β οΈ Processo non piΓΉ attivo (PID stale)');
|
|
39
|
+
console.log(' Rimuovo file PID obsoleto...');
|
|
40
|
+
fs.unlinkSync(pidFile);
|
|
41
|
+
console.log('\nπ‘ Riavvia il daemon con: npx playwright-daemon\n');
|
|
42
|
+
process.exit(0);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Controlla se il server risponde
|
|
46
|
+
const req = http.request(
|
|
47
|
+
{
|
|
48
|
+
hostname: 'localhost',
|
|
49
|
+
port: daemonPort,
|
|
50
|
+
path: '/health',
|
|
51
|
+
method: 'GET',
|
|
52
|
+
timeout: 2000,
|
|
53
|
+
},
|
|
54
|
+
(res) => {
|
|
55
|
+
let data = '';
|
|
56
|
+
|
|
57
|
+
res.on('data', (chunk) => {
|
|
58
|
+
data += chunk;
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
res.on('end', () => {
|
|
62
|
+
try {
|
|
63
|
+
const health = JSON.parse(data);
|
|
64
|
+
|
|
65
|
+
console.log('β
Daemon ATTIVO\n');
|
|
66
|
+
console.log('π Informazioni:');
|
|
67
|
+
console.log(` β’ PID: ${pid}`);
|
|
68
|
+
console.log(` β’ Porta: ${daemonPort}`);
|
|
69
|
+
console.log(` β’ Status: ${health.status}`);
|
|
70
|
+
console.log(` β’ Progetto: ${health.projectRoot}`);
|
|
71
|
+
console.log(` β’ Test Dir: ${health.testsDir}`);
|
|
72
|
+
console.log('\nπ URLs:');
|
|
73
|
+
console.log(` β’ Report: http://localhost:${daemonPort}`);
|
|
74
|
+
console.log(` β’ Dashboard: http://localhost:${daemonPort}/dashboard`);
|
|
75
|
+
console.log(` β’ Health: http://localhost:${daemonPort}/health`);
|
|
76
|
+
console.log('\nπ‘ Comandi:');
|
|
77
|
+
console.log(' β’ npx playwright-daemon stop - Ferma il daemon');
|
|
78
|
+
console.log(' β’ npx playwright-test - Esegui test');
|
|
79
|
+
console.log('');
|
|
80
|
+
|
|
81
|
+
} catch (e) {
|
|
82
|
+
console.log('β οΈ Server risponde ma formato non valido');
|
|
83
|
+
console.log(' Response:', data);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
req.on('error', (error) => {
|
|
90
|
+
console.log('β Daemon non risponde');
|
|
91
|
+
console.log(` Processo ${pid} attivo ma server non raggiungibile sulla porta ${daemonPort}`);
|
|
92
|
+
console.log(` Errore: ${error.message}`);
|
|
93
|
+
console.log('\nπ‘ Prova a:');
|
|
94
|
+
console.log(' 1. Fermare il daemon: npx playwright-daemon stop');
|
|
95
|
+
console.log(' 2. Riavviarlo: npx playwright-daemon\n');
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
req.on('timeout', () => {
|
|
99
|
+
req.destroy();
|
|
100
|
+
console.log('β±οΈ Timeout - Il server non risponde entro 2 secondi');
|
|
101
|
+
console.log('\nπ‘ Il daemon potrebbe essere in fase di avvio o sovraccarico\n');
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
req.end();
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Stop Daemon Script
|
|
5
|
+
* Ferma il daemon server dei report
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
const path = require('path');
|
|
10
|
+
|
|
11
|
+
const projectRoot = process.env.INIT_CWD || process.cwd();
|
|
12
|
+
const pidFile = path.join(projectRoot, '.playwright-daemon.pid');
|
|
13
|
+
|
|
14
|
+
if (!fs.existsSync(pidFile)) {
|
|
15
|
+
console.log('βΉοΈ Nessun daemon attivo trovato');
|
|
16
|
+
console.log(' File PID non esistente:', pidFile);
|
|
17
|
+
process.exit(0);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
try {
|
|
21
|
+
const pid = parseInt(fs.readFileSync(pidFile, 'utf-8').trim());
|
|
22
|
+
|
|
23
|
+
try {
|
|
24
|
+
// Prova a killare il processo
|
|
25
|
+
process.kill(pid, 'SIGTERM');
|
|
26
|
+
|
|
27
|
+
console.log(`β
Daemon fermato (PID: ${pid})`);
|
|
28
|
+
|
|
29
|
+
// Rimuovi il file PID
|
|
30
|
+
fs.unlinkSync(pidFile);
|
|
31
|
+
|
|
32
|
+
} catch (killError) {
|
|
33
|
+
if (killError.code === 'ESRCH') {
|
|
34
|
+
console.log(`βΉοΈ Processo ${pid} non piΓΉ in esecuzione`);
|
|
35
|
+
fs.unlinkSync(pidFile);
|
|
36
|
+
} else {
|
|
37
|
+
throw killError;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
} catch (error) {
|
|
42
|
+
console.error('β Errore durante la chiusura del daemon:', error.message);
|
|
43
|
+
console.log('\nπ‘ Prova a cercare il processo manualmente:');
|
|
44
|
+
console.log(' lsof -ti:9324 | xargs kill -9');
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|