a11ywatch / rust-to-npm

Rust to npm
https://crates.io/crates/rust-to-npm
MIT License
32 stars 4 forks source link

NPM deploy uses wrong README? #10

Open JimLynchCodes opened 1 year ago

JimLynchCodes commented 1 year ago

Hi, I am doing kind of a weird thing, but I think I have discovered a bug in doing it...

My project: https://github.com/JimLynchCodes/jims-rust-to-npm-test

My project's Cargo.toml file: https://github.com/JimLynchCodes/jims-rust-to-npm-test/blob/main/jims-rust-cli-test/Cargo.toml

which has the line: readme = "README-for-registry.md"

The strange thing is that crates.io does seem to be using the readme located at README-for-registry.md, but the npm one seems to be ignoring this field and just uses the content from README.md.

package on crates.io: https://crates.io/crates/jims-rust-cli-test

package on npmjs.com: https://www.npmjs.com/package/jims-rust-cli-test

I can probably pretty easily workaround this by just naming my registry README "README.md", but I just wanted to bring this to your attention since it seems like a bug to me. And in general I like the idea of being able to put all my cargo project files in the root of the repo (visible on github) but have it deploy a different README to the registries. Another somewhat related thing that I'm wondering is if it would make sense to have two different Cargo.toml fields- one pointing to a README to use on crates.io and one to a README to use on npmjs.com...

Thanks!

j-mendez commented 1 year ago

@JimLynchCodes for npm the README needs to start with any case and only allows extensions. Instead of using “-“ replace it with “.”.

JimLynchCodes commented 1 year ago

Interesting! was not aware of that. thanks 👍

j-mendez commented 1 year ago

@JimLynchCodes you are welcome, feel free to post any issues or PRs for changes, questions, etc!

JimLynchCodes commented 1 year ago

Hi @j-mendez I am reopening this issue because I just tried this again with another project that has the packages point to a readme named README.registry.md.

I'm seeing the name weird behavior though that it works correctly on crates.io but still shows the regular README.md file's content on the npm page...

j-mendez commented 1 year ago

If you have a root README without extensions it should load prominently first. Is the goal trying to declare a README as root?

JimLynchCodes commented 1 year ago

“Is the goal trying to declare a README as root?”

yes, personally I like having all the project files including README.md at the root of the repository because I don’t like having the files right there without having to dive into nested directories.

GitHub uses ‘README.me’ as the content displayed when you go to the repo on GitHub. AFAIK there is no way to have github use a readme with a different name for this…

so then when deploying my cli tool I am forced to use the same readme for registry content and GitHub page…

Is it really correct that README without extension should load predominantly first even when I specify a different README for the package’s readme field? 🤔

j-mendez commented 1 year ago

@JimLynchCodes the only workaround would be to use temp files that could be created with the CLI with modifications to swap README targets for NPM. If a README.md file is found it will be used as root display on their end, nothing we can adjust without a PR to npm etc.