[READ-ONLY] a fast, modern browser for the npm registry
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(cli): add security confirmation when launching (#20)

authored by

Mainasara Al-amin Tsowa and committed by
GitHub
50377f26 f9eab006

+17 -1
+17 -1
cli/src/cli.ts
··· 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 ··· 44 46 const port = Number.parseInt(args.port as string, 10) || DEFAULT_PORT 45 47 46 48 initLogger() 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 + } 47 63 48 64 // Check npm authentication before starting 49 65 logInfo('Checking npm authentication...')