Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr0nline authored Oct 19, 2023
2 parents d13ceac + 6888d84 commit 2b0ac75
Show file tree
Hide file tree
Showing 131 changed files with 2,163 additions and 1,692 deletions.
1 change: 1 addition & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
run: |
sh ./_scripts/install-ci-deps
echo "${HOME}/.local/bin" >> $GITHUB_PATH
echo "${HOME}/.local/opt/pwsh" >> $GITHUB_PATH
- run: shfmt --version
- run: shellcheck -V
- run: node --version
Expand Down
6 changes: 6 additions & 0 deletions .vimrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
" Note: You must enable per-project .vimrc in your ~/.vimrc
" set secure
" set exrc

" PowerShell settings
let g:ale_powershell_psscriptanalyzer_exclusions = "PSAvoidUsingWriteHost,PSUseDeclaredVarsMoreThanAssignments"
1 change: 0 additions & 1 deletion AtomicParsley

This file was deleted.

50 changes: 24 additions & 26 deletions _example/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,47 +15,45 @@ $pkg_src_bin = "$Env:USERPROFILE\.local\opt\foobar-v$Env:WEBI_VERSION\bin"
$pkg_src_dir = "$Env:USERPROFILE\.local\opt\foobar-v$Env:WEBI_VERSION"
$pkg_src = "$pkg_src_cmd"

New-Item "$Env:USERPROFILE\Downloads\webi" -ItemType Directory -Force | out-null
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"))
{
echo "Downloading foobar from $Env:WEBI_PKG_URL to $pkg_download"
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 "$pkg_download.part" "$pkg_download"
& Move-Item "$pkg_download.part" "$pkg_download"
}

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

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

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

# NOTE: DELETE THIS COMMENT IF NOT USED
# Move single binary into root of temporary folder
#& move "$pkg_download" "foo.exe"
# 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.
echo "Unpacking $pkg_download"
& tar xf "$pkg_download"
# 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
echo "Install Location: $pkg_src_cmd"
New-Item "$pkg_src_bin" -ItemType Directory -Force | out-null
Move-Item -Path ".\foobar-*\foo.exe" -Destination "$pkg_src_bin"
# 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 ".\foobar-*\foo.exe" -Destination "$pkg_src_bin"

# Exit tmp
popd
Pop-Location
}

echo "Copying into '$pkg_dst_cmd' from '$pkg_src_cmd'"
Remove-Item -Path "$pkg_dst_cmd" -Recurse -ErrorAction Ignore | out-null
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
6 changes: 6 additions & 0 deletions _scripts/install-ci-deps
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ curl -fsS https://webi.sh/[email protected] | sh

# Install 'shellcheck v0.9.x'
curl -fsS https://webi.sh/[email protected] | sh

# Install 'pwsh (PowerShell Core) v7.x'
curl -fsS https://webi.sh/pwsh@7 | sh
# shellcheck disable=SC1090
. ~/.config/envman/PATH.env
pwsh -Command "Install-Module -Name PSScriptAnalyzer -Scope CurrentUser -AllowClobber"
27 changes: 27 additions & 0 deletions _scripts/pwsh-fmt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh
set -e
set -u

echo "Formatting */*.ps1 ... "
for my_ps1 in */*.ps1; do
my_dir="$(
dirname "${my_ps1}"
)"
if test -L "${my_ps1}" ||
test -L "${my_dir}" ||
! test -f "${my_ps1}" ||
! test -d "${my_dir}"; then
printf ' SKIP %s (non-regular file or parent directory)\n' "${my_ps1}"
continue
fi

printf " %s" "${my_ps1}"

# -Settings ./Settings/CodeFormatting.psd1
my_new_file="$(
pwsh -Command "Invoke-Formatter -ScriptDefinition (Get-Content -Path '${my_ps1}' -Raw)"
)"
printf '%s\n' "${my_new_file}" > "${my_ps1}"

printf '\n'
done
40 changes: 40 additions & 0 deletions _scripts/pwsh-fmt.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env pwsh

$ErrorActionPreference = "Stop"

Write-Host "Formatting */*.ps1 ... "

$my_cwd = Get-Location
$my_dirs = Get-ChildItem -Directory
$my_status = 0

