Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

Commit

Permalink
[expo-cli] use Submission Service for Android uploads (#2069)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsokal authored May 26, 2020
1 parent 5eec01b commit dd058da
Show file tree
Hide file tree
Showing 40 changed files with 2,228 additions and 234 deletions.
6 changes: 4 additions & 2 deletions packages/expo-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"@expo/json-file": "8.2.18",
"@expo/package-manager": "0.0.24",
"@expo/plist": "0.0.7",
"@expo/results": "^1.0.0",
"@expo/simple-spinner": "1.0.2",
"@expo/spawn-async": "1.5.0",
"@expo/xdl": "57.9.9",
Expand All @@ -83,6 +84,7 @@
"fs-extra": "6.0.1",
"getenv": "0.7.0",
"glob": "7.1.2",
"got": "^11.1.4",
"indent-string": "4.0.0",
"inquirer": "5.2.0",
"klaw-sync": "6.0.0",
Expand All @@ -107,8 +109,8 @@
"wordwrap": "1.0.0"
},
"optionalDependencies": {
"@expo/traveling-fastlane-darwin": "1.13.2",
"@expo/traveling-fastlane-linux": "1.13.2"
"@expo/traveling-fastlane-darwin": "1.14.0",
"@expo/traveling-fastlane-linux": "1.14.0"
},
"gitHead": "613642fe06827cc231405784b099cf71c29072df"
}
14 changes: 14 additions & 0 deletions packages/expo-cli/src/__mocks__/prompt.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import inquirer, { Question } from 'inquirer';

type CliQuestions = Question | Question[];

function prompt(
questions: CliQuestions,
{ nonInteractiveHelp }: { nonInteractiveHelp?: string } = {}
) {
return {};
}

prompt.separator = (...args: any[]) => new inquirer.Separator(...args);

export default jest.fn(prompt);
64 changes: 64 additions & 0 deletions packages/expo-cli/src/__tests__/project-utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { User } from '@expo/xdl';

interface MockProject {
projectRoot: string;
projectTree: Record<string, string>;
appJSON: AppJSON;
packageJSON: PackageJSON;
}

interface PackageJSON {
name: string;
version: string;
description: string;
main: string;
}

interface AppJSON {
expo: {
name: string;
version: string;
slug: string;
sdkVersion: string;
owner: string;
android?: {
package: string;
};
[key: string]: object | string;
};
}

function createTestProject(
user: User,
appJSONExtraData?: Record<string, object | string>
): MockProject {
const projectRoot = '/test-project';
const packageJSON: PackageJSON = {
name: 'testing123',
version: '0.1.0',
description: 'fake description',
main: 'index.js',
};

const appJSON: AppJSON = {
expo: {
name: 'testing 123',
version: '0.1.0',
slug: 'testing-123',
sdkVersion: '33.0.0',
owner: user.username,
...appJSONExtraData,
},
};
return {
appJSON,
packageJSON,
projectRoot,
projectTree: {
[projectRoot + '/package.json']: JSON.stringify(packageJSON, null, 2),
[projectRoot + '/app.json']: JSON.stringify(appJSON, null, 2),
},
};
}

export { createTestProject };
14 changes: 14 additions & 0 deletions packages/expo-cli/src/__tests__/user-fixtures.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { User } from '@expo/xdl';

const jester: User = {
kind: 'user',
username: 'jester',
nickname: 'jester',
userId: 'jester-id',
picture: 'jester-pic',
userMetadata: { onboarded: true },
currentConnection: 'Username-Password-Authentication',
sessionSecret: 'jester-secret',
};

export { jester };
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ApiV2 } from '@expo/xdl';

import { getPublicationDetailAsync, getPublishHistoryAsync } from '../utils/PublishUtils';
import { jester } from '../../credentials/test-fixtures/mocks';
import { mockExpoXDL } from '../../__tests__/utils';
import { mockExpoXDL } from '../../__tests__/mock-utils';

jest.mock('fs');
jest.mock('resolve-from');
Expand Down
59 changes: 20 additions & 39 deletions packages/expo-cli/src/commands/__tests__/publish-modify-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
setPublishToChannelAsync,
} from '../utils/PublishUtils';
import { jester } from '../../credentials/test-fixtures/mocks';
import { mockExpoXDL } from '../../__tests__/utils';
import { mockExpoXDL } from '../../__tests__/mock-utils';
import { createTestProject } from '../../__tests__/project-utils';

jest.mock('fs');
jest.mock('resolve-from');
Expand All @@ -22,30 +23,10 @@ mockExpoXDL({
});

