Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
benjammin4dayz committed Feb 5, 2024
0 parents commit 740cddd
Show file tree
Hide file tree
Showing 12 changed files with 3,194 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "eslint:recommended",
"env": {
"node": 20,
"es2024": true
},
"parserOptions": {
"sourceType": "module"
}
}
62 changes: 62 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Release

on:
workflow_dispatch:
push:
tags: ["*"]

env:
VANITY_NAME: aceo-rpc
WIN32_PATH_IN: ./bin/aceo-rpc.exe # aceo-rpc-win.exe
WIN32_PATH_OUT: ./bin/aceo-rpc-win.zip
LINUX_PATH_IN: ./bin/aceo-rpc-linux
LINUX_PATH_OUT: ./bin/aceo-rpc-linux.tar.gz
win32_hash: ""
linux_hash: ""

jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: lts/iron

- name: Install dependencies
run: npm ci

- name: Generate binaries
env:
CLIENT_ID: ${{ secrets.CLIENT_ID }}
run: npm run build

- name: Create Windows artifact
run: |
win32_hash=$(sha256sum ${{ env.WIN32_PATH_IN }} | cut -d ' ' -f 1)
cp ./bin/bundle.js ./bin/${{ env.VANITY_NAME }}.js
zip -j ${{ env.WIN32_PATH_OUT }} ${{ env.WIN32_PATH_IN}} ./bin/${{ env.VANITY_NAME }}.js
echo "win32_hash=$win32_hash" >> $GITHUB_ENV
echo "SHA256 Checksum: $win32_hash"
# - name: Create Linux artifact
# run: |
# chmod +x ./bin/aceo-rpc-linux
# linux_hash=$(sha256sum ./bin/aceo-rpc-linux | cut -d ' ' -f 1)
# tar -czf ./bin/aceo-rpc-linux.tar.gz ./bin/aceo-rpc-linux ./bin/bundle.js
# echo "linux_hash=$linux_hash" >> $GITHUB_ENV
# echo "SHA256 Checksum: $linux_hash"

- name: Create release
uses: ncipollo/release-action@v1
with:
artifacts: "./bin/*.zip,./bin/*.tar.gz"
body: |
## SHA256
${{ env.VANITY_NAME }}.exe: ${{ env.win32_hash }}
# ${{ env.VANITY_NAME }}: ${{ env.linux_hash }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.env
bin/**
node_modules/**
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Airport CEO Rich Presence

Effortlessly share airport statistics with your friends on Discord!

<img alt="Preview" src="./preview.png">

## How-to:

1. Download the [latest release](https://github.com/benjammin4dayz/aceo-discord-rpc/releases/latest)
2. Start the executable
3. Start Airport CEO

## How does it work?

This program listens for the game to start before it reads data from your save file and broadcasts the presence to Discord. It updates periodically as you play by reading the latest saved game. After the game shuts down, it will clear your Discord presence and standby for the game to start once again until you close this program.
46 changes: 46 additions & 0 deletions make.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import esbuild from "esbuild";
import dotenv from "dotenv";
import pkg from "@yao-pkg/pkg";

dotenv.config();

esbuild
.build({
entryPoints: ["src/index.js"],
bundle: true,
platform: "node",
target: "node20",
outfile: "bin/bundle.js",
minify: true,
sourcemap: false,
define: getGlobalVars(),
})
.then(() => {
if (process.argv[2] === "--nopkg") return;
pkg.exec([
"bin/bundle.js",
"--targets",
getBuildTargets(process),
"--output",
"bin/aceo-rpc",
// "--no-warnings",
]);
});

function getGlobalVars() {
const clientId = process.env["CLIENT_ID"];
if (!clientId) throw new Error("Missing CLIENT_ID environment variable.");
console.log("CLIENT_ID:", "*".repeat(clientId?.length - 1)); // hunter2

return {
__ESBUILD_GLOBAL_PROD_CLIENT_ID: `"${clientId}"`,
};
}
function getBuildTargets({ argv }) {
const [tgt, args] = [[], argv.slice(2) || []];
const has = (flags) => flags.some((flag) => args.includes(flag));
has(["-w", "--win", "--windows"]) && tgt.push("latest-win-x64");
has(["-l", "--lin", "--linux"]) && tgt.push("latest-linux-x64");
!tgt.length && tgt.push("latest-win-x64");
return tgt.join(",");
}
Loading

0 comments on commit 740cddd

Please sign in to comment.