Skip to content

Commit 285b4f9

Browse files
authored
Remove Node-Api Hack and Update to Node-Api 10.0 (#27)
* Remove Node-Api Hack and Update to Node-Api 10.0 with the Serialization fix * Add Null Checks for inputs and packaging fixes
1 parent 7abdd17 commit 285b4f9

File tree

7 files changed

+51
-41
lines changed

7 files changed

+51
-41
lines changed

Tasks/emailReportTask/config/ConfigurationProvider.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { GroupTestResultsBy } from "./report/GroupTestResultsBy";
1212
import { PipelineConfiguration } from "./pipeline/PipelineConfiguration";
1313
import { PipelineType } from "./pipeline/PipelineType";
1414
import { StringUtils } from "../utils/StringUtils";
15+
import { isNullOrUndefined } from "util";
1516

1617
export class ConfigurationProvider implements IConfigurationProvider {
1718
private pipelineConfiguration: PipelineConfiguration;
@@ -115,12 +116,12 @@ export class ConfigurationProvider implements IConfigurationProvider {
115116
const groupTestSummaryByStr = tl.getInput(TaskConstants.GROUPTESTSUMMARYBY_INPUTKEY, false);
116117

117118
const groupTestSummaryBy: Array<GroupTestResultsBy> = new Array();
118-
if (groupTestSummaryByStr != null) {
119-
groupTestSummaryByStr.split(",").forEach(element => { groupTestSummaryBy.push(this.getGroupTestResultsByEnumFromString(element)) });
119+
if (!isNullOrUndefined(groupTestSummaryByStr)) {
120+
(groupTestSummaryByStr as string).split(",").forEach(element => { groupTestSummaryBy.push(this.getGroupTestResultsByEnumFromString(element)) });
120121
}
121122

122123
// derived input values
123-
const includeResultsConfig = includeResultsStr == null ? includeResultsStr.split(",") : [];
124+
const includeResultsConfig = isNullOrUndefined(includeResultsStr) ? [] : includeResultsStr.split(",");
124125
const includeFailedTests = includeResultsConfig.includes("1");
125126
const includeOtherTests = includeResultsConfig.includes("2");
126127
const includePassedTests = includeResultsConfig.includes("3");

Tasks/emailReportTask/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
"main": "../../dist/emailReportExtension/emailReportTask/index.js",
88
"types": "../../dist/emailReportExtension/emailReportTask/index.d.ts",
99
"dependencies": {
10-
"azure-devops-node-api": "^8.0.0",
10+
"azure-devops-node-api": "^10.0.0",
1111
"azure-pipelines-task-lib": "^2.8.0",
1212
"js2xmlparser": "^4.0.0",
1313
"nodemailer": "^6.3.0",
1414
"performance-now": "^2.1.0",
1515
"reflect-metadata": "^0.1.13",
1616
"xslt-processor": "^0.11.5"
1717
}
18-
}d
18+
}

Tasks/emailReportTask/task.dev.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"version": {
1414
"Major": 1,
1515
"Minor": 2,
16-
"Patch": 108
16+
"Patch": 116
1717
},
1818
"groups": [
1919
{

Tasks/emailReportTask/task.prod.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"version": {
1414
"Major": 2,
1515
"Minor": 0,
16-
"Patch": 1
16+
"Patch": 3
1717
},
1818
"groups": [
1919
{

commands/package.js

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,6 @@ exec(npmInstallCommand, function (error) {
2525
console.log(`NPM Install Error: ${error}`);
2626
} else {
2727
console.log("NPM Install Done");
28-
29-
console.log("Patching azure-devops-node-api node_modules..[REMOVE THIS AFTER 9.0.2 release]");
30-
const serializationJsFilePath = path.resolve(`${common.TaskOutDir}/node_modules/azure-devops-node-api/serialization.js`);
31-
let dataToWrite = "";
32-
fs.readFile(serializationJsFilePath, 'utf8', function(err, data) {
33-
if (err) throw err;
34-
const lines = data.split("\r\n");
35-
if(lines.length > 216) {
36-
lines[215] = "break;"
37-
dataToWrite = lines.join("\r\n");
38-
fs.writeFileSync(serializationJsFilePath, dataToWrite);
39-
fs.writeFileSync(path.resolve(`${__dirname}/../node_modules/azure-devops-node-api/serialization.js`), dataToWrite);
40-
}
41-
});
4228
}
4329
});
4430

@@ -61,18 +47,17 @@ if (fs.existsSync(imagesDir)) {
6147
// Package extension only for prod
6248
if (common.ReleaseType.toLowerCase() == "prod") {
6349
console.log(`Run command in ${common.ExtensionOutDir}: tfx extension create --root . --extension-id ${extensionId} --no-prompt`);
64-
// process.chdir(common.ExtensionOutDir);
65-
// var command = `tfx extension create --root . --extension-id ${extensionId} --no-prompt`;
66-
// console.log(`Running: ${command}`);
67-
// exec(command, function (error) {
68-
// if (error) {
69-
// console.log(`Package create error: ${error}`);
70-
// } else {
71-
// console.log("Package created");
72-
// }
73-
// });
74-
} else {
75-
console.log(`Navigate to ${common.TaskOutDir} and run the tfx upload command on the desired azure devops account to upload task directly. Command: 'tfx login && tfx build tasks upload --task-path .'`);
50+
process.chdir(common.ExtensionOutDir);
51+
var command = `tfx extension create --root . --extension-id ${extensionId} --no-prompt`;
52+
console.log(`Running: ${command}`);
53+
exec(command, function (error) {
54+
if (error) {
55+
console.log(`Package create error: ${error}`);
56+
} else {
57+
console.log("Package created. Upload the VSIX to Visual Studio Marketplace if you wish to publish the extension.");
58+
}
59+
});
7660
}
61+
console.log(`If you want to upload to AzureDevOps account directly, then Navigate to ${common.TaskOutDir} and run the tfx upload command on the desired azure devops account to upload task directly. Command: 'tfx login && tfx build tasks upload --task-path .'`);
7762

7863
process.chdir(cwd);

package-lock.json

Lines changed: 31 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"@types/sinon": "^7.0.12",
3030
"@types/stats-lite": "^2.2.0",
3131
"@types/string-template": "^1.0.2",
32-
"azure-devops-node-api": "^8.0.0",
32+
"azure-devops-node-api": "^10.0.0",
3333
"azure-pipelines-task-lib": "^2.8.0",
3434
"js2xmlparser": "^4.0.0",
3535
"nodemailer": "^6.3.0",

0 commit comments

Comments
 (0)