mirror of
https://github.com/expo/eas-cli.git
synced 2026-11-13 20:28:08 -10:00
Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bcf2c62066 | ||
|
|
8632b8ada7 | ||
|
|
b288879838 | ||
|
|
8beb8f46da | ||
|
|
9120bf5777 |
No files matched your search
@@ -10,11 +10,21 @@ This is the log of notable changes to EAS CLI and related packages.
|
||||
|
||||
### 🐛 Bug fixes
|
||||
|
||||
### 🧹 Chores
|
||||
|
||||
- Better wording in eas submit. ([#1527](https://github.com/expo/eas-cli/pull/1527) by [@dsokal](https://github.com/dsokal))
|
||||
- Upload project sources for EAS Build and archives for EAS Submit to GCS. ([#1524](https://github.com/expo/eas-cli/pull/1524) by [@wkozyra95](https://github.com/wkozyra95))
|
||||
|
||||
## [2.7.1](https://github.com/expo/eas-cli/releases/tag/v2.7.1) - 2022-11-16
|
||||
|
||||
### 🐛 Bug fixes
|
||||
|
||||
- Use envs from the build profile to resolve credentials in `eas credentials`. ([#1520](https://github.com/expo/eas-cli/pull/1520) by [@wkozyra95](https://github.com/wkozyra95))
|
||||
|
||||
### 🧹 Chores
|
||||
|
||||
- Print prompt message when failing because of the non-interactive shell. ([#1523](https://github.com/expo/eas-cli/pull/1523) by [@wkozyra95](https://github.com/wkozyra95))
|
||||
- Add SDK version to the analytics build events. ([#1529](https://github.com/expo/eas-cli/pull/1529) by [@wkozyra95](https://github.com/wkozyra95))
|
||||
- Add Xcode 14.1 image to `eas-json`. ([#1511](https://github.com/expo/eas-cli/pull/1511) by [@szdziedzic](https://github.com/szdziedzic))
|
||||
|
||||
## [2.7.0](https://github.com/expo/eas-cli/releases/tag/v2.7.0) - 2022-11-11
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
"build:tarballs:linux": "yarn build-for-size-check",
|
||||
"build-for-size-check": "yarn build && yarn workspace eas-cli pretarball-ci && CLI_SIZE_CHECK=1 yarn workspace eas-cli oclif pack:tarballs --no-xz --targets linux-x64",
|
||||
"typecheck": "lerna run typecheck",
|
||||
"start": "lerna run watch --parallel",
|
||||
"start": "lerna run watch --stream --parallel",
|
||||
"watch": "yarn start",
|
||||
"eas": "packages/eas-cli/bin/run",
|
||||
"lint": "eslint .",
|
||||
|
||||
Generated
+91
@@ -17413,6 +17413,35 @@
|
||||
"enumValues": null,
|
||||
"possibleTypes": null
|
||||
},
|
||||
{
|
||||
"kind": "ENUM",
|
||||
"name": "GitHubAppEnvironment",
|
||||
"description": "",
|
||||
"fields": null,
|
||||
"inputFields": null,
|
||||
"interfaces": null,
|
||||
"enumValues": [
|
||||
{
|
||||
"name": "DEVELOPMENT",
|
||||
"description": "",
|
||||
"isDeprecated": false,
|
||||
"deprecationReason": null
|
||||
},
|
||||
{
|
||||
"name": "PRODUCTION",
|
||||
"description": "",
|
||||
"isDeprecated": false,
|
||||
"deprecationReason": null
|
||||
},
|
||||
{
|
||||
"name": "STAGING",
|
||||
"description": "",
|
||||
"isDeprecated": false,
|
||||
"deprecationReason": null
|
||||
}
|
||||
],
|
||||
"possibleTypes": null
|
||||
},
|
||||
{
|
||||
"kind": "OBJECT",
|
||||
"name": "GitHubAppInstallation",
|
||||
@@ -17870,6 +17899,22 @@
|
||||
"isDeprecated": false,
|
||||
"deprecationReason": null
|
||||
},
|
||||
{
|
||||
"name": "environment",
|
||||
"description": "",
|
||||
"args": [],
|
||||
"type": {
|
||||
"kind": "NON_NULL",
|
||||
"name": null,
|
||||
"ofType": {
|
||||
"kind": "ENUM",
|
||||
"name": "GitHubAppEnvironment",
|
||||
"ofType": null
|
||||
}
|
||||
},
|
||||
"isDeprecated": false,
|
||||
"deprecationReason": null
|
||||
},
|
||||
{
|
||||
"name": "installation",
|
||||
"description": "",
|
||||
@@ -17903,6 +17948,22 @@
|
||||
"isDeprecated": false,
|
||||
"deprecationReason": null
|
||||
},
|
||||
{
|
||||
"name": "name",
|
||||
"description": "",
|
||||
"args": [],
|
||||
"type": {
|
||||
"kind": "NON_NULL",
|
||||
"name": null,
|
||||
"ofType": {
|
||||
"kind": "SCALAR",
|
||||
"name": "String",
|
||||
"ofType": null
|
||||
}
|
||||
},
|
||||
"isDeprecated": false,
|
||||
"deprecationReason": null
|
||||
},
|
||||
{
|
||||
"name": "searchRepositories",
|
||||
"description": "",
|
||||
@@ -18066,6 +18127,18 @@
|
||||
"name": "GitHubRepositoryMetadata",
|
||||
"description": "",
|
||||
"fields": [
|
||||
{
|
||||
"name": "defaultBranch",
|
||||
"description": "",
|
||||
"args": [],
|
||||
"type": {
|
||||
"kind": "SCALAR",
|
||||
"name": "String",
|
||||
"ofType": null
|
||||
},
|
||||
"isDeprecated": false,
|
||||
"deprecationReason": null
|
||||
},
|
||||
{
|
||||
"name": "githubRepoDescription",
|
||||
"description": "",
|
||||
@@ -18158,6 +18231,18 @@
|
||||
"isDeprecated": false,
|
||||
"deprecationReason": null
|
||||
},
|
||||
{
|
||||
"name": "openGraphImageUrl",
|
||||
"description": "",
|
||||
"args": [],
|
||||
"type": {
|
||||
"kind": "SCALAR",
|
||||
"name": "String",
|
||||
"ofType": null
|
||||
},
|
||||
"isDeprecated": false,
|
||||
"deprecationReason": null
|
||||
},
|
||||
{
|
||||
"name": "private",
|
||||
"description": "",
|
||||
@@ -22847,6 +22932,12 @@
|
||||
"inputFields": null,
|
||||
"interfaces": null,
|
||||
"enumValues": [
|
||||
{
|
||||
"name": "GCS",
|
||||
"description": "",
|
||||
"isDeprecated": false,
|
||||
"deprecationReason": null
|
||||
},
|
||||
{
|
||||
"name": "S3",
|
||||
"description": "",
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
import { fixS3Url } from '../uploads';
|
||||
|
||||
describe(fixS3Url, () => {
|
||||
it('fixes broken links', () => {
|
||||
const input =
|
||||
'https://submission-service-archives.s3.amazonaws.com/production%2Fdc98ca84-1473-4cb3-ae81-8c7b291cb27e%2F4424aa95-b985-4e2f-8755-9507b1037c1c';
|
||||
const expectedOutput =
|
||||
'https://submission-service-archives.s3.amazonaws.com/production/dc98ca84-1473-4cb3-ae81-8c7b291cb27e/4424aa95-b985-4e2f-8755-9507b1037c1c';
|
||||
expect(fixS3Url(input)).toBe(expectedOutput);
|
||||
});
|
||||
|
||||
it('does not change correct urls', () => {
|
||||
const correctUrl =
|
||||
'https://submission-service-archives.s3.amazonaws.com/production/dc98ca84-1473-4cb3-ae81-8c7b291cb27e/4424aa95-b985-4e2f-8755-9507b1037c1c';
|
||||
expect(fixS3Url(correctUrl)).toBe(correctUrl);
|
||||
});
|
||||
});
|
||||
@@ -26,7 +26,7 @@ import {
|
||||
appPlatformEmojis,
|
||||
requestedPlatformDisplayNames,
|
||||
} from '../platform';
|
||||
import { uploadFileAtPathToS3Async } from '../uploads';
|
||||
import { uploadFileAtPathToGCSAsync } from '../uploads';
|
||||
import { formatBytes } from '../utils/files';
|
||||
import { createProgressTracker } from '../utils/progress';
|
||||
import { sleepAsync } from '../utils/promise';
|
||||
@@ -113,7 +113,7 @@ export async function prepareBuildRequestForPlatformAsync<
|
||||
path: (await makeProjectTarballAsync()).path,
|
||||
} as const)
|
||||
: ({
|
||||
type: ArchiveSourceType.S3,
|
||||
type: ArchiveSourceType.GCS,
|
||||
bucketKey: await uploadProjectAsync(ctx),
|
||||
} as const);
|
||||
|
||||
@@ -219,9 +219,9 @@ async function uploadProjectAsync<TPlatform extends Platform>(
|
||||
|
||||
projectTarballPath = projectTarball.path;
|
||||
|
||||
const { bucketKey } = await uploadFileAtPathToS3Async(
|
||||
const bucketKey = await uploadFileAtPathToGCSAsync(
|
||||
ctx.graphqlClient,
|
||||
UploadSessionType.EasBuildProjectSources,
|
||||
UploadSessionType.EasBuildGcsProjectSources,
|
||||
projectTarball.path,
|
||||
createProgressTracker({
|
||||
total: projectTarball.size,
|
||||
|
||||
@@ -78,6 +78,7 @@ export async function createBuildContextAsync<T extends Platform>({
|
||||
const analyticsEventProperties = {
|
||||
tracking_id: uuidv4(),
|
||||
platform,
|
||||
...(exp.sdkVersion && { sdk_version: exp.sdkVersion }),
|
||||
...(accountId && { account_id: accountId }),
|
||||
project_id: projectId,
|
||||
project_type: workflow,
|
||||
|
||||
@@ -16,6 +16,11 @@ export function transformProjectArchive(archiveSource: ArchiveSource): ProjectAr
|
||||
type: ProjectArchiveSourceType.S3,
|
||||
bucketKey: archiveSource.bucketKey,
|
||||
};
|
||||
} else if (archiveSource.type === ArchiveSourceType.GCS) {
|
||||
return {
|
||||
type: ProjectArchiveSourceType.Gcs,
|
||||
bucketKey: archiveSource.bucketKey,
|
||||
};
|
||||
} else if (archiveSource.type === ArchiveSourceType.URL) {
|
||||
return {
|
||||
type: ProjectArchiveSourceType.Url,
|
||||
|
||||
@@ -75,7 +75,7 @@ export default class Submit extends EasCommand {
|
||||
exclusive: ['latest', 'id', 'path'],
|
||||
}),
|
||||
verbose: Flags.boolean({
|
||||
description: 'Always print logs from Submission Service',
|
||||
description: 'Always print logs from EAS Submit',
|
||||
default: false,
|
||||
}),
|
||||
wait: Flags.boolean({
|
||||
|
||||
+13
@@ -2523,6 +2523,12 @@ export type GetSignedAssetUploadSpecificationsResult = {
|
||||
specifications: Array<Scalars['String']>;
|
||||
};
|
||||
|
||||
export enum GitHubAppEnvironment {
|
||||
Development = 'DEVELOPMENT',
|
||||
Production = 'PRODUCTION',
|
||||
Staging = 'STAGING'
|
||||
}
|
||||
|
||||
export type GitHubAppInstallation = {
|
||||
__typename?: 'GitHubAppInstallation';
|
||||
accessibleRepositories: GitHubRepositoryPaginationResult;
|
||||
@@ -2586,7 +2592,9 @@ export type GitHubAppQuery = {
|
||||
__typename?: 'GitHubAppQuery';
|
||||
appIdentifier: Scalars['String'];
|
||||
clientIdentifier: Scalars['String'];
|
||||
environment: GitHubAppEnvironment;
|
||||
installation: GitHubAppInstallation;
|
||||
name: Scalars['String'];
|
||||
searchRepositories: GitHubRepositoryPaginationResult;
|
||||
};
|
||||
|
||||
@@ -2613,12 +2621,14 @@ export type GitHubRepository = {
|
||||
|
||||
export type GitHubRepositoryMetadata = {
|
||||
__typename?: 'GitHubRepositoryMetadata';
|
||||
defaultBranch?: Maybe<Scalars['String']>;
|
||||
githubRepoDescription?: Maybe<Scalars['String']>;
|
||||
githubRepoName: Scalars['String'];
|
||||
githubRepoOwnerName: Scalars['String'];
|
||||
githubRepoUrl: Scalars['String'];
|
||||
lastPushed: Scalars['DateTime'];
|
||||
lastUpdated: Scalars['DateTime'];
|
||||
openGraphImageUrl?: Maybe<Scalars['String']>;
|
||||
private: Scalars['Boolean'];
|
||||
};
|
||||
|
||||
@@ -3287,6 +3297,7 @@ export type ProjectArchiveSourceInput = {
|
||||
};
|
||||
|
||||
export enum ProjectArchiveSourceType {
|
||||
Gcs = 'GCS',
|
||||
S3 = 'S3',
|
||||
Url = 'URL'
|
||||
}
|
||||
@@ -5072,6 +5083,7 @@ export type CreateAndroidSubmissionMutationVariables = Exact<{
|
||||
appId: Scalars['ID'];
|
||||
config: AndroidSubmissionConfigInput;
|
||||
submittedBuildId?: InputMaybe<Scalars['ID']>;
|
||||
archiveSource?: InputMaybe<SubmissionArchiveSourceInput>;
|
||||
}>;
|
||||
|
||||
|
||||
@@ -5081,6 +5093,7 @@ export type CreateIosSubmissionMutationVariables = Exact<{
|
||||
appId: Scalars['ID'];
|
||||
config: IosSubmissionConfigInput;
|
||||
submittedBuildId?: InputMaybe<Scalars['ID']>;
|
||||
archiveSource?: InputMaybe<SubmissionArchiveSourceInput>;
|
||||
}>;
|
||||
|
||||
|
||||
|
||||
@@ -28,10 +28,16 @@ export const SubmissionMutation = {
|
||||
$appId: ID!
|
||||
$config: AndroidSubmissionConfigInput!
|
||||
$submittedBuildId: ID
|
||||
$archiveSource: SubmissionArchiveSourceInput
|
||||
) {
|
||||
submission {
|
||||
createAndroidSubmission(
|
||||
input: { appId: $appId, config: $config, submittedBuildId: $submittedBuildId }
|
||||
input: {
|
||||
appId: $appId
|
||||
config: $config
|
||||
submittedBuildId: $submittedBuildId
|
||||
archiveSource: $archiveSource
|
||||
}
|
||||
) {
|
||||
submission {
|
||||
id
|
||||
@@ -60,10 +66,16 @@ export const SubmissionMutation = {
|
||||
$appId: ID!
|
||||
$config: IosSubmissionConfigInput!
|
||||
$submittedBuildId: ID
|
||||
$archiveSource: SubmissionArchiveSourceInput
|
||||
) {
|
||||
submission {
|
||||
createIosSubmission(
|
||||
input: { appId: $appId, config: $config, submittedBuildId: $submittedBuildId }
|
||||
input: {
|
||||
appId: $appId
|
||||
config: $config
|
||||
submittedBuildId: $submittedBuildId
|
||||
archiveSource: $archiveSource
|
||||
}
|
||||
) {
|
||||
submission {
|
||||
id
|
||||
|
||||
@@ -8,16 +8,17 @@ import {
|
||||
UploadSessionType,
|
||||
} from '../generated';
|
||||
|
||||
export interface PresignedPost {
|
||||
export interface SignedUrl {
|
||||
url: string;
|
||||
fields: Record<string, string>;
|
||||
headers: Record<string, string>;
|
||||
bucketKey: string;
|
||||
}
|
||||
|
||||
export const UploadSessionMutation = {
|
||||
async createUploadSessionAsync(
|
||||
graphqlClient: ExpoGraphqlClient,
|
||||
type: UploadSessionType
|
||||
): Promise<PresignedPost> {
|
||||
): Promise<SignedUrl> {
|
||||
const data = await withErrorHandlingAsync(
|
||||
graphqlClient
|
||||
.mutation<CreateUploadSessionMutation, CreateUploadSessionMutationVariables>(
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
import { ProjectConfig, getConfig } from '@expo/config';
|
||||
|
||||
import { getExpoConfig } from '../expoConfig';
|
||||
|
||||
jest.mock('@expo/config');
|
||||
|
||||
describe(getExpoConfig, () => {
|
||||
it('correctly restores process.env as best as possible', () => {
|
||||
process.env.BEFORE_CALL_KEY = 'BEFORE';
|
||||
process.env.BEFORE_CALL_KEY_OVERRIDDEN_BY_WITHIN = 'BEFORE_OVERRIDDEN_BY_WITHIN';
|
||||
process.env.BEFORE_CALL_KEY_OVERRIDDEN_BY_OPTS = 'BEFORE_OVERRIDDEN_BY_OPTS';
|
||||
process.env.BEFORE_CALL_KEY_OVERRIDDEN_BY_OPTS_AND_WITHIN =
|
||||
'BEFORE_CALL_KEY_OVERRIDDEN_BY_OPTS_AND_WITHIN';
|
||||
|
||||
jest.mocked(getConfig).mockImplementation(() => {
|
||||
process.env.WITHIN_CALL_KEY = 'WITHIN';
|
||||
process.env.BEFORE_CALL_KEY_OVERRIDDEN_BY_WITHIN = 'OVERRIDDEN_VALUE';
|
||||
process.env.OPTS_KEY_OVERRIDDEN_BY_WITHIN = 'OVERRIDDEN_VALUE';
|
||||
process.env.OPTS_KEY_OVERRIDDEN_BY_WITHIN_TO_SAME_VALUE =
|
||||
'OPTS_KEY_OVERRIDDEN_BY_WITHIN_TO_SAME_VALUE';
|
||||
process.env.BEFORE_CALL_KEY_OVERRIDDEN_BY_OPTS_AND_WITHIN = 'OVERRIDDEN_WITHIN';
|
||||
return {} as ProjectConfig;
|
||||
});
|
||||
|
||||
// ensure idempotent (run N times)
|
||||
for (let i = 0; i < 2; i++) {
|
||||
getExpoConfig('', {
|
||||
env: {
|
||||
OPTS_KEY: 'OPTS',
|
||||
BEFORE_CALL_KEY_OVERRIDDEN_BY_OPTS: 'OVERRIDDEN_VALUE',
|
||||
OPTS_KEY_OVERRIDDEN_BY_WITHIN: 'OPTS_KEY_OVERRIDDEN_BY_WITHIN',
|
||||
OPTS_KEY_OVERRIDDEN_BY_WITHIN_TO_SAME_VALUE:
|
||||
'OPTS_KEY_OVERRIDDEN_BY_WITHIN_TO_SAME_VALUE',
|
||||
BEFORE_CALL_KEY_OVERRIDDEN_BY_OPTS_AND_WITHIN: 'OVERRIDDEN_OPTS',
|
||||
},
|
||||
});
|
||||
|
||||
// env from before the call should be restored
|
||||
expect(process.env.BEFORE_CALL_KEY).toEqual('BEFORE');
|
||||
|
||||
// env from before the call but overridden within the call should not be restored
|
||||
expect(process.env.BEFORE_CALL_KEY_OVERRIDDEN_BY_WITHIN).toEqual('OVERRIDDEN_VALUE');
|
||||
|
||||
// env from before the call but overridden by opts should be restored
|
||||
expect(process.env.BEFORE_CALL_KEY_OVERRIDDEN_BY_OPTS).toEqual('BEFORE_OVERRIDDEN_BY_OPTS');
|
||||
|
||||
// env added within the call should be kept
|
||||
expect(process.env.WITHIN_CALL_KEY).toEqual('WITHIN');
|
||||
|
||||
// env added by opts should be removed
|
||||
expect(process.env.OPTS_KEY).toBeUndefined();
|
||||
|
||||
// env added by opts but overridden within the call should be retained and have overridden value
|
||||
expect(process.env.OPTS_KEY_OVERRIDDEN_BY_WITHIN).toEqual('OVERRIDDEN_VALUE');
|
||||
|
||||
// env added by opts but overridden within the call to the same value will be removed
|
||||
// note that this is a known bug/limitation of this approach
|
||||
expect(process.env.OPTS_KEY_OVERRIDDEN_BY_WITHIN_TO_SAME_VALUE).toBeUndefined();
|
||||
|
||||
// env from before but overridden within the call and by opts should retain value from
|
||||
// within the call
|
||||
expect(process.env.BEFORE_CALL_KEY_OVERRIDDEN_BY_OPTS_AND_WITHIN).toEqual(
|
||||
'OVERRIDDEN_WITHIN'
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -1,5 +1,6 @@
|
||||
import { ExpoConfig, getConfig } from '@expo/config';
|
||||
import { Env } from '@expo/eas-build-job';
|
||||
import nullthrows from 'nullthrows';
|
||||
|
||||
export interface ExpoConfigOptions {
|
||||
env?: Env;
|
||||
@@ -9,6 +10,11 @@ export interface ExpoConfigOptions {
|
||||
|
||||
export function getExpoConfig(projectDir: string, opts: ExpoConfigOptions = {}): ExpoConfig {
|
||||
const originalProcessEnv: NodeJS.ProcessEnv = process.env;
|
||||
|
||||
const optsEnvKeys = opts.env ? Object.keys(opts.env) : [];
|
||||
const originalEnvKeys = new Set(Object.keys(process.env));
|
||||
const newKeysAddedToProcessEnv = new Set(optsEnvKeys.filter(k => !originalEnvKeys.has(k)));
|
||||
|
||||
try {
|
||||
process.env = {
|
||||
...process.env,
|
||||
@@ -20,6 +26,24 @@ export function getExpoConfig(projectDir: string, opts: ExpoConfigOptions = {}):
|
||||
});
|
||||
return exp;
|
||||
} finally {
|
||||
process.env = originalProcessEnv;
|
||||
optsEnvKeys.forEach(k => {
|
||||
// if new key added, remove unless it was modified
|
||||
if (newKeysAddedToProcessEnv.has(k)) {
|
||||
if (k in originalProcessEnv) {
|
||||
if (process.env[k] === originalProcessEnv[k]) {
|
||||
delete process.env[k];
|
||||
}
|
||||
} else {
|
||||
if (nullthrows(opts.env)[k] === process.env[k]) {
|
||||
delete process.env[k];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// opts key overrode env key, but only if the value is equal to the one declared by opts
|
||||
if (process.env[k] === nullthrows(opts.env)[k]) {
|
||||
process.env[k] = originalProcessEnv[k];
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -10,10 +10,9 @@ import promiseLimit from 'promise-limit';
|
||||
import { ExpoGraphqlClient } from '../commandUtils/context/contextUtils/createGraphqlClient';
|
||||
import { AssetMetadataStatus, PartialManifestAsset } from '../graphql/generated';
|
||||
import { PublishMutation } from '../graphql/mutations/PublishMutation';
|
||||
import { PresignedPost } from '../graphql/mutations/UploadSessionMutation';
|
||||
import { PublishQuery } from '../graphql/queries/PublishQuery';
|
||||
import Log from '../log';
|
||||
import { uploadWithPresignedPostWithRetryAsync } from '../uploads';
|
||||
import { PresignedPost, uploadWithPresignedPostWithRetryAsync } from '../uploads';
|
||||
import { expoCommandAsync, shouldUseVersionedExpoCLI } from '../utils/expoCli';
|
||||
import chunk from '../utils/expodash/chunk';
|
||||
import uniqBy from '../utils/expodash/uniqBy';
|
||||
|
||||
@@ -22,15 +22,21 @@ export enum ArchiveSourceType {
|
||||
latest,
|
||||
path,
|
||||
buildId,
|
||||
build,
|
||||
buildList,
|
||||
prompt,
|
||||
gcs,
|
||||
}
|
||||
|
||||
export interface ArchiveResolverContext {
|
||||
platform: Platform;
|
||||
projectId: string;
|
||||
nonInteractive: boolean;
|
||||
graphqlClient: ExpoGraphqlClient;
|
||||
}
|
||||
|
||||
interface ArchiveSourceBase {
|
||||
sourceType: ArchiveSourceType;
|
||||
platform: Platform;
|
||||
projectId: string;
|
||||
nonInteractive: boolean;
|
||||
}
|
||||
|
||||
interface ArchiveUrlSource extends ArchiveSourceBase {
|
||||
@@ -52,6 +58,11 @@ interface ArchiveBuildIdSource extends ArchiveSourceBase {
|
||||
id: string;
|
||||
}
|
||||
|
||||
interface ArchiveBuildSource extends ArchiveSourceBase {
|
||||
sourceType: ArchiveSourceType.build;
|
||||
build: BuildFragment;
|
||||
}
|
||||
|
||||
interface ArchiveBuildListSource extends ArchiveSourceBase {
|
||||
sourceType: ArchiveSourceType.buildList;
|
||||
}
|
||||
@@ -60,10 +71,10 @@ interface ArchivePromptSource extends ArchiveSourceBase {
|
||||
sourceType: ArchiveSourceType.prompt;
|
||||
}
|
||||
|
||||
export interface Archive {
|
||||
build?: BuildFragment;
|
||||
source: ArchiveSource;
|
||||
url?: string;
|
||||
interface ArchiveGCSSource extends ArchiveSourceBase {
|
||||
sourceType: ArchiveSourceType.gcs;
|
||||
bucketKey: string;
|
||||
localSource: ArchivePathSource;
|
||||
}
|
||||
|
||||
export type ArchiveSource =
|
||||
@@ -71,54 +82,62 @@ export type ArchiveSource =
|
||||
| ArchiveLatestSource
|
||||
| ArchivePathSource
|
||||
| ArchiveBuildIdSource
|
||||
| ArchiveBuildSource
|
||||
| ArchiveBuildListSource
|
||||
| ArchivePromptSource;
|
||||
| ArchivePromptSource
|
||||
| ArchiveGCSSource;
|
||||
|
||||
export type ResolvedArchiveSource = ArchiveUrlSource | ArchiveGCSSource | ArchiveBuildSource;
|
||||
|
||||
export async function getArchiveAsync(
|
||||
graphqlClient: ExpoGraphqlClient,
|
||||
ctx: ArchiveResolverContext,
|
||||
source: ArchiveSource
|
||||
): Promise<Archive> {
|
||||
): Promise<ResolvedArchiveSource> {
|
||||
switch (source.sourceType) {
|
||||
case ArchiveSourceType.prompt: {
|
||||
return await handlePromptSourceAsync(graphqlClient, source);
|
||||
return await handlePromptSourceAsync(ctx);
|
||||
}
|
||||
case ArchiveSourceType.url: {
|
||||
return await handleUrlSourceAsync(graphqlClient, source);
|
||||
return await handleUrlSourceAsync(ctx, source);
|
||||
}
|
||||
case ArchiveSourceType.latest: {
|
||||
return await handleLatestSourceAsync(graphqlClient, source);
|
||||
return await handleLatestSourceAsync(ctx);
|
||||
}
|
||||
case ArchiveSourceType.path: {
|
||||
return await handlePathSourceAsync(graphqlClient, source);
|
||||
return await handlePathSourceAsync(ctx, source);
|
||||
}
|
||||
case ArchiveSourceType.buildId: {
|
||||
return await handleBuildIdSourceAsync(graphqlClient, source);
|
||||
return await handleBuildIdSourceAsync(ctx, source);
|
||||
}
|
||||
case ArchiveSourceType.buildList: {
|
||||
return await handleBuildListSourceAsync(graphqlClient, source);
|
||||
return await handleBuildListSourceAsync(ctx);
|
||||
}
|
||||
case ArchiveSourceType.gcs: {
|
||||
return source;
|
||||
}
|
||||
case ArchiveSourceType.build: {
|
||||
return source;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function handleUrlSourceAsync(
|
||||
graphqlClient: ExpoGraphqlClient,
|
||||
ctx: ArchiveResolverContext,
|
||||
source: ArchiveUrlSource
|
||||
): Promise<Archive> {
|
||||
): Promise<ResolvedArchiveSource> {
|
||||
const { url } = source;
|
||||
|
||||
if (!validateUrl(url)) {
|
||||
Log.error(chalk.bold(`The URL you provided is invalid: ${url}`));
|
||||
return getArchiveAsync(graphqlClient, {
|
||||
...source,
|
||||
return getArchiveAsync(ctx, {
|
||||
sourceType: ArchiveSourceType.prompt,
|
||||
});
|
||||
}
|
||||
|
||||
const maybeBuildId = isBuildDetailsPage(url);
|
||||
if (maybeBuildId) {
|
||||
if (await askIfUseBuildIdFromUrlAsync(source, maybeBuildId)) {
|
||||
return getArchiveAsync(graphqlClient, {
|
||||
...source,
|
||||
if (await askIfUseBuildIdFromUrlAsync(ctx, source, maybeBuildId)) {
|
||||
return getArchiveAsync(ctx, {
|
||||
sourceType: ArchiveSourceType.buildId,
|
||||
id: maybeBuildId,
|
||||
});
|
||||
@@ -126,20 +145,19 @@ async function handleUrlSourceAsync(
|
||||
}
|
||||
|
||||
return {
|
||||
sourceType: ArchiveSourceType.url,
|
||||
url,
|
||||
source,
|
||||
};
|
||||
}
|
||||
|
||||
async function handleLatestSourceAsync(
|
||||
graphqlClient: ExpoGraphqlClient,
|
||||
source: ArchiveLatestSource
|
||||
): Promise<Archive> {
|
||||
ctx: ArchiveResolverContext
|
||||
): Promise<ResolvedArchiveSource> {
|
||||
try {
|
||||
const [latestBuild] = await getRecentBuildsForSubmissionAsync(
|
||||
graphqlClient,
|
||||
toAppPlatform(source.platform),
|
||||
source.projectId
|
||||
ctx.graphqlClient,
|
||||
toAppPlatform(ctx.platform),
|
||||
ctx.projectId
|
||||
);
|
||||
|
||||
if (!latestBuild) {
|
||||
@@ -148,15 +166,14 @@ async function handleLatestSourceAsync(
|
||||
"Couldn't find any builds for this project on EAS servers. It looks like you haven't run 'eas build' yet."
|
||||
)
|
||||
);
|
||||
return getArchiveAsync(graphqlClient, {
|
||||
...source,
|
||||
return getArchiveAsync(ctx, {
|
||||
sourceType: ArchiveSourceType.prompt,
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
sourceType: ArchiveSourceType.build,
|
||||
build: latestBuild,
|
||||
source,
|
||||
};
|
||||
} catch (err) {
|
||||
Log.error(err);
|
||||
@@ -165,34 +182,37 @@ async function handleLatestSourceAsync(
|
||||
}
|
||||
|
||||
async function handlePathSourceAsync(
|
||||
graphqlClient: ExpoGraphqlClient,
|
||||
ctx: ArchiveResolverContext,
|
||||
source: ArchivePathSource
|
||||
): Promise<Archive> {
|
||||
): Promise<ResolvedArchiveSource> {
|
||||
if (!(await isExistingFileAsync(source.path))) {
|
||||
Log.error(chalk.bold(`${source.path} doesn't exist`));
|
||||
return getArchiveAsync(graphqlClient, {
|
||||
...source,
|
||||
return getArchiveAsync(ctx, {
|
||||
sourceType: ArchiveSourceType.prompt,
|
||||
});
|
||||
}
|
||||
|
||||
Log.log('Uploading your app archive to the Expo Submission Service');
|
||||
const uploadUrl = await uploadAppArchiveAsync(graphqlClient, source.path);
|
||||
Log.log('Uploading your app archive to EAS Submit');
|
||||
const bucketKey = await uploadAppArchiveAsync(ctx.graphqlClient, source.path);
|
||||
return {
|
||||
url: uploadUrl,
|
||||
source,
|
||||
sourceType: ArchiveSourceType.gcs,
|
||||
bucketKey,
|
||||
localSource: {
|
||||
sourceType: ArchiveSourceType.path,
|
||||
path: source.path,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
async function handleBuildIdSourceAsync(
|
||||
graphqlClient: ExpoGraphqlClient,
|
||||
ctx: ArchiveResolverContext,
|
||||
source: ArchiveBuildIdSource
|
||||
): Promise<Archive> {
|
||||
): Promise<ResolvedArchiveSource> {
|
||||
try {
|
||||
const build = await BuildQuery.byIdAsync(graphqlClient, source.id);
|
||||
const build = await BuildQuery.byIdAsync(ctx.graphqlClient, source.id);
|
||||
|
||||
if (build.platform !== toAppPlatform(source.platform)) {
|
||||
const expectedPlatformName = appPlatformDisplayNames[toAppPlatform(source.platform)];
|
||||
if (build.platform !== toAppPlatform(ctx.platform)) {
|
||||
const expectedPlatformName = appPlatformDisplayNames[toAppPlatform(ctx.platform)];
|
||||
const receivedPlatformName = appPlatformDisplayNames[build.platform];
|
||||
Log.error(
|
||||
chalk.bold(
|
||||
@@ -200,15 +220,14 @@ async function handleBuildIdSourceAsync(
|
||||
)
|
||||
);
|
||||
|
||||
return getArchiveAsync(graphqlClient, {
|
||||
...source,
|
||||
return getArchiveAsync(ctx, {
|
||||
sourceType: ArchiveSourceType.prompt,
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
sourceType: ArchiveSourceType.build,
|
||||
build,
|
||||
source,
|
||||
};
|
||||
} catch (err) {
|
||||
Log.error(chalk.bold(`Could not find build with ID ${source.id}`));
|
||||
@@ -220,26 +239,24 @@ async function handleBuildIdSourceAsync(
|
||||
);
|
||||
Log.debug('Original error:', err);
|
||||
|
||||
return getArchiveAsync(graphqlClient, {
|
||||
...source,
|
||||
return getArchiveAsync(ctx, {
|
||||
sourceType: ArchiveSourceType.prompt,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function handleBuildListSourceAsync(
|
||||
graphqlClient: ExpoGraphqlClient,
|
||||
source: ArchiveBuildListSource
|
||||
): Promise<Archive> {
|
||||
ctx: ArchiveResolverContext
|
||||
): Promise<ResolvedArchiveSource> {
|
||||
try {
|
||||
const appPlatform = toAppPlatform(source.platform);
|
||||
const appPlatform = toAppPlatform(ctx.platform);
|
||||
const expiryDate = new Date(); // artifacts expire after 30 days
|
||||
expiryDate.setDate(expiryDate.getDate() - 30);
|
||||
|
||||
const recentBuilds = await getRecentBuildsForSubmissionAsync(
|
||||
graphqlClient,
|
||||
ctx.graphqlClient,
|
||||
appPlatform,
|
||||
source.projectId,
|
||||
ctx.projectId,
|
||||
{
|
||||
limit: BUILD_LIST_ITEM_COUNT,
|
||||
}
|
||||
@@ -252,8 +269,7 @@ async function handleBuildListSourceAsync(
|
||||
"It looks like you haven't run 'eas build' yet."
|
||||
)
|
||||
);
|
||||
return getArchiveAsync(graphqlClient, {
|
||||
...source,
|
||||
return getArchiveAsync(ctx, {
|
||||
sourceType: ArchiveSourceType.prompt,
|
||||
});
|
||||
}
|
||||
@@ -265,8 +281,7 @@ async function handleBuildListSourceAsync(
|
||||
'EAS keeps your build artifacts only for 30 days.'
|
||||
)
|
||||
);
|
||||
return getArchiveAsync(graphqlClient, {
|
||||
...source,
|
||||
return getArchiveAsync(ctx, {
|
||||
sourceType: ArchiveSourceType.prompt,
|
||||
});
|
||||
}
|
||||
@@ -286,15 +301,14 @@ async function handleBuildListSourceAsync(
|
||||
});
|
||||
|
||||
if (selectedBuild == null) {
|
||||
return getArchiveAsync(graphqlClient, {
|
||||
...source,
|
||||
return getArchiveAsync(ctx, {
|
||||
sourceType: ArchiveSourceType.prompt,
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
sourceType: ArchiveSourceType.build,
|
||||
build: selectedBuild,
|
||||
source,
|
||||
};
|
||||
} catch (err) {
|
||||
Log.error(err);
|
||||
@@ -334,9 +348,8 @@ function formatBuildChoice(build: BuildFragment, expiryDate: Date): prompts.Choi
|
||||
}
|
||||
|
||||
async function handlePromptSourceAsync(
|
||||
graphqlClient: ExpoGraphqlClient,
|
||||
source: ArchivePromptSource
|
||||
): Promise<Archive> {
|
||||
ctx: ArchiveResolverContext
|
||||
): Promise<ResolvedArchiveSource> {
|
||||
const { sourceType: sourceTypeRaw } = await promptAsync({
|
||||
name: 'sourceType',
|
||||
type: 'select',
|
||||
@@ -360,31 +373,27 @@ async function handlePromptSourceAsync(
|
||||
const sourceType = sourceTypeRaw as ArchiveSourceType;
|
||||
switch (sourceType) {
|
||||
case ArchiveSourceType.url: {
|
||||
const url = await askForArchiveUrlAsync(source.platform);
|
||||
return getArchiveAsync(graphqlClient, {
|
||||
...source,
|
||||
const url = await askForArchiveUrlAsync(ctx.platform);
|
||||
return getArchiveAsync(ctx, {
|
||||
sourceType: ArchiveSourceType.url,
|
||||
url,
|
||||
});
|
||||
}
|
||||
case ArchiveSourceType.path: {
|
||||
const path = await askForArchivePathAsync(source.platform);
|
||||
return getArchiveAsync(graphqlClient, {
|
||||
...source,
|
||||
const path = await askForArchivePathAsync(ctx.platform);
|
||||
return getArchiveAsync(ctx, {
|
||||
sourceType: ArchiveSourceType.path,
|
||||
path,
|
||||
});
|
||||
}
|
||||
case ArchiveSourceType.buildList: {
|
||||
return getArchiveAsync(graphqlClient, {
|
||||
...source,
|
||||
return getArchiveAsync(ctx, {
|
||||
sourceType: ArchiveSourceType.buildList,
|
||||
});
|
||||
}
|
||||
case ArchiveSourceType.buildId: {
|
||||
const id = await askForBuildIdAsync();
|
||||
return getArchiveAsync(graphqlClient, {
|
||||
...source,
|
||||
return getArchiveAsync(ctx, {
|
||||
sourceType: ArchiveSourceType.buildId,
|
||||
id,
|
||||
});
|
||||
@@ -454,13 +463,14 @@ async function askForBuildIdAsync(): Promise<string> {
|
||||
}
|
||||
|
||||
async function askIfUseBuildIdFromUrlAsync(
|
||||
ctx: ArchiveResolverContext,
|
||||
source: ArchiveUrlSource,
|
||||
buildId: string
|
||||
): Promise<boolean> {
|
||||
const { url } = source;
|
||||
Log.warn(`It seems that you provided a build details page URL: ${url}`);
|
||||
Log.warn('We expected to see the build artifact URL.');
|
||||
if (!source.nonInteractive) {
|
||||
if (!ctx.nonInteractive) {
|
||||
const useAsBuildId = await confirmAsync({
|
||||
message: `Do you want to submit build ${buildId} instead?`,
|
||||
});
|
||||
|
||||
@@ -5,12 +5,15 @@ import { withAnalyticsAsync } from '../analytics/common';
|
||||
import {
|
||||
AndroidSubmissionConfigInput,
|
||||
IosSubmissionConfigInput,
|
||||
SubmissionArchiveSourceInput,
|
||||
SubmissionArchiveSourceType,
|
||||
SubmissionFragment,
|
||||
} from '../graphql/generated';
|
||||
import { toAppPlatform } from '../graphql/types/AppPlatform';
|
||||
import Log from '../log';
|
||||
import { ora } from '../ora';
|
||||
import { appPlatformDisplayNames } from '../platform';
|
||||
import { ArchiveSourceType, ResolvedArchiveSource } from './ArchiveSource';
|
||||
import { SubmissionContext } from './context';
|
||||
|
||||
export interface SubmissionInput<P extends Platform> {
|
||||
@@ -19,6 +22,7 @@ export interface SubmissionInput<P extends Platform> {
|
||||
? AndroidSubmissionConfigInput
|
||||
: IosSubmissionConfigInput;
|
||||
buildId?: string;
|
||||
archiveSource?: SubmissionArchiveSourceInput;
|
||||
}
|
||||
|
||||
interface AnalyticEvents {
|
||||
@@ -71,6 +75,27 @@ export default abstract class BaseSubmitter<
|
||||
resolvedOptions: ResolvedSourceOptions
|
||||
): Promise<SubmissionInput<P>>;
|
||||
|
||||
public formatArchive(
|
||||
archive: ResolvedArchiveSource
|
||||
): Pick<SubmissionInput<P>, 'archiveSource' | 'buildId'> {
|
||||
switch (archive.sourceType) {
|
||||
case ArchiveSourceType.url: {
|
||||
return { archiveSource: { type: SubmissionArchiveSourceType.Url, url: archive.url } };
|
||||
}
|
||||
case ArchiveSourceType.gcs: {
|
||||
return {
|
||||
archiveSource: {
|
||||
type: SubmissionArchiveSourceType.GcsSubmitArchive,
|
||||
bucketKey: archive.bucketKey,
|
||||
},
|
||||
};
|
||||
}
|
||||
case ArchiveSourceType.build: {
|
||||
return { buildId: archive.build.id };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async createSubmissionAsync(
|
||||
submissionInput: SubmissionInput<P>
|
||||
): Promise<SubmissionFragment> {
|
||||
|
||||
@@ -4,17 +4,17 @@ import { vol } from 'memfs';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
|
||||
import { ExpoGraphqlClient } from '../../commandUtils/context/contextUtils/createGraphqlClient';
|
||||
import { AppPlatform, BuildFragment, UploadSessionType } from '../../graphql/generated';
|
||||
import {
|
||||
AppPlatform,
|
||||
BuildFragment,
|
||||
SubmissionArchiveSourceType,
|
||||
UploadSessionType,
|
||||
} from '../../graphql/generated';
|
||||
import { BuildQuery } from '../../graphql/queries/BuildQuery';
|
||||
import { toAppPlatform } from '../../graphql/types/AppPlatform';
|
||||
import { confirmAsync, promptAsync } from '../../prompts';
|
||||
import { uploadFileAtPathToS3Async } from '../../uploads';
|
||||
import {
|
||||
Archive,
|
||||
ArchiveSourceType,
|
||||
BUILD_LIST_ITEM_COUNT,
|
||||
getArchiveAsync,
|
||||
} from '../ArchiveSource';
|
||||
import { uploadFileAtPathToGCSAsync } from '../../uploads';
|
||||
import { ArchiveSourceType, BUILD_LIST_ITEM_COUNT, getArchiveAsync } from '../ArchiveSource';
|
||||
import { getRecentBuildsForSubmissionAsync } from '../utils/builds';
|
||||
|
||||
jest.mock('fs');
|
||||
@@ -28,12 +28,15 @@ jest.mock('../../graphql/queries/BuildQuery', () => ({
|
||||
},
|
||||
}));
|
||||
|
||||
const ARCHIVE_URL = 'https://url.to/archive.tar.gz';
|
||||
const ARCHIVE_SOURCE = {
|
||||
type: SubmissionArchiveSourceType.Url,
|
||||
url: 'https://url.to/archive.tar.gz',
|
||||
};
|
||||
|
||||
const MOCK_BUILD_FRAGMENT: Partial<BuildFragment> = {
|
||||
id: uuidv4(),
|
||||
artifacts: {
|
||||
buildUrl: ARCHIVE_URL,
|
||||
buildUrl: ARCHIVE_SOURCE.url,
|
||||
},
|
||||
appVersion: '1.2.3',
|
||||
platform: AppPlatform.Android,
|
||||
@@ -67,72 +70,82 @@ describe(getArchiveAsync, () => {
|
||||
});
|
||||
|
||||
it('handles URL source', async () => {
|
||||
const archive = await getArchiveAsync(graphqlClient, {
|
||||
...SOURCE_STUB_INPUT,
|
||||
sourceType: ArchiveSourceType.url,
|
||||
url: ARCHIVE_URL,
|
||||
});
|
||||
const archive = await getArchiveAsync(
|
||||
{ ...SOURCE_STUB_INPUT, graphqlClient },
|
||||
{
|
||||
sourceType: ArchiveSourceType.url,
|
||||
url: ARCHIVE_SOURCE.url,
|
||||
}
|
||||
);
|
||||
|
||||
assertArchiveResult(archive, ArchiveSourceType.url);
|
||||
expect(archive.sourceType).toBe(ArchiveSourceType.url);
|
||||
});
|
||||
|
||||
it('prompts again if provided URL is invalid', async () => {
|
||||
jest
|
||||
.mocked(promptAsync)
|
||||
.mockResolvedValueOnce({ sourceType: ArchiveSourceType.url })
|
||||
.mockResolvedValueOnce({ url: ARCHIVE_URL });
|
||||
.mockResolvedValueOnce({ url: ARCHIVE_SOURCE.url });
|
||||
|
||||
const archive = await getArchiveAsync(graphqlClient, {
|
||||
...SOURCE_STUB_INPUT,
|
||||
sourceType: ArchiveSourceType.url,
|
||||
url: 'invalid',
|
||||
});
|
||||
const archive = await getArchiveAsync(
|
||||
{ ...SOURCE_STUB_INPUT, graphqlClient },
|
||||
{
|
||||
sourceType: ArchiveSourceType.url,
|
||||
url: 'invalid',
|
||||
}
|
||||
);
|
||||
|
||||
expect(promptAsync).toHaveBeenCalledTimes(2);
|
||||
assertArchiveResult(archive, ArchiveSourceType.url);
|
||||
expect(archive.sourceType).toBe(ArchiveSourceType.url);
|
||||
});
|
||||
|
||||
it('asks the user if use build id instead of build details page url', async () => {
|
||||
jest.mocked(confirmAsync).mockResolvedValueOnce(true);
|
||||
jest.mocked(BuildQuery.byIdAsync).mockResolvedValueOnce(MOCK_BUILD_FRAGMENT as BuildFragment);
|
||||
|
||||
const archive = await getArchiveAsync(graphqlClient, {
|
||||
...SOURCE_STUB_INPUT,
|
||||
sourceType: ArchiveSourceType.url,
|
||||
url: 'https://expo.dev/accounts/turtle/projects/blah/builds/81da6b36-efe4-4262-8970-84f03efeec81',
|
||||
});
|
||||
const archive = await getArchiveAsync(
|
||||
{ ...SOURCE_STUB_INPUT, graphqlClient },
|
||||
{
|
||||
sourceType: ArchiveSourceType.url,
|
||||
url: 'https://expo.dev/accounts/turtle/projects/blah/builds/81da6b36-efe4-4262-8970-84f03efeec81',
|
||||
}
|
||||
);
|
||||
|
||||
expect(confirmAsync).toHaveBeenCalled();
|
||||
assertArchiveResult(archive, ArchiveSourceType.buildId);
|
||||
expect((archive.source as any).id).toBe('81da6b36-efe4-4262-8970-84f03efeec81');
|
||||
expect(archive.sourceType).toBe(ArchiveSourceType.build);
|
||||
expect((archive as any).build.id).toBe(MOCK_BUILD_FRAGMENT.id);
|
||||
});
|
||||
|
||||
it('handles prompt source', async () => {
|
||||
jest
|
||||
.mocked(promptAsync)
|
||||
.mockResolvedValueOnce({ sourceType: ArchiveSourceType.url })
|
||||
.mockResolvedValueOnce({ url: ARCHIVE_URL });
|
||||
.mockResolvedValueOnce({ url: ARCHIVE_SOURCE.url });
|
||||
|
||||
const archive = await getArchiveAsync(graphqlClient, {
|
||||
...SOURCE_STUB_INPUT,
|
||||
sourceType: ArchiveSourceType.prompt,
|
||||
});
|
||||
const archive = await getArchiveAsync(
|
||||
{ ...SOURCE_STUB_INPUT, graphqlClient },
|
||||
{
|
||||
sourceType: ArchiveSourceType.prompt,
|
||||
}
|
||||
);
|
||||
|
||||
assertArchiveResult(archive, ArchiveSourceType.url);
|
||||
expect(archive.sourceType).toBe(ArchiveSourceType.url);
|
||||
});
|
||||
|
||||
it('handles Build ID source', async () => {
|
||||
const buildId = uuidv4();
|
||||
jest.mocked(BuildQuery.byIdAsync).mockResolvedValueOnce(MOCK_BUILD_FRAGMENT as BuildFragment);
|
||||
|
||||
const archive = await getArchiveAsync(graphqlClient, {
|
||||
...SOURCE_STUB_INPUT,
|
||||
sourceType: ArchiveSourceType.buildId,
|
||||
id: buildId,
|
||||
});
|
||||
const archive = await getArchiveAsync(
|
||||
{ ...SOURCE_STUB_INPUT, graphqlClient },
|
||||
{
|
||||
sourceType: ArchiveSourceType.buildId,
|
||||
id: buildId,
|
||||
}
|
||||
);
|
||||
|
||||
expect(BuildQuery.byIdAsync).toBeCalledWith(graphqlClient, buildId);
|
||||
assertArchiveResult(archive, ArchiveSourceType.buildId);
|
||||
expect(archive.sourceType).toBe(ArchiveSourceType.build);
|
||||
});
|
||||
|
||||
it('prompts again if build with provided ID doesnt exist', async () => {
|
||||
@@ -140,15 +153,17 @@ describe(getArchiveAsync, () => {
|
||||
jest
|
||||
.mocked(promptAsync)
|
||||
.mockResolvedValueOnce({ sourceType: ArchiveSourceType.url })
|
||||
.mockResolvedValueOnce({ url: ARCHIVE_URL });
|
||||
.mockResolvedValueOnce({ url: ARCHIVE_SOURCE.url });
|
||||
|
||||
const archive = await getArchiveAsync(graphqlClient, {
|
||||
...SOURCE_STUB_INPUT,
|
||||
sourceType: ArchiveSourceType.buildId,
|
||||
id: uuidv4(),
|
||||
});
|
||||
const archive = await getArchiveAsync(
|
||||
{ ...SOURCE_STUB_INPUT, graphqlClient },
|
||||
{
|
||||
sourceType: ArchiveSourceType.buildId,
|
||||
id: uuidv4(),
|
||||
}
|
||||
);
|
||||
|
||||
assertArchiveResult(archive, ArchiveSourceType.url);
|
||||
expect(archive.sourceType).toBe(ArchiveSourceType.url);
|
||||
});
|
||||
|
||||
it('handles latest build source', async () => {
|
||||
@@ -157,18 +172,19 @@ describe(getArchiveAsync, () => {
|
||||
.mocked(getRecentBuildsForSubmissionAsync)
|
||||
.mockResolvedValueOnce([MOCK_BUILD_FRAGMENT as BuildFragment]);
|
||||
|
||||
const archive = await getArchiveAsync(graphqlClient, {
|
||||
...SOURCE_STUB_INPUT,
|
||||
projectId,
|
||||
sourceType: ArchiveSourceType.latest,
|
||||
});
|
||||
const archive = await getArchiveAsync(
|
||||
{ ...SOURCE_STUB_INPUT, graphqlClient, projectId },
|
||||
{
|
||||
sourceType: ArchiveSourceType.latest,
|
||||
}
|
||||
);
|
||||
|
||||
expect(getRecentBuildsForSubmissionAsync).toBeCalledWith(
|
||||
graphqlClient,
|
||||
toAppPlatform(SOURCE_STUB_INPUT.platform),
|
||||
projectId
|
||||
);
|
||||
assertArchiveResult(archive, ArchiveSourceType.latest);
|
||||
expect(archive.sourceType).toBe(ArchiveSourceType.build);
|
||||
});
|
||||
|
||||
it('prompts again if no builds exists when selected latest', async () => {
|
||||
@@ -176,14 +192,16 @@ describe(getArchiveAsync, () => {
|
||||
jest
|
||||
.mocked(promptAsync)
|
||||
.mockResolvedValueOnce({ sourceType: ArchiveSourceType.url })
|
||||
.mockResolvedValueOnce({ url: ARCHIVE_URL });
|
||||
.mockResolvedValueOnce({ url: ARCHIVE_SOURCE.url });
|
||||
|
||||
const archive = await getArchiveAsync(graphqlClient, {
|
||||
...SOURCE_STUB_INPUT,
|
||||
sourceType: ArchiveSourceType.latest,
|
||||
});
|
||||
const archive = await getArchiveAsync(
|
||||
{ ...SOURCE_STUB_INPUT, graphqlClient },
|
||||
{
|
||||
sourceType: ArchiveSourceType.latest,
|
||||
}
|
||||
);
|
||||
|
||||
assertArchiveResult(archive, ArchiveSourceType.url);
|
||||
expect(archive.sourceType).toBe(ArchiveSourceType.url);
|
||||
});
|
||||
|
||||
it('handles build-list-select source', async () => {
|
||||
@@ -193,11 +211,12 @@ describe(getArchiveAsync, () => {
|
||||
.mockResolvedValueOnce([MOCK_BUILD_FRAGMENT as BuildFragment]);
|
||||
jest.mocked(promptAsync).mockResolvedValueOnce({ selectedBuild: MOCK_BUILD_FRAGMENT });
|
||||
|
||||
const archive = await getArchiveAsync(graphqlClient, {
|
||||
...SOURCE_STUB_INPUT,
|
||||
projectId,
|
||||
sourceType: ArchiveSourceType.buildList,
|
||||
});
|
||||
const archive = await getArchiveAsync(
|
||||
{ ...SOURCE_STUB_INPUT, graphqlClient, projectId },
|
||||
{
|
||||
sourceType: ArchiveSourceType.buildList,
|
||||
}
|
||||
);
|
||||
|
||||
expect(getRecentBuildsForSubmissionAsync).toBeCalledWith(
|
||||
graphqlClient,
|
||||
@@ -205,7 +224,7 @@ describe(getArchiveAsync, () => {
|
||||
projectId,
|
||||
{ limit: BUILD_LIST_ITEM_COUNT }
|
||||
);
|
||||
assertArchiveResult(archive, ArchiveSourceType.buildList);
|
||||
expect(archive.sourceType).toBe(ArchiveSourceType.build);
|
||||
});
|
||||
|
||||
it('prompts again if all builds have expired', async () => {
|
||||
@@ -218,14 +237,16 @@ describe(getArchiveAsync, () => {
|
||||
jest
|
||||
.mocked(promptAsync)
|
||||
.mockResolvedValueOnce({ sourceType: ArchiveSourceType.url })
|
||||
.mockResolvedValueOnce({ url: ARCHIVE_URL });
|
||||
.mockResolvedValueOnce({ url: ARCHIVE_SOURCE.url });
|
||||
|
||||
const archive = await getArchiveAsync(graphqlClient, {
|
||||
...SOURCE_STUB_INPUT,
|
||||
sourceType: ArchiveSourceType.buildList,
|
||||
});
|
||||
const archive = await getArchiveAsync(
|
||||
{ ...SOURCE_STUB_INPUT, graphqlClient },
|
||||
{
|
||||
sourceType: ArchiveSourceType.buildList,
|
||||
}
|
||||
);
|
||||
|
||||
assertArchiveResult(archive, ArchiveSourceType.url);
|
||||
expect(archive.sourceType).toBe(ArchiveSourceType.url);
|
||||
});
|
||||
|
||||
it('falls back to prompt if user selected "None of the above"', async () => {
|
||||
@@ -236,62 +257,62 @@ describe(getArchiveAsync, () => {
|
||||
.mocked(promptAsync)
|
||||
.mockResolvedValueOnce({ selectedBuild: null })
|
||||
.mockResolvedValueOnce({ sourceType: ArchiveSourceType.url })
|
||||
.mockResolvedValueOnce({ url: ARCHIVE_URL });
|
||||
.mockResolvedValueOnce({ url: ARCHIVE_SOURCE.url });
|
||||
|
||||
const archive = await getArchiveAsync(graphqlClient, {
|
||||
...SOURCE_STUB_INPUT,
|
||||
sourceType: ArchiveSourceType.buildList,
|
||||
});
|
||||
const archive = await getArchiveAsync(
|
||||
{ ...SOURCE_STUB_INPUT, graphqlClient },
|
||||
{
|
||||
sourceType: ArchiveSourceType.buildList,
|
||||
}
|
||||
);
|
||||
|
||||
assertArchiveResult(archive, ArchiveSourceType.url);
|
||||
expect(archive.sourceType).toBe(ArchiveSourceType.url);
|
||||
});
|
||||
|
||||
it('handles path source', async () => {
|
||||
const path = '/archive.apk';
|
||||
await fs.writeFile(path, 'some content');
|
||||
|
||||
jest
|
||||
.mocked(uploadFileAtPathToS3Async)
|
||||
.mockResolvedValueOnce({ url: ARCHIVE_URL, bucketKey: 'wat' });
|
||||
jest.mocked(uploadFileAtPathToGCSAsync).mockResolvedValueOnce('wat');
|
||||
|
||||
const archive = await getArchiveAsync(graphqlClient, {
|
||||
...SOURCE_STUB_INPUT,
|
||||
sourceType: ArchiveSourceType.path,
|
||||
path,
|
||||
});
|
||||
const archive = await getArchiveAsync(
|
||||
{ ...SOURCE_STUB_INPUT, graphqlClient },
|
||||
{
|
||||
sourceType: ArchiveSourceType.path,
|
||||
path,
|
||||
}
|
||||
);
|
||||
|
||||
expect(uploadFileAtPathToS3Async).toBeCalledWith(
|
||||
expect(uploadFileAtPathToGCSAsync).toBeCalledWith(
|
||||
graphqlClient,
|
||||
UploadSessionType.EasSubmitAppArchive,
|
||||
UploadSessionType.EasSubmitGcsAppArchive,
|
||||
path,
|
||||
expect.anything()
|
||||
);
|
||||
assertArchiveResult(archive, ArchiveSourceType.path);
|
||||
expect(archive).toMatchObject({
|
||||
sourceType: ArchiveSourceType.gcs,
|
||||
bucketKey: 'wat',
|
||||
localSource: {
|
||||
sourceType: ArchiveSourceType.path,
|
||||
path,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('prompts again if provided path doesnt exist', async () => {
|
||||
jest
|
||||
.mocked(promptAsync)
|
||||
.mockResolvedValueOnce({ sourceType: ArchiveSourceType.url })
|
||||
.mockResolvedValueOnce({ url: ARCHIVE_URL });
|
||||
.mockResolvedValueOnce({ url: ARCHIVE_SOURCE.url });
|
||||
|
||||
const archive = await getArchiveAsync(graphqlClient, {
|
||||
...SOURCE_STUB_INPUT,
|
||||
sourceType: ArchiveSourceType.path,
|
||||
path: './doesnt/exist.aab',
|
||||
});
|
||||
const archive = await getArchiveAsync(
|
||||
{ ...SOURCE_STUB_INPUT, graphqlClient },
|
||||
{
|
||||
sourceType: ArchiveSourceType.path,
|
||||
path: './doesnt/exist.aab',
|
||||
}
|
||||
);
|
||||
|
||||
assertArchiveResult(archive, ArchiveSourceType.url);
|
||||
expect(archive.sourceType).toBe(ArchiveSourceType.url);
|
||||
});
|
||||
});
|
||||
|
||||
function assertArchiveResult(
|
||||
archive: Archive,
|
||||
expectedSourceType: ArchiveSourceType,
|
||||
expectedUrl: string = ARCHIVE_URL
|
||||
): void {
|
||||
expect(archive.source.sourceType).toBe(expectedSourceType);
|
||||
if (archive.url) {
|
||||
expect(archive.url).toBe(expectedUrl);
|
||||
}
|
||||
}
|
||||
@@ -114,7 +114,7 @@ export default class AndroidSubmitCommand {
|
||||
|
||||
private resolveArchiveSource(): Result<ArchiveSource> {
|
||||
try {
|
||||
return result(resolveArchiveSource(this.ctx, Platform.ANDROID));
|
||||
return result(resolveArchiveSource(this.ctx));
|
||||
} catch (err: any) {
|
||||
return result(err);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
} from '../../graphql/generated';
|
||||
import { SubmissionMutation } from '../../graphql/mutations/SubmissionMutation';
|
||||
import formatFields from '../../utils/formatFields';
|
||||
import { Archive, ArchiveSource, getArchiveAsync } from '../ArchiveSource';
|
||||
import { ArchiveSource, ResolvedArchiveSource, getArchiveAsync } from '../ArchiveSource';
|
||||
import BaseSubmitter, { SubmissionInput } from '../BaseSubmitter';
|
||||
import { SubmissionContext } from '../context';
|
||||
import {
|
||||
@@ -35,7 +35,7 @@ export interface AndroidSubmissionOptions
|
||||
}
|
||||
|
||||
interface ResolvedSourceOptions {
|
||||
archive: Archive;
|
||||
archive: ResolvedArchiveSource;
|
||||
serviceAccountKeyResult: ServiceAccountKeyResult;
|
||||
}
|
||||
|
||||
@@ -47,7 +47,16 @@ export default class AndroidSubmitter extends BaseSubmitter<
|
||||
constructor(ctx: SubmissionContext<Platform.ANDROID>, options: AndroidSubmissionOptions) {
|
||||
const sourceOptionsResolver = {
|
||||
// eslint-disable-next-line async-protect/async-suffix
|
||||
archive: async () => await getArchiveAsync(ctx.graphqlClient, this.options.archiveSource),
|
||||
archive: async () =>
|
||||
await getArchiveAsync(
|
||||
{
|
||||
graphqlClient: ctx.graphqlClient,
|
||||
platform: Platform.ANDROID,
|
||||
projectId: ctx.projectId,
|
||||
nonInteractive: ctx.nonInteractive,
|
||||
},
|
||||
this.options.archiveSource
|
||||
),
|
||||
// eslint-disable-next-line async-protect/async-suffix
|
||||
serviceAccountKeyResult: async () => {
|
||||
return await getServiceAccountKeyResultAsync(this.ctx, this.options.serviceAccountSource);
|
||||
@@ -71,7 +80,7 @@ export default class AndroidSubmitter extends BaseSubmitter<
|
||||
public async createSubmissionInputAsync(
|
||||
resolvedSourceOptions: ResolvedSourceOptions
|
||||
): Promise<SubmissionInput<Platform.ANDROID>> {
|
||||
const submissionConfig = await this.formatSubmissionConfig(this.options, resolvedSourceOptions);
|
||||
const submissionConfig = this.formatSubmissionConfig(this.options, resolvedSourceOptions);
|
||||
|
||||
printSummary(
|
||||
this.prepareSummaryData(this.options, resolvedSourceOptions),
|
||||
@@ -80,7 +89,7 @@ export default class AndroidSubmitter extends BaseSubmitter<
|
||||
return {
|
||||
projectId: this.options.projectId,
|
||||
submissionConfig,
|
||||
buildId: resolvedSourceOptions.archive.build?.id,
|
||||
...this.formatArchive(resolvedSourceOptions.archive),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -88,21 +97,22 @@ export default class AndroidSubmitter extends BaseSubmitter<
|
||||
projectId,
|
||||
submissionConfig,
|
||||
buildId,
|
||||
archiveSource,
|
||||
}: SubmissionInput<Platform.ANDROID>): Promise<SubmissionFragment> {
|
||||
return await SubmissionMutation.createAndroidSubmissionAsync(this.ctx.graphqlClient, {
|
||||
appId: projectId,
|
||||
config: submissionConfig,
|
||||
submittedBuildId: buildId,
|
||||
archiveSource,
|
||||
});
|
||||
}
|
||||
|
||||
private formatSubmissionConfig(
|
||||
options: AndroidSubmissionOptions,
|
||||
{ archive, serviceAccountKeyResult }: ResolvedSourceOptions
|
||||
{ serviceAccountKeyResult }: ResolvedSourceOptions
|
||||
): AndroidSubmissionConfigInput {
|
||||
const { track, releaseStatus, changesNotSentForReview } = options;
|
||||
return {
|
||||
archiveUrl: archive.url,
|
||||
track,
|
||||
changesNotSentForReview,
|
||||
releaseStatus,
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
BuildFragment,
|
||||
SubmissionAndroidReleaseStatus,
|
||||
SubmissionAndroidTrack,
|
||||
SubmissionArchiveSourceType,
|
||||
} from '../../../graphql/generated';
|
||||
import { SubmissionMutation } from '../../../graphql/mutations/SubmissionMutation';
|
||||
import { createTestProject } from '../../../project/__tests__/project-utils';
|
||||
@@ -104,7 +105,7 @@ describe(AndroidSubmitCommand, () => {
|
||||
});
|
||||
|
||||
describe('sending submission', () => {
|
||||
it('sends a request to Submission Service', async () => {
|
||||
it('sends a request to EAS Submit', async () => {
|
||||
const projectId = uuidv4();
|
||||
const graphqlClient = {} as any as ExpoGraphqlClient;
|
||||
const analytics = instance(mock<Analytics>());
|
||||
@@ -134,8 +135,8 @@ describe(AndroidSubmitCommand, () => {
|
||||
|
||||
expect(SubmissionMutation.createAndroidSubmissionAsync).toHaveBeenCalledWith(graphqlClient, {
|
||||
appId: projectId,
|
||||
archiveSource: { type: SubmissionArchiveSourceType.Url, url: 'http://expo.dev/fake.apk' },
|
||||
config: {
|
||||
archiveUrl: 'http://expo.dev/fake.apk',
|
||||
googleServiceAccountKeyJson: fakeFiles['/google-service-account.json'],
|
||||
releaseStatus: SubmissionAndroidReleaseStatus.Draft,
|
||||
track: SubmissionAndroidTrack.Internal,
|
||||
|
||||
@@ -3,10 +3,7 @@ import { Platform } from '@expo/eas-build-job';
|
||||
import { ArchiveSource, ArchiveSourceType, isUuidV4 } from './ArchiveSource';
|
||||
import { SubmissionContext } from './context';
|
||||
|
||||
export function resolveArchiveSource<T extends Platform>(
|
||||
ctx: SubmissionContext<T>,
|
||||
platform: T
|
||||
): ArchiveSource {
|
||||
export function resolveArchiveSource<T extends Platform>(ctx: SubmissionContext<T>): ArchiveSource {
|
||||
const { url, path, id, latest } = ctx.archiveFlags;
|
||||
const chosenOptions = [url, path, id, latest];
|
||||
if (chosenOptions.filter(opt => opt).length > 1) {
|
||||
@@ -17,17 +14,11 @@ export function resolveArchiveSource<T extends Platform>(
|
||||
return {
|
||||
sourceType: ArchiveSourceType.url,
|
||||
url,
|
||||
platform,
|
||||
projectId: ctx.projectId,
|
||||
nonInteractive: ctx.nonInteractive,
|
||||
};
|
||||
} else if (path) {
|
||||
return {
|
||||
sourceType: ArchiveSourceType.path,
|
||||
path,
|
||||
platform,
|
||||
projectId: ctx.projectId,
|
||||
nonInteractive: ctx.nonInteractive,
|
||||
};
|
||||
} else if (id) {
|
||||
if (!isUuidV4(id)) {
|
||||
@@ -36,25 +27,16 @@ export function resolveArchiveSource<T extends Platform>(
|
||||
return {
|
||||
sourceType: ArchiveSourceType.buildId,
|
||||
id,
|
||||
platform,
|
||||
projectId: ctx.projectId,
|
||||
nonInteractive: ctx.nonInteractive,
|
||||
};
|
||||
} else if (latest) {
|
||||
return {
|
||||
sourceType: ArchiveSourceType.latest,
|
||||
platform,
|
||||
projectId: ctx.projectId,
|
||||
nonInteractive: ctx.nonInteractive,
|
||||
};
|
||||
} else if (ctx.nonInteractive) {
|
||||
throw new Error('You need to specify the archive source when running in non-interactive mode ');
|
||||
} else {
|
||||
return {
|
||||
sourceType: ArchiveSourceType.prompt,
|
||||
platform,
|
||||
projectId: ctx.projectId,
|
||||
nonInteractive: ctx.nonInteractive,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -196,7 +196,7 @@ export default class IosSubmitCommand {
|
||||
|
||||
private resolveArchiveSource(): Result<ArchiveSource> {
|
||||
try {
|
||||
return result(resolveArchiveSource(this.ctx, Platform.IOS));
|
||||
return result(resolveArchiveSource(this.ctx));
|
||||
} catch (err: any) {
|
||||
return result(err);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import { MinimalAscApiKey } from '../../credentials/ios/credentials';
|
||||
import { IosSubmissionConfigInput, SubmissionFragment } from '../../graphql/generated';
|
||||
import { SubmissionMutation } from '../../graphql/mutations/SubmissionMutation';
|
||||
import formatFields from '../../utils/formatFields';
|
||||
import { Archive, ArchiveSource, getArchiveAsync } from '../ArchiveSource';
|
||||
import { ArchiveSource, ResolvedArchiveSource, getArchiveAsync } from '../ArchiveSource';
|
||||
import BaseSubmitter, { SubmissionInput } from '../BaseSubmitter';
|
||||
import { SubmissionContext } from '../context';
|
||||
import {
|
||||
@@ -40,7 +40,7 @@ export interface IosSubmissionOptions
|
||||
}
|
||||
|
||||
interface ResolvedSourceOptions {
|
||||
archive: Archive;
|
||||
archive: ResolvedArchiveSource;
|
||||
credentials: {
|
||||
appSpecificPassword?: AppSpecificPasswordCredentials;
|
||||
ascApiKeyResult?: AscApiKeyResult;
|
||||
@@ -55,7 +55,16 @@ export default class IosSubmitter extends BaseSubmitter<
|
||||
constructor(ctx: SubmissionContext<Platform.IOS>, options: IosSubmissionOptions) {
|
||||
const sourceOptionsResolver = {
|
||||
// eslint-disable-next-line async-protect/async-suffix
|
||||
archive: async () => await getArchiveAsync(ctx.graphqlClient, this.options.archiveSource),
|
||||
archive: async () =>
|
||||
await getArchiveAsync(
|
||||
{
|
||||
graphqlClient: ctx.graphqlClient,
|
||||
platform: Platform.IOS,
|
||||
projectId: ctx.projectId,
|
||||
nonInteractive: ctx.nonInteractive,
|
||||
},
|
||||
this.options.archiveSource
|
||||
),
|
||||
// eslint-disable-next-line async-protect/async-suffix
|
||||
credentials: async () => {
|
||||
const maybeAppSpecificPassword = this.options.appSpecificPasswordSource
|
||||
@@ -105,7 +114,7 @@ export default class IosSubmitter extends BaseSubmitter<
|
||||
return {
|
||||
projectId: this.options.projectId,
|
||||
submissionConfig,
|
||||
buildId: resolvedSourceOptions.archive.build?.id,
|
||||
...this.formatArchive(resolvedSourceOptions.archive),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -113,24 +122,25 @@ export default class IosSubmitter extends BaseSubmitter<
|
||||
projectId,
|
||||
submissionConfig,
|
||||
buildId,
|
||||
archiveSource,
|
||||
}: SubmissionInput<Platform.IOS>): Promise<SubmissionFragment> {
|
||||
return await SubmissionMutation.createIosSubmissionAsync(this.ctx.graphqlClient, {
|
||||
appId: projectId,
|
||||
config: submissionConfig,
|
||||
submittedBuildId: buildId,
|
||||
archiveSource,
|
||||
});
|
||||
}
|
||||
|
||||
private formatSubmissionConfig(
|
||||
options: IosSubmissionOptions,
|
||||
{ archive, credentials }: ResolvedSourceOptions
|
||||
{ credentials }: ResolvedSourceOptions
|
||||
): IosSubmissionConfigInput {
|
||||
const { appSpecificPassword, ascApiKeyResult } = credentials;
|
||||
const { appleIdUsername, ascAppIdentifier } = options;
|
||||
return {
|
||||
ascAppIdentifier,
|
||||
appleIdUsername,
|
||||
archiveUrl: archive.url,
|
||||
...(appSpecificPassword ? this.formatAppSpecificPassword(appSpecificPassword) : null),
|
||||
...(ascApiKeyResult?.result ? this.formatAscApiKeyResult(ascApiKeyResult.result) : null),
|
||||
};
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
jester as mockJester,
|
||||
testProjectId,
|
||||
} from '../../../credentials/__tests__/fixtures-constants';
|
||||
import { SubmissionArchiveSourceType } from '../../../graphql/generated';
|
||||
import { SubmissionMutation } from '../../../graphql/mutations/SubmissionMutation';
|
||||
import { createTestProject } from '../../../project/__tests__/project-utils';
|
||||
import { getOwnerAccountForProjectIdAsync } from '../../../project/projectUtils';
|
||||
@@ -80,7 +81,7 @@ describe(IosSubmitCommand, () => {
|
||||
});
|
||||
|
||||
describe('sending submission', () => {
|
||||
it('sends a request to Submission Service', async () => {
|
||||
it('sends a request to EAS Submit', async () => {
|
||||
const projectId = uuidv4();
|
||||
const graphqlClient = {} as any as ExpoGraphqlClient;
|
||||
const analytics = instance(mock<Analytics>());
|
||||
@@ -110,8 +111,8 @@ describe(IosSubmitCommand, () => {
|
||||
|
||||
expect(SubmissionMutation.createIosSubmissionAsync).toHaveBeenCalledWith(graphqlClient, {
|
||||
appId: projectId,
|
||||
archiveSource: { type: SubmissionArchiveSourceType.Url, url: 'http://expo.dev/fake.ipa' },
|
||||
config: {
|
||||
archiveUrl: 'http://expo.dev/fake.ipa',
|
||||
appleIdUsername: '[email protected]',
|
||||
appleAppSpecificPassword: 'supersecret',
|
||||
ascAppIdentifier: '12345678',
|
||||
|
||||
@@ -2,7 +2,7 @@ import fs from 'fs-extra';
|
||||
|
||||
import { ExpoGraphqlClient } from '../../commandUtils/context/contextUtils/createGraphqlClient';
|
||||
import { UploadSessionType } from '../../graphql/generated';
|
||||
import { uploadFileAtPathToS3Async } from '../../uploads';
|
||||
import { uploadFileAtPathToGCSAsync } from '../../uploads';
|
||||
import { createProgressTracker } from '../../utils/progress';
|
||||
|
||||
export async function isExistingFileAsync(filePath: string): Promise<boolean> {
|
||||
@@ -19,9 +19,9 @@ export async function uploadAppArchiveAsync(
|
||||
path: string
|
||||
): Promise<string> {
|
||||
const fileSize = (await fs.stat(path)).size;
|
||||
const { url } = await uploadFileAtPathToS3Async(
|
||||
const bucketKey = await uploadFileAtPathToGCSAsync(
|
||||
graphqlClient,
|
||||
UploadSessionType.EasSubmitAppArchive,
|
||||
UploadSessionType.EasSubmitGcsAppArchive,
|
||||
path,
|
||||
createProgressTracker({
|
||||
total: fileSize,
|
||||
@@ -29,5 +29,5 @@ export async function uploadAppArchiveAsync(
|
||||
completedMessage: 'Uploaded to EAS Submit',
|
||||
})
|
||||
);
|
||||
return url;
|
||||
return bucketKey;
|
||||
}
|
||||
@@ -3,7 +3,7 @@ import chalk from 'chalk';
|
||||
import { AppPlatform, BuildFragment } from '../../graphql/generated';
|
||||
import Log from '../../log';
|
||||
import formatFields from '../../utils/formatFields';
|
||||
import { Archive, ArchiveSourceType } from '../ArchiveSource';
|
||||
import { ArchiveSourceType, ResolvedArchiveSource } from '../ArchiveSource';
|
||||
export interface ArchiveSourceSummaryFields {
|
||||
archiveUrl?: string;
|
||||
archivePath?: string;
|
||||
@@ -43,19 +43,20 @@ function formatSubmissionBuildSummary(build: BuildFragment): string {
|
||||
);
|
||||
}
|
||||
|
||||
export function formatArchiveSourceSummary({ source, build }: Archive): ArchiveSourceSummaryFields {
|
||||
export function formatArchiveSourceSummary(
|
||||
archive: ResolvedArchiveSource
|
||||
): ArchiveSourceSummaryFields {
|
||||
const summarySlice: ArchiveSourceSummaryFields = {};
|
||||
|
||||
switch (source.sourceType) {
|
||||
case ArchiveSourceType.path:
|
||||
summarySlice.archivePath = source.path;
|
||||
switch (archive.sourceType) {
|
||||
case ArchiveSourceType.gcs:
|
||||
summarySlice.archivePath = archive.localSource.path;
|
||||
break;
|
||||
case ArchiveSourceType.url:
|
||||
summarySlice.archiveUrl = source.url;
|
||||
summarySlice.archiveUrl = archive.url;
|
||||
break;
|
||||
case ArchiveSourceType.buildId:
|
||||
case ArchiveSourceType.latest:
|
||||
summarySlice.formattedBuild = formatSubmissionBuildSummary(build!);
|
||||
case ArchiveSourceType.build:
|
||||
summarySlice.formattedBuild = formatSubmissionBuildSummary(archive.build!);
|
||||
break;
|
||||
}
|
||||
return summarySlice;
|
||||
|
||||
@@ -1,37 +1,29 @@
|
||||
import assert from 'assert';
|
||||
import FormData from 'form-data';
|
||||
import fs from 'fs-extra';
|
||||
import { Response } from 'node-fetch';
|
||||
import nullthrows from 'nullthrows';
|
||||
import promiseRetry from 'promise-retry';
|
||||
import { URL } from 'url';
|
||||
|
||||
import { ExpoGraphqlClient } from './commandUtils/context/contextUtils/createGraphqlClient';
|
||||
import fetch from './fetch';
|
||||
import { UploadSessionType } from './graphql/generated';
|
||||
import { PresignedPost, UploadSessionMutation } from './graphql/mutations/UploadSessionMutation';
|
||||
import { SignedUrl, UploadSessionMutation } from './graphql/mutations/UploadSessionMutation';
|
||||
import { ProgressHandler } from './utils/progress';
|
||||
|
||||
export async function uploadFileAtPathToS3Async(
|
||||
export interface PresignedPost {
|
||||
url: string;
|
||||
fields: Record<string, string>;
|
||||
}
|
||||
|
||||
export async function uploadFileAtPathToGCSAsync(
|
||||
graphqlClient: ExpoGraphqlClient,
|
||||
type: UploadSessionType,
|
||||
path: string,
|
||||
handleProgressEvent: ProgressHandler
|
||||
): Promise<{ url: string; bucketKey: string }> {
|
||||
const presignedPost = await UploadSessionMutation.createUploadSessionAsync(graphqlClient, type);
|
||||
assert(presignedPost.fields.key, 'key is not specified in in presigned post');
|
||||
): Promise<string> {
|
||||
const signedUrl = await UploadSessionMutation.createUploadSessionAsync(graphqlClient, type);
|
||||
|
||||
const response = await uploadWithPresignedPostWithProgressAsync(
|
||||
path,
|
||||
presignedPost,
|
||||
handleProgressEvent
|
||||
);
|
||||
const location = nullthrows(
|
||||
response.headers.get('location'),
|
||||
`location does not exist in response headers (make sure you're uploading to AWS S3)`
|
||||
);
|
||||
const url = fixS3Url(location);
|
||||
return { url, bucketKey: presignedPost.fields.key };
|
||||
await uploadWithSignedUrlWithProgressAsync(path, signedUrl, handleProgressEvent);
|
||||
return signedUrl.bucketKey;
|
||||
}
|
||||
|
||||
export async function uploadWithPresignedPostWithRetryAsync(
|
||||
@@ -72,10 +64,10 @@ export async function uploadWithPresignedPostWithRetryAsync(
|
||||
);
|
||||
}
|
||||
|
||||
async function createPresignedPostFormDataAsync(
|
||||
async function uploadWithPresignedPostAsync(
|
||||
file: string,
|
||||
presignedPost: PresignedPost
|
||||
): Promise<{ form: FormData; fileSize: number }> {
|
||||
): Promise<Response> {
|
||||
const fileStat = await fs.stat(file);
|
||||
const fileSize = fileStat.size;
|
||||
const form = new FormData();
|
||||
@@ -83,14 +75,6 @@ async function createPresignedPostFormDataAsync(
|
||||
form.append(fieldKey, fieldValue);
|
||||
}
|
||||
form.append('file', fs.createReadStream(file), { knownLength: fileSize });
|
||||
return { form, fileSize };
|
||||
}
|
||||
|
||||
async function uploadWithPresignedPostAsync(
|
||||
file: string,
|
||||
presignedPost: PresignedPost
|
||||
): Promise<Response> {
|
||||
const { form } = await createPresignedPostFormDataAsync(file, presignedPost);
|
||||
const formHeaders = form.getHeaders();
|
||||
return await fetch(presignedPost.url, {
|
||||
method: 'POST',
|
||||
@@ -101,23 +85,25 @@ async function uploadWithPresignedPostAsync(
|
||||
});
|
||||
}
|
||||
|
||||
async function uploadWithPresignedPostWithProgressAsync(
|
||||
async function uploadWithSignedUrlWithProgressAsync(
|
||||
file: string,
|
||||
presignedPost: PresignedPost,
|
||||
signedUrl: SignedUrl,
|
||||
handleProgressEvent: ProgressHandler
|
||||
): Promise<Response> {
|
||||
const { form, fileSize } = await createPresignedPostFormDataAsync(file, presignedPost);
|
||||
const formHeaders = form.getHeaders();
|
||||
const uploadPromise = fetch(presignedPost.url, {
|
||||
method: 'POST',
|
||||
body: form,
|
||||
const fileStat = await fs.stat(file);
|
||||
const fileSize = fileStat.size;
|
||||
|
||||
const readStream = fs.createReadStream(file);
|
||||
const uploadPromise = fetch(signedUrl.url, {
|
||||
method: 'PUT',
|
||||
body: readStream,
|
||||
headers: {
|
||||
...formHeaders,
|
||||
...signedUrl.headers,
|
||||
},
|
||||
});
|
||||
|
||||
let currentSize = 0;
|
||||
form.addListener('data', (chunk: Buffer) => {
|
||||
readStream.addListener('data', (chunk: Buffer) => {
|
||||
currentSize += Buffer.byteLength(chunk);
|
||||
handleProgressEvent({
|
||||
progress: {
|
||||
@@ -136,14 +122,3 @@ async function uploadWithPresignedPostWithProgressAsync(
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* S3 returns broken URLs, sth like:
|
||||
* https://submission-service-archives.s3.amazonaws.com/production%2Fdc98ca84-1473-4cb3-ae81-8c7b291cb27e%2F4424aa95-b985-4e2f-8755-9507b1037c1c
|
||||
* This function replaces %2F with /.
|
||||
*/
|
||||
export function fixS3Url(archiveUrl: string): string {
|
||||
const parsed = new URL(archiveUrl);
|
||||
parsed.pathname = decodeURIComponent(parsed.pathname);
|
||||
return parsed.toString();
|
||||
}
|
||||
Reference in new issue
Block a user