@ioffice/tc-builder
Advanced tools
Comparing version 1.2.1 to 1.3.0-beta.1806070241
@@ -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 |
@@ -139,3 +139,3 @@ "use strict"; | ||
var program = ts.createProgram(parsed.fileNames, parsed.options, host); | ||
var results = compile(program, project.config.compilerOptions || {}, tsLintConfigPath || './tslint.json', verbose); | ||
var results = compile(program, project.config.compilerOptions || {}, tsLintConfigPath, verbose); | ||
var output = { | ||
@@ -179,6 +179,9 @@ results: results, | ||
* @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; | ||
@@ -195,3 +198,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)); | ||
} | ||
@@ -212,2 +215,3 @@ return projectStatus.status; | ||
var failureStatus = { | ||
needsReadjustment: false, | ||
errorException: false, | ||
@@ -223,4 +227,10 @@ warningException: false, | ||
}; | ||
var sample = message.references[0]; | ||
var failed = message.count > messageMap[type]; | ||
if (message.references[0].message.category === 'error') { | ||
var needsReadjustment = message.count < messageMap[type]; | ||
failureStatus.needsReadjustment = failureStatus.needsReadjustment || needsReadjustment; | ||
if (!sample) { | ||
// There are no errors for this type ... | ||
} | ||
else if (sample.message.category === 'error') { | ||
failureStatus.errorCounter -= message.count; | ||
@@ -252,4 +262,7 @@ failureStatus.errorException = failureStatus.errorException || failed; | ||
} | ||
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,4 +116,10 @@ function breakMsg(msg, size) { | ||
var failed = msg[0]; | ||
var warn = msg[2] < msg[3]; | ||
buf.push(' '); | ||
buf.push(failed ? '✗'.red : '✓'.green); | ||
if (warn) { | ||
buf.push('✗'.yellow); | ||
} | ||
else { | ||
buf.push(failed ? '✗'.red : '✓'.green); | ||
} | ||
buf.push(' '); | ||
@@ -121,2 +129,5 @@ if (failed) { | ||
} | ||
else if (warn) { | ||
buf.push(align(msg[1], 'l', size).yellow); | ||
} | ||
else { | ||
@@ -127,4 +138,8 @@ buf.push(align(msg[1], 'l', size).green); | ||
if (failed) { | ||
buf.push(msg[2].toString().red + " found, " + msg[3].toString().yellow + " allowed\n"); | ||
var allowed = msg[3] === -1 ? '' : ", " + msg[3].toString().yellow + " allowed"; | ||
buf.push(msg[2].toString().red + " found" + allowed + "\n"); | ||
} | ||
else if (warn) { | ||
buf.push(msg[2].toString().green + " found, " + msg[3].toString().yellow + " allowed\n"); | ||
} | ||
else { | ||
@@ -135,37 +150,58 @@ buf.push((msg[2] + " found, " + msg[3] + " allowed\n").gray); | ||
} | ||
function _formatSummary(buf, messages) { | ||
var size = 0; | ||
messages.forEach(function (msg) { | ||
if (msg[0].length > size) { | ||
size = msg[0].length; | ||
function formatCIResults(byMessage, listLimit) { | ||
if (listLimit === void 0) { listLimit = 5; } | ||
var buffer = []; | ||
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'); | ||
} | ||
}); | ||
messages.forEach(function (msg) { | ||
buf.push(' '); | ||
buf.push(align(msg[0], 'l', size).gray); | ||
buf.push(" " + msg[1] + "\n"); | ||
}); | ||
return buffer.join(''); | ||
} | ||
function formatProjectResults(projectStatus, projectResults) { | ||
function formatProjectResults(projectStatus, projectResults, ci, ciLimit) { | ||
if (ci === void 0) { ci = false; } | ||
if (ciLimit === void 0) { ciLimit = 10; } | ||
var buffer = []; | ||
var allMessages = formatResults(projectResults.results); | ||
var types = Object.keys(projectStatus.exceptions).sort(); | ||
var allMessages = ''; | ||
if (!ci || projectResults.numMessages < ciLimit) { | ||
allMessages = formatResults(projectResults.results); | ||
} | ||
else { | ||
allMessages = formatCIResults(projectResults.byMessage); | ||
} | ||
var allTypes = Array.from(new Set(Object.keys(projectResults.byMessage).concat(Object.keys(projectStatus.exceptions)))).sort(); | ||
var messages = []; | ||
types.forEach(function (type) { | ||
allTypes.forEach(function (type) { | ||
var exception = projectStatus.exceptions[type]; | ||
messages.push([exception.failed, exception.type, exception.found, exception.allowed]); | ||
if (exception) { | ||
messages.push([exception.failed, exception.type, exception.found, exception.allowed]); | ||
} | ||
else { | ||
messages.push([true, type, projectResults.byMessage[type].count, -1]); | ||
} | ||
}); | ||
_formatExceptions(buffer, messages); | ||
var exceptions = messages.length ? 'EXCEPTIONS:'.magenta + "\n\n" + buffer.join('') : ''; | ||
var exceptions = messages.length ? 'STATS:'.magenta + "\n\n" + buffer.join('') : ''; | ||
buffer.length = 0; | ||
var allTypes = Object.keys(projectResults.byMessage).sort(); | ||
var stats = []; | ||
allTypes.forEach(function (type) { | ||
stats.push([type, projectResults.byMessage[type].count]); | ||
}); | ||
_formatSummary(buffer, stats); | ||
var statsMsg = 'STATS:'.cyan + "\n\n" + buffer.join(''); | ||
buffer.length = 0; | ||
return allMessages + "\n\n" + statsMsg + "\n\n" + exceptions; | ||
if (projectStatus.status === Interfaces_1.ExitCode.NEEDS_READJUSTMENT) { | ||
return exceptions + "\n\nPlease update 'package.json' to save our progress.\n"; | ||
} | ||
return allMessages + "\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,3 +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.1", | ||
"version": "1.3.0-beta.1806070241", | ||
"description": "iOFFICE TeamCity Builder", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -24,2 +24,3 @@ /// <reference types="request-promise" /> | ||
readonly baseUrl: string; | ||
owner: string; | ||
repo: string; | ||
@@ -110,4 +111,4 @@ preRelease: boolean; | ||
/** | ||
* Create a standard iOffice pre-release of the current state of the project. This command | ||
* will work on any machine that has the valid credentials to bartifactory. | ||
* Create a standard pre-release of the current state of the project. This command | ||
* will work on any machine that has the valid credentials. | ||
*/ | ||
@@ -114,0 +115,0 @@ makePreRelease(): void; |
@@ -33,8 +33,13 @@ "use strict"; | ||
var pkg = this.readNPMPackage(); | ||
var gitUrl = pkg.repository.url; | ||
var gitUrl = pkg.repository; | ||
if (gitUrl && typeof gitUrl !== 'string') { | ||
gitUrl = pkg.repository.url; | ||
} | ||
this.pkgVersion = pkg.version; | ||
this.pkgName = pkg.name; | ||
this.isPrivate = this.pkgName.startsWith('@ioffice-internal/'); | ||
this.repo = gitUrl.match(/iOffice\/(.*)\.git$/)[1]; | ||
this.baseUrl = "https://api.github.com/repos/iOffice/" + this.repo; | ||
var parts = gitUrl.match(/(.*)\/(.*)\/(.*)\.git$/); | ||
this.owner = parts[2]; | ||
this.repo = parts[3]; | ||
this.baseUrl = "https://api.github.com/repos/" + this.owner + "/" + this.repo; | ||
} | ||
@@ -165,3 +170,3 @@ /** | ||
name: "Version " + _this.pkgVersion, | ||
body: "**See [CHANGELOG](https://github.com/iOffice/" + _this.repo + "/blob/master/CHANGELOG.md).**", | ||
body: "**See [CHANGELOG](https://github.com/" + _this.owner + "/" + _this.repo + "/blob/master/CHANGELOG.md).**", | ||
draft: false, | ||
@@ -226,4 +231,4 @@ prerelease: false | ||
/** | ||
* Create a standard iOffice pre-release of the current state of the project. This command | ||
* will work on any machine that has the valid credentials to bartifactory. | ||
* Create a standard pre-release of the current state of the project. This command | ||
* will work on any machine that has the valid credentials. | ||
*/ | ||
@@ -230,0 +235,0 @@ TCBuilder.prototype.makePreRelease = function () { |
@@ -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; | ||
@@ -52,3 +52,3 @@ if (help || h) { | ||
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) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
62418
1473
2
8
3