@swell/cli 2.9.10 → 2.9.11
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/dist/lib/proxy.d.ts +8 -0
- package/dist/lib/proxy.js +15 -0
- package/dist/lib/sessions.js +3 -1
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
package/dist/lib/proxy.d.ts
CHANGED
|
@@ -3,4 +3,12 @@ export interface ProxyContext {
|
|
|
3
3
|
storeId?: string;
|
|
4
4
|
storefrontId?: string;
|
|
5
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* Stop the active tunnel (if any) so the process can exit on its own.
|
|
8
|
+
* The 'exit' handler below never fires while the tunnel's child process is
|
|
9
|
+
* keeping the event loop alive, so callers must stop it explicitly.
|
|
10
|
+
*
|
|
11
|
+
* @returns void
|
|
12
|
+
*/
|
|
13
|
+
export declare function stopProxy(): void;
|
|
6
14
|
export declare function getProxyUrl(port: number, context?: ProxyContext): Promise<string>;
|
package/dist/lib/proxy.js
CHANGED
|
@@ -4,7 +4,21 @@ import * as fs from 'node:fs/promises';
|
|
|
4
4
|
import ora from 'ora';
|
|
5
5
|
import { LOCAL_PROXY_PROVIDER } from './constants.js';
|
|
6
6
|
let activeTunnel = null;
|
|
7
|
+
let activeLocaltunnel = null;
|
|
7
8
|
let cleanupRegistered = false;
|
|
9
|
+
/**
|
|
10
|
+
* Stop the active tunnel (if any) so the process can exit on its own.
|
|
11
|
+
* The 'exit' handler below never fires while the tunnel's child process is
|
|
12
|
+
* keeping the event loop alive, so callers must stop it explicitly.
|
|
13
|
+
*
|
|
14
|
+
* @returns void
|
|
15
|
+
*/
|
|
16
|
+
export function stopProxy() {
|
|
17
|
+
activeTunnel?.stop();
|
|
18
|
+
activeTunnel = null;
|
|
19
|
+
activeLocaltunnel?.close();
|
|
20
|
+
activeLocaltunnel = null;
|
|
21
|
+
}
|
|
8
22
|
async function startCloudflaredTunnel(port) {
|
|
9
23
|
// Stop existing tunnel if called again
|
|
10
24
|
if (activeTunnel) {
|
|
@@ -72,6 +86,7 @@ export async function getProxyUrl(port, context) {
|
|
|
72
86
|
}
|
|
73
87
|
case 'localtunnel': {
|
|
74
88
|
const tunnel = await localtunnel({ port });
|
|
89
|
+
activeLocaltunnel = tunnel;
|
|
75
90
|
return tunnel.url;
|
|
76
91
|
}
|
|
77
92
|
// eslint-disable-next-line unicorn/no-useless-switch-case
|
package/dist/lib/sessions.js
CHANGED
|
@@ -2,7 +2,7 @@ import { ux } from '@oclif/core';
|
|
|
2
2
|
import * as http from 'node:http';
|
|
3
3
|
import open from 'open';
|
|
4
4
|
import { getLoginHost } from './constants.js';
|
|
5
|
-
import { getProxyUrl } from './proxy.js';
|
|
5
|
+
import { getProxyUrl, stopProxy } from './proxy.js';
|
|
6
6
|
import style from './style.js';
|
|
7
7
|
/**
|
|
8
8
|
* Get the session id for the passed in store. If the session is not found,
|
|
@@ -100,6 +100,8 @@ function serverForLogin({ onPost, onStart, storeId, }) {
|
|
|
100
100
|
});
|
|
101
101
|
const closeInterval = setInterval(() => {
|
|
102
102
|
if (postHandled) {
|
|
103
|
+
// stop the tunnel, otherwise its child process keeps the CLI alive
|
|
104
|
+
stopProxy();
|
|
103
105
|
server.close(() => {
|
|
104
106
|
clearInterval(closeInterval);
|
|
105
107
|
});
|
package/oclif.manifest.json
CHANGED