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

feat: installer #489

Merged
merged 28 commits into from
Jun 14, 2019
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
c689f8e
Add installer
syumai Jun 9, 2019
38aea3d
Update README of deno_install
syumai Jun 9, 2019
8f78c9d
replace wget with fetch
bartlomieju Jun 13, 2019
c865227
more prompts, handle situation without shebang, prompt on overwrite
bartlomieju Jun 13, 2019
b64f0a6
better prompt
bartlomieju Jun 13, 2019
a8d0f63
even better prompt
bartlomieju Jun 13, 2019
8435486
lint & fmt
bartlomieju Jun 13, 2019
fd4d530
remove shebang parsing
bartlomieju Jun 13, 2019
4ff7fec
add help prompt
bartlomieju Jun 13, 2019
ffd3af8
fix arg parsing
bartlomieju Jun 13, 2019
0331109
add uninstall command
bartlomieju Jun 13, 2019
aabd191
don't show PATH prompt if dir in path
bartlomieju Jun 13, 2019
86a6e4e
install local scripts
bartlomieju Jun 14, 2019
86bd510
lint
bartlomieju Jun 14, 2019
1dda37e
add simple test case
bartlomieju Jun 14, 2019
0576c4c
lint
bartlomieju Jun 14, 2019
75ab128
reset CI
bartlomieju Jun 14, 2019
cbd05ea
add env permission
bartlomieju Jun 14, 2019
29d891e
add debug statement
bartlomieju Jun 14, 2019
25b9ae5
remove debug statement
bartlomieju Jun 14, 2019
84143ca
Add missing await
bartlomieju Jun 14, 2019
b7a703b
properly parse script flags
bartlomieju Jun 14, 2019
77c37db
add more tests for installer
bartlomieju Jun 14, 2019
81030d6
fix windows test
bartlomieju Jun 14, 2019
b77746c
update README
bartlomieju Jun 14, 2019
6137f6e
explicitly require name for installed executable
bartlomieju Jun 14, 2019
637a6f3
s/deno_install/deno_installer/
bartlomieju Jun 14, 2019
09ac618
remove installer/deno_installer.ts
bartlomieju Jun 14, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update README
  • Loading branch information
bartlomieju committed Jun 14, 2019
commit b77746c91a6e63463491831f13be3ffb10abbf5f
75 changes: 52 additions & 23 deletions installer/README.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,74 @@
# deno_install
bartlomieju marked this conversation as resolved.
Show resolved Hide resolved

- This command installs executable deno script.
Installs remote or local script as executable.

## Features
````
## Installation

- Install executable script into ~/.deno/bin
`installer` can be install using iteself:

```sh
deno -A https://deno.land/std/install/deno_install.ts https://deno.land/std/install/deno_install.ts -A
````

Installer uses `~/.deno/bin` to store installed scripts so make sure it's in `$PATH`

```
echo 'export PATH="$HOME/.deno/bin:$PATH"' >> ~/.bashrc # change this to your shell
```

## Usage

Install script

```sh
$ deno_install https://deno.land/std/http/file_server.ts
> file_server requests network access. Grant permanently? [yN] # Grant the permissions to use command.
> y
> Successfully installed file_server.
$ file_server # now you can use installed command!
$ deno_install https://deno.land/std/http/file_server.ts --allow-net --allow-read
> Downloading: https://deno.land/std/http/file_server.ts
>
> ✅ Successfully installed file_server.

# local script
$ deno_install ./deno_std/http/file_server.ts --allow-net --allow-read
> Looking for: /dev/deno_std/http/file_server.ts
>
> ✅ Successfully installed file_server.
```

## Installing
Use installed script:

### 1. Install deno_install
```sh
$ file_server
HTTP server listening on http://0.0.0.0:4500/
```

deno_install can be installed by using itself.
Update installed script

```sh
deno -A https://deno.land/std/install/deno_install.ts https://deno.land/std/install/deno_install.ts
$ deno_install https://deno.land/std/http/file_server.ts --allow-net --allow-read
> ⚠️ file_server is already installed, do you want to overwrite it? [yN]
> y
>
> Downloading: https://deno.land/std/http/file_server.ts
>
> ✅ Successfully installed file_server.
```

### 2. Add `~/.deno/bin` to PATH
Uninstall script

```sh
$ deno_install uninstall file_server
> ℹ️ Uninstalled file_server
```
echo 'export PATH="$HOME/.deno/bin:$PATH"' >> ~/.bashrc # change this to your shell
```

## Create Executable Script

- Add shebang to top of your deno script.
- This defines what permissions are needed.
Display help

```sh
#!/usr/bin/env deno --allow-read --allow-write --allow-env --allow-run
```
$ deno_install --help
> USAGE:
deno https://deno.land/std/installer/mod.ts SCRIPT [FLAGS...]

- Host script on the web.
- Install script using deno_install.
ARGS:
SCRIPT URL of script to install
[FLAGS...] List of flags for script, both Deno permission and script specific flag can be used.

```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems when I run it with no arguments, there's no error message or help text:

~/src/deno_std> deno -A installer/deno_installer.ts
[1/1] Compiling file:///Users/rld/src/deno_std/installer/deno_installer.ts
~/src/deno_std>

Copy link
Member Author

@bartlomieju bartlomieju Jun 14, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yikes, can we just drop installer/deno_installer.ts and leave installer/mod.ts?

Removed installer/deno_installer.ts it's not needed anymore - previously it was discovering module name from path, but now it's explicitly passed as an arg.

Please try deno -A installer/mod.ts