utilitas 2001.1.115 → 2001.1.117
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/README.md +1 -0
- package/dist/utilitas.lite.mjs +1 -1
- package/dist/utilitas.lite.mjs.map +1 -1
- package/lib/manifest.mjs +1 -1
- package/lib/network.mjs +10 -1
- package/lib/shell.mjs +1 -1
- package/package.json +1 -1
package/lib/manifest.mjs
CHANGED
package/lib/network.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { assertExist } from './shell.mjs';
|
|
1
|
+
import { assertExist, exec } from './shell.mjs';
|
|
2
2
|
import { ensureArray, log as _log, need, throwError } from './utilitas.mjs';
|
|
3
3
|
import { getCurrentIp } from './web.mjs';
|
|
4
4
|
|
|
@@ -91,8 +91,17 @@ const getCurrentPosition = async () => {
|
|
|
91
91
|
return Object.assign(loc, { ip });
|
|
92
92
|
};
|
|
93
93
|
|
|
94
|
+
const cfTunnel = async (token, options = {}) => {
|
|
95
|
+
const bin = options?.bin || 'cloudflared';
|
|
96
|
+
await assertExist(bin);
|
|
97
|
+
assert(token, 'Token is required.', 401);
|
|
98
|
+
const cmd = [bin, 'tunnel', 'run', '--token', token];
|
|
99
|
+
return await exec(cmd.join(' '), { acceptError: true, ...options || {} });
|
|
100
|
+
};
|
|
101
|
+
|
|
94
102
|
export {
|
|
95
103
|
_NEED,
|
|
104
|
+
cfTunnel,
|
|
96
105
|
getCurrentPosition,
|
|
97
106
|
httping,
|
|
98
107
|
isLocalhost,
|
package/lib/shell.mjs
CHANGED
|
@@ -13,7 +13,7 @@ const exec = async (command, options = {}) => {
|
|
|
13
13
|
const child = (spawn || vF)(command, { ...options || {}, shell: true });
|
|
14
14
|
const buf = { stdout: { lines: [], p: '' }, stderr: { lines: [], p: '' } };
|
|
15
15
|
const collect = (k, d) => {
|
|
16
|
-
if (options?.stream) { options.stream(d); }
|
|
16
|
+
if (options?.stream) { options.stream(options?.raw ? d : d.toString().trim()); }
|
|
17
17
|
const p = (buf[k].p + d).split(/\r?\n/);
|
|
18
18
|
buf[k].p = p.pop();
|
|
19
19
|
buf[k].lines = buf[k].lines.concat(p);
|