add example dir

This commit is contained in:
AJ ONeal
2020-05-06 22:52:16 -06:00
parent 1c8b477efd
commit 82ba9cd633
4 changed files with 153 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
---
title: Foo Bar
bin: foobar
homepage: https://example.com/foobar
tagline: To err is human, but to foobar...
---
<!--
- The first h1 is for README.md preview only and will be ignored
-->
# Foo Bar
<!--
- Everything before the first h1 is ignored
- Everything after that and before the first h2 is the description
-->
Foo Bar is a community-developed, commercially supported destruction system.
## Examples
Really mess something up
```bash
foobar my-file.txt
```
Mess up the entire volume, forcefully and recursively
```bash
foobar -rf /
```
+78
View File
@@ -0,0 +1,78 @@
#!/bin/bash
set -e
set -u
###################
# Install foobar #
###################
common_opt="${HOME}/.local/opt/foobar-v${WEBI_VERSION}"
new_opt="${HOME}/.local/opt/foobar-v${WEBI_VERSION}"
new_bin="${HOME}/.local/opt/foobar-v${WEBI_VERSION}/bin/foobar"
update_installed() {
rm -rf "$common_opt"
ln -s "$new_opt" "$common_opt"
# TODO get better output from pathman / output the path to add as return to webi bootstrap
webi_path_add "$common_opt/bin"
webi_path_add "$HOME/foobar/bin"
}
if [ -x "$new_opt/bin/foobar" ]; then
update_installed
exit 0
fi
# Test for existing version
set +e
cur_go="$(command -v foobar)"
set -e
if [ -n "$cur_go" ]; then
cur_ver=$(foobar version | cut -d' ' -f3 | sed 's:foobar::')
if [ "$cur_ver" == "$(echo $WEBI_VERSION | sed 's:\.0::g')" ]; then
echo "foobar v$WEBI_VERSION already installed at $cur_go"
exit 0
elif [ "$cur_go" != "$new_bin" ]; then
echo "WARN: possible conflict with foobar v$WEBI_VERSION at $cur_go"
fi
fi
# Note: this file is `source`d by the true installer and hence will have the webi functions
# because we created releases.js we can use webi_download()
# downloads foobar to ~/Downloads
webi_download
# because this is tar or zip, we can webi_extract()
# extracts to the WEBI_TMP directory, raw (no --strip-prefix)
webi_extract
pushd "$WEBI_TMP" 2>&1 >/dev/null
echo Installing foobar v${WEBI_VERSION} as "$new_bin"
# simpler for single-binary commands
#mv ./example*/bin/example "$HOME/.local/bin"
# best for packages and toolchains
rm -rf "$new_opt"
if [ -n "$(command -v rsync 2>/dev/null | grep rsync)" ]; then
rsync -Krl ./foobar*/ "$new_opt/" 2>/dev/null
else
cp -Hr ./foobar*/* "$new_opt/" 2>/dev/null
cp -Hr ./foobar*/.* "$new_opt/" 2>/dev/null
fi
rm -rf ./foobar*
popd 2>&1 >/dev/null
###################
# Update PATH #
###################
update_installed
echo "Installed 'foobar'"
echo ""
+1
View File
@@ -0,0 +1 @@
rem TODO
+41
View File
@@ -0,0 +1,41 @@
'use strict';
var github = require('../_common/github.js');
var owner = 'HorseAJ86';
var repo = 'shmatter';
module.exports = function (request) {
// 1. fetch the list of releases
// 2. translate into the style of object that webinstall needs
// 3. missing / guessable pieces will be filled automatically by filename and such
// (in this example the github releases module does 100% of the work)
return github(request, owner, repo).then(function (data) {
var releases = data.releases;
/*
// Example:
var releases = [{
"name": "shmatter-darwin-x64-1.0.0.tgz",
"version": "v1.0.0",
"lts": false, // long-term support release
"channel": "stable", // stable|rc|beta|dev
"date": "2020-05-07",
"download": "https://github.com/HorseAJ86/shmatter/releases/download/v1.0.0/shmatter-darwin-x64-1.0.0.tgz",
"os": "", // will be guessed as macos (darwin -> macos)
"arch": "", // will be guessed as amd64 (x64 -> amd64)
"ext": "" // will be guessed as tar (tgz -> tar.gz -> tar)
}]
*/
return { releases: releases };
});
};
if (module === require.main) {
module.exports(require('@root/request')).then(function (all) {
// limit the example output
all.releases = all.releases.slice(0, 5);
console.info(JSON.stringify(all, null, 2));
});
}