lsh-framework 0.5.13 → 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 +39 -72
- package/dist/commands/self.js +3 -59
- package/dist/lib/secrets-manager.js +11 -34
- package/dist/services/lib/lib.js +1 -3
- package/dist/services/secrets/secrets.js +4 -122
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -64,36 +64,8 @@ program
|
|
|
64
64
|
await startInteractiveShell(options);
|
|
65
65
|
}
|
|
66
66
|
else {
|
|
67
|
-
// No arguments - show
|
|
68
|
-
|
|
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
|
|
166
|
-
|
|
167
|
-
//
|
|
168
|
-
await init_supabase(
|
|
169
|
-
|
|
170
|
-
await
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
//
|
|
174
|
-
|
|
175
|
-
|
|
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('
|
|
509
|
-
console.log(' lsh
|
|
510
|
-
console.log(' lsh
|
|
511
|
-
console.log(' lsh
|
|
512
|
-
console.log(' lsh
|
|
513
|
-
console.log(' lsh
|
|
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('
|
|
516
|
-
console.log(' lsh
|
|
517
|
-
console.log(' lsh
|
|
518
|
-
console.log(' lsh
|
|
519
|
-
console.log(' lsh
|
|
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%)');
|
package/dist/commands/self.js
CHANGED
|
@@ -60,7 +60,7 @@ async function fetchLatestVersion() {
|
|
|
60
60
|
const options = {
|
|
61
61
|
hostname: 'registry.npmjs.org',
|
|
62
62
|
port: 443,
|
|
63
|
-
path: '/lsh
|
|
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
|
|
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
|
|
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
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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);
|
|
@@ -144,7 +121,7 @@ export class SecretsManager {
|
|
|
144
121
|
/**
|
|
145
122
|
* Pull .env from Supabase
|
|
146
123
|
*/
|
|
147
|
-
async pull(envFilePath = '.env', environment = 'dev'
|
|
124
|
+
async pull(envFilePath = '.env', environment = 'dev') {
|
|
148
125
|
logger.info(`Pulling ${environment} secrets from Supabase...`);
|
|
149
126
|
// Get latest secrets
|
|
150
127
|
const jobs = await this.persistence.getActiveJobs();
|
|
@@ -159,8 +136,8 @@ export class SecretsManager {
|
|
|
159
136
|
throw new Error(`No encrypted data found for environment: ${environment}`);
|
|
160
137
|
}
|
|
161
138
|
const decrypted = this.decrypt(latestSecret.output);
|
|
162
|
-
// Backup existing .env if it exists
|
|
163
|
-
if (fs.existsSync(envFilePath)
|
|
139
|
+
// Backup existing .env if it exists
|
|
140
|
+
if (fs.existsSync(envFilePath)) {
|
|
164
141
|
const backup = `${envFilePath}.backup.${Date.now()}`;
|
|
165
142
|
fs.copyFileSync(envFilePath, backup);
|
|
166
143
|
logger.info(`Backed up existing .env to ${backup}`);
|
package/dist/services/lib/lib.js
CHANGED
|
@@ -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')
|
|
@@ -32,11 +29,10 @@ export async function init_secrets(program) {
|
|
|
32
29
|
.description('Pull .env from encrypted cloud storage')
|
|
33
30
|
.option('-f, --file <path>', 'Path to .env file', '.env')
|
|
34
31
|
.option('-e, --env <name>', 'Environment name (dev/staging/prod)', 'dev')
|
|
35
|
-
.option('--force', 'Overwrite without creating backup')
|
|
36
32
|
.action(async (options) => {
|
|
37
33
|
try {
|
|
38
34
|
const manager = new SecretsManager();
|
|
39
|
-
await manager.pull(options.file, options.env
|
|
35
|
+
await manager.pull(options.file, options.env);
|
|
40
36
|
}
|
|
41
37
|
catch (error) {
|
|
42
38
|
console.error('❌ Failed to pull secrets:', error.message);
|
|
@@ -45,18 +41,12 @@ export async function init_secrets(program) {
|
|
|
45
41
|
});
|
|
46
42
|
// List environments
|
|
47
43
|
secretsCmd
|
|
48
|
-
.command('list
|
|
44
|
+
.command('list')
|
|
49
45
|
.alias('ls')
|
|
50
|
-
.description('List all stored environments
|
|
51
|
-
.action(async (
|
|
46
|
+
.description('List all stored environments')
|
|
47
|
+
.action(async () => {
|
|
52
48
|
try {
|
|
53
49
|
const manager = new SecretsManager();
|
|
54
|
-
// If environment specified, show secrets for that environment
|
|
55
|
-
if (environment) {
|
|
56
|
-
await manager.show(environment);
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
// Otherwise, list all environments
|
|
60
50
|
const envs = await manager.listEnvironments();
|
|
61
51
|
if (envs.length === 0) {
|
|
62
52
|
console.log('No environments found. Push your first .env with: lsh secrets push');
|
|
@@ -100,113 +90,5 @@ export async function init_secrets(program) {
|
|
|
100
90
|
console.log('💡 Tip: Share this key securely with your team to sync secrets.');
|
|
101
91
|
console.log(' Never commit it to git!\n');
|
|
102
92
|
});
|
|
103
|
-
// Create .env file
|
|
104
|
-
secretsCmd
|
|
105
|
-
.command('create')
|
|
106
|
-
.description('Create a new .env file')
|
|
107
|
-
.option('-f, --file <path>', 'Path to .env file', '.env')
|
|
108
|
-
.option('-t, --template', 'Create with common template variables')
|
|
109
|
-
.action(async (options) => {
|
|
110
|
-
try {
|
|
111
|
-
const envPath = path.resolve(options.file);
|
|
112
|
-
// Check if file already exists
|
|
113
|
-
if (fs.existsSync(envPath)) {
|
|
114
|
-
console.log(`❌ File already exists: ${envPath}`);
|
|
115
|
-
console.log('💡 Use a different path or delete the existing file first.');
|
|
116
|
-
process.exit(1);
|
|
117
|
-
}
|
|
118
|
-
// Create template content if requested
|
|
119
|
-
let content = '';
|
|
120
|
-
if (options.template) {
|
|
121
|
-
content = `# Environment Configuration
|
|
122
|
-
# Generated by LSH Secrets Manager
|
|
123
|
-
|
|
124
|
-
# Application
|
|
125
|
-
NODE_ENV=development
|
|
126
|
-
PORT=3000
|
|
127
|
-
|
|
128
|
-
# Database
|
|
129
|
-
DATABASE_URL=
|
|
130
|
-
|
|
131
|
-
# API Keys
|
|
132
|
-
API_KEY=
|
|
133
|
-
|
|
134
|
-
# LSH Secrets (for cross-machine sync)
|
|
135
|
-
# LSH_SECRETS_KEY=
|
|
136
|
-
|
|
137
|
-
# Add your environment variables below
|
|
138
|
-
`;
|
|
139
|
-
}
|
|
140
|
-
// Create the file
|
|
141
|
-
fs.writeFileSync(envPath, content, 'utf8');
|
|
142
|
-
console.log(`✅ Created .env file: ${envPath}`);
|
|
143
|
-
if (options.template) {
|
|
144
|
-
console.log('📝 Template variables added - update with your values');
|
|
145
|
-
}
|
|
146
|
-
console.log('');
|
|
147
|
-
console.log('Next steps:');
|
|
148
|
-
console.log(` 1. Edit the file: ${options.file}`);
|
|
149
|
-
console.log(` 2. Push to cloud: lsh lib secrets push -f ${options.file}`);
|
|
150
|
-
console.log('');
|
|
151
|
-
}
|
|
152
|
-
catch (error) {
|
|
153
|
-
console.error('❌ Failed to create .env file:', error.message);
|
|
154
|
-
process.exit(1);
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
|
-
// Delete .env file with confirmation
|
|
158
|
-
secretsCmd
|
|
159
|
-
.command('delete')
|
|
160
|
-
.description('Delete .env file (requires confirmation)')
|
|
161
|
-
.option('-f, --file <path>', 'Path to .env file', '.env')
|
|
162
|
-
.option('-y, --yes', 'Skip confirmation prompt')
|
|
163
|
-
.action(async (options) => {
|
|
164
|
-
try {
|
|
165
|
-
const envPath = path.resolve(options.file);
|
|
166
|
-
// Check if file exists
|
|
167
|
-
if (!fs.existsSync(envPath)) {
|
|
168
|
-
console.log(`❌ File not found: ${envPath}`);
|
|
169
|
-
process.exit(1);
|
|
170
|
-
}
|
|
171
|
-
console.log('⚠️ WARNING: You are about to delete a .env file!');
|
|
172
|
-
console.log('');
|
|
173
|
-
console.log(`File: ${envPath}`);
|
|
174
|
-
console.log('');
|
|
175
|
-
// Skip confirmation if --yes flag is provided
|
|
176
|
-
if (!options.yes) {
|
|
177
|
-
console.log('To confirm deletion, please type the full path of the file:');
|
|
178
|
-
console.log(`Expected: ${envPath}`);
|
|
179
|
-
console.log('');
|
|
180
|
-
const rl = readline.createInterface({
|
|
181
|
-
input: process.stdin,
|
|
182
|
-
output: process.stdout,
|
|
183
|
-
});
|
|
184
|
-
const answer = await new Promise((resolve) => {
|
|
185
|
-
rl.question('Enter path to confirm: ', (ans) => {
|
|
186
|
-
rl.close();
|
|
187
|
-
resolve(ans.trim());
|
|
188
|
-
});
|
|
189
|
-
});
|
|
190
|
-
if (answer !== envPath) {
|
|
191
|
-
console.log('');
|
|
192
|
-
console.log('❌ Confirmation failed - path does not match');
|
|
193
|
-
console.log('Deletion cancelled');
|
|
194
|
-
process.exit(1);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
// Delete the file
|
|
198
|
-
fs.unlinkSync(envPath);
|
|
199
|
-
console.log('');
|
|
200
|
-
console.log(`✅ Deleted: ${envPath}`);
|
|
201
|
-
console.log('');
|
|
202
|
-
console.log('💡 Tip: You can still pull from cloud if you pushed previously:');
|
|
203
|
-
console.log(` lsh lib secrets pull -f ${options.file}`);
|
|
204
|
-
console.log('');
|
|
205
|
-
}
|
|
206
|
-
catch (error) {
|
|
207
|
-
console.error('❌ Failed to delete .env file:', error.message);
|
|
208
|
-
process.exit(1);
|
|
209
|
-
}
|
|
210
|
-
});
|
|
211
93
|
}
|
|
212
94
|
export default init_secrets;
|