|
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' |
| 5 | +import pc from 'picocolors' |
4 | 6 | import { defineCommand, runMain } from 'citty' |
5 | 7 | import { listen } from 'listhen' |
6 | 8 | import { toNodeListener } from 'h3' |
7 | 9 | import { createConnectorApp, generateToken, CONNECTOR_VERSION } from './server.ts' |
8 | 10 | import { getNpmUser } from './npm-client.ts' |
9 | | -import { initLogger, showToken, logInfo, logWarning } from './logger.ts' |
| 11 | +import { initLogger, showToken, logInfo, logWarning, logError } from './logger.ts' |
10 | 12 |
|
11 | 13 | const DEFAULT_PORT = 31415 |
12 | 14 |
|
@@ -45,6 +47,20 @@ const main = defineCommand({ |
45 | 47 |
|
46 | 48 | initLogger() |
47 | 49 |
|
| 50 | + // Warning message and accept prompt |
| 51 | + logWarning( |
| 52 | + `This allows ${pc.underline('npmx.dev')} to access your npm cli and any authenticated contexts.`, |
| 53 | + ) |
| 54 | + const accept = await p.confirm({ |
| 55 | + message: 'Do you accept?', |
| 56 | + initialValue: true, |
| 57 | + }) |
| 58 | + |
| 59 | + if (!accept || p.isCancel(accept)) { |
| 60 | + logError('Connector setup cancelled.') |
| 61 | + process.exit(0) |
| 62 | + } |
| 63 | + |
48 | 64 | // Check npm authentication before starting |
49 | 65 | logInfo('Checking npm authentication...') |
50 | 66 | let npmUser = await getNpmUser() |
|
0 commit comments