Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

chore(mobile): add EAS config and iOS device run script

Richie McIlroy947aaf187468
diff --git a/apps/mobile/eas.json b/apps/mobile/eas.json
new file mode 100644
index 000000000..9d28eb229
--- /dev/null
+++ b/apps/mobile/eas.json
@@ -0,0 +1,30 @@
+{
+ "cli": {
+ "appVersionSource": "remote",
+ "version": ">= 21.0.2"
+ },
+ "build": {
+ "development": {
+ "channel": "development",
+ "developmentClient": true,
+ "distribution": "internal",
+ "environment": "development",
+ "ios": {
+ "simulator": true
+ }
+ },
+ "preview": {
+ "channel": "preview",
+ "distribution": "internal",
+ "environment": "preview"
+ },
+ "production": {
+ "autoIncrement": true,
+ "channel": "production",
+ "environment": "production"
+ }
+ },
+ "submit": {
+ "production": {}
+ }
+}
diff --git a/apps/mobile/scripts/run-ios-device.mjs b/apps/mobile/scripts/run-ios-device.mjs
new file mode 100644
index 000000000..095a61a2a
--- /dev/null
+++ b/apps/mobile/scripts/run-ios-device.mjs
@@ -0,0 +1,55 @@
+import { spawnSync } from "node:child_process";
+import { networkInterfaces } from "node:os";
+
+const isPrivateIpv4 = ({ address, family, internal }) =>
+ family === "IPv4" &&
+ !internal &&
+ (address.startsWith("10.") ||
+ address.startsWith("192.168.") ||
+ /^172\.(1[6-9]|2\d|3[01])\./.test(address));
+
+const findLanAddress = () => {
+ const interfaces = networkInterfaces();
+ for (const name of ["en0", "en1"]) {
+ const address = interfaces[name]?.find(isPrivateIpv4)?.address;
+ if (address) return address;
+ }
+
+ return Object.values(interfaces)
+ .flat()
+ .find((address) => address && isPrivateIpv4(address))?.address;
+};
+
+const lanAddress = process.env.CAP_MOBILE_LAN_IP ?? findLanAddress();
+const localApiPort = process.env.CAP_MOBILE_LOCAL_API_PORT ?? "3000";
+const apiBaseUrl =
+ process.env.EXPO_PUBLIC_CAP_WEB_URL ??
+ (lanAddress ? `http://${lanAddress}:${localApiPort}` : null);
+
+if (!apiBaseUrl) {
+ throw new Error(
+ "Unable to find the Mac LAN address. Set EXPO_PUBLIC_CAP_WEB_URL explicitly.",
+ );
+}
+
+const forwardedArgs = process.argv.slice(2);
+if (forwardedArgs[0] === "--") forwardedArgs.shift();
+const command = ["exec", "expo", "run:ios", "--device", ...forwardedArgs];
+console.log(`Using Cap API: ${apiBaseUrl}`);
+
+if (process.env.CAP_MOBILE_DRY_RUN === "1") {
+ console.log(`pnpm ${command.join(" ")}`);
+ process.exit(0);
+}
+
+const result = spawnSync("pnpm", command, {
+ stdio: "inherit",
+ env: {
+ ...process.env,
+ CAP_MOBILE_DISABLE_ASSOCIATED_DOMAINS: "1",
+ EXPO_PUBLIC_CAP_WEB_URL: apiBaseUrl,
+ },
+});
+
+if (result.error) throw result.error;
+process.exit(result.status ?? 1);