Skip to content

Instantly share code, notes, and snippets.

@akunzai
Created September 2, 2022 02:34
Show Gist options
  • Save akunzai/621cc3baa60e2ad64e7074f87d4963d6 to your computer and use it in GitHub Desktop.
Save akunzai/621cc3baa60e2ad64e7074f87d4963d6 to your computer and use it in GitHub Desktop.
Bundles up the latest from prototypejs and scriptaculous into a single file
#!/bin/sh
# Origin: https://github.com/inderpreet99/protoaculous-bundler
# Requirements: curl,unzip,perl,npx
PROTOTYPE_VER="1.7.3.0"
SCRIPTACULOUS_VER="1.9.0"
[ -f "prototype.$PROTOTYPE_VER.js" ] || curl -so prototype.$PROTOTYPE_VER.js https://ajax.googleapis.com/ajax/libs/prototype/$PROTOTYPE_VER/prototype.js
[ -f "scriptaculous-js-$SCRIPTACULOUS_VER.zip" ] || curl -sO http://script.aculo.us/dist/scriptaculous-js-$SCRIPTACULOUS_VER.zip
unzip -q -o scriptaculous-js-$SCRIPTACULOUS_VER.zip
# Replace scriptaculous's functions to selectively load dependent scripts ...
perl -i.bak -pe 'BEGIN{undef $/;} s/require:.*REQUIRED_PROTOTYPE:/REQUIRED_PROTOTYPE:/gsm' scriptaculous-js-$SCRIPTACULOUS_VER/src/scriptaculous.js
perl -i.bak2 -pe 'BEGIN{undef $/;} s/\n var js = .* }\);//gsm' scriptaculous-js-$SCRIPTACULOUS_VER/src/scriptaculous.js
echo "Generate protoaculous.$SCRIPTACULOUS_VER-$PROTOTYPE_VER.js ..."
cat prototype.$PROTOTYPE_VER.js scriptaculous-js-$SCRIPTACULOUS_VER/src/scriptaculous.js scriptaculous-js-$SCRIPTACULOUS_VER/src/builder.js scriptaculous-js-$SCRIPTACULOUS_VER/src/effects.js scriptaculous-js-$SCRIPTACULOUS_VER/src/dragdrop.js scriptaculous-js-$SCRIPTACULOUS_VER/src/controls.js scriptaculous-js-$SCRIPTACULOUS_VER/src/slider.js scriptaculous-js-$SCRIPTACULOUS_VER/src/sound.js > protoaculous.$SCRIPTACULOUS_VER-$PROTOTYPE_VER.js
echo "Generate protoaculous.$SCRIPTACULOUS_VER-$PROTOTYPE_VER.min.js ..."
npx google-closure-compiler --strict_mode_input=false --js=protoaculous.$SCRIPTACULOUS_VER-$PROTOTYPE_VER.js --js_output_file=protoaculous.$SCRIPTACULOUS_VER-$PROTOTYPE_VER.min.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment