Skip to content

Commit 3105ec7

Browse files
committed
Bump version to 0.1.2 and add npm package support
1 parent faf58c1 commit 3105ec7

5 files changed

Lines changed: 69 additions & 13 deletions

File tree

CHANGELOG.md

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

33
All notable changes to Term-Rex will be documented in this file.
44

5+
## [0.1.2] - 2025-05-11
6+
7+
### Added
8+
- Added npm package support for easier installation via npm
9+
- Updated installation scripts to match current version
10+
511
## [0.1.1] - 2025-05-11
612

713
### Changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.PHONY: build clean test release snapshot
22

3-
VERSION := 0.1.1
3+
VERSION := 0.1.2
44
BUILD_DATE := $(shell date +%Y-%m-%d)
55
LDFLAGS := -ldflags "-X main.Version=$(VERSION) -X main.BuildDate=$(BUILD_DATE)"
66

install.js

Lines changed: 56 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@ const arch = os.arch();
1010
// Determine which binary to download
1111
let binaryName;
1212
if (platform === 'win32') {
13-
binaryName = arch === 'x64' ? 'term-rex-windows-amd64.exe' : 'term-rex-windows-arm64.exe';
13+
binaryName = arch === 'x64' ? 'term-rex_0.1.2_windows_amd64.zip' : null;
1414
} else if (platform === 'darwin') {
15-
binaryName = arch === 'x64' ? 'term-rex-macos-amd64' : 'term-rex-macos-arm64';
15+
binaryName = arch === 'x64' ? 'term-rex_0.1.2_darwin_amd64.tar.gz' : 'term-rex_0.1.2_darwin_arm64.tar.gz';
1616
} else if (platform === 'linux') {
17-
binaryName = arch === 'x64' ? 'term-rex-linux-amd64' : 'term-rex-linux-arm64';
17+
binaryName = arch === 'x64' ? 'term-rex_0.1.2_linux_amd64.tar.gz' : 'term-rex_0.1.2_linux_arm64.tar.gz';
1818
} else {
1919
console.error('Unsupported platform:', platform);
2020
process.exit(1);
2121
}
2222

2323
// Download URL (assuming binaries are uploaded to GitHub Releases)
24-
const downloadUrl = `https://github.com/jianongHe/Term-Rex/releases/download/v1.0.0/${binaryName}`;
24+
const downloadUrl = `https://github.com/jianongHe/Term-Rex/releases/download/v0.1.2/${binaryName}`;
2525

2626
// Local binary path
2727
const binPath = path.join(__dirname, 'bin');
@@ -34,20 +34,66 @@ if (!fs.existsSync(binPath)) {
3434

3535
// Download binary file
3636
console.log(`Downloading ${binaryName}...`);
37-
const file = fs.createWriteStream(binaryPath);
37+
38+
// Create a temporary directory for extraction
39+
const tempDir = path.join(os.tmpdir(), `term-rex-${Math.random().toString(36).substring(7)}`);
40+
fs.mkdirSync(tempDir, { recursive: true });
41+
42+
const tempFile = path.join(tempDir, binaryName);
43+
const file = fs.createWriteStream(tempFile);
44+
3845
https.get(downloadUrl, (response) => {
3946
response.pipe(file);
4047
file.on('finish', () => {
4148
file.close(() => {
4249
console.log('Download complete');
43-
// Set execute permissions
44-
if (platform !== 'win32') {
45-
fs.chmodSync(binaryPath, '755');
50+
51+
// Extract the archive
52+
console.log('Extracting...');
53+
if (binaryName.endsWith('.zip')) {
54+
// For Windows, we need to extract the zip file
55+
const extract = require('extract-zip');
56+
extract(tempFile, { dir: tempDir })
57+
.then(() => {
58+
// Find the executable in the extracted files
59+
const files = fs.readdirSync(tempDir);
60+
const exeFile = files.find(f => f.endsWith('.exe'));
61+
if (!exeFile) {
62+
throw new Error('Could not find executable in zip file');
63+
}
64+
65+
// Copy to bin directory
66+
fs.copyFileSync(path.join(tempDir, exeFile), binaryPath);
67+
console.log('Installation complete! You can now run the game using the term-rex command.');
68+
})
69+
.catch(err => {
70+
console.error('Extraction failed:', err.message);
71+
});
72+
} else {
73+
// For Unix systems, extract the tar.gz file
74+
const tar = require('tar');
75+
tar.extract({
76+
file: tempFile,
77+
cwd: tempDir
78+
}).then(() => {
79+
// Find the executable in the extracted files
80+
const files = fs.readdirSync(tempDir);
81+
const exeFile = files.find(f => f === 'term-rex');
82+
if (!exeFile) {
83+
throw new Error('Could not find executable in tar.gz file');
84+
}
85+
86+
// Copy to bin directory
87+
fs.copyFileSync(path.join(tempDir, exeFile), binaryPath);
88+
fs.chmodSync(binaryPath, '755');
89+
console.log('Installation complete! You can now run the game using the term-rex command.');
90+
}).catch(err => {
91+
console.error('Extraction failed:', err.message);
92+
});
4693
}
47-
console.log('Installation complete! You can now run the game using the term-rex command.');
4894
});
4995
});
5096
}).on('error', (err) => {
51-
fs.unlink(binaryPath);
97+
fs.unlink(tempFile, () => {});
5298
console.error('Download failed:', err.message);
5399
});

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212

1313
// Version information
1414
const (
15-
Version = "0.1.1"
15+
Version = "0.1.2"
1616
BuildDate = "2025-05-11"
1717
)
1818

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
{
22
"name": "term-rex",
3-
"version": "1.0.0",
3+
"version": "0.1.2",
44
"description": "Terminal-based dinosaur runner game",
55
"bin": {
66
"term-rex": "./bin/term-rex"
77
},
88
"scripts": {
99
"postinstall": "node install.js"
1010
},
11+
"dependencies": {
12+
"extract-zip": "^2.0.1",
13+
"tar": "^6.1.11"
14+
},
1115
"repository": {
1216
"type": "git",
1317
"url": "git+https://github.com/jianongHe/Term-Rex.git"

0 commit comments

Comments
 (0)