easc 0.0.27 → 0.0.28

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 CHANGED
@@ -13,14 +13,14 @@ easc
13
13
  Or run commands directly:
14
14
 
15
15
  ```bash
16
- easc build --platform ios --profile development
16
+ easc build --platform ios --profile preview
17
17
  easc update --channel production
18
18
  ```
19
19
 
20
20
  Use `--non-interactive` flag for CI environments:
21
21
 
22
22
  ```bash
23
- easc build --platform ios --profile production --non-interactive
23
+ easc submit --platform ios --profile production --non-interactive
24
24
  ```
25
25
 
26
26
  ## Commands
@@ -38,27 +38,27 @@ easc update --skip-build # Use existing export
38
38
 
39
39
  ### build
40
40
 
41
- Build the app locally and optionally submit to app stores.
41
+ Build locally and run on simulator/emulator. Always runs `expo prebuild --clean` before building.
42
42
 
43
43
  ```bash
44
- easc build # Build all platforms locally
45
- easc build --platform ios # iOS only
46
- easc build --platform android # Android only
47
- easc build --profile development # Use dev profile
48
- easc build --auto-submit # Auto-submit to stores
49
- easc build --clear-cache # Clean prebuild
50
- easc build --output ./build.ipa # Custom output path
44
+ easc build --platform ios # Build and run on iOS Simulator
45
+ easc build --platform android # Build and run on Android Emulator
46
+ easc build --platform ios --profile preview # Use specific build profile
47
+ easc build --platform ios --path ./build.tar.gz # Run existing artifact (skip build)
51
48
  ```
52
49
 
53
- ### build:run
50
+ ### submit
54
51
 
55
- Build locally and run on simulator/emulator. Always runs `expo prebuild --clean` before building.
52
+ Build the app locally and optionally submit to app stores.
56
53
 
57
54
  ```bash
58
- easc build:run --platform ios # Build and run on iOS Simulator
59
- easc build:run --platform android # Build and run on Android Emulator
60
- easc build:run --platform ios --profile preview # Use specific build profile
61
- easc build:run --platform ios --path ./build.tar.gz # Run existing artifact (skip build)
55
+ easc submit # Build all platforms locally
56
+ easc submit --platform ios # iOS only
57
+ easc submit --platform android # Android only
58
+ easc submit --profile development # Use dev profile
59
+ easc submit --auto-submit # Auto-submit to stores
60
+ easc submit --clear-cache # Clean prebuild
61
+ easc submit --output ./build.ipa # Custom output path
62
62
  ```
63
63
 
64
64
  ## Development
package/index.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  import { hideBin } from "yargs/helpers";
3
3
  import { cli } from "./src/utils/cli";
4
4
  import { build } from "./src/commands/build";
5
- import { buildRun } from "./src/commands/build-run";
5
+ import { submit } from "./src/commands/submit";
6
6
  import { update } from "./src/commands/update";
7
7
 
8
8
  cli(hideBin(process.argv))
@@ -10,7 +10,7 @@ cli(hideBin(process.argv))
10
10
  .usage("$0 <command> [options]")
11
11
  .command(update)
12
12
  .command(build)
13
- .command(buildRun)
13
+ .command(submit)
14
14
  .demandCommand(1, "")
15
15
  .help()
16
16
  .alias("help", "h")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easc",
3
- "version": "0.0.27",
3
+ "version": "0.0.28",
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",
@@ -17,8 +17,7 @@
17
17
  "test:watch": "vitest --watch",
18
18
  "test:ui": "vitest --ui",
19
19
  "test:coverage": "vitest --coverage",
20
- "typecheck": "tsgo --noEmit",
21
- "prepublishOnly": "pnpm run test"
20
+ "typecheck": "tsgo --noEmit"
22
21
  },
