Skip to content
This repository has been archived by the owner. It is now read-only.

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
Contributor

@ry 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

This comment has been minimized.

Copy link
Contributor

@bartlomieju bartlomieju commented May 30, 2019

This is super useful! I'll work on that

@zaynv

This comment has been minimized.

Copy link

@zaynv 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

This comment has been minimized.

Copy link
Contributor

@bartlomieju bartlomieju commented Jun 7, 2019

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

@bartlomieju

This comment has been minimized.

Copy link
Contributor

@bartlomieju bartlomieju commented Jun 9, 2019

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

This comment has been minimized.

Copy link
Contributor

@bartlomieju bartlomieju commented Jun 9, 2019

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

This comment has been minimized.

Copy link
Contributor Author

@ry ry commented Jun 9, 2019

~/.deno/bin sounds good to me

@syumai

This comment has been minimized.

Copy link

@syumai 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

This comment has been minimized.

Copy link

@syumai 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

This comment has been minimized.

Copy link
Contributor Author

@ry 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

This comment has been minimized.

Copy link
Contributor

@bartlomieju bartlomieju commented Jun 9, 2019

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

This comment has been minimized.

Copy link

@syumai 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

This comment has been minimized.

Copy link
Contributor

@bartlomieju bartlomieju commented Jun 9, 2019

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

@syumai

This comment has been minimized.

Copy link

@syumai syumai commented Jun 9, 2019

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

@syumai syumai mentioned this issue Jun 9, 2019
0 of 2 tasks complete
@syumai

This comment has been minimized.

Copy link

@syumai syumai commented Jun 9, 2019

@bartlomieju @ry I created a PR
#488

@ry ry closed this in #489 Jun 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
4 participants
You can’t perform that action at this time.