Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
],
"scripts": {
"build": "tsdown",
"dev": "node --experimental-strip-types src/cli.ts",
"dev": "NPMX_CLI_DEV=true node --experimental-strip-types src/cli.ts",
"test:types": "tsc --noEmit"
},
"dependencies": {
Expand Down
6 changes: 5 additions & 1 deletion cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { getNpmUser } from './npm-client.ts'
import { initLogger, showToken, logInfo, logWarning, logError } from './logger.ts'

const DEFAULT_PORT = 31415
const DEFAULT_FRONTEND_URL = 'https://npmx.dev/'
const DEV_FRONTEND_URL = 'http://localhost:3000/'

async function runNpmLogin(): Promise<boolean> {
return new Promise(resolve => {
Expand Down Expand Up @@ -43,6 +45,8 @@ const main = defineCommand({
},
async run({ args }) {
const port = Number.parseInt(args.port as string, 10) || DEFAULT_PORT
const frontendUrl =
process.env.NPMX_CLI_DEV === 'true' ? DEV_FRONTEND_URL : DEFAULT_FRONTEND_URL

initLogger()

Expand Down Expand Up @@ -90,7 +94,7 @@ const main = defineCommand({
logInfo(`Authenticated as: ${npmUser}`)

const token = generateToken()
showToken(token, port)
showToken(token, port, frontendUrl)

const app = createConnectorApp(token)

Expand Down
4 changes: 2 additions & 2 deletions cli/src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ export function logMessage(message: string): void {
/**
* Show the connection token in a nice box
*/
export function showToken(token: string, port: number): void {
const connectUrl = `https://npmx.dev/?token=${token}&port=${port}`
export function showToken(token: string, port: number, frontendUrl: string): void {
const connectUrl = `${frontendUrl}?token=${token}&port=${port}`

p.note(
[
Expand Down