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

Use Deno #5

Open
gr2m opened this issue Dec 16, 2020 · 5 comments
Open

Use Deno #5

gr2m opened this issue Dec 16, 2020 · 5 comments
Labels
pull request welcome Ready to work on

Comments

@gr2m
Copy link
Member

gr2m commented Dec 16, 2020

I think the CLI would be a great use case to use Deno. Scripts and dependencies could be loaded directly from a remote URL, and Deno has a better security system.

@gr2m gr2m added the pull request welcome Ready to work on label Dec 16, 2020
@gr2m
Copy link
Member Author

gr2m commented Feb 15, 2021

Something like this would be cool

deno run --allow-net=api.github.com https://octoherd.dev/scripts/star-or-unstar

@jsg2021
Copy link

jsg2021 commented Feb 15, 2021

Isn't running a script from a url generally frowned on tho?

@gr2m
Copy link
Member Author

gr2m commented Feb 15, 2021

not with deno. It has a similar sandbox as browsers do.

It's probably more secure than running

npx my-star-or-unstar-cli

@jsg2021
Copy link

jsg2021 commented Feb 15, 2021

Awesome, I didn't know that about deno. :)

@gr2m
Copy link
Member Author

gr2m commented Feb 26, 2021

The first step will be to create a deno version of the CLI.

Node introduced the convention of conditional exports. And skypack seems to support exports for different environments such as deno, they mention it at https://docs.skypack.dev/package-authors/package-checks#export-map

image

Changing

{ 
  "exports": "./bin/octoherd.js"
}

to

{ 
  "exports": {
    "node": "./bin/octoherd-node.js",
    "node": "./bin/octoherd-deno.js"
  }
}

Maybe we can also make the current CLI just work with Deno out of the box, but I'm not familiar enough with Deno to debug the errors I currently see.

Once we have a valid Deno export and Skypack supports it, a script such as the above mentiond https://octoherd.dev/scripts/star-or-unstar could

  1. import the CLI from https://cdn.skypack.dev/@octoherd/cli
  2. import the chosen script, e.g. if it's its own npm package it would import it from https://cdn.skypack.de/@octoherd/script-star-or-unstar
  3. then it would read the options such as the GitHub token, the repositories, and script options from CLI arguments or prompts and finally run the script

I'd love help with this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pull request welcome Ready to work on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants