eas-cli 2.7.1 → 2.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/README.md +78 -53
  2. package/build/branch/queries.d.ts +1 -0
  3. package/build/branch/queries.js +2 -2
  4. package/build/build/build.d.ts +1 -1
  5. package/build/build/build.js +2 -2
  6. package/build/build/createContext.js +1 -0
  7. package/build/build/graphql.js +6 -0
  8. package/build/build/local.js +1 -1
  9. package/build/build/queries.d.ts +4 -2
  10. package/build/build/queries.js +32 -7
  11. package/build/build/runBuildAndSubmit.js +31 -2
  12. package/build/commands/build/run.d.ts +0 -1
  13. package/build/commands/build/run.js +32 -12
  14. package/build/commands/submit.js +1 -1
  15. package/build/commands/update/index.js +20 -8
  16. package/build/devices/utils/formatDevice.js +1 -2
  17. package/build/graphql/generated.d.ts +15 -0
  18. package/build/graphql/generated.js +9 -2
  19. package/build/graphql/mutations/SubmissionMutation.js +14 -2
  20. package/build/graphql/mutations/UploadSessionMutation.d.ts +4 -3
  21. package/build/project/applicationIdentifier.js +6 -2
  22. package/build/run/android/aapt.d.ts +5 -0
  23. package/build/run/android/aapt.js +51 -0
  24. package/build/run/android/adb.d.ts +23 -0
  25. package/build/run/android/adb.js +120 -0
  26. package/build/run/android/emulator.d.ts +7 -0
  27. package/build/run/android/emulator.js +109 -0
  28. package/build/run/android/run.d.ts +1 -1
  29. package/build/run/android/run.js +10 -3
  30. package/build/run/android/sdk.d.ts +3 -0
  31. package/build/run/android/sdk.js +29 -0
  32. package/build/run/android/systemRequirements.d.ts +1 -0
  33. package/build/run/android/systemRequirements.js +24 -0
  34. package/build/run/ios/simulator.js +1 -1
  35. package/build/run/utils.d.ts +2 -0
  36. package/build/run/utils.js +20 -0
  37. package/build/submit/ArchiveSource.d.ts +20 -10
  38. package/build/submit/ArchiveSource.js +59 -60
  39. package/build/submit/BaseSubmitter.d.ts +4 -1
  40. package/build/submit/BaseSubmitter.js +20 -0
  41. package/build/submit/android/AndroidSubmitCommand.js +1 -2
  42. package/build/submit/android/AndroidSubmitter.d.ts +3 -3
  43. package/build/submit/android/AndroidSubmitter.js +12 -7
  44. package/build/submit/commons.d.ts +1 -1
  45. package/build/submit/commons.js +1 -16
  46. package/build/submit/ios/IosSubmitCommand.js +1 -2
  47. package/build/submit/ios/IosSubmitter.d.ts +3 -3
  48. package/build/submit/ios/IosSubmitter.js +11 -6
  49. package/build/submit/utils/files.js +2 -2
  50. package/build/submit/utils/summary.d.ts +2 -2
  51. package/build/submit/utils/summary.js +7 -8
  52. package/build/uploads.d.ts +4 -10
  53. package/build/uploads.js +16 -36
  54. package/build/utils/download.d.ts +3 -2
  55. package/build/utils/download.js +60 -36
  56. package/build/utils/paths.d.ts +7 -7
  57. package/build/utils/paths.js +3 -1
  58. package/build/utils/progress.d.ts +1 -1
  59. package/build/utils/progress.js +6 -4
  60. package/oclif.manifest.json +1 -1
  61. package/package.json +3 -3
@@ -1,16 +1,10 @@
1
1
  import { Response } from 'node-fetch';
2
2
  import { ExpoGraphqlClient } from './commandUtils/context/contextUtils/createGraphqlClient';
3
3
  import { UploadSessionType } from './graphql/generated';
4
- import { PresignedPost } from './graphql/mutations/UploadSessionMutation';
5
4
  import { ProgressHandler } from './utils/progress';
