Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[eas-cli] add publish.ts 3/4 #147

Merged
merged 11 commits into from
Dec 18, 2020
Merged

[eas-cli] add publish.ts 3/4 #147

merged 11 commits into from
Dec 18, 2020

Conversation

jkhales
Copy link
Contributor

@jkhales jkhales commented Dec 10, 2020

Why

This is the third of 4 PR's to add eas release:publish.

It adds all of the helper functions used by the command.

It is the most complex of the 4. It maybe worth cross referencing the final #146 to see how these functions are used.

How

  • collect assets from bundle directory.
  • get signed URLs and upload assets to GCS. Query expo servers every second to monitor the progress and fail if it takes more than 60 seconds.
  • If successful publish manifest.

Test Plan

yarn test

and also

tested in #146

@jkhales jkhales changed the title [eas-cli] add publish.ts [eas-cli] add publish.ts 3/4 Dec 10, 2020
@github-actions
Copy link

github-actions bot commented Dec 13, 2020

Size Change: +38.7 kB (0%)

Total Size: 42.5 MB

Filename Size Change
./packages/eas-cli/dist/eas-linux-x64.tar.gz 42.5 MB +38.7 kB (0%)

compressed-size-action

};
};

export function guessContentTypeFromExtension(ext?: string): string {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The content type is important for asset storage. In the future we may ask the user to specify the contentType if we don't recognize it. For now we default to 'application/octet-stream'

@jkhales jkhales marked this pull request as ready for review December 14, 2020 00:07
@jkhales jkhales requested a review from fson December 14, 2020 00:07
packages/eas-cli/src/project/publish.ts Outdated Show resolved Hide resolved
packages/eas-cli/src/project/publish.ts Outdated Show resolved Hide resolved
packages/eas-cli/src/project/publish.ts Outdated Show resolved Hide resolved
};
}

export function buildUpdateInfoGroup(assets: CollectedAssets) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the return type.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I made this PR to add noImplicitReturns to the tsconfig to help catch this in the future: #166

packages/eas-cli/src/project/publish.ts Outdated Show resolved Hide resolved
packages/eas-cli/src/project/publish.ts Outdated Show resolved Hide resolved
packages/eas-cli/src/project/publish.ts Outdated Show resolved Hide resolved
packages/eas-cli/src/project/publish.ts Outdated Show resolved Hide resolved
packages/eas-cli/src/project/publish.ts Outdated Show resolved Hide resolved
packages/eas-cli/src/project/publish.ts Outdated Show resolved Hide resolved
Base automatically changed from @jkhales/2 to main December 16, 2020 02:01
@@ -57,26 +57,30 @@ async function obtainS3PresignedPostAsync(
export async function uploadWithPresignedPostAsync(
stream: Readable | Buffer,
presignedPost: PresignedPost,
handleProgressEvent: ProgressHandler
) {
handleProgressEvent?: ProgressHandler
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allow handleProgressEvent to be optional. Uploading 100's of assets would look chaotic.

@@ -1,17 +1,13 @@
import gql from 'graphql-tag';

import { graphqlClient, withErrorHandlingAsync } from '../client';
import { AssetMetadataResult } from '../generated';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to generated type.

Copy link
Contributor

@fson fson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for making the changes! I did another round of review and noticed a few more things below.

packages/eas-cli/src/project/publish.ts Outdated Show resolved Hide resolved
packages/eas-cli/src/project/publish.ts Outdated Show resolved Hide resolved
handleProgressEvent({ isComplete: true });
return String(response.headers.location);
} catch (error) {
handleProgressEvent({ isComplete: true, error });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if we need these synthetic events after success/error because the caller can as easily trigger the necessary actions after the promise has resolved. Removing them (and additionally using the Progress event from got without wrapping it) would also greatly simplify this code:

const uploadPromise = got.post(presignedPost.url, { body: form, headers: { ...formHeaders } });
if (handleProgressEvent) {
  uploadPromise.on('uploadProgress', handleProgressEvent);
}
const response = await uploadPromise;
return String(response.headers.location);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is much more concise, but looking through the code for a progress handler, it seems to expect an isComplete argument.

See this recent PR in particular: https://github.com/expo/eas-cli/pull/153/files#diff-54650d756e5f6628f0b3c7c2564229e97085d05dacc0fac8263e0fcb9647da47R70

Simplifying this code seems desirable, but perhaps worth consulting @EvanBacon first and doing in a separate PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be still best to keep this function as simple as possible and then implement the progress handler interface in publish.ts, because it will need to keep track of all the uploads in order to show a combined progress bar. And I think the progress bar can be added in another PR.

packages/eas-cli/src/project/publish.ts Outdated Show resolved Hide resolved
packages/eas-cli/src/project/publish.ts Outdated Show resolved Hide resolved
@jkhales jkhales requested a review from fson December 17, 2020 15:04
Copy link
Contributor

@fson fson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks.

@jkhales jkhales merged commit d65c180 into main Dec 18, 2020
@jkhales jkhales deleted the @jkhales/3 branch December 18, 2020 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants