windmill-cli 1.393.4 → 1.393.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/deps.js +1 -1
- package/esm/dev.js +3 -3
- package/esm/login.js +5 -3
- package/package.json +3 -2
- package/types/deps.d.ts +1 -1
- package/types/deps.d.ts.map +1 -1
- package/types/login.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/net/1.0.2/get_available_port.js +0 -125
- package/esm/deps/jsr.io/@std/net/1.0.2/get_network_address.js +0 -46
- package/esm/deps/jsr.io/@std/net/1.0.2/mod.js +0 -20
- package/types/deps/jsr.io/@std/net/1.0.2/get_available_port.d.ts +0 -52
- package/types/deps/jsr.io/@std/net/1.0.2/get_available_port.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/net/1.0.2/get_network_address.d.ts +0 -37
- package/types/deps/jsr.io/@std/net/1.0.2/get_network_address.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/net/1.0.2/mod.d.ts +0 -20
- package/types/deps/jsr.io/@std/net/1.0.2/mod.d.ts.map +0 -1
package/esm/deps.js
CHANGED
|
@@ -17,7 +17,6 @@ export { ensureDir } from "./deps/jsr.io/@std/fs/1.0.3/mod.js";
|
|
|
17
17
|
export { SEPARATOR as SEP } from "./deps/jsr.io/@std/path/1.0.4/mod.js";
|
|
18
18
|
export * as path from "./deps/jsr.io/@std/path/1.0.4/mod.js";
|
|
19
19
|
export { encodeHex } from "./deps/jsr.io/@std/encoding/1.0.4/mod.js";
|
|
20
|
-
export { getAvailablePort } from "./deps/jsr.io/@std/net/1.0.2/mod.js";
|
|
21
20
|
export { writeAllSync } from "./deps/jsr.io/@std/io/0.224.7/write_all.js";
|
|
22
21
|
export { copy } from "./deps/jsr.io/@std/io/0.224.7/copy.js";
|
|
23
22
|
export { readAll } from "./deps/jsr.io/@std/io/0.224.7/read_all.js";
|
|
@@ -30,5 +29,6 @@ export { default as JSZip } from "jszip";
|
|
|
30
29
|
export * as express from "express";
|
|
31
30
|
export * as http from "node:http";
|
|
32
31
|
export { WebSocketServer, WebSocket } from "ws";
|
|
32
|
+
export * as getPort from "get-port";
|
|
33
33
|
export * as open from "open";
|
|
34
34
|
export * as esMain from "es-main";
|
package/esm/dev.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as dntShim from "./_dnt.shims.js";
|
|
2
|
-
import { Command, SEP, WebSocketServer, express,
|
|
2
|
+
import { Command, SEP, WebSocketServer, express, getPort, http, log, open, } from "./deps.js";
|
|
3
3
|
import { ignoreF } from "./sync.js";
|
|
4
4
|
import { requireLogin, resolveWorkspace } from "./context.js";
|
|
5
5
|
import { mergeConfigWithConfigFile, readConfigFile, } from "./conf.js";
|
|
@@ -52,7 +52,7 @@ async function dev(opts) {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
async function startApp() {
|
|
55
|
-
const app = express();
|
|
55
|
+
const app = express.default();
|
|
56
56
|
const server = http.createServer(app);
|
|
57
57
|
const wss = new WebSocketServer({ server });
|
|
58
58
|
// WebSocket server event listeners
|
|
@@ -83,7 +83,7 @@ async function dev(opts) {
|
|
|
83
83
|
});
|
|
84
84
|
});
|
|
85
85
|
// Start the server
|
|
86
|
-
const port = await
|
|
86
|
+
const port = await getPort.default({ port: 3001 });
|
|
87
87
|
const url = `${workspace.remote}scripts/dev?workspace=${workspace.workspaceId}&local=true` +
|
|
88
88
|
(port === PORT ? "" : `&port=${port}`);
|
|
89
89
|
console.log(`Go to ${url}`);
|
package/esm/login.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as dntShim from "./_dnt.shims.js";
|
|
2
|
-
import { colors,
|
|
2
|
+
import { colors, getPort, log, open, Secret, Select } from "./deps.js";
|
|
3
3
|
import * as http from "node:http";
|
|
4
4
|
export async function loginInteractive(remote) {
|
|
5
5
|
let token;
|
|
@@ -35,8 +35,10 @@ export async function tryGetLoginInfo(opts) {
|
|
|
35
35
|
return undefined;
|
|
36
36
|
}
|
|
37
37
|
export async function browserLogin(baseUrl) {
|
|
38
|
-
const env = dntShim.Deno.env.get("TOKEN_PORT")
|
|
39
|
-
|
|
38
|
+
const env = dntShim.Deno.env.get("TOKEN_PORT") != undefined
|
|
39
|
+
? parseInt(dntShim.Deno.env.get("TOKEN_PORT"))
|
|
40
|
+
: undefined;
|
|
41
|
+
const port = await getPort.default({ port: env });
|
|
40
42
|
if (port == undefined) {
|
|
41
43
|
log.info(colors.red.underline("failed to aquire port"));
|
|
42
44
|
return undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "windmill-cli",
|
|
3
|
-
"version": "1.393.
|
|
3
|
+
"version": "1.393.5",
|
|
4
4
|
"description": "CLI for Windmill",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"es-main": "*",
|
|
34
34
|
"esbuild": "*",
|
|
35
35
|
"express": "*",
|
|
36
|
+
"get-port": "7.1.0",
|
|
36
37
|
"jszip": "3.7.1",
|
|
37
38
|
"minimatch": "*",
|
|
38
39
|
"open": "*",
|
|
@@ -45,4 +46,4 @@
|
|
|
45
46
|
"picocolors": "^1.0.0"
|
|
46
47
|
},
|
|
47
48
|
"_generatedBy": "dnt@dev"
|
|
48
|
-
}
|
|
49
|
+
}
|
package/types/deps.d.ts
CHANGED
|
@@ -14,7 +14,6 @@ export { ensureDir } from "./deps/jsr.io/@std/fs/1.0.3/mod.js";
|
|
|
14
14
|
export { SEPARATOR as SEP } from "./deps/jsr.io/@std/path/1.0.4/mod.js";
|
|
15
15
|
export * as path from "./deps/jsr.io/@std/path/1.0.4/mod.js";
|
|
16
16
|
export { encodeHex } from "./deps/jsr.io/@std/encoding/1.0.4/mod.js";
|
|
17
|
-
export { getAvailablePort } from "./deps/jsr.io/@std/net/1.0.2/mod.js";
|
|
18
17
|
export { writeAllSync } from "./deps/jsr.io/@std/io/0.224.7/write_all.js";
|
|
19
18
|
export { copy } from "./deps/jsr.io/@std/io/0.224.7/copy.js";
|
|
20
19
|
export { readAll } from "./deps/jsr.io/@std/io/0.224.7/read_all.js";
|
|
@@ -26,6 +25,7 @@ export { default as JSZip } from "jszip";
|
|
|
26
25
|
export * as express from "express";
|
|
27
26
|
export * as http from "node:http";
|
|
28
27
|
export { WebSocketServer, WebSocket } from "ws";
|
|
28
|
+
export * as getPort from "get-port";
|
|
29
29
|
export * as open from "open";
|
|
30
30
|
export * as esMain from "es-main";
|
|
31
31
|
//# sourceMappingURL=deps.d.ts.map
|
package/types/deps.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deps.d.ts","sourceRoot":"","sources":["../src/deps.ts"],"names":[],"mappings":"AACA,cAAc,iBAAiB,CAAC;AAGhC,OAAO,EAAE,OAAO,EAAE,MAAM,+DAA+D,CAAC;AACxF,OAAO,EAAE,KAAK,EAAE,MAAM,6DAA6D,CAAC;AACpF,OAAO,EAAE,MAAM,EAAE,MAAM,+DAA+D,CAAC;AACvF,OAAO,EAAE,MAAM,EAAE,MAAM,iEAAiE,CAAC;AACzF,OAAO,EAAE,MAAM,EAAE,MAAM,iEAAiE,CAAC;AACzF,OAAO,EAAE,OAAO,EAAE,MAAM,kEAAkE,CAAC;AAC3F,OAAO,EAAE,KAAK,EAAE,MAAM,gEAAgE,CAAC;AACvF,OAAO,EAAE,cAAc,EAAE,MAAM,uEAAuE,CAAC;AACvG,OAAO,EAAE,WAAW,EAAE,MAAM,gFAAgF,CAAC;AAC7G,OAAO,EAAE,QAAQ,EAAE,MAAM,uEAAuE,CAAC;AAEjG,OAAO,EAAE,kBAAkB,EAAE,MAAM,2EAA2E,CAAC;AAE/G,OAAO,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAC/D,OAAO,EAAE,SAAS,IAAI,GAAG,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,KAAK,IAAI,MAAM,sCAAsC,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAC;AACrE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"deps.d.ts","sourceRoot":"","sources":["../src/deps.ts"],"names":[],"mappings":"AACA,cAAc,iBAAiB,CAAC;AAGhC,OAAO,EAAE,OAAO,EAAE,MAAM,+DAA+D,CAAC;AACxF,OAAO,EAAE,KAAK,EAAE,MAAM,6DAA6D,CAAC;AACpF,OAAO,EAAE,MAAM,EAAE,MAAM,+DAA+D,CAAC;AACvF,OAAO,EAAE,MAAM,EAAE,MAAM,iEAAiE,CAAC;AACzF,OAAO,EAAE,MAAM,EAAE,MAAM,iEAAiE,CAAC;AACzF,OAAO,EAAE,OAAO,EAAE,MAAM,kEAAkE,CAAC;AAC3F,OAAO,EAAE,KAAK,EAAE,MAAM,gEAAgE,CAAC;AACvF,OAAO,EAAE,cAAc,EAAE,MAAM,uEAAuE,CAAC;AACvG,OAAO,EAAE,WAAW,EAAE,MAAM,gFAAgF,CAAC;AAC7G,OAAO,EAAE,QAAQ,EAAE,MAAM,uEAAuE,CAAC;AAEjG,OAAO,EAAE,kBAAkB,EAAE,MAAM,2EAA2E,CAAC;AAE/G,OAAO,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAC/D,OAAO,EAAE,SAAS,IAAI,GAAG,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,KAAK,IAAI,MAAM,sCAAsC,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,4CAA4C,CAAC;AAC1E,OAAO,EAAE,IAAI,EAAE,MAAM,uCAAuC,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,2CAA2C,CAAC;AAEpE,OAAO,KAAK,GAAG,MAAM,uCAAuC,CAAC;AAC7D,OAAO,EAAE,SAAS,IAAI,aAAa,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,sCAAsC,CAAC;AAItG,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,OAAO,CAAC;AAEzC,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAChD,OAAO,KAAK,OAAO,MAAM,UAAU,CAAC;AACpC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,MAAM,MAAM,SAAS,CAAC"}
|
package/types/login.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../src/login.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAI3C,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,MAAM,+BA2BpD;AAGD,wBAAsB,eAAe,CACnC,IAAI,EAAE,aAAa,GAClB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAM7B;AAED,wBAAsB,YAAY,CAChC,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,
|
|
1
|
+
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../src/login.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAI3C,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,MAAM,+BA2BpD;AAGD,wBAAsB,eAAe,CACnC,IAAI,EAAE,aAAa,GAClB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAM7B;AAED,wBAAsB,YAAY,CAChC,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CA2E7B"}
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
|
2
|
-
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
3
|
-
if (value !== null && value !== void 0) {
|
|
4
|
-
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
5
|
-
var dispose, inner;
|
|
6
|
-
if (async) {
|
|
7
|
-
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
8
|
-
dispose = value[Symbol.asyncDispose];
|
|
9
|
-
}
|
|
10
|
-
if (dispose === void 0) {
|
|
11
|
-
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
12
|
-
dispose = value[Symbol.dispose];
|
|
13
|
-
if (async) inner = dispose;
|
|
14
|
-
}
|
|
15
|
-
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
16
|
-
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
17
|
-
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
18
|
-
}
|
|
19
|
-
else if (async) {
|
|
20
|
-
env.stack.push({ async: true });
|
|
21
|
-
}
|
|
22
|
-
return value;
|
|
23
|
-
};
|
|
24
|
-
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
|
25
|
-
return function (env) {
|
|
26
|
-
function fail(e) {
|
|
27
|
-
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
28
|
-
env.hasError = true;
|
|
29
|
-
}
|
|
30
|
-
function next() {
|
|
31
|
-
while (env.stack.length) {
|
|
32
|
-
var rec = env.stack.pop();
|
|
33
|
-
try {
|
|
34
|
-
var result = rec.dispose && rec.dispose.call(rec.value);
|
|
35
|
-
if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
36
|
-
}
|
|
37
|
-
catch (e) {
|
|
38
|
-
fail(e);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
if (env.hasError) throw env.error;
|
|
42
|
-
}
|
|
43
|
-
return next();
|
|
44
|
-
};
|
|
45
|
-
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
46
|
-
var e = new Error(message);
|
|
47
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
48
|
-
});
|
|
49
|
-
/** Options for {@linkcode getAvailablePort}. */
|
|
50
|
-
import * as dntShim from "../../../../../_dnt.shims.js";
|
|
51
|
-
/**
|
|
52
|
-
* Returns an available network port.
|
|
53
|
-
*
|
|
54
|
-
* > [!IMPORTANT]
|
|
55
|
-
* > In most cases, this function is not needed. Do not use it for trivial uses
|
|
56
|
-
* > such as when using {@linkcode Deno.serve} or {@linkcode Deno.listen}
|
|
57
|
-
* > directly. Instead, set the `port` option to `0` to automatically use an
|
|
58
|
-
* > available port, then get the assigned port from the function's return
|
|
59
|
-
* > object (see "Recommended Usage" example).
|
|
60
|
-
*
|
|
61
|
-
* @param options Options for getting an available port.
|
|
62
|
-
* @returns An available network port.
|
|
63
|
-
*
|
|
64
|
-
* @example Recommended Usage
|
|
65
|
-
*
|
|
66
|
-
* Bad:
|
|
67
|
-
* ```ts no-eval no-assert
|
|
68
|
-
* import { getAvailablePort } from "@std/net/get-available-port";
|
|
69
|
-
*
|
|
70
|
-
* const port = getAvailablePort();
|
|
71
|
-
* Deno.serve({ port }, () => new Response("Hello, world!"));
|
|
72
|
-
* ```
|
|
73
|
-
*
|
|
74
|
-
* Good:
|
|
75
|
-
* ```ts no-eval no-assert
|
|
76
|
-
* const { port } = Deno.serve({ port: 0 }, () => new Response("Hello, world!")).addr;
|
|
77
|
-
* ```
|
|
78
|
-
*
|
|
79
|
-
* Good:
|
|
80
|
-
* ```ts no-eval no-assert
|
|
81
|
-
* import { getAvailablePort } from "@std/net/get-available-port";
|
|
82
|
-
*
|
|
83
|
-
* const command = new Deno.Command(Deno.execPath(), {
|
|
84
|
-
* args: ["test.ts", "--port", getAvailablePort().toString()],
|
|
85
|
-
* });
|
|
86
|
-
* // ...
|
|
87
|
-
* ```
|
|
88
|
-
*/
|
|
89
|
-
export function getAvailablePort(options) {
|
|
90
|
-
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
91
|
-
try {
|
|
92
|
-
if (options?.preferredPort) {
|
|
93
|
-
try {
|
|
94
|
-
const env_2 = { stack: [], error: void 0, hasError: false };
|
|
95
|
-
try {
|
|
96
|
-
// Check if the preferred port is available
|
|
97
|
-
const listener = __addDisposableResource(env_2, dntShim.Deno.listen({ port: options.preferredPort }), false);
|
|
98
|
-
return listener.addr.port;
|
|
99
|
-
}
|
|
100
|
-
catch (e_1) {
|
|
101
|
-
env_2.error = e_1;
|
|
102
|
-
env_2.hasError = true;
|
|
103
|
-
}
|
|
104
|
-
finally {
|
|
105
|
-
__disposeResources(env_2);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
catch (e) {
|
|
109
|
-
// If the preferred port is not available, fall through and find an available port
|
|
110
|
-
if (!(e instanceof dntShim.Deno.errors.AddrInUse)) {
|
|
111
|
-
throw e;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
const listener = __addDisposableResource(env_1, dntShim.Deno.listen({ port: 0 }), false);
|
|
116
|
-
return listener.addr.port;
|
|
117
|
-
}
|
|
118
|
-
catch (e_2) {
|
|
119
|
-
env_1.error = e_2;
|
|
120
|
-
env_1.hasError = true;
|
|
121
|
-
}
|
|
122
|
-
finally {
|
|
123
|
-
__disposeResources(env_1);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
|
2
|
-
/**
|
|
3
|
-
* Gets the IPv4 or IPv6 network address of the machine.
|
|
4
|
-
*
|
|
5
|
-
* @experimental **UNSTABLE**: New API, yet to be vetted.
|
|
6
|
-
|
|
7
|
-
*
|
|
8
|
-
* This is inspired by the util of the same name in
|
|
9
|
-
* {@linkcode https://www.npmjs.com/package/serve | npm:serve}.
|
|
10
|
-
*
|
|
11
|
-
* For more advanced use, use {@linkcode Deno.networkInterfaces} directly.
|
|
12
|
-
*
|
|
13
|
-
* @see {@link https://github.com/vercel/serve/blob/1ea55b1b5004f468159b54775e4fb3090fedbb2b/source/utilities/http.ts#L33}
|
|
14
|
-
*
|
|
15
|
-
* @param family The IP protocol version of the interface to get the address of.
|
|
16
|
-
* @returns The IPv4 network address of the machine or `undefined` if not found.
|
|
17
|
-
*
|
|
18
|
-
* @example Get the IPv4 network address (default)
|
|
19
|
-
* ```ts no-assert no-eval
|
|
20
|
-
* import { getNetworkAddress } from "@std/net/get-network-address";
|
|
21
|
-
*
|
|
22
|
-
* const hostname = getNetworkAddress()!;
|
|
23
|
-
*
|
|
24
|
-
* Deno.serve({ port: 0, hostname }, () => new Response("Hello, world!"));
|
|
25
|
-
* ```
|
|
26
|
-
*
|
|
27
|
-
* @example Get the IPv6 network address
|
|
28
|
-
* ```ts no-assert no-eval
|
|
29
|
-
* import { getNetworkAddress } from "@std/net/get-network-address";
|
|
30
|
-
*
|
|
31
|
-
* const hostname = getNetworkAddress("IPv6")!;
|
|
32
|
-
*
|
|
33
|
-
* Deno.serve({ port: 0, hostname }, () => new Response("Hello, world!"));
|
|
34
|
-
* ```
|
|
35
|
-
*/
|
|
36
|
-
import * as dntShim from "../../../../../_dnt.shims.js";
|
|
37
|
-
export function getNetworkAddress(family = "IPv4") {
|
|
38
|
-
return dntShim.Deno.networkInterfaces()
|
|
39
|
-
.find((i) => i.family === family &&
|
|
40
|
-
(family === "IPv4"
|
|
41
|
-
// Cannot lie within 127.0.0.0/8
|
|
42
|
-
? !i.address.startsWith("127")
|
|
43
|
-
// Cannot be loopback or link-local addresses
|
|
44
|
-
: !(i.address === "::1" || i.address === "fe80::1") && i.scopeid === 0))
|
|
45
|
-
?.address;
|
|
46
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
|
2
|
-
/**
|
|
3
|
-
* Network utilities.
|
|
4
|
-
*
|
|
5
|
-
* ```ts no-assert no-eval
|
|
6
|
-
* import { getNetworkAddress, getAvailablePort } from "@std/net";
|
|
7
|
-
*
|
|
8
|
-
* console.log(`My network IP address is ${getNetworkAddress()}`);
|
|
9
|
-
*
|
|
10
|
-
* const command = new Deno.Command(Deno.execPath(), {
|
|
11
|
-
* args: ["test.ts", "--port", getAvailablePort().toString()],
|
|
12
|
-
* });
|
|
13
|
-
*
|
|
14
|
-
* // ...
|
|
15
|
-
* ```
|
|
16
|
-
*
|
|
17
|
-
* @module
|
|
18
|
-
*/
|
|
19
|
-
export * from "./get_available_port.js";
|
|
20
|
-
export * from "./get_network_address.js";
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
export interface GetAvailablePortOptions {
|
|
2
|
-
/**
|
|
3
|
-
* A port to check availability of first. If the port isn't available, fall
|
|
4
|
-
* back to another port.
|
|
5
|
-
*
|
|
6
|
-
* Defaults to port 0, which will let the operating system choose an available
|
|
7
|
-
* port.
|
|
8
|
-
*
|
|
9
|
-
* @default {0}
|
|
10
|
-
*/
|
|
11
|
-
preferredPort?: number;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Returns an available network port.
|
|
15
|
-
*
|
|
16
|
-
* > [!IMPORTANT]
|
|
17
|
-
* > In most cases, this function is not needed. Do not use it for trivial uses
|
|
18
|
-
* > such as when using {@linkcode Deno.serve} or {@linkcode Deno.listen}
|
|
19
|
-
* > directly. Instead, set the `port` option to `0` to automatically use an
|
|
20
|
-
* > available port, then get the assigned port from the function's return
|
|
21
|
-
* > object (see "Recommended Usage" example).
|
|
22
|
-
*
|
|
23
|
-
* @param options Options for getting an available port.
|
|
24
|
-
* @returns An available network port.
|
|
25
|
-
*
|
|
26
|
-
* @example Recommended Usage
|
|
27
|
-
*
|
|
28
|
-
* Bad:
|
|
29
|
-
* ```ts no-eval no-assert
|
|
30
|
-
* import { getAvailablePort } from "@std/net/get-available-port";
|
|
31
|
-
*
|
|
32
|
-
* const port = getAvailablePort();
|
|
33
|
-
* Deno.serve({ port }, () => new Response("Hello, world!"));
|
|
34
|
-
* ```
|
|
35
|
-
*
|
|
36
|
-
* Good:
|
|
37
|
-
* ```ts no-eval no-assert
|
|
38
|
-
* const { port } = Deno.serve({ port: 0 }, () => new Response("Hello, world!")).addr;
|
|
39
|
-
* ```
|
|
40
|
-
*
|
|
41
|
-
* Good:
|
|
42
|
-
* ```ts no-eval no-assert
|
|
43
|
-
* import { getAvailablePort } from "@std/net/get-available-port";
|
|
44
|
-
*
|
|
45
|
-
* const command = new Deno.Command(Deno.execPath(), {
|
|
46
|
-
* args: ["test.ts", "--port", getAvailablePort().toString()],
|
|
47
|
-
* });
|
|
48
|
-
* // ...
|
|
49
|
-
* ```
|
|
50
|
-
*/
|
|
51
|
-
export declare function getAvailablePort(options?: GetAvailablePortOptions): number;
|
|
52
|
-
//# sourceMappingURL=get_available_port.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get_available_port.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/net/1.0.2/get_available_port.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,uBAAuB;IACtC;;;;;;;;OAQG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,CAAC,EAAE,uBAAuB,GAAG,MAAM,CAgB1E"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Gets the IPv4 or IPv6 network address of the machine.
|
|
3
|
-
*
|
|
4
|
-
* @experimental **UNSTABLE**: New API, yet to be vetted.
|
|
5
|
-
|
|
6
|
-
*
|
|
7
|
-
* This is inspired by the util of the same name in
|
|
8
|
-
* {@linkcode https://www.npmjs.com/package/serve | npm:serve}.
|
|
9
|
-
*
|
|
10
|
-
* For more advanced use, use {@linkcode Deno.networkInterfaces} directly.
|
|
11
|
-
*
|
|
12
|
-
* @see {@link https://github.com/vercel/serve/blob/1ea55b1b5004f468159b54775e4fb3090fedbb2b/source/utilities/http.ts#L33}
|
|
13
|
-
*
|
|
14
|
-
* @param family The IP protocol version of the interface to get the address of.
|
|
15
|
-
* @returns The IPv4 network address of the machine or `undefined` if not found.
|
|
16
|
-
*
|
|
17
|
-
* @example Get the IPv4 network address (default)
|
|
18
|
-
* ```ts no-assert no-eval
|
|
19
|
-
* import { getNetworkAddress } from "@std/net/get-network-address";
|
|
20
|
-
*
|
|
21
|
-
* const hostname = getNetworkAddress()!;
|
|
22
|
-
*
|
|
23
|
-
* Deno.serve({ port: 0, hostname }, () => new Response("Hello, world!"));
|
|
24
|
-
* ```
|
|
25
|
-
*
|
|
26
|
-
* @example Get the IPv6 network address
|
|
27
|
-
* ```ts no-assert no-eval
|
|
28
|
-
* import { getNetworkAddress } from "@std/net/get-network-address";
|
|
29
|
-
*
|
|
30
|
-
* const hostname = getNetworkAddress("IPv6")!;
|
|
31
|
-
*
|
|
32
|
-
* Deno.serve({ port: 0, hostname }, () => new Response("Hello, world!"));
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
import * as dntShim from "../../../../../_dnt.shims.js";
|
|
36
|
-
export declare function getNetworkAddress(family?: dntShim.Deno.NetworkInterfaceInfo["family"]): string | undefined;
|
|
37
|
-
//# sourceMappingURL=get_network_address.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get_network_address.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/net/1.0.2/get_network_address.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,OAAO,KAAK,OAAO,MAAM,8BAA8B,CAAC;AAExD,wBAAgB,iBAAiB,CAC/B,MAAM,GAAE,OAAO,CAAC,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAU,GAC3D,MAAM,GAAG,SAAS,CAWpB"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Network utilities.
|
|
3
|
-
*
|
|
4
|
-
* ```ts no-assert no-eval
|
|
5
|
-
* import { getNetworkAddress, getAvailablePort } from "@std/net";
|
|
6
|
-
*
|
|
7
|
-
* console.log(`My network IP address is ${getNetworkAddress()}`);
|
|
8
|
-
*
|
|
9
|
-
* const command = new Deno.Command(Deno.execPath(), {
|
|
10
|
-
* args: ["test.ts", "--port", getAvailablePort().toString()],
|
|
11
|
-
* });
|
|
12
|
-
*
|
|
13
|
-
* // ...
|
|
14
|
-
* ```
|
|
15
|
-
*
|
|
16
|
-
* @module
|
|
17
|
-
*/
|
|
18
|
-
export * from "./get_available_port.js";
|
|
19
|
-
export * from "./get_network_address.js";
|
|
20
|
-
//# sourceMappingURL=mod.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/net/1.0.2/mod.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;GAgBG;AAEH,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC"}
|