-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate
executable file
·63 lines (48 loc) · 1.75 KB
/
generate
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#! /usr/bin/env bash
old_version=$(jq -r '.version' package.json)
# If a version is passed in, use that.
if [ -z "$1" ]; then
version=$(date +%Y.%-m.%-d)
else
version="$1"
fi
# Get the power and minlucks from the Minlucks spreadsheet.
curl -s 'https://docs.google.com/spreadsheets/d/13hKjNDFTFR3rTkmQzyi3d4ZDOlQJUvTfWPDQemmFW_Y/gviz/tq?tqx=out:csv&gid=0' > effs.csv
# Convert the csv to json and replace the escaped quotes.
jq -cR 'split("\",\"")' effs.csv > effs2.csv
sed -i '' 's/\\"//g' effs2.csv
jq -csf csv2json.jq effs2.csv | jq > effs.json
# # Reformat the json to be an array of objects in the format {"<mouse>": {"power": <power>, "minlucks": [<minlucks>]}}
jq -s '.[0][] | {(.Mouse):{ power: .Power, effs: [.Arcane, .Draconic, .Forgotten, .Hydro, .Parental, .Physical, .Shadow, .Tactical, .Law, .Rift]}}' effs.json > effs2.json
jq -s 'add' effs2.json > effs.json
# # Create the minlucks.js file.
minlucks=$(cat effs.json)
echo "// ==UserScript==
// @name MouseHunt Minlucks
// @description Minlucks and power for MouseHunt, from Google Sheets, to power the multiple mini-CRE scripts.
// @version $version
// @license MIT
// @author brap
// @namespace bradp
// @match https://www.mousehuntgame.com/*
// @icon https://i.mouse.rip/cheese.png
// @run-at document-end
// @grant none
// ==/UserScript==
window.minlucks = $minlucks;" > minlucks.js
# Clean up.
rm effs2.csv
rm effs.csv
rm effs.json
rm effs2.json
# Update the README.
sed -i '' "s/$old_version/$version/g" README.md
# Commit and tag.
git add README.md
git add minlucks.js
git commit -m "Update minlucks.js to $version"
git tag -a "$version" -m "Update minlucks.js to $version" -f
git push origin main
git push origin "$version" -f
npm version "$version"
npm publish