lsh-framework 0.8.1 → 0.8.2

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
File without changes
@@ -0,0 +1,186 @@
1
+ /**
2
+ * Git Utilities
3
+ * Helper functions for git repository detection and information extraction
4
+ */
5
+ import * as fs from 'fs';
6
+ import * as path from 'path';
7
+ import { execSync } from 'child_process';
8
+ import { createLogger } from './logger.js';
9
+ const logger = createLogger('GitUtils');
10
+ /**
11
+ * Check if a directory is inside a git repository
12
+ */
13
+ export function isInGitRepo(dir = process.cwd()) {
14
+ try {
15
+ execSync('git rev-parse --is-inside-work-tree', {
16
+ cwd: dir,
17
+ stdio: 'pipe',
18
+ encoding: 'utf8',
19
+ });
20
+ return true;
21
+ }
22
+ catch {
23
+ return false;
24
+ }
25
+ }
26
+ /**
27
+ * Get git repository root path
28
+ */
29
+ export function getGitRootPath(dir = process.cwd()) {
30
+ try {
31
+ const output = execSync('git rev-parse --show-toplevel', {
32
+ cwd: dir,
33
+ stdio: 'pipe',
34
+ encoding: 'utf8',
35
+ });
36
+ return output.trim();
37
+ }
38
+ catch {
39
+ return undefined;
40
+ }
41
+ }
42
+ /**
43
+ * Get git remote URL
44
+ */
45
+ export function getGitRemoteUrl(dir = process.cwd()) {
46
+ try {
47
+ const output = execSync('git remote get-url origin', {
48
+ cwd: dir,
49
+ stdio: 'pipe',
50
+ encoding: 'utf8',
51
+ });
52
+ return output.trim();
53
+ }
54
+ catch {
55
+ return undefined;
56
+ }
57
+ }
58
+ /**
59
+ * Extract repository name from git remote URL or directory name
60
+ */
61
+ export function extractRepoName(remoteUrl, rootPath) {
62
+ if (remoteUrl) {
63
+ // Extract from URL patterns:
64
+ // git@github.com:user/repo.git -> repo
65
+ // https://github.com/user/repo.git -> repo
66
+ const match = remoteUrl.match(/[/:]([\w-]+?)(\.git)?$/);
67
+ if (match) {
68
+ return match[1];
69
+ }
70
+ }
71
+ if (rootPath) {
72
+ // Use directory name as fallback
73
+ return path.basename(rootPath);
74
+ }
75
+ return undefined;
76
+ }
77
+ /**
78
+ * Get current git branch
79
+ */
80
+ export function getCurrentBranch(dir = process.cwd()) {
81
+ try {
82
+ const output = execSync('git rev-parse --abbrev-ref HEAD', {
83
+ cwd: dir,
84
+ stdio: 'pipe',
85
+ encoding: 'utf8',
86
+ });
87
+ return output.trim();
88
+ }
89
+ catch {
90
+ return undefined;
91
+ }
92
+ }
93
+ /**
94
+ * Get comprehensive git repository information
95
+ */
96
+ export function getGitRepoInfo(dir = process.cwd()) {
97
+ const isGitRepo = isInGitRepo(dir);
98
+ if (!isGitRepo) {
99
+ return { isGitRepo: false };
100
+ }
101
+ const rootPath = getGitRootPath(dir);
102
+ const remoteUrl = getGitRemoteUrl(dir);
103
+ const repoName = extractRepoName(remoteUrl, rootPath);
104
+ const currentBranch = getCurrentBranch(dir);
105
+ return {
106
+ isGitRepo: true,
107
+ rootPath,
108
+ repoName,
109
+ remoteUrl,
110
+ currentBranch,
111
+ };
112
+ }
113
+ /**
114
+ * Check if .env.example exists in the repo
115
+ */
116
+ export function hasEnvExample(dir = process.cwd()) {
117
+ const patterns = ['.env.example', '.env.sample', '.env.template'];
118
+ for (const pattern of patterns) {
119
+ const filePath = path.join(dir, pattern);
120
+ if (fs.existsSync(filePath)) {
121
+ return filePath;
122
+ }
123
+ }
124
+ return undefined;
125
+ }
126
+ /**
127
+ * Check if .gitignore exists and contains .env
128
+ */
129
+ export function isEnvIgnored(dir = process.cwd()) {
130
+ const gitignorePath = path.join(dir, '.gitignore');
131
+ if (!fs.existsSync(gitignorePath)) {
132
+ return false;
133
+ }
134
+ try {
135
+ const content = fs.readFileSync(gitignorePath, 'utf8');
136
+ const lines = content.split('\n');
137
+ for (const line of lines) {
138
+ const trimmed = line.trim();
139
+ // Check for .env or *.env patterns
140
+ if (trimmed === '.env' || trimmed === '*.env' || trimmed.includes('.env')) {
141
+ return true;
142
+ }
143
+ }
144
+ return false;
145
+ }
146
+ catch (error) {
147
+ logger.warn(`Failed to read .gitignore: ${error.message}`);
148
+ return false;
149
+ }
150
+ }
151
+ /**
152
+ * Add .env to .gitignore if not already present
153
+ */
154
+ export function ensureEnvInGitignore(dir = process.cwd()) {
155
+ const gitignorePath = path.join(dir, '.gitignore');
156
+ if (isEnvIgnored(dir)) {
157
+ return; // Already ignored
158
+ }
159
+ try {
160
+ let content = '';
161
+ if (fs.existsSync(gitignorePath)) {
162
+ content = fs.readFileSync(gitignorePath, 'utf8');
163
+ // Ensure newline at end
164
+ if (!content.endsWith('\n')) {
165
+ content += '\n';
166
+ }
167
+ }
168
+ content += '\n# Environment variables (managed by LSH)\n.env\n.env.local\n.env.*.local\n';
169
+ fs.writeFileSync(gitignorePath, content, 'utf8');
170
+ logger.info('āœ… Added .env to .gitignore');
171
+ }
172
+ catch (error) {
173
+ logger.warn(`Failed to update .gitignore: ${error.message}`);
174
+ }
175
+ }
176
+ export default {
177
+ isInGitRepo,
178
+ getGitRootPath,
179
+ getGitRemoteUrl,
180
+ extractRepoName,
181
+ getCurrentBranch,
182
+ getGitRepoInfo,
183
+ hasEnvExample,
184
+ isEnvIgnored,
185
+ ensureEnvInGitignore,
186
+ };
@@ -7,14 +7,20 @@ import * as path from 'path';
7
7
  import * as crypto from 'crypto';
8
8
  import DatabasePersistence from './database-persistence.js';
9
9
  import { createLogger } from './logger.js';
10
+ import { getGitRepoInfo, hasEnvExample, ensureEnvInGitignore } from './git-utils.js';
10
11
  const logger = createLogger('SecretsManager');
11
12
  export class SecretsManager {
12
13
  persistence;
13
14
  encryptionKey;
14
- constructor(userId, encryptionKey) {
15
+ gitInfo;
16
+ constructor(userId, encryptionKey, detectGit = true) {
15
17
  this.persistence = new DatabasePersistence(userId);
16
18
  // Use provided key or generate from machine ID + user
17
19
  this.encryptionKey = encryptionKey || this.getDefaultEncryptionKey();
20
+ // Auto-detect git repo context
21
+ if (detectGit) {
22
+ this.gitInfo = getGitRepoInfo();
23
+ }
18
24
  }
19
25
  /**
20
26
  * Get default encryption key from environment or machine
@@ -328,7 +334,329 @@ export class SecretsManager {
328
334
  return status;
329
335
  }
330
336
  /**
331
- * Sync command - check status and suggest actions
337
+ * Get repo-aware environment namespace
338
+ * Returns environment name with repo context if in a git repo
339
+ */
340
+ getRepoAwareEnvironment(environment) {
341
+ if (this.gitInfo?.repoName) {
342
+ return `${this.gitInfo.repoName}_${environment}`;
343
+ }
344
+ return environment;
345
+ }
346
+ /**
347
+ * Generate encryption key if not set
348
+ */
349
+ async ensureEncryptionKey() {
350
+ if (process.env.LSH_SECRETS_KEY) {
351
+ return true; // Key already set
352
+ }
353
+ logger.warn('āš ļø No encryption key found. Generating a new key...');
354
+ const key = crypto.randomBytes(32).toString('hex');
355
+ // Try to add to .env file
356
+ const envPath = path.join(process.cwd(), '.env');
357
+ try {
358
+ let content = '';
359
+ if (fs.existsSync(envPath)) {
360
+ content = fs.readFileSync(envPath, 'utf8');
361
+ if (!content.endsWith('\n')) {
362
+ content += '\n';
363
+ }
364
+ }
365
+ // Check if LSH_SECRETS_KEY already exists (but empty)
366
+ if (content.includes('LSH_SECRETS_KEY=')) {
367
+ content = content.replace(/LSH_SECRETS_KEY=.*$/m, `LSH_SECRETS_KEY=${key}`);
368
+ }
369
+ else {
370
+ content += `\n# LSH Secrets Encryption Key (do not commit!)\nLSH_SECRETS_KEY=${key}\n`;
371
+ }
372
+ fs.writeFileSync(envPath, content, 'utf8');
373
+ // Set in current process
374
+ process.env.LSH_SECRETS_KEY = key;
375
+ this.encryptionKey = key;
376
+ logger.info('āœ… Generated and saved encryption key to .env');
377
+ logger.info('šŸ’” Load it now: export LSH_SECRETS_KEY=' + key.substring(0, 8) + '...');
378
+ return true;
379
+ }
380
+ catch (error) {
381
+ logger.error(`Failed to save encryption key: ${error.message}`);
382
+ logger.info('Please set it manually:');
383
+ logger.info(`export LSH_SECRETS_KEY=${key}`);
384
+ return false;
385
+ }
386
+ }
387
+ /**
388
+ * Create .env from .env.example if available
389
+ */
390
+ async createEnvFromExample(envFilePath) {
391
+ const examplePath = hasEnvExample(process.cwd());
392
+ if (!examplePath) {
393
+ // Create minimal template
394
+ const template = `# Environment Configuration
395
+ # Generated by LSH Secrets Manager
396
+
397
+ # Application
398
+ NODE_ENV=development
399
+
400
+ # Database
401
+ DATABASE_URL=
402
+
403
+ # API Keys
404
+ API_KEY=
405
+
406
+ # LSH Secrets Encryption Key (auto-generated)
407
+ LSH_SECRETS_KEY=${this.encryptionKey}
408
+
409
+ # Add your environment variables below
410
+ `;
411
+ try {
412
+ fs.writeFileSync(envFilePath, template, 'utf8');
413
+ logger.info(`āœ… Created ${envFilePath} from template`);
414
+ return true;
415
+ }
416
+ catch (error) {
417
+ logger.error(`Failed to create ${envFilePath}: ${error.message}`);
418
+ return false;
419
+ }
420
+ }
421
+ // Copy from example
422
+ try {
423
+ const content = fs.readFileSync(examplePath, 'utf8');
424
+ let newContent = content;
425
+ // Add encryption key if not present
426
+ if (!content.includes('LSH_SECRETS_KEY')) {
427
+ newContent += `\n# LSH Secrets Encryption Key (auto-generated)\nLSH_SECRETS_KEY=${this.encryptionKey}\n`;
428
+ }
429
+ fs.writeFileSync(envFilePath, newContent, 'utf8');
430
+ logger.info(`āœ… Created ${envFilePath} from ${path.basename(examplePath)}`);
431
+ return true;
432
+ }
433
+ catch (error) {
434
+ logger.error(`Failed to create ${envFilePath}: ${error.message}`);
435
+ return false;
436
+ }
437
+ }
438
+ /**
439
+ * Generate shell export commands for loading .env file
440
+ */
441
+ generateExportCommands(envFilePath) {
442
+ if (!fs.existsSync(envFilePath)) {
443
+ return '# No .env file found\n';
444
+ }
445
+ const content = fs.readFileSync(envFilePath, 'utf8');
446
+ const lines = content.split('\n');
447
+ const exports = [];
448
+ for (const line of lines) {
449
+ // Skip comments and empty lines
450
+ if (line.trim().startsWith('#') || !line.trim()) {
451
+ continue;
452
+ }
453
+ // Parse KEY=VALUE
454
+ const match = line.match(/^([^=]+)=(.*)$/);
455
+ if (match) {
456
+ const key = match[1].trim();
457
+ let value = match[2].trim();
458
+ // Remove quotes if present (we'll add them back for the export)
459
+ if ((value.startsWith('"') && value.endsWith('"')) ||
460
+ (value.startsWith("'") && value.endsWith("'"))) {
461
+ value = value.slice(1, -1);
462
+ }
463
+ // Escape special characters for shell
464
+ const escapedValue = value
465
+ .replace(/\\/g, '\\\\')
466
+ .replace(/"/g, '\\"')
467
+ .replace(/\$/g, '\\$')
468
+ .replace(/`/g, '\\`');
469
+ exports.push(`export ${key}="${escapedValue}"`);
470
+ }
471
+ }
472
+ return exports.join('\n') + '\n';
473
+ }
474
+ /**
475
+ * Smart sync command - automatically set up and synchronize secrets
476
+ * This is the new enhanced sync that does everything automatically
477
+ */
478
+ async smartSync(envFilePath = '.env', environment = 'dev', autoExecute = true, loadMode = false) {
479
+ // Use repo-aware environment if in git repo
480
+ const effectiveEnv = this.getRepoAwareEnvironment(environment);
481
+ const displayEnv = this.gitInfo?.repoName ? `${this.gitInfo.repoName}/${environment}` : environment;
482
+ // In load mode, redirect output to stderr so stdout only has export commands
483
+ const out = loadMode ? console.error : console.log;
484
+ out(`\nšŸ” Smart sync for: ${displayEnv}\n`);
485
+ // Show git repo context if detected
486
+ if (this.gitInfo?.isGitRepo) {
487
+ out('šŸ“ Git Repository:');
488
+ out(` Repo: ${this.gitInfo.repoName || 'unknown'}`);
489
+ if (this.gitInfo.currentBranch) {
490
+ out(` Branch: ${this.gitInfo.currentBranch}`);
491
+ }
492
+ out();
493
+ }
494
+ // Step 1: Ensure encryption key exists
495
+ if (!process.env.LSH_SECRETS_KEY) {
496
+ logger.info('šŸ”‘ No encryption key found...');
497
+ await this.ensureEncryptionKey();
498
+ out();
499
+ }
500
+ // Step 2: Ensure .gitignore includes .env
501
+ if (this.gitInfo?.isGitRepo) {
502
+ ensureEnvInGitignore(process.cwd());
503
+ }
504
+ // Step 3: Check current status
505
+ const status = await this.status(envFilePath, effectiveEnv);
506
+ out('šŸ“Š Current Status:');
507
+ out(` Encryption key: ${status.keySet ? 'āœ…' : 'āŒ'}`);
508
+ out(` Local ${envFilePath}: ${status.localExists ? `āœ… (${status.localKeys} keys)` : 'āŒ'}`);
509
+ out(` Cloud storage: ${status.cloudExists ? `āœ… (${status.cloudKeys} keys)` : 'āŒ'}`);
510
+ if (status.cloudExists && status.keyMatches !== undefined) {
511
+ out(` Key matches: ${status.keyMatches ? 'āœ…' : 'āŒ'}`);
512
+ }
513
+ out();
514
+ // Step 4: Determine action and execute if auto mode
515
+ let action = 'in-sync';
516
+ if (status.cloudExists && status.keyMatches === false) {
517
+ action = 'key-mismatch';
518
+ out('āš ļø Encryption key mismatch!');
519
+ out(' The local key does not match the cloud storage.');
520
+ out(' Please use the original key or push new secrets with:');
521
+ out(` lsh lib secrets push -f ${envFilePath} -e ${environment}`);
522
+ out();
523
+ return;
524
+ }
525
+ if (!status.localExists && !status.cloudExists) {
526
+ action = 'create-and-push';
527
+ out('šŸ†• No secrets found locally or in cloud');
528
+ out(' Creating new .env file...');
529
+ if (autoExecute) {
530
+ await this.createEnvFromExample(envFilePath);
531
+ out(' Pushing to cloud...');
532
+ await this.push(envFilePath, effectiveEnv);
533
+ out();
534
+ out('āœ… Setup complete! Edit your .env and run sync again to update.');
535
+ }
536
+ else {
537
+ out('šŸ’” Run: lsh lib secrets create && lsh lib secrets push');
538
+ }
539
+ out();
540
+ // Output export commands in load mode
541
+ if (loadMode && fs.existsSync(envFilePath)) {
542
+ console.log(this.generateExportCommands(envFilePath));
543
+ }
544
+ return;
545
+ }
546
+ if (status.localExists && !status.cloudExists) {
547
+ action = 'push';
548
+ out('ā¬†ļø Local .env exists but not in cloud');
549
+ if (autoExecute) {
550
+ out(' Pushing to cloud...');
551
+ await this.push(envFilePath, effectiveEnv);
552
+ out('āœ… Secrets pushed to cloud!');
553
+ }
554
+ else {
555
+ out(`šŸ’” Run: lsh lib secrets push -f ${envFilePath} -e ${environment}`);
556
+ }
557
+ out();
558
+ // Output export commands in load mode
559
+ if (loadMode && fs.existsSync(envFilePath)) {
560
+ console.log(this.generateExportCommands(envFilePath));
561
+ }
562
+ return;
563
+ }
564
+ if (!status.localExists && status.cloudExists && status.keyMatches) {
565
+ action = 'pull';
566
+ out('ā¬‡ļø Cloud secrets available but no local file');
567
+ if (autoExecute) {
568
+ out(' Pulling from cloud...');
569
+ await this.pull(envFilePath, effectiveEnv, false);
570
+ out('āœ… Secrets pulled from cloud!');
571
+ }
572
+ else {
573
+ out(`šŸ’” Run: lsh lib secrets pull -f ${envFilePath} -e ${environment}`);
574
+ }
575
+ out();
576
+ // Output export commands in load mode
577
+ if (loadMode && fs.existsSync(envFilePath)) {
578
+ console.log(this.generateExportCommands(envFilePath));
579
+ }
580
+ return;
581
+ }
582
+ if (status.localExists && status.cloudExists && status.keyMatches) {
583
+ if (status.localModified && status.cloudModified) {
584
+ const localNewer = status.localModified > status.cloudModified;
585
+ const timeDiff = Math.abs(status.localModified.getTime() - status.cloudModified.getTime());
586
+ const minutesDiff = Math.floor(timeDiff / (1000 * 60));
587
+ // If difference is less than 1 minute, consider in sync
588
+ if (minutesDiff < 1) {
589
+ out('āœ… Local and cloud are in sync!');
590
+ out();
591
+ if (!loadMode) {
592
+ this.showLoadInstructions(envFilePath);
593
+ }
594
+ else if (fs.existsSync(envFilePath)) {
595
+ console.log(this.generateExportCommands(envFilePath));
596
+ }
597
+ return;
598
+ }
599
+ if (localNewer) {
600
+ action = 'push';
601
+ out('ā¬†ļø Local file is newer than cloud');
602
+ out(` Local: ${status.localModified.toLocaleString()}`);
603
+ out(` Cloud: ${status.cloudModified.toLocaleString()}`);
604
+ if (autoExecute) {
605
+ out(' Pushing to cloud...');
606
+ await this.push(envFilePath, effectiveEnv);
607
+ out('āœ… Secrets synced to cloud!');
608
+ }
609
+ else {
610
+ out(`šŸ’” Run: lsh lib secrets push -f ${envFilePath} -e ${environment}`);
611
+ }
612
+ }
613
+ else {
614
+ action = 'pull';
615
+ out('ā¬‡ļø Cloud is newer than local file');
616
+ out(` Local: ${status.localModified.toLocaleString()}`);
617
+ out(` Cloud: ${status.cloudModified.toLocaleString()}`);
618
+ if (autoExecute) {
619
+ out(' Pulling from cloud (backup created)...');
620
+ await this.pull(envFilePath, effectiveEnv, false);
621
+ out('āœ… Secrets synced from cloud!');
622
+ }
623
+ else {
624
+ out(`šŸ’” Run: lsh lib secrets pull -f ${envFilePath} -e ${environment}`);
625
+ }
626
+ }
627
+ out();
628
+ if (!loadMode) {
629
+ this.showLoadInstructions(envFilePath);
630
+ }
631
+ else if (fs.existsSync(envFilePath)) {
632
+ console.log(this.generateExportCommands(envFilePath));
633
+ }
634
+ return;
635
+ }
636
+ }
637
+ // Default: everything is in sync
638
+ out('āœ… Secrets are synchronized!');
639
+ out();
640
+ if (!loadMode) {
641
+ this.showLoadInstructions(envFilePath);
642
+ }
643
+ else if (fs.existsSync(envFilePath)) {
644
+ console.log(this.generateExportCommands(envFilePath));
645
+ }
646
+ }
647
+ /**
648
+ * Show instructions for loading secrets
649
+ */
650
+ showLoadInstructions(envFilePath) {
651
+ console.log('šŸ“ To load secrets in your current shell:');
652
+ console.log(` export $(cat ${envFilePath} | grep -v '^#' | xargs)`);
653
+ console.log();
654
+ console.log(' Or for safer loading (preserves quotes):');
655
+ console.log(` set -a; source ${envFilePath}; set +a`);
656
+ console.log();
657
+ }
658
+ /**
659
+ * Sync command - check status and suggest actions (legacy, kept for compatibility)
332
660
  */
333
661
  async sync(envFilePath = '.env', environment = 'dev') {
334
662
  console.log(`\nšŸ” Checking secrets status for environment: ${environment}\n`);
@@ -0,0 +1,58 @@
1
+ import AsyncLock from 'async-lock';
2
+ import request from 'request';
3
+ import { CONFIG } from './config.js';
4
+ import { FILE } from './file.js';
5
+ const semaphore = new AsyncLock();
6
+ let pkgId;
7
+ export const makePOSTRequest = async (typeName, method, data, onSuccess) => {
8
+ console.log("makePostRequest");
9
+ const url = CONFIG.URL + '/api/8' + '/' + typeName + '/' + method;
10
+ console.log(url);
11
+ // Prevent parallel writes/deletions
12
+ return semaphore.acquire('request', (done) => {
13
+ return request.post(url, {
14
+ method: 'POST',
15
+ body: data,
16
+ json: true,
17
+ headers: {
18
+ Authorization: CONFIG.AUTH_TOKEN,
19
+ },
20
+ }, (err, response, body) => {
21
+ console.log(body);
22
+ onSuccess?.(response);
23
+ done();
24
+ });
25
+ });
26
+ };
27
+ const getMetadataPath = (path) => {
28
+ console.log("getMetadataPath");
29
+ return path.substring(path.indexOf(CONFIG.PATH_TO_PACKAGE_REPO) + CONFIG.PATH_TO_PACKAGE_REPO.length);
30
+ };
31
+ const getPkgId = async () => {
32
+ console.log("getPkgId");
33
+ if (pkgId) {
34
+ return pkgId;
35
+ }
36
+ await makePOSTRequest('Pkg', 'inst', ['Pkg'], (body) => {
37
+ pkgId = body;
38
+ });
39
+ return pkgId;
40
+ };
41
+ const _writeContent = async (path) => {
42
+ console.log("writeContent");
43
+ const pkgId = await getPkgId();
44
+ const metadataPath = getMetadataPath(path);
45
+ const content = FILE.encodeContent(path);
46
+ if (await content === FILE.NO_CHANGE_TO_FILE) {
47
+ return;
48
+ }
49
+ return makePOSTRequest('Pkg', 'writeContent', [pkgId, metadataPath, {
50
+ type: 'ContentValue',
51
+ content,
52
+ }], () => console.log("Success"));
53
+ };
54
+ const _deleteContent = async (path) => {
55
+ const pkgId = await getPkgId();
56
+ const metadataPath = getMetadataPath(path);
57
+ return makePOSTRequest('Pkg', 'deleteContent', [pkgId, metadataPath, true], () => console.log("deleted!"));
58
+ };
@@ -169,19 +169,29 @@ API_KEY=
169
169
  process.exit(1);
170
170
  }
171
171
  });
172
- // Sync command - check status and suggest actions
172
+ // Sync command - automatically set up and synchronize secrets
173
173
  secretsCmd
174
174
  .command('sync')
175
- .description('Check secrets sync status and show recommended actions')
175
+ .description('Automatically set up and synchronize secrets (smart mode)')
176
176
  .option('-f, --file <path>', 'Path to .env file', '.env')
177
177
  .option('-e, --env <name>', 'Environment name', 'dev')
178
+ .option('--dry-run', 'Show what would be done without executing')
179
+ .option('--legacy', 'Use legacy sync mode (suggestions only)')
180
+ .option('--load', 'Output eval-able export commands for loading secrets')
178
181
  .action(async (options) => {
179
182
  try {
180
183
  const manager = new SecretsManager();
181
- await manager.sync(options.file, options.env);
184
+ if (options.legacy) {
185
+ // Use legacy sync (suggestions only)
186
+ await manager.sync(options.file, options.env);
187
+ }
188
+ else {
189
+ // Use new smart sync (auto-execute)
190
+ await manager.smartSync(options.file, options.env, !options.dryRun, options.load);
191
+ }
182
192
  }
183
193
  catch (error) {
184
- console.error('āŒ Failed to check sync status:', error.message);
194
+ console.error('āŒ Failed to sync:', error.message);
185
195
  process.exit(1);
186
196
  }
187
197
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lsh-framework",
3
- "version": "0.8.1",
3
+ "version": "0.8.2",
4
4
  "description": "Encrypted secrets manager with automatic rotation, team sync, and multi-environment support. Built on a powerful shell with daemon scheduling and CI/CD integration.",
5
5
  "main": "dist/app.js",
6
6
  "bin": {