Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
46 changes: 46 additions & 0 deletions nushell/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
title: Foo Bar
homepage: https://github.com/webinstall/foobar
tagline: |
foobar: An example that doesn't exist.
---

<!--
Note: Delete this comment section.

Need an example that has an **alias**? See `bat`.
Need a Windows example using **msvc**? See `bat`.
-->

To update or switch versions, run `webi example@stable` (or `@v2`, `@beta`,
etc).

### Files

These are the files / directories that are created and/or modified with this
install:

```text
~/.config/envman/PATH.env
~/.local/bin/foo
~/.local/opt/foo/
```

## Cheat Sheet

> `foo` doesn't exist and this text should have been replaced. It doesn't do
> anything, but what it does is useful because it is; everybody knows it.

To run foo:

```sh
foo
```

### Add Baz Highlighting

To run foo with both bar and baz highlighting turned on:

```sh
foo --bar=baz
```
59 changes: 59 additions & 0 deletions nushell/install.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/env pwsh

###################
# Install nushell #
###################

# Every package should define these variables
$pkg_cmd_name = "nu"

$pkg_dst_cmd = "$Env:USERPROFILE\.local\bin\nu.exe"
$pkg_dst = "$pkg_dst_cmd"

$pkg_src_cmd = "$Env:USERPROFILE\.local\opt\nushell-v$Env:WEBI_VERSION\bin\nu.exe"
$pkg_src_bin = "$Env:USERPROFILE\.local\opt\nushell-v$Env:WEBI_VERSION\bin"
$pkg_src_dir = "$Env:USERPROFILE\.local\opt\nushell-v$Env:WEBI_VERSION"
$pkg_src = "$pkg_src_cmd"

New-Item "$Env:USERPROFILE\Downloads\webi" -ItemType Directory -Force | Out-Null
$pkg_download = "$Env:USERPROFILE\Downloads\webi\$Env:WEBI_PKG_FILE"

# Fetch archive
IF (!(Test-Path -Path "$Env:USERPROFILE\Downloads\webi\$Env:WEBI_PKG_FILE")) {
Write-Output "Downloading foobar from $Env:WEBI_PKG_URL to $pkg_download"
& curl.exe -A "$Env:WEBI_UA" -fsSL "$Env:WEBI_PKG_URL" -o "$pkg_download.part"
& Move-Item "$pkg_download.part" "$pkg_download"
}

IF (!(Test-Path -Path "$pkg_src_cmd")) {
Write-Output "Installing nushell"

# TODO: create package-specific temp directory
# Enter tmp
Push-Location .local\tmp

# Remove any leftover tmp cruft
Remove-Item -Path ".\nu-*" -Recurse -ErrorAction Ignore
Remove-Item -Path ".\nu.exe" -Recurse -ErrorAction Ignore

# NOTE: DELETE THIS COMMENT IF NOT USED
# Move single binary into root of temporary folder
#& move "$pkg_download" "foo.exe"

# Unpack archive file into this temporary directory
# Windows BSD-tar handles zip. Imagine that.
Write-Output "Unpacking $pkg_download"
& tar xf "$pkg_download"

# Settle unpacked archive into place
Write-Output "Install Location: $pkg_src_cmd"
New-Item "$pkg_src_bin" -ItemType Directory -Force | Out-Null
Move-Item -Path ".\nu.exe" -Destination "$pkg_src_bin"

# Exit tmp
Pop-Location
}

Write-Output "Copying into '$pkg_dst_cmd' from '$pkg_src_cmd'"
Remove-Item -Path "$pkg_dst_cmd" -Recurse -ErrorAction Ignore | Out-Null
Copy-Item -Path "$pkg_src" -Destination "$pkg_dst" -Recurse
46 changes: 46 additions & 0 deletions nushell/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/sh

# shellcheck disable=SC2034
# "'pkg_cmd_name' appears unused. Verify it or export it."

__init_nushell() {
set -e
set -u

###################
# Install nushell #
###################

# Every package should define these 6 variables
pkg_cmd_name="nu"

pkg_dst_cmd="$HOME/.local/bin/nu"
pkg_dst="$pkg_dst_cmd"

pkg_src_cmd="$HOME/.local/opt/nushell-v$WEBI_VERSION/bin/nu"
pkg_src_dir="$HOME/.local/opt/nushell-v$WEBI_VERSION"
pkg_src="$pkg_src_cmd"

# pkg_install must be defined by every package
pkg_install() {
# ~/.local/opt/foobar-v0.99.9/bin
mkdir -p "$(dirname "${pkg_src_cmd}")"

# mv ./foobar-*/foo ~/.local/opt/foobar-v0.99.9/bin/foo
mv ./nu-*/nu "${pkg_src_cmd}"
}

# pkg_get_current_version is recommended, but not required
pkg_get_current_version() {
# 'foo --version' has output in this format:
# foobar 0.99.9 (rev abcdef0123)
# This trims it down to just the version number:
# 0.99.9
foo --version 2> /dev/null |
head -n 1 |
cut -d ' ' -f 2
}

}

__init_foobar
41 changes: 41 additions & 0 deletions nushell/releases.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
'use strict';

var github = require('../_common/github.js');
var owner = 'nushell';
var repo = 'nushell';

var ODDITIES = ['loongarch64', 'riscv64'];

module.exports = function () {
return github(null, owner, repo).then(function (all) {
all.releases = all.releases
.map(function (rel) {
for (let oddity of ODDITIES) {
if (rel.name.includes(oddity)) {
return;
}
}
if (/pc-windows/.test(rel.name)) {
rel.os = 'windows';
}
if (/msvc/.test(rel.name)) {
rel.name = rel.name.replace(/-msvc/, '');
rel.download = rel.download.replace(/-msvc/, '');
}

return rel;
})
.filter(Boolean);
return all;
});
};

if (module === require.main) {
module.exports().then(function (all) {
all = require('../_webi/normalize.js')(all);
// just select the first 5 for demonstration
all.releases = all.releases.slice(0, 5);
console.info(JSON.stringify(all, null, 2));
});
}

3 changes: 3 additions & 0 deletions test/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ __rmrf_local() {
nerd-font \
nerdfont \
node \
nushell \
ots \
pandoc \
pathman \
Expand Down Expand Up @@ -150,6 +151,7 @@ __rmrf_local() {
myip \
nerd-font \
nerdfont \
nushell \
node \
ots \
pandoc \
Expand Down Expand Up @@ -250,6 +252,7 @@ __test() {
nerd-font \
nerdfont \
node \
nushell \
ots \
pandoc \
pathman \
Expand Down
Loading