azure-pipelines-tasks-webdeployment-common 4.245.0 → 4.252.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,7 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.runCopyDirectoryTests = void 0;
13
13
  const assert = require("assert");
14
- const libMocker = require("azure-pipelines-task-lib/lib-mocker");
14
+ const mockery = require("azure-pipelines-task-lib/lib-mocker");
15
15
  const path = require("path");
16
16
  function runCopyDirectoryTests() {
17
17
  const fileList = [];
@@ -64,18 +64,18 @@ function runCopyDirectoryTests() {
64
64
  console.log(message);
65
65
  }
66
66
  };
67
- libMocker.registerMock('azure-pipelines-task-lib/task', taskLibMock);
68
- libMocker.registerMock('./packageUtility', {});
69
- libMocker.registerMock('./ziputility', {});
70
- libMocker.registerAllowable('../utility');
71
- libMocker.enable({
67
+ mockery.registerMock('azure-pipelines-task-lib/task', taskLibMock);
68
+ mockery.registerMock('./packageUtility', {});
69
+ mockery.registerMock('./ziputility', {});
70
+ mockery.registerAllowable('../utility');
71
+ mockery.enable({
72
72
  useCleanCache: true,
73
73
  warnOnReplace: false,
74
74
  warnOnUnregistered: false
75
75
  });
76
76
  }));
77
77
  after(() => {
78
- libMocker.disable();
78
+ mockery.disable();
79
79
  });
