Skip to content

Commit

Permalink
[eas-shared] Add support for installing iOS .app files from custom ta…
Browse files Browse the repository at this point in the history
…rballs (#193)

* [eas-shared] Add support for installing iOS .app files from custom tarballs

* Add changelog entry
  • Loading branch information
gabrieldonadel committed Mar 14, 2024
1 parent d72021c commit c6b6ffa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
### 🐛 Bug fixes

- Fix extra avd info being displayed as a bootable android emulator. ([#190](https://github.com/expo/orbit/pull/190) by [@gabrieldonadel](https://github.com/gabrieldonadel))
- Fix installing iOS apps from tarballs that don't contain an `.app` or `.ipa` file. ([#193](https://github.com/expo/orbit/pull/193) by [@gabrieldonadel](https://github.com/gabrieldonadel))

### 💡 Others

Expand Down
18 changes: 13 additions & 5 deletions packages/eas-shared/src/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export async function downloadAndMaybeExtractAppAsync(url: string): Promise<stri
const outputDir = path.join(_downloadsCacheDirectory(), `${name}`);
if (await fs.pathExists(outputDir)) {
try {
const appPath = await getAppPathAsync(outputDir, '(apk|app|ipa)');
const appPath = await getAppPathAsync(outputDir);
return appPath;
} catch (error) {
if (error instanceof InternalError) {
Expand Down Expand Up @@ -164,7 +164,7 @@ export async function downloadAndMaybeExtractAppAsync(url: string): Promise<stri
);
await tarExtractAsync(tmpArchivePath, outputDir);

const appPath = await getAppPathAsync(outputDir, '(apk|app|ipa)');
const appPath = await getAppPathAsync(outputDir);

return appPath;
}
Expand All @@ -176,16 +176,24 @@ export async function extractAppFromLocalArchiveAsync(appArchivePath: string): P

await tarExtractAsync(appArchivePath, outputDir);

return await getAppPathAsync(outputDir, '(apk|app|ipa)');
return await getAppPathAsync(outputDir);
}

async function getAppPathAsync(outputDir: string, applicationExtension: string): Promise<string> {
const appFilePaths = await glob(`./**/*.${applicationExtension}`, {
async function getAppPathAsync(outputDir: string): Promise<string> {
const applicationExtensionGlob = '(apk|app|ipa)';
const appFilePaths = await glob(`./**/*.${applicationExtensionGlob}`, {
cwd: outputDir,
onlyFiles: false,
});

if (appFilePaths.length === 0) {
// Check if outputDir is an .app but was extracted as folder
if (fs.existsSync(path.join(outputDir, 'Info.plist'))) {
const appPath = `${outputDir}.app`;
await fs.promises.cp(outputDir, appPath, { recursive: true });
return appPath;
}

throw Error('Did not find any installable apps inside tarball.');
}

Expand Down

0 comments on commit c6b6ffa

Please sign in to comment.