describe('publish details', () => {
const projectRoot = '/test-project';
const packageJson = JSON.stringify(
{
name: 'testing123',
version: '0.1.0',
description: 'fake description',
main: 'index.js',
},
null,
2
);
const appJson = JSON.stringify({
name: 'testing 123',
version: '0.1.0',
slug: 'testing-123',
sdkVersion: '33.0.0',
owner: jester.username,
});
const testProject = createTestProject(jester);

beforeAll(() => {
vol.fromJSON({
[projectRoot + '/package.json']: packageJson,
[projectRoot + '/app.json']: appJson,
});
vol.fromJSON(testProject.projectTree);
});

afterAll(() => {
Expand Down Expand Up @@ -73,7 +54,7 @@ describe('publish details', () => {
});
(ApiV2.clientForUser as jest.Mock).mockReturnValue({ postAsync });

await setPublishToChannelAsync(projectRoot, setOptions);
await setPublishToChannelAsync(testProject.projectRoot, setOptions);

expect(postAsync.mock.calls.length).toBe(1);
expect(postAsync).toHaveBeenCalledWith('publish/set', {
Expand Down Expand Up @@ -101,7 +82,7 @@ describe('publish details', () => {
(ApiV2.clientForUser as jest.Mock).mockReturnValue({ postAsync });

try {
await rollbackPublicationFromChannelAsync(projectRoot, rollbackOptions);
await rollbackPublicationFromChannelAsync(testProject.projectRoot, rollbackOptions);
} catch (e) {
expect(e.message).toMatch(/There isn't anything published/);
}
Expand All @@ -110,7 +91,7 @@ describe('publish details', () => {

expect(postAsync).toHaveBeenCalledWith('publish/history', {
releaseChannel: 'test-channel',
slug: 'testing-123',
slug: testProject.appJSON.expo.slug,
count: 2,
owner: jester.username,
platform: 'ios',
Expand Down Expand Up @@ -144,7 +125,7 @@ describe('publish details', () => {
(ApiV2.clientForUser as jest.Mock).mockReturnValue({ postAsync });

try {
await rollbackPublicationFromChannelAsync(projectRoot, rollbackOptions);
await rollbackPublicationFromChannelAsync(testProject.projectRoot, rollbackOptions);
} catch (e) {
expect(e.message).toMatch(/There is only 1 publication/);
}
Expand All @@ -153,7 +134,7 @@ describe('publish details', () => {

expect(postAsync).toHaveBeenCalledWith('publish/history', {
releaseChannel: 'test-channel',
slug: 'testing-123',
slug: testProject.appJSON.expo.slug,
count: 2,
owner: jester.username,
platform: 'ios',
Expand Down Expand Up @@ -193,25 +174,25 @@ describe('publish details', () => {
});
(ApiV2.clientForUser as jest.Mock).mockReturnValue({ postAsync });

await rollbackPublicationFromChannelAsync(projectRoot, rollbackOptions);
await rollbackPublicationFromChannelAsync(testProject.projectRoot, rollbackOptions);

expect(postAsync.mock.calls.length).toBe(3);
expect(postAsync).toHaveBeenCalledWith('publish/history', {
releaseChannel: 'test-channel',
slug: 'testing-123',
slug: testProject.appJSON.expo.slug,
count: 2,
owner: jester.username,
platform: 'ios',
sdkVersion: '35.0.0',
version: 2,
});
expect(postAsync).toHaveBeenCalledWith('publish/details', {
slug: 'testing-123',
slug: testProject.appJSON.expo.slug,
publishId: 'test-publication-uuid-1',
owner: jester.username,
});
expect(postAsync).toHaveBeenCalledWith('publish/set', {
slug: 'testing-123',
slug: testProject.appJSON.expo.slug,
publishId: 'test-publication-uuid-1',
releaseChannel: 'test-channel',
});
Expand Down Expand Up @@ -247,12 +228,12 @@ describe('publish details', () => {
});
(ApiV2.clientForUser as jest.Mock).mockReturnValue({ postAsync });

await rollbackPublicationFromChannelAsync(projectRoot, rollbackOptions);
await rollbackPublicationFromChannelAsync(testProject.projectRoot, rollbackOptions);

expect(postAsync.mock.calls.length).toBe(6);
expect(postAsync).toHaveBeenCalledWith('publish/history', {
releaseChannel: 'test-channel',
slug: 'testing-123',
slug: testProject.appJSON.expo.slug,
count: 2,
owner: jester.username,
platform: 'ios',
Expand All @@ -261,30 +242,30 @@ describe('publish details', () => {
});
expect(postAsync).toHaveBeenCalledWith('publish/history', {
releaseChannel: 'test-channel',
slug: 'testing-123',
slug: testProject.appJSON.expo.slug,
count: 2,
owner: jester.username,
platform: 'android',
sdkVersion: '35.0.0',
version: 2,
});
expect(postAsync).toHaveBeenCalledWith('publish/details', {
slug: 'testing-123',
slug: testProject.appJSON.expo.slug,
publishId: 'test-publication-uuid-ios-1',
owner: jester.username,
});
expect(postAsync).toHaveBeenCalledWith('publish/details', {
slug: 'testing-123',
slug: testProject.appJSON.expo.slug,
publishId: 'test-publication-uuid-android-1',
owner: jester.username,
});
expect(postAsync).toHaveBeenCalledWith('publish/set', {
slug: 'testing-123',
slug: testProject.appJSON.expo.slug,
publishId: 'test-publication-uuid-ios-1',
releaseChannel: 'test-channel',
});
expect(postAsync).toHaveBeenCalledWith('publish/set', {
slug: 'testing-123',
slug: testProject.appJSON.expo.slug,
publishId: 'test-publication-uuid-android-1',
releaseChannel: 'test-channel',
});
Expand Down
2 changes: 1 addition & 1 deletion packages/expo-cli/src/commands/__tests__/upgrade-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
maybeFormatSdkVersion,
upgradeAsync,
} from '../upgrade';
import { mockExpoXDL } from '../../__tests__/utils';
import { mockExpoXDL } from '../../__tests__/mock-utils';

jest.mock('fs');
jest.mock('resolve-from');
Expand Down
2 changes: 1 addition & 1 deletion packages/expo-cli/src/commands/build/BaseBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ ${job.id}
}
const job = fp.compose(
fp.head,
fp.filter((job) => buildId && (job as any).id === buildId),
fp.filter(job => buildId && (job as any).id === buildId),
fp.getOr([], 'jobs')
)(res);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
jester,
testAppJson,
} from '../../../credentials/test-fixtures/mocks';
import { mockExpoXDL } from '../../../__tests__/utils';
import { mockExpoXDL } from '../../../__tests__/mock-utils';

jest.setTimeout(10 * 1000); // 10s

Expand Down
Loading

0 comments on commit dd058da

Please sign in to comment.