@bytehide/react-native-shield
Version:
React Native plugin for ByteHide Shield obfuscation.
61 lines (54 loc) • 1.82 kB
JavaScript
#!/usr/bin/env node
const yargs = require('yargs');
const {obfuscate} = require("./index");
const argv = yargs
.option('src', {
alias: 's',
description: 'Source path where JavaScript files are located',
type: 'string',
default: './dist',
})
.option('projectToken', {
alias: 't',
description: 'ByteHide project token',
type: 'string',
demandOption: true,
})
.option('replace', {
description: 'Whether to replace original files or save obfuscated ones in a new directory',
type: 'boolean',
default: false,
})
.option('exclude', {
description: 'Patterns to exclude from obfuscation (comma-separated)',
type: 'string',
default: '',
})
.option('obfuscatedExtension', {
description: 'The extension for the obfuscated files',
type: 'string',
default: '.obf',
})
.help()
.alias('help', 'h')
.argv;
const excludePatterns = argv.exclude ? argv.exclude.split(',').map(pattern => pattern.trim()) : [];
if (argv.replace) {
console.log('Warning: original files will be replaced with obfuscated ones!');
}
if (excludePatterns.length) {
console.log('Excluding the following patterns from obfuscation:', excludePatterns);
}
if (!argv.projectToken || argv.projectToken === 'your_project_token') {
console.error('Error: project token is required. Please provide it as an argument.');
process.exit(1);
}
obfuscate(
argv.src,
argv.projectToken,
argv.replace,
excludePatterns ?? [],
argv.obfuscatedExtension
)
.then(() => console.log('Obfuscation completed successfully!'))
.catch((err) => console.error('Error during obfuscation:', err));