lsh-framework 1.2.0 → 1.3.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/README.md +40 -3
- package/dist/cli.js +104 -486
- package/dist/commands/doctor.js +427 -0
- package/dist/commands/init.js +371 -0
- package/dist/constants/api.js +94 -0
- package/dist/constants/commands.js +64 -0
- package/dist/constants/config.js +56 -0
- package/dist/constants/database.js +21 -0
- package/dist/constants/errors.js +79 -0
- package/dist/constants/index.js +28 -0
- package/dist/constants/paths.js +28 -0
- package/dist/constants/ui.js +73 -0
- package/dist/constants/validation.js +124 -0
- package/dist/daemon/lshd.js +11 -32
- package/dist/lib/daemon-client-helper.js +7 -4
- package/dist/lib/daemon-client.js +9 -2
- package/dist/lib/format-utils.js +163 -0
- package/dist/lib/fuzzy-match.js +123 -0
- package/dist/lib/job-manager.js +2 -1
- package/dist/lib/platform-utils.js +211 -0
- package/dist/lib/secrets-manager.js +11 -1
- package/dist/lib/string-utils.js +128 -0
- package/dist/services/daemon/daemon-registrar.js +3 -2
- package/dist/services/secrets/secrets.js +119 -59
- package/package.json +10 -74
- package/dist/app.js +0 -33
- package/dist/cicd/analytics.js +0 -261
- package/dist/cicd/auth.js +0 -269
- package/dist/cicd/cache-manager.js +0 -172
- package/dist/cicd/data-retention.js +0 -305
- package/dist/cicd/performance-monitor.js +0 -224
- package/dist/cicd/webhook-receiver.js +0 -640
- package/dist/commands/api.js +0 -346
- package/dist/commands/theme.js +0 -261
- package/dist/commands/zsh-import.js +0 -240
- package/dist/components/App.js +0 -1
- package/dist/components/Divider.js +0 -29
- package/dist/components/REPL.js +0 -43
- package/dist/components/Terminal.js +0 -232
- package/dist/components/UserInput.js +0 -30
- package/dist/daemon/api-server.js +0 -316
- package/dist/daemon/monitoring-api.js +0 -220
- package/dist/lib/api-error-handler.js +0 -185
- package/dist/lib/associative-arrays.js +0 -285
- package/dist/lib/base-api-server.js +0 -290
- package/dist/lib/brace-expansion.js +0 -160
- package/dist/lib/builtin-commands.js +0 -439
- package/dist/lib/executors/builtin-executor.js +0 -52
- package/dist/lib/extended-globbing.js +0 -411
- package/dist/lib/extended-parameter-expansion.js +0 -227
- package/dist/lib/interactive-shell.js +0 -460
- package/dist/lib/job-builtins.js +0 -582
- package/dist/lib/pathname-expansion.js +0 -216
- package/dist/lib/script-runner.js +0 -226
- package/dist/lib/shell-executor.js +0 -2504
- package/dist/lib/shell-parser.js +0 -958
- package/dist/lib/shell-types.js +0 -6
- package/dist/lib/shell.lib.js +0 -40
- package/dist/lib/theme-manager.js +0 -476
- package/dist/lib/variable-expansion.js +0 -385
- package/dist/lib/zsh-compatibility.js +0 -659
- package/dist/lib/zsh-import-manager.js +0 -707
- package/dist/lib/zsh-options.js +0 -328
- package/dist/pipeline/job-tracker.js +0 -491
- package/dist/pipeline/mcli-bridge.js +0 -309
- package/dist/pipeline/pipeline-service.js +0 -1119
- package/dist/pipeline/workflow-engine.js +0 -870
- package/dist/services/api/api.js +0 -58
- package/dist/services/api/auth.js +0 -35
- package/dist/services/api/config.js +0 -7
- package/dist/services/api/file.js +0 -22
- package/dist/services/shell/shell.js +0 -28
- package/dist/services/zapier.js +0 -16
- package/dist/simple-api-server.js +0 -148
package/dist/cli.js
CHANGED
|
@@ -1,19 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
3
|
* LSH CLI Entry Point
|
|
4
|
-
*
|
|
4
|
+
* Simple, cross-platform encrypted secrets manager
|
|
5
5
|
*/
|
|
6
6
|
import { Command } from 'commander';
|
|
7
|
-
import InteractiveShell from './lib/interactive-shell.js';
|
|
8
|
-
import ScriptRunner from './lib/script-runner.js';
|
|
9
|
-
import { parseShellCommand } from './lib/shell-parser.js';
|
|
10
7
|
import selfCommand from './commands/self.js';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import { registerThemeCommands } from './commands/theme.js';
|
|
8
|
+
import { registerInitCommands } from './commands/init.js';
|
|
9
|
+
import { registerDoctorCommands } from './commands/doctor.js';
|
|
14
10
|
import { init_daemon } from './services/daemon/daemon.js';
|
|
15
|
-
import { init_ishell } from './services/shell/shell.js';
|
|
16
|
-
import { init_lib } from './services/lib/lib.js';
|
|
17
11
|
import { init_supabase } from './services/supabase/supabase.js';
|
|
18
12
|
import { init_cron } from './services/cron/cron.js';
|
|
19
13
|
import { init_secrets } from './services/secrets/secrets.js';
|
|
@@ -27,140 +21,63 @@ function getVersion() {
|
|
|
27
21
|
try {
|
|
28
22
|
const packageJsonPath = path.join(__dirname, '../package.json');
|
|
29
23
|
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
30
|
-
return packageJson.version || '
|
|
24
|
+
return packageJson.version || '1.2.0';
|
|
31
25
|
}
|
|
32
26
|
catch {
|
|
33
|
-
return '
|
|
27
|
+
return '1.2.0';
|
|
34
28
|
}
|
|
35
29
|
}
|
|
36
30
|
const program = new Command();
|
|
37
31
|
program
|
|
38
32
|
.name('lsh')
|
|
39
|
-
.description('LSH -
|
|
33
|
+
.description('LSH - Simple, cross-platform encrypted secrets manager')
|
|
40
34
|
.version(getVersion())
|
|
41
35
|
.showSuggestionAfterError(true)
|
|
42
36
|
.showHelpAfterError('(add --help for additional information)')
|
|
43
37
|
.allowUnknownOption(false)
|
|
44
38
|
.enablePositionalOptions();
|
|
45
|
-
//
|
|
39
|
+
// Main action - show help by default
|
|
46
40
|
program
|
|
47
|
-
.option('-i, --interactive', 'Start interactive shell')
|
|
48
|
-
.option('-c, --command <command>', 'Execute command string')
|
|
49
|
-
.option('-s, --script <file>', 'Execute script file')
|
|
50
|
-
.option('--rc <file>', 'Use custom rc file')
|
|
51
|
-
.option('--zsh-compat', 'Enable ZSH compatibility mode')
|
|
52
|
-
.option('--source-zshrc', 'Source ~/.zshrc configuration')
|
|
53
|
-
.option('--package-manager <manager>', 'Package manager (npm, yarn, brew, apt, yum)')
|
|
54
41
|
.option('-v, --verbose', 'Verbose output')
|
|
55
42
|
.option('-d, --debug', 'Debug mode')
|
|
56
43
|
.action(async (options) => {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
console.log(' lsh push --env dev # Push your secrets');
|
|
95
|
-
console.log(' lsh pull --env dev # Pull on another machine');
|
|
96
|
-
console.log('');
|
|
97
|
-
console.log('📚 More Commands:');
|
|
98
|
-
console.log(' api API server management');
|
|
99
|
-
console.log(' supabase Supabase database management');
|
|
100
|
-
console.log(' daemon Daemon management');
|
|
101
|
-
console.log(' cron Cron job management');
|
|
102
|
-
console.log(' self Self-management commands');
|
|
103
|
-
console.log(' self zsh ZSH compatibility commands');
|
|
104
|
-
console.log(' -i, --interactive Start interactive shell');
|
|
105
|
-
console.log(' --help Show all options');
|
|
106
|
-
console.log('');
|
|
107
|
-
console.log('📖 Documentation: https://github.com/gwicho38/lsh');
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
catch (error) {
|
|
111
|
-
console.error(`Error: ${error.message}`);
|
|
112
|
-
process.exit(1);
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
// Script execution subcommand
|
|
116
|
-
program
|
|
117
|
-
.command('script <file>')
|
|
118
|
-
.description('Execute a shell script')
|
|
119
|
-
.option('-a, --args <args...>', 'Script arguments')
|
|
120
|
-
.option('-c, --cwd <dir>', 'Working directory')
|
|
121
|
-
.option('-e, --env <key=value>', 'Environment variables')
|
|
122
|
-
.action(async (file, options) => {
|
|
123
|
-
try {
|
|
124
|
-
await executeScript(file, options);
|
|
125
|
-
}
|
|
126
|
-
catch (error) {
|
|
127
|
-
console.error(`Script error: ${error.message}`);
|
|
128
|
-
process.exit(1);
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
// Configuration subcommand
|
|
132
|
-
program
|
|
133
|
-
.command('config')
|
|
134
|
-
.description('Manage LSH configuration')
|
|
135
|
-
.option('--init', 'Initialize configuration')
|
|
136
|
-
.option('--show', 'Show current configuration')
|
|
137
|
-
.option('--validate', 'Validate configuration')
|
|
138
|
-
.action(async (options) => {
|
|
139
|
-
try {
|
|
140
|
-
await handleConfig(options);
|
|
141
|
-
}
|
|
142
|
-
catch (error) {
|
|
143
|
-
console.error(`Config error: ${error.message}`);
|
|
144
|
-
process.exit(1);
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
// Self-management commands
|
|
148
|
-
program.addCommand(selfCommand);
|
|
149
|
-
// ZSH compatibility commands (under self)
|
|
150
|
-
selfCommand
|
|
151
|
-
.command('zsh')
|
|
152
|
-
.description('ZSH compatibility commands')
|
|
153
|
-
.option('--migrate', 'Migrate ZSH configuration to LSH')
|
|
154
|
-
.option('--source', 'Source ZSH configuration')
|
|
155
|
-
.option('--check', 'Check ZSH availability')
|
|
156
|
-
.action(async (options) => {
|
|
157
|
-
try {
|
|
158
|
-
await handleZshCompatibility(options);
|
|
159
|
-
}
|
|
160
|
-
catch (error) {
|
|
161
|
-
console.error(`ZSH compatibility error: ${error.message}`);
|
|
162
|
-
process.exit(1);
|
|
163
|
-
}
|
|
44
|
+
// No arguments - show secrets-focused help
|
|
45
|
+
console.log('LSH - Encrypted Secrets Manager');
|
|
46
|
+
console.log('');
|
|
47
|
+
console.log('🔐 Secrets Management Commands:');
|
|
48
|
+
console.log(' init Interactive setup wizard (first-time setup)');
|
|
49
|
+
console.log(' doctor Check configuration and connectivity');
|
|
50
|
+
console.log(' sync Check sync status & get recommendations');
|
|
51
|
+
console.log(' push Upload .env to encrypted cloud storage');
|
|
52
|
+
console.log(' pull Download .env from cloud storage');
|
|
53
|
+
console.log(' list List secrets in current local .env file');
|
|
54
|
+
console.log(' env [name] List/view cloud environments');
|
|
55
|
+
console.log(' key Generate encryption key');
|
|
56
|
+
console.log(' create Create new .env file');
|
|
57
|
+
console.log(' get <key> Get a specific secret value (--all for all)');
|
|
58
|
+
console.log(' set <key> <value> Set a specific secret value');
|
|
59
|
+
console.log(' delete Delete .env file');
|
|
60
|
+
console.log(' status Get detailed secrets status');
|
|
61
|
+
console.log('');
|
|
62
|
+
console.log('🔄 Automation (Optional - schedule secret rotation):');
|
|
63
|
+
console.log(' cron add Schedule automatic tasks');
|
|
64
|
+
console.log(' cron list List scheduled jobs');
|
|
65
|
+
console.log(' daemon start Start persistent daemon');
|
|
66
|
+
console.log('');
|
|
67
|
+
console.log('🚀 Quick Start:');
|
|
68
|
+
console.log(' lsh init # Interactive setup (first time)');
|
|
69
|
+
console.log(' lsh doctor # Verify configuration');
|
|
70
|
+
console.log(' lsh push --env dev # Push your secrets');
|
|
71
|
+
console.log(' lsh pull --env dev # Pull on another machine');
|
|
72
|
+
console.log('');
|
|
73
|
+
console.log('📚 More Commands:');
|
|
74
|
+
console.log(' supabase Supabase database management');
|
|
75
|
+
console.log(' daemon Daemon management');
|
|
76
|
+
console.log(' cron Cron job management');
|
|
77
|
+
console.log(' self Self-management commands');
|
|
78
|
+
console.log(' --help Show all options');
|
|
79
|
+
console.log('');
|
|
80
|
+
console.log('📖 Documentation: https://github.com/gwicho38/lsh');
|
|
164
81
|
});
|
|
165
82
|
// Help subcommand
|
|
166
83
|
program
|
|
@@ -215,32 +132,23 @@ function findSimilarCommands(input, validCommands) {
|
|
|
215
132
|
}
|
|
216
133
|
// Register async command modules
|
|
217
134
|
(async () => {
|
|
218
|
-
//
|
|
219
|
-
|
|
220
|
-
|
|
135
|
+
// Essential onboarding commands
|
|
136
|
+
registerInitCommands(program);
|
|
137
|
+
registerDoctorCommands(program);
|
|
138
|
+
// Secrets management (primary feature)
|
|
139
|
+
await init_secrets(program);
|
|
140
|
+
// Supporting services
|
|
221
141
|
await init_supabase(program);
|
|
222
142
|
await init_daemon(program);
|
|
223
143
|
await init_cron(program);
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
const libCommand = await init_lib(program);
|
|
227
|
-
await init_supabase(libCommand);
|
|
228
|
-
await init_daemon(libCommand);
|
|
229
|
-
await init_cron(libCommand);
|
|
230
|
-
registerApiCommands(libCommand);
|
|
231
|
-
// Secrets as top-level command
|
|
232
|
-
await init_secrets(program);
|
|
233
|
-
// Self-management commands with nested utilities
|
|
234
|
-
registerZshImportCommands(selfCommand);
|
|
235
|
-
registerThemeCommands(selfCommand);
|
|
144
|
+
// Self-management commands
|
|
145
|
+
program.addCommand(selfCommand);
|
|
236
146
|
// Pre-parse check for unknown commands
|
|
237
147
|
const args = process.argv.slice(2);
|
|
238
148
|
if (args.length > 0) {
|
|
239
149
|
const firstArg = args[0];
|
|
240
150
|
const validCommands = program.commands.map(cmd => cmd.name());
|
|
241
|
-
const validOptions = ['-
|
|
242
|
-
'--rc', '--zsh-compat', '--source-zshrc', '--package-manager',
|
|
243
|
-
'-v', '--verbose', '-d', '--debug', '-h', '--help', '-V', '--version'];
|
|
151
|
+
const validOptions = ['-v', '--verbose', '-d', '--debug', '-h', '--help', '-V', '--version'];
|
|
244
152
|
// Check if first argument looks like a command but isn't valid
|
|
245
153
|
if (!firstArg.startsWith('-') &&
|
|
246
154
|
!validCommands.includes(firstArg) &&
|
|
@@ -293,363 +201,73 @@ function findSimilarCommands(input, validCommands) {
|
|
|
293
201
|
// Parse command line arguments after all commands are registered
|
|
294
202
|
program.parse(process.argv);
|
|
295
203
|
})();
|
|
296
|
-
/**
|
|
297
|
-
* Start interactive shell
|
|
298
|
-
*/
|
|
299
|
-
async function startInteractiveShell(options) {
|
|
300
|
-
const shellOptions = {
|
|
301
|
-
verbose: options.verbose,
|
|
302
|
-
debug: options.debug,
|
|
303
|
-
};
|
|
304
|
-
// Only set rcFile if explicitly provided
|
|
305
|
-
if (options.rc) {
|
|
306
|
-
shellOptions.rcFile = options.rc;
|
|
307
|
-
}
|
|
308
|
-
const shell = new InteractiveShell(shellOptions);
|
|
309
|
-
await shell.start();
|
|
310
|
-
}
|
|
311
|
-
/**
|
|
312
|
-
* Execute single command
|
|
313
|
-
*/
|
|
314
|
-
async function executeCommand(command, options) {
|
|
315
|
-
const { ShellExecutor } = await import('./lib/shell-executor.js');
|
|
316
|
-
const executor = new ShellExecutor();
|
|
317
|
-
// Load configuration if rc file specified
|
|
318
|
-
if (options.rc) {
|
|
319
|
-
await loadRcFile(executor, options.rc);
|
|
320
|
-
}
|
|
321
|
-
try {
|
|
322
|
-
const ast = parseShellCommand(command);
|
|
323
|
-
const result = await executor.execute(ast);
|
|
324
|
-
if (result.stdout) {
|
|
325
|
-
console.log(result.stdout);
|
|
326
|
-
}
|
|
327
|
-
if (result.stderr) {
|
|
328
|
-
console.error(result.stderr);
|
|
329
|
-
}
|
|
330
|
-
process.exit(result.exitCode);
|
|
331
|
-
}
|
|
332
|
-
catch (error) {
|
|
333
|
-
console.error(`Command error: ${error.message}`);
|
|
334
|
-
process.exit(1);
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
/**
|
|
338
|
-
* Execute script file
|
|
339
|
-
*/
|
|
340
|
-
async function executeScript(scriptPath, options) {
|
|
341
|
-
if (!fs.existsSync(scriptPath)) {
|
|
342
|
-
console.error(`Script file not found: ${scriptPath}`);
|
|
343
|
-
process.exit(1);
|
|
344
|
-
}
|
|
345
|
-
const runner = new ScriptRunner({
|
|
346
|
-
cwd: options.cwd,
|
|
347
|
-
env: parseEnvOptions(options.env),
|
|
348
|
-
});
|
|
349
|
-
const result = await runner.executeScript(scriptPath, {
|
|
350
|
-
args: options.args || [],
|
|
351
|
-
});
|
|
352
|
-
if (result.output) {
|
|
353
|
-
console.log(result.output);
|
|
354
|
-
}
|
|
355
|
-
if (result.errors) {
|
|
356
|
-
console.error(result.errors);
|
|
357
|
-
}
|
|
358
|
-
process.exit(result.exitCode);
|
|
359
|
-
}
|
|
360
|
-
/**
|
|
361
|
-
* Handle configuration commands
|
|
362
|
-
*/
|
|
363
|
-
async function handleConfig(options) {
|
|
364
|
-
const rcFile = path.join(process.env.HOME || '/', '.lshrc');
|
|
365
|
-
if (options.init) {
|
|
366
|
-
await initializeConfig(rcFile);
|
|
367
|
-
}
|
|
368
|
-
else if (options.show) {
|
|
369
|
-
await showConfig(rcFile);
|
|
370
|
-
}
|
|
371
|
-
else if (options.validate) {
|
|
372
|
-
await validateConfig(rcFile);
|
|
373
|
-
}
|
|
374
|
-
else {
|
|
375
|
-
console.log('Configuration management:');
|
|
376
|
-
console.log(' --init Initialize default configuration');
|
|
377
|
-
console.log(' --show Show current configuration');
|
|
378
|
-
console.log(' --validate Validate configuration file');
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
/**
|
|
382
|
-
* Initialize configuration file
|
|
383
|
-
*/
|
|
384
|
-
async function initializeConfig(rcFile) {
|
|
385
|
-
if (fs.existsSync(rcFile)) {
|
|
386
|
-
console.log(`Configuration file already exists: ${rcFile}`);
|
|
387
|
-
return;
|
|
388
|
-
}
|
|
389
|
-
const defaultConfig = `# LSH Configuration File
|
|
390
|
-
# This file is executed when LSH starts in interactive mode
|
|
391
|
-
|
|
392
|
-
# Enable ZSH features
|
|
393
|
-
setopt EXTENDED_GLOB
|
|
394
|
-
setopt AUTO_CD
|
|
395
|
-
setopt SHARE_HISTORY
|
|
396
|
-
setopt HIST_IGNORE_DUPS
|
|
397
|
-
|
|
398
|
-
# Set prompt
|
|
399
|
-
export PROMPT='%n@%m:%~$ '
|
|
400
|
-
export RPROMPT='%T'
|
|
401
|
-
|
|
402
|
-
# Set history options
|
|
403
|
-
export HISTSIZE=10000
|
|
404
|
-
export HISTFILE=~/.lsh_history
|
|
405
|
-
|
|
406
|
-
# Aliases
|
|
407
|
-
alias ll='ls -la'
|
|
408
|
-
alias la='ls -A'
|
|
409
|
-
alias l='ls -CF'
|
|
410
|
-
alias ..='cd ..'
|
|
411
|
-
alias ...='cd ../..'
|
|
412
|
-
|
|
413
|
-
# Functions
|
|
414
|
-
greet() {
|
|
415
|
-
echo "Hello from LSH!"
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
# Welcome message
|
|
419
|
-
echo "LSH interactive shell loaded. Type 'help' for commands."
|
|
420
|
-
`;
|
|
421
|
-
try {
|
|
422
|
-
fs.writeFileSync(rcFile, defaultConfig, 'utf8');
|
|
423
|
-
console.log(`✅ Created configuration file: ${rcFile}`);
|
|
424
|
-
}
|
|
425
|
-
catch (error) {
|
|
426
|
-
console.error(`❌ Failed to create configuration: ${error.message}`);
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
/**
|
|
430
|
-
* Show current configuration
|
|
431
|
-
*/
|
|
432
|
-
async function showConfig(rcFile) {
|
|
433
|
-
if (!fs.existsSync(rcFile)) {
|
|
434
|
-
console.log(`❌ Configuration file not found: ${rcFile}`);
|
|
435
|
-
console.log('Run "lsh config --init" to create one.');
|
|
436
|
-
return;
|
|
437
|
-
}
|
|
438
|
-
try {
|
|
439
|
-
const content = fs.readFileSync(rcFile, 'utf8');
|
|
440
|
-
console.log(`📄 Configuration file: ${rcFile}`);
|
|
441
|
-
console.log('='.repeat(50));
|
|
442
|
-
console.log(content);
|
|
443
|
-
}
|
|
444
|
-
catch (error) {
|
|
445
|
-
console.error(`❌ Failed to read configuration: ${error.message}`);
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
/**
|
|
449
|
-
* Validate configuration file
|
|
450
|
-
*/
|
|
451
|
-
async function validateConfig(rcFile) {
|
|
452
|
-
if (!fs.existsSync(rcFile)) {
|
|
453
|
-
console.log(`❌ Configuration file not found: ${rcFile}`);
|
|
454
|
-
return;
|
|
455
|
-
}
|
|
456
|
-
try {
|
|
457
|
-
const content = fs.readFileSync(rcFile, 'utf8');
|
|
458
|
-
const lines = content.split('\n');
|
|
459
|
-
let valid = true;
|
|
460
|
-
const errors = [];
|
|
461
|
-
for (let i = 0; i < lines.length; i++) {
|
|
462
|
-
const line = lines[i].trim();
|
|
463
|
-
if (line.startsWith('#') || line === '') {
|
|
464
|
-
continue;
|
|
465
|
-
}
|
|
466
|
-
try {
|
|
467
|
-
parseShellCommand(line);
|
|
468
|
-
}
|
|
469
|
-
catch (error) {
|
|
470
|
-
valid = false;
|
|
471
|
-
errors.push(`Line ${i + 1}: ${error.message}`);
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
if (valid) {
|
|
475
|
-
console.log(`✅ Configuration file is valid: ${rcFile}`);
|
|
476
|
-
}
|
|
477
|
-
else {
|
|
478
|
-
console.log(`❌ Configuration file has errors: ${rcFile}`);
|
|
479
|
-
errors.forEach(error => console.log(` ${error}`));
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
catch (error) {
|
|
483
|
-
console.error(`❌ Failed to validate configuration: ${error.message}`);
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
/**
|
|
487
|
-
* Load rc file
|
|
488
|
-
*/
|
|
489
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
490
|
-
async function loadRcFile(executor, rcFile) {
|
|
491
|
-
if (!fs.existsSync(rcFile)) {
|
|
492
|
-
console.error(`Configuration file not found: ${rcFile}`);
|
|
493
|
-
return;
|
|
494
|
-
}
|
|
495
|
-
try {
|
|
496
|
-
const content = fs.readFileSync(rcFile, 'utf8');
|
|
497
|
-
const lines = content.split('\n');
|
|
498
|
-
for (const line of lines) {
|
|
499
|
-
const trimmed = line.trim();
|
|
500
|
-
if (trimmed.startsWith('#') || trimmed === '') {
|
|
501
|
-
continue;
|
|
502
|
-
}
|
|
503
|
-
try {
|
|
504
|
-
const ast = parseShellCommand(trimmed);
|
|
505
|
-
await executor.execute(ast);
|
|
506
|
-
}
|
|
507
|
-
catch (error) {
|
|
508
|
-
console.error(`Config error: ${error.message}`);
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
catch (error) {
|
|
513
|
-
console.error(`Failed to load configuration: ${error.message}`);
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
/**
|
|
517
|
-
* Parse environment variable options
|
|
518
|
-
*/
|
|
519
|
-
function parseEnvOptions(envOptions) {
|
|
520
|
-
const env = {};
|
|
521
|
-
if (envOptions) {
|
|
522
|
-
for (const option of envOptions) {
|
|
523
|
-
const [key, value] = option.split('=', 2);
|
|
524
|
-
if (key && value !== undefined) {
|
|
525
|
-
env[key] = value;
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
return env;
|
|
530
|
-
}
|
|
531
|
-
/**
|
|
532
|
-
* Handle ZSH compatibility commands
|
|
533
|
-
*/
|
|
534
|
-
async function handleZshCompatibility(options) {
|
|
535
|
-
const { ShellExecutor } = await import('./lib/shell-executor.js');
|
|
536
|
-
const executor = new ShellExecutor();
|
|
537
|
-
if (options.migrate) {
|
|
538
|
-
const result = await executor.getZshCompatibility().migrateZshConfig();
|
|
539
|
-
console.log(result.message);
|
|
540
|
-
process.exit(result.success ? 0 : 1);
|
|
541
|
-
}
|
|
542
|
-
else if (options.source) {
|
|
543
|
-
const result = await executor.getZshCompatibility().sourceZshConfig();
|
|
544
|
-
console.log(result.message);
|
|
545
|
-
process.exit(result.success ? 0 : 1);
|
|
546
|
-
}
|
|
547
|
-
else if (options.check) {
|
|
548
|
-
const result = await executor.getZshCompatibility().checkZshAvailability();
|
|
549
|
-
if (result.available) {
|
|
550
|
-
console.log(`✅ ZSH is available: version ${result.version}`);
|
|
551
|
-
console.log(` Path: ${result.path}`);
|
|
552
|
-
}
|
|
553
|
-
else {
|
|
554
|
-
console.log('❌ ZSH is not available on this system');
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
else {
|
|
558
|
-
console.log('ZSH Compatibility Commands:');
|
|
559
|
-
console.log(' --migrate Migrate ZSH configuration to LSH');
|
|
560
|
-
console.log(' --source Source ZSH configuration');
|
|
561
|
-
console.log(' --check Check ZSH availability');
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
204
|
/**
|
|
565
205
|
* Show detailed help
|
|
566
206
|
*/
|
|
567
207
|
function showDetailedHelp() {
|
|
568
|
-
console.log('LSH -
|
|
569
|
-
console.log('
|
|
208
|
+
console.log('LSH - Encrypted Secrets Manager');
|
|
209
|
+
console.log('================================');
|
|
570
210
|
console.log('');
|
|
571
211
|
console.log('Usage:');
|
|
572
212
|
console.log(' lsh Show help (default)');
|
|
573
|
-
console.log(' lsh
|
|
574
|
-
console.log(' lsh
|
|
575
|
-
console.log(' lsh
|
|
576
|
-
console.log(' lsh script.sh Execute script file');
|
|
213
|
+
console.log(' lsh init Interactive setup wizard');
|
|
214
|
+
console.log(' lsh push Push secrets to cloud');
|
|
215
|
+
console.log(' lsh pull Pull secrets from cloud');
|
|
577
216
|
console.log('');
|
|
578
|
-
console.log('
|
|
579
|
-
console.log('
|
|
580
|
-
console.log('
|
|
581
|
-
console.log('
|
|
582
|
-
console.log('
|
|
583
|
-
console.log('
|
|
584
|
-
console.log('
|
|
585
|
-
console.log('
|
|
586
|
-
console.log('
|
|
217
|
+
console.log('Main Commands:');
|
|
218
|
+
console.log(' init Interactive setup wizard (first-time)');
|
|
219
|
+
console.log(' doctor Health check & troubleshooting');
|
|
220
|
+
console.log(' sync Check sync status');
|
|
221
|
+
console.log(' push Upload encrypted secrets');
|
|
222
|
+
console.log(' pull Download encrypted secrets');
|
|
223
|
+
console.log(' list List local secrets');
|
|
224
|
+
console.log(' env Manage environments');
|
|
225
|
+
console.log(' key Generate encryption key');
|
|
226
|
+
console.log(' status Detailed status report');
|
|
587
227
|
console.log('');
|
|
588
|
-
console.log('
|
|
589
|
-
console.log('
|
|
590
|
-
console.log('
|
|
591
|
-
console.log('
|
|
592
|
-
console.log('
|
|
593
|
-
console.log('
|
|
228
|
+
console.log('Automation:');
|
|
229
|
+
console.log(' daemon start Start background daemon');
|
|
230
|
+
console.log(' daemon stop Stop background daemon');
|
|
231
|
+
console.log(' daemon status Check daemon status');
|
|
232
|
+
console.log(' cron add Schedule automatic tasks');
|
|
233
|
+
console.log(' cron list List scheduled jobs');
|
|
594
234
|
console.log('');
|
|
595
|
-
console.log('Self-Management
|
|
596
|
-
console.log(' self update
|
|
597
|
-
console.log(' self version
|
|
598
|
-
console.log(' self uninstall
|
|
599
|
-
console.log(' self theme Manage themes (import Oh-My-Zsh themes)');
|
|
600
|
-
console.log(' self zsh ZSH compatibility commands');
|
|
601
|
-
console.log(' self zsh-import Import ZSH configs (aliases, functions, exports)');
|
|
235
|
+
console.log('Self-Management:');
|
|
236
|
+
console.log(' self update Update to latest version');
|
|
237
|
+
console.log(' self version Show version information');
|
|
238
|
+
console.log(' self uninstall Uninstall from system');
|
|
602
239
|
console.log('');
|
|
603
|
-
console.log('
|
|
604
|
-
console.log('
|
|
605
|
-
console.log(' supabase
|
|
606
|
-
console.log('
|
|
607
|
-
console.log(' daemon job Job management');
|
|
608
|
-
console.log(' daemon db Database integration');
|
|
609
|
-
console.log(' cron Cron job management');
|
|
240
|
+
console.log('Database:');
|
|
241
|
+
console.log(' supabase init Initialize Supabase connection');
|
|
242
|
+
console.log(' supabase test Test Supabase connectivity');
|
|
243
|
+
console.log(' supabase reset Reset database schema');
|
|
610
244
|
console.log('');
|
|
611
245
|
console.log('Examples:');
|
|
612
246
|
console.log('');
|
|
613
|
-
console.log('
|
|
614
|
-
console.log(' lsh
|
|
615
|
-
console.log(' lsh
|
|
616
|
-
console.log(' lsh repl # Start JavaScript REPL');
|
|
617
|
-
console.log(' lsh -c "echo hello && pwd" # Execute command');
|
|
618
|
-
console.log(' lsh my-script.sh arg1 arg2 # Execute script');
|
|
247
|
+
console.log(' First-Time Setup:');
|
|
248
|
+
console.log(' lsh init # Interactive wizard');
|
|
249
|
+
console.log(' lsh doctor # Verify setup');
|
|
619
250
|
console.log('');
|
|
620
|
-
console.log('
|
|
621
|
-
console.log(' lsh
|
|
622
|
-
console.log(' lsh
|
|
623
|
-
console.log(' lsh
|
|
624
|
-
console.log(' lsh
|
|
251
|
+
console.log(' Daily Usage:');
|
|
252
|
+
console.log(' lsh push --env dev # Push to dev env');
|
|
253
|
+
console.log(' lsh pull --env production # Pull from prod');
|
|
254
|
+
console.log(' lsh sync # Check status');
|
|
255
|
+
console.log(' lsh get API_KEY # Get specific secret');
|
|
256
|
+
console.log(' lsh set API_KEY newvalue # Update secret');
|
|
625
257
|
console.log('');
|
|
626
|
-
console.log('
|
|
627
|
-
console.log(' lsh
|
|
628
|
-
console.log(' lsh
|
|
629
|
-
console.log('
|
|
630
|
-
console.log('
|
|
631
|
-
console.log(' lsh self zsh-import aliases # Import ZSH aliases');
|
|
632
|
-
console.log('');
|
|
633
|
-
console.log(' Secrets Management:');
|
|
634
|
-
console.log(' lsh secrets sync # Check sync status');
|
|
635
|
-
console.log(' lsh secrets push # Push secrets to cloud');
|
|
636
|
-
console.log(' lsh secrets pull # Pull secrets from cloud');
|
|
637
|
-
console.log(' lsh secrets list # List environments');
|
|
638
|
-
console.log('');
|
|
639
|
-
console.log(' Service Operations:');
|
|
640
|
-
console.log(' lsh daemon start # Start daemon');
|
|
641
|
-
console.log(' lsh daemon status # Check daemon status');
|
|
642
|
-
console.log(' lsh daemon job list # List all jobs');
|
|
643
|
-
console.log(' lsh cron list # List cron jobs');
|
|
644
|
-
console.log(' lsh api start # Start API server');
|
|
645
|
-
console.log(' lsh api key # Generate API key');
|
|
258
|
+
console.log(' Automation:');
|
|
259
|
+
console.log(' lsh daemon start # Start daemon');
|
|
260
|
+
console.log(' lsh cron add --name rotate-keys \\');
|
|
261
|
+
console.log(' --schedule "0 0 * * *" \\');
|
|
262
|
+
console.log(' --command "./rotate.sh" # Daily rotation');
|
|
646
263
|
console.log('');
|
|
647
264
|
console.log('Features:');
|
|
648
|
-
console.log(' ✅
|
|
649
|
-
console.log(' ✅
|
|
650
|
-
console.log(' ✅
|
|
651
|
-
console.log(' ✅
|
|
652
|
-
console.log(' ✅
|
|
653
|
-
console.log(' ✅
|
|
654
|
-
console.log('
|
|
265
|
+
console.log(' ✅ Cross-platform (Windows, macOS, Linux)');
|
|
266
|
+
console.log(' ✅ AES-256 encryption');
|
|
267
|
+
console.log(' ✅ Multi-environment support');
|
|
268
|
+
console.log(' ✅ Team collaboration');
|
|
269
|
+
console.log(' ✅ Automatic secret rotation');
|
|
270
|
+
console.log(' ✅ Git-aware namespacing');
|
|
271
|
+
console.log('');
|
|
272
|
+
console.log('Need help? Visit https://github.com/gwicho38/lsh');
|
|
655
273
|
}
|