lsh-framework 0.5.12 → 0.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/dist/cli.js CHANGED
@@ -64,36 +64,8 @@ program
64
64
  await startInteractiveShell(options);
65
65
  }
66
66
  else {
67
- // No arguments - show commands without verbose options
68
- console.log('LSH - A modern shell with ZSH features and superior job management');
69
- console.log('');
70
- console.log('Usage: lsh [options] [command]');
71
- console.log('');
72
- console.log('Commands:');
73
- console.log(' repl JavaScript REPL interactive shell');
74
- console.log(' script <file> Execute shell script');
75
- console.log(' config Manage configuration');
76
- console.log(' zsh ZSH compatibility commands');
77
- console.log(' help Show detailed help');
78
- console.log('');
79
- console.log('Self-Management:');
80
- console.log(' self update Update to latest version');
81
- console.log(' self version Show version information');
82
- console.log(' self uninstall Uninstall LSH from system');
83
- console.log(' self theme Manage themes');
84
- console.log(' self zsh-import Import ZSH configs');
85
- console.log('');
86
- console.log('Library Services:');
87
- console.log(' lib api API server management');
88
- console.log(' lib daemon Daemon management');
89
- console.log(' lib cron Cron job management');
90
- console.log(' lib secrets Secrets management');
91
- console.log(' lib supabase Supabase database management');
92
- console.log('');
93
- console.log('Quick Start:');
94
- console.log(' lsh -i Start interactive shell');
95
- console.log(' lsh --help Show all options');
96
- console.log(' lsh help Show detailed help with examples');
67
+ // No arguments - show help
68
+ program.help();
97
69
  }
98
70
  }
99
71
  catch (error) {
@@ -162,17 +134,22 @@ program
162
134
  (async () => {
163
135
  // REPL interactive shell
164
136
  await init_ishell(program);
165
- // Library commands (parent for service commands)
166
- const libCommand = await init_lib(program);
167
- // Nest service commands under lib
168
- await init_supabase(libCommand);
169
- await init_daemon(libCommand);
170
- await init_cron(libCommand);
171
- await init_secrets(libCommand);
172
- registerApiCommands(libCommand);
173
- // Self-management commands with nested utilities
174
- registerZshImportCommands(selfCommand);
175
- registerThemeCommands(selfCommand);
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);
147
+ // API server commands
148
+ registerApiCommands(program);
149
+ // ZSH import commands
150
+ registerZshImportCommands(program);
151
+ // Theme commands
152
+ registerThemeCommands(program);
176
153
  // Parse command line arguments after all commands are registered
177
154
  program.parse(process.argv);
178
155
  })();
