|
1 | 1 | #!/usr/bin/env node |
2 | 2 | import process from 'node:process' |
3 | 3 | import { spawn } from 'node:child_process' |
| 4 | +import * as p from '@clack/prompts' |
4 | 5 | import { defineCommand, runMain } from 'citty' |
5 | 6 | import { listen } from 'listhen' |
6 | 7 | import { toNodeListener } from 'h3' |
7 | 8 | import { createConnectorApp, generateToken, CONNECTOR_VERSION } from './server.ts' |
8 | 9 | import { getNpmUser } from './npm-client.ts' |
9 | | -import { initLogger, showToken, logInfo, logWarning } from './logger.ts' |
| 10 | +import { initLogger, showToken, logInfo, logWarning, logError } from './logger.ts' |
10 | 11 |
|
11 | 12 | const DEFAULT_PORT = 31415 |
12 | 13 |
|
@@ -45,13 +46,24 @@ const main = defineCommand({ |
45 | 46 |
|
46 | 47 | initLogger() |
47 | 48 |
|
| 49 | + // Warning message and accept prompt |
| 50 | + logWarning('This allows npmx to access your npm cli and any authenticated contexts.') |
| 51 | + const accept = await p.confirm({ |
| 52 | + message: 'Do you accept?', |
| 53 | + initialValue: false, |
| 54 | + }) |
| 55 | + |
| 56 | + if (!accept || p.isCancel(accept)) { |
| 57 | + logError('Connector setup cancelled.') |
| 58 | + process.exit(0) |
| 59 | + } |
| 60 | + |
48 | 61 | // Check npm authentication before starting |
49 | 62 | logInfo('Checking npm authentication...') |
50 | 63 | let npmUser = await getNpmUser() |
51 | 64 |
|
52 | 65 | if (!npmUser) { |
53 | 66 | logWarning('Not logged in to npm. Starting npm login...') |
54 | | - logWarning('This allows npmx to access your npm cli and any authenticated contexts.') |
55 | 67 | // oxlint-disable-next-line no-console -- deliberate spacing |
56 | 68 | console.log() |
57 | 69 |
|
|
0 commit comments