Skip to content

Commit

Permalink
Merge pull request #71 from StampyAI/issue-68-jrhender-add-diff-script
Browse files Browse the repository at this point in the history
Add Diff Script
  • Loading branch information
LeMurphant authored Nov 12, 2024
2 parents a38d4c0 + 8e261a8 commit d5f618b
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,15 @@ These are totally optional. If not provided, any logging to Discord will be skip
# Running

`node bin/importContent.js`

# Dev Testing Scripts

For the below, a useful google doc for testing is the
[Example with all the formatting](https://docs.google.com/document/d/10g6U9SL0CBy__wCBTib7_WhB3S3aaFt7Fx1vVgCzg2I/edit?tab=t.0).
It has document id `10g6U9SL0CBy__wCBTib7_WhB3S3aaFt7Fx1vVgCzg2I`.

## Fetch and Parse a Single Document
The `devtool.js` script can be run using node.js to either fetch the JSON or the parsed markdown for a google doc. See the script for parameter details.

## Git diff changes
The `dev-output-diff.sh` bash script can be run to do a git diff of document to visualize how changes in a feature branch will affect the parsed markdown.
29 changes: 29 additions & 0 deletions dev-output-diff.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

# 1. Take the feature branch as the first param
feature_branch=$1

# 2. Take the google doc id as the second param
google_doc_id=$2

# 3. Check out the main git branch
git checkout main

# 4. Run the node devtool.js command and store the result
main_output=$(node devtools.js md $google_doc_id)
main_output_file=$(mktemp)
echo "$main_output" > "$main_output_file"

# 5. Check out the feature branch
git checkout $feature_branch

# 6. Run the same node command
branch_output=$(node devtools.js md $google_doc_id)
branch_output_file=$(mktemp)
echo "$branch_output" > "$branch_output_file"

# 7. Output a git diff of the two command runs
git diff "$main_output_file" "$branch_output_file"

# 8. Clean up temporary files
rm "$main_output_file" "$branch_output_file"

0 comments on commit d5f618b

Please sign in to comment.