graph-tooling icon indicating copy to clipboard operation
graph-tooling copied to clipboard

allow passing `spkg.io` from `graph init`

Open saihaj opened this issue 1 year ago • 4 comments

Pull the substream package from spkg.io

image

saihaj avatar Apr 24 '24 15:04 saihaj

@saihaj can I pick this to work on next?

joshuanazareth97 avatar Apr 24 '24 16:04 joshuanazareth97

go for it @joshuanazareth97

saihaj avatar Apr 25 '24 17:04 saihaj

@saihaj Notes on my understanding / the implementation I am planning:

  • As I understand it, there are 2 locations from which we could receive spkgPath: (1) flag (2) interactive prompt
  • The value received from either of these is passed into the same initSubgraphFromContract method, which then adds this to the manifest file under source
  • Currently, the file must exist in the path relative to the directory that graph init is called in

Approach:

  • Change the validation for the spkg file to also pass for the URL format above (spkg.io.../.../)
  • If we receive a URL, download the file into the current directory
  • In this case spkgPath becomes the name of the spkg file, since it is in the root of the current directory
  • Continue as before, passing spkgPath into the manifest, just like with local files

Bonus:

  • Potential UX improvement: If a URL is passed, we can further ask the user which directory they want to download the spkg file into, defaulting to the current dir. This would give more control to the user, but would require additional logic for creating non-existent folders etc.

Interested to know your thoughts around this approach.

joshuanazareth97 avatar Apr 26 '24 08:04 joshuanazareth97

Hey @saihaj, have implemented this using a slight variation of the approach above. have not yet implemented the bonus feature I mentioned, do let me know if there's anything you'd like me to change?

joshuanazareth97 avatar Apr 26 '24 18:04 joshuanazareth97