@promptcellar/pc 0.3.0 → 0.3.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/bin/pc.js +1 -1
- package/package.json +2 -3
- package/src/commands/login.js +9 -15
package/bin/pc.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptcellar/pc",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "CLI for PromptCellar - sync prompts between your terminal and the cloud",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -40,7 +40,6 @@
|
|
|
40
40
|
"ora": "^8.0.0",
|
|
41
41
|
"inquirer": "^9.2.0",
|
|
42
42
|
"socket.io-client": "^4.6.0",
|
|
43
|
-
"node-fetch": "^3.3.0"
|
|
44
|
-
"open": "^10.0.0"
|
|
43
|
+
"node-fetch": "^3.3.0"
|
|
45
44
|
}
|
|
46
45
|
}
|
package/src/commands/login.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import ora from 'ora';
|
|
2
2
|
import chalk from 'chalk';
|
|
3
|
-
import
|
|
4
|
-
import { setApiKey, setApiUrl, isLoggedIn, getApiUrl } from '../lib/config.js';
|
|
3
|
+
import { setApiKey, setApiUrl, isLoggedIn } from '../lib/config.js';
|
|
5
4
|
|
|
6
5
|
const DEFAULT_API_URL = 'https://prompts.weldedanvil.com';
|
|
7
6
|
|
|
@@ -56,7 +55,7 @@ async function pollForApproval(apiUrl, deviceCode, interval, expiresIn) {
|
|
|
56
55
|
|
|
57
56
|
function getDeviceName() {
|
|
58
57
|
const os = process.platform;
|
|
59
|
-
const hostname = process.env.HOSTNAME || process.env.COMPUTERNAME || '
|
|
58
|
+
const hostname = process.env.HOSTNAME || process.env.COMPUTERNAME || 'CLI';
|
|
60
59
|
|
|
61
60
|
const osNames = {
|
|
62
61
|
darwin: 'macOS',
|
|
@@ -82,27 +81,22 @@ export async function login(options) {
|
|
|
82
81
|
|
|
83
82
|
console.log(chalk.bold('\nPromptCellar CLI Login\n'));
|
|
84
83
|
|
|
85
|
-
const spinner = ora('
|
|
84
|
+
const spinner = ora('Connecting...').start();
|
|
86
85
|
|
|
87
86
|
try {
|
|
88
87
|
// Step 1: Request device code
|
|
89
88
|
const authData = await initiateDeviceAuth(apiUrl);
|
|
90
89
|
spinner.stop();
|
|
91
90
|
|
|
92
|
-
// Step 2: Show
|
|
93
|
-
console.log(chalk.bold('Your verification code:\n'));
|
|
94
|
-
console.log(chalk.cyan.bold(` ${authData.user_code}\n`));
|
|
95
|
-
console.log('Opening your browser to authorize this device...\n');
|
|
96
|
-
console.log(chalk.dim(`If the browser doesn't open, visit: ${authData.verification_url}\n`));
|
|
97
|
-
|
|
98
|
-
// Open browser with the code pre-filled
|
|
91
|
+
// Step 2: Show login URL and code
|
|
99
92
|
const verifyUrl = `${authData.verification_url}?code=${authData.user_code}`;
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
});
|
|
93
|
+
|
|
94
|
+
console.log('Open this URL in your browser to log in:\n');
|
|
95
|
+
console.log(chalk.cyan.bold(` ${verifyUrl}\n`));
|
|
96
|
+
console.log(chalk.dim(`Or go to ${authData.verification_url} and enter code: ${authData.user_code}\n`));
|
|
103
97
|
|
|
104
98
|
// Step 3: Poll for approval
|
|
105
|
-
spinner.start('Waiting for
|
|
99
|
+
spinner.start('Waiting for you to authorize in browser...');
|
|
106
100
|
|
|
107
101
|
const result = await pollForApproval(
|
|
108
102
|
apiUrl,
|