add git and golang for windows, fix some PATH stuff
authorAJ ONeal <aj@therootcompany.com>
Sat, 4 Jul 2020 06:57:53 +0000 (06:57 +0000)
committerAJ ONeal <aj@therootcompany.com>
Sat, 4 Jul 2020 06:57:53 +0000 (06:57 +0000)
_webi/template.ps1
_webi/webi.ps1
git/install.ps1 [new file with mode: 0644]
git/install.sh [new file with mode: 0644]
git/releases.js [new file with mode: 0644]
golang/install.ps1 [new file with mode: 0644]
golang/install.sh
node/install.ps1
vim-go/README.md [new file with mode: 0644]
vim-go/install.ps1 [new file with mode: 0644]
vim-go/install.sh [new file with mode: 0644]

index 6ebdcd89a55d61c48ee22dbca16ee5a4dcc0b8ba..491e3a544c17bf69fbbaf86b791c8b9c21dffcdf 100644 (file)
@@ -35,7 +35,7 @@ if (!(Test-Path -Path .local\opt))
 
 # Run pathman to set up the folder
 #& "$Env:USERPROFILE\.local\bin\pathman.exe" add "$Env:USERPROFILE\.local\bin"
-& "$Env:USERPROFILE\.local\bin\pathman.exe" add .local\bin
+& "$Env:USERPROFILE\.local\bin\pathman.exe" add %USERPROFILE%\.local\bin
 
 {{ installer }}
 
index 7d8de291ee643c0a19da0cef62292933ec275c23..d18996cc4245aaaf5ac053033c31923c062ec383 100644 (file)
@@ -49,7 +49,7 @@ if (!(Test-Path -Path .local\bin\pathman.exe))
 
 # Run pathman to set up the folder
 #& "$Env:USERPROFILE\.local\bin\pathman.exe" add "$Env:USERPROFILE\.local\bin"
-& "$Env:USERPROFILE\.local\bin\pathman.exe" add .local\bin
+& "$Env:USERPROFILE\.local\bin\pathman.exe" add %USERPROFILE%\.local\bin
 
 # {{ baseurl }}
 # {{ version }}
