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

add run subcommand #76

Open
ry opened this issue Apr 24, 2024 · 9 comments
Open

add run subcommand #76

ry opened this issue Apr 24, 2024 · 9 comments

Comments

@ry
Copy link
Contributor

ry commented Apr 24, 2024

npx jsr run @luca/flag

just like deno run jsr:@luca/flag

@JLarky https://twitter.com/JLarky/status/1783147968251748624

@kt3k
Copy link

kt3k commented Apr 25, 2024

Currently jsr run subcommand is used for running run-script in package.json. ref

["run <script>", "Run a script from the package.json file"],

Does it make sense to change the behavior conditionally based on the given argument? (Or should we replace the existing behavior?)

@opeolluwa
Copy link

what does the run command do, exactly? Suppose I have a module with a default export someFunction(){}

Will it exec the some function, and pass the argument to it if any?

@marvinhagemeister
Copy link
Collaborator

Right now it only runs scripts defined in package.json.

@opeolluwa
Copy link

Oh, okay

@opeolluwa
Copy link

I'm looking forward to working on this, I'm going to need more explanation of the feature request

@JLarky
Copy link

JLarky commented May 23, 2024

With npm packages I can run commands like prettier without installing the package using commands like npx, bunx or yarn dlx, pnpm dlx. I wish there was a way to run jsr packages in node/bun like we have with "deno run"

@jordanbtucker
Copy link

I wish there was a way to run jsr packages in node/bun like we have with "deno run"

This will likely require buy in from npm and bun. You can get half way there with npm using a .npmrc with JSR as a scoped registry.

For example:

# This works
deno run jsr:@denorg/scrypt/cli hash mypassword

# This fails
npx @jsr/denorg__scrypt/cli hash mypassword

# This also fails
npx @jsr/denorg__scrypt hash mypassword

This is because npm expects @jsr/denorg__scrypt/cli to be a directory with a package.json file since it needs to check that for a bin field.

If you remove the cli part, then npm is able to find the package.json file that JSR generated, but it does not have a bin field, so npm doesn't know what file to run.

bunx doesn't even get as far as recognizing the scoped registry even though bun add does.

@jordanbtucker
Copy link

I suppose it might be possible for jsr to do an npm install into a cache location and then run the requested file.

jsr run @denorg/scrypt/cli hash mypassword

# Under the hood, jsr does something like this:
export NPM_PREFIX=~./jsr
npm install @jsr/denorg__scrypt
node $NPM_PREFIX/@jsr/denorg__scrypt/cli hash mypassword

I don't think that's really within the scope of JSR since it's not a runtime itself.

The better solution is for npx and bunx to support JSR packages.

@nakasyou
Copy link
Contributor

nakasyou commented Aug 8, 2024

I tried to support this, but npm.jsr.io doesn't exports a main field in package.json so I couldn't complete to implement.
Probably, if you use npx to implement this, JSR have to export a main field in package.json in tarball.

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

7 participants