Skip to content
Closed
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": "node --experimental-strip-types src/cli.ts --frontend-url http://localhost:3000/",
"test:types": "tsc --noEmit"
},
"dependencies": {
Expand Down
10 changes: 8 additions & 2 deletions cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ 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/'

async function runNpmLogin(): Promise<boolean> {
return new Promise(resolve => {
Expand All @@ -35,11 +36,16 @@ const main = defineCommand({
description: 'Local connector for npmx.dev',
},
args: {
port: {
'port': {
type: 'string',
description: 'Port to listen on',
default: String(DEFAULT_PORT),
},
'frontend-url': {
type: 'string',
description: 'Url for the npmx.dev frontend',
default: DEFAULT_FRONTEND_URL,
},
},
async run({ args }) {
const port = Number.parseInt(args.port as string, 10) || DEFAULT_PORT
Expand Down Expand Up @@ -90,7 +96,7 @@ const main = defineCommand({
logInfo(`Authenticated as: ${npmUser}`)

const token = generateToken()
showToken(token, port)
showToken(token, port, args.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
Loading