Compare commits

..

22 Commits

Author SHA1 Message Date
AJ ONeal
5dacdc7b9a wip: ffprobe 2024-07-15 19:34:29 -06:00
AJ ONeal
5c7a218d88 feat(git): option to install from package manager 2024-07-15 19:34:29 -06:00
AJ ONeal
01ae7f5603 feat(fish): option to install from package manager 2024-07-15 19:34:29 -06:00
AJ ONeal
5c12cb1fa7 fix(busybox): use -k instead of --keep 2024-06-05 17:40:01 +00:00
AJ ONeal
b1738741d1 ref!(github-like): use 'fetch' instead of '@root/request' 2024-06-05 17:37:20 +00:00
AJ ONeal
125ffa96dc ref(github-like): pass options object for args 2024-06-05 17:37:19 +00:00
AJ ONeal
dca40ff2ed ref+sec(github-like): lift _common/github.js from _common/githubish.js 2024-06-05 17:35:28 +00:00
AJ ONeal
36af48aceb ref(github-like): rename _common/githubish.js 2024-06-05 17:35:28 +00:00
AJ ONeal
9e9c3a610d fix(github-like): don't send GitHub Tokens to GitHub-like APIs (i.e. Gitea) 2024-06-05 17:35:21 +00:00
AJ ONeal
fefeb076f2 doc(github-like): update types 2024-06-05 17:35:20 +00:00
AJ ONeal
e54262cf13 ref(ssh-pubkey): show key generation message since it takes so long 2024-06-05 17:32:38 +00:00
AJ ONeal
6c5b040b8c fix: update ssh-pubkey for modern 3072+ bit and ed25519 keys 2024-06-05 17:32:37 +00:00
AJ ONeal
e872442f3b fix(ssh-pubkey): use POSIX-compliant cp -RPp 2024-06-05 17:32:14 +00:00
AJ ONeal
2d65bb14ff ref(ssh-pubkey): prefer 'test ...' over '[ ... ]' 2024-06-05 17:32:14 +00:00
AJ ONeal
5ead8362c0 ref(ssh-pubkey): prefer ~ over $HOME for unquoted paths 2024-06-05 17:32:13 +00:00
AJ ONeal
88a9319431 chore: remove junk file vim-things.sh 2024-06-05 17:32:12 +00:00
AJ ONeal
7b70ab8538 ref(pwsh): cleanup and comment 'pkg_done_message' 2024-05-16 21:10:25 +00:00
Victor Irzak
974e2cfc9c fix: Use full path to call pwsh, since it is not in the PATH yet 2024-05-16 21:10:04 +00:00
AJ ONeal
3810cd621e doc(README.md): use 'npm clean-install' 2024-05-16 20:35:44 +00:00
HacDan
8ffba627f3 docs(README.md): add command for cloning submodules to readme 2024-05-16 20:34:51 +00:00
HacDan
1a3f22e2ba docs(README.md): update readme to reflect repo name change
Updated README.md from packages to webi-installers to be in line with current project structure
2024-05-16 20:34:37 +00:00
Patrick Matthiesen
48574168a8 Fix vim-devicons homepage link
added the missing 'vim-' from the repository name

Signed-off-by: Patrick Matthiesen <43612965+PatrickMatthiesen@users.noreply.github.com>
2024-05-11 22:48:40 +02:00
11 changed files with 340 additions and 131 deletions

View File

@@ -98,9 +98,10 @@ You just fill in the blanks.
Just create an empty directory and run the tests until you get a good result. Just create an empty directory and run the tests until you get a good result.
```sh ```sh
git clone git@github.com:webinstall/packages.git git clone git@github.com:webinstall/webi-installers.git
pushd packages pushd ./webi-installers/
npm install git submodule update --init
npm clean-install
``` ```
```sh ```sh

View File