80
80
  beforeEach(() => {
81
81
  mkdirPCount = 0;
@@ -1,5 +1,5 @@
1
1
  import * as assert from "assert";
2
- import * as libMocker from "azure-pipelines-task-lib/lib-mocker";
2
+ import * as mockery from "azure-pipelines-task-lib/lib-mocker";
3
3
  import * as path from "path";
4
4
 
5
5
  export function runCopyDirectoryTests(): void {
@@ -56,12 +56,12 @@ export function runCopyDirectoryTests(): void {
56
56
  console.log(message);
57
57
  }
58
58
  };
59
- libMocker.registerMock('azure-pipelines-task-lib/task', taskLibMock);
60
- libMocker.registerMock('./packageUtility', {});
61
- libMocker.registerMock('./ziputility', {});
62
- libMocker.registerAllowable('../utility');
59
+ mockery.registerMock('azure-pipelines-task-lib/task', taskLibMock);
60
+ mockery.registerMock('./packageUtility', {});
61
+ mockery.registerMock('./ziputility', {});
62
+ mockery.registerAllowable('../utility');
63
63
 
64
- libMocker.enable({
64
+ mockery.enable({
65
65
  useCleanCache: true,
66
66
  warnOnReplace: false,
67
67
  warnOnUnregistered: false
@@ -69,7 +69,7 @@ export function runCopyDirectoryTests(): void {
69
69
  });
70
70
 
71
71
  after(() => {
72
- libMocker.disable();
72
+ mockery.disable();
73
73
  });
74
74
 
75
75
  beforeEach(() => {
@@ -11,11 +11,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.runGenerateWebCongigTests = void 0;
13
13
  const assert = require("assert");
14
- const libMocker = require("azure-pipelines-task-lib/lib-mocker");
14
+ const mockery = require("azure-pipelines-task-lib/lib-mocker");
15
15
  function runGenerateWebCongigTests() {
16
16
  let webConfigContents;
17
17
  before(() => {
18
- libMocker.registerMock('azure-pipelines-task-lib/task', {
18
+ mockery.registerMock('azure-pipelines-task-lib/task', {
19
19
  writeFile: function (_file, data, _options) {
20
20
  console.log("web.config contents: " + data);
21
21
  webConfigContents = data;
@@ -24,20 +24,20 @@ function runGenerateWebCongigTests() {
24
24
  console.log("##[debug]: " + message);
25
25
  }
26
26
  });
27
- libMocker.registerMock('fs', {
27
+ mockery.registerMock('fs', {
28
28
  readFileSync: function (_path, _format) {
29
29
  return "{NodeStartFile};{Handler}";
30
30
  }
31
31
  });
32
- libMocker.registerAllowable("../webconfigutil");
33
- libMocker.enable({
32
+ mockery.registerAllowable("../webconfigutil");
33
+ mockery.enable({
34
34
  useCleanCache: true,
35
35
  warnOnReplace: false,
36
36
  warnOnUnregistered: false
37
37
  });
38
38
  });
39
39
  after(() => {
40
- libMocker.disable();
40
+ mockery.disable();
41
41
  });
42
42
  beforeEach(() => {
43
43
  webConfigContents = "";
@@ -1,5 +1,5 @@
1
1
  import * as assert from "assert";
2
- import * as libMocker from "azure-pipelines-task-lib/lib-mocker";
2
+ import * as mockery from "azure-pipelines-task-lib/lib-mocker";
3
3
 
4
4
 
5
5
  export function runGenerateWebCongigTests() {
@@ -7,7 +7,7 @@ export function runGenerateWebCongigTests() {
7
7
 
8
8
  before(() => {
9
9
 
10
- libMocker.registerMock('azure-pipelines-task-lib/task', {
10
+ mockery.registerMock('azure-pipelines-task-lib/task', {
11
11
  writeFile: function (_file: string, data: string, _options: any): void {
12
12
  console.log("web.config contents: " + data);
13
13
  webConfigContents = data;
@@ -17,15 +17,15 @@ export function runGenerateWebCongigTests() {
17
17
  }
18
18
  });
19
19
 
20
- libMocker.registerMock('fs', {
20
+ mockery.registerMock('fs', {
21
21
  readFileSync: function (_path: string, _format: string): string {
22
22
  return "{NodeStartFile};{Handler}"
23
23
  }
24
24
  });
25
25
 
26
- libMocker.registerAllowable("../webconfigutil");
26
+ mockery.registerAllowable("../webconfigutil");
27
27
 
28
- libMocker.enable({
28
+ mockery.enable({
29
29
  useCleanCache: true,
30
30
  warnOnReplace: false,
31
31
  warnOnUnregistered: false
@@ -33,7 +33,7 @@ export function runGenerateWebCongigTests() {
33
33
  });
34
34
 
35
35
  after(() => {
36
- libMocker.disable();
36
+ mockery.disable();
37
37
  });
38
38
 
39
39
  beforeEach(() => {
@@ -137,7 +137,7 @@ function enhancedFileTransformations(isFolderBasedDeployment, xmlTransformation,
137
137
  console.log(tl.loc("XDTTransformationsappliedsuccessfully"));
138
138
  }
139
139
  else {
140
- tl.error(tl.loc('FailedToApplySpecialTransformationReason1'));
140
+ tl.warning(tl.loc('FailedToApplySpecialTransformationReason1'));
141
141
  }
142
142
  }
143
143
  }
@@ -160,7 +160,7 @@ function enhancedFileTransformations(isFolderBasedDeployment, xmlTransformation,
160
160
  console.log(tl.loc('JSONvariablesubstitutionappliedsuccessfully'));
161
161
  }
162
162
  else {
163
- tl.error(tl.loc('FailedToApplyJSONvariablesubstitutionReason1'));
163
+ throw Error(tl.loc('FailedToApplyJSONvariablesubstitutionReason1'));
164
164
  }
165
165
  }
166
166
  }
@@ -175,26 +175,28 @@ function jsonVariableSubstitution(absolutePath, jsonSubFiles, substituteAllTypes
175
175
  }
176
176
  for (let file of matchFiles) {
177
177
  var fileBuffer = fs.readFileSync(file);
178
- var fileEncodeType = fileEncoding.detectFileEncoding(file, fileBuffer);
179
- var fileContent = fileBuffer.toString(fileEncodeType[0]);
180
- if (fileEncodeType[1]) {
181
- fileContent = fileContent.slice(1);
182
- }
183
- try {
184
- fileContent = stripJsonComments(fileContent);
185
- var jsonObject = JSON.parse(fileContent);
186
- }
187
- catch (exception) {
188
- throw Error(tl.loc('JSONParseError', file, exception));
189
- }
190
- console.log(tl.loc('JSONvariableSubstitution', file));
191
- if (substituteAllTypes) {
192
- isSubstitutionApplied = substituteJsonVariableV2(jsonObject, envVarObject) || isSubstitutionApplied;
193
- }
194
- else {
195
- isSubstitutionApplied = substituteJsonVariable(jsonObject, envVarObject) || isSubstitutionApplied;
178
+ if (fileBuffer.length > 4) {
179
+ var fileEncodeType = fileEncoding.detectFileEncoding(file, fileBuffer);
180
+ var fileContent = fileBuffer.toString(fileEncodeType[0]);
181
+ if (fileEncodeType[1]) {
182
+ fileContent = fileContent.slice(1);
183
+ }
184
+ try {
185
+ fileContent = stripJsonComments(fileContent);
186
+ var jsonObject = JSON.parse(fileContent);
187
+ }
188
+ catch (exception) {
189
+ throw Error(tl.loc('JSONParseError', file, exception));
190
+ }
191
+ console.log(tl.loc('JSONvariableSubstitution', file));
192
+ if (substituteAllTypes) {
193
+ isSubstitutionApplied = substituteJsonVariableV2(jsonObject, envVarObject) || isSubstitutionApplied;
194
+ }
195
+ else {
196
+ isSubstitutionApplied = substituteJsonVariable(jsonObject, envVarObject) || isSubstitutionApplied;
197
+ }
198
+ tl.writeFile(file, (fileEncodeType[1] ? '\uFEFF' : '') + JSON.stringify(jsonObject, null, 4), fileEncodeType[0]);
196
199
  }
197
- tl.writeFile(file, (fileEncodeType[1] ? '\uFEFF' : '') + JSON.stringify(jsonObject, null, 4), fileEncodeType[0]);
198
200
  }
199
201
  }
200
202
  return isSubstitutionApplied;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "azure-pipelines-tasks-webdeployment-common",
3
- "version": "4.245.0",
3
+ "version": "4.252.0",
4
4
  "description": "Common Lib for MSDeploy Utility",
5
5
  "repository": {
6
6
  "type": "git",