@caleb-collar/steamcmd 1.0.0-alpha.1 → 1.1.0

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 CHANGED
@@ -7,6 +7,32 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.1.0] - 2026-01-31
11
+
12
+ ### Added
13
+
14
+ - **Full TypeScript source**: Entire codebase converted from JavaScript to TypeScript
15
+ - **Strict TypeScript configuration**: Enabled all strict mode checks for better type safety
16
+ - **TSDoc documentation**: All public APIs documented with TSDoc comments
17
+ - **API documentation generation**: `npm run docs` generates HTML documentation via TypeDoc
18
+
19
+ ### Changed
20
+
21
+ - **Build system**: Package now compiles from TypeScript source to dist/ folder
22
+ - **Linting**: Replaced `standard` with Biome for modern, fast linting
23
+ - **Node.js imports**: Updated to use `node:` protocol for builtin modules
24
+
25
+ ### Removed
26
+
27
+ - **standard linter**: Replaced with Biome (fixes eslint security vulnerability chain)
28
+ - **Legacy JavaScript source**: Source files are now TypeScript (.ts)
29
+
30
+ ### Security
31
+
32
+ - **Resolved**: Removed `standard` linter dependency which had eslint vulnerability chain
33
+
34
+ ## [1.0.0-alpha.2] - 2026-01-31
35
+
10
36
  ### Added
11
37
 
12
38
  - **ESM module support**: Package now supports both CommonJS (`require`) and ES Modules (`import`)
@@ -15,11 +41,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
15
41
  - **`validate()`**: Validate an installed Steam application
16
42
  - **`getInstalledVersion()`**: Get the installed version (build ID) of a Steam application
17
43
  - **`createProgressEmitter()`**: Create an EventEmitter for real-time progress tracking
44
+ - **Renovate**: Replaced Dependabot with Renovate for better dependency management
18
45
 
19
46
  ### Changed
20
47
 
21
48
  - **package.json**: Added `exports` field for dual CJS/ESM support
22
49
  - **package.json**: Added `module` field pointing to ESM entry point
50
+ - **package.json**: Fixed bin path format (removed leading `./`)
51
+
52
+ ### Removed
53
+
54
+ - **Travis CI**: Removed legacy `.travis.yml` (replaced by GitHub Actions)
55
+ - **Dependabot**: Removed `dependabot.yml` (replaced by Renovate)
56
+
57
+ ### Security
58
+
59
+ - **Known Issue**: `standard` linter depends on eslint <9.26.0 which has a moderate severity vulnerability (GHSA-p5wg-g6qr-c7cg). This only affects development and does not impact published package. Will be resolved in v2.0 by migrating to Biome.
23
60
 
24
61
  ## [1.0.0-alpha.1] - 2026-01-31
25
62
 
@@ -136,6 +173,7 @@ try {
136
173
  }
137
174
  ```
138
175
 
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
176
+ [Unreleased]: https://github.com/caleb-collar/node-steamcmd/compare/v1.0.0-alpha.2...HEAD
177
+ [1.0.0-alpha.2]: https://github.com/caleb-collar/node-steamcmd/compare/v1.0.0-alpha.1...v1.0.0-alpha.2
178
+ [1.0.0-alpha.1]: https://github.com/caleb-collar/node-steamcmd/compare/v0.3.1...v1.0.0-alpha.1
179
+ [0.3.1]: https://github.com/caleb-collar/node-steamcmd/releases/tag/v0.3.1
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2014-2026 Björn Dahlgren
3
+ Copyright (c) 2014-2026 Caleb Collar
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # SteamCMD
2
2
 
3
- [![CI](https://github.com/dahlgren/node-steamcmd/actions/workflows/ci.yml/badge.svg)](https://github.com/dahlgren/node-steamcmd/actions/workflows/ci.yml)
4
- [![npm version](https://badge.fury.io/js/steamcmd.svg)](https://www.npmjs.com/package/steamcmd)
3
+ [![CI](https://github.com/caleb-collar/node-steamcmd/actions/workflows/ci.yml/badge.svg)](https://github.com/caleb-collar/node-steamcmd/actions/workflows/ci.yml)
4
+ [![npm version](https://img.shields.io/npm/v/@caleb-collar/steamcmd.svg)](https://www.npmjs.com/package/@caleb-collar/steamcmd)
5
5
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
6
 
7
7
  A Node.js wrapper for Valve's [SteamCMD](https://developer.valvesoftware.com/wiki/SteamCMD) tool. Download, install, and manage Steam applications programmatically.
@@ -35,7 +35,7 @@ sudo apt-get install lib32gcc-s1
35
35
  ## Installation
36
36
 
37
37
  ```bash
