@displaydev/cli 0.2.0 → 0.2.1
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/main.js +25 -11
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -137,12 +137,15 @@ function _ts_generator(thisArg, body) {
|
|
|
137
137
|
}
|
|
138
138
|
import { readFile, mkdir, writeFile, rename, chmod } from 'node:fs/promises';
|
|
139
139
|
import { createInterface } from 'node:readline/promises';
|
|
140
|
+
import { createRequire } from 'node:module';
|
|
140
141
|
import { execFileSync } from 'node:child_process';
|
|
141
142
|
import { homedir, platform } from 'node:os';
|
|
142
143
|
import { join, extname } from 'node:path';
|
|
143
144
|
import { Command } from 'commander';
|
|
144
145
|
import { ApiClient } from './api-client.js';
|
|
145
146
|
import { startMcpServer } from './mcp-server.js';
|
|
147
|
+
var require = createRequire(import.meta.url);
|
|
148
|
+
var version = require('../package.json').version;
|
|
146
149
|
var DEFAULT_API_URL = 'https://api.display.dev';
|
|
147
150
|
var CONFIG_DIR = join(homedir(), '.displaydev');
|
|
148
151
|
var CONFIG_PATH = join(CONFIG_DIR, 'config.json');
|
|
@@ -280,7 +283,7 @@ function createClient(auth) {
|
|
|
280
283
|
clientType: 'cli'
|
|
281
284
|
});
|
|
282
285
|
}
|
|
283
|
-
var program = new Command().name('dsp').description('display.dev CLI — publish artifacts behind company auth').version(
|
|
286
|
+
var program = new Command().name('dsp').description('display.dev CLI — publish artifacts behind company auth').version(version);
|
|
284
287
|
function collectEmails(value, prev) {
|
|
285
288
|
return prev.concat(value);
|
|
286
289
|
}
|
|
@@ -512,7 +515,7 @@ function sleep(ms) {
|
|
|
512
515
|
// --- login ---
|
|
513
516
|
program.command('login').description('Authenticate with display.dev').option('--email <email>', 'Email address').option('--api-key [key]', 'Authenticate with an API key').action(function(opts) {
|
|
514
517
|
return _async_to_generator(function() {
|
|
515
|
-
var _process_env_DISPLAYDEV_API_URL, apiUrl, client, key, rl, validation,
|
|
518
|
+
var _process_env_DISPLAYDEV_API_URL, apiUrl, client, key, rl, validation, email, rl1, method, check, unused, err, msg, rl2, code, result, unused1, deviceResult, unused2, device_code, verification_uri_complete, initialInterval, interval, tokenResult, unused3, _$err;
|
|
516
519
|
return _ts_generator(this, function(_state) {
|
|
517
520
|
switch(_state.label){
|
|
518
521
|
case 0:
|
|
@@ -628,21 +631,26 @@ program.command('login').description('Authenticate with display.dev').option('--
|
|
|
628
631
|
];
|
|
629
632
|
case 8:
|
|
630
633
|
// --- Mode 1 & 2: Email-based login ---
|
|
631
|
-
rl1 = createInterface({
|
|
632
|
-
input: process.stdin,
|
|
633
|
-
output: process.stdout
|
|
634
|
-
});
|
|
635
634
|
email = opts.email;
|
|
636
635
|
if (!!email) return [
|
|
637
636
|
3,
|
|
638
637
|
10
|
|
639
638
|
];
|
|
639
|
+
if (!process.stdin.isTTY) {
|
|
640
|
+
console.error('Email is required. Use --email <email> for non-interactive mode.');
|
|
641
|
+
process.exit(1);
|
|
642
|
+
}
|
|
643
|
+
rl1 = createInterface({
|
|
644
|
+
input: process.stdin,
|
|
645
|
+
output: process.stdout
|
|
646
|
+
});
|
|
640
647
|
return [
|
|
641
648
|
4,
|
|
642
649
|
rl1.question('Email: ')
|
|
643
650
|
];
|
|
644
651
|
case 9:
|
|
645
652
|
email = _state.sent();
|
|
653
|
+
rl1.close();
|
|
646
654
|
_state.label = 10;
|
|
647
655
|
case 10:
|
|
648
656
|
email = email.trim();
|
|
@@ -698,12 +706,11 @@ program.command('login').description('Authenticate with display.dev').option('--
|
|
|
698
706
|
];
|
|
699
707
|
case 17:
|
|
700
708
|
err = _state.sent();
|
|
701
|
-
rl1.close();
|
|
702
709
|
msg = _instanceof(err, Error) ? err.message : 'Something went wrong';
|
|
703
710
|
if (msg.includes('requires SSO')) {
|
|
704
711
|
console.error('Your organization requires SSO. Run dsp login again.');
|
|
705
712
|
} else {
|
|
706
|
-
console.error(
|
|
713
|
+
console.error('Something went wrong. Check your connection and try again.');
|
|
707
714
|
}
|
|
708
715
|
process.exit(1);
|
|
709
716
|
return [
|
|
@@ -712,13 +719,21 @@ program.command('login').description('Authenticate with display.dev').option('--
|
|
|
712
719
|
];
|
|
713
720
|
case 18:
|
|
714
721
|
console.log("Code sent to ".concat(email));
|
|
722
|
+
if (!process.stdin.isTTY) {
|
|
723
|
+
console.error('OTP code required. Use dsp login --api-key for non-interactive auth.');
|
|
724
|
+
process.exit(1);
|
|
725
|
+
}
|
|
726
|
+
rl2 = createInterface({
|
|
727
|
+
input: process.stdin,
|
|
728
|
+
output: process.stdout
|
|
729
|
+
});
|
|
715
730
|
return [
|
|
716
731
|
4,
|
|
717
|
-
|
|
732
|
+
rl2.question('Enter the 6-digit code: ')
|
|
718
733
|
];
|
|
719
734
|
case 19:
|
|
720
735
|
code = _state.sent();
|
|
721
|
-
|
|
736
|
+
rl2.close();
|
|
722
737
|
_state.label = 20;
|
|
723
738
|
case 20:
|
|
724
739
|
_state.trys.push([
|
|
@@ -762,7 +777,6 @@ program.command('login').description('Authenticate with display.dev').option('--
|
|
|
762
777
|
];
|
|
763
778
|
case 25:
|
|
764
779
|
// --- Mode 2: SSO device flow ---
|
|
765
|
-
rl1.close();
|
|
766
780
|
console.log('Your organization requires SSO. Opening browser...');
|
|
767
781
|
_state.label = 26;
|
|
768
782
|
case 26:
|