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

Mirroring with custom host much harder compared with node-pre-gyp #183

Open
Fiouz opened this issue Jun 23, 2022 · 0 comments
Open

Mirroring with custom host much harder compared with node-pre-gyp #183

Fiouz opened this issue Jun 23, 2022 · 0 comments

Comments

@Fiouz
Copy link

Fiouz commented Jun 23, 2022

Context

  • Hosting of binary on custom host
  • Package with working mirroring migrated from node-pre-gyp to prebuild-install
    • Migration did not change host
  • prebuild-install/util.js

    Lines 46 to 60 in 8250adf

    if (hostMirrorUrl) {
    return hostMirrorUrl + '/{tag_prefix}{version}/' + packageName
    }
    if (opts.pkg.binary && opts.pkg.binary.host) {
    return [
    opts.pkg.binary.host,
    opts.pkg.binary.remote_path,
    opts.pkg.binary.package_name || packageName
    ].map(function (path) {
    return trimSlashes(path)
    }).filter(Boolean).join('/')
    }
    return github(opts.pkg) + '/releases/download/{tag_prefix}{version}/' + packageName

Issue

Even though prebuild-install seems to have a similar option set compared to node-pre-gyp, mirroring is much harder to achieve and requires proper planning from the package maintainer.

Requirements for mirroring a binary that relies on node-pre-gyp:

  • (consumer) Mirror the <package.json>.binary.host
  • (consumer) Configure the npm <package>_binary_host_mirror variable to point to the mirror

Requirements for mirroring a binary that relies on prebuild-install with a custom host:

  • (package maintainer) Need to make sure that <package.json>.binary.remote_path ends with the hardcoded /{tag_prefix}{version}/ pattern. In case remote_path does not already include {tag_prefix}, prebuild-install must be invoked with --tag-prefix=
  • (consumer) Mirror the <package.json>.binary.host
  • (consumer) In case interoperability with node-pre-gyp is needed (e.g. case of realm library)
    • use the <package>_binary_host npm variable, and keep <package>_binary_host_mirror unchanged
    • configure <package>_binary_host npm variable to include whatever is needed so that the concatenation of <package>_binary_host + /{tag_prefix}{version}/ (taking into consideration that {tag_prefix} is controlled by package maintainer) matches the HTTP mirror

An example of such difficulty can be seen at realm/realm-js#4667 (comment)

Is there a chance to simplify binary mirroring?

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

No branches or pull requests

1 participant