@meloniwastaken/prri-jira-viewer 1.0.0 → 1.0.2

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/bin/cli.js CHANGED
@@ -1,6 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { createInterface } from 'readline';
4
3
  import { spawn } from 'child_process';
5
4
  import { fileURLToPath } from 'url';
6
5
  import { dirname, join } from 'path';
@@ -8,76 +7,39 @@ import { dirname, join } from 'path';
8
7
  const __dirname = dirname(fileURLToPath(import.meta.url));
9
8
  const serverPath = join(__dirname, '..', 'server.js');
10
9
 
11
- function ask(rl, question, hidden = false) {
12
- return new Promise((resolve) => {
13
- rl.question(question, (answer) => resolve(answer.trim()));
14
- });
15
- }
16
-
17
- async function main() {
18
- const email = process.env.JIRA_EMAIL;
19
- const token = process.env.JIRA_TOKEN;
20
- const port = process.env.PORT || 3000;
21
-
22
- let finalEmail = email;
23
- let finalToken = token;
24
-
25
- if (!finalEmail || !finalToken) {
26
- console.log('\n PRRI Jira Sprint Viewer\n');
27
- console.log(' Credenziali Jira necessarie.\n (oppure usa JIRA_EMAIL e JIRA_TOKEN come variabili d\'ambiente)\n');
28
-
29
- const rl = createInterface({ input: process.stdin, output: process.stdout });
30
-
31
- if (!finalEmail) {
32
- finalEmail = await ask(rl, ' Email Jira: ');
33
- }
34
- if (!finalToken) {
35
- finalToken = await ask(rl, ' API Token: ');
36
- }
37
-
38
- rl.close();
39
-
40
- if (!finalEmail || !finalToken) {
41
- console.error('\n Errore: email e token sono obbligatori.\n');
42
- process.exit(1);
43
- }
10
+ const port = process.env.PORT || 3000;
11
+
12
+ const env = {
13
+ ...process.env,
14
+ JIRA_URL: process.env.JIRA_URL || 'https://regcam-projectmgm.atlassian.net',
15
+ PORT: String(port),
16
+ NODE_ENV: 'production',
17
+ };
18
+
19
+ console.log(`\n PRRI Jira Sprint Viewer`);
20
+ console.log(` Avvio server su http://localhost:${port} ...`);
21
+
22
+ const child = spawn(process.execPath, [serverPath], {
23
+ env,
24
+ stdio: 'inherit',
25
+ });
26
+
27
+ // Wait for server to start, then open browser
28
+ setTimeout(async () => {
29
+ try {
30
+ const open = (await import('open')).default;
31
+ await open(`http://localhost:${port}`);
32
+ } catch {
33
+ console.log(` Apri il browser su http://localhost:${port}`);
44
34
  }
35
+ }, 1500);
45
36
 
46
- const env = {
47
- ...process.env,
48
- JIRA_URL: 'https://regcam-projectmgm.atlassian.net',
49
- JIRA_EMAIL: finalEmail,
50
- JIRA_TOKEN: finalToken,
51
- PORT: String(port),
52
- NODE_ENV: 'production',
53
- };
54
-
55
- console.log(`\n Avvio server su http://localhost:${port} ...`);
56
-
57
- const child = spawn(process.execPath, [serverPath], {
58
- env,
59
- stdio: 'inherit',
60
- });
61
-
62
- // Wait for server to start, then open browser
63
- setTimeout(async () => {
64
- try {
65
- const open = (await import('open')).default;
66
- await open(`http://localhost:${port}`);
67
- } catch {
68
- console.log(` Apri il browser su http://localhost:${port}`);
69
- }
70
- }, 1500);
71
-
72
- // Clean shutdown
73
- const shutdown = () => {
74
- child.kill();
75
- process.exit(0);
76
- };
77
- process.on('SIGINT', shutdown);
78
- process.on('SIGTERM', shutdown);
79
-
80
- child.on('exit', (code) => process.exit(code || 0));
81
- }
37
+ // Clean shutdown
38
+ const shutdown = () => {
39
+ child.kill();
40
+ process.exit(0);
41
+ };
42
+ process.on('SIGINT', shutdown);
43
+ process.on('SIGTERM', shutdown);
82
44
 
83
- main();
45
+ child.on('exit', (code) => process.exit(code || 0));