decharge-scout 2.5.5 → 2.5.6
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 +20 -7
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -26,8 +26,8 @@ import path from 'path';
|
|
|
26
26
|
import { fileURLToPath } from 'url';
|
|
27
27
|
import { dirname } from 'path';
|
|
28
28
|
|
|
29
|
-
// Load environment variables
|
|
30
|
-
dotenv.config();
|
|
29
|
+
// Load environment variables from current working directory (not package dir)
|
|
30
|
+
dotenv.config({ path: path.join(process.cwd(), '.env') });
|
|
31
31
|
|
|
32
32
|
// Import modules
|
|
33
33
|
import { startWalletServer, openWalletConnection, waitForWalletConnection, getConnectedWallet } from './src/wallet-server.js';
|
|
@@ -71,16 +71,29 @@ function generateAgentName() {
|
|
|
71
71
|
* Auto-configure .env if needed
|
|
72
72
|
*/
|
|
73
73
|
async function ensureEnvironment() {
|
|
74
|
-
|
|
74
|
+
// Use current working directory for .env (so npx works correctly)
|
|
75
|
+
const envPath = path.join(process.cwd(), '.env');
|
|
75
76
|
|
|
76
77
|
// Create .env from example if missing
|
|
77
78
|
if (!existsSync(envPath)) {
|
|
79
|
+
// Look for .env.example in package directory
|
|
78
80
|
const examplePath = path.join(__dirname, '.env.example');
|
|
79
81
|
if (existsSync(examplePath)) {
|
|
80
82
|
console.log(chalk.yellow('⚠️ .env file not found, creating from template...'));
|
|
81
83
|
const example = readFileSync(examplePath, 'utf-8');
|
|
82
84
|
writeFileSync(envPath, example);
|
|
83
|
-
console.log(chalk.green(
|
|
85
|
+
console.log(chalk.green(`✓ .env file created at ${envPath}`));
|
|
86
|
+
} else {
|
|
87
|
+
// Create a basic .env file if no example exists
|
|
88
|
+
const basicEnv = `# EIA API Key (Required - Get from https://www.eia.gov/opendata/register.php)
|
|
89
|
+
EIA_API_KEY=your_eia_api_key_here
|
|
90
|
+
|
|
91
|
+
# Solana Configuration
|
|
92
|
+
SOLANA_NETWORK=devnet
|
|
93
|
+
SOLANA_RPC_URL=https://api.devnet.solana.com
|
|
94
|
+
`;
|
|
95
|
+
writeFileSync(envPath, basicEnv);
|
|
96
|
+
console.log(chalk.green(`✓ .env file created at ${envPath}`));
|
|
84
97
|
}
|
|
85
98
|
}
|
|
86
99
|
|
|
@@ -172,13 +185,13 @@ async function main(options) {
|
|
|
172
185
|
// Ask user to confirm or override (with timeout)
|
|
173
186
|
console.log(chalk.blue('\nYou can use this location or enter a custom one.'));
|
|
174
187
|
console.log(chalk.gray('(Press Enter to use detected location, or type custom location)'));
|
|
175
|
-
console.log(chalk.gray('You have
|
|
188
|
+
console.log(chalk.gray('You have 60 seconds to respond...'));
|
|
176
189
|
|
|
177
190
|
try {
|
|
178
191
|
let timeoutId;
|
|
179
192
|
let hasResolved = false;
|
|
180
193
|
|
|
181
|
-
// Create a promise that auto-resolves after
|
|
194
|
+
// Create a promise that auto-resolves after 60 seconds
|
|
182
195
|
const timeoutPromise = new Promise((resolve) => {
|
|
183
196
|
timeoutId = setTimeout(() => {
|
|
184
197
|
if (!hasResolved) {
|
|
@@ -186,7 +199,7 @@ async function main(options) {
|
|
|
186
199
|
console.log(chalk.yellow('\n⏱️ Timeout - using detected location...'));
|
|
187
200
|
resolve('__TIMEOUT__');
|
|
188
201
|
}
|
|
189
|
-
},
|
|
202
|
+
}, 60000); // 60 seconds for npx readline delay
|
|
190
203
|
});
|
|
191
204
|
|
|
192
205
|
const questionPromise = question('Enter custom location (or press Enter): ').then(answer => {
|