lsh-framework 0.5.6 → 0.5.8

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/cli.js CHANGED
@@ -134,16 +134,13 @@ program
134
134
  (async () => {
135
135
  // REPL interactive shell
136
136
  await init_ishell(program);
137
- // Library commands
138
- await init_lib(program);
139
- // Supabase commands
140
- await init_supabase(program);
141
- // Daemon management commands
142
- await init_daemon(program);
143
- // Cron commands
144
- await init_cron(program);
145
- // Secrets management commands
146
- await init_secrets(program);
137
+ // Library commands (parent for supabase, daemon, cron, secrets)
138
+ const libCommand = await init_lib(program);
139
+ // Nest service commands under lib
140
+ await init_supabase(libCommand);
141
+ await init_daemon(libCommand);
142
+ await init_cron(libCommand);
143
+ await init_secrets(libCommand);
147
144
  // API server commands
148
145
  registerApiCommands(program);
149
146
  // ZSH import commands
@@ -446,21 +443,23 @@ function showDetailedHelp() {
446
443
  console.log('');
447
444
  console.log('Subcommands:');
448
445
  console.log(' repl JavaScript REPL interactive shell');
449
- console.log(' lib Library commands');
450
- console.log(' supabase Supabase database management');
451
446
  console.log(' script <file> Execute shell script');
452
447
  console.log(' config Manage configuration');
453
448
  console.log(' zsh ZSH compatibility commands');
454
449
  console.log(' zsh-import Import ZSH configs (aliases, functions, exports)');
455
450
  console.log(' theme Manage themes (import Oh-My-Zsh themes)');
456
451
  console.log(' self Self-management (update, version)');
457
- console.log(' daemon Daemon management');
458
- console.log(' daemon job Job management');
459
- console.log(' daemon db Database integration');
460
- console.log(' cron Cron job management');
461
452
  console.log(' api API server management');
462
453
  console.log(' help Show detailed help');
463
454
  console.log('');
455
+ console.log('Library Commands (lsh lib <command>):');
456
+ console.log(' lib supabase Supabase database management');
457
+ console.log(' lib daemon Daemon management');
458
+ console.log(' lib daemon job Job management');
459
+ console.log(' lib daemon db Database integration');
460
+ console.log(' lib cron Cron job management');
461
+ console.log(' lib secrets Secrets management');
462
+ console.log('');
464
463
  console.log('Examples:');
465
464
  console.log('');
466
465
  console.log(' Shell Usage:');
@@ -476,12 +475,17 @@ function showDetailedHelp() {
476
475
  console.log(' lsh self version # Show version');
477
476
  console.log(' lsh self update # Update to latest');
478
477
  console.log('');
479
- console.log(' Daemon & Job Management:');
480
- console.log(' lsh daemon start # Start daemon');
481
- console.log(' lsh daemon status # Check daemon status');
482
- console.log(' lsh daemon job list # List all jobs');
483
- console.log(' lsh daemon job create # Create new job');
484
- console.log(' lsh daemon job trigger <id> # Run job immediately');
478
+ console.log(' Library Services:');
479
+ console.log(' lsh lib daemon start # Start daemon');
480
+ console.log(' lsh lib daemon status # Check daemon status');
481
+ console.log(' lsh lib daemon job list # List all jobs');
482
+ console.log(' lsh lib daemon job create # Create new job');
483
+ console.log(' lsh lib daemon job trigger <id> # Run job immediately');
484
+ console.log(' lsh lib cron list # List cron jobs');
485
+ console.log(' lsh lib secrets push # Push secrets to cloud');
486
+ console.log(' lsh lib secrets pull # Pull secrets from cloud');
487
+ console.log(' lsh lib secrets list # List environments');
488
+ console.log(' lsh lib supabase status # Check Supabase connection');
485
489
  console.log('');
486
490
  console.log(' API Server:');
487
491
  console.log(' lsh api start # Start daemon with API');
@@ -45,14 +45,30 @@ export class SecretsManager {
45
45
  * Decrypt a value
46
46
  */
47
47
  decrypt(text) {
48
- const parts = text.split(':');
49
- const iv = Buffer.from(parts[0], 'hex');
50
- const encryptedText = parts[1];
51
- const key = Buffer.from(this.encryptionKey, 'hex');
52
- const decipher = crypto.createDecipheriv('aes-256-cbc', key.slice(0, 32), iv);
53
- let decrypted = decipher.update(encryptedText, 'hex', 'utf8');
54
- decrypted += decipher.final('utf8');
55
- return decrypted;
48
+ try {
49
+ const parts = text.split(':');
50
+ if (parts.length !== 2) {
51
+ throw new Error('Invalid encrypted format');
52
+ }
53
+ const iv = Buffer.from(parts[0], 'hex');
54
+ const encryptedText = parts[1];
55
+ const key = Buffer.from(this.encryptionKey, 'hex');
56
+ const decipher = crypto.createDecipheriv('aes-256-cbc', key.slice(0, 32), iv);
57
+ let decrypted = decipher.update(encryptedText, 'hex', 'utf8');
58
+ decrypted += decipher.final('utf8');
59
+ return decrypted;
60
+ }
61
+ catch (error) {
62
+ if (error.message.includes('bad decrypt') || error.message.includes('wrong final block length')) {
63
+ throw new Error('Decryption failed. This usually means:\n' +
64
+ ' 1. You need to set LSH_SECRETS_KEY environment variable\n' +
65
+ ' 2. The key must match the one used during encryption\n' +
66
+ ' 3. Generate a shared key with: lsh secrets key\n' +
67
+ ' 4. Add it to your .env: LSH_SECRETS_KEY=<key>\n' +
68
+ '\nOriginal error: ' + error.message);
69
+ }
70
+ throw error;
71
+ }
56
72
  }
57
73
  /**
58
74
  * Parse .env file into key-value pairs
@@ -100,6 +116,13 @@ export class SecretsManager {
100
116
  if (!fs.existsSync(envFilePath)) {
101
117
  throw new Error(`File not found: ${envFilePath}`);
102
118
  }
119
+ // Warn if using default key
120
+ if (!process.env.LSH_SECRETS_KEY) {
121
+ logger.warn('⚠️ Warning: No LSH_SECRETS_KEY set. Using machine-specific key.');
122
+ logger.warn(' To share secrets across machines, generate a key with: lsh secrets key');
123
+ logger.warn(' Then add LSH_SECRETS_KEY=<key> to your .env on all machines');
124
+ console.log();
125
+ }
103
126
  logger.info(`Pushing ${envFilePath} to Supabase (${environment})...`);
104
127
  const content = fs.readFileSync(envFilePath, 'utf8');
105
128
  const env = this.parseEnvFile(content);
@@ -66,7 +66,9 @@ async function _makeCommand(commander) {
66
66
  // // });
67
67
  // }
68
68
  export async function init_lib(program) {
69
- const lib = program.command("lib");
69
+ const lib = program
70
+ .command("lib")
71
+ .description("LSH library and service commands");
70
72
  // Load and register dynamic commands
71
73
  const commands = await loadCommands();
72
74
  for (const commandName of Object.keys(commands)) {
@@ -41,12 +41,18 @@ export async function init_secrets(program) {
41
41
  });
42
42
  // List environments
43
43
  secretsCmd
44
- .command('list')
44
+ .command('list [environment]')
45
45
  .alias('ls')
46
- .description('List all stored environments')
47
- .action(async () => {
46
+ .description('List all stored environments or show secrets for specific environment')
47
+ .action(async (environment) => {
48
48
  try {
49
49
  const manager = new SecretsManager();
50
+ // If environment specified, show secrets for that environment
51
+ if (environment) {
52
+ await manager.show(environment);
53
+ return;
54
+ }
55
+ // Otherwise, list all environments
50
56
  const envs = await manager.listEnvironments();
51
57
  if (envs.length === 0) {
52
58
  console.log('No environments found. Push your first .env with: lsh secrets push');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lsh-framework",
3
- "version": "0.5.6",
3
+ "version": "0.5.8",
4
4
  "description": "A powerful, extensible shell with advanced job management, database persistence, and modern CLI features",
5
5
  "main": "dist/app.js",
6
6
  "bin": {