2022-01-19 15:56:33 +00:00
|
|
|
#!/bin/bash
|
2022-01-19 16:21:07 +00:00
|
|
|
# ================================================================
|
|
|
|
# apps.json used to contain the metadata for every app. Now the
|
|
|
|
# metadata is stored in each apps's directory - app/yourapp/metadata.js
|
|
|
|
#
|
|
|
|
# The app loader still wants all the data in one file, so normally
|
|
|
|
# with GitHub pages, Jekyll is automatically run and creates a working
|
|
|
|
# apps.json
|
|
|
|
#
|
|
|
|
# However if you're hosting locally, or not on GitHub pages then you
|
|
|
|
# will want to create apps.json yourself. You can do that by installing
|
|
|
|
# and running Jekyll, OR the easier option is just to run this script.
|
|
|
|
#
|
|
|
|
# If you do this, please do not attempt to commit your modified
|
|
|
|
# apps.json back into the main BangleApps repository!
|
2022-01-20 19:22:58 +00:00
|
|
|
#
|
|
|
|
# You can pass an optional filename to this script, and it will write
|
|
|
|
# to that instead, apps.local.json is used when opening the loader on localhost
|
|
|
|
outfile="${1:-apps.json}"
|
2022-01-19 15:56:33 +00:00
|
|
|
|
|
|
|
cd `dirname $0`/..
|
2022-01-20 19:22:58 +00:00
|
|
|
echo "[" > "$outfile"
|
|
|
|
first=1
|
2022-01-19 15:56:33 +00:00
|
|
|
for app in apps/*/; do
|
|
|
|
echo "Processing $app...";
|
2022-06-18 11:00:02 +00:00
|
|
|
if [[ "$app" =~ ^apps/_example.* ]] || [ ! -e "$app/"metadata.json ]; then
|
2022-01-19 15:56:33 +00:00
|
|
|
echo "Ignoring $app"
|
|
|
|
else
|
2022-01-20 19:22:58 +00:00
|
|
|
if [ $first -eq 1 ]; then
|
|
|
|
first=0;
|
|
|
|
else
|
|
|
|
echo "," >> "$outfile"
|
|
|
|
fi;
|
|
|
|
cat ${app}metadata.json >> "$outfile"
|
2022-01-19 16:48:38 +00:00
|
|
|
# echo ",\"$app\"," >> apps.json # DEBUG ONLY
|
2022-01-19 15:56:33 +00:00
|
|
|
fi
|
|
|
|
done
|
2022-01-20 19:22:58 +00:00
|
|
|
echo "]" >> "$outfile"
|
2022-01-20 19:39:06 +00:00
|
|
|
|
2022-01-27 14:34:39 +00:00
|
|
|
if [ -z "$1" ]; then
|
2022-01-20 19:39:06 +00:00
|
|
|
# Running with no arguments: prevent accidental commit of modified apps.json.
|
|
|
|
# You can use `create_apps.json.sh apps.json` if you really want to both
|
|
|
|
# overwrite and still commit apps.json
|
|
|
|
git update-index --skip-worktree apps.json
|
|
|
|
echo "Told git to ignore modified apps.json."
|
|
|
|
# If you want to unignore it, use
|
|
|
|
# 'git update-index --no-skip-worktree apps.json'
|
2022-01-27 14:34:39 +00:00
|
|
|
fi
|