Comparing version 0.1.2 to 0.1.3
@@ -7,3 +7,3 @@ "use strict"; | ||
commander.name('tyscan') | ||
.version('0.1.2', '-V, --version') | ||
.version('0.1.3', '-V, --version') | ||
.description('Command line tool for scanning TypeScript sources'); | ||
@@ -19,3 +19,3 @@ commander.command('scan [path...]') | ||
compiler_1.configureCompilerOptions(opts.tsconfig); | ||
run(() => cli.scan(paths.length ? paths : ['.'], opts.config, opts.json || false, opts.verbose || false)); | ||
run(() => cli.scan(paths.length ? paths : ['.'], opts.config, opts.json || false, opts.verbose || false, console.log, console.error)); | ||
}); | ||
@@ -27,5 +27,6 @@ commander.command('test') | ||
.option('-t, --tsconfig <path>', 'path to tsconfig.json', 'tsconfig.json') | ||
.option('-j, --json', 'output json') | ||
.action((opts) => { | ||
compiler_1.configureCompilerOptions(opts.tsconfig); | ||
run(() => cli.test(opts.config)); | ||
run(() => cli.test(opts.config, opts.json || false, console.log, console.error)); | ||
}); | ||
@@ -49,1 +50,2 @@ if (process.argv.slice(2).length === 0) { | ||
} | ||
//# sourceMappingURL=bin.js.map |
@@ -7,3 +7,3 @@ "use strict"; | ||
const config = require("./config"); | ||
function scan(srcPaths, configPath, jsonOutput, verboseOutput) { | ||
function scan(srcPaths, configPath, jsonOutput, verboseOutput, stdout, stderr) { | ||
const paths = srcPaths | ||
@@ -31,3 +31,3 @@ .filter(p => fs.existsSync(p)) | ||
if (verboseOutput) { | ||
console.log(`Scanning ${src.fileName} (${scannedFileCount}/${targetFileCount})`); | ||
stdout(`Scanning ${src.fileName} (${scannedFileCount}/${targetFileCount})`); | ||
} | ||
@@ -54,6 +54,6 @@ if (result.nodes !== undefined) { | ||
if (verboseOutput) { | ||
console.error(`\x1b[31m${txt}\x1b[0m`); | ||
stderr(`\x1b[31m${txt}\x1b[0m`); | ||
} | ||
else { | ||
console.log(`${txt}`); | ||
stdout(`${txt}`); | ||
} | ||
@@ -76,3 +76,3 @@ } | ||
else { | ||
console.error(`${result.path}#L${start.line + 1}C${start.character + 1}: ${msg}`); | ||
stderr(`${result.path}#L${start.line + 1}C${start.character + 1}: ${msg}`); | ||
} | ||
@@ -83,3 +83,3 @@ } | ||
if (jsonOutput) { | ||
console.log(JSON.stringify(output)); | ||
stdout(JSON.stringify(output)); | ||
} | ||
@@ -89,4 +89,5 @@ return ecode; | ||
exports.scan = scan; | ||
function test(configPath) { | ||
function test(configPath, jsonOutput, stdout, stderr) { | ||
const count = { success: 0, failure: 0, skipped: 0 }; | ||
const messages = []; | ||
for (const result of config.load(configPath).test()) { | ||
@@ -100,6 +101,18 @@ const testId = `#${result.test.index + 1} in ${result.test.rule.id}`; | ||
if (result.test.match) { | ||
console.log(`No match found in match test ${testId}`); | ||
const msg = `No match found in match test ${testId}`; | ||
if (jsonOutput) { | ||
messages.push(msg); | ||
} | ||
else { | ||
stdout(msg); | ||
} | ||
} | ||
else { | ||
console.log(`Match found in unmatch test ${testId}`); | ||
const msg = `Match found in unmatch test ${testId}`; | ||
if (jsonOutput) { | ||
messages.push(msg); | ||
} | ||
else { | ||
stdout(msg); | ||
} | ||
} | ||
@@ -110,11 +123,23 @@ } | ||
const kind = result.test.match ? 'match' : 'unmatch'; | ||
console.log(`Skipped ${kind} test ${testId}`); | ||
const msg = `Skipped ${kind} test ${testId}`; | ||
if (jsonOutput) { | ||
messages.push(msg); | ||
} | ||
else { | ||
stdout(msg); | ||
} | ||
} | ||
} | ||
console.log('Summary:'); | ||
console.log(` - Success: ${count.success} test(s)`); | ||
console.log(` - Failure: ${count.failure} test(s)`); | ||
console.log(` - Skipped: ${count.skipped} test(s)`); | ||
if (jsonOutput) { | ||
stdout(JSON.stringify({ messages, summary: count })); | ||
} | ||
else { | ||
stdout('Summary:'); | ||
stdout(` - Success: ${count.success} test(s)`); | ||
stdout(` - Failure: ${count.failure} test(s)`); | ||
stdout(` - Skipped: ${count.skipped} test(s)`); | ||
} | ||
return (count.failure + count.skipped) ? 1 : 0; | ||
} | ||
exports.test = test; | ||
//# sourceMappingURL=cli.js.map |
@@ -42,1 +42,2 @@ "use strict"; | ||
let compilerOptions = {}; | ||
//# sourceMappingURL=compiler.js.map |
@@ -180,1 +180,2 @@ "use strict"; | ||
} | ||
//# sourceMappingURL=config.js.map |
@@ -133,5 +133,9 @@ "use strict"; | ||
} | ||
return exprIdx === exprs.length; | ||
if (exprIdx === 0) { | ||
return exprIdx === exprs.length; | ||
} | ||
return argIdx === this.args.length && exprIdx === exprs.length; | ||
} | ||
} | ||
exports.Call = Call; | ||
//# sourceMappingURL=node.js.map |
@@ -64,1 +64,2 @@ "use strict"; | ||
}); | ||
//# sourceMappingURL=parser.js.map |
@@ -27,1 +27,2 @@ "use strict"; | ||
const isExpressionNode = ts.isExpressionNode; | ||
//# sourceMappingURL=pattern.js.map |
@@ -159,2 +159,7 @@ "use strict"; | ||
match(declaration) { | ||
if (this.path.components.length !== 0) { | ||
if (!this.path.match(declaration.getSourceFile())) { | ||
return false; | ||
} | ||
} | ||
if (this.namespaces.length === 0) { | ||
@@ -175,7 +180,2 @@ return true; | ||
nss.reverse(); | ||
if (0 < this.path.components.length) { | ||
return this.path.match(declaration.getSourceFile()) | ||
&& nss.length === this.namespaces.length | ||
&& nss.every((s, i) => s === this.namespaces[i]); | ||
} | ||
if (nss.length < this.namespaces.length) { | ||
@@ -194,7 +194,3 @@ return false; | ||
match(sourceFile) { | ||
const path = sourceFile.fileName.split('.').slice(0, -1).join('.'); | ||
if (path.startsWith('/')) { | ||
return false; | ||
} | ||
const ps = path.split('/'); | ||
const ps = sourceFile.fileName.split('.').slice(0, -1).join('.').split('/'); | ||
if (ps.length < this.components.length) { | ||
@@ -233,1 +229,2 @@ return false; | ||
exports.Predefined = Predefined; | ||
//# sourceMappingURL=node.js.map |
@@ -55,1 +55,2 @@ "use strict"; | ||
exports.typeParser = parser.Type; | ||
//# sourceMappingURL=parser.js.map |
{ | ||
"name": "tyscan", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "Command line tool for scanning TypeScript sources", | ||
@@ -10,5 +10,5 @@ "bin": { | ||
"build": "tsc --project tsconfig.json --outDir dist", | ||
"format": "tslint --fix --project tsconfig.json 'src/**/*.ts'", | ||
"format": "tslint --fix --project tsconfig.json", | ||
"prepare": "npm run build", | ||
"test": "nyc mocha test/**/*.ts test/*.ts", | ||
"test": "nyc mocha test/*.ts --timeout 5000", | ||
"watch": "npm run build" | ||
@@ -36,4 +36,4 @@ }, | ||
"@types/js-yaml": "^3.12.0", | ||
"@types/mocha": "^5.2.5", | ||
"@types/node": "^10.12.12", | ||
"@types/mocha": "^5.2.6", | ||
"@types/node": "^10.12.27", | ||
"@types/parsimmon": "^1.10.0", | ||
@@ -43,9 +43,9 @@ "@types/typescript": "^2.0.0", | ||
"mocha": "^5.2.0", | ||
"nyc": "^13.1.0", | ||
"nyc": "^13.3.0", | ||
"ts-loader": "^5.3.3", | ||
"ts-node": "^8.0.1", | ||
"tslint": "^5.12.1", | ||
"ts-node": "^8.0.2", | ||
"tslint": "^5.13.0", | ||
"tslint-config-airbnb": "^5.11.1", | ||
"tsutils": "^3.7.0", | ||
"typescript": "^3.2.4" | ||
"tsutils": "^3.8.0", | ||
"typescript": "^3.3.3333" | ||
}, | ||
@@ -52,0 +52,0 @@ "peerDependencies": { |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
24
70128
913
1