-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
146 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
title: sqlc | ||
homepage: https://github.com/sqlc-dev/sqlc | ||
tagline: | | ||
sqlc: generate code from SQL (not the other way around) | ||
--- | ||
|
||
To update or switch versions, run `webi sqlc@stable` (or `@v1.27`, `@beta`, | ||
etc). | ||
|
||
### Files | ||
|
||
These are the files / directories that are created and/or modified with this | ||
install: | ||
|
||
```text | ||
~/.config/envman/PATH.env | ||
~/.local/bin/sqlc | ||
``` | ||
|
||
## Cheat Sheet | ||
|
||
TODO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/usr/bin/env pwsh | ||
|
||
################ | ||
# Install sqlc # | ||
################ | ||
|
||
# Every package should define these variables | ||
$pkg_cmd_name = "sqlc" | ||
|
||
$pkg_dst_cmd = "$Env:USERPROFILE\.local\bin\sqlc.exe" | ||
$pkg_dst_bin = "$Env:USERPROFILE\.local\bin" | ||
$pkg_dst = "$pkg_dst_cmd" | ||
|
||
$pkg_src_cmd = "$Env:USERPROFILE\.local\opt\sqlc-v$Env:WEBI_VERSION\bin\sqlc.exe" | ||
$pkg_src_bin = "$Env:USERPROFILE\.local\opt\sqlc-v$Env:WEBI_VERSION\bin" | ||
$pkg_src_dir = "$Env:USERPROFILE\.local\opt\sqlc-v$Env:WEBI_VERSION" | ||
$pkg_src = "$pkg_src_cmd" | ||
|
||
$pkg_download_dir = "$Env:USERPROFILE\Downloads\webi\$pkg_cmd_name\$Env:WEBI_VERSION" | ||
$pkg_download_file = "$pkg_download_dir\$Env:WEBI_PKG_FILE" | ||
|
||
# Fetch archive | ||
IF (!(Test-Path -Path "$pkg_download_file")) { | ||
New-Item "$pkg_download_dir" -ItemType Directory -Force | Out-Null | ||
Write-Output " Downloading $pkg_cmd_name v$Env:WEBI_VERSION from $Env:WEBI_PKG_URL to $pkg_download_file" | ||
& curl.exe -A "$Env:WEBI_UA" -fsSL "$Env:WEBI_PKG_URL" -o "$pkg_download_file.part" | ||
& Move-Item "$pkg_download_file.part" "$pkg_download_file" | ||
} | ||
|
||
IF (!(Test-Path -Path "$pkg_src_cmd")) { | ||
Write-Output " Installing sqlc v$Env:WEBI_VERSION" | ||
|
||
# Remove any leftover tmp cruft and recreate the unpack | ||
Remove-Item -Path ".local\tmp\sqlc-v$Env:WEBI_VERSION" -Recurse -ErrorAction Ignore | ||
New-Item ".local\tmp\sqlc-v$Env:WEBI_VERSION" -ItemType Directory -Force | Out-Null | ||
|
||
# Unpack archive file into this temporary directory | ||
Push-Location ".local\tmp\sqlc-v$Env:WEBI_VERSION" | ||
# Windows BSD-tar handles zip. Imagine that. | ||
Write-Output " Unpacking $pkg_download_file" | ||
& tar xf "$pkg_download_file" | ||
Pop-Location | ||
|
||
# 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 ".local\tmp\sqlc-v$Env:WEBI_VERSION.\sqlc.exe" -Destination "$pkg_src_bin" | ||
|
||
# Remove any leftover tmp cruft & exit tmp | ||
Remove-Item -Path ".local\tmp\sqlc-v$Env:WEBI_VERSION" -Recurse -ErrorAction Ignore | ||
Pop-Location | ||
} | ||
|
||
Write-Output " Copying into '$pkg_dst_cmd' from '$pkg_src_cmd'" | ||
Remove-Item -Path "$pkg_dst_cmd" -Recurse -ErrorAction Ignore | Out-Null | ||
New-Item "$pkg_dst_bin" -ItemType Directory -Force | Out-Null | ||
Copy-Item -Path "$pkg_src" -Destination "$pkg_dst" -Recurse | ||
|
||
$version_output = & "$pkg_dst_cmd" version | ||
$version_line = $version_output | | ||
Select-String -Pattern 'v\d+\.\d+' | ||
Write-Output " Installed $version_line" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/bin/sh | ||
# shellcheck disable=SC2034 | ||
set -x | ||
|
||
__init_sqlc() { | ||
set -e | ||
set -u | ||
|
||
################ | ||
# Install sqlc # | ||
################ | ||
|
||
# Every package should define these 6 variables | ||
pkg_cmd_name="sqlc" | ||
|
||
pkg_dst_cmd="$HOME/.local/bin/sqlc" | ||
pkg_dst="$pkg_dst_cmd" | ||
|
||
pkg_src_cmd="$HOME/.local/opt/sqlc-v$WEBI_VERSION/bin/sqlc" | ||
pkg_src_dir="$HOME/.local/opt/sqlc-v$WEBI_VERSION" | ||
pkg_src="$pkg_src_cmd" | ||
|
||
pkg_install() { | ||
# mkdir -p "$HOME/.local/opt/sqlc-v1.27.0/bin" | ||
mkdir -p "$(dirname "$pkg_src_cmd")" | ||
|
||
# mv ./sqlc* "$HOME/.local/opt/sqlc-v1.27.0/bin/sqlc" | ||
mv ./"$pkg_cmd_name"* "$pkg_src_cmd" | ||
|
||
# chmod a+x "$HOME/.local/opt/sqlc-v1.27.0/bin/sqlc" | ||
chmod a+x "$pkg_src_cmd" | ||
} | ||
|
||
pkg_get_current_version() { | ||
# 'sqlc version' has output in this format: | ||
# v1.27.0 | ||
# This trims it down to just the version number: | ||
# 1.27.0 | ||
sqlc version 2> /dev/null | | ||
head -n 1 | | ||
sed 's:^v::' | ||
} | ||
} | ||
__init_sqlc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
'use strict'; | ||
|
||
var github = require('../_common/github.js'); | ||
var owner = 'sqlc-dev'; | ||
var repo = 'sqlc'; | ||
|
||
module.exports = async function () { | ||
let all = await github(null, owner, repo); | ||
return all; | ||
}; | ||
|
||
if (module === require.main) { | ||
module.exports().then(function (all) { | ||
all = require('../_webi/normalize.js')(all); | ||
console.info(JSON.stringify(all)); | ||
}); | ||
} |