fix(cli): browser login works on npm

This commit is contained in:
Ruben Fiszel
2024-09-10 12:06:12 +02:00
parent 516466bbda
commit cfb50ce8b8
4 changed files with 17 additions and 8 deletions
Generated
+6
View File
@@ -64,6 +64,8 @@
"npm:es-main": "npm:es-main@1.3.0",
"npm:esbuild": "npm:esbuild@0.23.0",
"npm:express": "npm:express@4.19.2",
"npm:get-port": "npm:get-port@7.1.0",
"npm:get-port@7.1.0": "npm:get-port@7.1.0",
"npm:gitignore-parser": "npm:gitignore-parser@0.0.2",
"npm:jszip@3.7.1": "npm:jszip@3.7.1",
"npm:minimatch": "npm:minimatch@10.0.1",
@@ -656,6 +658,10 @@
"hasown": "hasown@2.0.2"
}
},
"get-port@7.1.0": {
"integrity": "sha512-QB9NKEeDg3xxVwCCwJQ9+xycaz6pBB6iQ76wiWMl1927n0Kir6alPiP+yuiICLLU4jpMe08dXfpebuQppFA2zw==",
"dependencies": {}
},
"gitignore-parser@0.0.2": {
"integrity": "sha512-X6mpqUv59uWLGD4n3hZ8Cu8KbF2PMWPSFYmxZjdkpm3yOU7hSUYnzTkZI1mcWqchphvqyuz3/BhgBR4E/JtkCg==",
"dependencies": {}
+1 -2
View File
@@ -19,7 +19,6 @@ export { ensureDir } from "jsr:@std/fs";
export { SEPARATOR as SEP } from "jsr:@std/path";
export * as path from "jsr:@std/path/";
export { encodeHex } from "jsr:@std/encoding";
export { getAvailablePort } from "jsr:@std/net";
export { writeAllSync } from "jsr:@std/io/write-all";
export { copy } from "jsr:@std/io/copy";
export { readAll } from "jsr:@std/io/read-all";
@@ -36,6 +35,6 @@ export { default as JSZip } from "npm:jszip@3.7.1";
export * as express from "npm:express";
export * as http from "node:http";
export { WebSocketServer, WebSocket } from "npm:ws";
export * as getPort from "npm:get-port@7.1.0";
export * as open from "npm:open";
export * as esMain from "npm:es-main";
+3 -3
View File
@@ -3,7 +3,7 @@ import {
SEP,
WebSocketServer,
express,
getAvailablePort,
getPort,
http,
log,
open,
@@ -81,7 +81,7 @@ async function dev(opts: GlobalOptions & SyncOptions) {
}
async function startApp() {
const app = express();
const app = express.default();
const server = http.createServer(app);
const wss = new WebSocketServer({ server });
@@ -117,7 +117,7 @@ async function dev(opts: GlobalOptions & SyncOptions) {
});
// Start the server
const port = await getAvailablePort({ preferredPort: 3001 });
const port = await getPort.default({ port: 3001 });
const url =
`${workspace.remote}scripts/dev?workspace=${workspace.workspaceId}&local=true` +
(port === PORT ? "" : `&port=${port}`);
+7 -3
View File
@@ -1,5 +1,5 @@
import { GlobalOptions } from "./types.ts";
import { colors, getAvailablePort, log, open, Secret, Select } from "./deps.ts";
import { colors, getPort, log, open, Secret, Select } from "./deps.ts";
import * as http from "node:http";
export async function loginInteractive(remote: string) {
@@ -45,8 +45,12 @@ export async function tryGetLoginInfo(
export async function browserLogin(
baseUrl: string
): Promise<string | undefined> {
const env = Deno.env.get("TOKEN_PORT");
const port = env ? Number(env) : await getAvailablePort();
const env =
Deno.env.get("TOKEN_PORT") != undefined
? parseInt(Deno.env.get("TOKEN_PORT")!)
: undefined;
const port = await getPort.default({ port: env });
if (port == undefined) {
log.info(colors.red.underline("failed to aquire port"));
return undefined;