repo-cloak-cli 1.2.4 → 1.3.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/src/cli.js CHANGED
@@ -1,84 +1,86 @@
1
- /**
2
- * CLI Command Router
3
- * Handles command-line arguments and routes to appropriate handlers
4
- */
5
-
6
- import { Command } from 'commander';
7
- import { showBanner } from './ui/banner.js';
8
- import { pull } from './commands/pull.js';
9
- import { push } from './commands/push.js';
10
- import { readFileSync } from 'fs';
11
- import { fileURLToPath } from 'url';
12
- import { dirname, join } from 'path';
13
-
14
- const __filename = fileURLToPath(import.meta.url);
15
- const __dirname = dirname(__filename);
16
-
17
- // Read version from package.json
18
- const packageJson = JSON.parse(
19
- readFileSync(join(__dirname, '..', 'package.json'), 'utf-8')
20
- );
21
-
22
- const program = new Command();
23
-
24
- program
25
- .name('repo-cloak')
26
- .description('🎭 Selectively extract and anonymize files from repositories')
27
- .version(packageJson.version);
28
-
29
- program
30
- .command('pull')
31
- .description('Extract files and anonymize sensitive information')
32
- .option('-s, --source <path>', 'Source directory (default: current directory)')
33
- .option('-d, --dest <path>', 'Destination directory')
34
- .option('-q, --quiet', 'Minimal output')
35
- .action(async (options) => {
36
- await showBanner();
37
- await pull(options);
38
- });
39
-
40
- program
41
- .command('push')
42
- .description('Restore files with original names from a cloaked backup')
43
- .option('-s, --source <path>', 'Source cloaked directory')
44
- .option('-d, --dest <path>', 'Destination directory (original location)')
45
- .option('-q, --quiet', 'Minimal output')
46
- .action(async (options) => {
47
- await showBanner();
48
- await push(options);
49
- });
50
-
51
- // Default command (no subcommand) - show interactive menu
52
- program
53
- .action(async () => {
54
- await showBanner();
55
- const { default: inquirer } = await import('inquirer');
56
-
57
- const { action } = await inquirer.prompt([
58
- {
59
- type: 'list',
60
- name: 'action',
61
- message: 'What would you like to do?',
62
- choices: [
63
- { name: '📤 Pull - Extract & anonymize files', value: 'pull' },
64
- { name: '📥 Push - Restore files with original names', value: 'push' },
65
- { name: ' Exit', value: 'exit' }
66
- ]
67
- }
68
- ]);
69
-
70
- if (action === 'pull') {
71
- await pull({});
72
- } else if (action === 'push') {
73
- await push({});
74
- }
75
- });
76
-
77
- export async function run() {
78
- try {
79
- await program.parseAsync(process.argv);
80
- } catch (error) {
81
- console.error('Error:', error.message);
82
- process.exit(1);
83
- }
84
- }
1
+ /**
2
+ * CLI Command Router
3
+ * Handles command-line arguments and routes to appropriate handlers
4
+ */
5
+
6
+ import { Command } from 'commander';
7
+ import { showBanner } from './ui/banner.js';
8
+ import { pull } from './commands/pull.js';
9
+ import { push } from './commands/push.js';
10
+ import { readFileSync } from 'fs';
11
+ import { fileURLToPath } from 'url';
12
+ import { dirname, join } from 'path';
13
+
14
+ const __filename = fileURLToPath(import.meta.url);
15
+ const __dirname = dirname(__filename);
16
+
17
+ // Read version from package.json
18
+ const packageJson = JSON.parse(
19
+ readFileSync(join(__dirname, '..', 'package.json'), 'utf-8')
20
+ );
21
+
22
+ const program = new Command();
23
+
24
+ program
25
+ .name('repo-cloak')
26
+ .description('🎭 Selectively extract and anonymize files from repositories')
27
+ .version(packageJson.version);
28
+
29
+ program
30
+ .command('pull')
31
+ .description('Extract files and anonymize sensitive information')
32
+ .option('-s, --source <path>', 'Source directory (default: current directory)')
33
+ .option('-d, --dest <path>', 'Destination directory')
34
+ .option('-f, --force', 'Force pull all files (skip prompts, requires existing mapping)')
35
+ .option('-q, --quiet', 'Minimal output')
36
+ .action(async (options) => {
37
+ await showBanner();
38
+ await pull(options);
39
+ });
40
+
41
+ program
42
+ .command('push')
43
+ .description('Restore files with original names from a cloaked backup')
44
+ .option('-s, --source <path>', 'Source cloaked directory')
45
+ .option('-d, --dest <path>', 'Destination directory (original location)')
46
+ .option('-f, --force', 'Force push/restore all files (skip confirmation)')
47
+ .option('-q, --quiet', 'Minimal output')
48
+ .action(async (options) => {
49
+ await showBanner();
50
+ await push(options);
51
+ });
52
+
53
+ // Default command (no subcommand) - show interactive menu
54
+ program
55
+ .action(async () => {
56
+ await showBanner();
57
+ const { default: inquirer } = await import('inquirer');
58
+
59
+ const { action } = await inquirer.prompt([
60
+ {
61
+ type: 'list',
62
+ name: 'action',
63
+ message: 'What would you like to do?',
64
+ choices: [
65
+ { name: '📤 Pull - Extract & anonymize files', value: 'pull' },
66
+ { name: '📥 Push - Restore files with original names', value: 'push' },
67
+ { name: '❌ Exit', value: 'exit' }
68
+ ]
69
+ }
70
+ ]);
71
+
72
+ if (action === 'pull') {
73
+ await pull({});
74
+ } else if (action === 'push') {
75
+ await push({});
76
+ }
77
+ });
78
+
79
+ export async function run() {
80
+ try {
81
+ await program.parseAsync(process.argv);
82
+ } catch (error) {
83
+ console.error('Error:', error.message);
84
+ process.exit(1);
85
+ }
86
+ }