easc 0.0.21 → 0.0.24

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easc",
3
- "version": "0.0.21",
3
+ "version": "0.0.24",
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",
@@ -12,6 +12,14 @@
12
12
  "index.ts",
13
13
  "src"
14
14
  ],
15
+ "scripts": {
16
+ "test": "vitest",
17
+ "test:watch": "vitest --watch",
18
+ "test:ui": "vitest --ui",
19
+ "test:coverage": "vitest --coverage",
20
+ "typecheck": "tsgo --noEmit",
21
+ "prepublishOnly": "pnpm run test"
22
+ },
15
23
  "dependencies": {
16
24
  "@inquirer/prompts": "^7.8.6",
17
25
  "chalk": "5.6.0",
@@ -45,12 +53,5 @@
45
53
  ],
46
54
  "publishConfig": {
47
55
  "access": "public"
48
- },
49
- "scripts": {
50
- "test": "vitest",
51
- "test:watch": "vitest --watch",
52
- "test:ui": "vitest --ui",
53
- "test:coverage": "vitest --coverage",
54
- "typecheck": "tsgo --noEmit"
55
56
  }
56
- }
57
+ }
@@ -1,6 +1,5 @@
1
1
  import fs from "fs";
2
2
  import path from "path";
3
- import chalk from "chalk";
4
3
  import type { CommandModule } from "yargs";
5
4
  import { Logger } from "../utils/logger";
6
5
  import { Platform, PlatformType } from "../enums/platform";
@@ -86,6 +85,13 @@ export const buildRun: CommandModule = {
86
85
  const args = argv as unknown as IArgs;
87
86
  const logger = new Logger();
88
87
 
88
+ if (!args.profile) {
89
+ logger.error(
90
+ "eas.json not found or has no build profiles. Run 'eas build:configure' to create one.",
91
+ );
92
+ process.exit(1);
93
+ }
94
+
89
95
  try {
90
96
  const platform = args.platform;
91
97
  const platformName = platform === Platform.iOS ? "iOS" : "Android";
@@ -163,7 +169,7 @@ export const buildRun: CommandModule = {
163
169
  logger.success("Done! App is running on simulator/emulator.");
164
170
  } catch (error) {
165
171
  const message = error instanceof Error ? error.message : String(error);
166
- console.error(chalk.red(`Build:run failed: ${message}`));
172
+ logger.error(`Build:run failed: ${message}`);
167
173
  process.exit(1);
168
174
  }
169
175
  },
@@ -1,6 +1,5 @@
1
1
  import fs from "fs";
2
2
  import path from "path";
3
- import chalk from "chalk";
4
3
  import type { CommandModule } from "yargs";
5
4
  import { Logger } from "../utils/logger";
6
5
  import { Platform, PlatformType } from "../enums/platform";
@@ -76,6 +75,13 @@ export const build: CommandModule = {
76
75
  const args = argv as unknown as IArgs;
77
76
  const logger = new Logger();
78
77
 
78
+ if (!args.profile) {
79
+ logger.error(
80
+ "eas.json not found or has no build profiles. Run 'eas build:configure' to create one.",
81
+ );
82
+ process.exit(1);
83
+ }
84
+
79
85
  try {
80
86
  const platforms: PlatformType[] =
81
87
  args.platform === "all"
@@ -151,7 +157,7 @@ export const build: CommandModule = {
151
157
  logger.success("Build completed!");
152
158
  } catch (error) {
153
159
  const message = error instanceof Error ? error.message : String(error);
154
- console.error(chalk.red(`Build failed: ${message}`));
160
+ logger.error(`Build failed: ${message}`);
155
161
  process.exit(1);
156
162
  }
157
163
  },
package/src/utils/cli.ts CHANGED
@@ -173,10 +173,20 @@ class InteractiveCLI {
173
173
  if (opt.default !== undefined) continue;
174
174
  if (!opt.choices || !Array.isArray(opt.choices)) continue;
175
175
 
176
- argv[key] = await select({
176
+ const selected = await select({
177
177
  message: `Select ${key.replace(/-/g, " ")}:`,
178
- choices: opt.choices.map((c: string) => ({ name: c, value: c })),
178
+ choices: [
179
+ ...opt.choices.map((c: string) => ({ name: c, value: c })),
180
+ { name: "← Back", value: "__back__" },
181
+ ],
179
182
  });
183
+
184
+ if (selected === "__back__") {
185
+ this.args = [];
186
+ return this.parse();
187
+ }
188
+
189
+ argv[key] = selected;
180
190
  argv[camelKey] = argv[key];
181
191
  }
182
192
  }
package/src/utils/eas.ts CHANGED
@@ -5,28 +5,27 @@ interface EasConfig {
5
5
  build?: Record<string, unknown>;
6
6
  }
7
7
 
8
+ /**
9
+ * Get EAS build profiles from eas.json
10
+ * Returns an empty array if eas.json is not found, invalid, or has no build profiles.
11
+ */
8
12
  export function getEasProfiles(): string[] {
9
13
  const easJsonPath = path.join(process.cwd(), "eas.json");
10
14
 
11
15
  if (!fs.existsSync(easJsonPath)) {
12
- throw new Error("eas.json not found. Run 'eas build:configure' to create one.");
16
+ return [];
13
17
  }
14
18
 
15
19
  let easConfig: EasConfig;
16
20
  try {
17
21
  easConfig = JSON.parse(fs.readFileSync(easJsonPath, "utf-8"));
18
- } catch (error) {
19
- throw new Error(`Failed to parse eas.json: ${error instanceof Error ? error.message : String(error)}`);
22
+ } catch {
23
+ return [];
20
24
  }
21
25
 
22
26
  if (!easConfig.build || typeof easConfig.build !== "object") {
23
- throw new Error("No build profiles found in eas.json");
27
+ return [];
24
28
  }
25
29
 
26
- const profiles = Object.keys(easConfig.build);
27
- if (profiles.length === 0) {
28
- throw new Error("No build profiles found in eas.json");
29
- }
30
-
31
- return profiles;
30
+ return Object.keys(easConfig.build);
32
31
  }