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

feat: expose standalone download function #73

Merged
merged 1 commit into from
May 17, 2024

Conversation

lidel
Copy link
Member

@lidel lidel commented May 16, 2024

This PR exposes manual download function that allows downloading binaries for more than one platform in programmatic fashion.

Use case: we want to use this in ipfs-desktop, to download both amd64 and arm64 binaries required for building universal DMGs (ipfs/ipfs-desktop#1856).

Exposing download function here allows us to:

  1. leverage cached downloads, avoiding fetching same base arch artifact twice
  2. confirm download was successful by checking sha512

This allows downloading binaries for more than one platform.
We want to use this in ipfs-desktop, to download both amd64 and arm64
binaries required for building universal DMGs.

Exposing download function here allows us to
1. leverage cached downloads, avoid fetching same arch twice
2. confirm download by checkign sha512
/**
* @param {string} [version]
* @param {string} [platform]
* @param {string} [arch]
* @param {string} [installPath]
*/
module.exports = async (version, platform, arch, installPath) => {
module.exports.downloadAndUpdateBin = async (version, platform, arch, installPath) => {
Copy link
Member Author

@lidel lidel May 16, 2024

Choose a reason for hiding this comment

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

ℹ️ This funciton did download+link. Renamed to better describe what it really does.

Copy link
Member Author

Choose a reason for hiding this comment

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

ℹ️ Had to do this to pass lint

Copy link
Member Author

Choose a reason for hiding this comment

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

ℹ️ Added test for download function.

Copy link
Member

@SgtPooki SgtPooki left a comment

Choose a reason for hiding this comment

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

lgtm

Comment on lines +5 to +7
const { download } = require('./download')

module.exports.download = download
Copy link
Member

Choose a reason for hiding this comment

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

do we want to expose the downloadAndUpdateBin as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think no, it is only meaningful in NPM's postinstall hook, there is no use case where end use would want to use it.

@lidel
Copy link
Member Author

lidel commented May 17, 2024

Merging so this ships with 0.29.x

@lidel lidel merged commit 6cc476f into master May 17, 2024
1 check passed
@lidel lidel deleted the feat/expose-download-funcion branch May 17, 2024 13:03
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.

2 participants