novacloud22-cli 1.0.1 → 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.
Files changed (2) hide show
  1. package/index.js +44 -4
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -124,10 +124,50 @@ program
124
124
  })
125
125
 
126
126
  server.listen(9876, async () => {
127
- spinner.text = 'Opening browser...'
128
- const loginUrl = `${FRONTEND_URL}/signin?cli=1&callback=http://localhost:9876`
129
- await open(loginUrl)
130
- spinner.text = 'Waiting for login in browser...'
127
+ spinner.stop()
128
+ const loginUrl = `${FRONTEND_URL}/cli-auth?callback=http://localhost:9876`
129
+
130
+ console.log(chalk.bold('\n NovaCloud22 CLI Login\n'))
131
+ console.log(chalk.gray(' ' + '─'.repeat(50)))
132
+ console.log(chalk.cyan('\n Login URL:'))
133
+ console.log(chalk.blue.underline(` ${loginUrl}\n`))
134
+ console.log(chalk.gray(' ' + '─'.repeat(50)))
135
+
136
+ const { action } = await inquirer.prompt([{
137
+ type: 'list',
138
+ name: 'action',
139
+ message: 'What would you like to do?',
140
+ choices: [
141
+ { name: '🌐 Open in browser', value: 'open' },
142
+ { name: '📋 Copy link', value: 'copy' },
143
+ { name: '✕ Cancel', value: 'cancel' },
144
+ ]
145
+ }])
146
+
147
+ if (action === 'open') {
148
+ await open(loginUrl)
149
+ console.log(chalk.gray('\n Browser opened. Complete sign in there.\n'))
150
+ console.log(chalk.gray(' Waiting for authentication...'))
151
+ } else if (action === 'copy') {
152
+ // Copy to clipboard using pbcopy (mac) / clip (win) / xclip (linux)
153
+ const { execSync } = require('child_process')
154
+ try {
155
+ const platform = process.platform
156
+ if (platform === 'darwin') execSync(`echo '${loginUrl}' | pbcopy`)
157
+ else if (platform === 'win32') execSync(`echo ${loginUrl} | clip`)
158
+ else execSync(`echo '${loginUrl}' | xclip -selection clipboard`)
159
+ console.log(chalk.green('\n ✓ Link copied to clipboard!'))
160
+ console.log(chalk.gray(' Paste it in your browser to sign in.\n'))
161
+ console.log(chalk.gray(' Waiting for authentication...'))
162
+ } catch {
163
+ console.log(chalk.yellow('\n Could not copy automatically. Copy this link manually:'))
164
+ console.log(chalk.blue.underline(` ${loginUrl}\n`))
165
+ }
166
+ } else {
167
+ console.log(chalk.gray('\n Login cancelled.\n'))
168
+ server.close()
169
+ process.exit(0)
170
+ }
131
171
  })
132
172
 
133
173
  server.on('error', () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "novacloud22-cli",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Deploy static websites to NovaCloud22",
5
5
  "main": "index.js",
6
6
  "bin": {