38
- npm install steamcmd
38
+ npm install @caleb-collar/steamcmd
39
39
  ```
40
40
 
41
41
  ## Usage
@@ -45,7 +45,7 @@ npm install steamcmd
45
45
  #### Basic Installation
46
46
 
47
47
  ```javascript
48
- const steamcmd = require("steamcmd");
48
+ const steamcmd = require("@caleb-collar/steamcmd");
49
49
 
50
50
  // Install a dedicated server (e.g., Counter-Strike 2)
51
51
  await steamcmd.install({
@@ -97,7 +97,7 @@ await steamcmd.install({
97
97
  #### Utility Functions
98
98
 
99
99
  ```javascript
100
- const steamcmd = require("steamcmd");
100
+ const steamcmd = require("@caleb-collar/steamcmd");
101
101
 
102
102
  // Check if SteamCMD is installed
103
103
  const installed = await steamcmd.isInstalled();
@@ -148,7 +148,7 @@ await steamcmd.validate({
148
148
  #### EventEmitter Progress
149
149
 
150
150
  ```javascript
151
- const steamcmd = require("steamcmd");
151
+ const steamcmd = require("@caleb-collar/steamcmd");
152
152
 
153
153
  // Create an event emitter for real-time progress
154
154
  const emitter = steamcmd.createProgressEmitter("install", {
@@ -176,7 +176,11 @@ emitter.on("complete", () => {
176
176
  #### Error Handling
177
177
 
178
178
  ```javascript
179
- const { SteamCmdError, DownloadError, InstallError } = require("steamcmd");
179
+ const {
180
+ SteamCmdError,
181
+ DownloadError,
182
+ InstallError,
183
+ } = require("@caleb-collar/steamcmd");
180
184
 
181
185
  try {
182
186
  await steamcmd.install({
@@ -346,7 +350,10 @@ npx steamcmd 107410 450814997 --path ./arma3
346
350
  TypeScript definitions are included:
347
351
 
348
352
  ```typescript
349
- import steamcmd, { SteamCmdError, InstallOptions } from "steamcmd";
353
+ import steamcmd, {
354
+ SteamCmdError,
355
+ InstallOptions,
356
+ } from "@caleb-collar/steamcmd";
350
357
 
351
358
  const options: InstallOptions = {
352
359
  applicationId: 740,
@@ -365,12 +372,12 @@ The package supports both CommonJS and ES Modules:
365
372
 
366
373
  ```javascript
367
374
  // CommonJS
368
- const steamcmd = require("steamcmd");
375
+ const steamcmd = require("@caleb-collar/steamcmd");
369
376
 
370
377
  // ES Modules
371
- import steamcmd from "steamcmd";
378
+ import steamcmd from "@caleb-collar/steamcmd";
372
379
  // or with named exports
373
- import { install, getInfo, SteamCmdError } from "steamcmd";
380
+ import { install, getInfo, SteamCmdError } from "@caleb-collar/steamcmd";
374
381
  ```
375
382
 
376
383
  ## Finding App IDs
@@ -382,4 +389,9 @@ Workshop IDs can be found in the URL of any Workshop item page.
382
389
 
383
390
  ## License
384
391
 
385
- MIT © [Björn Dahlgren](https://github.com/dahlgren)
392
+ MIT
393
+
394
+ ## Credits
395
+
396
+ - **Original Author:** [Björn Dahlgren](https://github.com/dahlgren) - Creator of the original node-steamcmd package
397
+ - **Modernization:** [Caleb Collar](https://github.com/caleb-collar) - ES Modules, TypeScript definitions, Promise API, and modern Node.js support
package/bin/steamcmd CHANGED
@@ -1,28 +1,28 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const { program } = require('commander')
3
+ const { program } = require("commander");
4
4
 
5
- const steamcmd = require('../src/steamcmd')
5
+ const steamcmd = require("../dist/steamcmd");
6
6
 
7
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)
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
18
 
19
- const args = program.args
20
- const options = program.opts()
19
+ const args = program.args;
20
+ const options = program.opts();
21
21
 
22
- const appId = args[0]
23
- const workshopId = args[1]
22
+ const appId = args[0];
23
+ const workshopId = args[1];
24
24
 
25
- const installPath = options.path || process.cwd()
25
+ const installPath = options.path || process.cwd();
26
26
 
27
27
  steamcmd.install({
28
28
  applicationId: appId,
@@ -31,5 +31,5 @@ steamcmd.install({
31
31
  password: options.password,
32
32
  platform: options.platform,
33
33
  steamGuardCode: options.steamGuardCode,
34
- workshopId
35
- })
34
+ workshopId,
35
+ });
@@ -0,0 +1,85 @@
1
+ /**
2
+ * @module steamcmd/download
3
+ * @description Downloads and extracts SteamCMD for the current platform
4
+ * @private
5
+ */
6
+ import { EventEmitter } from 'node:events';
7
+ /**
8
+ * Progress information for download operations
9
+ */
10
+ export interface DownloadProgress {
11
+ /** Current phase of the operation */
12
+ phase: 'starting' | 'downloading' | 'complete';
13
+ /** Percentage complete (0-100) */
14
+ percent: number;
15
+ /** Number of bytes downloaded so far */
16
+ bytesDownloaded: number;
17
+ /** Total bytes to download (0 if unknown) */
18
+ totalBytes: number;
19
+ }
20
+ /**
21
+ * Options for download operations
22
+ */
23
+ export interface DownloadOptions {
24
+ /** Progress callback fired during download */
25
+ onProgress?: (progress: DownloadProgress) => void;
26
+ }
27
+ /**
28
+ * Callback function type for download operations
29
+ */
30
+ export type DownloadCallback = (error: Error | null) => void;
31
+ /**
32
+ * SteamCMD download URLs by platform
33
+ */
34
+ export declare const DOWNLOAD_URLS: Record<string, string>;
35
+ /**
36
+ * Custom error class for download failures
37
+ */
38
+ export declare class DownloadError extends Error {
39
+ name: "DownloadError";
40
+ code: string;
41
+ constructor(message: string, code: string);
42
+ }
43
+ /**
44
+ * EventEmitter for download operations with progress events
45
+ */
46
+ export interface DownloadEmitter extends EventEmitter {
47
+ on(event: 'progress', listener: (progress: DownloadProgress) => void): this;
48
+ on(event: 'complete', listener: () => void): this;
49
+ on(event: 'error', listener: (error: DownloadError) => void): this;
50
+ once(event: 'progress', listener: (progress: DownloadProgress) => void): this;
51
+ once(event: 'complete', listener: () => void): this;
52
+ once(event: 'error', listener: (error: DownloadError) => void): this;
53
+ emit(event: 'progress', progress: DownloadProgress): boolean;
54
+ emit(event: 'complete'): boolean;
55
+ emit(event: 'error', error: DownloadError): boolean;
56
+ }
57
+ /**
58
+ * Download and extract SteamCMD for the current platform
59
+ * @param options Download options
60
+ * @param callback Optional callback. If omitted, returns a Promise.
61
+ * @returns Promise if no callback provided
62
+ *
63
+ * @example
64
+ * // With progress callback
65
+ * await download({
66
+ * onProgress: (progress) => {
67
+ * console.log(`${progress.phase}: ${progress.percent}%`);
68
+ * }
69
+ * });
70
+ */
71
+ export declare function download(options?: DownloadOptions | DownloadCallback, callback?: DownloadCallback): Promise<void> | void;
72
+ /**
73
+ * Download SteamCMD with EventEmitter-based progress
74
+ * @param options Download options
75
+ * @returns Emitter that fires 'progress', 'error', and 'complete' events
76
+ *
77
+ * @example
78
+ * const emitter = downloadWithProgress();
79
+ * emitter.on('progress', (p) => console.log(`${p.percent}%`));
80
+ * emitter.on('complete', () => console.log('Done!'));
81
+ * emitter.on('error', (err) => console.error(err));
82
+ */
83
+ export declare function downloadWithProgress(options?: DownloadOptions): DownloadEmitter;
84
+ export default download;
85
+ //# sourceM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IAAI,CAAA;IAClE,IAAI,CAAC,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC,QAAQ,EAAE,gBAAgB,KAAK,IAAI,GAAG,IAAI,CAAA;IAC7E,IAAI,CAAC,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAAA;IACnD,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,GAAG,IAAI,CAAA;IACpE,IAAI,CAAC,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAA;IAC5D,IAAI,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAA;IAChC,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,aAAa,GAAG,OAAO,CAAA;CACpD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,QAAQ,CACtB,OAAO,CAAC,EAAE,eAAe,GAAG,gBAAgB,EAC5C,QAAQ,CAAC,EAAE,gBAAgB,GAC1B,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAkItB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,CAAC,EAAE,eAAe,GACxB,eAAe,CAqBjB;AAED,eAAe,QAAQ,CAAA"}
@@ -0,0 +1,213 @@
1
+ "use strict";
2
+ /**
3
+ * @module steamcmd/download
4
+ * @description Downloads and extracts SteamCMD for the current platform
5
+ * @private
6
+ */
7
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
+ if (k2 === undefined) k2 = k;
9
+ var desc = Object.getOwnPropertyDescriptor(m, k);
10
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
+ desc = { enumerable: true, get: function() { return m[k]; } };
12
+ }
13
+ Object.defineProperty(o, k2, desc);
14
+ }) : (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ o[k2] = m[k];
17
+ }));
18
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
20
+ }) : function(o, v) {
21
+ o["default"] = v;
22
+ });
23
+ var __importStar = (this && this.__importStar) || (function () {
24
+ var ownKeys = function(o) {
25
+ ownKeys = Object.getOwnPropertyNames || function (o) {
26
+ var ar = [];
27
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
28
+ return ar;
29
+ };
30
+ return ownKeys(o);
31
+ };
32
+ return function (mod) {
33
+ if (mod && mod.__esModule) return mod;
34
+ var result = {};
35
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
36
+ __setModuleDefault(result, mod);
37
+ return result;
38
+ };
39
+ })();
40
+ var __importDefault = (this && this.__importDefault) || function (mod) {
41
+ return (mod && mod.__esModule) ? mod : { "default": mod };
42
+ };
43
+ Object.defineProperty(exports, "__esModule", { value: true });
44
+ exports.DownloadError = exports.DOWNLOAD_URLS = void 0;
45
+ exports.download = download;
46
+ exports.downloadWithProgress = downloadWithProgress;
47
+ const node_events_1 = require("node:events");
48
+ const node_fs_1 = __importDefault(require("node:fs"));
49
+ const node_https_1 = __importDefault(require("node:https"));
50
+ const tar_1 = __importDefault(require("tar"));
51
+ const unzipper_1 = __importDefault(require("unzipper"));
52
+ const env = __importStar(require("./env.js"));
53
+ /**
54
+ * SteamCMD download URLs by platform
55
+ */
56
+ exports.DOWNLOAD_URLS = {
57
+ darwin: 'https://steamcdn-a.akamaihd.net/client/installer/steamcmd_osx.tar.gz',
58
+ linux: 'https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz',
59
+ win32: 'https://steamcdn-a.akamaihd.net/client/installer/steamcmd.zip',
60
+ };
61
+ /**
62
+ * Custom error class for download failures
63
+ */
64
+ class DownloadError extends Error {
65
+ name = 'DownloadError';
66
+ code;
67
+ constructor(message, code) {
68
+ super(message);
69
+ this.code = code;
70
+ }
71
+ }
72
+ exports.DownloadError = DownloadError;
73
+ /**
74
+ * Download and extract SteamCMD for the current platform
75
+ * @param options Download options
76
+ * @param callback Optional callback. If omitted, returns a Promise.
77
+ * @returns Promise if no callback provided
78
+ *
79
+ * @example
80
+ * // With progress callback
81
+ * await download({
82
+ * onProgress: (progress) => {
83
+ * console.log(`${progress.phase}: ${progress.percent}%`);
84
+ * }
85
+ * });
86
+ */
87
+ function download(options, callback) {
88
+ // Handle legacy signature: download(callback)
89
+ if (typeof options === 'function') {
90
+ callback = options;
91
+ options = {};
92
+ }
93
+ options = options || {};
94
+ // Support Promise-based usage
95
+ if (typeof callback !== 'function') {
96
+ return new Promise((resolve, reject) => {
97
+ download(options, (err) => {
98
+ if (err)
99
+ reject(err);
100
+ else
101
+ resolve();
102
+ });
103
+ });
104
+ }
105
+ const onProgress = typeof options.onProgress === 'function' ? options.onProgress : () => { };
106
+ const platformValue = env.platform();
107
+ const url = exports.DOWNLOAD_URLS[platformValue];
108
+ const destDir = env.directory();
109
+ if (!url) {
110
+ callback(new DownloadError(`Unsupported platform: ${platformValue}`, 'UNSUPPORTED_PLATFORM'));
111
+ return;
112
+ }
113
+ // Ensure destination directory exists
114
+ try {
115
+ node_fs_1.default.mkdirSync(destDir, { recursive: true });
116
+ }
117
+ catch (err) {
118
+ const message = err instanceof Error ? err.message : String(err);
119
+ callback(new DownloadError(`Failed to create directory ${destDir}: ${message}`, 'DIRECTORY_ERROR'));
120
+ return;
121
+ }
122
+ onProgress({
123
+ phase: 'starting',
124
+ percent: 0,
125
+ bytesDownloaded: 0,
126
+ totalBytes: 0,
127
+ });
128
+ node_https_1.default
129
+ .get(url, (res) => {
130
+ if (res.statusCode !== 200) {
131
+ callback(new DownloadError(`Failed to download SteamCMD: HTTP ${res.statusCode}`, 'HTTP_ERROR'));
132
+ return;
133
+ }
134
+ const totalBytes = parseInt(res.headers['content-length'] || '0', 10);
135
+ let bytesDownloaded = 0;
136
+ res.on('data', (chunk) => {
137
+ bytesDownloaded += chunk.length;
138
+ const percent = totalBytes > 0 ? Math.round((bytesDownloaded / totalBytes) * 100) : 0;
139
+ onProgress({
140
+ phase: 'downloading',
141
+ percent,
142
+ bytesDownloaded,
143
+ totalBytes,
144
+ });
145
+ });
146
+ if (platformValue === 'darwin' || platformValue === 'linux') {
147
+ res
148
+ .pipe(tar_1.default.x({ cwd: destDir }))
149
+ .on('error', (err) => {
150
+ callback(new DownloadError(`Failed to extract tar archive: ${err.message}`, 'EXTRACT_ERROR'));
151
+ })
152
+ .on('finish', () => {
153
+ onProgress({
154
+ phase: 'complete',
155
+ percent: 100,
156
+ bytesDownloaded,
157
+ totalBytes,
158
+ });
159
+ callback(null);
160
+ });
161
+ }
162
+ else if (platformValue === 'win32') {
163
+ res
164
+ .pipe(unzipper_1.default.Extract({ path: destDir }))
165
+ .on('error', (err) => {
166
+ callback(new DownloadError(`Failed to extract zip archive: ${err.message}`, 'EXTRACT_ERROR'));
167
+ })
168
+ .on('close', () => {
169
+ onProgress({
170
+ phase: 'complete',
171
+ percent: 100,
172
+ bytesDownloaded,
173
+ totalBytes,
174
+ });
175
+ callback(null);
176
+ });
177
+ }
178
+ })
179
+ .on('error', (err) => {
180
+ callback(new DownloadError(`Network error: ${err.message}`, 'NETWORK_ERROR'));
181
+ });
182
+ }
183
+ /**
184
+ * Download SteamCMD with EventEmitter-based progress
185
+ * @param options Download options
186
+ * @returns Emitter that fires 'progress', 'error', and 'complete' events
187
+ *
188
+ * @example
189
+ * const emitter = downloadWithProgress();
190
+ * emitter.on('progress', (p) => console.log(`${p.percent}%`));
191
+ * emitter.on('complete', () => console.log('Done!'));
192
+ * emitter.on('error', (err) => console.error(err));
193
+ */
194
+ function downloadWithProgress(options) {
195
+ const emitter = new node_events_1.EventEmitter();
196
+ // Run download in next tick to allow event binding
197
+ process.nextTick(() => {
198
+ download({
199
+ ...options,
200
+ onProgress: (progress) => emitter.emit('progress', progress),
201
+ }, (err) => {
202
+ if (err) {
203
+ emitter.emit('error', err);
204
+ }
205
+ else {
206
+ emitter.emit('complete');
207
+ }
208
+ });
209
+ });
210
+ return emitter;
211
+ }
212
+ exports.default = download;
213
+ //# sourceMappingURL=download.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"download.js","sourceRoot":"","sources":["../src/download.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyFH,4BAqIC;AAaD,oDAuBC;AAhQD,6CAA0C;AAC1C,sDAAwB;AACxB,4DAA8B;AAC9B,8CAAqB;AACrB,wDAA4B;AAC5B,8CAA+B;AA6B/B;;GAEG;AACU,QAAA,aAAa,GAA2B;IACnD,MAAM,EACJ,sEAAsE;IACxE,KAAK,EACH,wEAAwE;IAC1E,KAAK,EAAE,+DAA+D;CACvE,CAAA;AAED;;GAEG;AACH,MAAa,aAAc,SAAQ,KAAK;IACtC,IAAI,GAAG,eAAwB,CAAA;IAC/B,IAAI,CAAQ;IAEZ,YAAY,OAAe,EAAE,IAAY;QACvC,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;CACF;AARD,sCAQC;AAiBD;;;;;;;;;;;;;GAaG;AACH,SAAgB,QAAQ,CACtB,OAA4C,EAC5C,QAA2B;IAE3B,8CAA8C;IAC9C,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE,CAAC;QAClC,QAAQ,GAAG,OAAO,CAAA;QAClB,OAAO,GAAG,EAAE,CAAA;IACd,CAAC;IACD,OAAO,GAAG,OAAO,IAAI,EAAE,CAAA;IAEvB,8BAA8B;IAC9B,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE,CAAC;QACnC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,QAAQ,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;gBAC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;YAC1B,CAAC;QACH,CAAC,CACF,CAAA;IACH,CAAC,CAAC,CAAA;IAEF,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,kBAAe,QAAQ,CAAA"}
package/dist/env.d.ts ADDED
@@ -0,0 +1,38 @@
1
+ /**
2
+ * @module steamcmd/env
3
+ * @description Platform detection and path resolution for SteamCMD
4
+ * @private
5
+ */
6
+ /**
7
+ * Supported platforms for SteamCMD
8
+ */
9
+ export declare const SUPPORTED_PLATFORMS: readonly string[];
10
+ /**
11
+ * Get the SteamCMD installation directory
12
+ * @returns Path to the SteamCMD directory
13
+ */
14
+ export declare function directory(): string;
15
+ /**
16
+ * Get the current platform
17
+ * @returns The current OS platform
18
+ */
19
+ export declare function platform(): NodeJS.Platform;
20
+ /**
21
+ * Check if the current platform is supported
22
+ * @returns True if platform is supported
23
+ */
24
+ export declare function isPlatformSupported(): boolean;
25
+ /**
26
+ * Get the path to the SteamCMD executable
27
+ * @returns Path to executable or null if unsupported platform
28
+ */
29
+ export declare function executable(): string | null;
30
+ declare const _default: {
31
+ directory: typeof directory;
32
+ executable: typeof executable;
33
+ platform: typeof platform;
34
+ isPlatformSupported: typeof isPlatformSupported;
35
+ SUPPORTED_PLATFORMS: readonly string[];
36
+ };
37
+ export default _default;
38
+ //# sourceMappingURL=env.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH;;GAEG;AACH,eAAO,MAAM,mBAAmB,EAAE,SAAS,MAAM,EAIvC,CAAA;AAEV;;;GAGG;AACH,wBAAgB,SAAS,IAAI,MAAM,CAElC;AAED;;;GAGG;AACH,wBAAgB,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAE1C;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAE7C;AAED;;;GAGG;AACH,wBAAgB,UAAU,IAAI,MAAM,GAAG,IAAI,CAY1C;;;;;;;;AAED,wBAMC"}
package/dist/env.js ADDED
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ /**
3
+ * @module steamcmd/env
4
+ * @description Platform detection and path resolution for SteamCMD
5
+ * @private
6
+ */
7
+ var __importDefault = (this && this.__importDefault) || function (mod) {
8
+ return (mod && mod.__esModule) ? mod : { "default": mod };
9
+ };
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.SUPPORTED_PLATFORMS = void 0;
12
+ exports.directory = directory;
13
+ exports.platform = platform;
14
+ exports.isPlatformSupported = isPlatformSupported;
15
+ exports.executable = executable;
16
+ const node_os_1 = __importDefault(require("node:os"));
17
+ const node_path_1 = __importDefault(require("node:path"));
18
+ const env_paths_1 = __importDefault(require("env-paths"));
19
+ const paths = (0, env_paths_1.default)('steamcmd', { suffix: '' });
20
+ /**
21
+ * Supported platforms for SteamCMD
22
+ */
23
+ exports.SUPPORTED_PLATFORMS = [
24
+ 'linux',
25
+ 'darwin',
26
+ 'win32',
27
+ ];
28
+ /**
29
+ * Get the SteamCMD installation directory
30
+ * @returns Path to the SteamCMD directory
31
+ */
32
+ function directory() {
33
+ return paths.data;
34
+ }
35
+ /**
36
+ * Get the current platform
37
+ * @returns The current OS platform
38
+ */
39
+ function platform() {
40
+ return node_os_1.default.platform();
41
+ }
42
+ /**
43
+ * Check if the current platform is supported
44
+ * @returns True if platform is supported
45
+ */
46
+ function isPlatformSupported() {
47
+ return exports.SUPPORTED_PLATFORMS.includes(platform());
48
+ }
49
+ /**
50
+ * Get the path to the SteamCMD executable
51
+ * @returns Path to executable or null if unsupported platform
52
+ */
53
+ function executable() {
54
+ const plat = platform();
55
+ if (plat === 'linux' || plat === 'darwin') {
56
+ return node_path_1.default.resolve(directory(), 'steamcmd.sh');
57
+ }
58
+ if (plat === 'win32') {
59
+ return node_path_1.default.resolve(directory(), 'steamcmd.exe');
60
+ }
61
+ return null;
62
+ }
63
+ exports.default = {
64
+ directory,
65
+ executable,
66
+ platform,
67
+ isPlatformSupported,
68
+ SUPPORTED_PLATFORMS: exports.SUPPORTED_PLATFORMS,
69
+ };
70
+ //# sourceMappingURL=env.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.js","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAqBH,8BAEC;AAMD,4BAEC;AAMD,kDAEC;AAMD,gCAYC;AAvDD,sDAAwB;AACxB,0DAA4B;AAC5B,0DAAgC;AAEhC,MAAM,KAAK,GAAG,IAAA,mBAAQ,EAAC,UAAU,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAA;AAElD;;GAEG;AACU,QAAA,mBAAmB,GAAsB;IACpD,OAAO;IACP,QAAQ;IACR,OAAO;CACC,CAAA;AAEV;;;GAGG;AACH,SAAgB,SAAS;IACvB,OAAO,KAAK,CAAC,IAAI,CAAA;AACnB,CAAC;AAED;;;GAGG;AACH,SAAgB,QAAQ;IACtB,OAAO,iBAAE,CAAC,QAAQ,EAAE,CAAA;AACtB,CAAC;AAED;;;GAGG;AACH,SAAgB,mBAAmB;IACjC,OAAO,2BAAmB,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAA;AACjD,CAAC;AAED;;;GAGG;AACH,SAAgB,UAAU;IACxB,MAAM,IAAI,GAAG,QAAQ,EAAE,CAAA;IAEvB,IAAI,IAAI,KAAK,OAAO,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC1C,OAAO,mBAAI,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,aAAa,CAAC,CAAA;IACjD,CAAC;IAED,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;QACrB,OAAO,mBAAI,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,cAAc,CAAC,CAAA;IAClD,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC;AAED,kBAAe;IACb,SAAS;IACT,UAAU;IACV,QAAQ;IACR,mBAAmB;IACnB,mBAAmB,EAAnB,2BAAmB;CACpB,CAAA"}