Updated update.js to be self-contained

This commit is contained in:
Zakary Timson 2022-02-10 17:28:51 +00:00
parent bdfcdefac0
commit 2d7ea8867c
2 changed files with 15 additions and 30 deletions

View File

@ -61,16 +61,18 @@ Options:
### [update.js](./scripts/update.js)
**RAM:** 1.60 GB
Automatically download the latest versions of all scripts using wget.
```
[home ~/]> run scripts/update.js --help
Running script with 1 thread(s), pid 129 and args: ["--help"].
/scripts/update.js:
Automatically update scripts from the repository using wget.
Usage: run update.js
run update.js --help
Options:
-h --help Display help message
[home ~/]> run scripts/update.js
Running script with 1 thread(s), pid 142 and args: [].
/scripts/update.js: Downloading scripts:
/scripts/update.js: lib/arg-parser.js [==================>] 100% (15 MB/s)
/scripts/update.js: auto-pwn.js [==================>] 100% (22.3 MB/s)
/scripts/update.js: bruteforce.js [==================>] 100% (22 MB/s)
/scripts/update.js: crawler.js [==================>] 100% (26.2 MB/s)
/scripts/update.js: miner.js [==================>] 100% (10.8 MB/s)
/scripts/update.js: node-manager.js [==================>] 100% (14.6 MB/s)
/scripts/update.js: update.js [==================>] 100% (11.1 MB/s)
/scripts/update.js: ✅ Done!
```

View File

@ -1,29 +1,12 @@
import {ArgParser} from './scripts/lib/arg-parser';
/**
* Automatically download all the scripts in the repository.
*/
export async function main(ns) {
// Initilize script arguments
const argParser = new ArgParser({
desc: 'Automatically update scripts from the repository using wget.',
examples: [
'run update.js',
'run update.js --help',
],
args: [
{key: 'help', alias: 'h', optional: true, desc: 'Display help message'},
]
});
const args = argParser.parse(ns.args);
// Check arguments
if(args['help']) return ns.tprint(argParser.help());
// Setup
const src = 'https://gitlab.zakscode.com/ztimson/BitBurner/-/raw/develop/scripts/';
const dist = '/scripts/';
const fileList = [
'lib/arg-parser.js',
'auto-pwn.js',
'bruteforce.js',
'crawler.js',
@ -40,5 +23,5 @@ export async function main(ns) {
const speed = ~~((Math.random() * 200) + 100) / 10;
ns.tprint(`${file} ${file.length <= 10 ? '\t' : ''}\t [==================>] 100% \t (${speed} MB/s)`);
}
ns.tprint('Done!');
ns.tprint('Done!');
}