Skip to content

Commit 50377f2

Browse files
authored
fix(cli): add security confirmation when launching (#20)
1 parent f9eab00 commit 50377f2

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

cli/src/cli.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
#!/usr/bin/env node
22
import process from 'node:process'
33
import { spawn } from 'node:child_process'
4+
import * as p from '@clack/prompts'
5+
import pc from 'picocolors'
46
import { defineCommand, runMain } from 'citty'
57
import { listen } from 'listhen'
68
import { toNodeListener } from 'h3'
79
import { createConnectorApp, generateToken, CONNECTOR_VERSION } from './server.ts'
810
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'
1012

1113
const DEFAULT_PORT = 31415
1214

@@ -45,6 +47,20 @@ const main = defineCommand({
4547

4648
initLogger()
4749

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+
4864
// Check npm authentication before starting
4965
logInfo('Checking npm authentication...')
5066
let npmUser = await getNpmUser()

0 commit comments

Comments
 (0)