🚚 Move command-line tools to ssn-tools repo

This commit is contained in:
C-3PO 2018-10-19 01:07:12 +02:00
parent 16d8f49ed8
commit 684a123a76
Signed by: c3po
GPG key ID: 62993C4BB4D86F24
6 changed files with 25 additions and 162 deletions

View file

@ -1,41 +1,34 @@
This tool is used for fetching releases from SWTORs patch server CDN and installing them. This library provides various methods for fetching releases from SWTORs patch server CDN and installing them. You can use it to write your own patch program. If you just want to install patches without having to do any programming, use the command-line tools from the [ssn-tools](/swtor/ssn-tools) repository.
# Installation # Installation
For this tool to work, `tsc` and `tslint` must be globally available, e.g. by running: For this tool to work, `tsc` and `tslint` must be globally available, e.g. by running:
```bash ```bash
sudo npm install -g typescript tslint sudo npm install -g typescript tslint
``` ```
Install dependencies and transpile the TypeScript files to JavaScript by running: In the project where you want to use this library, add the following to your `package.json` file:
```bash ```json
npm install && npm start {
"dependencies": {
"ssn": "git+https://git.jedipedia.net/swtor/ssn.git"
}
}
``` ```
For a better command line experience, add the following to your `~/.bashrc` file: Then run:
```bash ```bash
alias swtor_install='node /path/to/installation/patcher/dist/installPatch.js' npm install
complete -W 'assets_swtor_de_de assets_swtor_en_us assets_swtor_fr_fr assets_swtor_main assets_swtor_test_de_de assets_swtor_test_en_us assets_swtor_test_fr_fr assets_swtor_test_main eualas movies_de_de movies_en_us movies_fr_fr patcher2014 patcher2017 retailclient_liveqatest retailclient_swtor retailclient_publictest' 'swtor_install'
``` ```
# Usage # Usage
Either directly run whatever script you need: To import the functions into your Node.js application:
```bash ```ts
node dist/getManifest.js assets_swtor_main import * as ssn from 'ssn';
node dist/getSolidPkg.js assets_swtor_main 126 127
node dist/getSolidPkgZip.js assets_swtor_main 126 127
node dist/installPatch.js assets_swtor_main 126 127
swtor_install assets_swtor_main 126 127
```
Or import the functions into your Node.js application:
```js
import * as ssn from './dist';
(async function() { (async function() {
const manifestContents = await ssn.getManifest('assets_swtor_main'); const manifestContents = await ssn.getManifest('assets_swtor_main');
@ -46,6 +39,17 @@ import * as ssn from './dist';
}()) }())
``` ```
# Development
To work with the repository locally:
```bash
sudo npm install -g typescript tslint
git clone https://git.jedipedia.net/swtor/ssn.git
cd ssn
npm install && npm start
```
# License # License
Copyright (C) 2018 Jedipedia.net Copyright (C) 2018 Jedipedia.net

View file

@ -1,7 +0,0 @@
export default function failWithError(usage: string, msg?: string) {
if (msg !== undefined) {
process.stderr.write(`Error: ${msg.trim()}\n`);
}
process.stderr.write(`Usage: ${usage} \n`);
process.exit(1);
}

View file

@ -1,23 +0,0 @@
import failWithError from './failWithError';
import IManifest from './interfaces/IManifest';
import { Product } from './interfaces/ISettings';
import getManifest from './ssn/getManifest';
import verifyProductName from './ssn/verify/verifyProductName';
const failFunction = failWithError.bind(null, 'node dist/getManifest.js <product>');
if (process.argv.length !== 3) {
failFunction(`Expected 1 argument but ${process.argv.length - 2} arguments were supplied.`);
}
//Check that product name is valid
const product = process.argv[2];
if (!verifyProductName(product)) {
failFunction(`"${product} is not a valid product name.`);
}
//Get manifest and write output to stdout
getManifest(product as Product).then((output: IManifest) => {
process.stdout.write(JSON.stringify(output));
//process.exit(0);
});

View file