foreach ($my_dir in $my_dirs) {

$my_files = Get-ChildItem -Path $my_dir.FullName -File -Filter *.ps1
foreach ($my_file in $my_files) {
$my_ps1 = [System.IO.Path]::GetRelativePath($my_cwd, $my_file.FullName)
$my_dir = [System.IO.Path]::GetDirectoryName($my_file.FullName)

if (-Not (Test-Path -PathType Leaf -Path $my_ps1) -or
-Not (Test-Path -PathType Container -Path $my_dir)) {
Write-Host (" SKIP {0} (non-regular file or parent directory)" -f $my_ps1)
continue
}

Write-Host (" {0}" -f $my_ps1)

$text = Get-Content -Path $my_ps1 -Raw
$my_new_file = Invoke-Formatter -ScriptDefinition $text
$my_new_file = $my_new_file.Trim()

# note: trailing newline is added back on write
$my_new_file | Set-Content -Path $my_ps1

$my_new_file = $my_new_file + "`n"
IF ($text -ne $my_new_file) {
$my_status = 1
}
}
}

exit $my_status
36 changes: 36 additions & 0 deletions _scripts/pwsh-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/sh
set -e
set -u

echo "Formatting */*.ps1 ..."

for my_ps1 in */*.ps1; do
my_dir="$(
dirname "${my_ps1}"
)"
if test -L "${my_ps1}" ||
test -L "${my_dir}" ||
! test -f "${my_ps1}" ||
! test -d "${my_dir}"; then
printf ' SKIP %s (non-regular file or parent directory)\n' "${my_ps1}"
continue
fi

printf " %s" "${my_ps1}"

# -Settings ./PSScriptAnalyzerSettings.psd1
pwsh -Command "Invoke-ScriptAnalyzer -Fix -ExcludeRule PSAvoidUsingWriteHost,PSUseDeclaredVarsMoreThanAssignment -Path '$my_ps1'"

#
# fmt MUST happen after lint due to Byte-Order Marker (BOM) issues
# See https://github.com/PowerShell/PSScriptAnalyzer/issues/1743
#

# -Settings ./Settings/CodeFormatting.psd1
my_new_file="$(
pwsh -Command "Invoke-Formatter -ScriptDefinition (Get-Content -Path '${my_ps1}' -Raw)"
)"
printf '%s\n' "${my_new_file}" > "${my_ps1}"

printf '\n'
done
48 changes: 48 additions & 0 deletions _scripts/pwsh-lint.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env pwsh

$ErrorActionPreference = "Stop"

Write-Host "Linting */*.ps1 ... "

$my_cwd = Get-Location
$my_dirs = Get-ChildItem -Directory
$my_status = 0

foreach ($my_dir in $my_dirs) {

$my_files = Get-ChildItem -Path $my_dir.FullName -File -Filter *.ps1
foreach ($my_file in $my_files) {
$my_ps1 = [System.IO.Path]::GetRelativePath($my_cwd, $my_file.FullName)
$my_dir = [System.IO.Path]::GetDirectoryName($my_file.FullName)

if (-Not (Test-Path -PathType Leaf -Path $my_ps1) -or
-Not (Test-Path -PathType Container -Path $my_dir)) {
Write-Host (" SKIP {0} (non-regular file or parent directory)" -f $my_ps1)
continue
}

Write-Host (" {0}" -f $my_ps1)

$my_old_file = (Get-Content -Path $my_ps1 -Raw)
Invoke-ScriptAnalyzer -Fix -ExcludeRule PSAvoidUsingWriteHost, PSUseDeclaredVarsMoreThanAssignment -Path $my_ps1

#
# fmt MUST happen after lint due to Byte-Order Marker (BOM) issues
# See https://github.com/PowerShell/PSScriptAnalyzer/issues/1743
#

$my_fixed_file = (Get-Content -Path $my_ps1 -Raw)
$my_new_file = Invoke-Formatter -ScriptDefinition $my_fixed_file
$my_new_file = $my_new_file.Trim()

# note: trailing newline is added back on write
$my_new_file | Set-Content -Path $my_ps1

$my_new_file = $my_new_file + "`n"
IF ($my_old_file -ne $my_new_file) {
$my_status = 1
}
}
}

exit $my_status
2 changes: 1 addition & 1 deletion _vim-example/install.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env pwsh

