Skip to content

Commit

Permalink
feat(astexplorer): insert commit hash into footer
Browse files Browse the repository at this point in the history
  • Loading branch information
JamieMason committed May 10, 2020
1 parent e94cac8 commit 1f41789
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pull-upstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ jobs:
- uses: actions/checkout@v2
- name: Clone Upstream
run: |
yarn pull-upstream
yarn build-upstream
latest_commit=${{needs.get-latest-commit.outputs.latest_commit}}
echo $latest_commit > upstream-latest.txt
yarn pull-upstream $latest_commit
yarn build-upstream
- name: Create Pull Request
id: create-pr
uses: peter-evans/create-pull-request@v2
Expand Down
2 changes: 1 addition & 1 deletion scripts/build-upstream.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ yarn install
rm -rf "$UPSTREAM/out"
mkdir -p "$UPSTREAM/out"
NODE_ENV=${NODE_ENV:-production}
yarn exec webpack --mode=$NODE_ENV
node_modules/.bin/webpack --mode=$NODE_ENV
36 changes: 22 additions & 14 deletions scripts/pull-upstream.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
#!/usr/bin/env bash

REPO="$PWD"
rm -rf "$REPO/astexplorer"
git clone https://github.com/fkling/astexplorer.git
rm -rf "$REPO/vendor"
mkdir -p "$REPO/vendor/astexplorer"
mv "$REPO/astexplorer/website" "$REPO/vendor/astexplorer"
rm -rf "$REPO/astexplorer"
rm -rf "./astexplorer"
git clone "https://github.com/fkling/astexplorer.git"
rm -rf "./vendor"
mkdir -p "./vendor/astexplorer"
mv "./astexplorer/website" "./vendor/astexplorer"
rm -rf "./astexplorer"

# apply patches
ENTRY_FILE="$REPO/vendor/astexplorer/website/src/app.js"
DISABLE_DRAG_AND_DROP="$REPO/scripts/transforms/disable-drag-and-drop.js"
DISABLE_EXIT_DIALOG="$REPO/scripts/transforms/disable-exit-dialog.js"
INSERT_MIDDLEWARE="$REPO/scripts/transforms/insert-middleware.js"
HTML_FILE="./vendor/astexplorer/website/index.ejs"
ENTRY_FILE="./vendor/astexplorer/website/src/app.js"
DISABLE_DRAG_AND_DROP="./scripts/transforms/disable-drag-and-drop.js"
DISABLE_EXIT_DIALOG="./scripts/transforms/disable-exit-dialog.js"
INSERT_MIDDLEWARE="./scripts/transforms/insert-middleware.js"

yarn install
yarn exec jscodeshift --parser flow --extensions js -t "$DISABLE_DRAG_AND_DROP" "$ENTRY_FILE"
yarn exec jscodeshift --parser flow --extensions js -t "$DISABLE_EXIT_DIALOG" "$ENTRY_FILE"
yarn exec jscodeshift --parser flow --extensions js -t "$INSERT_MIDDLEWARE" "$ENTRY_FILE"
node_modules/.bin/jscodeshift --parser flow --extensions js --transform "$DISABLE_DRAG_AND_DROP" "$ENTRY_FILE"
node_modules/.bin/jscodeshift --parser flow --extensions js --transform "$DISABLE_EXIT_DIALOG" "$ENTRY_FILE"
node_modules/.bin/jscodeshift --parser flow --extensions js --transform "$INSERT_MIDDLEWARE" "$ENTRY_FILE"

# insert commit hash
LATEST_COMMIT="$1"
SHORT_HASH=$(echo $LATEST_COMMIT | cut -c1-7)
BUILD_NOTICE="Build: <a href=\"https:\/\/github.com\/fkling\/astexplorer\/commits\/$SHORT_HASH\">$SHORT_HASH<\/a>"

sed -i '' -e "s/@@COMMIT@@/$BUILD_NOTICE/g" $HTML_FILE

0 comments on commit 1f41789

Please sign in to comment.