mirror of
https://github.com/sydev/decrypt-dlc-cli
synced 2026-01-03 08:18:02 +00:00
release / 1.0.0
This commit is contained in:
9
.eslintrc
Normal file
9
.eslintrc
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:node/recommended"
|
||||
],
|
||||
"parserOptions": {
|
||||
"sourceType": "module"
|
||||
}
|
||||
}
|
||||
0
.gitignore
vendored
Normal file → Executable file
0
.gitignore
vendored
Normal file → Executable file
2
README.md
Normal file → Executable file
2
README.md
Normal file → Executable file
@@ -43,6 +43,8 @@ $ npm test
|
||||
|
||||
## Release Notes
|
||||
|
||||
- ```1.0.0```
|
||||
- Release
|
||||
- ```0.1.0```
|
||||
- Add the new API-Usage from [decrypt-dlc](https://github.com/sydev/decrypt-dlc)
|
||||
- Add more endpoints
|
||||
|
||||
@@ -1,70 +1,43 @@
|
||||
#! /usr/bin/env node
|
||||
#!/usr/bin/env node
|
||||
|
||||
const decrypt = require('decrypt-dlc');
|
||||
const fs = require('fs');
|
||||
const isFile = require('is-file');
|
||||
const isUrl = require('is-url');
|
||||
const path = require('path');
|
||||
const fs = require('fs-extra');
|
||||
const isFile = require('is-file');
|
||||
const isUrl = require('is-url');
|
||||
const path = require('path');
|
||||
const program = require('commander');
|
||||
const signale = require('signale');
|
||||
|
||||
|
||||
program
|
||||
.version('1.0.0')
|
||||
.usage('[options] <file>')
|
||||
.usage('[options] <file|url>')
|
||||
.option('-o, --output <file>', 'File to store decrypted urls in. (Default: urls.txt)', path.join(process.cwd(), 'urls.txt'))
|
||||
.parse(process.argv);
|
||||
|
||||
let urls = null;
|
||||
.parse(process.argv);
|
||||
|
||||
/**
|
||||
* Store the string containing the urls in a file.
|
||||
* @param {String} urls String of urls
|
||||
* Check if a filepath has an allowed extension. Allowed are `.dlc`, `.ccf` and `.rsdf`.
|
||||
* @param {String} filepath The filepath to check
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
function storeUrlsInFile(urls) {
|
||||
fs.writeFile(program.output, urls, (err) => {
|
||||
if (err) throw err;
|
||||
console.log(`Successfully stored urls in ${program.output}`);
|
||||
});
|
||||
}
|
||||
const hasAllowedExtension = (filepath = '') => ['.dlc', '.ccf', '.rsdf'].indexOf(path.extname(filepath)) > -1;
|
||||
|
||||
/**
|
||||
* Check if file has a .dlc extension
|
||||
* @param {String} file path to a file
|
||||
* @return {Boolean} Checks wether if the file is a .dlc file or not
|
||||
*/
|
||||
function isDLCFile(file) {
|
||||
let ext = path.extname(file);
|
||||
return (ext === '.dlc');
|
||||
}
|
||||
const run = async () => {
|
||||
const filepath = path.isAbsolute(program.output) ? program.output : path.resolve(process.cwd(), program.output);
|
||||
const input = program.args[0];
|
||||
|
||||
let links = [];
|
||||
|
||||
try {
|
||||
if (isFile(input) && hasAllowedExtension(input)) links = await decrypt.upload(input);
|
||||
else if (isUrl(input)) links = await decrypt.container(input);
|
||||
else throw new Error('Positional argument must be a filepath or an url.');
|
||||
|
||||
await fs.outputFile(filepath, links.join('\n'));
|
||||
signale.success(`Urls stored at ${filepath}`);
|
||||
} catch (err) {
|
||||
signale.fatal(err);
|
||||
}
|
||||
};
|
||||
|
||||
if (isFile(program.args[0]) && isDLCFile(program.args[0])) {
|
||||
decrypt.upload(program.args[0], (err, response) => {
|
||||
if (err) throw err;
|
||||
|
||||
urls = response.success.links.join('\n');
|
||||
storeUrlsInFile(urls);
|
||||
});
|
||||
} else if (isFile(program.args[0]) && !isDLCFile(program.args[0])) {
|
||||
fs.readFile(program.args[0], 'utf-8', (err, content) => {
|
||||
if (err) throw err;
|
||||
|
||||
decrypt.paste(content, (err, response) => {
|
||||
if (err) throw err;
|
||||
|
||||
urls = response.success.links.join('\n');
|
||||
storeUrlsInFile(urls);
|
||||
});
|
||||
});
|
||||
} else if (isUrl(program.args[0])) {
|
||||
decrypt.container(program.args[0], (err, response) => {
|
||||
if (err) throw err;
|
||||
|
||||
urls = response.success.links.join('\n');
|
||||
storeUrlsInFile(urls);
|
||||
});
|
||||
} else {
|
||||
console.error('Parameter must be url or path to a file.');
|
||||
}
|
||||
run();
|
||||
|
||||
27
package.json
Normal file → Executable file
27
package.json
Normal file → Executable file
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "decrypt-dlc-cli",
|
||||
"version": "0.1.0",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "lib/index.js",
|
||||
"bin": {
|
||||
@@ -23,22 +23,23 @@
|
||||
"line"
|
||||
],
|
||||
"author": "Dominik Winter <dominik.winter92@gmail.com>",
|
||||
"license": "MIT",
|
||||
"eslintConfig": {
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 7,
|
||||
"sourceType": "module"
|
||||
}
|
||||
},
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"commander": "^2.9.0",
|
||||
"decrypt-dlc": "^1.0.0",
|
||||
"commander": "^2.20.0",
|
||||
"decrypt-dlc": "^2.0.0",
|
||||
"fs-extra": "^8.0.1",
|
||||
"is-file": "^1.0.0",
|
||||
"is-url": "^1.2.2"
|
||||
"is-url": "^1.2.4",
|
||||
"signale": "^1.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "^0.17.0",
|
||||
"execa": "^0.5.0"
|
||||
"ava": "^2.0.0",
|
||||
"eslint": "^5.16.0",
|
||||
"eslint-plugin-node": "^9.1.0",
|
||||
"execa": "^1.0.0"
|
||||
},
|
||||
"ava": {
|
||||
"files": [
|
||||
|
||||
0
test/test.dlc
Normal file → Executable file
0
test/test.dlc
Normal file → Executable file
47
test/test.js
Normal file → Executable file
47
test/test.js
Normal file → Executable file
@@ -1,63 +1,46 @@
|
||||
import test from 'ava';
|
||||
import execa from 'execa';
|
||||
|
||||
const BIN_FILE = 'bin/decrypt-dlc';
|
||||
const TEST_FILE = 'test/test.dlc';
|
||||
const TEST_FILE_NON_DLC = 'test/test.txt';
|
||||
const TEST_CONTAINER = 'https://raw.githubusercontent.com/sydev/decrypt-dlc/master/test/test.dlc';
|
||||
const TEST_FILE_CORRUPTED = 'test/test_corrupted.dlc';
|
||||
const TEST_FILE_CORRUPTED_NON_DLC = 'test/test_corrupted.txt';
|
||||
const TEST_CONTAINER_CORRUPTED = 'https://raw.githubusercontent.com/sydev/decrypt-dlc/master/test/test_corrupted.dlc'
|
||||
const TEST_OUTPUT = 'test/urls.txt';
|
||||
const BIN_FILE = 'bin/decrypt-dlc';
|
||||
const TEST_FILE = 'test/test.dlc';
|
||||
const TEST_CONTAINER = 'https://raw.githubusercontent.com/sydev/decrypt-dlc/master/test/test.dlc';
|
||||
const TEST_FILE_CORRUPTED = 'test/test_corrupted.dlc';
|
||||
const TEST_CONTAINER_CORRUPTED = 'https://raw.githubusercontent.com/sydev/decrypt-dlc/master/test/test_corrupted.dlc'
|
||||
const TEST_OUTPUT = 'test/urls.txt';
|
||||
|
||||
|
||||
// decrypt local file
|
||||
test('decrypt local file', async t => {
|
||||
const dlc = await execa(BIN_FILE, [TEST_FILE]);
|
||||
t.regex(dlc.stdout, /Successfully/);
|
||||
const dlc = await execa(BIN_FILE, [TEST_FILE]);
|
||||
t.regex(dlc.stdout, /Urls stored at /);
|
||||
});
|
||||
|
||||
test('decrypt local file with ouput parameter', async t => {
|
||||
const dlc = await execa(BIN_FILE, [TEST_FILE, '-o', TEST_OUTPUT]);
|
||||
t.regex(dlc.stdout, /Successfully/);
|
||||
t.regex(dlc.stdout, /Urls stored at /);
|
||||
});
|
||||
|
||||
|
||||
// decrypt remote container
|
||||
test('decrypt remote container', async t => {
|
||||
const dlc = await execa(BIN_FILE, [TEST_CONTAINER]);
|
||||
t.regex(dlc.stdout, /Successfully/);
|
||||
t.regex(dlc.stdout, /Urls stored at /);
|
||||
});
|
||||
|
||||
test('decrypt remote container with output parameter', async t => {
|
||||
const dlc = await execa(BIN_FILE, [TEST_CONTAINER, '-o', TEST_OUTPUT]);
|
||||
t.regex(dlc.stdout, /Successfully/);
|
||||
});
|
||||
|
||||
|
||||
// decrypt from non-DLC file
|
||||
test('decrypt non DLC-file', async t => {
|
||||
const dlc = await execa(BIN_FILE, [TEST_FILE_NON_DLC]);
|
||||
t.regex(dlc.stdout, /Successfully/);
|
||||
});
|
||||
|
||||
test('decrypt non DLC-file with output parameter', async t => {
|
||||
const dlc = await execa(BIN_FILE, [TEST_FILE_NON_DLC, '-o', TEST_OUTPUT]);
|
||||
t.regex(dlc.stdout, /Successfully/);
|
||||
t.regex(dlc.stdout, /Urls stored at /);
|
||||
});
|
||||
|
||||
|
||||
// decrypt corrupted local file
|
||||
test('decrypt corrupted local file', async t => {
|
||||
t.throws(execa(BIN_FILE, [TEST_FILE_CORRUPTED]));
|
||||
const { stdout } = await execa(BIN_FILE, [TEST_FILE_CORRUPTED]);
|
||||
t.regex(stdout, /fatal/);
|
||||
});
|
||||
|
||||
// decrypt corrupted remote container
|
||||
test('decrypt corrupted remote file', async t => {
|
||||
t.throws(execa(BIN_FILE, [TEST_CONTAINER_CORRUPTED]));
|
||||
});
|
||||
|
||||
// decrypt corrupted non-DLC file
|
||||
test('decrypt corrupted non-DLC file', async t => {
|
||||
t.throws(execa(BIN_FILE, [TEST_FILE_CORRUPTED_NON_DLC]));
|
||||
const { stdout } = await execa(BIN_FILE, [TEST_CONTAINER_CORRUPTED]);
|
||||
t.regex(stdout, /fatal/);
|
||||
});
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
4CFKzMshEldO7RKGnI4J4PGIi/DSnwZfnsdaSlA+cH4TRqBBHdPo0gHPhlSvzQR++iUk7Dtjk8Tw10RfTuBUSvHQO4Cf1BLnRHKZWdSylJQPiZQFlKQjgpZvMJCpbwMNEoi5KElLvTwv8M9cig7lbdKg3PSvRLcDvEXmEguysuA/mvH1vaqdJcHtNbgoa8nOScBTMy/zYNrjmBSPrlnxOL+x1QEGQVzT81ao1+YMOd4oBBT5pKoKAnYCZ4gPgf/5C5Hn8Z13cYerLmqbb5zQmzyYdk0Zq7IXb76ISKJG53TZ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Up2ePW3w2nlf4us4=WkZZNm9JL2hDUm1CQmFGRmZoeTN3VXFlUllCdlNSNUE4SzhqL0ZvcFI0RWYxUjhObU9XNXZza2lDRlhyOUpiTQ==
|
||||
0
test/test_corrupted.dlc
Normal file → Executable file
0
test/test_corrupted.dlc
Normal file → Executable file
0
test/test_corrupted.txt
Normal file → Executable file
0
test/test_corrupted.txt
Normal file → Executable file
Reference in New Issue
Block a user