Skip to content

Generate a valid tarball url when publishing#987

Merged
arcanis merged 3 commits into
yarnpkg:masterfrom
nicolo-ribaudo:publish-tar-url
Feb 23, 2020
Merged

Generate a valid tarball url when publishing#987
arcanis merged 3 commits into
yarnpkg:masterfrom
nicolo-ribaudo:publish-tar-url

Conversation

@nicolo-ribaudo
Copy link
Copy Markdown
Contributor

What's the problem this PR addresses?

Packages published on a verdaccio registry had the wrong tarball URL, making it impossible to download them.

How did you fix it?

I copied the logic used by lerna (https://github.com/evocateur/libnpmpublish/blob/latest/publish.js#L142).
I couldn't find any test for the npm publish command, but I'll check if this works with Babel.

@nicolo-ribaudo nicolo-ribaudo force-pushed the publish-tar-url branch 2 times, most recently from 4068d2e to d876fe9 Compare February 23, 2020 18:32
nicolo-ribaudo added a commit to babel/babel that referenced this pull request Feb 23, 2020
Comment thread .yarn/versions/edd3bc49.yml Outdated
Comment on lines +2 to +30
"@yarnpkg/builder": prerelease
"@yarnpkg/cli": prerelease
"@yarnpkg/core": prerelease
"@yarnpkg/doctor": prerelease
"@yarnpkg/plugin-compat": prerelease
"@yarnpkg/plugin-constraints": prerelease
"@yarnpkg/plugin-dlx": prerelease
"@yarnpkg/plugin-essentials": prerelease
"@yarnpkg/plugin-exec": prerelease
"@yarnpkg/plugin-file": prerelease
"@yarnpkg/plugin-git": prerelease
"@yarnpkg/plugin-github": prerelease
"@yarnpkg/plugin-http": prerelease
"@yarnpkg/plugin-init": prerelease
"@yarnpkg/plugin-interactive-tools": prerelease
"@yarnpkg/plugin-link": prerelease
"@yarnpkg/plugin-node-modules": prerelease
"@yarnpkg/plugin-npm": prerelease
"@yarnpkg/plugin-npm-cli": prerelease
"@yarnpkg/plugin-pack": prerelease
"@yarnpkg/plugin-patch": prerelease
"@yarnpkg/plugin-pnp": prerelease
"@yarnpkg/plugin-stage": prerelease
"@yarnpkg/plugin-typescript": prerelease
"@yarnpkg/plugin-version": prerelease
"@yarnpkg/plugin-workspace-tools": prerelease
"@yarnpkg/pnp": prerelease
"@yarnpkg/pnpify": prerelease
vscode-zipfs: prerelease
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not a blocker, but in this case you only need to bump plugin-npm (for direct consumers) and cli (for a new binary to be released). The others don't need to be bumped.

// other registries such as verdaccio.
const tarballName = `${name}-${version}.tgz`;
const tarballURL = new URL(`${name}/-/${tarballName}`, registry);
if (tarballURL.protocol === "https:") tarballURL.protocol = "http:";
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🤨 What do you think of omitting this line if it works without? I don't understand it (all tarball fields returned from the registry are expected to be https), and it sounds counterintuitive and potentially dangerous.

@nicolo-ribaudo nicolo-ribaudo changed the title Generate a valid taball url when publishing Generate a valid tarball url when publishing Feb 23, 2020
nicolo-ribaudo added a commit to babel/babel that referenced this pull request Feb 23, 2020
@nicolo-ribaudo
Copy link
Copy Markdown
Contributor Author

This seems to work in our tests.

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