decharge-scout 1.5.0 → 1.6.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/index.js CHANGED
@@ -307,25 +307,33 @@ async function main(options) {
307
307
  // Ask user to confirm or override (with timeout)
308
308
  console.log(chalk.blue('\nYou can use this location or enter a custom one.'));
309
309
  console.log(chalk.gray('(Press Enter to use detected location, or type custom location)'));
310
+ console.log(chalk.gray('You have 30 seconds to respond...'));
310
311
 
311
312
  try {
312
- // Create a promise that auto-resolves after 10 seconds
313
+ // Create a promise that auto-resolves after 30 seconds
313
314
  const timeoutPromise = new Promise((resolve) => {
314
315
  setTimeout(() => {
315
- console.log(chalk.yellow('\n⏱️ No input received, using detected location...'));
316
- resolve('');
317
- }, 10000);
316
+ console.log(chalk.yellow('\n⏱️ Timeout - using detected location...'));
317
+ resolve('__TIMEOUT__');
318
+ }, 30000);
318
319
  });
319
320
 
320
321
  const questionPromise = question('Enter custom location (or press Enter): ');
321
322
 
322
323
  const customLocation = await Promise.race([questionPromise, timeoutPromise]);
323
- location = customLocation.trim() || detectedLocation;
324
324
 
325
- if (customLocation.trim()) {
326
- console.log(chalk.green(`✓ Using custom location: ${location}`));
327
- } else {
325
+ // If timeout occurred, use detected location
326
+ if (customLocation === '__TIMEOUT__') {
327
+ location = detectedLocation;
328
328
  console.log(chalk.green(`✓ Using detected location: ${location}`));
329
+ } else {
330
+ // Use custom location if provided, otherwise use detected
331
+ location = customLocation.trim() || detectedLocation;
332
+ if (customLocation.trim()) {
333
+ console.log(chalk.green(`✓ Using custom location: ${location}`));
334
+ } else {
335
+ console.log(chalk.green(`✓ Using detected location: ${location}`));
336
+ }
329
337
  }
330
338
  } catch (error) {
331
339
  console.log(chalk.yellow(`\n⚠️ Prompt error, using detected location: ${detectedLocation}`));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "decharge-scout",
3
- "version": "1.5.0",
3
+ "version": "1.6.0",
4
4
  "description": "AI-powered energy grid data scout with Solana integration",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -6,8 +6,16 @@
6
6
 
7
7
  import fetch from 'node-fetch';
8
8
  import dotenv from 'dotenv';
9
+ import path from 'path';
10
+ import { fileURLToPath } from 'url';
11
+ import { dirname } from 'path';
9
12
 
10
- dotenv.config();
13
+ // Get the directory of this module
14
+ const __filename = fileURLToPath(import.meta.url);
15
+ const __dirname = dirname(__filename);
16
+
17
+ // Load .env from project root (one level up from src/)
18
+ dotenv.config({ path: path.join(__dirname, '..', '.env') });
11
19
 
12
20
  const EIA_API_KEY = process.env.EIA_API_KEY;
13
21
  const EIA_BASE_URL = 'https://api.eia.gov/v2';