6
- export declare function uploadFileAtPathToS3Async(graphqlClient: ExpoGraphqlClient, type: UploadSessionType, path: string, handleProgressEvent: ProgressHandler): Promise<{
5
+ export interface PresignedPost {
7
6
  url: string;
8
- bucketKey: string;
9
- }>;
7
+ fields: Record<string, string>;
8
+ }
9
+ export declare function uploadFileAtPathToGCSAsync(graphqlClient: ExpoGraphqlClient, type: UploadSessionType, path: string, handleProgressEvent: ProgressHandler): Promise<string>;
10
10
  export declare function uploadWithPresignedPostWithRetryAsync(file: string, presignedPost: PresignedPost): Promise<Response>;
11
- /**
12
- * S3 returns broken URLs, sth like:
13
- * https://submission-service-archives.s3.amazonaws.com/production%2Fdc98ca84-1473-4cb3-ae81-8c7b291cb27e%2F4424aa95-b985-4e2f-8755-9507b1037c1c
14
- * This function replaces %2F with /.
15
- */
16
- export declare function fixS3Url(archiveUrl: string): string;
package/build/uploads.js CHANGED
@@ -1,24 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fixS3Url = exports.uploadWithPresignedPostWithRetryAsync = exports.uploadFileAtPathToS3Async = void 0;
3
+ exports.uploadWithPresignedPostWithRetryAsync = exports.uploadFileAtPathToGCSAsync = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const assert_1 = tslib_1.__importDefault(require("assert"));
6
5
  const form_data_1 = tslib_1.__importDefault(require("form-data"));
7
6
  const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
8
- const nullthrows_1 = tslib_1.__importDefault(require("nullthrows"));
9
7
  const promise_retry_1 = tslib_1.__importDefault(require("promise-retry"));
10
- const url_1 = require("url");
11
8
  const fetch_1 = tslib_1.__importDefault(require("./fetch"));
12
9
  const UploadSessionMutation_1 = require("./graphql/mutations/UploadSessionMutation");
