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

Feature | graph init Add support to download spkg files from spkg.io #1642

Open
wants to merge 20 commits into
base: main
Choose a base branch
from

Conversation

joshuanazareth97
Copy link
Contributor

@joshuanazareth97 joshuanazareth97 commented Apr 26, 2024

Change Description

  • Allow passing a file url for spkg files instead of just a file path.
  • Download the file if a url has been passed

Related Issue / Discussion

#1641

Screenshot of change

image
image
image

Copy link

changeset-bot bot commented Apr 26, 2024

🦋 Changeset detected

Latest commit: 91e488c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@graphprotocol/graph-cli Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@joshuanazareth97 joshuanazareth97 changed the title Feature | Add support to download spkg files from spkg.io Feature | graph init Add support to download spkg files from spkg.io Apr 26, 2024
@joshuanazareth97
Copy link
Contributor Author

Hi @saihaj can you please review this PR? Let me know if there's anything you need me to do before you merge it. Thanks!

@saihaj
Copy link
Member

saihaj commented May 2, 2024

thanks @joshuanazareth97 sorry for the delay. I was away on vacation last week, catching up on things will try to land this early next week

Copy link
Member

@saihaj saihaj left a comment

Choose a reason for hiding this comment

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

few minor nits, thanks for adding tests!

(sorry for the delayed review)

Comment on lines +1 to +13
import { createWriteStream } from 'fs';
import { http } from 'gluegun';

export async function downloadFile(fileUrl: string, outputLocationPath: string) {
const writer = createWriteStream(outputLocationPath);
const api = http.create({
baseURL: fileUrl,
});
return api.get('', {}, { responseType: 'stream' }).then((response: any) => {
response.data.pipe(writer);
return Promise.resolve(outputLocationPath);
});
}
Copy link
Member

Choose a reason for hiding this comment

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

I would use fetch, we maintain an internal wrapper that also passes some headers that can let origin servers know where the traffic is coming from.

export default function fetchWrapper(

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Have now resolved this to use the wrapped fetch

packages/cli/src/command-helpers/spkg.ts Outdated Show resolved Hide resolved
Co-authored-by: Saihajpreet Singh <saihajpreet.singh@gmail.com>
@saihaj
Copy link
Member

saihaj commented May 15, 2024

@joshuanazareth97 are you still working on this?

@joshuanazareth97
Copy link
Contributor Author

@joshuanazareth97 are you still working on this?

@saihaj apologies, was occupied with some other stuff last week. Have addressed all your comments.

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