@yadurajfleetos/cli 0.18.1 → 0.18.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/dist/commands/auth.js +7 -11
- package/dist/commands/open.js +9 -13
- package/package.json +1 -1
package/dist/commands/auth.js
CHANGED
|
@@ -1,24 +1,20 @@
|
|
|
1
1
|
import { createInterface } from 'node:readline/promises';
|
|
2
2
|
import { createServer } from 'node:http';
|
|
3
|
-
import {
|
|
4
|
-
import { promisify } from 'node:util';
|
|
3
|
+
import { spawn } from 'node:child_process';
|
|
5
4
|
import { request, CliError, EXIT } from '../api.js';
|
|
6
5
|
import { loadProfile, saveProfile, configLocation } from '../config.js';
|
|
7
6
|
import { c, keyValues } from '../render.js';
|
|
8
7
|
import { banner } from '../mark.js';
|
|
9
8
|
import { glyph, rule, task, spinner } from '../ui.js';
|
|
10
|
-
const execAsync = promisify(exec);
|
|
11
9
|
async function openBrowserUrl(url) {
|
|
12
10
|
const platform = process.platform;
|
|
13
|
-
let cmd = '';
|
|
14
|
-
if (platform === 'darwin')
|
|
15
|
-
cmd = `open "${url}"`;
|
|
16
|
-
else if (platform === 'win32')
|
|
17
|
-
cmd = `start "" "${url}"`;
|
|
18
|
-
else
|
|
19
|
-
cmd = `xdg-open "${url}"`;
|
|
20
11
|
try {
|
|
21
|
-
|
|
12
|
+
if (platform === 'darwin')
|
|
13
|
+
spawn('open', [url], { stdio: 'ignore' });
|
|
14
|
+
else if (platform === 'win32')
|
|
15
|
+
spawn('cmd', ['/c', 'start', '""', url], { stdio: 'ignore' });
|
|
16
|
+
else
|
|
17
|
+
spawn('xdg-open', [url], { stdio: 'ignore' });
|
|
22
18
|
}
|
|
23
19
|
catch {
|
|
24
20
|
// Ignore browser opener errors; URL is printed on screen
|
package/dist/commands/open.js
CHANGED
|
@@ -4,30 +4,26 @@
|
|
|
4
4
|
* Discovers the public HTTPS URL for the service and launches it via the
|
|
5
5
|
* platform's native opener (open on macOS, xdg-open on Linux, start on Windows).
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
8
|
-
import { promisify } from 'node:util';
|
|
7
|
+
import { spawn } from 'node:child_process';
|
|
9
8
|
import { request, requireFleet, CliError, EXIT } from '../api.js';
|
|
10
9
|
import { c } from '../render.js';
|
|
11
10
|
import { glyph } from '../ui.js';
|
|
12
|
-
const execAsync = promisify(exec);
|
|
13
11
|
async function openUrl(url) {
|
|
14
12
|
const platform = process.platform;
|
|
15
|
-
let
|
|
13
|
+
let child;
|
|
16
14
|
if (platform === 'darwin') {
|
|
17
|
-
|
|
15
|
+
child = spawn('open', [url], { stdio: 'ignore' });
|
|
18
16
|
}
|
|
19
17
|
else if (platform === 'win32') {
|
|
20
|
-
|
|
18
|
+
child = spawn('cmd', ['/c', 'start', '""', url], { stdio: 'ignore' });
|
|
21
19
|
}
|
|
22
20
|
else {
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
try {
|
|
26
|
-
await execAsync(cmd);
|
|
27
|
-
}
|
|
28
|
-
catch (err) {
|
|
29
|
-
throw new CliError(`Could not open browser automatically: ${String(err)}`, EXIT.failure);
|
|
21
|
+
child = spawn('xdg-open', [url], { stdio: 'ignore' });
|
|
30
22
|
}
|
|
23
|
+
return new Promise((resolve, reject) => {
|
|
24
|
+
child.on('error', (err) => reject(new CliError(`Could not open browser automatically: ${err.message}`, EXIT.failure)));
|
|
25
|
+
child.on('close', () => resolve());
|
|
26
|
+
});
|
|
31
27
|
}
|
|
32
28
|
export const openCommand = {
|
|
33
29
|
async run(args, flags) {
|