feat(plugins): Added the official bootstrap plugin repository
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
# pardon my french
|
||||
parse_json() {
|
||||
# Tokenize the JSON using grep
|
||||
grep -oE '"([^"\\]|\\.)*"|true|false|null|[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?|[{}[\]:,]' | \
|
||||
grep -oE '"([^"\\]|\\.)*"|true|false|null|[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?|[][}{:,]' | \
|
||||
awk '
|
||||
BEGIN {
|
||||
depth=0;
|
||||
|
||||
13
lib/plugin_cache.sh
Normal file
13
lib/plugin_cache.sh
Normal file
@@ -0,0 +1,13 @@
|
||||
# Auto-generated plugin cache. Do not edit manually.
|
||||
declare -g -A PLUGIN_URLS
|
||||
declare -g -A PLUGIN_VERSIONS
|
||||
declare -g -A PLUGIN_BOOTSTRAP_VERSIONS
|
||||
PLUGIN_VERSIONS["weather"]="1.0.0"
|
||||
PLUGIN_URLS["weather"]="https://git.adityagupta.dev/sortedcord/bootstrap/raw/branch/master/official_plugins/weather.sh"
|
||||
PLUGIN_BOOTSTRAP_VERSIONS["weather"]="2.1.0"
|
||||
PLUGIN_VERSIONS["sysinfo"]="1.0.0"
|
||||
PLUGIN_URLS["sysinfo"]="https://git.adityagupta.dev/sortedcord/bootstrap/raw/branch/master/official_plugins/sysinfo.sh"
|
||||
PLUGIN_BOOTSTRAP_VERSIONS["sysinfo"]="2.1.0"
|
||||
PLUGIN_VERSIONS["todo"]="1.0.0"
|
||||
PLUGIN_URLS["todo"]="https://git.adityagupta.dev/sortedcord/bootstrap/raw/branch/master/official_plugins/todo.sh"
|
||||
PLUGIN_BOOTSTRAP_VERSIONS["todo"]="2.1.0"
|
||||
@@ -39,14 +39,28 @@ parse_plugin_manifest() {
|
||||
print "PLUGIN_VERSIONS[\"" plugin_name "\"]=\"" val "\""
|
||||
} else if (prop == "url") {
|
||||
print "PLUGIN_URLS[\"" plugin_name "\"]=\"" val "\""
|
||||
} else if (prop == "bootstrap") {
|
||||
print "PLUGIN_BOOTSTRAP_VERSIONS[\"" plugin_name "\"]=\"" val "\""
|
||||
}
|
||||
}
|
||||
}
|
||||
}'
|
||||
}
|
||||
|
||||
# Ensures that the plugin sources file exists, initializing it with the official repository by default
|
||||
ensure_sources_file() {
|
||||
local sources_file="$BOOTSTRAP_DIR/plugin_sources.txt"
|
||||
if [ ! -f "$sources_file" ]; then
|
||||
mkdir -p "$BOOTSTRAP_DIR"
|
||||
echo "# Add raw URLs to JSON plugin manifests here, one per line." > "$sources_file"
|
||||
echo "# Official Bootstrap plugin repository" >> "$sources_file"
|
||||
echo "https://git.adityagupta.dev/sortedcord/bootstrap/raw/branch/master/plugins.json" >> "$sources_file"
|
||||
fi
|
||||
}
|
||||
|
||||
# Fetches manifests from sources and generates the cache
|
||||
update_plugin_cache() {
|
||||
ensure_sources_file
|
||||
local cache_file="$BOOTSTRAP_DIR/lib/plugin_cache.sh"
|
||||
local sources_file="$BOOTSTRAP_DIR/plugin_sources.txt"
|
||||
|
||||
@@ -57,6 +71,7 @@ update_plugin_cache() {
|
||||
# Auto-generated plugin cache. Do not edit manually.
|
||||
declare -g -A PLUGIN_URLS
|
||||
declare -g -A PLUGIN_VERSIONS
|
||||
declare -g -A PLUGIN_BOOTSTRAP_VERSIONS
|
||||
EOF
|
||||
|
||||
if [ -f "$sources_file" ]; then
|
||||
@@ -93,11 +108,8 @@ EOF
|
||||
}
|
||||
|
||||
manage_plugin_sources() {
|
||||
ensure_sources_file
|
||||
local sources_file="$BOOTSTRAP_DIR/plugin_sources.txt"
|
||||
if [ ! -f "$sources_file" ]; then
|
||||
touch "$sources_file"
|
||||
echo "# Add raw URLs to JSON plugin manifests here, one per line." > "$sources_file"
|
||||
fi
|
||||
|
||||
local editor="${EDITOR:-}"
|
||||
if [ -z "$editor" ]; then
|
||||
@@ -151,6 +163,18 @@ run_plugin() {
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Check compatibility version
|
||||
local compat_ver="${PLUGIN_BOOTSTRAP_VERSIONS[$plugin_name]:-}"
|
||||
if [ -n "$compat_ver" ]; then
|
||||
local current_ver="0.0.0"
|
||||
if [ -f "$BOOTSTRAP_DIR/VERSION" ]; then
|
||||
current_ver=$(cat "$BOOTSTRAP_DIR/VERSION" | tr -d '[:space:]')
|
||||
fi
|
||||
if version_lt "$compat_ver" "$current_ver"; then
|
||||
log_warn "Plugin '$plugin_name' is only tested up to bootstrap version $compat_ver (current: $current_ver). It may be incompatible."
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$is_ephemeral" = "true" ]; then
|
||||
log_info "Downloading and running plugin '$plugin_name' (ephemeral)..."
|
||||
local script_content
|
||||
|
||||
@@ -200,7 +200,6 @@ for script in "${SCRIPTS[@]}"; do
|
||||
# Handle non-installer commands
|
||||
case "$script" in
|
||||
plugin)
|
||||
shift # consume 'plugin' arg
|
||||
handle_plugin "$@"
|
||||
# Once handle_plugin completes, we should exit so it doesn't process more SCRIPTS
|
||||
exit $?
|
||||
|
||||
Reference in New Issue
Block a user