Skip to content

Commit d41716d

Browse files
chore: shim package bin
1 parent eb0443c commit d41716d

3 files changed

Lines changed: 38 additions & 13 deletions

File tree

.github/workflows/release.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
run: bun install && bun run build:client
2323

2424
- name: Upload client dist
25-
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
25+
uses: actions/upload-artifact@v6
2626
with:
2727
name: client-dist
2828
path: client/dist/
@@ -35,7 +35,7 @@ jobs:
3535
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
3636

3737
- name: Download client dist
38-
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
38+
uses: actions/download-artifact@v8
3939
with:
4040
name: client-dist
4141
path: client/dist/
@@ -49,7 +49,7 @@ jobs:
4949
run: cargo build --release --bin server --target x86_64-unknown-linux-gnu
5050

5151
- name: Upload artifact
52-
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
52+
uses: actions/upload-artifact@v6
5353
with:
5454
name: bin-linux
5555
path: target/x86_64-unknown-linux-gnu/release/server
@@ -62,7 +62,7 @@ jobs:
6262
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
6363

6464
- name: Download client dist
65-
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
65+
uses: actions/download-artifact@v8
6666
with:
6767
name: client-dist
6868
path: client/dist/
@@ -79,7 +79,7 @@ jobs:
7979
run: cargo build --release --bin server --target x86_64-apple-darwin
8080

8181
- name: Upload artifacts
82-
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
82+
uses: actions/upload-artifact@v6
8383
with:
8484
name: bin-mac
8585
path: |
@@ -94,13 +94,13 @@ jobs:
9494
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
9595

9696
- name: Download Linux binary
97-
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
97+
uses: actions/download-artifact@v8
9898
with:
9999
name: bin-linux
100100
path: bin-linux/
101101

102102
- name: Download Mac binaries
103-
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
103+
uses: actions/download-artifact@v8
104104
with:
105105
name: bin-mac
106106
path: bin-mac/

bin/freecodecamp-server

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env node
2+
'use strict';
3+
4+
const { execFileSync } = require('child_process');
5+
const { join, existsSync } = require('path');
6+
7+
const PLATFORM_MAP = {
8+
'linux-x64': 'x86_64-unknown-linux-gnu',
9+
'darwin-x64': 'x86_64-apple-darwin',
10+
'darwin-arm64': 'aarch64-apple-darwin',
11+
};
12+
13+
const key = `${process.platform}-${process.arch}`;
14+
const target = PLATFORM_MAP[key];
15+
16+
if (!target) {
17+
console.error(`freecodecamp-os: no pre-built binary for ${key}`);
18+
process.exit(1);
19+
}
20+
21+
const bin = join(__dirname, `freecodecamp-server-${target}`);
22+
23+
if (!existsSync(bin)) {
24+
console.error(`freecodecamp-os: binary not found at ${bin} — try reinstalling`);
25+
process.exit(1);
26+
}
27+
28+
execFileSync(bin, process.argv.slice(2), { stdio: 'inherit' });

scripts/postinstall.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,14 @@ if (!target) {
2626
}
2727

2828
const binDir = join(__dirname, '..', 'bin');
29-
const binPath = join(binDir, 'freecodecamp-server');
29+
const binPath = join(binDir, `freecodecamp-server-${target}`);
3030
const url = `https://github.com/freeCodeCamp/freeCodeCampOS/releases/download/v${version}/freecodecamp-server-${target}`;
3131

3232
mkdirSync(binDir, { recursive: true });
3333

34-
// Binary was bundled with the published package — copy the platform binary into place
35-
const bundledBin = join(binDir, `freecodecamp-server-${target}`);
36-
if (existsSync(bundledBin)) {
37-
require('fs').copyFileSync(bundledBin, binPath);
34+
// Binary was bundled with the published package — nothing to do, shim handles selection
35+
if (existsSync(binPath)) {
3836
chmodSync(binPath, 0o755);
39-
console.log('freecodecamp-os: installed bundled binary for', target);
4037
process.exit(0);
4138
}
4239

0 commit comments

Comments
 (0)