[READ-ONLY] a fast, modern browser for the npm registry
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat(cli): support click-to-open on npmx.dev

+21 -4
+16 -1
app/composables/useConnector.ts
··· 68 68 69 69 const baseUrl = computed(() => `http://localhost:${config.value?.port ?? DEFAULT_PORT}`) 70 70 71 - // Load persisted config on client 71 + const route = useRoute() 72 + const router = useRouter() 73 + 72 74 onMounted(() => { 75 + const urlToken = route.query.token as string | undefined 76 + const urlPort = route.query.port as string | undefined 77 + 78 + if (urlToken) { 79 + const { token: _, port: __, ...cleanQuery } = route.query 80 + router.replace({ query: cleanQuery }) 81 + 82 + // Connect with URL params 83 + const port = urlPort ? Number.parseInt(urlPort, 10) : DEFAULT_PORT 84 + connect(urlToken, port) 85 + return 86 + } 87 + 73 88 const stored = localStorage.getItem(STORAGE_KEY) 74 89 if (stored) { 75 90 try {
+5 -3
cli/src/logger.ts
··· 58 58 * Show the connection token in a nice box 59 59 */ 60 60 export function showToken(token: string, port: number): void { 61 + const connectUrl = `https://npmx.dev/?token=${token}&port=${port}` 62 + 61 63 p.note( 62 64 [ 63 - `Token: ${pc.bold(pc.cyan(token))}`, 65 + `Open: ${pc.bold(pc.underline(pc.cyan(connectUrl)))}`, 64 66 '', 65 - pc.dim(`Server: http://localhost:${port}`), 67 + pc.dim(`Or paste token manually: ${token}`), 66 68 ].join('\n'), 67 - 'Paste this token in npmx.dev to connect', 69 + 'Click to connect', 68 70 ) 69 71 } 70 72