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: Add a script to set up the PATH and install shell completions #295

Merged
merged 29 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
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
26 changes: 26 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,29 @@ jobs:
if: matrix.os == 'windows-latest'
shell: pwsh
run: ./install_test.ps1

check-js:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- uses: denoland/setup-deno@v1
with:
deno-version: rc

- name: deno lint
run: deno lint

- name: check fmt
run: deno fmt --check

- name: check bundled file up to date
run: |
cd shell-setup
deno task bundle
if ! git --no-pager diff --exit-code ./bundled.esm.js; then
echo 'Bundled script is out of date, update it with `cd shell-setup; deno task bundle`'.
exit 1
fi

23 changes: 23 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Publish
on:
push:
tags:
- '*'

jobs:
publish:
runs-on: ubuntu-latest

permissions:
contents: read
id-token: write

steps:
- uses: actions/checkout@v4

- uses: denoland/setup-deno@v1
with:
deno-version: rc

- name: Publish to JSR on tag
run: deno run -A jsr:@david/[email protected]
9 changes: 9 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
MIT License
Copy link
Member

Choose a reason for hiding this comment

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

lol


Copyright 2018-2024 the Deno authors

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 changes: 18 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@ $v="1.0.0"; irm https://deno.land/install.ps1 | iex

## Install via Package Manager

**With [winget](https://github.com/microsoft/winget-pkgs/tree/master/manifests/d/DenoLand/Deno):**
**With
[winget](https://github.com/microsoft/winget-pkgs/tree/master/manifests/d/DenoLand/Deno):**

```powershell
winget install deno
```

**With [Scoop](https://github.com/ScoopInstaller/Main/blob/master/bucket/deno.json):**
**With
[Scoop](https://github.com/ScoopInstaller/Main/blob/master/bucket/deno.json):**

```powershell
scoop install deno
Expand Down Expand Up @@ -95,7 +97,8 @@ cargo install deno

## Install and Manage Multiple Versions

**With [asdf](https://asdf-vm.com) and [asdf-deno](https://github.com/asdf-community/asdf-deno):**
**With [asdf](https://asdf-vm.com) and
[asdf-deno](https://github.com/asdf-community/asdf-deno):**

```sh
asdf plugin add deno
Expand Down Expand Up @@ -123,7 +126,8 @@ asdf global deno 1.0.0
asdf local deno 1.0.0
```

**With [Scoop](https://github.com/lukesampson/scoop/wiki/Switching-Ruby-And-Python-Versions):**
**With
[Scoop](https://github.com/lukesampson/scoop/wiki/Switching-Ruby-And-Python-Versions):**

```sh
# Install a specific version of deno:
Expand Down Expand Up @@ -158,13 +162,17 @@ scoop reset deno

## Compatibility

- The Shell installer can be used on Windows with [Windows Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/about), [MSYS](https://www.msys2.org) or equivalent set of tools.
- The Shell installer can be used on Windows with
[Windows Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/about),
[MSYS](https://www.msys2.org) or equivalent set of tools.

## Known Issues

### either unzip or 7z is required

To decompress the `deno` archive, one of either [`unzip`](https://linux.die.net/man/1/unzip) or [`7z`](https://linux.die.net/man/1/7z) must be available on the target system.
To decompress the `deno` archive, one of either
[`unzip`](https://linux.die.net/man/1/unzip) or
[`7z`](https://linux.die.net/man/1/7z) must be available on the target system.

```sh
$ curl -fsSL https://deno.land/install.sh | sh
Expand All @@ -173,8 +181,10 @@ Error: either unzip or 7z is required to install Deno (see: https://github.com/d

**When does this issue occur?**

During the `install.sh` process, `unzip` or `7z` is used to extract the zip archive.
During the `install.sh` process, `unzip` or `7z` is used to extract the zip
archive.

**How can this issue be fixed?**

You can install unzip via `brew install unzip` on MacOS or `apt-get install unzip -y` on Linux.
You can install unzip via `brew install unzip` on MacOS or
`apt-get install unzip -y` on Linux.
20 changes: 20 additions & 0 deletions deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"workspace": [
"./shell-setup"
],
"lint": {
"exclude": [
"./shell-setup/bundled.esm.js"
],
"rules": {
"exclude": [
"no-slow-types"
]
}
},
"fmt": {
"exclude": [
"./shell-setup/bundled.esm.js"
]
}
}
10 changes: 3 additions & 7 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,12 @@ chmod +x "$exe"
rm "$exe.zip"

echo "Deno was installed successfully to $exe"
if $exe eval 'const [major, minor] = Deno.version.deno.split("."); if (major < 2 && minor < 42) Deno.exit(1)'; then
$exe run -A jsr:@deno/installer-shell-setup/bundled "$deno_install"
fi
if command -v deno >/dev/null; then
echo "Run 'deno --help' to get started"
else
case $SHELL in
/bin/zsh) shell_profile=".zshrc" ;;
*) shell_profile=".bashrc" ;;
esac
echo "Manually add the directory to your \$HOME/$shell_profile (or similar)"
echo " export DENO_INSTALL=\"$deno_install\""
echo " export PATH=\"\$DENO_INSTALL/bin:\$PATH\""
echo "Run '$exe --help' to get started"
fi
echo
Expand Down
20 changes: 20 additions & 0 deletions shell-setup/bundle.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import * as esbuild from "npm:esbuild";

import { fromFileUrl } from "@std/path/from-file-url";
import { denoPlugins } from "jsr:@luca/esbuild-deno-loader";

const result = await esbuild.build({
plugins: denoPlugins({
configPath: fromFileUrl(import.meta.resolve("./deno.json")),
lockPath: fromFileUrl(import.meta.resolve("./deno.lock")),
}),
entryPoints: ["./src/main.ts"],
outfile: "./bundled.esm.js",
bundle: true,
minify: true,
format: "esm",
});

console.log(result.outputFiles);

await esbuild.stop();
Loading
Loading