Comparing version 0.2.5 to 0.2.6
@@ -1,11 +0,1 @@ | ||
import * as minimist from 'minimist'; | ||
interface Options extends minimist.ParsedArgs { | ||
package?: string; | ||
projectRoot?: string; | ||
file?: string; | ||
} | ||
export declare namespace Options { | ||
const defaults: Options; | ||
} | ||
export declare function main(): void; | ||
export {}; |
@@ -23,3 +23,4 @@ "use strict"; | ||
Options.defaults = { | ||
_: [], | ||
help: false, | ||
version: false, | ||
package: undefined, | ||
@@ -29,3 +30,10 @@ projectRoot: undefined, | ||
}; | ||
})(Options = exports.Options || (exports.Options = {})); | ||
Options.descriptions = [ | ||
{ id: 'version', type: 'boolean', alias: 'v', default: false, description: 'output the version number' }, | ||
{ id: 'help', type: 'boolean', alias: 'h', default: false, description: 'output usage information' }, | ||
{ id: 'package', type: 'string', default: undefined, description: 'Specifies the location of the package.json file to use. Defaults to the package.json in the current directory.' }, | ||
{ id: 'projectRoot', type: 'string', default: undefined, description: 'Specifies the project root. Defaults to the location of the [tj]sconfig.json file.' }, | ||
{ id: 'file', type: 'string', default: undefined, description: 'Specifies the file that contains a LSIF dump. Defaults to stdin.' }, | ||
]; | ||
})(Options || (Options = {})); | ||
function emit(value) { | ||
@@ -202,7 +210,41 @@ if (Is.string(value)) { | ||
function main() { | ||
let options = Object.assign(Options.defaults, minimist(process.argv.slice(2), { | ||
string: [ | ||
'package', 'projectRoot', 'file', | ||
] | ||
})); | ||
let minOpts = { | ||
string: [], | ||
boolean: [], | ||
default: Object.create(null), | ||
alias: Object.create(null) | ||
}; | ||
let longestId = 0; | ||
for (let description of Options.descriptions) { | ||
longestId = Math.max(longestId, description.id.length); | ||
minOpts[description.type] = description.id; | ||
minOpts.default[description.id] = description.default; | ||
if (description.alias !== undefined) { | ||
minOpts.alias[description.id] = [description.alias]; | ||
} | ||
} | ||
const options = Object.assign(Options.defaults, minimist(process.argv.slice(2), minOpts)); | ||
if (options.version) { | ||
console.log(require('../package.json').version); | ||
return; | ||
} | ||
let buffer = []; | ||
if (options.help) { | ||
buffer.push(`Languag Server Index Format tool for NPM`); | ||
buffer.push(`Version: ${require('../package.json').version}`); | ||
buffer.push(''); | ||
buffer.push(`Usage: lsif-npm [options]`); | ||
buffer.push(''); | ||
buffer.push(`Options`); | ||
for (let description of Options.descriptions) { | ||
if (description.alias !== undefined) { | ||
buffer.push(` -${description.alias} --${description.id}${' '.repeat(longestId - description.id.length)} ${description.description}`); | ||
} | ||
else { | ||
buffer.push(` --${description.id} ${' '.repeat(longestId - description.id.length)} ${description.description}`); | ||
} | ||
} | ||
console.log(buffer.join('\n')); | ||
return; | ||
} | ||
let packageFile = options.package; | ||
@@ -209,0 +251,0 @@ if (packageFile === undefined) { |
{ | ||
"name": "lsif-npm", | ||
"description": "A tools to rewrite Typescript LSIF monikers into npm monikers", | ||
"version": "0.2.5", | ||
"version": "0.2.6", | ||
"author": "Microsoft Corporation", | ||
@@ -23,3 +23,3 @@ "license": "MIT", | ||
"lsif-protocol": "0.2.3", | ||
"lsif-tsc": "0.2.5" | ||
"lsif-tsc": "0.2.6" | ||
}, | ||
@@ -26,0 +26,0 @@ "devDependencies": { |
@@ -27,3 +27,5 @@ /* -------------------------------------------------------------------------------------------- | ||
interface Options extends minimist.ParsedArgs { | ||
interface Options { | ||
help: boolean; | ||
version: boolean; | ||
package?: string; | ||
@@ -34,5 +36,15 @@ projectRoot?: string; | ||
export namespace Options { | ||
interface OptionDescription { | ||
id: keyof Options; | ||
type: 'boolean' | 'string'; | ||
alias?: string; | ||
default: any; | ||
values?: string[]; | ||
description: string; | ||
} | ||
namespace Options { | ||
export const defaults: Options = { | ||
_: [], | ||
help: false, | ||
version: false, | ||
package: undefined, | ||
@@ -42,2 +54,9 @@ projectRoot: undefined, | ||
}; | ||
export const descriptions: OptionDescription[] = [ | ||
{ id: 'version', type: 'boolean', alias: 'v', default: false, description: 'output the version number'}, | ||
{ id: 'help', type: 'boolean', alias: 'h', default: false, description: 'output usage information'}, | ||
{ id: 'package', type: 'string', default: undefined, description: 'Specifies the location of the package.json file to use. Defaults to the package.json in the current directory.'}, | ||
{ id: 'projectRoot', type: 'string', default: undefined, description: 'Specifies the project root. Defaults to the location of the [tj]sconfig.json file.'}, | ||
{ id: 'file', type: 'string', default: undefined, description: 'Specifies the file that contains a LSIF dump. Defaults to stdin.'}, | ||
]; | ||
} | ||
@@ -234,7 +253,47 @@ | ||
export function main(): void { | ||
let options: Options = Object.assign(Options.defaults, minimist(process.argv.slice(2), { | ||
string: [ | ||
'package', 'projectRoot', 'file', | ||
] | ||
})); | ||
let minOpts: minimist.Opts = { | ||
string: [], | ||
boolean: [], | ||
default: Object.create(null), | ||
alias: Object.create(null) | ||
}; | ||
let longestId: number = 0; | ||
for (let description of Options.descriptions) { | ||
longestId = Math.max(longestId, description.id.length); | ||
minOpts[description.type] = description.id; | ||
minOpts.default![description.id] = description.default; | ||
if (description.alias !== undefined) { | ||
minOpts.alias![description.id] = [description.alias]; | ||
} | ||
} | ||
const options: Options = Object.assign(Options.defaults, minimist(process.argv.slice(2), minOpts)); | ||
if (options.version) { | ||
console.log(require('../package.json').version); | ||
return; | ||
} | ||
let buffer: string[] = []; | ||
if (options.help) { | ||
buffer.push(`Languag Server Index Format tool for NPM`); | ||
buffer.push(`Version: ${require('../package.json').version}`); | ||
buffer.push(''); | ||
buffer.push(`Usage: lsif-npm [options]`); | ||
buffer.push(''); | ||
buffer.push(`Options`); | ||
for (let description of Options.descriptions) { | ||
if (description.alias !== undefined) { | ||
buffer.push(` -${description.alias} --${description.id}${' '.repeat(longestId - description.id.length)} ${description.description}`); | ||
} else { | ||
buffer.push(` --${description.id} ${' '.repeat(longestId - description.id.length)} ${description.description}`); | ||
} | ||
} | ||
console.log(buffer.join('\n')); | ||
return; | ||
} | ||
let packageFile: string | undefined = options.package; | ||
@@ -241,0 +300,0 @@ if (packageFile === undefined) { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
49259
15
796
1
13
+ Addedlsif-tsc@0.2.6(transitive)
- Removedlsif-tsc@0.2.5(transitive)
Updatedlsif-tsc@0.2.6