Skip to content

Commit

Permalink
feat: update eye and support its new semantic versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
jeswr committed Jan 8, 2023
1 parent 7e1728a commit 0375315
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 18 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@
},
"config": {
"eye": {
"name": "v23.107.1359",
"sha": "a9ac74edbd1f86a1cb20338712a8afbb97d53153"
"name": "v2.0.1",
"url": "https://api.github.com/repos/eyereasoner/eye/releases/88218657"
}
},
"dependencies": {
Expand Down
6 changes: 4 additions & 2 deletions scripts/fetch-eye.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import { fetch } from 'cross-fetch';
import * as fs from 'fs';
import path from 'path';

const EYE_COMMIT = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json')).toString()).config.eye.sha;
const EYE_URL = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json')).toString()).config.eye.url;

(async () => {
const res = (await fetch(`https://raw.githubusercontent.com/eyereasoner/eye/${EYE_COMMIT}/eye.pl`));
const releaseInfo = (await (await fetch(EYE_URL)).json());
const res = (await fetch(`https://raw.githubusercontent.com/eyereasoner/eye/${releaseInfo.tag_name}/eye.pl`));

if (res.status === 200) {
fs.writeFileSync(path.join(__dirname, '..', 'eye', 'eye.pl'), await res.text());
} else {
Expand Down
21 changes: 10 additions & 11 deletions scripts/update-eye.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
before=$(git diff HEAD~1 | grep "\- \"name\"")
after=$(git diff HEAD~1 | grep "\+ \"name\"")
before=$(git show HEAD~1:./package.json | jq .config.eye.name)
current=$(cat ./package.json | jq .config.eye.name)

# Use change in eye version to determine whether
# this needs to be a major, minor or patch update
if [ ${before:17:2} != ${after:17:2} ]; then
version="breaking"
elif [ ${before:20:4} != ${after:20:4} ]; then
readarray -d . -t before <<<"${before:2:-1}"
readarray -d . -t after <<<"${current:2:-1}"

if [ ${before[0]} != ${after[0]} ]; then
version="BREAKING CHANGE"
elif [ ${before[1]} != ${after[1]} ]; then
version="feat"
elif [ ${before:25:4} != ${after:25:4} ]; then
elif [ ${before[2]} != ${after[2]} ]; then
version="fix"
fi

version="feat"

git config --global user.name 'Jesse Wright'
git config --global user.email '63333554+jeswr@users.noreply.github.com'
git commit -am "$version: update eye"
git commit -am "$version: update to eye ${current:1:-1}"
git push
6 changes: 3 additions & 3 deletions scripts/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import * as fs from 'fs';
import path from 'path';

(async () => {
const res = (await fetch('https://api.github.com/repos/eyereasoner/eye/tags'));
const res = (await fetch('https://api.github.com/repos/eyereasoner/eye/releases/latest'));
if (res.status === 200) {
const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json')).toString());
const [tag] = await res.json();
pkg.config.eye = { name: tag.name, sha: tag.commit.sha };
const tag = await res.json();
pkg.config.eye = { name: tag.name, url: tag.url };
fs.writeFileSync(
path.join(__dirname, '..', 'package.json'),
`${JSON.stringify(pkg, null, 2)}\n`,
Expand Down

0 comments on commit 0375315

Please sign in to comment.