IF (!(Test-Path -Path "$Env:USERPROFILE\.vim\pack\plugins\start")) {
New-Item -Path "$Env:USERPROFILE\.vim\pack\plugins\start" -ItemType Directory -Force | out-null
New-Item -Path "$Env:USERPROFILE\.vim\pack\plugins\start" -ItemType Directory -Force | Out-Null
}
Remove-Item -Path "$Env:USERPROFILE\.vim\pack\plugins\start\example" -Recurse -ErrorAction Ignore
& git clone --depth=1 https://github.com/CHANGEME/example.git "$Env:USERPROFILE\.vim\pack\plugins\start\example"
6 changes: 3 additions & 3 deletions _webi/bootstrap.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
# <h1>Cheat Sheet at CHEATSHEET_URL</h1>
# <meta http-equiv="refresh" content="3; URL='CHEATSHEET_URL'" />
############################################################
New-Item -Path "$Env:USERPROFILE\Downloads\webi" -ItemType Directory -Force | out-null
New-Item -Path "$Env:USERPROFILE\.local\bin" -ItemType Directory -Force | out-null
IF ($Env:WEBI_HOST -eq $null -or $Env:WEBI_HOST -eq "") { $Env:WEBI_HOST = "https://webinstall.dev" }
New-Item -Path "$Env:USERPROFILE\Downloads\webi" -ItemType Directory -Force | Out-Null
New-Item -Path "$Env:USERPROFILE\.local\bin" -ItemType Directory -Force | Out-Null
IF ($null -eq $Env:WEBI_HOST -or $Env:WEBI_HOST -eq "") { $Env:WEBI_HOST = "https://webinstall.dev" }
curl.exe -s -A "windows" "$Env:WEBI_HOST/packages/_webi/webi-pwsh.ps1" -o "$Env:USERPROFILE\.local\bin\webi-pwsh.ps1"
Set-ExecutionPolicy -Scope Process Bypass
& "$Env:USERPROFILE\.local\bin\webi-pwsh.ps1" "{{ exename }}"
16 changes: 8 additions & 8 deletions _webi/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ __install_webi() {
export WEBI_HOST

echo ""
printf "Thanks for using webi to install '\e[32m%s\e[0m' on '\e[31m%s/%s\e[0m'.\n" "${WEBI_PKG-}" "$(uname -s)/$(uname -r)" "$(uname -m)"
printf "Thanks for using webi to install '\e[32m%s\e[0m' on '\e[33m%s/%s\e[0m'.\n" "${WEBI_PKG-}" "$(uname -s)/$(uname -r)" "$(uname -m)"
echo "Have a problem? Experience a bug? Please let us know:"
echo " https://github.com/webinstall/webi-installers/issues"
printf " \e[2m\e[36mhttps://github.com/webinstall/webi-installers/issues\e[0m\n"
echo ""
printf "\e[31mLovin'\e[0m it? Say thanks with a \e[34mStar on GitHub\e[0m:\n"
printf " \e[32mhttps://github.com/webinstall/webi-installers\e[0m\n"
printf "\e[35mLovin'\e[0m it? Say thanks with a \e[1m\e[33mStar on GitHub\e[0m:\n"
printf " \e[36mhttps://github.com/webinstall/webi-installers\e[0m\n"
echo ""

WEBI_WELCOME=true
Expand Down Expand Up @@ -145,9 +145,9 @@ __webi_main() {
printf 'PATH.env updated with:\\n'
printf "%s\\n" "\$my_paths"
printf '\\n'
printf "\\e[31mTO FINISH\\e[0m: copy, paste & run the following command:\\n"
printf "\\e[1m\\e[35mTO FINISH\\e[0m: copy, paste & run the following command:\\n"
printf "\\n"
printf " \\e[34msource ~/.config/envman/PATH.env\\e[0m\\n"
printf " \\e[1m\\e[32msource ~/.config/envman/PATH.env\\e[0m\\n"
printf " (newly opened terminal windows will update automatically)\\n"
fi
rm -f "\$_webi_tmp/.PATH.env"
Expand All @@ -158,8 +158,8 @@ __webi_main() {
version() {
my_version=v1.1.15
printf "\\e[31mwebi\\e[32m %s\\e[0m Copyright 2020+ AJ ONeal\\n" "\${my_version}"
printf " \\e[34mhttps://webinstall.dev/webi\\e[0m\\n"
printf "\\e[35mwebi\\e[32m %s\\e[0m Copyright 2020+ AJ ONeal\\n" "\${my_version}"
printf " \\e[36mhttps://webinstall.dev/webi\\e[0m\\n"
}
# show help if no params given or help flags are used
Expand Down
Loading

0 comments on commit 2b0ac75

Please sign in to comment.