mirror of
https://github.com/webinstall/webi-installers.git
synced 2026-06-04 06:53:04 +00:00
Compare commits
6 Commits
next
...
ref-ssh-pu
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8a70ae85b7 | ||
|
|
6172fba55f | ||
|
|
24c51bef34 | ||
|
|
fbacd622ee | ||
|
|
345d4fa146 | ||
|
|
fa71ef9002 |
@@ -98,10 +98,9 @@ You just fill in the blanks.
|
||||
Just create an empty directory and run the tests until you get a good result.
|
||||
|
||||
```sh
|
||||
git clone git@github.com:webinstall/webi-installers.git
|
||||
pushd ./webi-installers/
|
||||
git submodule update --init
|
||||
npm clean-install
|
||||
git clone git@github.com:webinstall/packages.git
|
||||
pushd packages
|
||||
npm install
|
||||
```
|
||||
|
||||
```sh
|
||||
|
||||
@@ -1,46 +1,35 @@
|
||||
'use strict';
|
||||
|
||||
var GitHubish = require('./githubish.js');
|
||||
var ghRelease = require('./github.js');
|
||||
|
||||
/**
|
||||
* Lists Gitea Releases (w/ uploaded assets)
|
||||
* Gets the releases for 'ripgrep'. This function could be trimmed down and made
|
||||
* for use with any github release.
|
||||
*
|
||||
* @param {any} _request - deprecated
|
||||
* @param {String} owner
|
||||
* @param {String} repo
|
||||
* @param {String} baseurl
|
||||
* @param {String} [username]
|
||||
* @param {String} [token]
|
||||
* @param request
|
||||
* @param {string} owner
|
||||
* @param {string} repo
|
||||
* @returns {PromiseLike<any> | Promise<any>}
|
||||
*/
|
||||
async function getAllReleases(
|
||||
_request,
|
||||
owner,
|
||||
repo,
|
||||
baseurl,
|
||||
username = '',
|
||||
token = '',
|
||||
) {
|
||||
baseurl = `${baseurl}/api/v1`;
|
||||
let all = await GitHubish.getAllReleases({
|
||||
owner,
|
||||
repo,
|
||||
baseurl,
|
||||
username,
|
||||
token,
|
||||
});
|
||||
return all;
|
||||
function getAllReleases(request, owner, repo, baseurl) {
|
||||
if (!baseurl) {
|
||||
return Promise.reject('missing baseurl');
|
||||
}
|
||||
return ghRelease(request, owner, repo, baseurl + '/api/v1').then(
|
||||
function (all) {
|
||||
return all;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
module.exports = getAllReleases;
|
||||
|
||||
if (module === require.main) {
|
||||
getAllReleases(
|
||||
null,
|
||||
'root',
|
||||
'pathman',
|
||||
'https://git.rootprojects.org',
|
||||
'',
|
||||
'',
|
||||
require('@root/request'),
|
||||
'coolaj86',
|
||||
'go-pathman',
|
||||
'https://git.coolaj86.com',
|
||||
).then(
|
||||
//getAllReleases(require('@root/request'), 'root', 'serviceman', 'https://git.rootprojects.org').then(
|
||||
function (all) {
|
||||
|
||||
@@ -1,41 +1,102 @@
|
||||
'use strict';
|
||||
|
||||
require('dotenv').config({ path: '.env' });
|
||||
|
||||
let GitHubish = require('./githubish.js');
|
||||
require('dotenv').config();
|
||||
|
||||
/**
|
||||
* Lists GitHub Releases (w/ uploaded assets)
|
||||
*
|
||||
* @param {any} _request - deprecated
|
||||
* @param {String} owner
|
||||
* @param {String} repo
|
||||
* @param {String} [baseurl]
|
||||
* @param {String} [username]
|
||||
* @param {String} [token]
|
||||
* @param request
|
||||
* @param {string} owner
|
||||
* @param {string} repo
|
||||
* @returns {PromiseLike<any> | Promise<any>}
|
||||
*/
|
||||
async function getAllReleases(
|
||||
_request,
|
||||
request,
|
||||
owner,
|
||||
repo,
|
||||
baseurl = 'https://api.github.com',
|
||||
username = process.env.GITHUB_USERNAME || '',
|
||||
token = process.env.GITHUB_TOKEN || '',
|
||||
) {
|
||||
let all = await GitHubish.getAllReleases({
|
||||
owner,
|
||||
repo,
|
||||
baseurl,
|
||||
username,
|
||||
token,
|
||||
});
|
||||
if (!owner) {
|
||||
throw new Error('missing owner for repo');
|
||||
}
|
||||
if (!repo) {
|
||||
throw new Error('missing repo name');
|
||||
}
|
||||
|
||||
var req = {
|
||||
url: `${baseurl}/repos/${owner}/${repo}/releases`,
|
||||
json: true,
|
||||
};
|
||||
|
||||
// TODO I really don't like global config, find a way to do better
|
||||
if (process.env.GITHUB_USERNAME) {
|
||||
req.auth = {
|
||||
user: process.env.GITHUB_USERNAME,
|
||||
pass: process.env.GITHUB_TOKEN,
|
||||
};
|
||||
}
|
||||
|
||||
let resp = await request(req);
|
||||
if (!resp.ok) {
|
||||
console.error('Bad Resp Headers:', resp.headers);
|
||||
console.error('Bad Resp Body:', resp.body);
|
||||
throw new Error('the elusive releases BOOGEYMAN strikes again');
|
||||
}
|
||||
|
||||
let gHubResp = resp.body;
|
||||
let all = {
|
||||
releases: [],
|
||||
// todo make this ':baseurl' + ':releasename'
|
||||
download: '',
|
||||
};
|
||||
|
||||
try {
|
||||
gHubResp.forEach(transformReleases);
|
||||
} catch (e) {
|
||||
console.error(e.message);
|
||||
console.error('Error Headers:', resp.headers);
|
||||
console.error('Error Body:', resp.body);
|
||||
throw e;
|
||||
}
|
||||
|
||||
function transformReleases(release) {
|
||||
for (let asset of release['assets']) {
|
||||
let name = asset['name'];
|
||||
let date = release['published_at']?.replace(/T.*/, '');
|
||||
let download = asset['browser_download_url'];
|
||||
|
||||
// TODO tags aren't always semver / sensical
|
||||
let version = release['tag_name'];
|
||||
let channel;
|
||||
if (release['prerelease']) {
|
||||
// -rcX, -preview, -beta, etc will be checked in _webi/normalize.js
|
||||
channel = 'beta';
|
||||
}
|
||||
let lts = /(\b|_)(lts)(\b|_)/.test(release['tag_name']);
|
||||
|
||||
all.releases.push({
|
||||
name: name,
|
||||
version: version,
|
||||
lts: lts,
|
||||
channel: channel,
|
||||
date: date,
|
||||
os: '', // will be guessed by download filename
|
||||
arch: '', // will be guessed by download filename
|
||||
ext: '', // will be normalized
|
||||
download: download,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return all;
|
||||
}
|
||||
|
||||
module.exports = getAllReleases;
|
||||
|
||||
if (module === require.main) {
|
||||
getAllReleases(null, 'BurntSushi', 'ripgrep').then(function (all) {
|
||||
console.info(JSON.stringify(all, null, 2));
|
||||
});
|
||||
getAllReleases(require('@root/request'), 'BurntSushi', 'ripgrep').then(
|
||||
function (all) {
|
||||
console.info(JSON.stringify(all, null, 2));
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,124 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
let GitHubish = module.exports;
|
||||
|
||||
/**
|
||||
* Lists GitHub-Like Releases (w/ uploaded assets)
|
||||
*
|
||||
* @param {Object} opts
|
||||
* @param {String} opts.owner
|
||||
* @param {String} opts.repo
|
||||
* @param {String} opts.baseurl
|
||||
* @param {String} [opts.username]
|
||||
* @param {String} [opts.token]
|
||||
*/
|
||||
GitHubish.getAllReleases = async function ({
|
||||
owner,
|
||||
repo,
|
||||
baseurl,
|
||||
username = '',
|
||||
token = '',
|
||||
}) {
|
||||
if (!owner) {
|
||||
throw new Error('missing owner for repo');
|
||||
}
|
||||
if (!repo) {
|
||||
throw new Error('missing repo name');
|
||||
}
|
||||
if (!baseurl) {
|
||||
throw new Error('missing baseurl');
|
||||
}
|
||||
|
||||
let url = `${baseurl}/repos/${owner}/${repo}/releases`;
|
||||
let opts = {
|
||||
headers: {
|
||||
'Content-Type': 'appplication/json',
|
||||
},
|
||||
};
|
||||
|
||||
if (token) {
|
||||
let userpass = `${username}:${token}`;
|
||||
let basicAuth = btoa(userpass);
|
||||
Object.assign(opts.headers, {
|
||||
Authentication: `Basic ${basicAuth}`,
|
||||
});
|
||||
}
|
||||
|
||||
let resp = await fetch(url, opts);
|
||||
if (!resp.ok) {
|
||||
let headers = Array.from(resp.headers);
|
||||
console.error('Bad Resp Headers:', headers);
|
||||
let text = await resp.text();
|
||||
console.error('Bad Resp Body:', text);
|
||||
let msg = `failed to fetch releases from '${baseurl}' with user '${username}'`;
|
||||
throw new Error(msg);
|
||||
}
|
||||
|
||||
let respText = await resp.text();
|
||||
let gHubResp;
|
||||
try {
|
||||
gHubResp = JSON.parse(respText);
|
||||
} catch (e) {
|
||||
console.error('Bad Resp JSON:', respText);
|
||||
console.error(e.message);
|
||||
let msg = `failed to parse releases from '${baseurl}' with user '${username}'`;
|
||||
throw new Error(msg);
|
||||
}
|
||||
|
||||
let all = {
|
||||
releases: [],
|
||||
// todo make this ':baseurl' + ':releasename'
|
||||
download: '',
|
||||
};
|
||||
|
||||
try {
|
||||
gHubResp.forEach(transformReleases);
|
||||
} catch (e) {
|
||||
console.error(e.message);
|
||||
console.error('Error Headers:', resp.headers);
|
||||
console.error('Error Body:', resp.body);
|
||||
let msg = `failed to transform releases from '${baseurl}' with user '${username}'`;
|
||||
throw new Error(msg);
|
||||
}
|
||||
|
||||
function transformReleases(release) {
|
||||
for (let asset of release['assets']) {
|
||||
let name = asset['name'];
|
||||
let date = release['published_at']?.replace(/T.*/, '');
|
||||
let download = asset['browser_download_url'];
|
||||
|
||||
// TODO tags aren't always semver / sensical
|
||||
let version = release['tag_name'];
|
||||
let channel;
|
||||
if (release['prerelease']) {
|
||||
// -rcX, -preview, -beta, etc will be checked in _webi/normalize.js
|
||||
channel = 'beta';
|
||||
}
|
||||
let lts = /(\b|_)(lts)(\b|_)/.test(release['tag_name']);
|
||||
|
||||
all.releases.push({
|
||||
name: name,
|
||||
version: version,
|
||||
lts: lts,
|
||||
channel: channel,
|
||||
date: date,
|
||||
os: '', // will be guessed by download filename
|
||||
arch: '', // will be guessed by download filename
|
||||
ext: '', // will be normalized
|
||||
download: download,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return all;
|
||||
};
|
||||
|
||||
if (module === require.main) {
|
||||
GitHubish.getAllReleases({
|
||||
owner: 'BurntSushi',
|
||||
repo: 'ripgrep',
|
||||
baseurl: 'https://api.github.com',
|
||||
}).then(function (all) {
|
||||
console.info(JSON.stringify(all, null, 2));
|
||||
});
|
||||
}
|
||||
@@ -202,7 +202,7 @@ __bootstrap_webi() {
|
||||
unzstd -c --keep "${WEBI_PKG_PATH}/$WEBI_PKG_FILE" | tar xf -
|
||||
elif test "$WEBI_EXT" = "tar.xz"; then
|
||||
echo " Extracting $(t_path "${my_dl_rel}")"
|
||||
unxz -c -k "${WEBI_PKG_PATH}/$WEBI_PKG_FILE" | tar xf -
|
||||
unxz -c --keep "${WEBI_PKG_PATH}/$WEBI_PKG_FILE" | tar xf -
|
||||
elif test "$WEBI_EXT" = "tar.gz"; then
|
||||
echo " Extracting $(t_path "${my_dl_rel}")"
|
||||
tar xzf "${WEBI_PKG_PATH}/$WEBI_PKG_FILE"
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var path = require('path');
|
||||
|
||||
var github = require('../_common/github.js');
|
||||
var owner = 'eugeneware';
|
||||
var repo = 'ffmpeg-static';
|
||||
|
||||
module.exports = function (request) {
|
||||
return github(request, owner, repo).then(function (all) {
|
||||
all.releases = all.releases
|
||||
.filter(function (rel) {
|
||||
let isFfmpeg = rel.name.includes('ffmpeg');
|
||||
if (!isFfmpeg) {
|
||||
return;
|
||||
}
|
||||
|
||||
// remove README and LICENSE
|
||||
return !['.README', '.LICENSE'].includes(path.extname(rel.name));
|
||||
})
|
||||
.map(function (rel) {
|
||||
rel.version = rel.version.replace(/^b/, '');
|
||||
|
||||
if (/win32/.test(rel.name)) {
|
||||
rel.os = 'windows';
|
||||
rel.ext = 'exe';
|
||||
}
|
||||
if (/ia32/.test(rel.name)) {
|
||||
rel.arch = '386';
|
||||
} else if (/x64/.test(rel.name)) {
|
||||
rel.arch = 'amd64';
|
||||
}
|
||||
|
||||
return rel;
|
||||
});
|
||||
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));
|
||||
});
|
||||
}
|
||||
@@ -3,51 +3,17 @@ set -e
|
||||
set -u
|
||||
|
||||
if command -v fish > /dev/null; then
|
||||
if ! test -r ~/.config/fish/config.fish; then
|
||||
if [ ! -e ~/.config/fish/config.fish ]; then
|
||||
mkdir -p ~/.config/fish
|
||||
touch ~/.config/fish/config.fish
|
||||
chmod 0600 ~/.config/fish/config.fish
|
||||
fi
|
||||
else
|
||||
if command -v sudo > /dev/null; then
|
||||
my_answer='n'
|
||||
if command -v apt > /dev/null; then
|
||||
echo ""
|
||||
echo "ERROR"
|
||||
echo " No Webi installer for fish on Linux yet."
|
||||
echo ""
|
||||
echo "SOLUTION"
|
||||
echo " Would you like to install with apt?"
|
||||
echo " sudo apt install -y fish"
|
||||
echo ""
|
||||
printf "Install with sudo and apt [Y/n]? "
|
||||
elif command -v apk > /dev/null; then
|
||||
echo ""
|
||||
echo "ERROR"
|
||||
echo " No Webi installer for fish on Alpine yet."
|
||||
echo ""
|
||||
echo "SOLUTION"
|
||||
echo " Would you like to install with apk?"
|
||||
echo " sudo apk add --no-cache fish"
|
||||
echo ""
|
||||
printf "Install with sudo and apk [Y/n]? "
|
||||
elif test "Darwin" != "$(uname -s)"; then
|
||||
echo "No fish installer for Linux yet."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
read -r my_answer < /dev/tty
|
||||
if test -z "${my_answer}" ||
|
||||
test "${my_answer}" = "Y" ||
|
||||
test "${my_answer}" = "y"; then
|
||||
sudo apt install -y fish
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
elif test "Darwin" != "$(uname -s)"; then
|
||||
echo "No fish installer for Linux yet."
|
||||
exit 1
|
||||
fi
|
||||
if [ "Darwin" != "$(uname -s)" ]; then
|
||||
echo "No fish installer for Linux yet. Try this instead:"
|
||||
echo " sudo apt install -y fish"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
################
|
||||
@@ -71,10 +37,6 @@ pkg_src="$pkg_src_cmd"
|
||||
# pkg_install must be defined by every package
|
||||
|
||||
_macos_post_install() {
|
||||
if test "Darwin" != "$(uname -s)"; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
if ! [ -e "$HOME/.local/bin/fish" ]; then
|
||||
return 0
|
||||
fi
|
||||
@@ -109,10 +71,8 @@ _macos_post_install() {
|
||||
killall cfprefsd
|
||||
}
|
||||
|
||||
if test "Darwin" = "$(uname -s)"; then
|
||||
# always try to reset the default shells
|
||||
_macos_post_install
|
||||
fi
|
||||
# always try to reset the default shells
|
||||
_macos_post_install
|
||||
|
||||
pkg_install() {
|
||||
mv fish.app/Contents/Resources/base/usr/local "$HOME/.local/opt/fish-v${WEBI_VERSION}"
|
||||
@@ -124,10 +84,7 @@ pkg_post_install() {
|
||||
webi_post_install
|
||||
|
||||
# try again to update default shells, now that all files should exist
|
||||
if test "Darwin" = "$(uname -s)"; then
|
||||
# always try to reset the default shells
|
||||
_macos_post_install
|
||||
fi
|
||||
_macos_post_install
|
||||
|
||||
if [ ! -e ~/.config/fish/config.fish ]; then
|
||||
mkdir -p ~/.config/fish
|
||||
|
||||
@@ -14,57 +14,11 @@ __init_git() {
|
||||
echo >&2 " for example, try: xcode-select --install"
|
||||
# sudo xcodebuild -license accept
|
||||
else
|
||||
fn_prompt_sudo_install git
|
||||
echo >&2 "Error: to install 'git' on Linux use the built-in package manager."
|
||||
echo >&2 " for example, try: sudo apt install -y git"
|
||||
fi
|
||||
|
||||
exit 1
|
||||
}
|
||||
|
||||
fn_prompt_sudo_install() {
|
||||
a_pkg="${1}"
|
||||
|
||||
if command -v sudo > /dev/null; then
|
||||
my_answer='n'
|
||||
cmd_pkg_add=''
|
||||
if command -v apt > /dev/null; then
|
||||
echo ""
|
||||
echo "ERROR"
|
||||
echo " No Webi installer for ${a_pkg} on Linux yet."
|
||||
echo ""
|
||||
echo "SOLUTION"
|
||||
echo " Would you like to install with apt?"
|
||||
echo " sudo apt install -y ${a_pkg}"
|
||||
echo ""
|
||||
printf "Install with sudo and apt [Y/n]? "
|
||||
cmd_pkg_add='sudo apt install -y'
|
||||
elif command -v apk > /dev/null; then
|
||||
echo ""
|
||||
echo "ERROR"
|
||||
echo " No Webi installer for ${a_pkg} on Alpine yet."
|
||||
echo ""
|
||||
echo "SOLUTION"
|
||||
echo " Would you like to install with apk?"
|
||||
echo " sudo apk add --no-cache ${a_pkg}"
|
||||
echo ""
|
||||
printf "Install with sudo and apk [Y/n]? "
|
||||
cmd_pkg_add='sudo apk add --no-cache'
|
||||
elif test "Darwin" != "$(uname -s)"; then
|
||||
echo "No ${a_pkg} installer for Linux yet."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
read -r my_answer < /dev/tty
|
||||
if test -z "${my_answer}" ||
|
||||
test "${my_answer}" = "Y" ||
|
||||
test "${my_answer}" = "y"; then
|
||||
$cmd_pkg_add "${a_pkg}"
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
elif test "Darwin" != "$(uname -s)"; then
|
||||
echo "No ${a_pkg} installer for Linux yet."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
__init_git
|
||||
|
||||
@@ -45,10 +45,8 @@ __init_pwsh() {
|
||||
}
|
||||
|
||||
pkg_done_message() {
|
||||
# We print the version here to ensure the install completed without
|
||||
# errors - no missing libraries, not incompatible arch, etc
|
||||
echo ""
|
||||
"$pkg_dst_cmd" -V
|
||||
echo "Installed 'pwsh' at $pkg_dst"
|
||||
pwsh -V
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -74,24 +74,26 @@ main() {
|
||||
else
|
||||
my_keytype='rsa'
|
||||
echo >&2 ""
|
||||
echo >&2 "Generating public/private rsa key pair."
|
||||
ssh-keygen -b 4096 -t rsa -f ~/.ssh/id_rsa -q -N ""
|
||||
ssh-keygen -y -f ~/.ssh/id_rsa > ~/.ssh/id_rsa.pub
|
||||
fi
|
||||
|
||||
# TODO use the comment (if any) for the name of the file
|
||||
my_comment="$(tr '[:space:]' '\n' < "$HOME/.ssh/id_${my_keytype}.pub" | grep '\w' | tail -n 1)"
|
||||
if test -z "${my_comment}" || test "${my_comment#}" -gt 100; then
|
||||
my_comment="$(id -u -n)"
|
||||
fi
|
||||
echo >&2 ""
|
||||
#shellcheck disable=SC2088
|
||||
echo >&2 "~/Downloads/id_${my_keytype}.$(whoami).pub":
|
||||
echo >&2 "~/Downloads/id_${my_keytype}.${my_comment}.pub":
|
||||
echo >&2 ""
|
||||
rm -f "$HOME/Downloads/id_${my_keytype}.$(whoami).pub"
|
||||
cp -RPp "$HOME/.ssh/id_${my_keytype}.pub" "$HOME/Downloads/id_${my_keytype}.$(whoami).pub"
|
||||
cat "$HOME/Downloads/id_${my_keytype}.$(whoami).pub"
|
||||
rm -f "$HOME/Downloads/id_${my_keytype}.${my_comment}.pub"
|
||||
cp -RPp "$HOME/.ssh/id_${my_keytype}.pub" "$HOME/Downloads/id_${my_keytype}.${my_comment}.pub"
|
||||
cat "$HOME/Downloads/id_${my_keytype}.${my_comment}.pub"
|
||||
echo >&2 ""
|
||||
|
||||
if test -f ~/.ssh/id_rsa; then
|
||||
my_rsa_chars="$(cat ~/.ssh/id_rsa)"
|
||||
if test "${#my_rsa_chars}" -lt 2500; then
|
||||
my_rsa_size="$(wc < ~/.ssh/id_rsa | rev | cut -d' ' -f1 | rev)"
|
||||
if test "${my_rsa_size}" -lt 2500; then
|
||||
fn_warn_rsa >&2
|
||||
echo >&2 ""
|
||||
fi
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: vim-devicons
|
||||
homepage: https://github.com/ryanoasis/vim-devicons
|
||||
homepage: https://github.com/ryanoasis/devicons
|
||||
tagline: |
|
||||
VimDevIcons: Adds Icons to Your Plugins.
|
||||
---
|
||||
|
||||
Reference in New Issue
Block a user