diff --git a/README.md b/README.md index f274635..17f5eb4 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,14 @@ Simple helper to do typechecking ```npm install git://github.com/fuse-box/fuse-box-typechecker --save-dev``` +### Note +This have been tested with + * "tslint": "^5.4.3", + * "typescript": "^2.4.1" + +So this might not work with earlier version if typescript and tslint (tsLint 3 will fail, been tested). + + ### How to use ```javascript diff --git a/dist/commonjs/checker.js b/dist/commonjs/checker.js index 95146b1..38be11d 100644 --- a/dist/commonjs/checker.js +++ b/dist/commonjs/checker.js @@ -1,3 +1,4 @@ +"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var ts = require("typescript"); var chalk = require("chalk"); diff --git a/dist/commonjs/checker.js.map b/dist/commonjs/checker.js.map index 80ac3f6..20cdfc4 100644 --- a/dist/commonjs/checker.js.map +++ b/dist/commonjs/checker.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/checker.ts"],"names":[],"mappings":";AAAA,+BAAiC;AACjC,6BAA+B;AAC/B,+BAAiC;AACjC,2BAA6B;AAC7B,2CAAqE;AAGrE;IAkBI;IAEA,CAAC;IAGM,6BAAW,GAAlB,UAAmB,OAAoC;QAAvD,iBAyFC;QAxFG,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAIvB,IAAM,eAAe,GAAQ;YACzB,UAAU,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU;YAC7B,aAAa,EAAE,EAAE,CAAC,GAAG,CAAC,aAAa;YACnC,QAAQ,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ;YACzB,yBAAyB,EAAE,IAAI;SAClC,CAAC;QAGF,IAAI,mBAAmB,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;QAG/C,IAAM,MAAM,GAAG,EAAE,CAAC,0BAA0B,CAAC,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE,eAAe,EAAE,OAAO,CAAC,QAAQ,IAAI,GAAG,EAAE,SAAS,CAAC,CAAC;QACpI,IAAI,CAAC,O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'chalk';\r\nimport * as tslint from 'tslint';\r\nimport * as path from 'path';\r\nimport { IInternalTypeCheckerOptions, END_LINE } from './interfaces';\r\n\r\n\r\nexport class Checker {\r\n\r\n // options that will be used when checking and printing results\r\n private options: IInternalTypeCheckerOptions;\r\n\r\n // typescript program\r\n private program: ts.Program;\r\n\r\n // time used to do typecheck/linting\r\n private elapsedInspectionTime: number;\r\n\r\n // type diagonstic returned by typescript\r\n private tsDiagnostics: ts.Diagnostic[];\r\n\r\n // lint result returned by tsLint\r\n private lintFileResult: tslint.LintResult[];\r\n\r\n\r\n constructor() {\r\n // nothing atm\r\n }\r\n\r\n\r\n public inspectCode(options: IInternalTypeCheckerOptions) {\r\n this.options = options;\r\n\r\n\r\n // parse it right away, no need to wait...\r\n const parseConfigHost: any = {\r\n fileExists: ts.sys.fileExists,\r\n readDirectory: ts.sys.readDirectory,\r\n readFile: ts.sys.readFile,\r\n useCaseSensitiveFileNames: true\r\n };\r\n\r\n // take the time\r\n let inspectionTimeStart = new Date().getTime();\r\n\r\n // get program and get diagnostics and store them diagnostics\r\n const parsed = ts.parseJsonConfigFileContent(this.options.tsConfigJsonContent, parseConfigHost, options.basePath || '.', undefined);\r\n this.program = ts.createProgram(parsed.fileNames, parsed.options, undefined, this.program);\r\n\r\n\r\n // get errors and tag them;\r\n this.tsDiagnostics = [];\r\n let optionsErrors = this.program.getOptionsDiagnostics().map((obj) => {\r\n // tag em so we know for later\r\n (obj)._type = 'options';\r\n return obj;\r\n });\r\n this.tsDiagnostics = this.tsDiagnostics.concat(optionsErrors);\r\n\r\n\r\n\r\n let globalErrors = this.program.getGlobalDiagnostics().map((obj) => {\r\n (obj)._type = 'global';\r\n return obj;\r\n });\r\n this.tsDiagnostics = this.tsDiagnostics.concat(globalErrors);\r\n\r\n\r\n\r\n let syntacticErrors = this.program.getSyntacticDiagnostics().map((obj) => {\r\n (obj)._type = 'syntactic';\r\n return obj;\r\n });\r\n this.tsDiagnostics = this.tsDiagnostics.concat(syntacticErrors);\r\n\r\n\r\n\r\n let semanticErrors = this.program.getSemanticDiagnostics().map((obj) => {\r\n (obj)._type = 'semantic';\r\n return obj;\r\n });\r\n this.tsDiagnostics = this.tsDiagnostics.concat(semanticErrors);\r\n\r\n\r\n // get tslint if json file is supplied\r\n this.lintFileResult = [];\r\n if (options.tsLint) {\r\n\r\n // get full path\r\n let fullPath = path.resolve(this.options.basePath, options.tsLint);\r\n\r\n // gets the files, lint every file and store errors in lintResults\r\n let files = tslint.Linter.getFileNames(this.program);\r\n\r\n // get tslint configuration\r\n const tsLintConfiguration = tslint.Configuration.findConfiguration(fullPath, this.options.basePath).results;\r\n\r\n // lint the files\r\n this.lintFileResult =\r\n files.map(file => {\r\n // get content of file\r\n const fileContents = this.program.getSourceFile(file).getFullText();\r\n\r\n // create new linter using lint options and tsprogram\r\n const linter = new tslint.Linter((options.lintoptions), this.program);\r\n\r\n // lint file using filename, filecontent, and tslint configuration\r\n linter.lint(file, fileContents, tsLintConfiguration);\r\n\r\n // return result\r\n return linter.getResult();\r\n }).filter((result) => {\r\n // only return the one with erros\r\n return result.errorCount ? true : false;\r\n });\r\n }\r\n\r\n // save elapsed check time\r\n this.elapsedInspectionTime = new Date().getTime() - inspectionTimeStart;\r\n }\r\n\r\n\r\n\r\n /**\r\n * print result\r\n *\r\n */\r\n public printResult(isWorker?: boolean) {\r\n\r\n // consts\r\n const print = this.writeText;\r\n const program = this.program;\r\n const options = this.options;\r\n\r\n // print header\r\n print(\r\n chalk.bgWhite(\r\n chalk.black(`${END_LINE}Typechecker plugin(${options.type}) ${options.name}`)\r\n ) +\r\n chalk.white(`.${END_LINE}`)\r\n );\r\n\r\n // print time\r\n print(\r\n chalk.grey(`Time:${new Date().toString()} ${END_LINE}`)\r\n );\r\n\r\n // get the lint errors messages\r\n let lintErrorMessages = this.processLintFiles();\r\n\r\n // loop diagnostics and get the errors messages\r\n let tsErrorMessages = this.processTsDiagnostics();\r\n\r\n // combine errors and print if any\r\n let allErrors = tsErrorMessages.concat(lintErrorMessages);\r\n\r\n // print if any\r\n if (allErrors.length > 0) {\r\n\r\n // insert header\r\n allErrors.unshift(\r\n chalk.underline(`${END_LINE}File errors`) + chalk.white(':') // fix windows\r\n );\r\n\r\n print(allErrors.join(END_LINE));\r\n }\r\n\r\n // time for summary >>>>>\r\n\r\n // get errors totals\r\n let optionsErrors = program.getOptionsDiagnostics().length;\r\n let globalErrors = program.getGlobalDiagnostics().length;\r\n let syntacticErrors = program.getSyntacticDiagnostics().length;\r\n let semanticErrors = program.getSemanticDiagnostics().length;\r\n let tsLintErrors = lintErrorMessages.length;\r\n let totalsErrors = optionsErrors + globalErrors + syntacticErrors + semanticErrors + tsLintErrors;\r\n\r\n\r\n\r\n // if errors, show user\r\n if (totalsErrors) {\r\n\r\n // write header\r\n print(\r\n chalk.underline(`${END_LINE}${END_LINE}Errors`) +\r\n chalk.white(`:${totalsErrors}${END_LINE}`)\r\n );\r\n\r\n print(\r\n chalk[optionsErrors ? options.yellowOnOptions ? 'yellow' : 'red' : 'white']\r\n (`└── Options: ${optionsErrors}${END_LINE}`)\r\n );\r\n\r\n print(\r\n chalk[globalErrors ? options.yellowOnGlobal ? 'yellow' : 'red' : 'white']\r\n (`└── Global: ${globalErrors}${END_LINE}`)\r\n );\r\n\r\n print(\r\n chalk[syntacticErrors ? options.yellowOnSyntactic ? 'yellow' : 'red' : 'white']\r\n (`└── Syntactic: ${syntacticErrors}${END_LINE}`)\r\n );\r\n\r\n print(\r\n chalk[semanticErrors ? options.yellowOnSemantic ? 'yellow' : 'red' : 'white']\r\n (`└── Semantic: ${semanticErrors}${END_LINE}`)\r\n );\r\n\r\n print(\r\n chalk[tsLintErrors ? options.yellowOnLint ? 'yellow' : 'red' : 'white']\r\n (`└── TsLint: ${tsLintErrors}${END_LINE}${END_LINE}`)\r\n );\r\n\r\n } else {\r\n // if there no errors, then also give some feedback about this, so they know its working\r\n print(\r\n chalk.grey(`All good, no errors :-)${END_LINE}`)\r\n );\r\n }\r\n\r\n print(\r\n chalk.grey(`Typechecking time: ${this.elapsedInspectionTime}ms${END_LINE}`)\r\n );\r\n\r\n\r\n // final check how to end the checker, throw, exit or keep alive\r\n\r\n switch (true) {\r\n\r\n // if throwError is set then callback and quit\r\n case options.throwOnGlobal && globalErrors > 0:\r\n case options.throwOnOptions && optionsErrors > 0:\r\n case options.throwOnSemantic && semanticErrors > 0:\r\n case options.throwOnTsLint && tsLintErrors > 0:\r\n case options.throwOnSyntactic && syntacticErrors > 0:\r\n if (process.send) {\r\n process.send('error');\r\n } else {\r\n throw new Error('Typechecker throwing error due to throw options set');\r\n }\r\n // exit with error\r\n process.exit(1);\r\n break;\r\n\r\n // if quit is set and its a worker, then post message and callback to main tread and tell its done\r\n case options.quit && isWorker:\r\n print(chalk.grey(`Quiting typechecker${END_LINE}${END_LINE}`));\r\n\r\n // since Im a worker I need to send back a message;\r\n (process).send('done');\r\n break;\r\n\r\n // if quit is set and not worker, then just post messeage\r\n case options.quit && !isWorker:\r\n print(chalk.grey(`Quiting typechecker${END_LINE}${END_LINE}`));\r\n break;\r\n\r\n // default action\r\n default:\r\n print(chalk.grey(`Keeping typechecker alive${END_LINE}${END_LINE}`));\r\n }\r\n\r\n return totalsErrors;\r\n\r\n }\r\n\r\n\r\n\r\n /**\r\n * write to screen helper\r\n *\r\n */\r\n private writeText(text: string) {\r\n ts.sys.write(text);\r\n }\r\n\r\n\r\n\r\n /**\r\n * loops lint failures and return pretty failure string ready to be printed\r\n *\r\n */\r\n private processLintFiles(): string[] {\r\n\r\n const options = this.options;\r\n\r\n // loop lint results\r\n let lintResultsFilesMessages =\r\n this.lintFileResult.map((fileResult: tslint.LintResult) => {\r\n let messages: string[] = [];\r\n if (fileResult.failures) {\r\n // we have a failure, lets check its failures\r\n messages = fileResult.failures.map((failure: any) => {\r\n\r\n // simplify it so its more readable later\r\n let r = {\r\n fileName: failure.fileName,\r\n line: failure.startPosition.lineAndCharacter.line,\r\n char: failure.startPosition.lineAndCharacter.character,\r\n ruleSeverity: failure.ruleSeverity.charAt(0).toUpperCase() + failure.ruleSeverity.slice(1),\r\n ruleName: failure.ruleName,\r\n failure: failure.failure\r\n };\r\n\r\n // make error pretty and return it\r\n let message = chalk.red('└── ');\r\n message += chalk[options.yellowOnLint ? 'yellow' : 'red'](`${r.fileName} (${r.line + 1},${r.char + 1}) `);\r\n message += chalk.white(`(${r.ruleSeverity}:`);\r\n message += chalk.white(`${r.ruleName})`);\r\n message += ' ' + r.failure;\r\n return message;\r\n });\r\n }\r\n // return messages\r\n return messages;\r\n\r\n }).filter((res: string[]) => {\r\n // filter our only messages with content\r\n return res.length === 0 ? false : true;\r\n });\r\n\r\n // flatten/concatenate lint files - > failures\r\n let lintErrorMessages: string[] = [];\r\n try {\r\n if (lintResultsFilesMessages.length) {\r\n lintErrorMessages = lintResultsFilesMessages.reduce((a: string[], b: string[]) => {\r\n return a.concat(b);\r\n });\r\n }\r\n } catch (err) {\r\n console.log(err);\r\n }\r\n\r\n return lintErrorMessages;\r\n }\r\n\r\n\r\n\r\n /**\r\n * loops ts failures and return pretty failure string ready to be printed\r\n *\r\n */\r\n private processTsDiagnostics(): string[] {\r\n\r\n const options = this.options;\r\n let tsErrorMessages: string[] = [];\r\n\r\n if (this.tsDiagnostics.length > 0) {\r\n tsErrorMessages = this.tsDiagnostics.map((diag: any) => {\r\n\r\n // get message type error, warn, info\r\n let message = chalk.red('└── ');\r\n\r\n // set color from options\r\n let color: string;\r\n switch (diag._type) {\r\n case 'options':\r\n color = options.yellowOnOptions ? 'yellow' : 'red';\r\n break;\r\n case 'global':\r\n color = options.yellowOnGlobal ? 'yellow' : 'red';\r\n break;\r\n case 'syntactic':\r\n color = options.yellowOnSyntactic ? 'yellow' : 'red';\r\n break;\r\n case 'semantic':\r\n color = options.yellowOnSemantic ? 'yellow' : 'red';\r\n break;\r\n default:\r\n color = 'red';\r\n }\r\n\r\n // if file\r\n if (diag.file) {\r\n const {\r\n line,\r\n character\r\n } = diag.file.getLineAndCharacterOfPosition(diag.start);\r\n\r\n message += chalk[color](`${diag.file.fileName} (${line + 1},${character + 1}) `);\r\n message += chalk.white(`(${ts.DiagnosticCategory[diag.category]}:`);\r\n message += chalk.white(`TS${diag.code})`);\r\n }\r\n\r\n // flatten error message\r\n message += ' ' + ts.flattenDiagnosticMessageText(diag.messageText, END_LINE);\r\n\r\n // return message\r\n return message;\r\n });\r\n }\r\n\r\n return tsErrorMessages;\r\n }\r\n\r\n\r\n}\r\n"],"sourceRoot":"src/"} \ No newline at end of file +{"version":3,"sources":["../src/checker.ts"],"names":[],"mappings":";;AAAA,+BAAiC;AACjC,6BAA+B;AAC/B,+BAAiC;AACjC,2BAA6B;AAC7B,2CAAqE;AAGrE;IAkBI;IAEA,CAAC;IAGM,6BAAW,GAAlB,UAAmB,OAAoC;QAAvD,iBAyFC;QAxFG,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAIvB,IAAM,eAAe,GAAQ;YACzB,UAAU,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU;YAC7B,aAAa,EAAE,EAAE,CAAC,GAAG,CAAC,aAAa;YACnC,QAAQ,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ;YACzB,yBAAyB,EAAE,IAAI;SAClC,CAAC;QAGF,IAAI,mBAAmB,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;QAG/C,IAAM,MAAM,GAAG,EAAE,CAAC,0BAA0B,CAAC,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE,eAAe,EAAE,OAAO,CAAC,QAAQ,IAAI,GAAG,EAAE,SAAS,CAAC,CAAC;QACpI,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,OAAO,EAAE,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAI3F,IAAI,CAAC,aAAa,GAAG,EAAE,CAAC;QACxB,IAAI,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,qBAAq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,iBAAiB,GAAG,QAAQ,GAAG,KAAK,CAAC;wBACrD,KAAK,CAAC;oBACV,KAAK,UAAU;wBACX,KAAK,GAAG,OAAO,CAAC,gBAAgB,GAAG,QAAQ,GAAG,KAAK,CAAC;wBACpD,KAAK,CAAC;oBACV;wBACI,KAAK,GAAG,KAAK,CAAC;gBACtB,CAAC;gBAGD,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;oBACN,IAAA,wDAGiD,EAFnD,cAAI,EACJ,wBAAS,CAC2C;oBAExD,OAAO,IAAI,KAAK,CAAC,KAAK,CAAC,CAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,WAAK,IAAI,GAAG,CAAC,WAAI,SAAS,GAAG,CAAC,QAAI,CAAC,CAAC;oBACjF,OAAO,IAAI,KAAK,CAAC,KAAK,CAAC,MAAI,EAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAG,CAAC,CAAC;oBACpE,OAAO,IAAI,KAAK,CAAC,KAAK,CAAC,OAAK,IAAI,CAAC,IAAI,MAAG,CAAC,CAAC;gBAC9C,CAAC;gBAGD,OAAO,IAAI,GAAG,GAAG,EAAE,CAAC,4BAA4B,CAAC,IAAI,CAAC,WAAW,EAAE,qBAAQ,CAAC,CAAC;gBAG7E,MAAM,CAAC,OAAO,CAAC;YACnB,CAAC,CAAC,CAAC;QACP,CAAC;QAED,MAAM,CAAC,eAAe,CAAC;IAC3B,CAAC;IAGL,cAAC;AAAD,CArYA,AAqYC,IAAA;AArYY,0BAAO","file":"checker.js","sourcesContent":["import * as ts from 'typescript';\r\nimport * as chalk from 'chalk';\r\nimport * as tslint from 'tslint';\r\nimport * as path from 'path';\r\nimport { IInternalTypeCheckerOptions, END_LINE } from './interfaces';\r\n\r\n\r\nexport class Checker {\r\n\r\n // options that will be used when checking and printing results\r\n private options: IInternalTypeCheckerOptions;\r\n\r\n // typescript program\r\n private program: ts.Program;\r\n\r\n // time used to do typecheck/linting\r\n private elapsedInspectionTime: number;\r\n\r\n // type diagonstic returned by typescript\r\n private tsDiagnostics: ts.Diagnostic[];\r\n\r\n // lint result returned by tsLint\r\n private lintFileResult: tslint.LintResult[];\r\n\r\n\r\n constructor() {\r\n // nothing atm\r\n }\r\n\r\n\r\n public inspectCode(options: IInternalTypeCheckerOptions) {\r\n this.options = options;\r\n\r\n\r\n // parse it right away, no need to wait...\r\n const parseConfigHost: any = {\r\n fileExists: ts.sys.fileExists,\r\n readDirectory: ts.sys.readDirectory,\r\n readFile: ts.sys.readFile,\r\n useCaseSensitiveFileNames: true\r\n };\r\n\r\n // take the time\r\n let inspectionTimeStart = new Date().getTime();\r\n\r\n // get program and get diagnostics and store them diagnostics\r\n const parsed = ts.parseJsonConfigFileContent(this.options.tsConfigJsonContent, parseConfigHost, options.basePath || '.', undefined);\r\n this.program = ts.createProgram(parsed.fileNames, parsed.options, undefined, this.program);\r\n\r\n\r\n // get errors and tag them;\r\n this.tsDiagnostics = [];\r\n let optionsErrors = this.program.getOptionsDiagnostics().map((obj) => {\r\n // tag em so we know for later\r\n (obj)._type = 'options';\r\n return obj;\r\n });\r\n this.tsDiagnostics = this.tsDiagnostics.concat(optionsErrors);\r\n\r\n\r\n\r\n let globalErrors = this.program.getGlobalDiagnostics().map((obj) => {\r\n (obj)._type = 'global';\r\n return obj;\r\n });\r\n this.tsDiagnostics = this.tsDiagnostics.concat(globalErrors);\r\n\r\n\r\n\r\n let syntacticErrors = this.program.getSyntacticDiagnostics().map((obj) => {\r\n (obj)._type = 'syntactic';\r\n return obj;\r\n });\r\n this.tsDiagnostics = this.tsDiagnostics.concat(syntacticErrors);\r\n\r\n\r\n\r\n let semanticErrors = this.program.getSemanticDiagnostics().map((obj) => {\r\n (obj)._type = 'semantic';\r\n return obj;\r\n });\r\n this.tsDiagnostics = this.tsDiagnostics.concat(semanticErrors);\r\n\r\n\r\n // get tslint if json file is supplied\r\n this.lintFileResult = [];\r\n if (options.tsLint) {\r\n\r\n // get full path\r\n let fullPath = path.resolve(this.options.basePath, options.tsLint);\r\n\r\n // gets the files, lint every file and store errors in lintResults\r\n let files = tslint.Linter.getFileNames(this.program);\r\n\r\n // get tslint configuration\r\n const tsLintConfiguration = tslint.Configuration.findConfiguration(fullPath, this.options.basePath).results;\r\n\r\n // lint the files\r\n this.lintFileResult =\r\n files.map(file => {\r\n // get content of file\r\n const fileContents = this.program.getSourceFile(file).getFullText();\r\n\r\n // create new linter using lint options and tsprogram\r\n const linter = new tslint.Linter((options.lintoptions), this.program);\r\n\r\n // lint file using filename, filecontent, and tslint configuration\r\n linter.lint(file, fileContents, tsLintConfiguration);\r\n\r\n // return result\r\n return linter.getResult();\r\n }).filter((result) => {\r\n // only return the one with erros\r\n return result.errorCount ? true : false;\r\n });\r\n }\r\n\r\n // save elapsed check time\r\n this.elapsedInspectionTime = new Date().getTime() - inspectionTimeStart;\r\n }\r\n\r\n\r\n\r\n /**\r\n * print result\r\n *\r\n */\r\n public printResult(isWorker?: boolean) {\r\n\r\n // consts\r\n const print = this.writeText;\r\n const program = this.program;\r\n const options = this.options;\r\n\r\n // print header\r\n print(\r\n chalk.bgWhite(\r\n chalk.black(`${END_LINE}Typechecker plugin(${options.type}) ${options.name}`)\r\n ) +\r\n chalk.white(`.${END_LINE}`)\r\n );\r\n\r\n // print time\r\n print(\r\n chalk.grey(`Time:${new Date().toString()} ${END_LINE}`)\r\n );\r\n\r\n // get the lint errors messages\r\n let lintErrorMessages = this.processLintFiles();\r\n\r\n // loop diagnostics and get the errors messages\r\n let tsErrorMessages = this.processTsDiagnostics();\r\n\r\n // combine errors and print if any\r\n let allErrors = tsErrorMessages.concat(lintErrorMessages);\r\n\r\n // print if any\r\n if (allErrors.length > 0) {\r\n\r\n // insert header\r\n allErrors.unshift(\r\n chalk.underline(`${END_LINE}File errors`) + chalk.white(':') // fix windows\r\n );\r\n\r\n print(allErrors.join(END_LINE));\r\n }\r\n\r\n // time for summary >>>>>\r\n\r\n // get errors totals\r\n let optionsErrors = program.getOptionsDiagnostics().length;\r\n let globalErrors = program.getGlobalDiagnostics().length;\r\n let syntacticErrors = program.getSyntacticDiagnostics().length;\r\n let semanticErrors = program.getSemanticDiagnostics().length;\r\n let tsLintErrors = lintErrorMessages.length;\r\n let totalsErrors = optionsErrors + globalErrors + syntacticErrors + semanticErrors + tsLintErrors;\r\n\r\n\r\n\r\n // if errors, show user\r\n if (totalsErrors) {\r\n\r\n // write header\r\n print(\r\n chalk.underline(`${END_LINE}${END_LINE}Errors`) +\r\n chalk.white(`:${totalsErrors}${END_LINE}`)\r\n );\r\n\r\n print(\r\n chalk[optionsErrors ? options.yellowOnOptions ? 'yellow' : 'red' : 'white']\r\n (`└── Options: ${optionsErrors}${END_LINE}`)\r\n );\r\n\r\n print(\r\n chalk[globalErrors ? options.yellowOnGlobal ? 'yellow' : 'red' : 'white']\r\n (`└── Global: ${globalErrors}${END_LINE}`)\r\n );\r\n\r\n print(\r\n chalk[syntacticErrors ? options.yellowOnSyntactic ? 'yellow' : 'red' : 'white']\r\n (`└── Syntactic: ${syntacticErrors}${END_LINE}`)\r\n );\r\n\r\n print(\r\n chalk[semanticErrors ? options.yellowOnSemantic ? 'yellow' : 'red' : 'white']\r\n (`└── Semantic: ${semanticErrors}${END_LINE}`)\r\n );\r\n\r\n print(\r\n chalk[tsLintErrors ? options.yellowOnLint ? 'yellow' : 'red' : 'white']\r\n (`└── TsLint: ${tsLintErrors}${END_LINE}${END_LINE}`)\r\n );\r\n\r\n } else {\r\n // if there no errors, then also give some feedback about this, so they know its working\r\n print(\r\n chalk.grey(`All good, no errors :-)${END_LINE}`)\r\n );\r\n }\r\n\r\n print(\r\n chalk.grey(`Typechecking time: ${this.elapsedInspectionTime}ms${END_LINE}`)\r\n );\r\n\r\n\r\n // final check how to end the checker, throw, exit or keep alive\r\n\r\n switch (true) {\r\n\r\n // if throwError is set then callback and quit\r\n case options.throwOnGlobal && globalErrors > 0:\r\n case options.throwOnOptions && optionsErrors > 0:\r\n case options.throwOnSemantic && semanticErrors > 0:\r\n case options.throwOnTsLint && tsLintErrors > 0:\r\n case options.throwOnSyntactic && syntacticErrors > 0:\r\n if (process.send) {\r\n process.send('error');\r\n } else {\r\n throw new Error('Typechecker throwing error due to throw options set');\r\n }\r\n // exit with error\r\n process.exit(1);\r\n break;\r\n\r\n // if quit is set and its a worker, then post message and callback to main tread and tell its done\r\n case options.quit && isWorker:\r\n print(chalk.grey(`Quiting typechecker${END_LINE}${END_LINE}`));\r\n\r\n // since Im a worker I need to send back a message;\r\n (process).send('done');\r\n break;\r\n\r\n // if quit is set and not worker, then just post messeage\r\n case options.quit && !isWorker:\r\n print(chalk.grey(`Quiting typechecker${END_LINE}${END_LINE}`));\r\n break;\r\n\r\n // default action\r\n default:\r\n print(chalk.grey(`Keeping typechecker alive${END_LINE}${END_LINE}`));\r\n }\r\n\r\n return totalsErrors;\r\n\r\n }\r\n\r\n\r\n\r\n /**\r\n * write to screen helper\r\n *\r\n */\r\n private writeText(text: string) {\r\n ts.sys.write(text);\r\n }\r\n\r\n\r\n\r\n /**\r\n * loops lint failures and return pretty failure string ready to be printed\r\n *\r\n */\r\n private processLintFiles(): string[] {\r\n\r\n const options = this.options;\r\n\r\n // loop lint results\r\n let lintResultsFilesMessages =\r\n this.lintFileResult.map((fileResult: tslint.LintResult) => {\r\n let messages: string[] = [];\r\n if (fileResult.failures) {\r\n // we have a failure, lets check its failures\r\n messages = fileResult.failures.map((failure: any) => {\r\n\r\n // simplify it so its more readable later\r\n let r = {\r\n fileName: failure.fileName,\r\n line: failure.startPosition.lineAndCharacter.line,\r\n char: failure.startPosition.lineAndCharacter.character,\r\n ruleSeverity: failure.ruleSeverity.charAt(0).toUpperCase() + failure.ruleSeverity.slice(1),\r\n ruleName: failure.ruleName,\r\n failure: failure.failure\r\n };\r\n\r\n // make error pretty and return it\r\n let message = chalk.red('└── ');\r\n message += chalk[options.yellowOnLint ? 'yellow' : 'red'](`${r.fileName} (${r.line + 1},${r.char + 1}) `);\r\n message += chalk.white(`(${r.ruleSeverity}:`);\r\n message += chalk.white(`${r.ruleName})`);\r\n message += ' ' + r.failure;\r\n return message;\r\n });\r\n }\r\n // return messages\r\n return messages;\r\n\r\n }).filter((res: string[]) => {\r\n // filter our only messages with content\r\n return res.length === 0 ? false : true;\r\n });\r\n\r\n // flatten/concatenate lint files - > failures\r\n let lintErrorMessages: string[] = [];\r\n try {\r\n if (lintResultsFilesMessages.length) {\r\n lintErrorMessages = lintResultsFilesMessages.reduce((a: string[], b: string[]) => {\r\n return a.concat(b);\r\n });\r\n }\r\n } catch (err) {\r\n console.log(err);\r\n }\r\n\r\n return lintErrorMessages;\r\n }\r\n\r\n\r\n\r\n /**\r\n * loops ts failures and return pretty failure string ready to be printed\r\n *\r\n */\r\n private processTsDiagnostics(): string[] {\r\n\r\n const options = this.options;\r\n let tsErrorMessages: string[] = [];\r\n\r\n if (this.tsDiagnostics.length > 0) {\r\n tsErrorMessages = this.tsDiagnostics.map((diag: any) => {\r\n\r\n // get message type error, warn, info\r\n let message = chalk.red('└── ');\r\n\r\n // set color from options\r\n let color: string;\r\n switch (diag._type) {\r\n case 'options':\r\n color = options.yellowOnOptions ? 'yellow' : 'red';\r\n break;\r\n case 'global':\r\n color = options.yellowOnGlobal ? 'yellow' : 'red';\r\n break;\r\n case 'syntactic':\r\n color = options.yellowOnSyntactic ? 'yellow' : 'red';\r\n break;\r\n case 'semantic':\r\n color = options.yellowOnSemantic ? 'yellow' : 'red';\r\n break;\r\n default:\r\n color = 'red';\r\n }\r\n\r\n // if file\r\n if (diag.file) {\r\n const {\r\n line,\r\n character\r\n } = diag.file.getLineAndCharacterOfPosition(diag.start);\r\n\r\n message += chalk[color](`${diag.file.fileName} (${line + 1},${character + 1}) `);\r\n message += chalk.white(`(${ts.DiagnosticCategory[diag.category]}:`);\r\n message += chalk.white(`TS${diag.code})`);\r\n }\r\n\r\n // flatten error message\r\n message += ' ' + ts.flattenDiagnosticMessageText(diag.messageText, END_LINE);\r\n\r\n // return message\r\n return message;\r\n });\r\n }\r\n\r\n return tsErrorMessages;\r\n }\r\n\r\n\r\n}\r\n"],"sourceRoot":"src/"} \ No newline at end of file diff --git a/dist/commonjs/index.js b/dist/commonjs/index.js index 908942f..82ba007 100644 --- a/dist/commonjs/index.js +++ b/dist/commonjs/index.js @@ -1,3 +1,4 @@ +"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var child = require("child_process"); var path = require("path"); diff --git a/dist/commonjs/index.js.map b/dist/commonjs/index.js.map index 355de07..dd32dc5 100644 --- a/dist/commonjs/index.js.map +++ b/dist/commonjs/index.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";AAEA,qCAAuC;AACvC,2BAA6B;AAC7B,2CAAiI;AACjI,qCAAoC;AACpC,6BAA+B;AAC/B,+BAAiC;AACjC,6BAA+B;AAG/B;IASI,yBAAY,OAA4B;QACpC,IAAI,CAAC,OAAO,GAAG,IAAI,iBAAO,EAAE,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAGvB,IAAI,CAAC,OAAO,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;QACzG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,CAAI,IAAI,8BAAyB,KAAK,CAAC,KAAK,CAAC,KAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,GAAG,IAAM,CAAG,CAAC,CAAC,CAAC;QAG/G,IAAI,CAAC,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,GAAG,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,GAAG,EAAE,CAAC;QAGrE,IAAI,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;QACtC,IAAI,CAAC,OAAO,CAAC,WAAW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,CAAC,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,WAAW,CAAC,EAAE,EAAE,CAAC,CAAC;QAGhE,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,UAAC,GAAQ;YAE/B,EAAE,CAAC,CAAC,GAAG,KAAK,OAAO,CAAC,CAAC,CAAC;gBAGlB,KAAI,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAC;gBACpC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACpB,CAAC;YAAC,IAAI,CAAC,CAAC;gBAGJ,KAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;gBACjC,KAAI,CAAC,UAAU,EAAE,CAAC;YACtB,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IAQO,mCAAS,GAAjB,UAAkB,IAAY;QAC1B,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACvB,CAAC;IAQO,iCAAO,GAAf,UAAgB,OAAe;QAC3B,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,CAAC,CAAC;IACvH,CAAC;IAGL,sBAAC;AAAD,CA5RA,AA4RC,IAAA;AA5RY,0CAAe;AA+Rf,QAAA,UAAU,GAAG,UAAC,OAA4B;IACnD,MAAM,CAAC,IAAI,eAAe,CAAC,OAAO,CAAC,CAAC;AACxC,CAAC,CAAC","file":"index.js","sourcesContent":["// mostly a little from compiler API, gulp-typescript, tslint and a lot of failing :-)\r\n\r\nimport * as child from 'child_process';\r\nimport * as path from 'path';\r\nimport { ILintOptions, ITypeCheckerOptions, WorkerCommand, TypecheckerRunType, IInternalTypeCheckerOptions } from './interfaces';\r\nimport { Checker } from './checker';\r\nimport * as watch from 'watch';\r\nimport * as ts from 'typescript';\r\nimport * as chalk from 'chalk';\r\n\r\n\r\nexport class TypeHelperClass {\r\n private options: ITypeCheckerOptions;\r\n private worker: child.ChildProcess;\r\n private checker: Checker;\r\n private monitor: any;\r\n private watchTimeout: NodeJS.Timer;\r\n private isWorkerInspectPreformed: boolean;\r\n\r\n\r\n constructor(options: ITypeCheckerOptions) {\r\n this.checker = new Checker();\r\n this.options = options;\r\n\r\n // get/set base path\r\n this.options.basePath = options.basePath ? path.resolve(process.cwd(), options.basePath) : process.cwd();\r\n this.writeText(chalk.yellow(`${'\\n'}Typechecker basepath: ${chalk.white(`${this.options.basePath}${'\\n'}`)}`));\r\n\r\n // get name\r\n this.options.name = this.options.name ? ':' + this.options.name : '';\r\n\r\n // tslint options\r\n let lintOp = this.options.lintoptions;\r\n this.options.lintoptions = lintOp ? lintOp : ({} as ILintOptions);\r\n\r\n // fix tslint options so tslint do not complain\r\n this.options.lintoptions = {\r\n fix: this.options.lintoptions.fix || false, // <- this can be useful to have\r\n formatter: 'json',\r\n formattersDirectory: this.options.lintoptions.formattersDirectory || null,\r\n rulesDirectory: this.options.lintoptions.rulesDirectory || null\r\n };\r\n\r\n // get tsconfig path and options\r\n let tsconf = this.getPath(options.tsConfig);\r\n (this.options).tsConfigJsonContent = require(tsconf);\r\n this.writeText(chalk.yellow(`Typechecker tsconfig: ${chalk.white(`${tsconf}${'\\n'}`)}`));\r\n\r\n // get tslint path and options\r\n if (options.tsLint) {\r\n let tsLint = this.getPath(options.tsLint);\r\n this.writeText(chalk.yellow(`Typechecker tsLint: ${chalk.white(`${tsLint}${'\\n'}`)}`));\r\n }\r\n }\r\n\r\n\r\n\r\n /**\r\n * Runs in own thread/works and quits\r\n *\r\n */\r\n public runAsync(): void {\r\n\r\n // set options, add if it need to quit and run type\r\n let options: IInternalTypeCheckerOptions = Object.assign(this.options, { quit: true, type: TypecheckerRunType.async });\r\n\r\n // create thread\r\n this.createThread();\r\n\r\n // inspect our code\r\n this.inspectCodeWithWorker(options);\r\n\r\n // call worker\r\n this.printResultWithWorker();\r\n }\r\n\r\n\r\n /**\r\n * Runs in sync and quits\r\n * Returns total errors\r\n */\r\n public runSync(): number {\r\n\r\n // set options, add if it need to quit and run type\r\n let options: IInternalTypeCheckerOptions = Object.assign(this.options, { quit: true, type: TypecheckerRunType.sync });\r\n\r\n // inspect our code\r\n this.checker.inspectCode(options);\r\n\r\n // print result to screen and return total errors\r\n return this.checker.printResult();\r\n }\r\n\r\n\r\n /**\r\n * Runs in sync but return promise and callbacks and quits\r\n *\r\n */\r\n public runPromise(): Promise {\r\n\r\n // return promise so we can use it wrih then() or async/await\r\n return new Promise((resolve: Function, reject: Function) => {\r\n\r\n // wrap in try/catch so we can do reject if it fails\r\n try {\r\n\r\n // set options, add if it need to quit and run type\r\n let options: IInternalTypeCheckerOptions = Object.assign(this.options, { quit: true, type: TypecheckerRunType.promiseSync });\r\n\r\n // inspect our code\r\n this.checker.inspectCode(options);\r\n\r\n // print result to screen and return total errors\r\n let errors = this.checker.printResult();\r\n\r\n // return result\r\n resolve(errors);\r\n } catch (err) {\r\n reject(err);\r\n }\r\n });\r\n }\r\n\r\n\r\n\r\n /**\r\n * Creates thread/worker, starts watch on path and runs\r\n *\r\n */\r\n public runWatch(pathToWatch: string): void {\r\n\r\n // set options, add if it need to quit and run type\r\n let options: IInternalTypeCheckerOptions = Object.assign(this.options, { quit: false, type: TypecheckerRunType.watch });\r\n\r\n // const\r\n const write = this.writeText;\r\n const END_LINE = '\\n';\r\n\r\n // create thread and inspect code with worker\r\n this.createThread();\r\n this.inspectCodeWithWorker(options);\r\n\r\n // current basepath to watch\r\n let basePath = this.getPath(pathToWatch);\r\n\r\n watch.createMonitor(basePath, (monitor: any) => {\r\n\r\n // tell user what path we are watching\r\n write(chalk.yellow(`Typechecker watching: ${chalk.white(`${basePath}${END_LINE}`)}`));\r\n\r\n // on created file event\r\n monitor.on('created', (f: any /*, stat: any*/) => {\r\n write(END_LINE + chalk.yellow(`File created: ${f}${END_LINE}`));\r\n });\r\n\r\n // on changed file event\r\n monitor.on('changed', (f: any /*, curr: any, prev: any*/) => {\r\n\r\n // tell user about event\r\n write(END_LINE + chalk.yellow(`File changed: ${chalk.white(`${f}${END_LINE}`)}`));\r\n write(chalk.grey(`Calling typechecker${END_LINE}`));\r\n\r\n // have inside timeout, so we only run once when multible files are saved\r\n clearTimeout(this.watchTimeout);\r\n this.watchTimeout = setTimeout(() => {\r\n\r\n // inspect and print result\r\n this.inspectCodeWithWorker(options);\r\n this.printResultWithWorker();\r\n }, 500);\r\n\r\n });\r\n\r\n monitor.on('removed', (f: any /*, stat: any*/) => {\r\n\r\n // tell user about event\r\n write(END_LINE + chalk.yellow(`File removed: ${chalk.white(`${f}${END_LINE}`)}`));\r\n write(chalk.grey(`Calling typechecker${END_LINE}`));\r\n\r\n // have inside timeout, so we only run once when multible files are saved\r\n clearTimeout(this.watchTimeout);\r\n this.watchTimeout = setTimeout(() => {\r\n\r\n // inspect and print result\r\n this.inspectCodeWithWorker(options);\r\n this.printResultWithWorker();\r\n }, 500);\r\n\r\n });\r\n\r\n // set to class so we can stop it later if error is thrown\r\n this.monitor = monitor;\r\n });\r\n\r\n // print result, since its our first run\r\n this.printResultWithWorker();\r\n\r\n }\r\n\r\n\r\n /**\r\n * Kills worker and watch if started\r\n *\r\n */\r\n public killWorker(): void {\r\n if (this.worker) {\r\n this.worker.kill();\r\n }\r\n\r\n if (this.monitor) {\r\n this.monitor.stop();\r\n }\r\n }\r\n\r\n\r\n\r\n /**\r\n * Configure worker, internal function\r\n *\r\n */\r\n private inspectCodeWithWorker(options: ITypeCheckerOptions): void {\r\n this.worker.send({ type: WorkerCommand.inspectCode, options: options });\r\n\r\n // we set this so we can stop worker print from trying to run\r\n this.isWorkerInspectPreformed = true;\r\n }\r\n\r\n\r\n\r\n /**\r\n * Tells worker to do a typecheck\r\n *\r\n */\r\n private printResultWithWorker(): void {\r\n\r\n // have we inspected code?\r\n if (this.isWorkerInspectPreformed) {\r\n\r\n // all well, lets preform printout\r\n this.worker.send({ type: WorkerCommand.printResult });\r\n } else {\r\n this.writeText('You can not run pront before you have inspected code first');\r\n }\r\n }\r\n\r\n\r\n\r\n\r\n /**\r\n * Creates thread/worker\r\n *\r\n */\r\n private createThread(): void {\r\n\r\n // create worker fork\r\n this.worker = child.fork(path.join(__dirname, 'worker.js'), []);\r\n\r\n // listen for worker messages\r\n this.worker.on('message', (err: any) => {\r\n\r\n if (err === 'error') {\r\n\r\n // if error then exit\r\n this.writeText('error typechecker');\r\n process.exit(1);\r\n } else {\r\n\r\n // if not error, then just kill worker\r\n this.writeText('killing worker');\r\n this.killWorker();\r\n }\r\n });\r\n }\r\n\r\n\r\n\r\n /**\r\n * Helper to write to cmd\r\n *\r\n */\r\n private writeText(text: string): void {\r\n ts.sys.write(text);\r\n }\r\n\r\n\r\n\r\n /**\r\n * gets path based on basepath being set\r\n *\r\n */\r\n private getPath(usePath: string): string {\r\n return this.options.basePath ? path.resolve(this.options.basePath, usePath) : path.resolve(process.cwd(), usePath);\r\n }\r\n\r\n\r\n}\r\n\r\n// return new typechecker\r\nexport const TypeHelper = (options: ITypeCheckerOptions): TypeHelperClass => {\r\n return new TypeHelperClass(options);\r\n};\r\n\r\n"],"sourceRoot":"src/"} \ No newline at end of file +{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;AAEA,qCAAuC;AACvC,2BAA6B;AAC7B,2CAAiI;AACjI,qCAAoC;AACpC,6BAA+B;AAC/B,+BAAiC;AACjC,6BAA+B;AAG/B;IASI,yBAAY,OAA4B;QACpC,IAAI,CAAC,OAAO,GAAG,IAAI,iBAAO,EAAE,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAGvB,IAAI,CAAC,OAAO,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,CAA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AAO,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,CAAC,CAAC;IACvH,CAAC;IAGL,sBAAC;AAAD,CA5RA,AA4RC,IAAA;AA5RY,0CAAe;AA+Rf,QAAA,UAAU,GAAG,UAAC,OAA4B;IACnD,MAAM,CAAC,IAAI,eAAe,CAAC,OAAO,CAAC,CAAC;AACxC,CAAC,CAAC","file":"index.js","sourcesContent":["// mostly a little from compiler API, gulp-typescript, tslint and a lot of failing :-)\r\n\r\nimport * as child from 'child_process';\r\nimport * as path from 'path';\r\nimport { ILintOptions, ITypeCheckerOptions, WorkerCommand, TypecheckerRunType, IInternalTypeCheckerOptions } from './interfaces';\r\nimport { Checker } from './checker';\r\nimport * as watch from 'watch';\r\nimport * as ts from 'typescript';\r\nimport * as chalk from 'chalk';\r\n\r\n\r\nexport class TypeHelperClass {\r\n private options: ITypeCheckerOptions;\r\n private worker: child.ChildProcess;\r\n private checker: Checker;\r\n private monitor: any;\r\n private watchTimeout: NodeJS.Timer;\r\n private isWorkerInspectPreformed: boolean;\r\n\r\n\r\n constructor(options: ITypeCheckerOptions) {\r\n this.checker = new Checker();\r\n this.options = options;\r\n\r\n // get/set base path\r\n this.options.basePath = options.basePath ? path.resolve(process.cwd(), options.basePath) : process.cwd();\r\n this.writeText(chalk.yellow(`${'\\n'}Typechecker basepath: ${chalk.white(`${this.options.basePath}${'\\n'}`)}`));\r\n\r\n // get name\r\n this.options.name = this.options.name ? ':' + this.options.name : '';\r\n\r\n // tslint options\r\n let lintOp = this.options.lintoptions;\r\n this.options.lintoptions = lintOp ? lintOp : ({} as ILintOptions);\r\n\r\n // fix tslint options so tslint do not complain\r\n this.options.lintoptions = {\r\n fix: this.options.lintoptions.fix || false, // <- this can be useful to have\r\n formatter: 'json',\r\n formattersDirectory: this.options.lintoptions.formattersDirectory || null,\r\n rulesDirectory: this.options.lintoptions.rulesDirectory || null\r\n };\r\n\r\n // get tsconfig path and options\r\n let tsconf = this.getPath(options.tsConfig);\r\n (this.options).tsConfigJsonContent = require(tsconf);\r\n this.writeText(chalk.yellow(`Typechecker tsconfig: ${chalk.white(`${tsconf}${'\\n'}`)}`));\r\n\r\n // get tslint path and options\r\n if (options.tsLint) {\r\n let tsLint = this.getPath(options.tsLint);\r\n this.writeText(chalk.yellow(`Typechecker tsLint: ${chalk.white(`${tsLint}${'\\n'}`)}`));\r\n }\r\n }\r\n\r\n\r\n\r\n /**\r\n * Runs in own thread/works and quits\r\n *\r\n */\r\n public runAsync(): void {\r\n\r\n // set options, add if it need to quit and run type\r\n let options: IInternalTypeCheckerOptions = Object.assign(this.options, { quit: true, type: TypecheckerRunType.async });\r\n\r\n // create thread\r\n this.createThread();\r\n\r\n // inspect our code\r\n this.inspectCodeWithWorker(options);\r\n\r\n // call worker\r\n this.printResultWithWorker();\r\n }\r\n\r\n\r\n /**\r\n * Runs in sync and quits\r\n * Returns total errors\r\n */\r\n public runSync(): number {\r\n\r\n // set options, add if it need to quit and run type\r\n let options: IInternalTypeCheckerOptions = Object.assign(this.options, { quit: true, type: TypecheckerRunType.sync });\r\n\r\n // inspect our code\r\n this.checker.inspectCode(options);\r\n\r\n // print result to screen and return total errors\r\n return this.checker.printResult();\r\n }\r\n\r\n\r\n /**\r\n * Runs in sync but return promise and callbacks and quits\r\n *\r\n */\r\n public runPromise(): Promise {\r\n\r\n // return promise so we can use it wrih then() or async/await\r\n return new Promise((resolve: Function, reject: Function) => {\r\n\r\n // wrap in try/catch so we can do reject if it fails\r\n try {\r\n\r\n // set options, add if it need to quit and run type\r\n let options: IInternalTypeCheckerOptions = Object.assign(this.options, { quit: true, type: TypecheckerRunType.promiseSync });\r\n\r\n // inspect our code\r\n this.checker.inspectCode(options);\r\n\r\n // print result to screen and return total errors\r\n let errors = this.checker.printResult();\r\n\r\n // return result\r\n resolve(errors);\r\n } catch (err) {\r\n reject(err);\r\n }\r\n });\r\n }\r\n\r\n\r\n\r\n /**\r\n * Creates thread/worker, starts watch on path and runs\r\n *\r\n */\r\n public runWatch(pathToWatch: string): void {\r\n\r\n // set options, add if it need to quit and run type\r\n let options: IInternalTypeCheckerOptions = Object.assign(this.options, { quit: false, type: TypecheckerRunType.watch });\r\n\r\n // const\r\n const write = this.writeText;\r\n const END_LINE = '\\n';\r\n\r\n // create thread and inspect code with worker\r\n this.createThread();\r\n this.inspectCodeWithWorker(options);\r\n\r\n // current basepath to watch\r\n let basePath = this.getPath(pathToWatch);\r\n\r\n watch.createMonitor(basePath, (monitor: any) => {\r\n\r\n // tell user what path we are watching\r\n write(chalk.yellow(`Typechecker watching: ${chalk.white(`${basePath}${END_LINE}`)}`));\r\n\r\n // on created file event\r\n monitor.on('created', (f: any /*, stat: any*/) => {\r\n write(END_LINE + chalk.yellow(`File created: ${f}${END_LINE}`));\r\n });\r\n\r\n // on changed file event\r\n monitor.on('changed', (f: any /*, curr: any, prev: any*/) => {\r\n\r\n // tell user about event\r\n write(END_LINE + chalk.yellow(`File changed: ${chalk.white(`${f}${END_LINE}`)}`));\r\n write(chalk.grey(`Calling typechecker${END_LINE}`));\r\n\r\n // have inside timeout, so we only run once when multible files are saved\r\n clearTimeout(this.watchTimeout);\r\n this.watchTimeout = setTimeout(() => {\r\n\r\n // inspect and print result\r\n this.inspectCodeWithWorker(options);\r\n this.printResultWithWorker();\r\n }, 500);\r\n\r\n });\r\n\r\n monitor.on('removed', (f: any /*, stat: any*/) => {\r\n\r\n // tell user about event\r\n write(END_LINE + chalk.yellow(`File removed: ${chalk.white(`${f}${END_LINE}`)}`));\r\n write(chalk.grey(`Calling typechecker${END_LINE}`));\r\n\r\n // have inside timeout, so we only run once when multible files are saved\r\n clearTimeout(this.watchTimeout);\r\n this.watchTimeout = setTimeout(() => {\r\n\r\n // inspect and print result\r\n this.inspectCodeWithWorker(options);\r\n this.printResultWithWorker();\r\n }, 500);\r\n\r\n });\r\n\r\n // set to class so we can stop it later if error is thrown\r\n this.monitor = monitor;\r\n });\r\n\r\n // print result, since its our first run\r\n this.printResultWithWorker();\r\n\r\n }\r\n\r\n\r\n /**\r\n * Kills worker and watch if started\r\n *\r\n */\r\n public killWorker(): void {\r\n if (this.worker) {\r\n this.worker.kill();\r\n }\r\n\r\n if (this.monitor) {\r\n this.monitor.stop();\r\n }\r\n }\r\n\r\n\r\n\r\n /**\r\n * Configure worker, internal function\r\n *\r\n */\r\n private inspectCodeWithWorker(options: ITypeCheckerOptions): void {\r\n this.worker.send({ type: WorkerCommand.inspectCode, options: options });\r\n\r\n // we set this so we can stop worker print from trying to run\r\n this.isWorkerInspectPreformed = true;\r\n }\r\n\r\n\r\n\r\n /**\r\n * Tells worker to do a typecheck\r\n *\r\n */\r\n private printResultWithWorker(): void {\r\n\r\n // have we inspected code?\r\n if (this.isWorkerInspectPreformed) {\r\n\r\n // all well, lets preform printout\r\n this.worker.send({ type: WorkerCommand.printResult });\r\n } else {\r\n this.writeText('You can not run pront before you have inspected code first');\r\n }\r\n }\r\n\r\n\r\n\r\n\r\n /**\r\n * Creates thread/worker\r\n *\r\n */\r\n private createThread(): void {\r\n\r\n // create worker fork\r\n this.worker = child.fork(path.join(__dirname, 'worker.js'), []);\r\n\r\n // listen for worker messages\r\n this.worker.on('message', (err: any) => {\r\n\r\n if (err === 'error') {\r\n\r\n // if error then exit\r\n this.writeText('error typechecker');\r\n process.exit(1);\r\n } else {\r\n\r\n // if not error, then just kill worker\r\n this.writeText('killing worker');\r\n this.killWorker();\r\n }\r\n });\r\n }\r\n\r\n\r\n\r\n /**\r\n * Helper to write to cmd\r\n *\r\n */\r\n private writeText(text: string): void {\r\n ts.sys.write(text);\r\n }\r\n\r\n\r\n\r\n /**\r\n * gets path based on basepath being set\r\n *\r\n */\r\n private getPath(usePath: string): string {\r\n return this.options.basePath ? path.resolve(this.options.basePath, usePath) : path.resolve(process.cwd(), usePath);\r\n }\r\n\r\n\r\n}\r\n\r\n// return new typechecker\r\nexport const TypeHelper = (options: ITypeCheckerOptions): TypeHelperClass => {\r\n return new TypeHelperClass(options);\r\n};\r\n\r\n"],"sourceRoot":"src/"} \ No newline at end of file diff --git a/dist/commonjs/interfaces.js b/dist/commonjs/interfaces.js index f7ba100..59d33e2 100644 --- a/dist/commonjs/interfaces.js +++ b/dist/commonjs/interfaces.js @@ -1,3 +1,4 @@ +"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var WorkerCommand; (function (WorkerCommand) { diff --git a/dist/commonjs/interfaces.js.map b/dist/commonjs/interfaces.js.map index dfe5dbf..97dca85 100644 --- a/dist/commonjs/interfaces.js.map +++ b/dist/commonjs/interfaces.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/interfaces.ts"],"names":[],"mappings":";AAwDA,IAAY,aAGX;AAHD,WAAY,aAAa;IACrB,+DAAW,CAAA;IACX,+DAAW,CAAA;AACf,CAAC,EAHW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAGxB;AAKD,IAAY,kBAKX;AALD,WAAY,kBAAkB;IAC1B,gDAAO,MAAa,UAAA,CAAA;IACpB,iDAAQ,OAAe,WAAA,CAAA;IACvB,iDAAQ,OAAe,WAAA,CAAA;IACvB,uDAAc,aAAqB,iBAAA,CAAA;AACvC,CAAC,EALW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAK7B;AAEY,QAAA,QAAQ,GAAG,IAAI,CAAC","file":"interfaces.js","sourcesContent":["\r\n// options they can use to create the typechecker\r\nexport interface ITypeCheckerOptions {\r\n // base path\r\n basePath: string;\r\n\r\n // path to tsconfig file (from basepath)\r\n tsConfig: string;\r\n\r\n // throw options\r\n throwOnSyntactic?: boolean;\r\n throwOnSemantic?: boolean;\r\n throwOnTsLint?: boolean;\r\n throwOnGlobal?: boolean;\r\n throwOnOptions?: boolean;\r\n\r\n // color options\r\n yellowOnLint?: boolean;\r\n yellowOnOptions?: boolean;\r\n yellowOnGlobal?: boolean;\r\n yellowOnSemantic?: boolean;\r\n yellowOnSyntactic?: boolean;\r\n\r\n // path to tslint json (from basepath)\r\n tsLint?: string;\r\n\r\n // name that will be displayed on cmd echo\r\n name?: string;\r\n\r\n // lint options that can be passed in\r\n // todo: rename to lintOptions, but thats a breaking change, so will do that later\r\n lintoptions?: ILintOptions;\r\n}\r\n\r\n// lint options,this is the same as tsLint uses all paths will be from basepath\r\nexport interface ILintOptions {\r\n fix?: boolean;\r\n formatter?: string;\r\n formattersDirectory?: string | null;\r\n rulesDirectory?: string | null;\r\n}\r\n\r\n// extended internal options, needed for some interal usage\r\nexport interface IInternalTypeCheckerOptions extends ITypeCheckerOptions {\r\n type: TypecheckerRunType;\r\n tsConfigJsonContent?: any;\r\n quit?: boolean;\r\n}\r\n\r\n// params used when calling worker to tell it what to do\r\nexport interface IWorkerOptions {\r\n type: WorkerCommand;\r\n options?: IInternalTypeCheckerOptions;\r\n}\r\n\r\n// run options for worker\r\nexport enum WorkerCommand {\r\n inspectCode,\r\n printResult\r\n}\r\n\r\n\r\n\r\n// checkers run types (when generating cmd print)\r\nexport enum TypecheckerRunType {\r\n sync = 'syns' as any,\r\n async = 'async' as any,\r\n watch = 'watch' as any,\r\n promiseSync = 'promisesync' as any\r\n}\r\n\r\nexport const END_LINE = '\\n';\r\n"],"sourceRoot":"src/"} \ No newline at end of file +{"version":3,"sources":["../src/interfaces.ts"],"names":[],"mappings":";;AAwDA,IAAY,aAGX;AAHD,WAAY,aAAa;IACrB,+DAAW,CAAA;IACX,+DAAW,CAAA;AACf,CAAC,EAHW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAGxB;AAKD,IAAY,kBAKX;AALD,WAAY,kBAAkB;IAC1B,gDAAO,MAAa,UAAA,CAAA;IACpB,iDAAQ,OAAe,WAAA,CAAA;IACvB,iDAAQ,OAAe,WAAA,CAAA;IACvB,uDAAc,aAAqB,iBAAA,CAAA;AACvC,CAAC,EALW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAK7B;AAEY,QAAA,QAAQ,GAAG,IAAI,CAAC","file":"interfaces.js","sourcesContent":["\r\n// options they can use to create the typechecker\r\nexport interface ITypeCheckerOptions {\r\n // base path\r\n basePath: string;\r\n\r\n // path to tsconfig file (from basepath)\r\n tsConfig: string;\r\n\r\n // throw options\r\n throwOnSyntactic?: boolean;\r\n throwOnSemantic?: boolean;\r\n throwOnTsLint?: boolean;\r\n throwOnGlobal?: boolean;\r\n throwOnOptions?: boolean;\r\n\r\n // color options\r\n yellowOnLint?: boolean;\r\n yellowOnOptions?: boolean;\r\n yellowOnGlobal?: boolean;\r\n yellowOnSemantic?: boolean;\r\n yellowOnSyntactic?: boolean;\r\n\r\n // path to tslint json (from basepath)\r\n tsLint?: string;\r\n\r\n // name that will be displayed on cmd echo\r\n name?: string;\r\n\r\n // lint options that can be passed in\r\n // todo: rename to lintOptions, but thats a breaking change, so will do that later\r\n lintoptions?: ILintOptions;\r\n}\r\n\r\n// lint options,this is the same as tsLint uses all paths will be from basepath\r\nexport interface ILintOptions {\r\n fix?: boolean;\r\n formatter?: string;\r\n formattersDirectory?: string | null;\r\n rulesDirectory?: string | null;\r\n}\r\n\r\n// extended internal options, needed for some interal usage\r\nexport interface IInternalTypeCheckerOptions extends ITypeCheckerOptions {\r\n type: TypecheckerRunType;\r\n tsConfigJsonContent?: any;\r\n quit?: boolean;\r\n}\r\n\r\n// params used when calling worker to tell it what to do\r\nexport interface IWorkerOptions {\r\n type: WorkerCommand;\r\n options?: IInternalTypeCheckerOptions;\r\n}\r\n\r\n// run options for worker\r\nexport enum WorkerCommand {\r\n inspectCode,\r\n printResult\r\n}\r\n\r\n\r\n\r\n// checkers run types (when generating cmd print)\r\nexport enum TypecheckerRunType {\r\n sync = 'syns' as any,\r\n async = 'async' as any,\r\n watch = 'watch' as any,\r\n promiseSync = 'promisesync' as any\r\n}\r\n\r\nexport const END_LINE = '\\n';\r\n"],"sourceRoot":"src/"} \ No newline at end of file diff --git a/dist/commonjs/test.js b/dist/commonjs/test.js index 22890ff..9f18884 100644 --- a/dist/commonjs/test.js +++ b/dist/commonjs/test.js @@ -1,3 +1,3 @@ - +"use strict"; //# sourceMappingURL=test.js.map diff --git a/dist/commonjs/worker.js b/dist/commonjs/worker.js index ca97088..a699efb 100644 --- a/dist/commonjs/worker.js +++ b/dist/commonjs/worker.js @@ -1,3 +1,4 @@ +"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var checker_1 = require("./checker"); var interfaces_1 = require("./interfaces"); diff --git a/dist/commonjs/worker.js.map b/dist/commonjs/worker.js.map index ac1f0ff..58517bd 100644 --- a/dist/commonjs/worker.js.map +++ b/dist/commonjs/worker.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/worker.ts"],"names":[],"mappings":";AACA,qCAAoC;AACpC,2CAA6D;AAG7D,IAAI,OAAO,GAAG,IAAI,iBAAO,EAAE,CAAC;AAG5B,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,UAAU,GAAmB;IAC/C,MAAM,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;QAGf,KAAK,0BAAa,CAAC,WAAW;YAC1B,EAAE,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;gBACd,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YACrC,CAAC;YAAC,IAAI,CAAC,CAAC;gBACJ,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;YACzE,CAAC;YAED,KAAK,CAAC;QAGV,KAAK,0BAAa,CAAC,WAAW;YAC1B,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;YAC1B,KAAK,CAAC;IACd,CAAC;AACL,CAAC,CAAC,CAAC","file":"worker.js","sourcesContent":["// typechecker\r\nimport { Checker } from './checker';\r\nimport { WorkerCommand, IWorkerOptions } from './interfaces';\r\n\r\n// create checker instance\r\nlet checker = new Checker();\r\n\r\n// listen for messages\r\nprocess.on('message', function (msg: IWorkerOptions) {\r\n switch (msg.type) {\r\n\r\n // tell checker to inspect code\r\n case WorkerCommand.inspectCode:\r\n if (msg.options) {\r\n checker.inspectCode(msg.options);\r\n } else {\r\n throw new Error('You tried to inspect code without ts/lint options');\r\n }\r\n\r\n break;\r\n\r\n // tell checker to print result\r\n case WorkerCommand.printResult:\r\n checker.printResult(true);\r\n break;\r\n }\r\n});\r\n"],"sourceRoot":"src/"} \ No newline at end of file +{"version":3,"sources":["../src/worker.ts"],"names":[],"mappings":";;AACA,qCAAoC;AACpC,2CAA6D;AAG7D,IAAI,OAAO,GAAG,IAAI,iBAAO,EAAE,CAAC;AAG5B,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,UAAU,GAAmB;IAC/C,MAAM,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;QAGf,KAAK,0BAAa,CAAC,WAAW;YAC1B,EAAE,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;gBACd,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YACrC,CAAC;YAAC,IAAI,CAAC,CAAC;gBACJ,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;YACzE,CAAC;YAED,KAAK,CAAC;QAGV,KAAK,0BAAa,CAAC,WAAW;YAC1B,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;YAC1B,KAAK,CAAC;IACd,CAAC;AACL,CAAC,CAAC,CAAC","file":"worker.js","sourcesContent":["// typechecker\r\nimport { Checker } from './checker';\r\nimport { WorkerCommand, IWorkerOptions } from './interfaces';\r\n\r\n// create checker instance\r\nlet checker = new Checker();\r\n\r\n// listen for messages\r\nprocess.on('message', function (msg: IWorkerOptions) {\r\n switch (msg.type) {\r\n\r\n // tell checker to inspect code\r\n case WorkerCommand.inspectCode:\r\n if (msg.options) {\r\n checker.inspectCode(msg.options);\r\n } else {\r\n throw new Error('You tried to inspect code without ts/lint options');\r\n }\r\n\r\n break;\r\n\r\n // tell checker to print result\r\n case WorkerCommand.printResult:\r\n checker.printResult(true);\r\n break;\r\n }\r\n});\r\n"],"sourceRoot":"src/"} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 6555d0f..1cc07bc 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,20 +9,22 @@ "declaration": true, "noImplicitAny": true, "noImplicitReturns": true, - "noImplicitUseStrict": true, "noUnusedParameters": true, "suppressImplicitAnyIndexErrors": true, "noFallthroughCasesInSwitch": true, + "forceConsistentCasingInFileNames": true, "strictNullChecks": true, + "alwaysStrict": true, "noImplicitThis": false, "noUnusedLocals": true, - "allowUnreachableCode":false, + "allowUnusedLabels": false, + "allowUnreachableCode": false, "removeComments": true, "emitDecoratorMetadata": true, - "preserveConstEnums":true, + "preserveConstEnums": true, "experimentalDecorators": true, "moduleResolution": "node", - "lib": ["es2015","es2017", "dom"] + "lib": ["es2015", "es2017", "dom"] }, "filesGlob": [ "./src/**/*.ts", @@ -34,4 +36,4 @@ "atom": { "rewriteTsconfig": false } -} +} \ No newline at end of file