@@ -469,27 +446,21 @@ function showDetailedHelp() {
469
446
  console.log('');
470
447
  console.log('Subcommands:');
471
448
  console.log(' repl JavaScript REPL interactive shell');
449
+ console.log(' lib Library commands');
450
+ console.log(' supabase Supabase database management');
472
451
  console.log(' script <file> Execute shell script');
473
452
  console.log(' config Manage configuration');
474
453
  console.log(' zsh ZSH compatibility commands');
454
+ console.log(' zsh-import Import ZSH configs (aliases, functions, exports)');
455
+ console.log(' theme Manage themes (import Oh-My-Zsh themes)');
456
+ 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
+ console.log(' api API server management');
475
462
  console.log(' help Show detailed help');
476
463
  console.log('');
477
- console.log('Self-Management (lsh self <command>):');
478
- console.log(' self update Update to latest version');
479
- console.log(' self version Show version information');
480
- console.log(' self uninstall Uninstall LSH from system');
481
- console.log(' self theme Manage themes (import Oh-My-Zsh themes)');
482
- console.log(' self zsh-import Import ZSH configs (aliases, functions, exports)');
483
- console.log('');
484
- console.log('Library Commands (lsh lib <command>):');
485
- console.log(' lib api API server management');
486
- console.log(' lib supabase Supabase database management');
487
- console.log(' lib daemon Daemon management');
488
- console.log(' lib daemon job Job management');
489
- console.log(' lib daemon db Database integration');
490
- console.log(' lib cron Cron job management');
491
- console.log(' lib secrets Secrets management');
492
- console.log('');
493
464
  console.log('Examples:');
494
465
  console.log('');
495
466
  console.log(' Shell Usage:');
@@ -505,22 +476,18 @@ function showDetailedHelp() {
505
476
  console.log(' lsh self version # Show version');
506
477
  console.log(' lsh self update # Update to latest');
507
478
  console.log('');
508
- console.log(' Self-Management:');
509
- console.log(' lsh self update # Update to latest version');
510
- console.log(' lsh self version # Show version');
511
- console.log(' lsh self theme list # List available themes');
512
- console.log(' lsh self theme import robbyrussell # Import Oh-My-Zsh theme');
513
- console.log(' lsh self zsh-import aliases # Import ZSH aliases');
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');
514
485
  console.log('');
515
- console.log(' Library Services:');
516
- console.log(' lsh lib daemon start # Start daemon');
517
- console.log(' lsh lib daemon status # Check daemon status');
518
- console.log(' lsh lib daemon job list # List all jobs');
519
- console.log(' lsh lib cron list # List cron jobs');
520
- console.log(' lsh lib secrets push # Push secrets to cloud');
521
- console.log(' lsh lib secrets list # List environments');
522
- console.log(' lsh lib api start # Start API server');
523
- console.log(' lsh lib api key # Generate API key');
486
+ console.log(' API Server:');
487
+ console.log(' lsh api start # Start daemon with API');
488
+ console.log(' lsh api key # Generate API key');
489
+ console.log(' lsh api test # Test API connection');
490
+ console.log(' lsh api example -l python # Show Python client code');
524
491
  console.log('');
525
492
  console.log('Features:');
526
493
  console.log(' ✅ POSIX Shell Compliance (85-95%)');
@@ -60,7 +60,7 @@ async function fetchLatestVersion() {
60
60
  const options = {
61
61
  hostname: 'registry.npmjs.org',
62
62
  port: 443,
63
- path: '/lsh-framework',
63
+ path: '/gwicho38-lsh',
64
64
  method: 'GET',
65
65
  headers: {
66
66
  'User-Agent': 'lsh-cli',
@@ -239,7 +239,7 @@ selfCommand
239
239
  // Install update
240
240
  console.log(chalk.cyan(`📦 Installing lsh ${latestVersion}...`));
241
241
  const npmCmd = process.platform === 'win32' ? 'npm.cmd' : 'npm';
242
- const updateProcess = spawn(npmCmd, ['install', '-g', 'lsh-framework@latest'], {
242
+ const updateProcess = spawn(npmCmd, ['install', '-g', 'gwicho38-lsh@latest'], {
243
243
  stdio: 'inherit',
244
244
  });
245
245
  updateProcess.on('close', (code) => {
@@ -249,7 +249,7 @@ selfCommand
249
249
  }
250
250
  else {
251
251
  console.log(chalk.red('✗ Update failed'));
252
- console.log(chalk.yellow('ℹ Try running with sudo: sudo npm install -g lsh-framework@latest'));
252
+ console.log(chalk.yellow('ℹ Try running with sudo: sudo npm install -g gwicho38-lsh@latest'));
253
253
  }
254
254
  });
255
255
  }
@@ -315,60 +315,4 @@ selfCommand
315
315
  console.log();
316
316
  console.log(chalk.dim('For more info, visit: https://github.com/gwicho38/lsh'));
317
317
  });
318
- /**
319
- * Uninstall command - remove LSH from the system
320
- */
321
- selfCommand
322
- .command('uninstall')
323
- .description('Uninstall LSH from your system')
324
- .option('-y, --yes', 'Skip confirmation prompt')
325
- .action(async (options) => {
326
- try {
327
- console.log(chalk.yellow('╔════════════════════════════════════╗'));
328
- console.log(chalk.yellow('║ Uninstall LSH Framework ║'));
329
- console.log(chalk.yellow('╚════════════════════════════════════╝'));
330
- console.log();
331
- // Ask for confirmation unless --yes flag is used
332
- if (!options.yes) {
333
- const readline = await import('readline');
334
- const rl = readline.createInterface({
335
- input: process.stdin,
336
- output: process.stdout,
337
- });
338
- const answer = await new Promise((resolve) => {
339
- rl.question(chalk.yellow('Are you sure you want to uninstall LSH? (y/N) '), (ans) => {
340
- rl.close();
341
- resolve(ans);
342
- });
343
- });
344
- if (answer.toLowerCase() !== 'y' && answer.toLowerCase() !== 'yes') {
345
- console.log(chalk.yellow('Uninstall cancelled'));
346
- return;
347
- }
348
- }
349
- console.log(chalk.cyan('📦 Uninstalling lsh-framework...'));
350
- console.log();
351
- const npmCmd = process.platform === 'win32' ? 'npm.cmd' : 'npm';
352
- const uninstallProcess = spawn(npmCmd, ['uninstall', '-g', 'lsh-framework'], {
353
- stdio: 'inherit',
354
- });
355
- uninstallProcess.on('close', (code) => {
356
- if (code === 0) {
357
- console.log();
358
- console.log(chalk.green('✓ LSH has been uninstalled successfully'));
359
- console.log();
360
- console.log(chalk.dim('Thank you for using LSH!'));
361
- console.log(chalk.dim('You can reinstall anytime with: npm install -g lsh-framework'));
362
- }
363
- else {
364
- console.log();
365
- console.log(chalk.red('✗ Uninstall failed'));
366
- console.log(chalk.yellow('ℹ Try running with sudo: sudo npm uninstall -g lsh-framework'));
367
- }
368
- });
369
- }
370
- catch (error) {
371
- console.error(chalk.red('✗ Error during uninstall:'), error);
372
- }
373
- });
374
318
  export default selfCommand;
@@ -45,30 +45,14 @@ export class SecretsManager {
45
45
  * Decrypt a value
46
46
  */
47
47
  decrypt(text) {
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
- }
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;
72
56
  }
73
57
  /**
74
58
  * Parse .env file into key-value pairs
@@ -116,13 +100,6 @@ export class SecretsManager {
116
100
  if (!fs.existsSync(envFilePath)) {
117
101
  throw new Error(`File not found: ${envFilePath}`);
118
102
  }
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
- }
126
103
  logger.info(`Pushing ${envFilePath} to Supabase (${environment})...`);
127
104
  const content = fs.readFileSync(envFilePath, 'utf8');
128
105
  const env = this.parseEnvFile(content);
@@ -66,9 +66,7 @@ async function _makeCommand(commander) {
66
66
  // // });
67
67
  // }
68
68
  export async function init_lib(program) {
69
- const lib = program
70
- .command("lib")
71
- .description("LSH library and service commands");
69
+ const lib = program.command("lib");
72
70
  // Load and register dynamic commands
73
71
  const commands = await loadCommands();
74
72
  for (const commandName of Object.keys(commands)) {
@@ -3,9 +3,6 @@
3
3
  * Sync .env files across development environments
4
4
  */
5
5
  import SecretsManager from '../../lib/secrets-manager.js';
6
- import * as fs from 'fs';
7
- import * as path from 'path';
8
- import * as readline from 'readline';
9
6
  export async function init_secrets(program) {
10
7
  const secretsCmd = program
11
8
  .command('secrets')
@@ -44,18 +41,12 @@ export async function init_secrets(program) {
44
41
  });
45
42
  // List environments
46
43
  secretsCmd
47
- .command('list [environment]')
44
+ .command('list')
48
45
  .alias('ls')
49
- .description('List all stored environments or show secrets for specific environment')
50
- .action(async (environment) => {
46
+ .description('List all stored environments')
47
+ .action(async () => {
51
48
  try {
52
49
  const manager = new SecretsManager();
53
- // If environment specified, show secrets for that environment
54
- if (environment) {
55
- await manager.show(environment);
56
- return;
57
- }
58
- // Otherwise, list all environments
59
50
  const envs = await manager.listEnvironments();
60
51
  if (envs.length === 0) {
61
52
  console.log('No environments found. Push your first .env with: lsh secrets push');
@@ -99,113 +90,5 @@ export async function init_secrets(program) {
99
90
  console.log('💡 Tip: Share this key securely with your team to sync secrets.');
100
91
  console.log(' Never commit it to git!\n');
101
92
  });
102
- // Create .env file
103
- secretsCmd
104
- .command('create')
105
- .description('Create a new .env file')
106
- .option('-f, --file <path>', 'Path to .env file', '.env')
107
- .option('-t, --template', 'Create with common template variables')
108
- .action(async (options) => {
109
- try {
110
- const envPath = path.resolve(options.file);
111
- // Check if file already exists
112
- if (fs.existsSync(envPath)) {
113
- console.log(`❌ File already exists: ${envPath}`);
114
- console.log('💡 Use a different path or delete the existing file first.');
115
- process.exit(1);
116
- }
117
- // Create template content if requested
118
- let content = '';
119
- if (options.template) {
120
- content = `# Environment Configuration
121
- # Generated by LSH Secrets Manager
122
-
123
- # Application
124
- NODE_ENV=development
125
- PORT=3000
126
-
127
- # Database
128
- DATABASE_URL=
129
-
130
- # API Keys
131
- API_KEY=
132
-
133
- # LSH Secrets (for cross-machine sync)
134
- # LSH_SECRETS_KEY=
135
-
136
- # Add your environment variables below
137
- `;
138
- }
139
- // Create the file
140
- fs.writeFileSync(envPath, content, 'utf8');
141
- console.log(`✅ Created .env file: ${envPath}`);
142
- if (options.template) {
143
- console.log('📝 Template variables added - update with your values');
144
- }
145
- console.log('');
146
- console.log('Next steps:');
147
- console.log(` 1. Edit the file: ${options.file}`);
148
- console.log(` 2. Push to cloud: lsh lib secrets push -f ${options.file}`);
149
- console.log('');
150
- }
151
- catch (error) {
152
- console.error('❌ Failed to create .env file:', error.message);
153
- process.exit(1);
154
- }
155
- });
156
- // Delete .env file with confirmation
157
- secretsCmd
158
- .command('delete')
159
- .description('Delete .env file (requires confirmation)')
160
- .option('-f, --file <path>', 'Path to .env file', '.env')
161
- .option('-y, --yes', 'Skip confirmation prompt')
162
- .action(async (options) => {
163
- try {
164
- const envPath = path.resolve(options.file);
165
- // Check if file exists
166
- if (!fs.existsSync(envPath)) {
167
- console.log(`❌ File not found: ${envPath}`);
168
- process.exit(1);
169
- }
170
- console.log('⚠️ WARNING: You are about to delete a .env file!');
171
- console.log('');
172
- console.log(`File: ${envPath}`);
173
- console.log('');
174
- // Skip confirmation if --yes flag is provided
175
- if (!options.yes) {
176
- console.log('To confirm deletion, please type the full path of the file:');
177
- console.log(`Expected: ${envPath}`);
178
- console.log('');
179
- const rl = readline.createInterface({
180
- input: process.stdin,
181
- output: process.stdout,
182
- });
183
- const answer = await new Promise((resolve) => {
184
- rl.question('Enter path to confirm: ', (ans) => {
185
- rl.close();
186
- resolve(ans.trim());
187
- });
188
- });
189
- if (answer !== envPath) {
190
- console.log('');
191
- console.log('❌ Confirmation failed - path does not match');
192
- console.log('Deletion cancelled');
193
- process.exit(1);
194
- }
195
- }
196
- // Delete the file
197
- fs.unlinkSync(envPath);
198
- console.log('');
199
- console.log(`✅ Deleted: ${envPath}`);
200
- console.log('');
201
- console.log('💡 Tip: You can still pull from cloud if you pushed previously:');
202
- console.log(` lsh lib secrets pull -f ${options.file}`);
203
- console.log('');
204
- }
205
- catch (error) {
206
- console.error('❌ Failed to delete .env file:', error.message);
207
- process.exit(1);
208
- }
209
- });
210
93
  }
211
94
  export default init_secrets;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lsh-framework",
3
- "version": "0.5.12",
3
+ "version": "0.6.0",
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": {