38 lines
1.5 KiB
TypeScript
38 lines
1.5 KiB
TypeScript
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
|
|
//TODO: set to=manifest/current to install whatever is the current version in manifest/on CDN
|
|
|
|
(async () => {
|
|
const patch = await getPatch(product as Product, Number(from), Number(to));
|
|
//console.log(patch);
|
|
})();
|