@swell/cli 2.9.10 → 2.9.12

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.
@@ -1,6 +1,5 @@
1
1
  import { confirm } from '@inquirer/prompts';
2
- import { Args, Flags } from '@oclif/core';
3
- import { CLIError } from '@oclif/errors';
2
+ import { Args, Errors, Flags } from '@oclif/core';
4
3
  import * as fs from 'node:fs/promises';
5
4
  import ora from 'ora';
6
5
  import * as semver from 'semver';
@@ -15,7 +14,7 @@ export default class AppRelease extends PushAppCommand {
15
14
  if (parsedInput) {
16
15
  return parsedInput;
17
16
  }
18
- throw new CLIError(`Invalid version: ${input}`);
17
+ throw new Errors.CLIError(`Invalid version: ${input}`);
19
18
  },
20
19
  }),
21
20
  };
@@ -1,7 +1,6 @@
1
1
  import { confirm, input } from '@inquirer/prompts';
2
2
  import git from '@npmcli/git';
3
- import { Args, Flags } from '@oclif/core';
4
- import { CLIError } from '@oclif/errors';
3
+ import { Args, Errors, Flags } from '@oclif/core';
5
4
  import ora from 'ora';
6
5
  import * as semver from 'semver';
7
6
  import style from '../../lib/style.js';
@@ -30,7 +29,7 @@ export default class AppVersion extends PushAppCommand {
30
29
  if (parsedInput) {
31
30
  return parsedInput;
32
31
  }
33
- throw new CLIError(`Invalid version: ${input}`);
32
+ throw new Errors.CLIError(`Invalid version: ${input}`);
34
33
  },
35
34
  }),
36
35
  };
@@ -1,5 +1,4 @@
1
- import { Args } from '@oclif/core';
2
- import { CLIError } from '@oclif/errors';
1
+ import { Args, Errors } from '@oclif/core';
3
2
  import config from '../lib/config.js';
4
3
  import { selectLoggedInStoreId } from '../lib/stores.js';
5
4
  import style from '../lib/style.js';
@@ -35,7 +34,7 @@ define the store that all other commands will apply to by default.
35
34
  this.log(`Current store is now ${style.storeId(config.getDefaultStore())}.`);
36
35
  }
37
36
  else {
38
- throw new CLIError('Could not switch stores.');
37
+ throw new Errors.CLIError('Could not switch stores.');
39
38
  }
40
39
  }
41
40
  }
@@ -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
@@ -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
  });
@@ -38,7 +38,7 @@ export declare function selectStoreId({ authorizations, currentStoreId, force, }
38
38
  *
39
39
  * @param message Store selection message
40
40
  * @returns The store ID to switch to
41
- * @throws CLIError - If there are no stores to switch to
41
+ * @throws Errors.CLIError - If there are no stores to switch to
42
42
  */
43
43
  export declare function selectLoggedInStoreId(message?: string): Promise<string>;
44
44
  /**
@@ -46,7 +46,7 @@ export declare function selectLoggedInStoreId(message?: string): Promise<string>
46
46
  *
47
47
  * @param message Environment selection message
48
48
  * @returns Environment to switch to
49
- * @throws CLIError - If there are no stores to switch to
49
+ * @throws Errors.CLIError - If there are no stores to switch to
50
50
  */
51
51
  export declare function selectEnvironmentId(message?: string): Promise<string>;
52
52
  /**
@@ -1,5 +1,5 @@
1
1
  import { Separator, confirm, select } from '@inquirer/prompts';
2
- import { CLIError } from '@oclif/errors';
2
+ import { Errors } from '@oclif/core';
3
3
  import config from './config.js';
4
4
  import style from './style.js';
5
5
  /**
@@ -18,7 +18,7 @@ import style from './style.js';
18
18
  */
19
19
  export function showStores(stores, currentStoreId) {
20
20
  if (stores.length === 0) {
21
- throw new CLIError('You are not logged in to any store.');
21
+ throw new Errors.CLIError('You are not logged in to any store.');
22
22
  }
23
23
  function currentStoreLabel(store) {
24
24
  if (stores.length === 1 || store.storeId !== currentStoreId) {
@@ -103,13 +103,13 @@ export async function selectStoreId({ authorizations, currentStoreId, force = fa
103
103
  *
104
104
  * @param message Store selection message
105
105
  * @returns The store ID to switch to
106
- * @throws CLIError - If there are no stores to switch to
106
+ * @throws Errors.CLIError - If there are no stores to switch to
107
107
  */
108
108
  export async function selectLoggedInStoreId(message) {
109
109
  const currentStoreId = config.getDefaultStore();
110
110
  const loggedInStores = config.get('stores') || [];
111
111
  if (loggedInStores.length === 0) {
112
- throw new CLIError(`You are not logged in. Run ${style.command('swell login')} to continue.`);
112
+ throw new Errors.CLIError(`You are not logged in. Run ${style.command('swell login')} to continue.`);
113
113
  }
114
114
  const selectStoreChoices = loggedInStores.map((store) => ({
115
115
  name: `${store.name} (${store.storeId})` +
@@ -134,7 +134,7 @@ export async function selectLoggedInStoreId(message) {
134
134
  *
135
135
  * @param message Environment selection message
136
136
  * @returns Environment to switch to
137
- * @throws CLIError - If there are no stores to switch to
137
+ * @throws Errors.CLIError - If there are no stores to switch to
138
138
  */
139
139
  export async function selectEnvironmentId(message) {
140
140
  return select({
@@ -3594,5 +3594,5 @@
3594
3594
  ]
3595
3595
  }
3596
3596
  },
3597
- "version": "2.9.10"
3597
+ "version": "2.9.12"
3598
3598
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swell/cli",
3
- "version": "2.9.10",
3
+ "version": "2.9.12",
4
4
  "type": "module",
5
5
  "description": "Swell's command line interface/utility",
6
6
  "keywords": [
@@ -29,9 +29,7 @@
29
29
  "@inquirer/prompts": "3.2.0",
30
30
  "@npmcli/git": "5.0.3",
31
31
  "@oclif/core": "3.7.1",
32
- "@oclif/errors": "1.3.6",
33
32
  "@oclif/plugin-help": "6.0.4",
34
- "@oclif/plugin-plugins": "3.9.4",
35
33
  "ajv": "8.20.0",
36
34
  "ajv-errors": "3.0.0",
37
35
  "ajv-formats": "3.0.1",
@@ -49,18 +47,17 @@
49
47
  "inflection": "3.0.0",
50
48
  "istextorbinary": "9.5.0",
51
49
  "localtunnel": "2.0.2",
52
- "lodash": "4.17.21",
50
+ "lodash": "4.18.1",
53
51
  "mime-detect": "1.2.0",
54
52
  "node-fetch": "3.3.2",
55
- "oclif": "4.0.3",
56
53
  "open": "9.1.0",
57
54
  "ora": "7.0.1",
58
55
  "parse-json": "8.3.0",
59
- "qs": "6.12.3",
56
+ "qs": "6.15.3",
60
57
  "semver": "7.5.4",
61
58
  "table": "6.8.1",
62
59
  "typescript": "5.2.2",
63
- "ws": "8.18.1"
60
+ "ws": "8.21.3"
64
61
  },
65
62
  "devDependencies": {
66
63
  "@inquirer/testing": "2.1.8",