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/.github/workflows/release.yml +92 -92
- package/LICENSE +21 -21
- package/README.md +138 -118
- package/bin/repo-cloak.js +9 -9
- package/package.json +50 -50
- package/src/cli.js +86 -84
- package/src/commands/pull.js +582 -352
- package/src/commands/push.js +250 -235
- package/src/core/anonymizer.js +128 -128
- package/src/core/copier.js +139 -139
- package/src/core/crypto.js +128 -128
- package/src/core/git.js +61 -0
- package/src/core/mapper.js +235 -235
- package/src/core/scanner.js +137 -137
- package/src/index.js +8 -8
- package/src/ui/banner.js +70 -70
- package/src/ui/fileSelector.js +256 -256
- package/src/ui/prompts.js +165 -165
- package/tests/anonymizer.test.js +127 -127
- package/tests/copier.test.js +94 -94
- package/tests/crypto.test.js +106 -106
- package/tests/git.test.js +103 -0
- package/tests/mapper.test.js +166 -166
- package/tests/scanner.test.js +100 -100
- package/medium.md +0 -319
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('-
|
|
35
|
-
.
|
|
36
|
-
|
|
37
|
-
await
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
.
|
|
43
|
-
.
|
|
44
|
-
.option('-
|
|
45
|
-
.option('-
|
|
46
|
-
.
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
{ name: '
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
await
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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
|
+
}
|