lsh-framework 3.1.8 → 3.1.9

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.
@@ -313,6 +313,72 @@ API_KEY=
313
313
  await manager.cleanup();
314
314
  }
315
315
  });
316
+ // Load command - sync and output export commands for shell evaluation
317
+ program
318
+ .command('load')
319
+ .description('Sync secrets and output export commands (use with eval)')
320
+ .option('-f, --file <path>', 'Path to .env file', '.env')
321
+ .option('-e, --env <name>', 'Environment name', 'dev')
322
+ .option('-g, --global', 'Use global workspace ($HOME)')
323
+ .option('--no-sync', 'Skip sync, just output exports from local file')
324
+ .option('--quiet', 'Suppress hints (for scripting)')
325
+ .action(async (options) => {
326
+ const manager = new SecretsManager({ globalMode: options.global });
327
+ try {
328
+ const filePath = manager.resolveFilePath(options.file);
329
+ const env = options.env === 'dev' ? manager.getDefaultEnvironment() : options.env;
330
+ // Sync first (unless --no-sync)
331
+ if (options.sync !== false) {
332
+ // Use smartSync in load mode (suppresses output, returns exports)
333
+ await manager.smartSync(filePath, env, true, true, false, false);
334
+ }
335
+ else {
336
+ // Just output exports from local file
337
+ const envPath = path.resolve(filePath);
338
+ if (!fs.existsSync(envPath)) {
339
+ console.error(`❌ File not found: ${envPath}`);
340
+ process.exit(1);
341
+ }
342
+ const content = fs.readFileSync(envPath, 'utf8');
343
+ const lines = content.split('\n');
344
+ for (const line of lines) {
345
+ if (line.trim().startsWith('#') || !line.trim())
346
+ continue;
347
+ const match = line.match(/^([^=]+)=(.*)$/);
348
+ if (match) {
349
+ const key = match[1].trim();
350
+ let value = match[2].trim();
351
+ // Remove quotes if present
352
+ if ((value.startsWith('"') && value.endsWith('"')) ||
353
+ (value.startsWith("'") && value.endsWith("'"))) {
354
+ value = value.slice(1, -1);
355
+ }
356
+ // Escape single quotes in value
357
+ const escapedValue = value.replace(/'/g, "'\\''");
358
+ console.log(`export ${key}='${escapedValue}'`);
359
+ }
360
+ }
361
+ }
362
+ // Show hint to stderr (doesn't interfere with eval)
363
+ if (!options.quiet) {
364
+ console.error('');
365
+ console.error('💡 To load these into your shell:');
366
+ console.error(' eval "$(lsh load)"');
367
+ console.error('');
368
+ console.error('💡 Add to ~/.zshrc for auto-load:');
369
+ console.error(' lsh-load() { eval "$(lsh load --quiet "$@")"; echo "✅ Secrets loaded"; }');
370
+ }
371
+ }
372
+ catch (error) {
373
+ const err = error;
374
+ console.error('❌ Failed to load secrets:', err.message);
375
+ await manager.cleanup();
376
+ process.exit(1);
377
+ }
378
+ finally {
379
+ await manager.cleanup();
380
+ }
381
+ });
316
382
  // Status command - get detailed status info
317
383
  program
318
384
  .command('status')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lsh-framework",
3
- "version": "3.1.8",
3
+ "version": "3.1.9",
4
4
  "description": "Simple, cross-platform encrypted secrets manager with automatic sync, IPFS audit logs, and multi-environment support. Just run lsh sync and start managing your secrets.",
5
5
  "main": "dist/app.js",
6
6
  "bin": {