@ioffice/tc-builder
Advanced tools
Comparing version 1.2.0 to 1.2.1-beta.1805041405
@@ -12,5 +12,7 @@ import { TypedObject, ExitCode, IProjectResults, IProjectStatus, IFileMessages } from './Interfaces'; | ||
* @param {boolean} verbose Provide if progress bars are desired | ||
* @param {TypedObject<number>} messageMap specifies what messages are allowed | ||
* @param {boolean} ci Continuous Integration flag | ||
* @return {number} Non-zero if there is a failure | ||
*/ | ||
declare function compileCLI(tsconfigPath: string, tslintPath?: string, verbose?: boolean, messageMap?: TypedObject<number>): ExitCode; | ||
declare function compileCLI(tsconfigPath: string, tslintPath?: string, verbose?: boolean, messageMap?: TypedObject<number>, ci?: boolean): ExitCode; | ||
/** | ||
@@ -17,0 +19,0 @@ * Process the project results along with the message map containing the allowed number of messages |
@@ -178,6 +178,9 @@ "use strict"; | ||
* @param {boolean} verbose Provide if progress bars are desired | ||
* @param {TypedObject<number>} messageMap specifies what messages are allowed | ||
* @param {boolean} ci Continuous Integration flag | ||
* @return {number} Non-zero if there is a failure | ||
*/ | ||
function compileCLI(tsconfigPath, tslintPath, verbose, messageMap) { | ||
function compileCLI(tsconfigPath, tslintPath, verbose, messageMap, ci) { | ||
if (messageMap === void 0) { messageMap = {}; } | ||
if (ci === void 0) { ci = false; } | ||
var projectResults; | ||
@@ -194,3 +197,3 @@ try { | ||
if (projectStatus.status !== Interfaces_1.ExitCode.OK) { | ||
process.stderr.write(Formatter_1.formatProjectResults(projectStatus, projectResults)); | ||
process.stderr.write(Formatter_1.formatProjectResults(projectStatus, projectResults, ci)); | ||
} | ||
@@ -211,2 +214,3 @@ return projectStatus.status; | ||
var failureStatus = { | ||
needsReadjustment: false, | ||
errorException: false, | ||
@@ -223,2 +227,4 @@ warningException: false, | ||
var failed = message.count > messageMap[type]; | ||
var needsReadjustment = message.count < messageMap[type]; | ||
failureStatus.needsReadjustment = failureStatus.needsReadjustment || needsReadjustment; | ||
if (message.references[0].message.category === 'error') { | ||
@@ -251,4 +257,7 @@ failureStatus.errorCounter -= message.count; | ||
} | ||
else if (failureStatus.needsReadjustment) { | ||
exceptionsResults.status = Interfaces_1.ExitCode.NEEDS_READJUSTMENT; | ||
} | ||
return exceptionsResults; | ||
} | ||
exports.getProjectStatus = getProjectStatus; |
import { TypedObject, IFileMessages, IProjectStatus, IProjectResults } from './Interfaces'; | ||
declare function formatResults(results: TypedObject<IFileMessages>): string; | ||
declare function formatProjectResults(projectStatus: IProjectStatus, projectResults: IProjectResults): string; | ||
declare function formatProjectResults(projectStatus: IProjectStatus, projectResults: IProjectResults, ci?: boolean, ciLimit?: number): string; | ||
export { formatResults, formatProjectResults }; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var Interfaces_1 = require("./Interfaces"); | ||
var colors = require("colors"); | ||
function align(msg, alignment, size) { | ||
var repeatNumber = Math.max(size - msg.length, 0); | ||
if (alignment === 'l') { | ||
return msg + ' '.repeat(size - msg.length); | ||
return msg + ' '.repeat(repeatNumber); | ||
} | ||
return ' '.repeat(size - msg.length) + msg; | ||
return ' '.repeat(repeatNumber) + msg; | ||
} | ||
@@ -114,2 +116,3 @@ function breakMsg(msg, size) { | ||
var failed = msg[0]; | ||
var warn = msg[2] < msg[3]; | ||
buf.push(' '); | ||
@@ -121,2 +124,5 @@ buf.push(failed ? '✗'.red : '✓'.green); | ||
} | ||
else if (warn) { | ||
buf.push(align(msg[1], 'l', size).yellow); | ||
} | ||
else { | ||
@@ -129,2 +135,5 @@ buf.push(align(msg[1], 'l', size).green); | ||
} | ||
else if (warn) { | ||
buf.push(msg[2].toString().green + " found, " + msg[3].toString().yellow + " allowed\n"); | ||
} | ||
else { | ||
@@ -148,5 +157,39 @@ buf.push((msg[2] + " found, " + msg[3] + " allowed\n").gray); | ||
} | ||
function formatProjectResults(projectStatus, projectResults) { | ||
function formatCIResults(byMessage, listLimit) { | ||
if (listLimit === void 0) { listLimit = 5; } | ||
var buffer = []; | ||
var allMessages = formatResults(projectResults.results); | ||
var msgTypes = Object.keys(byMessage).sort(); | ||
msgTypes.forEach(function (msgType) { | ||
var obj = byMessage[msgType]; | ||
var numMessages = obj.count; | ||
if (!numMessages) { | ||
return; | ||
} | ||
var messageInfo = numMessages + " " + msgType; | ||
buffer.push("\n" + messageInfo.magenta + ":\n"); | ||
buffer.push('\n'); | ||
var fileNames = obj.references.map(function (x) { return x.fileInfo.absPath; }); | ||
var uniqueFileNames = Array.from(new Set(fileNames)); | ||
var totalRefs = Math.min(listLimit, uniqueFileNames.length); | ||
var refs = uniqueFileNames.slice(0, totalRefs); | ||
refs.forEach(function (msg) { | ||
buffer.push(" - " + msg + "\n"); | ||
}); | ||
if (totalRefs < uniqueFileNames.length) { | ||
buffer.push(' ...\n'); | ||
} | ||
}); | ||
return buffer.join(''); | ||
} | ||
function formatProjectResults(projectStatus, projectResults, ci, ciLimit) { | ||
if (ci === void 0) { ci = false; } | ||
if (ciLimit === void 0) { ciLimit = 10; } | ||
var buffer = []; | ||
var allMessages = ''; | ||
if (!ci || projectResults.numMessages < ciLimit) { | ||
allMessages = formatResults(projectResults.results); | ||
} | ||
else { | ||
allMessages = formatCIResults(projectResults.byMessage); | ||
} | ||
var types = Object.keys(projectStatus.exceptions).sort(); | ||
@@ -169,4 +212,7 @@ var messages = []; | ||
buffer.length = 0; | ||
if (projectStatus.status === Interfaces_1.ExitCode.NEEDS_READJUSTMENT) { | ||
return exceptions + "\n\nPlease update 'package.json' to save our progress.\n"; | ||
} | ||
return allMessages + "\n\n" + statsMsg + "\n\n" + exceptions; | ||
} | ||
exports.formatProjectResults = formatProjectResults; |
@@ -12,2 +12,3 @@ declare type MessageCategory = 'error' | 'warning' | 'info' | 'log' | 'debug'; | ||
NODE_ERROR = 5, | ||
NEEDS_READJUSTMENT = 6, | ||
} | ||
@@ -14,0 +15,0 @@ interface ITSMessage { |
@@ -11,4 +11,4 @@ "use strict"; | ||
ExitCode[ExitCode["NODE_ERROR"] = 5] = "NODE_ERROR"; | ||
ExitCode[ExitCode["NEEDS_READJUSTMENT"] = 6] = "NEEDS_READJUSTMENT"; | ||
})(ExitCode || (ExitCode = {})); | ||
exports.ExitCode = ExitCode; | ||
; |
{ | ||
"name": "@ioffice/tc-builder", | ||
"version": "1.2.0", | ||
"version": "1.2.1-beta.1805041405", | ||
"description": "iOFFICE TeamCity Builder", | ||
@@ -20,3 +20,3 @@ "main": "index.js", | ||
"devDependencies": { | ||
"@ioffice/tslint-config-ioffice": "^0.0.1-beta.1804251410", | ||
"@ioffice/tslint-config-ioffice": "0.2.0", | ||
"@types/chai": "4.1.2", | ||
@@ -23,0 +23,0 @@ "@types/mocha": "2.2.48", |
@@ -8,8 +8,8 @@ #!/usr/bin/env node | ||
var commands = ['setup', 'compile', 'run']; | ||
var options = ['--no-lint', '--verbose', '--help', '-h', '--version', '-v', '-f']; | ||
var options = ['--no-lint', '--verbose', '--help', '-h', '--version', '-v', '--ci']; | ||
var _a = commands.map(function (x) { return process.argv.indexOf(x) > -1; }), setup = _a[0], compile = _a[1], run = _a[2]; | ||
var _b = options.map(function (x) { return process.argv.indexOf(x) > -1; }), noLint = _b[0], verbose = _b[1], help = _b[2], h = _b[3], version = _b[4], v = _b[5]; | ||
var _b = options.map(function (x) { return process.argv.indexOf(x) > -1; }), noLint = _b[0], verbose = _b[1], help = _b[2], h = _b[3], version = _b[4], v = _b[5], ci = _b[6]; | ||
var pkg = Util_1.readJSON('./package.json', __dirname) || {}; | ||
var pkgVersion = pkg['version']; | ||
var usage = "usage: tc-builder <command> [--options]\n\nThe following commands are supported:\n\n - setup: Installs all the same dependencies as the ones in the tc-builder and creates\n configuration files if they do not exists. This command should be run when starting\n a new project or updating tc-builder.\n\n If there are any new updates to the configuration files and you wish to see them you\n can provide the name of the file right after the command.\n - compile: Looks at the 'tsconfig.json' file to compile the project. By default it will also\n lint the files unless we use the '--no-lint' option.\n - run: Main command to be run in team city. It will make sure to run all the tests and publish\n to npm if necessary.\n\nOptions:\n\n --no-lint: Skip linting.\n --verbose: Print messages of the steps for the 'compile' command.\n --help, -h: Print this message.\n --version, -v: Print the version.\n\ntc-builder@" + pkgVersion + "\n"; | ||
var usage = "usage: tc-builder <command> [--options]\n\nThe following commands are supported:\n\n - setup: Installs all the same dependencies as the ones in the tc-builder and creates\n configuration files if they do not exists. This command should be run when starting\n a new project or updating tc-builder.\n\n If there are any new updates to the configuration files and you wish to see them you\n can provide the name of the file right after the command.\n - compile: Looks at the 'tsconfig.json' file to compile the project. By default it will also\n lint the files unless we use the '--no-lint' option.\n - run: Main command to be run in team city. It will make sure to run all the tests and publish\n to npm if necessary.\n\nOptions:\n\n --no-lint: Skip linting.\n --verbose: Print messages of the steps for the 'compile' command.\n --ci: Continous Integration flag, minimizes the output in case there are too many errors.\n --help, -h: Print this message.\n --version, -v: Print the version.\n\ntc-builder@" + pkgVersion + "\n"; | ||
var exitNumber = 0; | ||
@@ -50,5 +50,5 @@ if (help || h) { | ||
var projectPkg = Util_1.readJSON('./package.json', '.'); | ||
var tcBuilderOptions = projectPkg ? projectPkg['tcBuilder'] : {}; | ||
var tcBuilderOptions = projectPkg ? projectPkg['tcBuilder'] || {} : {}; | ||
var messageMap = tcBuilderOptions['allowed'] || {}; | ||
exitNumber = compileCLI('tsconfig.json', noLint ? '' : './tslint.json', verbose, messageMap); | ||
exitNumber = compileCLI('tsconfig.json', noLint ? '' : './tslint.json', verbose, messageMap, ci); | ||
} | ||
@@ -55,0 +55,0 @@ else if (run) { |
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
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
63223
1473
2
8