Skip to content

Commit 3923edc

Browse files
committed
Cli connection link points to localhost when running w. pnpm dev
1 parent bf55ec9 commit 3923edc

3 files changed

Lines changed: 11 additions & 5 deletions

File tree

cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
],
2828
"scripts": {
2929
"build": "tsdown",
30-
"dev": "node --experimental-strip-types src/cli.ts",
30+
"dev": "node --experimental-strip-types src/cli.ts --frontend-url http://localhost:3000/",
3131
"test:types": "tsc --noEmit"
3232
},
3333
"dependencies": {

cli/src/cli.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { getNpmUser } from './npm-client.ts'
1010
import { initLogger, showToken, logInfo, logWarning, logError } from './logger.ts'
1111

1212
const DEFAULT_PORT = 31415
13+
const DEFAULT_FRONTEND_URL = 'https://npmx.dev/'
1314

1415
async function runNpmLogin(): Promise<boolean> {
1516
return new Promise(resolve => {
@@ -35,11 +36,16 @@ const main = defineCommand({
3536
description: 'Local connector for npmx.dev',
3637
},
3738
args: {
38-
port: {
39+
'port': {
3940
type: 'string',
4041
description: 'Port to listen on',
4142
default: String(DEFAULT_PORT),
4243
},
44+
'frontend-url': {
45+
type: 'string',
46+
description: 'Url for the npmx.dev frontend',
47+
default: DEFAULT_FRONTEND_URL,
48+
},
4349
},
4450
async run({ args }) {
4551
const port = Number.parseInt(args.port as string, 10) || DEFAULT_PORT
@@ -90,7 +96,7 @@ const main = defineCommand({
9096
logInfo(`Authenticated as: ${npmUser}`)
9197

9298
const token = generateToken()
93-
showToken(token, port)
99+
showToken(token, port, args.frontendUrl)
94100

95101
const app = createConnectorApp(token)
96102

cli/src/logger.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ export function logMessage(message: string): void {
6363
/**
6464
* Show the connection token in a nice box
6565
*/
66-
export function showToken(token: string, port: number): void {
67-
const connectUrl = `https://npmx.dev/?token=${token}&port=${port}`
66+
export function showToken(token: string, port: number, frontendUrl: string): void {
67+
const connectUrl = `${frontendUrl}?token=${token}&port=${port}`
6868

6969
p.note(
7070
[

0 commit comments

Comments
 (0)