Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit d56ff1c
Author: Tomasz Sapeta <1714764+tsapeta@users.noreply.github.com>
Date:   Wed Jul 29 11:49:15 2020 +0200

    [et] Move UpdateVersions from xdl to expotools (#9336)

    # Why

    Part of expo/expo-cli#2282

    # How

    Moved some functionality of xdl's UpdateVersions to expotools and refactored `et client-build` command a little bit.

    # Test Plan

    Tested with `et client-build -p ios --release --skip-upload`, will test Android soon

commit b5532de
Author: Michał Czernek <czernekmichal@gmail.com>
Date:   Wed Jul 29 11:13:45 2020 +0200

    [expo-module-template] Add unit tests in android module template.

commit fc7bc75
Author: Tomasz Sapeta <tsapeta@users.noreply.github.com>
Date:   Wed Jul 29 10:17:35 2020 +0200

    [bare-expo] Install pods

commit 9bca879
Author: Bartłomiej Klocek <bartlomiej.klocek@swmansion.com>
Date:   Wed Jul 29 10:03:05 2020 +0200

    [media-library] Fix `getAssetsAsync` crash when given invalid `after` value on Android (#9466)

    # Why

    Fixes #9440

    Non-number string values caused `Integer.parseInt()` throwing uncaught `NumberFormatException` in background thread - this crashed the whole application.

    # How

    Surrounded `parseInt()` within a `try-catch` block with fallback to default value.

    # Test Plan

    Tested `getAssetsAsync({after: ... })` for different string values (both valid and invalid) on Android emulator.
  • Loading branch information
barthap committed Jul 29, 2020
1 parent 792dd43 commit 215844a
Show file tree
Hide file tree
Showing 15 changed files with 624 additions and 350 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

493 changes: 255 additions & 238 deletions apps/bare-expo/ios/Pods/EXNotifications.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions ios/Exponent/Supporting/Info.plist
Expand Up @@ -16,8 +16,6 @@
<string>$(EX_BUNDLE_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleVersion</key>
<string>2.16.0</string>
<key>CFBundleShortVersionString</key>
<string>2.16.0</string>
<key>CFBundleSignature</key>
Expand Down Expand Up @@ -55,6 +53,8 @@
</array>
</dict>
</array>
<key>CFBundleVersion</key>
<string>2.16.0</string>
<key>FacebookAdvertiserIDCollectionEnabled</key>
<false/>
<key>FacebookAppID</key>
Expand Down
2 changes: 2 additions & 0 deletions packages/expo-media-library/CHANGELOG.md
Expand Up @@ -10,6 +10,8 @@

### 🐛 Bug fixes

- Fixed `getAssetsAsync` crashes when given invalid `after` value on Android. ([#9466](https://github.com/expo/expo/pull/9466) by [@barthap](https://github.com/barthap))

## 8.4.0 — 2020-07-27

### 🐛 Bug fixes
Expand Down
Expand Up @@ -87,8 +87,12 @@ public GetQueryInfo invoke() {
}

// to maintain compatibility with IOS field after is in string object
mOffset = mInput.containsKey("after") ?
try {
mOffset = mInput.containsKey("after") ?
Integer.parseInt((String) mInput.get("after")) : 0;
} catch (NumberFormatException e) {
mOffset = 0;
}
return this;
}
}
8 changes: 0 additions & 8 deletions packages/expo-module-template/CHANGELOG.md
Expand Up @@ -7,11 +7,3 @@
### 🎉 New features

### 🐛 Bug fixes

## 8.3.1 — 2020-05-29

*This version does not introduce any user-facing changes.*

## 8.3.0 — 2020-05-27

*This version does not introduce any user-facing changes.*
3 changes: 3 additions & 0 deletions packages/expo-module-template/android/build.gradle
Expand Up @@ -75,4 +75,7 @@ repositories {
dependencies {
unimodule 'unimodules-core'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${safeExtGet("kotlinVersion", "1.3.50")}"

testImplementation project(':unimodules-test-core')
testImplementation 'org.robolectric:robolectric:4.3.1'
}
@@ -0,0 +1,32 @@
package expo.modules.template

import io.mockk.mockk
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.unimodules.test.core.PromiseMock
import org.unimodules.test.core.moduleRegistryMock

@RunWith(RobolectricTestRunner::class)
class ModuleTemplateModuleTest {

private var moduleRegistry = moduleRegistryMock()

private lateinit var promise: PromiseMock

private lateinit var module: ModuleTemplateModule

@Before
fun initializeMock() {
promise = PromiseMock()
module = ModuleTemplateModule(mockk())
}

@Test
fun testSomeGreatMethodAsync() {
assertTrue(true)
}

}
74 changes: 74 additions & 0 deletions tools/expotools/src/Versions.ts
@@ -0,0 +1,74 @@
import { Config, Versions } from '@expo/xdl';

export enum VersionsApiHost {
PRODUCTION = 'exp.host',
STAGING = 'staging.exp.host',
}

export type VersionsSchema = {
sdkVersions: Record<string, VersionsSdkSchema>;
turtleSdkVersions: {
android: string;
ios: string;
};
};

export type VersionsSdkSchema = Partial<{
androidClientUrl: string;
androidClientVersion: string;
androidExpoViewUrl: string;
expokitNpmPackage: string;
expoReactNativeTag: string;
facebookReactNativeVersion: string;
facebookReactVersion: string;
iosClientUrl: string;
iosClientVersion: string;
iosExpoViewUrl: string;
packagesToInstallWhenEjecting: Record<string, string>;
relatedPackages: Record<string, string>;
releaseNoteUrl: string;
}>;

export async function getVersionsAsync(
apiHost: VersionsApiHost = VersionsApiHost.STAGING
): Promise<VersionsSchema> {
return await runWithApiHost(apiHost, () => Versions.versionsAsync() as Promise<VersionsSchema>);
}

export async function getSdkVersionsAsync(
sdkVersion: string,
apiHost: VersionsApiHost = VersionsApiHost.STAGING
): Promise<VersionsSdkSchema | null> {
const versions = await getVersionsAsync(apiHost);
return versions?.sdkVersions?.[sdkVersion] ?? null;
}

export async function setVersionsAsync(
versions: VersionsSchema,
apiHost: VersionsApiHost = VersionsApiHost.STAGING
): Promise<void> {
return await runWithApiHost(apiHost, () => Versions.setVersionsAsync(versions));
}

export async function modifySdkVersionsAsync(
sdkVersion: string,
modifier: (sdkVersions: VersionsSdkSchema) => VersionsSdkSchema | Promise<VersionsSdkSchema>
): Promise<VersionsSdkSchema> {
const versions = await getVersionsAsync();
const sdkVersions = await modifier(versions.sdkVersions[sdkVersion] ?? {});

versions.sdkVersions[sdkVersion] = sdkVersions;
await setVersionsAsync(versions);
return sdkVersions;
}

async function runWithApiHost<T = any>(
apiHost: VersionsApiHost,
lambda: () => T | Promise<T>
): Promise<T> {
const originalHost = Config.api.host;
Config.api.host = apiHost;
const result = await lambda();
Config.api.host = originalHost;
return result;
}
40 changes: 40 additions & 0 deletions tools/expotools/src/client-build/AndroidClientBuilder.ts
@@ -0,0 +1,40 @@
import fs from 'fs-extra';
import path from 'path';

import { ANDROID_DIR } from '../Constants';
import { androidAppVersionAsync } from '../ProjectVersions';
import { spawnAsync } from '../Utils';
import { ClientBuilder, Platform, S3Client } from './types';

export default class AndroidClientBuilder implements ClientBuilder {
platform: Platform = 'android';

getAppPath(): string {
return path.join(ANDROID_DIR, 'app', 'build', 'outputs', 'apk', 'release', 'app-release.apk');
}

getClientUrl(appVersion: string): string {
return `https://d1ahtucjixef4r.cloudfront.net/Exponent-${appVersion}.apk`;
}

async getAppVersionAsync(): Promise<string> {
return androidAppVersionAsync();
}

async buildAsync() {
await spawnAsync('fastlane', ['android', 'build', 'build_type:Release'], { stdio: 'inherit' });
}

async uploadBuildAsync(s3Client: S3Client, appVersion: string) {
const file = fs.createReadStream(this.getAppPath());

await s3Client
.putObject({
Bucket: 'exp-android-apks',
Key: `Exponent-${appVersion}.apk`,
Body: file,
ACL: 'public-read',
})
.promise();
}
}
55 changes: 55 additions & 0 deletions tools/expotools/src/client-build/IosClientBuilder.ts
@@ -0,0 +1,55 @@
import fs from 'fs-extra';
import path from 'path';

import { EXPO_DIR, IOS_DIR } from '../Constants';
import { iosAppVersionAsync } from '../ProjectVersions';
import { spawnAsync } from '../Utils';
import { ClientBuilder, Platform } from './types';

export default class IosClientBuilder implements ClientBuilder {
platform: Platform = 'ios';

getAppPath(): string {
return path.join(
IOS_DIR,
'simulator-build',
'Build',
'Products',
'Release-iphonesimulator',
'Exponent.app'
);
}

getClientUrl(appVersion: string): string {
return `https://dpq5q02fu5f55.cloudfront.net/Exponent-${appVersion}.tar.gz`;
}

async getAppVersionAsync(): Promise<string> {
return await iosAppVersionAsync();
}

async buildAsync() {
await spawnAsync('fastlane', ['ios', 'create_simulator_build'], { stdio: 'inherit' });
}

async uploadBuildAsync(s3Client, appVersion: string) {
const tempAppPath = path.join(EXPO_DIR, 'temp-app.tar.gz');

await spawnAsync('tar', ['-zcvf', tempAppPath, '-C', this.getAppPath(), '.'], {
stdio: ['ignore', 'ignore', 'inherit'], // only stderr
});

const file = fs.createReadStream(tempAppPath);

await s3Client
.putObject({
Bucket: 'exp-ios-simulator-apps',
Key: `Exponent-${appVersion}.tar.gz`,
Body: file,
ACL: 'public-read',
})
.promise();

await fs.remove(tempAppPath);
}
}
15 changes: 15 additions & 0 deletions tools/expotools/src/client-build/types.ts
@@ -0,0 +1,15 @@
import aws from 'aws-sdk';
import { Platform } from '../ProjectVersions';

export { Platform };

export type S3Client = aws.S3;

export interface ClientBuilder {
platform: Platform;
getAppPath: () => string;
getClientUrl: (appVersion: string) => string;
getAppVersionAsync: () => Promise<string>;
buildAsync: () => Promise<void>;
uploadBuildAsync: (s3Client: S3Client, appVersion: string) => Promise<void>;
}

0 comments on commit 215844a

Please sign in to comment.