aboutsummaryrefslogtreecommitdiff
path: root/build.sh
blob: c03ee96b1b5e8b268d4274c6e00c519ab7ee0974 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash

api_key="${1}"
skel="${2}"
plugin="${3}"
name="${4:=${3#*/}}"

if ! [[ -e ${skel} ]]
	|| [[ -z ${api_key} ]]
	|| [[ -z ${plugin} ]]; then
	>&2 echo "usage: ${0} <github api key> <skel file> <nvim/package> <plugin name>"
	exit -1
fi

echo "generating app-nvim/${name}"

repo_info=$(curl -L \
	-H "Accept: application/vnd.github+json" \
	-H "Authorization: Bearer ${api_key}" \
	https://api.github.com/repos/${plugin} 2>/dev/null)

src=https://github.com/${plugin}
desc=$(jq -r .description <<< ${repo_info})
license=$(jq -r .license.spdx_id <<< ${repo_info})
url=$(jq -r .html_url <<< ${repo_info})

mkdir -p app-nvim/${name}
sed -e "s#@DESCRIPTION@#${desc}#" \
	-e "s#@URI@#${url}#" \
	-e "s#@SRC@#${src}#" \
	-e "s#@LICENSE@#${license}#" \
	-e "s#@PLUGIN@#${plugin}#" \
	${skel} > app-nvim/${name}/${name}-9999.ebuild