Skip to content

Commit 6d6a6c7

Browse files
committed
Move warning message to show on startup
1 parent f9a2da1 commit 6d6a6c7

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

cli/src/cli.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
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'
45
import { defineCommand, runMain } from 'citty'
56
import { listen } from 'listhen'
67
import { toNodeListener } from 'h3'
78
import { createConnectorApp, generateToken, CONNECTOR_VERSION } from './server.ts'
89
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'
1011

1112
const DEFAULT_PORT = 31415
1213

@@ -45,13 +46,24 @@ const main = defineCommand({
4546

4647
initLogger()
4748

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+
4861
// Check npm authentication before starting
4962
logInfo('Checking npm authentication...')
5063
let npmUser = await getNpmUser()
5164

5265
if (!npmUser) {
5366
logWarning('Not logged in to npm. Starting npm login...')
54-
logWarning('This allows npmx to access your npm cli and any authenticated contexts.')
5567
// oxlint-disable-next-line no-console -- deliberate spacing
5668
console.log()
5769

0 commit comments

Comments
 (0)