@louisraetz/steamidled 1.0.0 → 1.0.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/dist/index.js +55 -4
- package/dist/ui/gameSelector.js +13 -14
- package/package.json +1 -1
- package/src/index.ts +2 -2
package/dist/index.js
CHANGED
|
@@ -5,7 +5,10 @@ import { loginWithQR, loginWithCredentials, loginWithStoredCredentials, hasStore
|
|
|
5
5
|
import { promptAuthMethod } from './ui/prompts.js';
|
|
6
6
|
import { selectGames } from './ui/gameSelector.js';
|
|
7
7
|
import { showWelcome, showIdlingStatus, showLoginSuccess, showLoginError, showGoodbye, showError, } from './ui/display.js';
|
|
8
|
+
import { loadFavorites } from './storage/favorites.js';
|
|
8
9
|
import ora from 'ora';
|
|
10
|
+
const args = process.argv.slice(2);
|
|
11
|
+
const isHeadless = args.includes('--headless');
|
|
9
12
|
const client = new SteamClient();
|
|
10
13
|
let isIdling = false;
|
|
11
14
|
let idlingGames = [];
|
|
@@ -17,9 +20,59 @@ let isInEditMode = false;
|
|
|
17
20
|
let accountName = '';
|
|
18
21
|
// Main entry point that orchestrates the application flow
|
|
19
22
|
async function main() {
|
|
20
|
-
showWelcome();
|
|
21
23
|
process.on('SIGINT', handleShutdown);
|
|
22
24
|
process.on('SIGTERM', handleShutdown);
|
|
25
|
+
if (isHeadless) {
|
|
26
|
+
await runHeadless();
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
await runInteractive();
|
|
30
|
+
}
|
|
31
|
+
await new Promise(() => { });
|
|
32
|
+
}
|
|
33
|
+
// Headless mode: auto-login and start idling favorites
|
|
34
|
+
async function runHeadless() {
|
|
35
|
+
if (!hasStoredLogin()) {
|
|
36
|
+
showError('No stored login found. Run interactively first to log in.');
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
const spinner = ora('Logging in...').start();
|
|
40
|
+
const loginResult = await loginWithStoredCredentials(client);
|
|
41
|
+
if (!loginResult.success) {
|
|
42
|
+
spinner.fail('Login failed');
|
|
43
|
+
showError(loginResult.error || 'Unknown error');
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
accountName = loginResult.accountName;
|
|
47
|
+
spinner.succeed(`Logged in as ${accountName}`);
|
|
48
|
+
const gamesSpinner = ora('Fetching your game library...').start();
|
|
49
|
+
try {
|
|
50
|
+
allGames = await client.getOwnedGames();
|
|
51
|
+
gamesSpinner.succeed(`Found ${allGames.length} games`);
|
|
52
|
+
}
|
|
53
|
+
catch (err) {
|
|
54
|
+
gamesSpinner.fail('Failed to fetch games');
|
|
55
|
+
showError(err.message);
|
|
56
|
+
process.exit(1);
|
|
57
|
+
}
|
|
58
|
+
const favoriteIds = loadFavorites(accountName);
|
|
59
|
+
if (favoriteIds.length === 0) {
|
|
60
|
+
showError('No favorites configured. Run interactively first to set favorites.');
|
|
61
|
+
process.exit(1);
|
|
62
|
+
}
|
|
63
|
+
const selectedGames = allGames
|
|
64
|
+
.filter((g) => favoriteIds.includes(g.appid))
|
|
65
|
+
.map((g) => ({ appid: g.appid, name: g.name }));
|
|
66
|
+
if (selectedGames.length === 0) {
|
|
67
|
+
showError('No matching games found for your favorites.');
|
|
68
|
+
process.exit(1);
|
|
69
|
+
}
|
|
70
|
+
console.log(`Starting ${selectedGames.length} favorite game(s)...`);
|
|
71
|
+
startIdling(selectedGames);
|
|
72
|
+
}
|
|
73
|
+
// Interactive mode: full UI with prompts and game selector
|
|
74
|
+
async function runInteractive() {
|
|
75
|
+
showWelcome();
|
|
23
76
|
const loginResult = await handleLogin();
|
|
24
77
|
if (!loginResult.success) {
|
|
25
78
|
showLoginError(loginResult.error || 'Unknown error');
|
|
@@ -41,14 +94,12 @@ async function main() {
|
|
|
41
94
|
showError('No games found in your library');
|
|
42
95
|
process.exit(1);
|
|
43
96
|
}
|
|
44
|
-
const { selectedGames
|
|
97
|
+
const { selectedGames } = await selectGames(allGames, accountName);
|
|
45
98
|
if (selectedGames.length === 0) {
|
|
46
99
|
showError('No games selected');
|
|
47
100
|
process.exit(1);
|
|
48
101
|
}
|
|
49
102
|
startIdling(selectedGames);
|
|
50
|
-
await new Promise(() => {
|
|
51
|
-
});
|
|
52
103
|
}
|
|
53
104
|
// Handles authentication method selection and login
|
|
54
105
|
async function handleLogin() {
|
package/dist/ui/gameSelector.js
CHANGED
|
@@ -71,7 +71,7 @@ export async function selectGames(games, accountName, currentSelection = []) {
|
|
|
71
71
|
// Instructions
|
|
72
72
|
console.log('');
|
|
73
73
|
console.log(chalk.gray(' ↑/↓: Navigate | Space: Toggle | F: Favorite'));
|
|
74
|
-
console.log(chalk.gray(' Enter: Start |
|
|
74
|
+
console.log(chalk.gray(' Enter: Start | S: Start all favorites'));
|
|
75
75
|
console.log('');
|
|
76
76
|
};
|
|
77
77
|
const handleKey = (str, key) => {
|
|
@@ -143,21 +143,20 @@ export async function selectGames(games, accountName, currentSelection = []) {
|
|
|
143
143
|
render();
|
|
144
144
|
return;
|
|
145
145
|
}
|
|
146
|
+
if (str === 's' || str === 'S') {
|
|
147
|
+
cleanup();
|
|
148
|
+
const selectedGames = selectableGames
|
|
149
|
+
.filter((g) => g.isFavorite)
|
|
150
|
+
.map((g) => ({ appid: g.appid, name: g.name }));
|
|
151
|
+
resolve({ selectedGames, quickStart: true });
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
146
154
|
if (key.name === 'return') {
|
|
147
155
|
cleanup();
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
.filter((g) => g.isFavorite)
|
|
153
|
-
.map((g) => ({ appid: g.appid, name: g.name }));
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
selectedGames = selectableGames
|
|
157
|
-
.filter((g) => g.selected)
|
|
158
|
-
.map((g) => ({ appid: g.appid, name: g.name }));
|
|
159
|
-
}
|
|
160
|
-
resolve({ selectedGames, quickStart });
|
|
156
|
+
const selectedGames = selectableGames
|
|
157
|
+
.filter((g) => g.selected)
|
|
158
|
+
.map((g) => ({ appid: g.appid, name: g.name }));
|
|
159
|
+
resolve({ selectedGames, quickStart: false });
|
|
161
160
|
return;
|
|
162
161
|
}
|
|
163
162
|
};
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -19,11 +19,11 @@ import {
|
|
|
19
19
|
showError,
|
|
20
20
|
} from './ui/display.js';
|
|
21
21
|
import { loadFavorites } from './storage/favorites.js';
|
|
22
|
+
import ora from 'ora';
|
|
23
|
+
import type { SteamGame, GameSelection, IdlingGame, LoginResult } from './types/index.js';
|
|
22
24
|
|
|
23
25
|
const args = process.argv.slice(2);
|
|
24
26
|
const isHeadless = args.includes('--headless');
|
|
25
|
-
import ora from 'ora';
|
|
26
|
-
import type { SteamGame, GameSelection, IdlingGame, LoginResult } from './types/index.js';
|
|
27
27
|
|
|
28
28
|
const client = new SteamClient();
|
|
29
29
|
let isIdling = false;
|