@ioffice/tc-builder
Advanced tools
Comparing version 1.3.0-beta.1806202125 to 1.3.0-beta.1806212344
@@ -31,2 +31,3 @@ "use strict"; | ||
builder.io.error("Failure in the `" + builder.step + "` step: " + m); | ||
builder.io.dumpMessages(); | ||
return [2 /*return*/, { builder: builder, code: 1 }]; | ||
@@ -33,0 +34,0 @@ case 4: |
@@ -193,2 +193,3 @@ "use strict"; | ||
io.error("Failure during project compilation: " + e.message); | ||
io.dumpMessages(); | ||
return Interfaces_1.ExitCode.NODE_ERROR; | ||
@@ -200,2 +201,3 @@ } | ||
io.error(Formatter_1.formatFailureMessage(projectStatus, projectResults)); | ||
io.dumpMessages(); | ||
} | ||
@@ -202,0 +204,0 @@ return projectStatus.status; |
@@ -210,5 +210,10 @@ "use strict"; | ||
var amount = itemCount === 1 ? '' : 's'; | ||
return itemCount + " " + itemName + amount; | ||
return "`" + itemCount + "` _" + itemName + amount + "_"; | ||
}; | ||
var numFiles = Object.keys(projectResults.results).length; | ||
var results = projectResults.results; | ||
var numFiles = Object.keys(results) | ||
.filter(function (fileName) { | ||
var obj = results[fileName]; | ||
return obj.messages.length > 0; | ||
}).length; | ||
var errors = projectResults.numErrors; | ||
@@ -215,0 +220,0 @@ var warnings = projectResults.numWarnings; |
{ | ||
"name": "@ioffice/tc-builder", | ||
"version": "1.3.0-beta.1806202125", | ||
"version": "1.3.0-beta.1806212344", | ||
"description": "iOFFICE TeamCity Builder", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -11,4 +11,9 @@ declare enum CI { | ||
declare class Environment { | ||
readonly projectName: string; | ||
readonly configName: string; | ||
readonly ci: CI; | ||
readonly buildId: string; | ||
readonly buildNumber: string; | ||
readonly pullRequestBranch: string; | ||
readonly pullRequestNumber: string; | ||
readonly targetBranch: string; | ||
@@ -31,3 +36,8 @@ readonly commitMessage: string; | ||
protected getCIEnvironment(): CI; | ||
protected getProjectName(): string; | ||
protected getConfigName(): string; | ||
protected getBuildId(): string; | ||
protected getBuildNumber(): string; | ||
protected getPullRequestBranch(): string; | ||
protected getPullRequestNumber(): string; | ||
protected getTargetBranch(): string; | ||
@@ -34,0 +44,0 @@ protected getCommitMessage(): string; |
@@ -19,4 +19,9 @@ "use strict"; | ||
var pEnv = process.env; | ||
this.projectName = this.getProjectName(); | ||
this.configName = this.getConfigName(); | ||
this.ci = this.getCIEnvironment(); | ||
this.buildId = this.getBuildId(); | ||
this.buildNumber = this.getBuildNumber(); | ||
this.pullRequestBranch = this.getPullRequestBranch(); | ||
this.pullRequestNumber = this.getPullRequestNumber(); | ||
this.targetBranch = this.getTargetBranch(); | ||
@@ -51,2 +56,18 @@ this.commitMessage = this.getCommitMessage(); | ||
}; | ||
Environment.prototype.getProjectName = function () { | ||
var pEnv = process.env; | ||
return pEnv['TEAMCITY_PROJECT_NAME'] || pEnv['PROJECT_NAME'] || ''; | ||
}; | ||
Environment.prototype.getConfigName = function () { | ||
var pEnv = process.env; | ||
return pEnv['TEAMCITY_BUILDCONF_NAME'] || pEnv['CONFIG_NAME'] || ''; | ||
}; | ||
Environment.prototype.getBuildId = function () { | ||
var pEnv = process.env; | ||
return pEnv['TEAMCITY_BUILD_ID'] || pEnv['TRAVIS_BUILD_ID'] || ''; | ||
}; | ||
Environment.prototype.getBuildNumber = function () { | ||
var pEnv = process.env; | ||
return pEnv['BUILD_NUMBER'] || pEnv['TRAVIS_BUILD_NUMBER'] || ''; | ||
}; | ||
Environment.prototype.getPullRequestBranch = function () { | ||
@@ -56,2 +77,6 @@ var pEnv = process.env; | ||
}; | ||
Environment.prototype.getPullRequestNumber = function () { | ||
var pEnv = process.env; | ||
return pEnv['TEAMCITY_PULL_REQUEST_NUMBER'] || pEnv['TRAVIS_PULL_REQUEST'] || ''; | ||
}; | ||
Environment.prototype.getTargetBranch = function () { | ||
@@ -58,0 +83,0 @@ var pEnv = process.env; |
import { Environment } from './Environment'; | ||
declare class IO { | ||
env: Environment; | ||
static warnings: string[]; | ||
static errors: string[]; | ||
static warnings: [string, number][]; | ||
static errors: [string, number][]; | ||
constructor(env: Environment); | ||
@@ -31,3 +31,8 @@ log(msg: any): void; | ||
escapeTC(msg: string): string; | ||
/** | ||
* To be called before the process finishes so that all the error and warning messages may be | ||
* dumped. | ||
*/ | ||
dumpMessages(fileName?: string): void; | ||
} | ||
export { IO, }; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var Environment_1 = require("./Environment"); | ||
var Util_1 = require("../Util"); | ||
var IO = /** @class */ (function () { | ||
@@ -16,6 +17,9 @@ function IO(env) { | ||
IO.prototype.warn = function (msg) { | ||
IO.warnings.unshift(msg); | ||
IO.warnings.push([msg, +(new Date())]); | ||
if (this.env.ci === Environment_1.CI.TEAMCITY) { | ||
this.log("##teamcity[message text='" + this.escapeTC(msg) + "' status='WARNING']"); | ||
} | ||
else if (this.env.ci === Environment_1.CI.TRAVIS) { | ||
this.log("##buildWarning: " + msg); | ||
} | ||
else { | ||
@@ -29,6 +33,9 @@ this.log("WARNING: " + msg); | ||
IO.prototype.error = function (msg) { | ||
IO.errors.unshift(msg); | ||
IO.errors.push([msg, +(new Date())]); | ||
if (this.env.ci === Environment_1.CI.TEAMCITY) { | ||
this.log("##teamcity[buildProblem description='" + this.escapeTC(msg) + "']\n"); | ||
this.log("##teamcity[buildProblem description='" + this.escapeTC(msg) + "']"); | ||
} | ||
else if (this.env.ci === Environment_1.CI.TRAVIS) { | ||
this.log("##buildFailure: " + msg); | ||
} | ||
else { | ||
@@ -87,2 +94,14 @@ this.log("ERROR: " + msg + "\n"); | ||
}; | ||
/** | ||
* To be called before the process finishes so that all the error and warning messages may be | ||
* dumped. | ||
*/ | ||
IO.prototype.dumpMessages = function (fileName) { | ||
if (fileName === void 0) { fileName = 'tcBuilderMessages.json'; } | ||
var data = { | ||
errors: IO.errors, | ||
warnings: IO.warnings, | ||
}; | ||
Util_1.util.writeJSON(data, fileName); | ||
}; | ||
IO.warnings = []; | ||
@@ -89,0 +108,0 @@ IO.errors = []; |
@@ -39,2 +39,6 @@ declare class Util { | ||
/** | ||
* Write the contents to a file. Returns a boolean indicating if writing was successful. | ||
*/ | ||
writeJSON(contents: any, name: string, path?: string): boolean; | ||
/** | ||
* Quick and dirty string replacement. The `template` needs to have strings in the form | ||
@@ -41,0 +45,0 @@ * of `%{<key>}` where `<key>` is one of the keys specified in `properties`. |
13
Util.js
@@ -121,2 +121,15 @@ "use strict"; | ||
/** | ||
* Write the contents to a file. Returns a boolean indicating if writing was successful. | ||
*/ | ||
Util.prototype.writeJSON = function (contents, name, path) { | ||
var base = path || process.cwd(); | ||
try { | ||
fs_1.writeFileSync(base + "/" + name, JSON.stringify(contents, null, 2)); | ||
return true; | ||
} | ||
catch (e) { | ||
return false; | ||
} | ||
}; | ||
/** | ||
* Quick and dirty string replacement. The `template` needs to have strings in the form | ||
@@ -123,0 +136,0 @@ * of `%{<key>}` where `<key>` is one of the keys specified in `properties`. |
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
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
96097
2258
2
15