archematics/tools/makePlugin.bash

61 lines
1.8 KiB
Bash
Raw Normal View History

# Takes two parameters, the destination directory and what to include
# in the plugin:
# full - everything
# wrl - just the wrl viewer
modules="$2"
mkdir -p $1/deps/x_ite/assets/images
mkdir -p $1/deps/x_ite/assets/components
versionLine=$(grep version package.json5)
regex="'(.*)'"
if [[ $versionLine =~ $regex ]]
then
version="${BASH_REMATCH[1]}"
fi
# Mark full versions with an extra version number field:
if [ "$modules" = full ]
then
version="${version}.2"
fi
echo "Building plugin version $version"
VERSION="$version" WHAT="$modules" bash etc/manifest.bash > $1/manifest.json
WHAT="$modules" bash etc/options.bash > $1/options.html
cp etc/deps/x_ite/x_ite.css $1/deps/x_ite
cp etc/deps/x_ite/assets/images/logo.128.png $1/deps/x_ite/assets/images
cp etc/deps/x_ite/x_ite.mjs $1/deps/x_ite
cp etc/deps/x_ite/assets/components/* $1/deps/x_ite/assets/components
npx rollup public/js/giveAwrl.js --dir $1
cp public/js/options.js public/js/conway.js public/js/prism.js $1
cp public/js/adapptypes.js $1
cp node_modules/webextension-polyfill/dist/browser-polyfill.js $1
cp node_modules/@webcomponents/custom-elements/custom-elements.min.js $1
mkdir -p $1/assets
cp public/assets/arch*.png $1/assets
cp public/assets/vrmlExample.png $1/assets
if [ "$modules" = full ]
then
geoFiles=($(grep deps/GeoGebra $1/manifest.json))
for spec in "${geoFiles[@]}"
do
quotspec=${spec%,}
trimRspec="${quotspec%\"}"
trimspec="${trimRspec#\"}"
dest=${trimspec%/*}
mkdir -p $1/$dest
cp -r etc/$trimspec $1/$dest
done
cp public/js/deps/jsxgraph{.css,core.mjs} $1/deps
npx rollup public/js/adapptlet.js --file $1/adapptlet.js
npx rollup public/js/adapptext.js --file $1/adapptext.js
cp public/assets/joyceExample.png $1/assets
fi
# Wrap it all up
cd $1
zip -r ../$1 *