@@ -1,35 +1,46 @@
'use strict'; 'use strict';
var ghRelease = require('./github.js'); var GitHubish = require('./githubish.js');
/** /**
* Gets the releases for 'ripgrep'. This function could be trimmed down and made * Lists Gitea Releases (w/ uploaded assets)
* for use with any github release.
* *
* @param request * @param {any} _request - deprecated
* @param {string} owner * @param {String} owner
* @param {string} repo * @param {String} repo
* @returns {PromiseLike<any> | Promise<any>} * @param {String} baseurl
* @param {String} [username]
* @param {String} [token]
*/ */
function getAllReleases(request, owner, repo, baseurl) { async function getAllReleases(
if (!baseurl) { _request,
return Promise.reject('missing baseurl'); owner,
} repo,
return ghRelease(request, owner, repo, baseurl + '/api/v1').then( baseurl,
function (all) { username = '',
token = '',
) {
baseurl = `${baseurl}/api/v1`;
let all = await GitHubish.getAllReleases({
owner,
repo,
baseurl,
username,
token,
});
return all; return all;
},
);
} }
module.exports = getAllReleases; module.exports = getAllReleases;
if (module === require.main) { if (module === require.main) {
getAllReleases( getAllReleases(
require('@root/request'), null,
'coolaj86', 'root',
'go-pathman', 'pathman',
'https://git.coolaj86.com', 'https://git.rootprojects.org',
'',
'',
).then( ).then(
//getAllReleases(require('@root/request'), 'root', 'serviceman', 'https://git.rootprojects.org').then( //getAllReleases(require('@root/request'), 'root', 'serviceman', 'https://git.rootprojects.org').then(
function (all) { function (all) {

View File

@@ -1,102 +1,41 @@
'use strict'; 'use strict';
require('dotenv').config(); require('dotenv').config({ path: '.env' });
let GitHubish = require('./githubish.js');
/** /**
* Lists GitHub Releases (w/ uploaded assets) * Lists GitHub Releases (w/ uploaded assets)
* *
* @param request * @param {any} _request - deprecated
* @param {string} owner * @param {String} owner
* @param {string} repo * @param {String} repo
* @returns {PromiseLike<any> | Promise<any>} * @param {String} [baseurl]
* @param {String} [username]
* @param {String} [token]
*/ */
async function getAllReleases( async function getAllReleases(
request, _request,
owner, owner,
repo, repo,
baseurl = 'https://api.github.com', baseurl = 'https://api.github.com',
username = process.env.GITHUB_USERNAME || '',
token = process.env.GITHUB_TOKEN || '',
) { ) {
if (!owner) { let all = await GitHubish.getAllReleases({
throw new Error('missing owner for repo'); owner,
} repo,
if (!repo) { baseurl,
throw new Error('missing repo name'); username,
} token,
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; return all;
} }
module.exports = getAllReleases; module.exports = getAllReleases;
if (module === require.main) { if (module === require.main) {
getAllReleases(require('@root/request'), 'BurntSushi', 'ripgrep').then( getAllReleases(null, 'BurntSushi', 'ripgrep').then(function (all) {
function (all) {
console.info(JSON.stringify(all, null, 2)); console.info(JSON.stringify(all, null, 2));
}, });
);
} }

124
_common/githubish.js Normal file
View File

@@ -0,0 +1,124 @@
'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));
});
}

View File

@@ -202,7 +202,7 @@ __bootstrap_webi() {
unzstd -c --keep "${WEBI_PKG_PATH}/$WEBI_PKG_FILE" | tar xf - unzstd -c --keep "${WEBI_PKG_PATH}/$WEBI_PKG_FILE" | tar xf -
elif test "$WEBI_EXT" = "tar.xz"; then elif test "$WEBI_EXT" = "tar.xz"; then
echo " Extracting $(t_path "${my_dl_rel}")" echo " Extracting $(t_path "${my_dl_rel}")"
unxz -c --keep "${WEBI_PKG_PATH}/$WEBI_PKG_FILE" | tar xf - unxz -c -k "${WEBI_PKG_PATH}/$WEBI_PKG_FILE" | tar xf -
elif test "$WEBI_EXT" = "tar.gz"; then elif test "$WEBI_EXT" = "tar.gz"; then
echo " Extracting $(t_path "${my_dl_rel}")" echo " Extracting $(t_path "${my_dl_rel}")"
tar xzf "${WEBI_PKG_PATH}/$WEBI_PKG_FILE" tar xzf "${WEBI_PKG_PATH}/$WEBI_PKG_FILE"

45
ffprobe/releases.js Normal file
View File

@@ -0,0 +1,45 @@
'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));
});
}

View File

@@ -3,18 +3,52 @@ set -e
set -u set -u
if command -v fish > /dev/null; then if command -v fish > /dev/null; then
if [ ! -e ~/.config/fish/config.fish ]; then if ! test -r ~/.config/fish/config.fish; then
mkdir -p ~/.config/fish mkdir -p ~/.config/fish
touch ~/.config/fish/config.fish touch ~/.config/fish/config.fish
chmod 0600 ~/.config/fish/config.fish chmod 0600 ~/.config/fish/config.fish
fi 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
if [ "Darwin" != "$(uname -s)" ]; then read -r my_answer < /dev/tty
echo "No fish installer for Linux yet. Try this instead:" if test -z "${my_answer}" ||
echo " sudo apt install -y fish" test "${my_answer}" = "Y" ||
test "${my_answer}" = "y"; then
sudo apt install -y fish
else
exit 1 exit 1
fi fi
elif test "Darwin" != "$(uname -s)"; then
echo "No fish installer for Linux yet."
exit 1
fi
fi
################ ################
# Install fish # # Install fish #
@@ -37,6 +71,10 @@ pkg_src="$pkg_src_cmd"
# pkg_install must be defined by every package # pkg_install must be defined by every package
_macos_post_install() { _macos_post_install() {
if test "Darwin" != "$(uname -s)"; then
return 0
fi
if ! [ -e "$HOME/.local/bin/fish" ]; then if ! [ -e "$HOME/.local/bin/fish" ]; then
return 0 return 0
fi fi
@@ -71,8 +109,10 @@ _macos_post_install() {
killall cfprefsd killall cfprefsd
} }
if test "Darwin" = "$(uname -s)"; then
# always try to reset the default shells # always try to reset the default shells
_macos_post_install _macos_post_install
fi
pkg_install() { pkg_install() {
mv fish.app/Contents/Resources/base/usr/local "$HOME/.local/opt/fish-v${WEBI_VERSION}" mv fish.app/Contents/Resources/base/usr/local "$HOME/.local/opt/fish-v${WEBI_VERSION}"
@@ -84,7 +124,10 @@ pkg_post_install() {
webi_post_install webi_post_install
# try again to update default shells, now that all files should exist # 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 _macos_post_install
fi
if [ ! -e ~/.config/fish/config.fish ]; then if [ ! -e ~/.config/fish/config.fish ]; then
mkdir -p ~/.config/fish mkdir -p ~/.config/fish

View File

@@ -14,11 +14,57 @@ __init_git() {
echo >&2 " for example, try: xcode-select --install" echo >&2 " for example, try: xcode-select --install"
# sudo xcodebuild -license accept # sudo xcodebuild -license accept
else else
echo >&2 "Error: to install 'git' on Linux use the built-in package manager." fn_prompt_sudo_install git
echo >&2 " for example, try: sudo apt install -y git"
fi fi
exit 1 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 __init_git

View File

@@ -45,8 +45,10 @@ __init_pwsh() {
} }
pkg_done_message() { pkg_done_message() {
echo "Installed 'pwsh' at $pkg_dst" # We print the version here to ensure the install completed without
pwsh -V # errors - no missing libraries, not incompatible arch, etc
echo ""
"$pkg_dst_cmd" -V
} }
} }

View File

@@ -74,26 +74,24 @@ main() {
else else
my_keytype='rsa' my_keytype='rsa'
echo >&2 "" echo >&2 ""
echo >&2 "Generating public/private rsa key pair."
ssh-keygen -b 4096 -t rsa -f ~/.ssh/id_rsa -q -N "" ssh-keygen -b 4096 -t rsa -f ~/.ssh/id_rsa -q -N ""
ssh-keygen -y -f ~/.ssh/id_rsa > ~/.ssh/id_rsa.pub ssh-keygen -y -f ~/.ssh/id_rsa > ~/.ssh/id_rsa.pub
fi fi
my_comment="$(tr '[:space:]' '\n' < "$HOME/.ssh/id_${my_keytype}.pub" | grep '\w' | tail -n 1)" # TODO use the comment (if any) for the name of the file
if test -z "${my_comment}" || test "${my_comment#}" -gt 100; then
my_comment="$(id -u -n)"
fi
echo >&2 "" echo >&2 ""
#shellcheck disable=SC2088 #shellcheck disable=SC2088
echo >&2 "~/Downloads/id_${my_keytype}.${my_comment}.pub": echo >&2 "~/Downloads/id_${my_keytype}.$(whoami).pub":
echo >&2 "" echo >&2 ""
rm -f "$HOME/Downloads/id_${my_keytype}.${my_comment}.pub" rm -f "$HOME/Downloads/id_${my_keytype}.$(whoami).pub"
cp -RPp "$HOME/.ssh/id_${my_keytype}.pub" "$HOME/Downloads/id_${my_keytype}.${my_comment}.pub" cp -RPp "$HOME/.ssh/id_${my_keytype}.pub" "$HOME/Downloads/id_${my_keytype}.$(whoami).pub"
cat "$HOME/Downloads/id_${my_keytype}.${my_comment}.pub" cat "$HOME/Downloads/id_${my_keytype}.$(whoami).pub"
echo >&2 "" echo >&2 ""
if test -f ~/.ssh/id_rsa; then if test -f ~/.ssh/id_rsa; then
my_rsa_size="$(wc < ~/.ssh/id_rsa | rev | cut -d' ' -f1 | rev)" my_rsa_chars="$(cat ~/.ssh/id_rsa)"
if test "${my_rsa_size}" -lt 2500; then if test "${#my_rsa_chars}" -lt 2500; then
fn_warn_rsa >&2 fn_warn_rsa >&2
echo >&2 "" echo >&2 ""
fi fi

View File

@@ -1,6 +1,6 @@
--- ---
title: vim-devicons title: vim-devicons
homepage: https://github.com/ryanoasis/devicons homepage: https://github.com/ryanoasis/vim-devicons
tagline: | tagline: |
VimDevIcons: Adds Icons to Your Plugins. VimDevIcons: Adds Icons to Your Plugins.
--- ---