From 693613da4bb1f37b33b393f086f9be57a35dc7c5 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Tue, 30 Jun 2020 06:15:43 +0000 Subject: [PATCH] add PowerShell for Mac and Linux --- _webi/normalize.js | 2 +- powershell/README.md | 17 +++++++++++++++++ powershell/install.sh | 42 ++++++++++++++++++++++++++++++++++++++++++ powershell/releases.js | 22 ++++++++++++++++++++++ 4 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 powershell/README.md create mode 100644 powershell/install.sh create mode 100644 powershell/releases.js diff --git a/_webi/normalize.js b/_webi/normalize.js index cd9c624..5672bca 100644 --- a/_webi/normalize.js +++ b/_webi/normalize.js @@ -2,7 +2,7 @@ // this may need customizations between packages var osMap = { - macos: /(\b|_)(apple|mac|darwin|iPhone|iOS|iPad)/i, + macos: /(\b|_)(apple|os\s?x\b|mac|darwin|iPhone|iOS|iPad)/i, linux: /(\b|_)(linux)/i, freebsd: /(\b|_)(freebsd)/i, windows: /(\b|_)(win|microsoft|msft)/i, diff --git a/powershell/README.md b/powershell/README.md new file mode 100644 index 0000000..b0215b6 --- /dev/null +++ b/powershell/README.md @@ -0,0 +1,17 @@ +--- +title: Microsoft PowerShell +homepage: https://docs.microsoft.com/en-us/powershell/ +tagline: | + PowerShell Core is a cross-platform (Windows, Linux, and macOS) automation and configuration tool/framework. +description: | + PowerShell is the default shell on Windows 10. Since `curl.exe | powershell` is effectively as convenient as `curl | bash` for users, and since Windows 10 also includes tar, curl.exe, and ssh, among others, you can use fairly simple PowerShell to make a variety of tasks simple for Windows developers. +--- + +For example, if you wanted to install Node.js with powershell and +webinstall.dev, you can: + +```cmd +curl.exe -s -A "MS" https://webinstall.dev/node@lts | powershell +``` + + diff --git a/powershell/install.sh b/powershell/install.sh new file mode 100644 index 0000000..ac1a36c --- /dev/null +++ b/powershell/install.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +{ + set -e + set -u + + pkg_cmd_name="pwsh" + # no ./bin prefix + pkg_src_cmd="$HOME/.local/opt/pwsh-v$WEBI_VERSION/pwsh" + pkg_dst_cmd="$HOME/.local/opt/pwsh/pwsh" + + pkg_get_current_version() { + # 'pwsh --version' has output in this format: + # PowerShell 7.0.2 + # This trims it down to just the version number: + # 7.0.2 + echo "$(pwsh --version 2>/dev/null | head -n 1 | cut -d' ' -f2)" + } + + pkg_install() { + # mv ./* "$HOME/.local/opt/pwsh-v7.0.2" + mkdir -p "$pkg_src" + mv ./* "$pkg_src" + + # symlink powershell to pwsh + pushd "$pkg_src" >/dev/null + ln -s pwsh powershell + popd >/dev/null + } + + pkg_link() { + # rm -f "$HOME/.local/opt/pwsh" + rm -f "$pkg_dst" + + # ln -s "$HOME/.local/opt/pwsh-v7.0.2" "$HOME/.local/opt/pwsh" + ln -s "$pkg_src" "$pkg_dst" + } + + pkg_done_message() { + echo "Installed 'pwsh' at $pkg_dst" + } +} diff --git a/powershell/releases.js b/powershell/releases.js new file mode 100644 index 0000000..7f43815 --- /dev/null +++ b/powershell/releases.js @@ -0,0 +1,22 @@ +'use strict'; + +var github = require('../_common/github.js'); +var owner = 'powershell'; +var repo = 'powershell'; + +module.exports = function (request) { + return github(request, owner, repo).then(function (all) { + // remove checksums and .deb + all.releases = all.releases.filter(function (rel) { + return !/(alpine)|(fxdependent)|(\.deb)|(\.pkg)|(\.rpm)$/i.test(rel.name); + }); + return all; + }); +}; + +if (module === require.main) { + module.exports(require('@root/request')).then(function (all) { + all = require('../_webi/normalize.js')(all); + console.info(JSON.stringify(all)); + }); +} -- 2.25.1