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.
package/Tests/L0CopyDirectory.js
CHANGED
|
@@ -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
|
|
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
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
|
|
78
|
+
mockery.disable();
|
|
79
79
|
});
|
|
80
80
|
beforeEach(() => {
|
|
81
81
|
mkdirPCount = 0;
|
package/Tests/L0CopyDirectory.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as assert from "assert";
|
|
2
|
-
import * as
|
|
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
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
mockery.registerMock('azure-pipelines-task-lib/task', taskLibMock);
|
|
60
|
+
mockery.registerMock('./packageUtility', {});
|
|
61
|
+
mockery.registerMock('./ziputility', {});
|
|
62
|
+
mockery.registerAllowable('../utility');
|
|
63
63
|
|
|
64
|
-
|
|
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
|
-
|
|
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
|
|
14
|
+
const mockery = require("azure-pipelines-task-lib/lib-mocker");
|
|
15
15
|
function runGenerateWebCongigTests() {
|
|
16
16
|
let webConfigContents;
|
|
17
17
|
before(() => {
|
|
18
|
-
|
|
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
|
-
|
|
27
|
+
mockery.registerMock('fs', {
|
|
28
28
|
readFileSync: function (_path, _format) {
|
|
29
29
|
return "{NodeStartFile};{Handler}";
|
|
30
30
|
}
|
|
31
31
|
});
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
26
|
+
mockery.registerAllowable("../webconfigutil");
|
|
27
27
|
|
|
28
|
-
|
|
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
|
-
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
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;
|