13
- async function uploadFileAtPathToS3Async(graphqlClient, type, path, handleProgressEvent) {
14
- const presignedPost = await UploadSessionMutation_1.UploadSessionMutation.createUploadSessionAsync(graphqlClient, type);
15
- (0, assert_1.default)(presignedPost.fields.key, 'key is not specified in in presigned post');
16
- const response = await uploadWithPresignedPostWithProgressAsync(path, presignedPost, handleProgressEvent);
17
- const location = (0, nullthrows_1.default)(response.headers.get('location'), `location does not exist in response headers (make sure you're uploading to AWS S3)`);
18
- const url = fixS3Url(location);
19
- return { url, bucketKey: presignedPost.fields.key };
10
+ async function uploadFileAtPathToGCSAsync(graphqlClient, type, path, handleProgressEvent) {
11
+ const signedUrl = await UploadSessionMutation_1.UploadSessionMutation.createUploadSessionAsync(graphqlClient, type);
12
+ await uploadWithSignedUrlWithProgressAsync(path, signedUrl, handleProgressEvent);
13
+ return signedUrl.bucketKey;
20
14
  }
21
- exports.uploadFileAtPathToS3Async = uploadFileAtPathToS3Async;
15
+ exports.uploadFileAtPathToGCSAsync = uploadFileAtPathToGCSAsync;
22
16
  async function uploadWithPresignedPostWithRetryAsync(file, presignedPost) {
23
17
  return await (0, promise_retry_1.default)(async (retry) => {
24
18
  // retry fetch errors (usually connection or DNS errors)
@@ -48,7 +42,7 @@ async function uploadWithPresignedPostWithRetryAsync(file, presignedPost) {
48
42
  });
49
43
  }
50
44
  exports.uploadWithPresignedPostWithRetryAsync = uploadWithPresignedPostWithRetryAsync;
51
- async function createPresignedPostFormDataAsync(file, presignedPost) {
45
+ async function uploadWithPresignedPostAsync(file, presignedPost) {
52
46
  const fileStat = await fs_extra_1.default.stat(file);
53
47
  const fileSize = fileStat.size;
54
48
  const form = new form_data_1.default();
@@ -56,10 +50,6 @@ async function createPresignedPostFormDataAsync(file, presignedPost) {
56
50
  form.append(fieldKey, fieldValue);
57
51
  }
58
52
  form.append('file', fs_extra_1.default.createReadStream(file), { knownLength: fileSize });
59
- return { form, fileSize };
60
- }
61
- async function uploadWithPresignedPostAsync(file, presignedPost) {
62
- const { form } = await createPresignedPostFormDataAsync(file, presignedPost);
63
53
  const formHeaders = form.getHeaders();
64
54
  return await (0, fetch_1.default)(presignedPost.url, {
65
55
  method: 'POST',
@@ -69,18 +59,19 @@ async function uploadWithPresignedPostAsync(file, presignedPost) {
69
59
  },
70
60
  });
71
61
  }
72
- async function uploadWithPresignedPostWithProgressAsync(file, presignedPost, handleProgressEvent) {
73
- const { form, fileSize } = await createPresignedPostFormDataAsync(file, presignedPost);
74
- const formHeaders = form.getHeaders();
75
- const uploadPromise = (0, fetch_1.default)(presignedPost.url, {
76
- method: 'POST',
77
- body: form,
62
+ async function uploadWithSignedUrlWithProgressAsync(file, signedUrl, handleProgressEvent) {
63
+ const fileStat = await fs_extra_1.default.stat(file);
64
+ const fileSize = fileStat.size;
65
+ const readStream = fs_extra_1.default.createReadStream(file);
66
+ const uploadPromise = (0, fetch_1.default)(signedUrl.url, {
67
+ method: 'PUT',
68
+ body: readStream,
78
69
  headers: {
79
- ...formHeaders,
70
+ ...signedUrl.headers,
80
71
  },
81
72
  });
82
73
  let currentSize = 0;
83
- form.addListener('data', (chunk) => {
74
+ readStream.addListener('data', (chunk) => {
84
75
  currentSize += Buffer.byteLength(chunk);
85
76
  handleProgressEvent({
86
77
  progress: {
@@ -100,14 +91,3 @@ async function uploadWithPresignedPostWithProgressAsync(file, presignedPost, han
100
91
  throw error;
101
92
  }
102
93
  }
103
- /**
104
- * S3 returns broken URLs, sth like:
105
- * https://submission-service-archives.s3.amazonaws.com/production%2Fdc98ca84-1473-4cb3-ae81-8c7b291cb27e%2F4424aa95-b985-4e2f-8755-9507b1037c1c
106
- * This function replaces %2F with /.
107
- */
108
- function fixS3Url(archiveUrl) {
109
- const parsed = new url_1.URL(archiveUrl);
110
- parsed.pathname = decodeURIComponent(parsed.pathname);
111
- return parsed.toString();
112
- }
113
- exports.fixS3Url = fixS3Url;
@@ -1,2 +1,3 @@
1
- export declare function downloadAndExtractAppAsync(url: string, applicationExtension: string): Promise<string>;
2
- export declare function extractAppFromLocalArchiveAsync(appArchivePath: string, applicationExtension: string): Promise<string>;
1
+ import { AppPlatform } from '../graphql/generated';
2
+ export declare function downloadAndMaybeExtractAppAsync(url: string, platform: AppPlatform, cachedAppPath?: string): Promise<string>;
3
+ export declare function extractAppFromLocalArchiveAsync(appArchivePath: string, platform: AppPlatform): Promise<string>;
@@ -1,22 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.extractAppFromLocalArchiveAsync = exports.downloadAndExtractAppAsync = void 0;
3
+ exports.extractAppFromLocalArchiveAsync = exports.downloadAndMaybeExtractAppAsync = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const spawn_async_1 = tslib_1.__importDefault(require("@expo/spawn-async"));
6
- const cli_progress_1 = tslib_1.__importDefault(require("cli-progress"));
7
6
  const fast_glob_1 = tslib_1.__importDefault(require("fast-glob"));
8
- const fs_1 = tslib_1.__importDefault(require("fs"));
7
+ const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
9
8
  const path_1 = tslib_1.__importDefault(require("path"));
10
9
  const stream_1 = require("stream");
11
10
  const tar_1 = require("tar");
12
11
  const util_1 = require("util");
13
12
  const uuid_1 = require("uuid");
14
13
  const fetch_1 = tslib_1.__importDefault(require("../fetch"));
14
+ const generated_1 = require("../graphql/generated");
15
15
  const log_1 = tslib_1.__importDefault(require("../log"));
16
+ const files_1 = require("./files");
16
17
  const paths_1 = require("./paths");
18
+ const progress_1 = require("./progress");
17
19
  const pipeline = (0, util_1.promisify)(stream_1.Stream.pipeline);
18
20
  function wrapFetchWithProgress() {
19
- return async (url, init, onProgressCallback) => {
21
+ let didProgressBarFinish = false;
22
+ return async (url, init, progressHandler) => {
20
23
  const response = await (0, fetch_1.default)(url, init);
21
24
  if (response.ok) {
22
25
  const totalDownloadSize = response.headers.get('Content-Length');
@@ -31,7 +34,15 @@ function wrapFetchWithProgress() {
31
34
  length += chunkLength;
32
35
  }
33
36
  const progress = length / total;
34
- onProgressCallback(progress, total, length);
37
+ if (!didProgressBarFinish) {
38
+ progressHandler({
39
+ progress: { total, percent: progress, transferred: length },
40
+ isComplete: total === length,
41
+ });
42
+ if (total === length) {
43
+ didProgressBarFinish = true;
44
+ }
45
+ }
35
46
  };
36
47
  response.body.on('data', chunk => {
37
48
  onProgress(chunk.length);
@@ -43,46 +54,59 @@ function wrapFetchWithProgress() {
43
54
  return response;
44
55
  };
45
56
  }
46
- async function downloadFileWithProgressBarAsync(url, outputPath, infoMessage) {
57
+ async function downloadFileWithProgressTrackerAsync(url, outputPath, progressTrackerMessage, progressTrackerCompletedMessage) {
47
58
  log_1.default.newLine();
48
- log_1.default.log(infoMessage ? infoMessage : `Downloading file from ${url}...`);
49
- const downloadProgressBar = new cli_progress_1.default.SingleBar({ format: '|{bar}|' }, cli_progress_1.default.Presets.rect);
50
- let downloadProgressBarStarted = false;
51
- const response = await wrapFetchWithProgress()(url, {
52
- timeout: 1000 * 60 * 5, // 5 minutes
53
- }, (_progress, total, loaded) => {
54
- if (!downloadProgressBarStarted) {
55
- downloadProgressBar.start(total, loaded);
56
- downloadProgressBarStarted = true;
57
- }
58
- else if (loaded < total) {
59
- downloadProgressBar.update(loaded);
59
+ try {
60
+ const response = await wrapFetchWithProgress()(url, {
61
+ timeout: 1000 * 60 * 5, // 5 minutes
62
+ }, (0, progress_1.createProgressTracker)({
63
+ message: progressTrackerMessage,
64
+ completedMessage: progressTrackerCompletedMessage,
65
+ }));
66
+ if (!response.ok) {
67
+ throw new Error(`Failed to download file from ${url}`);
60
68
  }
61
- else {
62
- downloadProgressBar.stop();
69
+ await pipeline(response.body, fs_extra_1.default.createWriteStream(outputPath));
70
+ }
71
+ catch (error) {
72
+ if (await fs_extra_1.default.pathExists(outputPath)) {
73
+ await fs_extra_1.default.remove(outputPath);
63
74
  }
64
- });
65
- if (!response.ok) {
66
- throw new Error(`Failed to download file from ${url}`);
75
+ throw error;
76
+ }
77
+ }
78
+ async function maybeCacheAppAsync(appPath, cachedAppPath) {
79
+ if (cachedAppPath) {
80
+ await fs_extra_1.default.ensureDir(path_1.default.dirname(cachedAppPath));
81
+ await fs_extra_1.default.move(appPath, cachedAppPath);
82
+ return cachedAppPath;
67
83
  }
68
- await pipeline(response.body, fs_1.default.createWriteStream(outputPath));
84
+ return appPath;
69
85
  }
70
- async function downloadAndExtractAppAsync(url, applicationExtension) {
86
+ async function downloadAndMaybeExtractAppAsync(url, platform, cachedAppPath) {
71
87
  const outputDir = path_1.default.join((0, paths_1.getTmpDirectory)(), (0, uuid_1.v4)());
72
- await fs_1.default.promises.mkdir(outputDir, { recursive: true });
73
- const tmpArchivePathDir = path_1.default.join((0, paths_1.getTmpDirectory)(), (0, uuid_1.v4)());
74
- await fs_1.default.promises.mkdir(tmpArchivePathDir, { recursive: true });
75
- const tmpArchivePath = path_1.default.join(tmpArchivePathDir, `${(0, uuid_1.v4)()}.tar.gz`);
76
- await downloadFileWithProgressBarAsync(url, tmpArchivePath, 'Downloading app archive...');
77
- await tarExtractAsync(tmpArchivePath, outputDir);
78
- return await getAppPathAsync(outputDir, applicationExtension);
88
+ await fs_extra_1.default.promises.mkdir(outputDir, { recursive: true });
89
+ if (url.endsWith('apk')) {
90
+ const apkFilePath = path_1.default.join(outputDir, `${(0, uuid_1.v4)()}.apk`);
91
+ await downloadFileWithProgressTrackerAsync(url, apkFilePath, (ratio, total) => `Downloading app (${(0, files_1.formatBytes)(total * ratio)} / ${(0, files_1.formatBytes)(total)})`, 'Successfully downloaded app');
92
+ return maybeCacheAppAsync(apkFilePath, cachedAppPath);
93
+ }
94
+ else {
95
+ const tmpArchivePathDir = path_1.default.join((0, paths_1.getTmpDirectory)(), (0, uuid_1.v4)());
96
+ await fs_extra_1.default.mkdir(tmpArchivePathDir, { recursive: true });
97
+ const tmpArchivePath = path_1.default.join(tmpArchivePathDir, `${(0, uuid_1.v4)()}.tar.gz`);
98
+ await downloadFileWithProgressTrackerAsync(url, tmpArchivePath, (ratio, total) => `Downloading app archive (${(0, files_1.formatBytes)(total * ratio)} / ${(0, files_1.formatBytes)(total)})`, 'Successfully downloaded app archive');
99
+ await tarExtractAsync(tmpArchivePath, outputDir);
100
+ const appPath = await getAppPathAsync(outputDir, platform === generated_1.AppPlatform.Ios ? 'app' : 'apk');
101
+ return maybeCacheAppAsync(appPath, cachedAppPath);
102
+ }
79
103
  }
80
- exports.downloadAndExtractAppAsync = downloadAndExtractAppAsync;
81
- async function extractAppFromLocalArchiveAsync(appArchivePath, applicationExtension) {
104
+ exports.downloadAndMaybeExtractAppAsync = downloadAndMaybeExtractAppAsync;
105
+ async function extractAppFromLocalArchiveAsync(appArchivePath, platform) {
82
106
  const outputDir = path_1.default.join((0, paths_1.getTmpDirectory)(), (0, uuid_1.v4)());
83
- await fs_1.default.promises.mkdir(outputDir, { recursive: true });
107
+ await fs_extra_1.default.promises.mkdir(outputDir, { recursive: true });
84
108
  await tarExtractAsync(appArchivePath, outputDir);
85
- return await getAppPathAsync(outputDir, applicationExtension);
109
+ return await getAppPathAsync(outputDir, platform === generated_1.AppPlatform.Android ? 'apk' : 'app');
86
110
  }
87
111
  exports.extractAppFromLocalArchiveAsync = extractAppFromLocalArchiveAsync;
88
112
  async function getAppPathAsync(outputDir, applicationExtension) {
@@ -1,7 +1,7 @@
1
- declare const getStateJsonPath: () => string;
2
- declare const getDataDirectory: () => string;
3
- declare const getConfigDirectory: () => string;
4
- declare const getCacheDirectory: () => string;
5
- declare const getLogDirectory: () => string;
6
- declare const getTmpDirectory: () => string;
7
- export { getDataDirectory, getConfigDirectory, getCacheDirectory, getLogDirectory, getTmpDirectory, getStateJsonPath, };
1
+ export declare const getStateJsonPath: () => string;
2
+ export declare const getEasBuildRunCacheDirectoryPath: () => string;
3
+ export declare const getDataDirectory: () => string;
4
+ export declare const getConfigDirectory: () => string;
5
+ export declare const getCacheDirectory: () => string;
6
+ export declare const getLogDirectory: () => string;
7
+ export declare const getTmpDirectory: () => string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getStateJsonPath = exports.getTmpDirectory = exports.getLogDirectory = exports.getCacheDirectory = exports.getConfigDirectory = exports.getDataDirectory = void 0;
3
+ exports.getTmpDirectory = exports.getLogDirectory = exports.getCacheDirectory = exports.getConfigDirectory = exports.getDataDirectory = exports.getEasBuildRunCacheDirectoryPath = exports.getStateJsonPath = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const env_paths_1 = tslib_1.__importDefault(require("env-paths"));
6
6
  const os_1 = require("os");
@@ -26,6 +26,8 @@ function dotExpoHomeDirectory() {
26
26
  }
27
27
  const getStateJsonPath = () => path.join(dotExpoHomeDirectory(), 'state.json');
28
28
  exports.getStateJsonPath = getStateJsonPath;
29
+ const getEasBuildRunCacheDirectoryPath = () => path.join((0, exports.getTmpDirectory)(), 'eas-build-run-cache');
30
+ exports.getEasBuildRunCacheDirectoryPath = getEasBuildRunCacheDirectoryPath;
29
31
  // Paths for storing things like data, config, cache, etc.
30
32
  // Should use the correct OS-specific paths (e.g. XDG base directory on Linux)
31
33
  const { data: DATA_PATH, config: CONFIG_PATH, cache: CACHE_PATH, log: LOG_PATH, temp: TEMP_PATH, } = (0, env_paths_1.default)('eas-cli');
@@ -10,6 +10,6 @@ export declare type ProgressHandler = (props: {
10
10
  }) => void;
11
11
  export declare function createProgressTracker({ total, message, completedMessage, }: {
12
12
  total?: number;
13
- message: string | ((ratio: number) => string);
13
+ message: string | ((ratio: number, total: number) => string);
14
14
  completedMessage: string | ((duration: string) => string);
15
15
  }): ProgressHandler;
@@ -11,16 +11,18 @@ function createProgressTracker({ total, message, completedMessage, }) {
11
11
  let transferredSoFar = 0;
12
12
  let current = 0;
13
13
  const timerLabel = String(Date.now());
14
- const getMessage = (v) => {
14
+ const getMessage = (v, total) => {
15
15
  const ratio = Math.min(Math.max(v, 0), 1);
16
16
  const percent = Math.floor(ratio * 100);
17
- return typeof message === 'string' ? `${message} ${percent.toFixed(0)}%` : message(ratio);
17
+ return typeof message === 'string'
18
+ ? `${message} ${percent.toFixed(0)}%`
19
+ : message(ratio, total);
18
20
  };
19
21
  return ({ progress, isComplete, error }) => {
20
22
  if (progress) {
21
23
  if (!bar && (progress.total !== undefined || total !== undefined)) {
22
24
  calcTotal = (total !== null && total !== void 0 ? total : progress.total);
23
- bar = (0, ora_1.ora)(getMessage(0)).start();
25
+ bar = (0, ora_1.ora)(getMessage(0, calcTotal)).start();
24
26
  (0, timer_1.startTimer)(timerLabel);
25
27
  }
26
28
  if (progress.total) {
@@ -35,7 +37,7 @@ function createProgressTracker({ total, message, completedMessage, }) {
35
37
  current += progress.transferred - transferredSoFar;
36
38
  percentage = current / calcTotal;
37
39
  }
38
- bar.text = getMessage(percentage);
40
+ bar.text = getMessage(percentage, calcTotal);
39
41
  }
40
42
  transferredSoFar = progress.transferred;
41
43
  }