1 |
efrain |
1 |
#!/usr/bin/env bash
|
|
|
2 |
|
|
|
3 |
SCRIPTPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
4 |
cd "$SCRIPTPATH"
|
|
|
5 |
|
|
|
6 |
# Install codemirror, rollup, and any codemirror plugins we want to use.
|
|
|
7 |
# Note: We don't want to put these into the packages.json because we want to fetch the latest version when we run.
|
|
|
8 |
echo "Installing codemirror and rollup"
|
|
|
9 |
npm install --no-save \
|
|
|
10 |
codemirror \
|
|
|
11 |
@codemirror/lang-javascript \
|
|
|
12 |
@codemirror/lang-html \
|
|
|
13 |
@codemirror/lang-xml \
|
|
|
14 |
rollup \
|
|
|
15 |
@rollup/plugin-node-resolve
|
|
|
16 |
|
|
|
17 |
# Create the rollup.
|
|
|
18 |
npx rollup \
|
|
|
19 |
./codemirror.mjs \
|
|
|
20 |
-f esm \
|
|
|
21 |
-o ../amd/src/codemirror-lazy.js \
|
|
|
22 |
-p @rollup/plugin-node-resolve
|
|
|
23 |
|
|
|
24 |
# Next install js-beautify
|
|
|
25 |
echo "Installing js-beautify"
|
|
|
26 |
API_URL='https://api.github.com/repos/beautifier/js-beautify/releases/latest'
|
|
|
27 |
|
|
|
28 |
# Get the .zip download URL
|
|
|
29 |
ZIP_URL=$(curl -s $API_URL | jq -r ".zipball_url")
|
|
|
30 |
# Download the latest release
|
|
|
31 |
curl -L -o latest_release.zip $ZIP_URL
|
|
|
32 |
# Create a temporary directory
|
|
|
33 |
TEMP_DIR=$(mktemp -d)
|
|
|
34 |
|
|
|
35 |
# Extract the .zip file to the temporary directory.
|
|
|
36 |
unzip -q latest_release.zip -d $TEMP_DIR
|
|
|
37 |
|
|
|
38 |
# Find the subdirectory that starts with "beautify"
|
|
|
39 |
SUB_DIR=$(find $TEMP_DIR -type d -name "beautifier*beautify*" | head -n 1)
|
|
|
40 |
|
|
|
41 |
# Copy the js-beautify files to the correct location.
|
|
|
42 |
cp -v $SUB_DIR/js/lib/beautify*.js ../amd/src/beautify
|
|
|
43 |
|
|
|
44 |
# Copy the License file to the correct location.
|
|
|
45 |
cp -v $SUB_DIR/LICENSE ../amd/src/beautify/LICENSE
|
|
|
46 |
|
|
|
47 |
# Remove the temporary directory, node_modules directory and the js-beautify zip.
|
|
|
48 |
rm -rf $TEMP_DIR
|
|
|
49 |
|
|
|
50 |
echo 'Code mirror version: ' $(npm --json ls codemirror | jq -r '.dependencies.codemirror.version')
|
|
|
51 |
echo 'Beautify version:' $(curl -s $API_URL | jq -r '.tag_name')
|
|
|
52 |
|
|
|
53 |
rm -rf node_modules
|
|
|
54 |
rm latest_release.zip
|