@ -1,33 +0,0 @@
import failWithError from './failWithError';
import { Product } from './interfaces/ISettings';
import ISolidSimple from './interfaces/ISolidSimple';
import getSolidpkg from './ssn/getSolidpkg';
import verifyProductName from './ssn/verify/verifyProductName';
const failFunction = failWithError.bind(null, 'node dist/getSolidpkg.js <product> <from> <to>');
if (process.argv.length !== 5) {
failFunction(`Expected 3 arguments but ${process.argv.length - 2} arguments were supplied.`);
}
//Check that product name is valid
const product = process.argv[2];
if (!verifyProductName(product)) {
failFunction(`"${product.substring(0, 300)}" is not a valid product name.`);
}
//Check that from and to are valid numbers
const from = process.argv[3];
const to = process.argv[4];
if (!from.match(/^(-1|0|[1-9][0-9]{0,2})$/)) {
failFunction(`from value "${from.substring(0, 300)}" is not a valid integer; it must be in range [-1, 999].`);
}
if (!to.match(/^(0|[1-9][0-9]{0,2})$/)) {
failFunction(`to value "${to.substring(0, 300)}" is not a valid integer; it must be in range [0, 999].`);
}
//Get solidpkg and write output to stdout
getSolidpkg(product as Product, Number(from), Number(to)).then((output: ISolidSimple) => {
process.stdout.write(JSON.stringify(output));
//process.exit(0);
});

View file

@ -1,33 +0,0 @@
import failWithError from './failWithError';
import { Product } from './interfaces/ISettings';
import { ISsnFileEntry } from './interfaces/ISsnFileEntry';
import getSolidpkgZip from './ssn/getSolidpkgZip';
import verifyProductName from './ssn/verify/verifyProductName';
const failFunction = failWithError.bind(null, 'node dist/getSolidpkgZip.js <product> <from> <to>');
if (process.argv.length !== 5) {
failFunction(`Expected 3 arguments but ${process.argv.length - 2} arguments were supplied.`);
}
//Check that product name is valid
const product = process.argv[2];
if (!verifyProductName(product)) {
failFunction(`"${product.substring(0, 300)}" is not a valid product name.`);
}
//Check that from and to are valid numbers
const from = process.argv[3];
const to = process.argv[4];
if (!from.match(/^(-1|0|[1-9][0-9]{0,2})$/)) {
failFunction(`from value "${from.substring(0, 300)}" is not a valid integer; it must be in range [-1, 999].`);
}
if (!to.match(/^(0|[1-9][0-9]{0,2})$/)) {
failFunction(`to value "${to.substring(0, 300)}" is not a valid integer; it must be in range [0, 999].`);
}
//Get solidpkg's .zip file and write output to stdout
getSolidpkgZip(product as Product, Number(from), Number(to)).then((output: ISsnFileEntry[]) => {
process.stdout.write(JSON.stringify(output));
//process.exit(0);
});

View file

@ -1,45 +0,0 @@
import failWithError from './failWithError';
import { Product } from './interfaces/ISettings';
import getPatch from './ssn/getPatch';
import verifyProductName from './ssn/verify/verifyProductName';
const failFunction = failWithError.bind(null, 'node dist/installPatch.js <product> <from> <to>');
if (process.argv.length !== 5) {
failFunction(`Expected 3 arguments but ${process.argv.length - 2} arguments were supplied.`);
}
//Check that product name is valid
const product = process.argv[2];
if (!verifyProductName(product)) {
failFunction(`"${product.substring(0, 300)}" is not a valid product name.`);
}
//Check that from and to are valid numbers
const from = process.argv[3];
const to = process.argv[4];
if (!from.match(/^(-1|0|[1-9][0-9]{0,2})$/)) {
failFunction(`from value "${from.substring(0, 300)}" is not a valid integer; it must be in range [-1, 999].`);
}
if (!to.match(/^(0|[1-9][0-9]{0,2})$/)) {
failFunction(`to value "${to.substring(0, 300)}" is not a valid integer; it must be in range [0, 999].`);
}
//TODO: set directory with existing patch data
//TODO: set target directory where patch should be installed
//TODO: set temp directory where patch files should be stored.
//TODO: set location of xdelta3 executable
//TODO: set from=any so it detects current version automatically (based on .version files)
//TODO: set to=manifest/current to install whatever is the current version in manifest/on CDN
(async () => {
await getPatch({
/* tslint:disable:object-literal-sort-keys */
product: product as Product,
from: Number(from),
to: Number(to),
sourceDirectory: process.cwd(),
targetDirectory: process.cwd(),
/* tslint:enable:object-literal-sort-keys */
});
})();