@caleb-collar/steamcmd 1.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +141 -0
- package/LICENSE +21 -0
- package/README.md +385 -0
- package/bin/steamcmd +35 -0
- package/package.json +71 -0
- package/src/download.js +220 -0
- package/src/env.js +66 -0
- package/src/install.js +356 -0
- package/src/steamcmd.js +404 -0
- package/src/steamcmd.mjs +28 -0
- package/types/steamcmd.d.ts +466 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **ESM module support**: Package now supports both CommonJS (`require`) and ES Modules (`import`)
|
|
13
|
+
- **`getInstalledApps()`**: List all installed Steam applications in a directory
|
|
14
|
+
- **`update()`**: Update an existing Steam application installation
|
|
15
|
+
- **`validate()`**: Validate an installed Steam application
|
|
16
|
+
- **`getInstalledVersion()`**: Get the installed version (build ID) of a Steam application
|
|
17
|
+
- **`createProgressEmitter()`**: Create an EventEmitter for real-time progress tracking
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
|
|
21
|
+
- **package.json**: Added `exports` field for dual CJS/ESM support
|
|
22
|
+
- **package.json**: Added `module` field pointing to ESM entry point
|
|
23
|
+
|
|
24
|
+
## [1.0.0-alpha.1] - 2026-01-31
|
|
25
|
+
|
|
26
|
+
### Added
|
|
27
|
+
|
|
28
|
+
- **Promise/async-await support**: All API functions now return Promises when no callback is provided
|
|
29
|
+
- **Progress tracking**: New `onProgress` callback for tracking download and installation progress
|
|
30
|
+
- **Output streaming**: New `onOutput` callback for real-time SteamCMD output
|
|
31
|
+
- **Utility functions**: `isInstalled()`, `ensureInstalled()`, and `getInfo()`
|
|
32
|
+
- **Custom error classes**: `SteamCmdError`, `DownloadError`, and `InstallError` with error codes
|
|
33
|
+
- **Input validation**: Comprehensive validation for all options with descriptive error messages
|
|
34
|
+
- **TypeScript definitions**: Full type definitions in `types/steamcmd.d.ts`
|
|
35
|
+
- **Test suite**: Comprehensive unit and integration tests with >80% coverage
|
|
36
|
+
- **CI/CD pipeline**: GitHub Actions for testing on Node 18/20/22 across Linux, Windows, and macOS
|
|
37
|
+
- **Automated publishing**: GitHub workflow for npm publishing on release
|
|
38
|
+
- **Dependabot**: Automated dependency updates
|
|
39
|
+
|
|
40
|
+
### Changed
|
|
41
|
+
|
|
42
|
+
- **BREAKING**: Minimum Node.js version is now 18 (previously no requirement)
|
|
43
|
+
- **BREAKING**: Download URLs now use HTTPS instead of HTTP
|
|
44
|
+
- **Dependencies**: Replaced `tarball-extract` with `tar` (actively maintained)
|
|
45
|
+
- **Dependencies**: Replaced `path-extra` with `env-paths` (modern alternative)
|
|
46
|
+
- **Dependencies**: Updated `commander` from v2 to v12 (CLI improvements)
|
|
47
|
+
- **Dependencies**: Updated `unzipper` to latest version
|
|
48
|
+
- **Dependencies**: Updated `standard` to v17 (dev dependency)
|
|
49
|
+
- **Data directory**: Now uses `env-paths` conventions
|
|
50
|
+
- Linux: `~/.local/share/steamcmd` (was `~/.config/steamcmd`)
|
|
51
|
+
- macOS: `~/Library/Application Support/steamcmd` (unchanged)
|
|
52
|
+
- Windows: `%LOCALAPPDATA%\steamcmd` (unchanged)
|
|
53
|
+
|
|
54
|
+
### Fixed
|
|
55
|
+
|
|
56
|
+
- Security: Download URLs now use HTTPS instead of HTTP
|
|
57
|
+
- Error handling: All async operations now properly catch and report errors
|
|
58
|
+
- CLI: Updated to work with Commander v12 API
|
|
59
|
+
|
|
60
|
+
### Deprecated
|
|
61
|
+
|
|
62
|
+
- Callback-based API: Still supported but Promise API is recommended
|
|
63
|
+
|
|
64
|
+
## [0.3.1] - Previous Version
|
|
65
|
+
|
|
66
|
+
This was the last version before the modernization effort. See the git history for changes prior to this release.
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## Migration Guide: 0.x to 1.0
|
|
71
|
+
|
|
72
|
+
### Minimum Node.js Version
|
|
73
|
+
|
|
74
|
+
Update to Node.js 18 or higher:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
node --version # Must be >= 18.0.0
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Using Promises (Recommended)
|
|
81
|
+
|
|
82
|
+
Before (callbacks):
|
|
83
|
+
|
|
84
|
+
```javascript
|
|
85
|
+
steamcmd.install({ applicationId: 740 }, function (err) {
|
|
86
|
+
if (err) {
|
|
87
|
+
console.error(err);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
console.log("Done");
|
|
91
|
+
});
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
After (async/await):
|
|
95
|
+
|
|
96
|
+
```javascript
|
|
97
|
+
try {
|
|
98
|
+
await steamcmd.install({ applicationId: 740 });
|
|
99
|
+
console.log("Done");
|
|
100
|
+
} catch (err) {
|
|
101
|
+
console.error(err);
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Data Directory Change (Linux)
|
|
106
|
+
|
|
107
|
+
If you have an existing SteamCMD installation on Linux, it may be in the old location:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
# Old location
|
|
111
|
+
~/.config/steamcmd
|
|
112
|
+
|
|
113
|
+
# New location
|
|
114
|
+
~/.local/share/steamcmd
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
You can either:
|
|
118
|
+
|
|
119
|
+
1. Let the library download SteamCMD again to the new location
|
|
120
|
+
2. Move your existing installation: `mv ~/.config/steamcmd ~/.local/share/steamcmd`
|
|
121
|
+
|
|
122
|
+
### Error Handling
|
|
123
|
+
|
|
124
|
+
The library now throws typed errors:
|
|
125
|
+
|
|
126
|
+
```javascript
|
|
127
|
+
const { SteamCmdError, InstallError } = require("steamcmd");
|
|
128
|
+
|
|
129
|
+
try {
|
|
130
|
+
await steamcmd.install(options);
|
|
131
|
+
} catch (err) {
|
|
132
|
+
if (err instanceof InstallError) {
|
|
133
|
+
console.error(`Install failed with code: ${err.code}`);
|
|
134
|
+
console.error(`Exit code: ${err.exitCode}`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
[Unreleased]: https://github.com/dahlgren/node-steamcmd/compare/v1.0.0-alpha.1...HEAD
|
|
140
|
+
[1.0.0-alpha.1]: https://github.com/dahlgren/node-steamcmd/compare/v0.3.1...v1.0.0-alpha.1
|
|
141
|
+
[0.3.1]: https://github.com/dahlgren/node-steamcmd/releases/tag/v0.3.1
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2014-2026 Björn Dahlgren
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
# SteamCMD
|
|
2
|
+
|
|
3
|
+
[](https://github.com/dahlgren/node-steamcmd/actions/workflows/ci.yml)
|
|
4
|
+
[](https://www.npmjs.com/package/steamcmd)
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
|
|
7
|
+
A Node.js wrapper for Valve's [SteamCMD](https://developer.valvesoftware.com/wiki/SteamCMD) tool. Download, install, and manage Steam applications programmatically.
|
|
8
|
+
|
|
9
|
+
**Features:**
|
|
10
|
+
|
|
11
|
+
- Automatic SteamCMD download and installation
|
|
12
|
+
- Promise-based API with async/await support
|
|
13
|
+
- Progress tracking for downloads and installations
|
|
14
|
+
- TypeScript definitions included
|
|
15
|
+
- Cross-platform (Windows, Linux, macOS)
|
|
16
|
+
|
|
17
|
+
SteamCMD will be automatically downloaded to your platform-specific data folder:
|
|
18
|
+
|
|
19
|
+
- **Linux:** `~/.local/share/steamcmd`
|
|
20
|
+
- **macOS:** `~/Library/Application Support/steamcmd`
|
|
21
|
+
- **Windows:** `%LOCALAPPDATA%\steamcmd`
|
|
22
|
+
|
|
23
|
+
## Requirements
|
|
24
|
+
|
|
25
|
+
**Node.js 18 or higher** is required.
|
|
26
|
+
|
|
27
|
+
See [SteamCMD requirements](https://developer.valvesoftware.com/wiki/SteamCMD) for platform-specific dependencies.
|
|
28
|
+
|
|
29
|
+
For Ubuntu/Debian:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
sudo apt-get install lib32gcc-s1
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Installation
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npm install steamcmd
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Usage
|
|
42
|
+
|
|
43
|
+
### Module API (Recommended)
|
|
44
|
+
|
|
45
|
+
#### Basic Installation
|
|
46
|
+
|
|
47
|
+
```javascript
|
|
48
|
+
const steamcmd = require("steamcmd");
|
|
49
|
+
|
|
50
|
+
// Install a dedicated server (e.g., Counter-Strike 2)
|
|
51
|
+
await steamcmd.install({
|
|
52
|
+
applicationId: 730,
|
|
53
|
+
path: "./cs2-server",
|
|
54
|
+
});
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
#### With Authentication
|
|
58
|
+
|
|
59
|
+
```javascript
|
|
60
|
+
await steamcmd.install({
|
|
61
|
+
applicationId: 123456,
|
|
62
|
+
path: "./game-server",
|
|
63
|
+
username: "your-steam-username",
|
|
64
|
+
password: "your-steam-password",
|
|
65
|
+
steamGuardCode: "12345", // If Steam Guard is enabled
|
|
66
|
+
});
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
#### Workshop Items
|
|
70
|
+
|
|
71
|
+
```javascript
|
|
72
|
+
// Download a workshop item
|
|
73
|
+
await steamcmd.install({
|
|
74
|
+
applicationId: 107410, // Arma 3
|
|
75
|
+
workshopId: 450814997,
|
|
76
|
+
path: "./arma3",
|
|
77
|
+
});
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
#### Progress Tracking
|
|
81
|
+
|
|
82
|
+
```javascript
|
|
83
|
+
await steamcmd.install({
|
|
84
|
+
applicationId: 740,
|
|
85
|
+
path: "./csds",
|
|
86
|
+
onProgress: (progress) => {
|
|
87
|
+
console.log(`${progress.phase}: ${progress.percent}%`);
|
|
88
|
+
// Output: "downloading: 45%", "validating: 100%"
|
|
89
|
+
},
|
|
90
|
+
onOutput: (data, type) => {
|
|
91
|
+
// type is 'stdout' or 'stderr'
|
|
92
|
+
process.stdout.write(data);
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
#### Utility Functions
|
|
98
|
+
|
|
99
|
+
```javascript
|
|
100
|
+
const steamcmd = require("steamcmd");
|
|
101
|
+
|
|
102
|
+
// Check if SteamCMD is installed
|
|
103
|
+
const installed = await steamcmd.isInstalled();
|
|
104
|
+
console.log("SteamCMD installed:", installed);
|
|
105
|
+
|
|
106
|
+
// Get installation info
|
|
107
|
+
const info = steamcmd.getInfo();
|
|
108
|
+
console.log(info);
|
|
109
|
+
// {
|
|
110
|
+
// directory: '/home/user/.local/share/steamcmd',
|
|
111
|
+
// executable: '/home/user/.local/share/steamcmd/steamcmd.sh',
|
|
112
|
+
// platform: 'linux',
|
|
113
|
+
// isSupported: true
|
|
114
|
+
// }
|
|
115
|
+
|
|
116
|
+
// Manually ensure SteamCMD is installed
|
|
117
|
+
await steamcmd.ensureInstalled({
|
|
118
|
+
onProgress: (p) => console.log(`Download: ${p.percent}%`),
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
// List installed apps in a directory
|
|
122
|
+
const apps = await steamcmd.getInstalledApps({ path: "./server" });
|
|
123
|
+
console.log(apps);
|
|
124
|
+
// [{ appId: 740, name: 'CSGO Server', buildId: 12345, ... }]
|
|
125
|
+
|
|
126
|
+
// Get installed version of an app
|
|
127
|
+
const version = await steamcmd.getInstalledVersion({
|
|
128
|
+
applicationId: 740,
|
|
129
|
+
path: "./server",
|
|
130
|
+
});
|
|
131
|
+
console.log(version);
|
|
132
|
+
// { appId: 740, name: 'CSGO Server', buildId: 12345, lastUpdated: Date }
|
|
133
|
+
|
|
134
|
+
// Update an existing installation
|
|
135
|
+
await steamcmd.update({
|
|
136
|
+
applicationId: 740,
|
|
137
|
+
path: "./server",
|
|
138
|
+
onProgress: (p) => console.log(`Update: ${p.percent}%`),
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
// Validate an installation
|
|
142
|
+
await steamcmd.validate({
|
|
143
|
+
applicationId: 740,
|
|
144
|
+
path: "./server",
|
|
145
|
+
});
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
#### EventEmitter Progress
|
|
149
|
+
|
|
150
|
+
```javascript
|
|
151
|
+
const steamcmd = require("steamcmd");
|
|
152
|
+
|
|
153
|
+
// Create an event emitter for real-time progress
|
|
154
|
+
const emitter = steamcmd.createProgressEmitter("install", {
|
|
155
|
+
applicationId: 740,
|
|
156
|
+
path: "./server",
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
emitter.on("progress", (p) => {
|
|
160
|
+
console.log(`${p.phase}: ${p.percent}%`);
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
emitter.on("output", (data, type) => {
|
|
164
|
+
process.stdout.write(`[${type}] ${data}`);
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
emitter.on("error", (err) => {
|
|
168
|
+
console.error("Failed:", err.message);
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
emitter.on("complete", () => {
|
|
172
|
+
console.log("Done!");
|
|
173
|
+
});
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
#### Error Handling
|
|
177
|
+
|
|
178
|
+
```javascript
|
|
179
|
+
const { SteamCmdError, DownloadError, InstallError } = require("steamcmd");
|
|
180
|
+
|
|
181
|
+
try {
|
|
182
|
+
await steamcmd.install({
|
|
183
|
+
applicationId: 740,
|
|
184
|
+
path: "./server",
|
|
185
|
+
});
|
|
186
|
+
} catch (err) {
|
|
187
|
+
if (err instanceof SteamCmdError) {
|
|
188
|
+
console.error(`SteamCMD error: ${err.message} (code: ${err.code})`);
|
|
189
|
+
} else if (err instanceof InstallError) {
|
|
190
|
+
console.error(`Install failed: ${err.message}`);
|
|
191
|
+
console.error(`Exit code: ${err.exitCode}`);
|
|
192
|
+
} else {
|
|
193
|
+
throw err;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
#### Legacy Callback API
|
|
199
|
+
|
|
200
|
+
```javascript
|
|
201
|
+
// Callback-style is still supported for backward compatibility
|
|
202
|
+
steamcmd.install({ applicationId: 740, path: "./server" }, (err) => {
|
|
203
|
+
if (err) {
|
|
204
|
+
console.error("Installation failed:", err.message);
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
console.log("Installation complete!");
|
|
208
|
+
});
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### API Reference
|
|
212
|
+
|
|
213
|
+
#### `install(options, [callback])`
|
|
214
|
+
|
|
215
|
+
Install a Steam application or Workshop item.
|
|
216
|
+
|
|
217
|
+
| Option | Type | Description |
|
|
218
|
+
| ---------------- | ------------------ | ----------------------------------------------------- |
|
|
219
|
+
| `applicationId` | `number \| string` | Steam application ID to install |
|
|
220
|
+
| `workshopId` | `number \| string` | Workshop item ID (requires `applicationId`) |
|
|
221
|
+
| `path` | `string` | Installation directory |
|
|
222
|
+
| `username` | `string` | Steam username for authentication |
|
|
223
|
+
| `password` | `string` | Steam password for authentication |
|
|
224
|
+
| `steamGuardCode` | `string` | Steam Guard code for 2FA |
|
|
225
|
+
| `platform` | `string` | Target platform: `'windows'`, `'macos'`, or `'linux'` |
|
|
226
|
+
| `onProgress` | `function` | Progress callback: `(progress) => void` |
|
|
227
|
+
| `onOutput` | `function` | Output callback: `(data, type) => void` |
|
|
228
|
+
|
|
229
|
+
**Returns:** `Promise<void>` if no callback provided, `undefined` if callback provided.
|
|
230
|
+
|
|
231
|
+
#### `isInstalled()`
|
|
232
|
+
|
|
233
|
+
Check if SteamCMD is installed and executable.
|
|
234
|
+
|
|
235
|
+
**Returns:** `Promise<boolean>`
|
|
236
|
+
|
|
237
|
+
#### `ensureInstalled([options])`
|
|
238
|
+
|
|
239
|
+
Ensure SteamCMD is installed, downloading if necessary.
|
|
240
|
+
|
|
241
|
+
| Option | Type | Description |
|
|
242
|
+
| ------------ | ---------- | -------------------------- |
|
|
243
|
+
| `onProgress` | `function` | Download progress callback |
|
|
244
|
+
|
|
245
|
+
**Returns:** `Promise<void>`
|
|
246
|
+
|
|
247
|
+
#### `getInfo()`
|
|
248
|
+
|
|
249
|
+
Get information about the SteamCMD installation.
|
|
250
|
+
|
|
251
|
+
**Returns:** `{ directory, executable, platform, isSupported }`
|
|
252
|
+
|
|
253
|
+
#### `getInstalledApps(options)`
|
|
254
|
+
|
|
255
|
+
List all installed Steam applications in a directory.
|
|
256
|
+
|
|
257
|
+
| Option | Type | Description |
|
|
258
|
+
| ------ | -------- | ------------------------------ |
|
|
259
|
+
| `path` | `string` | Installation directory to scan |
|
|
260
|
+
|
|
261
|
+
**Returns:** `Promise<Array>` - Array of installed app info objects
|
|
262
|
+
|
|
263
|
+
#### `getInstalledVersion(options)`
|
|
264
|
+
|
|
265
|
+
Get the installed version of a Steam application.
|
|
266
|
+
|
|
267
|
+
| Option | Type | Description |
|
|
268
|
+
| --------------- | ------------------ | ---------------------- |
|
|
269
|
+
| `applicationId` | `number \| string` | Steam application ID |
|
|
270
|
+
| `path` | `string` | Installation directory |
|
|
271
|
+
|
|
272
|
+
**Returns:** `Promise<Object | null>` - Version info or null if not installed
|
|
273
|
+
|
|
274
|
+
#### `update(options)`
|
|
275
|
+
|
|
276
|
+
Update an installed Steam application.
|
|
277
|
+
|
|
278
|
+
| Option | Type | Description |
|
|
279
|
+
| ---------------- | ------------------ | ------------------------------ |
|
|
280
|
+
| `applicationId` | `number \| string` | Steam application ID to update |
|
|
281
|
+
| `path` | `string` | Installation directory |
|
|
282
|
+
| `username` | `string` | Steam username (optional) |
|
|
283
|
+
| `password` | `string` | Steam password (optional) |
|
|
284
|
+
| `steamGuardCode` | `string` | Steam Guard code (optional) |
|
|
285
|
+
| `onProgress` | `function` | Progress callback (optional) |
|
|
286
|
+
|
|
287
|
+
**Returns:** `Promise<void>`
|
|
288
|
+
|
|
289
|
+
#### `validate(options)`
|
|
290
|
+
|
|
291
|
+
Validate an installed Steam application.
|
|
292
|
+
|
|
293
|
+
| Option | Type | Description |
|
|
294
|
+
| --------------- | ------------------ | -------------------------------- |
|
|
295
|
+
| `applicationId` | `number \| string` | Steam application ID to validate |
|
|
296
|
+
| `path` | `string` | Installation directory |
|
|
297
|
+
| `username` | `string` | Steam username (optional) |
|
|
298
|
+
| `password` | `string` | Steam password (optional) |
|
|
299
|
+
| `onProgress` | `function` | Progress callback (optional) |
|
|
300
|
+
|
|
301
|
+
**Returns:** `Promise<void>`
|
|
302
|
+
|
|
303
|
+
#### `createProgressEmitter(operation, options)`
|
|
304
|
+
|
|
305
|
+
Create an EventEmitter for real-time progress tracking.
|
|
306
|
+
|
|
307
|
+
| Parameter | Type | Description |
|
|
308
|
+
| ----------- | -------- | ----------------------------------------------------- |
|
|
309
|
+
| `operation` | `string` | Operation type: `'install'`, `'update'`, `'validate'` |
|
|
310
|
+
| `options` | `object` | Same options as `install()` |
|
|
311
|
+
|
|
312
|
+
**Returns:** `EventEmitter` - Emits `'progress'`, `'output'`, `'error'`, and `'complete'` events
|
|
313
|
+
|
|
314
|
+
### Command Line Interface
|
|
315
|
+
|
|
316
|
+
```bash
|
|
317
|
+
npx steamcmd <appid> [workshopid] [options]
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
**Options:**
|
|
321
|
+
|
|
322
|
+
| Option | Description |
|
|
323
|
+
| -------------------------- | ----------------------------------------- |
|
|
324
|
+
| `-u, --username <value>` | Steam username |
|
|
325
|
+
| `-p, --password <value>` | Steam password |
|
|
326
|
+
| `--path <value>` | Install path (default: current directory) |
|
|
327
|
+
| `--platform <value>` | Target platform |
|
|
328
|
+
| `--steamGuardCode <value>` | Steam Guard code |
|
|
329
|
+
| `-h, --help` | Show help |
|
|
330
|
+
|
|
331
|
+
**Examples:**
|
|
332
|
+
|
|
333
|
+
```bash
|
|
334
|
+
# Install CS2 dedicated server
|
|
335
|
+
npx steamcmd 730 --path ./cs2-server
|
|
336
|
+
|
|
337
|
+
# Install with authentication
|
|
338
|
+
npx steamcmd 123456 --username myuser --password mypass --path ./game
|
|
339
|
+
|
|
340
|
+
# Install a workshop item
|
|
341
|
+
npx steamcmd 107410 450814997 --path ./arma3
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
## TypeScript
|
|
345
|
+
|
|
346
|
+
TypeScript definitions are included:
|
|
347
|
+
|
|
348
|
+
```typescript
|
|
349
|
+
import steamcmd, { SteamCmdError, InstallOptions } from "steamcmd";
|
|
350
|
+
|
|
351
|
+
const options: InstallOptions = {
|
|
352
|
+
applicationId: 740,
|
|
353
|
+
path: "./server",
|
|
354
|
+
onProgress: (progress) => {
|
|
355
|
+
console.log(`${progress.phase}: ${progress.percent}%`);
|
|
356
|
+
},
|
|
357
|
+
};
|
|
358
|
+
|
|
359
|
+
await steamcmd.install(options);
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
## ES Modules
|
|
363
|
+
|
|
364
|
+
The package supports both CommonJS and ES Modules:
|
|
365
|
+
|
|
366
|
+
```javascript
|
|
367
|
+
// CommonJS
|
|
368
|
+
const steamcmd = require("steamcmd");
|
|
369
|
+
|
|
370
|
+
// ES Modules
|
|
371
|
+
import steamcmd from "steamcmd";
|
|
372
|
+
// or with named exports
|
|
373
|
+
import { install, getInfo, SteamCmdError } from "steamcmd";
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
## Finding App IDs
|
|
377
|
+
|
|
378
|
+
- [Steam Application IDs](https://developer.valvesoftware.com/wiki/Steam_Application_IDs)
|
|
379
|
+
- [SteamDB](https://steamdb.info/)
|
|
380
|
+
|
|
381
|
+
Workshop IDs can be found in the URL of any Workshop item page.
|
|
382
|
+
|
|
383
|
+
## License
|
|
384
|
+
|
|
385
|
+
MIT © [Björn Dahlgren](https://github.com/dahlgren)
|
package/bin/steamcmd
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { program } = require('commander')
|
|
4
|
+
|
|
5
|
+
const steamcmd = require('../src/steamcmd')
|
|
6
|
+
|
|
7
|
+
program
|
|
8
|
+
.name('steamcmd')
|
|
9
|
+
.description('Download and install Steam applications via SteamCMD')
|
|
10
|
+
.argument('<appid>', 'Steam Application ID to install')
|
|
11
|
+
.argument('[workshopid]', 'Workshop item ID (optional)')
|
|
12
|
+
.option('-u, --username <value>', 'Steam Username')
|
|
13
|
+
.option('-p, --password <value>', 'Steam Password')
|
|
14
|
+
.option('--path <value>', 'Install Path instead of CWD')
|
|
15
|
+
.option('--platform <value>', 'Install application for specific OS')
|
|
16
|
+
.option('--steamGuardCode <value>', 'Code for steam guard')
|
|
17
|
+
.parse(process.argv)
|
|
18
|
+
|
|
19
|
+
const args = program.args
|
|
20
|
+
const options = program.opts()
|
|
21
|
+
|
|
22
|
+
const appId = args[0]
|
|
23
|
+
const workshopId = args[1]
|
|
24
|
+
|
|
25
|
+
const installPath = options.path || process.cwd()
|
|
26
|
+
|
|
27
|
+
steamcmd.install({
|
|
28
|
+
applicationId: appId,
|
|
29
|
+
path: installPath,
|
|
30
|
+
username: options.username,
|
|
31
|
+
password: options.password,
|
|
32
|
+
platform: options.platform,
|
|
33
|
+
steamGuardCode: options.steamGuardCode,
|
|
34
|
+
workshopId
|
|
35
|
+
})
|
package/package.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@caleb-collar/steamcmd",
|
|
3
|
+
"version": "1.0.0-alpha.1",
|
|
4
|
+
"description": "Node.js wrapper for SteamCMD - download, install, and manage Steam applications programmatically",
|
|
5
|
+
"main": "src/steamcmd.js",
|
|
6
|
+
"module": "src/steamcmd.mjs",
|
|
7
|
+
"types": "types/steamcmd.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": {
|
|
11
|
+
"types": "./types/steamcmd.d.ts",
|
|
12
|
+
"default": "./src/steamcmd.mjs"
|
|
13
|
+
},
|
|
14
|
+
"require": {
|
|
15
|
+
"types": "./types/steamcmd.d.ts",
|
|
16
|
+
"default": "./src/steamcmd.js"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"lint": "standard --verbose **/*.js bin/*",
|
|
22
|
+
"test": "vitest run",
|
|
23
|
+
"test:watch": "vitest",
|
|
24
|
+
"test:coverage": "vitest run --coverage"
|
|
25
|
+
},
|
|
26
|
+
"bin": {
|
|
27
|
+
"steamcmd": "./bin/steamcmd"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"src/",
|
|
31
|
+
"bin/",
|
|
32
|
+
"types/",
|
|
33
|
+
"README.md",
|
|
34
|
+
"LICENSE",
|
|
35
|
+
"CHANGELOG.md"
|
|
36
|
+
],
|
|
37
|
+
"keywords": [
|
|
38
|
+
"steam",
|
|
39
|
+
"steamcmd",
|
|
40
|
+
"valve",
|
|
41
|
+
"game-server",
|
|
42
|
+
"dedicated-server",
|
|
43
|
+
"workshop",
|
|
44
|
+
"download",
|
|
45
|
+
"install"
|
|
46
|
+
],
|
|
47
|
+
"author": "Björn Dahlgren",
|
|
48
|
+
"license": "MIT",
|
|
49
|
+
"repository": {
|
|
50
|
+
"type": "git",
|
|
51
|
+
"url": "git+https://github.com/caleb-collar/node-steamcmd.git"
|
|
52
|
+
},
|
|
53
|
+
"bugs": {
|
|
54
|
+
"url": "https://github.com/caleb-collar/node-steamcmd/issues"
|
|
55
|
+
},
|
|
56
|
+
"homepage": "https://github.com/caleb-collar/node-steamcmd#readme",
|
|
57
|
+
"engines": {
|
|
58
|
+
"node": ">=18"
|
|
59
|
+
},
|
|
60
|
+
"dependencies": {
|
|
61
|
+
"commander": "^12.1.0",
|
|
62
|
+
"env-paths": "^2.2.1",
|
|
63
|
+
"tar": "^7.4.3",
|
|
64
|
+
"unzipper": "^0.12.3"
|
|
65
|
+
},
|
|
66
|
+
"devDependencies": {
|
|
67
|
+
"@vitest/coverage-v8": "^4.0.18",
|
|
68
|
+
"standard": "^17.1.2",
|
|
69
|
+
"vitest": "^4.0.18"
|
|
70
|
+
}
|
|
71
|
+
}
|