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

Wanted: installer #471

Closed
ry opened this issue May 30, 2019 · 14 comments · Fixed by #489
Closed

Wanted: installer #471

ry opened this issue May 30, 2019 · 14 comments · Fixed by #489

Comments

@ry
Copy link
Member

ry commented May 30, 2019

deno run -A https://deno.land/std/installer/install.ts

a program which installs itself into your $PATH. It will walk your $PATH, find a writable directory, writing a new shell script into it called $PATH/deno_install

The shell script will look like this:

#!/bin/sh
deno run -A https://deno.land/std/installer/bin.ts $@

So now people can run this:

deno_install file_server https://deno.land/std/http/file_server.ts --allow-write --allow-net

This will create a new executable shell script called $PATH/file_server, which would have the following contents:

#!/bin/sh
deno run --allow-write --allow-net https://deno.land/std/http/file_server.ts $@
@bartlomieju
Copy link
Member

This is super useful! I'll work on that

@zaynv
Copy link

zaynv commented Jun 7, 2019

It would be cool if this could just be a part of the deno program itself since subcommands are used now maybe something like

deno install file_server https://deno.land/std/http/file_server.ts --allow-write --allow-net

@bartlomieju
Copy link
Member

@zaynv this will most likely happen after we land it here. I shall have prototype before end of weekend

@bartlomieju
Copy link
Member

It looks like denoget already does most of the stuff described in the issue.

Maybe we could import it into std and change some things (no need for wget and update directory selection).

CC @syumai @ry

@bartlomieju
Copy link
Member

a program which installs itself into your $PATH. It will walk your $PATH, find a writable directory, writing a new shell script into it called $PATH/deno_install

Should we select first writeable dir? How about keeping it all in one place and using ~/.deno/bin for that purpose?

Also we should take a moment to figure out how to go about updating and/or reloading of installed scripts

@ry
Copy link
Member Author

ry commented Jun 9, 2019

~/.deno/bin sounds good to me

@syumai
Copy link
Contributor

syumai commented Jun 9, 2019

Thanks @bartlomieju !
I think what denoget does is almost same as @ry says.

Usage of denoget:

denoget https://deno.land/std/http/file_server.ts

This command creates files below:

1.)
path: ~/.deno/denoget/src/file_server.ts
content: import 'https://deno.land/std/http/file_server.ts';

2.)
path: ~/.deno/denoget/bin/file_server (shell script)
content: deno --allow-net /Users/syumai/.deno/denoget/src/file_server.ts $@

If you add ~/.deno/denoget/bin into $PATH, you can execute file_server directly.

The reason why denoget uses wget is to read shebang of target script.
denoget adds launch options like --allow-net --allow-write to generated shell script.
To determine which options to add, denoget reads shebang of target script like this:

example script

#!/usr/bin/env deno --allow-all

deno's fetch doesn't support redirect, so I couldn't read shebang from script using redirect server like deno.land/x.

I'm okay to remove this feature if I would add denoget into std.

@syumai
Copy link
Contributor

syumai commented Jun 9, 2019

In Go's way,

  • go get <script> installs script.
  • go get -u <script> updates and installs script.

These behaviors may be helpful to decide command name ;)

  • deno get / install <script>
  • deno get / install -r <script> // This flag has consistency with deno's original refreshing option.

@ry
Copy link
Member Author

ry commented Jun 9, 2019

Let’s just call it “deno install” for now. I think “deno fetch” and “deno get” are confusing next to each other.

@bartlomieju
Copy link
Member

This command creates files below:

1.)
path: ~/.deno/denoget/src/file_server.ts
content: import 'https://deno.land/std/http/file_server.ts';

2.)
path: ~/.deno/denoget/bin/file_server (shell script)
content: deno --allow-all /Users/syumai/.deno/denoget/src/denoget.ts $@

I think 1) can be skipped and included directly in 2)

If you add ~/.deno/denoget/bin into $PATH, you can execute file_server directly.

We can automate it

The reason why denoget uses wget is to read shebang of target script.
denoget adds launch options like --allow-net --allow-write to generated shell script.
To determine which options to add, denoget reads shebang of target script like this:

Can you elaborate? Won't fetch allow to read content of file after redirects?

Re: installation deno install, deno install --update and deno uninstall should handle what we need 👍

@syumai let's get PR going and iterate in there, I'll help out

@syumai
Copy link
Contributor

syumai commented Jun 9, 2019

I think 1) can be skipped and included directly in 2)

Yes, this can be

content: deno --allow-net https://deno.land/std/http/file_server.ts $@

directly.

Can you elaborate? Won't fetch allow to read content of file after redirects?

Maybe what I should try is to implement feature of this TODO comment.
https://github.com/denoland/deno/blob/master/js/fetch.ts#L246

@syumai let's get PR going and iterate in there, I'll help out

Thanks! I'm going to start doing it this week ;)

What I'm going to do:

  1. Fix redirect of deno fetch
  2. Create PR to add installer to std (based on denoget)

Is this ok? If it is, I start doing it. @bartlomieju

@bartlomieju
Copy link
Member

Sure, you can start with installer to get the ball rolling and we'll figure out fetch in the meantime

@syumai
Copy link
Contributor

syumai commented Jun 9, 2019

OK, then I'll create a PR to std first.

@syumai syumai mentioned this issue Jun 9, 2019
2 tasks
@syumai
Copy link
Contributor

syumai commented Jun 9, 2019

@bartlomieju @ry I created a PR
#488

@ry ry closed this as completed in #489 Jun 14, 2019
inverted-capital pushed a commit to dreamcatcher-tech/napps that referenced this issue Oct 24, 2024
This cleans up some of the unnecessary LOC for the script.

Related to denoland#471
inverted-capital pushed a commit to dreamcatcher-tech/napps that referenced this issue Oct 24, 2024
inverted-capital pushed a commit to dreamcatcher-tech/napps that referenced this issue Oct 24, 2024
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 a pull request may close this issue.

4 participants