easc 0.0.24 → 0.0.25

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/utils/cli.ts +19 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easc",
3
- "version": "0.0.24",
3
+ "version": "0.0.25",
4
4
  "description": "Expo App Services for Cloudflare - Deploy tool for Expo OTA updates to Cloudflare Workers",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/utils/cli.ts CHANGED
@@ -2,6 +2,14 @@ import yargs, { type Argv, type CommandModule, type Options } from "yargs";
2
2
  import { select } from "@inquirer/prompts";
3
3
  import chalk from "chalk";
4
4
 
5
+ // Custom error to signal going back to menu
6
+ class BackToMenuError extends Error {
7
+ constructor() {
8
+ super("Back to menu");
9
+ this.name = "BackToMenuError";
10
+ }
11
+ }
12
+
5
13
  interface CommandInfo {
6
14
  command: string;
7
15
  describe: string;
@@ -137,8 +145,16 @@ class InteractiveCLI {
137
145
  return y;
138
146
  },
139
147
  handler: async (argv: any) => {
140
- await this._promptForMissingArgs(argv, cmd.options);
141
- return cmd.handler(argv);
148
+ try {
149
+ await this._promptForMissingArgs(argv, cmd.options);
150
+ return cmd.handler(argv);
151
+ } catch (error) {
152
+ if (error instanceof BackToMenuError) {
153
+ this.args = [];
154
+ return this.parse();
155
+ }
156
+ throw error;
157
+ }
142
158
  },
143
159
  });
144
160
  }
@@ -182,8 +198,7 @@ class InteractiveCLI {
182
198
  });
183
199
 
184
200
  if (selected === "__back__") {
185
- this.args = [];
186
- return this.parse();
201
+ throw new BackToMenuError();
187
202
  }
188
203
 
189
204
  argv[key] = selected;