Skip to content

Commit 4a145a9

Browse files
committed
Convert AutoCR to CLI
1 parent e52ae02 commit 4a145a9

File tree

8 files changed

+718
-230
lines changed

8 files changed

+718
-230
lines changed

.github/workflows/release.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*"
7+
8+
jobs:
9+
npm:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
id-token: write
14+
steps:
15+
- uses: actions/checkout@v5
16+
- uses: actions/setup-node@v5
17+
with:
18+
node-version: "24"
19+
- uses: JS-DevTools/npm-publish@v4
20+
with:
21+
access: "public"
22+
provenance: true
23+
24+
github:
25+
runs-on: ubuntu-latest
26+
permissions:
27+
contents: read
28+
id-token: write
29+
packages: write
30+
steps:
31+
- uses: actions/checkout@v5
32+
- uses: actions/setup-node@v5
33+
with:
34+
node-version: "24"
35+
- uses: JS-DevTools/npm-publish@v4
36+
with:
37+
token: ${{ secrets.GITHUB_TOKEN }}
38+
registry: "https://npm.pkg.github.com"
39+
access: "public"
40+
provenance: true

.github/workflows/test.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
6+
jobs:
7+
npm:
8+
runs-on: ubuntu-latest
9+
permissions:
10+
contents: read
11+
id-token: write
12+
steps:
13+
- uses: actions/checkout@v5
14+
- uses: actions/setup-node@v5
15+
with:
16+
node-version: "24"
17+
- uses: JS-DevTools/npm-publish@v4
18+
with:
19+
token: ${{ secrets.NPM_TOKEN }}
20+
access: "public"
21+
provenance: true
22+
dry-run: true
23+
24+
github:
25+
runs-on: ubuntu-latest
26+
permissions:
27+
contents: read
28+
id-token: write
29+
packages: write
30+
steps:
31+
- uses: actions/checkout@v5
32+
- uses: actions/setup-node@v5
33+
with:
34+
node-version: "24"
35+
- uses: JS-DevTools/npm-publish@v4
36+
with:
37+
token: ${{ secrets.GITHUB_TOKEN }}
38+
registry: "https://npm.pkg.github.com"
39+
access: "public"
40+
provenance: true
41+
dry-run: true

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
Heavily taken from [AutoCR](https://github.com/authorblues/retroachievements/tree/main/AutoCR) in an attempt to use the same logic as in a command line interface to automate checking achievement logic in pipelines
44

5+
Available on [NPM](https://www.npmjs.com/package/@joshraphael/autocr-cli) and [Github Packages](https://github.com/joshraphael/autocr-cli/pkgs/npm/autocr-cli)
6+
57
## Usage
68

79
```sh

achievements.js

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
const { MemSize, Logic, FormatTypeMap, FormatType } = require("./logic");
2+
13
class MemRegion
24
{
35
start;
@@ -1092,8 +1094,8 @@ function testCodeNotes()
10921094
let cn = new CodeNote(0x0, note);
10931095
let res = cn.size == size && cn.type == type ? "PASS" : "FAIL";
10941096

1095-
console.log(note, '-->', size, type);
1096-
console.log(res, cn);
1097+
// console.log(note, '-->', size, type);
1098+
// console.log(res, cn);
10971099

10981100
count += 1;
10991101
if (!(cn.size == size && cn.type == type)) fails += 1;
@@ -1200,7 +1202,7 @@ function testCodeNotes()
12001202
_testNote("lower 4-byte value", 1, MemSize.BYTE);
12011203
_testNote("lower (4-byte) value", 4, MemSize.DWORD);
12021204

1203-
console.log(fails + "/" + count + " failed")
1205+
// console.log(fails + "/" + count + " failed")
12041206
}
12051207

12061208
class LookupRange
@@ -1315,11 +1317,20 @@ class RichPresence
13151317
}
13161318

13171319
// process all lookups in each display
1318-
for (let d of richp.display)
1319-
d.lookups = [...d.string.matchAll(/@([ _a-z][ _a-z0-9]*)\((.+?)\)/gi).map((x) => ({
1320-
name: x[1],
1321-
calc: Logic.fromString(x[2], true),
1322-
}))];
1320+
for (let d of richp.display) {
1321+
let parts = d.string.matchAll(/@([ _a-z][ _a-z0-9]*)\((.+?)\)/gi)
1322+
1323+
var lookups = []
1324+
for (const x of parts) {
1325+
lookups.push({
1326+
name: x[1],
1327+
calc: Logic.fromString(x[2], true),
1328+
})
1329+
}
1330+
d.lookups = lookups
1331+
}
13231332
return richp;
13241333
}
1325-
}
1334+
}
1335+
1336+
module.exports = { AchievementSet, CodeNote, RichPresence, Leaderboard, AssetState, CodeNoteSet };

0 commit comments

Comments
 (0)