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

Allow users to use package.json without needing separate deno/jsr.json #555

Open
jhechtf opened this issue May 23, 2024 · 4 comments
Open
Labels
publishing Problems with publishing

Comments

@jhechtf
Copy link

jhechtf commented May 23, 2024

Looking into using the JSR registry, I tried to manually push a test package that I plan on building primarily for node. As such, I used the package.json file to declare things like name, version, and exports. Trying to push this failed, obviously.

This means I need to add either a jsr.json or deno.json, which duplicates the name, version, and exports. I feel this is cumbersome, especially because I often use some variety of tooling to automate version bumping my package.json file. I don't personally know of any tools (beyond ones I've written and since deprecated) that worked with deno.json or jsr.json. This puts me in a weird spot where I'd like to use the jsr registry, but I find the idea of needing to sync between package.json and jsr.json tedious. Maybe not tedious enough to not use it, but tedious enough I felt it necessary to create an issue on your github.

@github-project-automation github-project-automation bot moved this to Needs Triage in JSR May 23, 2024
@fdaciuk
Copy link

fdaciuk commented Jun 4, 2024

Maybe jsr CLI could bump the version in jsr.json, using the same version in package.json, or if the project already has a package.json, JSR could use name, version and exports from there =)

@jhechtf
Copy link
Author

jhechtf commented Jun 4, 2024

I could see if the npx jsr client preferred the package.json over the jsr.json and copied it; deno publish would obviously prefer the deno.json and then jsr.json. However, people would have to make sure to publish the copy over from the package.json to the jsr.json after running the npx jsr step in the event that it copied over the package.json version, which I'm not huge on.

Perhaps there could be a jsr sync command, which looks for package.json or deno.json and copies over the name/version. This way in say a package.json script we could have something like the following, which would auto-sync the versions.

{
  "name": "@scoped/package-name",
  "version": "1.0.0-rc",
  "scripts": {
    "prepublish": "npx jsr sync",
    "publish": "npx jsr publish"
  }
}

I'd prefer it that npx jsr just used the package.json, but I'd be willing to work with this.

@wojpawlik
Copy link

Possibly autogenerated (#544 (comment)) jsr.json should always have priority over deno.json:

jq '{ name, version, exports }' package.json >jsr.json

@nikelborm
Copy link

nikelborm commented Dec 29, 2024

Here is my command to move "version" and "name" fields from package.json to jsr.json. It doesn't overwrite other preexisting fields in jsr.json such as "$schema" (btw, I highly recommend adding "$schema": "https://jsr.io/schema/config-file.v1.json", to your jsr.json) or "publish" which could be quite different from the usual "publish" in package.json.

jq -s '.[1] + {name: .[0].name, version: .[0].version}' package.json jsr.json > temp.json && mv temp.json jsr.json

Or also you can prefix the name:

jq -s '.[1] + {name: ("@nikelborm/" + .[0].name), version: .[0].version}' package.json jsr.json > temp.json && mv temp.json jsr.json

@crowlKats crowlKats marked this as a duplicate of #864 Jan 17, 2025
@crowlKats crowlKats added the publishing Problems with publishing label Jan 17, 2025
@crowlKats crowlKats moved this from Needs Triage to Needs Plan in JSR Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
publishing Problems with publishing
Projects
Status: Needs Plan
Development

No branches or pull requests

5 participants