23
22
  "dependencies": {
24
23
  "@inquirer/prompts": "^7.8.6",
@@ -7,15 +7,26 @@ import { runx } from "../utils/runx";
7
7
  import { getEasProfiles } from "../utils/eas";
8
8
 
9
9
  interface IArgs {
10
- platform: PlatformType | "all";
10
+ path?: string;
11
11
  profile: string;
12
- autoSubmit: boolean;
13
- clearCache: boolean;
14
- output?: string;
12
+ platform: PlatformType;
15
13
  nonInteractive: boolean;
16
14
  }
17
15
 
18
- function findBuildArtifact(pattern: string): string | null {
16
+ /**
17
+ * Get the artifact pattern for a platform.
18
+ * These patterns match EAS Build local output:
19
+ * - iOS simulator builds: .tar.gz (contains .app)
20
+ * - Android builds: .apk
21
+ */
22
+ function getArtifactPattern(platform: PlatformType): string {
23
+ return platform === Platform.iOS ? "build-*.tar.gz" : "build-*.apk";
24
+ }
25
+
26
+ /**
27
+ * Find the latest build artifact matching a pattern
28
+ */
29
+ function findLatestArtifact(pattern: string): string | null {
19
30
  const cwd = process.cwd();
20
31
  const files = fs.readdirSync(cwd).filter((f) => {
21
32
  const regex = new RegExp(pattern.replace("*", ".*"));
@@ -33,44 +44,43 @@ function findBuildArtifact(pattern: string): string | null {
33
44
 
34
45
  export const build: CommandModule = {
35
46
  command: "build",
36
- describe: "Build the app locally and submit to the stores",
47
+ describe: "Build locally and run on simulator/emulator",
37
48
  builder: (yargs) =>
38
49
  yargs
39
50
  .option("platform", {
40
51
  alias: "p",
41
52
  type: "string",
42
- choices: [Platform.iOS, Platform.Android, "all"] as const,
53
+ choices: [Platform.iOS, Platform.Android] as const,
43
54
  description: "Target platform",
44
55
  })
45
56
  .option("profile", {
46
57
  alias: "e",
47
58
  type: "string",
48
- choices: getEasProfiles(),
59
+ choices: getEasProfiles("development"),
49
60
  description: "EAS build profile",
50
61
  })
51
- .option("auto-submit", {
52
- alias: "s",
53
- type: "boolean",
54
- description: "Submit to app stores after building",
55
- default: true,
56
- })
57
- .option("clear-cache", {
58
- type: "boolean",
59
- description: "Clear cache before building",
60
- default: false,
61
- })
62
- .option("output", {
62
+ .option("path", {
63
63
  type: "string",
64
- description: "Output path for the build artifact",
64
+ description:
65
+ "Path to the simulator/emulator build archive or app (skips build)",
65
66
  })
66
67
  .option("non-interactive", {
67
68
  type: "boolean",
68
69
  description: "Never prompt for user input",
69
70
  default: false,
70
71
  })
71
- .example("$0 build", "Build all platforms locally")
72
- .example("$0 build -p ios -e development", "Build iOS with dev profile")
73
- .example("$0 build -s", "Build and submit to stores"),
72
+ .example(
73
+ "$0 build -p ios -e preview",
74
+ "Build with preview profile and run on iOS Simulator",
75
+ )
76
+ .example(
77
+ "$0 build -p android",
78
+ "Build with default profile and run on Android Emulator",
79
+ )
80
+ .example(
81
+ "$0 build -p ios --path ./build.tar.gz",
82
+ "Run existing build artifact",
83
+ ),
74
84
  async handler(argv) {
75
85
  const args = argv as unknown as IArgs;
76
86
  const logger = new Logger();
@@ -83,26 +93,36 @@ export const build: CommandModule = {
83
93
  }
84
94
 
85
95
  try {
86
- const platforms: PlatformType[] =
87
- args.platform === "all"
88
- ? [Platform.iOS, Platform.Android]
89
- : [args.platform];
90
-
91
- for (const platform of platforms) {
92
- const platformName = platform === Platform.iOS ? "iOS" : "Android";
93
-
94
- logger.section(`${platformName} Build`);
95
-
96
- if (args.clearCache) {
97
- logger.info(`Running prebuild for ${platformName}...`);
98
- runx(`expo prebuild --platform ${platform} --clean`, {
99
- cwd: process.cwd(),
100
- stdio: "inherit",
101
- env: { ...process.env, CI: "1" },
102
- });
103
- logger.success("Prebuild completed");
96
+ const platform = args.platform;
97
+ const platformName = platform === Platform.iOS ? "iOS" : "Android";
98
+ const artifactPattern = getArtifactPattern(platform);
99
+
100
+ logger.section(`${platformName} Build & Run`);
101
+
102
+ let artifactPath: string | null = null;
103
+ let didBuild = false;
104
+
105
+ if (args.path) {
106
+ artifactPath = args.path;
107
+ if (!fs.existsSync(artifactPath)) {
108
+ logger.error(`Artifact not found: ${artifactPath}`);
109
+ process.exit(1);
104
110
  }
111
+ logger.info(`Using provided artifact: ${artifactPath}`);
112
+ }
113
+
114
+ if (!artifactPath) {
115
+ didBuild = true;
116
+
117
+ logger.info(`Running prebuild for ${platformName}...`);
118
+
119
+ runx(`expo prebuild --platform ${platform} --clean`, {
120
+ cwd: process.cwd(),
121
+ stdio: "inherit",
122
+ env: { ...process.env, CI: "1" },
123
+ });
105
124
 
125
+ logger.success("Prebuild completed");
106
126
  logger.info(`Building ${platformName} locally...`);
107
127
 
108
128
  const buildFlags = [
@@ -110,8 +130,6 @@ export const build: CommandModule = {
110
130
  `--profile ${args.profile}`,
111
131
  "--local",
112
132
  "--non-interactive",
113
- args.clearCache ? "--clear-cache" : "",
114
- args.output ? `--output ${args.output}` : "",
115
133
  ]
116
134
  .filter(Boolean)
117
135
  .join(" ");
@@ -123,38 +141,32 @@ export const build: CommandModule = {
123
141
 
124
142
  logger.success(`${platformName} build completed`);
125
143
 
126
- if (args.autoSubmit) {
127
- logger.info(`Submitting ${platformName} build...`);
144
+ artifactPath = findLatestArtifact(artifactPattern);
128
145
 
129
- const artifactPath =
130
- platform === Platform.iOS
131
- ? findBuildArtifact("build-*.ipa")
132
- : findBuildArtifact("build-*.aab") ||
133
- findBuildArtifact("build-*.apk");
146
+ if (!artifactPath) {
147
+ logger.error(`No build artifact found after build`);
148
+ process.exit(1);
149
+ }
134
150
 
135
- if (!artifactPath) {
136
- logger.error(`No ${platformName} build artifact found`);
137
- process.exit(1);
138
- }
151
+ logger.info(`Build artifact: ${artifactPath}`);
152
+ }
139
153
 
140
- logger.info(`Found artifact: ${artifactPath}`);
154
+ logger.info(`Installing on ${platformName} simulator/emulator...`);
141
155
 
142
- runx(
143
- `eas submit --platform ${platform} --path "${artifactPath}" --non-interactive`,
144
- { cwd: process.cwd(), stdio: "inherit" },
145
- );
156
+ runx(`eas build:run --path "${artifactPath}" --platform ${platform}`, {
157
+ cwd: process.cwd(),
158
+ stdio: "inherit",
159
+ });
146
160
 
147
- logger.success(`${platformName} submitted`);
161
+ logger.success(`${platformName} app installed and running`);
148
162
 
149
- if (fs.existsSync(artifactPath)) {
150
- fs.unlinkSync(artifactPath);
151
- logger.info(`Cleaned up: ${artifactPath}`);
152
- }
153
- }
163
+ if (didBuild && artifactPath && fs.existsSync(artifactPath)) {
164
+ fs.unlinkSync(artifactPath);
165
+ logger.info(`Cleaned up: ${artifactPath}`);
154
166
  }
155
167
 
156
168
  logger.section("");
157
- logger.success("Build completed!");
169
+ logger.success("Done! App is running on simulator/emulator.");
158
170
  } catch (error) {
159
171
  const message = error instanceof Error ? error.message : String(error);
160
172
  logger.error(`Build failed: ${message}`);
@@ -0,0 +1,164 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import type { CommandModule } from "yargs";
4
+ import { Logger } from "../utils/logger";
5
+ import { Platform, PlatformType } from "../enums/platform";
6
+ import { runx } from "../utils/runx";
7
+ import { getEasProfiles } from "../utils/eas";
8
+
9
+ interface IArgs {
10
+ platform: PlatformType | "all";
11
+ profile: string;
12
+ autoSubmit: boolean;
13
+ clearCache: boolean;
14
+ output?: string;
15
+ nonInteractive: boolean;
16
+ }
17
+
18
+ function findBuildArtifact(pattern: string): string | null {
19
+ const cwd = process.cwd();
20
+ const files = fs.readdirSync(cwd).filter((f) => {
21
+ const regex = new RegExp(pattern.replace("*", ".*"));
22
+ return regex.test(f);
23
+ });
24
+
25
+ if (files.length === 0) return null;
26
+
27
+ return (
28
+ files
29
+ .map((f) => ({ name: f, mtime: fs.statSync(path.join(cwd, f)).mtime }))
30
+ .sort((a, b) => b.mtime.getTime() - a.mtime.getTime())[0]?.name ?? null
31
+ );
32
+ }
33
+
34
+ export const submit: CommandModule = {
35
+ command: "submit",
36
+ describe: "Build the app locally and submit to the stores",
37
+ builder: (yargs) =>
38
+ yargs
39
+ .option("platform", {
40
+ alias: "p",
41
+ type: "string",
42
+ choices: [Platform.iOS, Platform.Android, "all"] as const,
43
+ description: "Target platform",
44
+ })
45
+ .option("profile", {
46
+ alias: "e",
47
+ type: "string",
48
+ choices: getEasProfiles("production"),
49
+ description: "EAS build profile",
50
+ })
51
+ .option("auto-submit", {
52
+ alias: "s",
53
+ type: "boolean",
54
+ description: "Submit to app stores after building",
55
+ default: true,
56
+ })
57
+ .option("clear-cache", {
58
+ type: "boolean",
59
+ description: "Clear cache before building",
60
+ default: false,
61
+ })
62
+ .option("output", {
63
+ type: "string",
64
+ description: "Output path for the build artifact",
65
+ })
66
+ .option("non-interactive", {
67
+ type: "boolean",
68
+ description: "Never prompt for user input",
69
+ default: false,
70
+ })
71
+ .example("$0 submit", "Build all platforms locally")
72
+ .example("$0 submit -p ios -e development", "Build iOS with dev profile")
73
+ .example("$0 submit -s", "Build and submit to stores"),
74
+ async handler(argv) {
75
+ const args = argv as unknown as IArgs;
76
+ const logger = new Logger();
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
+
85
+ try {
86
+ const platforms: PlatformType[] =
87
+ args.platform === "all"
88
+ ? [Platform.iOS, Platform.Android]
89
+ : [args.platform];
90
+
91
+ for (const platform of platforms) {
92
+ const platformName = platform === Platform.iOS ? "iOS" : "Android";
93
+
94
+ logger.section(`${platformName} Build`);
95
+
96
+ if (args.clearCache) {
97
+ logger.info(`Running prebuild for ${platformName}...`);
98
+ runx(`expo prebuild --platform ${platform} --clean`, {
99
+ cwd: process.cwd(),
100
+ stdio: "inherit",
101
+ env: { ...process.env, CI: "1" },
102
+ });
103
+ logger.success("Prebuild completed");
104
+ }
105
+
106
+ logger.info(`Building ${platformName} locally...`);
107
+
108
+ const buildFlags = [
109
+ `--platform ${platform}`,
110
+ `--profile ${args.profile}`,
111
+ "--local",
112
+ "--non-interactive",
113
+ args.clearCache ? "--clear-cache" : "",
114
+ args.output ? `--output ${args.output}` : "",
115
+ ]
116
+ .filter(Boolean)
117
+ .join(" ");
118
+
119
+ runx(`eas build ${buildFlags}`, {
120
+ cwd: process.cwd(),
121
+ stdio: "inherit",
122
+ });
123
+
124
+ logger.success(`${platformName} build completed`);
125
+
126
+ if (args.autoSubmit) {
127
+ logger.info(`Submitting ${platformName} build...`);
128
+
129
+ const artifactPath =
130
+ platform === Platform.iOS
131
+ ? findBuildArtifact("build-*.ipa")
132
+ : findBuildArtifact("build-*.aab") ||
133
+ findBuildArtifact("build-*.apk");
134
+
135
+ if (!artifactPath) {
136
+ logger.error(`No ${platformName} build artifact found`);
137
+ process.exit(1);
138
+ }
139
+
140
+ logger.info(`Found artifact: ${artifactPath}`);
141
+
142
+ runx(
143
+ `eas submit --platform ${platform} --path "${artifactPath}" --non-interactive`,
144
+ { cwd: process.cwd(), stdio: "inherit" },
145
+ );
146
+
147
+ logger.success(`${platformName} submitted`);
148
+
149
+ if (fs.existsSync(artifactPath)) {
150
+ fs.unlinkSync(artifactPath);
151
+ logger.info(`Cleaned up: ${artifactPath}`);
152
+ }
153
+ }
154
+ }
155
+
156
+ logger.section("");
157
+ logger.success("Submit completed!");
158
+ } catch (error) {
159
+ const message = error instanceof Error ? error.message : String(error);
160
+ logger.error(`Submit failed: ${message}`);
161
+ process.exit(1);
162
+ }
163
+ },
164
+ };
package/src/utils/eas.ts CHANGED
@@ -8,8 +8,9 @@ interface EasConfig {
8
8
  /**
9
9
  * Get EAS build profiles from eas.json
10
10
  * Returns an empty array if eas.json is not found, invalid, or has no build profiles.
11
+ * If `prioritize` is provided and exists in the profiles, it will be moved to the front.
11
12
  */
12
- export function getEasProfiles(): string[] {
13
+ export function getEasProfiles(prioritize?: string): string[] {
13
14
  const easJsonPath = path.join(process.cwd(), "eas.json");
14
15
 
15
16
  if (!fs.existsSync(easJsonPath)) {
@@ -27,5 +28,11 @@ export function getEasProfiles(): string[] {
27
28
  return [];
28
29
  }
29
30
 
30
- return Object.keys(easConfig.build);
31
+ const profiles = Object.keys(easConfig.build);
32
+
33
+ if (prioritize && profiles.includes(prioritize)) {
34
+ return [prioritize, ...profiles.filter((p) => p !== prioritize)];
35
+ }
36
+
37
+ return profiles;
31
38
  }
@@ -1,176 +0,0 @@
1
- import fs from "fs";
2
- import path from "path";
3
- import type { CommandModule } from "yargs";
4
- import { Logger } from "../utils/logger";
5
- import { Platform, PlatformType } from "../enums/platform";
6
- import { runx } from "../utils/runx";
7
- import { getEasProfiles } from "../utils/eas";
8
-
9
- interface IArgs {
10
- path?: string;
11
- profile: string;
12
- platform: PlatformType;
13
- nonInteractive: boolean;
14
- }
15
-
16
- /**
17
- * Get the artifact pattern for a platform.
18
- * These patterns match EAS Build local output:
19
- * - iOS simulator builds: .tar.gz (contains .app)
20
- * - Android builds: .apk
21
- */
22
- function getArtifactPattern(platform: PlatformType): string {
23
- return platform === Platform.iOS ? "build-*.tar.gz" : "build-*.apk";
24
- }
25
-
26
- /**
27
- * Find the latest build artifact matching a pattern
28
- */
29
- function findLatestArtifact(pattern: string): string | null {
30
- const cwd = process.cwd();
31
- const files = fs.readdirSync(cwd).filter((f) => {
32
- const regex = new RegExp(pattern.replace("*", ".*"));
33
- return regex.test(f);
34
- });
35
-
36
- if (files.length === 0) return null;
37
-
38
- return (
39
- files
40
- .map((f) => ({ name: f, mtime: fs.statSync(path.join(cwd, f)).mtime }))
41
- .sort((a, b) => b.mtime.getTime() - a.mtime.getTime())[0]?.name ?? null
42
- );
43
- }
44
-
45
- export const buildRun: CommandModule = {
46
- command: "build:run",
47
- describe: "Build locally and run on simulator/emulator",
48
- builder: (yargs) =>
49
- yargs
50
- .option("platform", {
51
- alias: "p",
52
- type: "string",
53
- choices: [Platform.iOS, Platform.Android] as const,
54
- description: "Target platform",
55
- })
56
- .option("profile", {
57
- alias: "e",
58
- type: "string",
59
- choices: getEasProfiles(),
60
- description: "EAS build profile",
61
- })
62
- .option("path", {
63
- type: "string",
64
- description:
65
- "Path to the simulator/emulator build archive or app (skips build)",
66
- })
67
- .option("non-interactive", {
68
- type: "boolean",
69
- description: "Never prompt for user input",
70
- default: false,
71
- })
72
- .example(
73
- "$0 build:run -p ios -e preview",
74
- "Build with preview profile and run on iOS Simulator",
75
- )
76
- .example(
77
- "$0 build:run -p android",
78
- "Build with default profile and run on Android Emulator",
79
- )
80
- .example(
81
- "$0 build:run -p ios --path ./build.tar.gz",
82
- "Run existing build artifact",
83
- ),
84
- async handler(argv) {
85
- const args = argv as unknown as IArgs;
86
- const logger = new Logger();
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
-
95
- try {
96
- const platform = args.platform;
97
- const platformName = platform === Platform.iOS ? "iOS" : "Android";
98
- const artifactPattern = getArtifactPattern(platform);
99
-
100
- logger.section(`${platformName} Build & Run`);
101
-
102
- let artifactPath: string | null = null;
103
- let didBuild = false;
104
-
105
- if (args.path) {
106
- artifactPath = args.path;
107
- if (!fs.existsSync(artifactPath)) {
108
- logger.error(`Artifact not found: ${artifactPath}`);
109
- process.exit(1);
110
- }
111
- logger.info(`Using provided artifact: ${artifactPath}`);
112
- }
113
-
114
- if (!artifactPath) {
115
- didBuild = true;
116
-
117
- logger.info(`Running prebuild for ${platformName}...`);
118
-
119
- runx(`expo prebuild --platform ${platform} --clean`, {
120
- cwd: process.cwd(),
121
- stdio: "inherit",
122
- env: { ...process.env, CI: "1" },
123
- });
124
-
125
- logger.success("Prebuild completed");
126
- logger.info(`Building ${platformName} locally...`);
127
-
128
- const buildFlags = [
129
- `--platform ${platform}`,
130
- `--profile ${args.profile}`,
131
- "--local",
132
- "--non-interactive",
133
- ]
134
- .filter(Boolean)
135
- .join(" ");
136
-
137
- runx(`eas build ${buildFlags}`, {
138
- cwd: process.cwd(),
139
- stdio: "inherit",
140
- });
141
-
142
- logger.success(`${platformName} build completed`);
143
-
144
- artifactPath = findLatestArtifact(artifactPattern);
145
-
146
- if (!artifactPath) {
147
- logger.error(`No build artifact found after build`);
148
- process.exit(1);
149
- }
150
-
151
- logger.info(`Build artifact: ${artifactPath}`);
152
- }
153
-
154
- logger.info(`Installing on ${platformName} simulator/emulator...`);
155
-
156
- runx(`eas build:run --path "${artifactPath}" --platform ${platform}`, {
157
- cwd: process.cwd(),
158
- stdio: "inherit",
159
- });
160
-
161
- logger.success(`${platformName} app installed and running`);
162
-
163
- if (didBuild && artifactPath && fs.existsSync(artifactPath)) {
164
- fs.unlinkSync(artifactPath);
165
- logger.info(`Cleaned up: ${artifactPath}`);
166
- }
167
-
168
- logger.section("");
169
- logger.success("Done! App is running on simulator/emulator.");
170
- } catch (error) {
171
- const message = error instanceof Error ? error.message : String(error);
172
- logger.error(`Build:run failed: ${message}`);
173
- process.exit(1);
174
- }
175
- },
176
- };