diff --git a/git/install.ps1 b/git/install.ps1
new file mode 100644 (file)
index 0000000..d6d1e22
--- /dev/null
@@ -0,0 +1,56 @@
+#!/usr/bin/env pwsh
+
+$pkg_cmd_name = "git"
+$pkg_download = "$Env:USERPROFILE\Downloads\$Env:WEBI_PKG_FILE"
+
+$pkg_src = "$Env:USERPROFILE\.local\opt\$pkg_cmd_name-v$Env:WEBI_VERSION"
+
+$pkg_dst = "$Env:USERPROFILE\.local\opt\$pkg_cmd_name"
+$pkg_dst_cmd = "$pkg_dst\cmd\$pkg_cmd_name"
+$pkg_dst_bin = "$pkg_dst\cmd"
+
+# Fetch archive
+IF (!(Test-Path -Path "$pkg_download"))
+{
+    # TODO: arch detection
+    echo "Downloading $Env:PKG_NAME 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"
+}
+
+IF (!(Test-Path -Path "$pkg_src"))
+{
+    echo "Installing $pkg_cmd_name"
+    # TODO: temp directory
+
+    # Enter opt
+    ($none = pushd .local\tmp) | out-null
+
+        # Remove any leftover tmp cruft
+        Remove-Item -Path "$pkg_cmd_name*" -Recurse -ErrorAction Ignore
+
+        # Unpack archive
+        # Windows BSD-tar handles zip. Imagine that.
+        echo "Unpacking $pkg_download"
+        IF (!(Test-Path -Path "$pkg_cmd_name-v$Env:WEBI_VERSION")) {
+            New-Item -Path "$pkg_cmd_name-v$Env:WEBI_VERSION" -ItemType Directory
+        }
+        ($none = pushd "$pkg_cmd_name-v$Env:WEBI_VERSION")  | out-null
+            & tar xf "$pkg_download"
+        ($none = popd)  | out-null
+
+        # Settle unpacked archive into place
+        echo "New Name: $pkg_cmd_name-v$Env:WEBI_VERSION"
+        echo "New Location: $pkg_src"
+        Move-Item -Path "$pkg_cmd_name-v$Env:WEBI_VERSION" -Destination "$Env:USERPROFILE\.local\opt"
+
+    # Exit tmp
+    $none = popd
+}
+
+echo "Copying into '$pkg_dst' from '$pkg_src'"
+Remove-Item -Path "$pkg_dst" -Recurse -ErrorAction Ignore
+Copy-Item -Path "$pkg_src" -Destination "$pkg_dst" -Recurse
+
+# Add to path
+& "$Env:USERPROFILE\.local\bin\pathman.exe" add %USERPROFILE%\.local\opt\git\cmd
diff --git a/git/install.sh b/git/install.sh
new file mode 100644 (file)
index 0000000..68e66d6
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/bash
+{
+    set -e
+    set -u
+
+    echo "This package doesn't work for Mac or Linux yet - only Windows 10"
+    exit 1
+}
diff --git a/git/releases.js b/git/releases.js
new file mode 100644 (file)
index 0000000..caeac2a
--- /dev/null
@@ -0,0 +1,30 @@
+'use strict';
+
+var github = require('../_common/github.js');
+var owner = 'git-for-windows';
+var repo = 'git';
+
+module.exports = function (request) {
+  // TODO support mac and linux tarballs
+  return github(request, owner, repo).then(function (all) {
+    // See https://github.com/git-for-windows/git/wiki/MinGit
+    // also consider https://github.com/git-for-windows/git/wiki/Silent-or-Unattended-Installation
+    all.releases = all.releases
+      .filter(function (rel) {
+        rel.os = 'windows';
+        return (
+          /MinGit/i.test(rel.name || rel.download) &&
+          !/busybox/i.test(rel.name || rel.download)
+        );
+      })
+      .slice(0, 20);
+    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, null, 2));
+  });
+}
diff --git a/golang/install.ps1 b/golang/install.ps1
new file mode 100644 (file)
index 0000000..d7d1161
--- /dev/null
@@ -0,0 +1,74 @@
+#!/usr/bin/env pwsh
+
+$pkg_cmd_name = "go"
+$pkg_download = "$Env:USERPROFILE\Downloads\$Env:WEBI_PKG_FILE"
+
+$pkg_src = "$Env:USERPROFILE\.local\opt\$pkg_cmd_name-v$Env:WEBI_VERSION"
+
+$pkg_dst = "$Env:USERPROFILE\.local\opt\$pkg_cmd_name"
+$pkg_dst_cmd = "$pkg_dst\bin\$pkg_cmd_name"
+$pkg_dst_bin = "$pkg_dst\bin"
+
+# Fetch archive
+IF (!(Test-Path -Path "$pkg_download"))
+{
+    # TODO: arch detection
+    echo "Downloading $Env:PKG_NAME 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"
+}
+
+IF (!(Test-Path -Path "$pkg_src"))
+{
+    echo "Installing $pkg_cmd_name"
+    # TODO: temp directory
+
+    # Enter opt
+    pushd .local\tmp
+
+        # Remove any leftover tmp cruft
+        Remove-Item -Path "$pkg_cmd_name*" -Recurse -ErrorAction Ignore
+
+        # Unpack archive
+        # Windows BSD-tar handles zip. Imagine that.
+        echo "Unpacking $pkg_download"
+        & tar xf "$pkg_download"
+
+        # Settle unpacked archive into place
+        echo "New Name: $pkg_cmd_name-v$Env:WEBI_VERSION"
+        Get-ChildItem "$pkg_cmd_name*" | Select -f 1 | Rename-Item -NewName "$pkg_cmd_name-v$Env:WEBI_VERSION"
+        echo "New Location: $pkg_src"
+        Move-Item -Path "$pkg_cmd_name-v$Env:WEBI_VERSION" -Destination "$Env:USERPROFILE\.local\opt"
+
+    # Exit tmp
+    popd
+}
+
+echo "Copying into '$pkg_dst' from '$pkg_src'"
+Remove-Item -Path "$pkg_dst" -Recurse -ErrorAction Ignore
+Copy-Item -Path "$pkg_src" -Destination "$pkg_dst" -Recurse
+
+# Special to go: re-run all go tooling builds
+echo "Building go language tools..."
+echo gopls
+& "$pkg_dst_cmd" get golang.org/x/tools/gopls
+echo golint
+& "$pkg_dst_cmd" get golang.org/x/lint/golint 
+echo errcheck
+& "$pkg_dst_cmd" get github.com/kisielk/errcheck 
+echo gotags
+& "$pkg_dst_cmd" get github.com/jstemmer/gotags 
+echo goimports
+& "$pkg_dst_cmd" get golang.org/x/tools/cmd/goimports 
+echo gorename
+& "$pkg_dst_cmd" get golang.org/x/tools/cmd/gorename 
+echo gotype
+& "$pkg_dst_cmd" get golang.org/x/tools/cmd/gotype 
+echo stringer
+& "$pkg_dst_cmd" get golang.org/x/tools/cmd/stringer 
+
+# Add to path
+& "$Env:USERPROFILE\.local\bin\pathman.exe" add %USERPROFILE%\.local\opt\go\bin
+
+# Special to go: add default GOBIN to PATH
+& "$Env:USERPROFILE\.local\bin\pathman.exe" add %USERPROFILE%\go\bin
index f35eecb67da19535a93651ac7d7d78eef6218340..5f7af1642e5e893443d5cc3ab2a2b6af9232ff29 100644 (file)
@@ -56,6 +56,10 @@ pkg_post_install() {
     echo "Building go language tools..."
     echo gopls
     "$pkg_dst_cmd" get golang.org/x/tools/gopls > /dev/null #2>/dev/null
+    echo golint
+    "$pkg_dst_cmd" get golang.org/x/lint/golint > /dev/null #2>/dev/null
+    echo errcheck
+    "$pkg_dst_cmd" get github.com/kisielk/errcheck > /dev/null #2>/dev/null
     echo gotags
     "$pkg_dst_cmd" get github.com/jstemmer/gotags > /dev/null #2>/dev/null
     echo goimports
index c108acbc57ec066085f7b27ce3a0ab74880fe947..8c8789f3b48ee647332bc0d450eff4ee8270951d 100644 (file)
@@ -44,4 +44,4 @@ Copy-Item -Path "$Env:USERPROFILE\.local\opt\$Env:PKG_NAME-v$Env:WEBI_VERSION" -
 & .\.local\opt\node\npm.cmd --scripts-prepend-node-path=true config set scripts-prepend-node-path true
 
 # Add to path
-& "$Env:USERPROFILE\.local\bin\pathman.exe" add .local\opt\node
+& "$Env:USERPROFILE\.local\bin\pathman.exe" add '%USERPROFILE\.local\opt\node'
diff --git a/vim-go/README.md b/vim-go/README.md
new file mode 100644 (file)
index 0000000..ebabbd2
--- /dev/null
@@ -0,0 +1,71 @@
+---
+title: vim-go
+homepage: https://github.com/fatih/vim-go
+tagline: |
+  vim-go adds Go language support for Vim.
+description: |
+  `vim-go` provides integration with various official and 3rd part go tooling for linting, vetting, etc.
+
+  You'll also need `syntastic` or similar.
+---
+
+### How to install by hand
+
+```bash
+git clone --depth=1 https://github.com/fatih/vim-go.git ~/.vim/pack/plugins/start/vim-go
+```
+
+### How to configure your `.vimrc`
+
+```vimrc
+" don't check syntax immediately on open or on quit
+let g:syntastic_check_on_open = 1
+let g:syntastic_check_on_wq = 0
+
+" we also want to get rid of accidental trailing whitespace on save
+autocmd BufWritePre * :%s/\s\+$//e
+```
+
+```vimrc
+"""""""""""""""""""""""""""
+" Golang-specific options "
+"""""""""""""""""""""""""""
+
+" tell syntastic that go, golint, and errcheck are installed
+let g:syntastic_go_checkers = ['go', 'golint', 'errcheck']
+
+" tell vim-go that goimports is installed
+let g:go_fmt_command = "goimports"
+
+" tell vim-go to highlight
+let g:go_highlight_functions = 1
+let g:go_highlight_methods = 1
+let g:go_highlight_structs = 1
+let g:go_highlight_operators = 1
+let g:go_highlight_build_constraints = 1
+```
+
+### How to install go language tools
+
+```bash
+# gopls
+go get golang.org/x/tools/gopls
+
+# golint
+go get golang.org/x/lint/golint
+
+# errcheck
+go get github.com/kisielk/errcheck
+
+# gotags
+go get github.com/jstemmer/gotags
+
+# goimports
+go get golang.org/x/tools/cmd/goimports
+
+# gorename
+go get golang.org/x/tools/cmd/gorename
+
+# gotype
+go get golang.org/x/tools/cmd/gotype
+```
diff --git a/vim-go/install.ps1 b/vim-go/install.ps1
new file mode 100644 (file)
index 0000000..5c72a7c
--- /dev/null
@@ -0,0 +1,4 @@
+#!/usr/bin/env pwsh
+
+Remove-Item -Path "$Env:USERPROFILE\.vim\pack\plugins\start\vim-go" -Recurse -ErrorAction Ignore
+& git clone --depth=1 https://github.com/fatih/vim-go.git "$Env:USERPROFILE\.vim\pack\plugins\start\vim-go"
diff --git a/vim-go/install.sh b/vim-go/install.sh
new file mode 100644 (file)
index 0000000..da4401b
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+{
+    set -e
+    set -u
+
+    rm -rf "$HOME/.vim/pack/plugins/start/vim-go"
+    git clone --depth=1 https://github.com/fatih/vim-go.git "$HOME/.vim/pack/plugins/start/vim-go"
+}