ssn-tools/src/getSolidpkg.ts
2018-11-04 17:08:35 +01:00

17 lines
1.1 KiB
JavaScript

#!/usr/bin/env node
import parseArguments from 'argument-parser';
import { getSolidpkg, ISolidSimple, Product, verifyProductName } from 'ssn';
const { args, fail } = parseArguments({
product: { short: 'p', description: 'Name of the product you want to get the solidpkg on', verify: verifyProductName, message: (value) => `"${value}" is not a valid product name.` },
from: { short: 'f', description: 'Number of the from release, must be an integer in the range [-1, 999]', verify: (str) => (str.match(/^(?:-1|0|[1-9][0-9]{0,2})$/) !== null) },
to: { short: 't', description: 'Number of the to release, must be an integer in the range [0, 999]', verify: (str) => (str.match(/^(?:0|[1-9][0-9]{0,2})$/) !== null) },
}, (origArgs) => ((origArgs.length === 3) ? ['--product', origArgs[0], '--from', origArgs[1], '--to', origArgs[2]] : undefined));
//Get solidpkg and write output to stdout
getSolidpkg(args.product as Product, Number(args.from), Number(args.to)).then((output: ISolidSimple) => {
process.stdout.write(JSON.stringify(output));
}).catch((error) => {
fail(error);
});