azure-pipelines-tasks-webdeployment-common 4.230.1 → 4.230.3
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/L0.d.ts +1 -0
- package/Tests/L0.js +25 -0
- package/Tests/L0.ts +24 -0
- package/Tests/L0CopyDirectory.d.ts +1 -5
- package/Tests/L0CopyDirectory.js +89 -51
- package/Tests/L0CopyDirectory.ts +93 -55
- package/Tests/L0GenerateWebConfig.d.ts +1 -2
- package/Tests/L0GenerateWebConfig.js +55 -24
- package/Tests/L0GenerateWebConfig.ts +51 -31
- package/Tests/L0MSDeployUtility.d.ts +2 -16
- package/Tests/L0MSDeployUtility.js +91 -97
- package/Tests/L0MSDeployUtility.ts +89 -100
- package/Tests/L0ParameterParserUtility.d.ts +1 -0
- package/Tests/L0ParameterParserUtility.js +59 -0
- package/Tests/L0ParameterParserUtility.ts +65 -0
- package/Tests/L1JSONVarSubWithComments.d.ts +1 -1
- package/Tests/L1JSONVarSubWithComments.js +30 -46
- package/Tests/L1JSONVarSubWithComments.ts +39 -52
- package/Tests/L1JsonVarSub.d.ts +1 -1
- package/Tests/L1JsonVarSub.js +58 -66
- package/Tests/L1JsonVarSub.ts +67 -66
- package/Tests/L1JsonVarSubV2.d.ts +1 -1
- package/Tests/L1JsonVarSubV2.js +82 -93
- package/Tests/L1JsonVarSubV2.ts +82 -94
- package/Tests/L1ValidateFileEncoding.d.ts +2 -5
- package/Tests/L1ValidateFileEncoding.js +52 -65
- package/Tests/L1ValidateFileEncoding.ts +61 -77
- package/Tests/L1XdtTransform.d.ts +2 -3
- package/Tests/L1XdtTransform.js +48 -6
- package/Tests/L1XdtTransform.ts +57 -6
- package/Tests/L1XmlVarSub.d.ts +2 -3
- package/Tests/L1XmlVarSub.js +56 -20
- package/Tests/L1XmlVarSub.ts +81 -24
- package/ctt/ctt/ctt.exe +0 -0
- package/package.json +7 -3
- package/packageUtility.js +6 -5
- package/utility.js +1 -1
- package/webconfigutil.d.ts +3 -1
- package/xdttransformationutility.js +1 -1
package/Tests/L1JsonVarSubV2.ts
CHANGED
|
@@ -1,100 +1,88 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import assert = require('assert');
|
|
2
|
+
import { createEnvTree, substituteJsonVariableV2 } from '../jsonvariablesubstitutionutility';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
4
|
+
export function runL1JsonVarSubV2Tests(): void {
|
|
5
|
+
it("Should substitute JSON variables V2", (done: Mocha.Done) => {
|
|
6
|
+
const envVarObject = createEnvTree([
|
|
7
|
+
{ name: 'system.debug', value: 'true', secret: false },
|
|
8
|
+
{ name: 'data.ConnectionString', value: 'database_connection', secret: false },
|
|
9
|
+
{ name: 'data.userName', value: 'db_admin', secret: false },
|
|
10
|
+
{ name: 'data.password', value: 'db_pass', secret: true },
|
|
11
|
+
{ name: '&pl.ch@r@cter.k^y', value: '*.config', secret: false },
|
|
12
|
+
{ name: 'build.sourceDirectory', value: 'DefaultWorkingDirectory', secret: false },
|
|
13
|
+
{ name: 'user.profile.name.first', value: 'firstName', secret: false },
|
|
14
|
+
{ name: 'user.profile', value: 'replace_all', secret: false },
|
|
15
|
+
{ name: 'constructor.name', value: 'newConstructorName', secret: false },
|
|
16
|
+
{ name: 'constructor.valueOf', value: 'constructorNewValue', secret: false },
|
|
17
|
+
{ name: 'profile.users', value: '["suaggar","rok","asranja", "chaitanya"]', secret: false },
|
|
18
|
+
{ name: 'profile.enabled', value: 'false', secret: false },
|
|
19
|
+
{ name: 'profile.version', value: '1173', secret: false },
|
|
20
|
+
{ name: 'profile.somefloat', value: '97.75', secret: false },
|
|
21
|
+
{ name: 'profile.preimum_level', value: '{"suaggar": "V4", "rok": "V5", "asranja": { "type" : "V6"}}', secret: false },
|
|
22
|
+
{ name: 'systemsettings.appurl', value: 'https://dev.azure.com/helloworld', secret: false }
|
|
23
|
+
]);
|
|
22
24
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
25
|
+
const jsonObject = {
|
|
26
|
+
'User.Profile': 'do_not_replace',
|
|
27
|
+
'data': {
|
|
28
|
+
'ConnectionString': 'connect_string',
|
|
29
|
+
'userName': 'name',
|
|
30
|
+
'password': 'pass'
|
|
31
|
+
},
|
|
32
|
+
'&pl': {
|
|
33
|
+
'ch@r@cter.k^y': 'v@lue'
|
|
34
|
+
},
|
|
35
|
+
'system': {
|
|
36
|
+
'debug': 'no_change'
|
|
37
|
+
},
|
|
38
|
+
'user.profile': {
|
|
39
|
+
'name.first': 'fname'
|
|
40
|
+
},
|
|
41
|
+
'constructor.name': 'myconstructorname',
|
|
42
|
+
'constructor': {
|
|
43
|
+
'name': 'myconstructorname',
|
|
44
|
+
'valueOf': 'myconstructorvalue'
|
|
45
|
+
},
|
|
46
|
+
'profile': {
|
|
47
|
+
'users': ['arjgupta', 'raagra', 'muthuk'],
|
|
48
|
+
'preimum_level': {
|
|
49
|
+
'arjgupta': 'V1',
|
|
50
|
+
'raagra': 'V2',
|
|
51
|
+
'muthuk': {
|
|
52
|
+
'type': 'V3'
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"enabled": true,
|
|
56
|
+
"version": 2,
|
|
57
|
+
"somefloat": 2.3456
|
|
58
|
+
},
|
|
59
|
+
'systemsettings': {
|
|
60
|
+
'appurl': 'https://helloworld.visualstudio.com'
|
|
51
61
|
}
|
|
52
|
-
},
|
|
53
|
-
"enabled": true,
|
|
54
|
-
"version": 2,
|
|
55
|
-
"somefloat": 2.3456
|
|
56
|
-
},
|
|
57
|
-
'systemsettings': {
|
|
58
|
-
'appurl': 'https://helloworld.visualstudio.com'
|
|
59
|
-
}
|
|
60
62
|
|
|
61
|
-
}
|
|
62
|
-
// Method to be checked for JSON variable substitution
|
|
63
|
-
jsonSubUtil.substituteJsonVariableV2(jsonObject, envVarObject);
|
|
63
|
+
};
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
console.log('JSON - Array Object validated');
|
|
86
|
-
}
|
|
87
|
-
if(jsonObject['profile']['enabled'] == false) {
|
|
88
|
-
console.log('JSON - Boolean validated');
|
|
89
|
-
}
|
|
90
|
-
if(jsonObject['profile']['somefloat'] == 97.75) {
|
|
91
|
-
console.log('JSON - Number(float) validated');
|
|
92
|
-
}
|
|
93
|
-
if(jsonObject['profile']['version'] == 1173) {
|
|
94
|
-
console.log('JSON - Number(int) validated');
|
|
95
|
-
}
|
|
96
|
-
if(JSON.stringify(jsonObject['profile']['preimum_level']) == JSON.stringify({"suaggar": "V4", "rok": "V5", "asranja": { "type" : "V6"}})) {
|
|
97
|
-
console.log('JSON - Object validated');
|
|
98
|
-
}
|
|
65
|
+
substituteJsonVariableV2(jsonObject, envVarObject);
|
|
66
|
+
|
|
67
|
+
assert.strictEqual(jsonObject['data']['ConnectionString'], 'database_connection');
|
|
68
|
+
assert.strictEqual(jsonObject['data']['userName'], 'db_admin');
|
|
69
|
+
assert.strictEqual(jsonObject['systemsettings']['appurl'], 'https://dev.azure.com/helloworld');
|
|
70
|
+
assert.strictEqual(jsonObject['system']['debug'], 'no_change');
|
|
71
|
+
assert.strictEqual(jsonObject['&pl']['ch@r@cter.k^y'], '*.config');
|
|
72
|
+
assert.strictEqual(jsonObject['User.Profile'], 'do_not_replace');
|
|
73
|
+
assert.strictEqual(jsonObject['constructor.name'], 'newConstructorName');
|
|
74
|
+
assert.strictEqual(jsonObject['constructor']['name'], 'newConstructorName');
|
|
75
|
+
assert.strictEqual(jsonObject['constructor']['valueOf'], 'constructorNewValue');
|
|
76
|
+
assert.strictEqual(jsonObject['profile']['users'].length, 4);
|
|
77
|
+
assert.notStrictEqual(jsonObject['profile']['users'].indexOf('suaggar'), -1);
|
|
78
|
+
assert.notStrictEqual(jsonObject['profile']['users'].indexOf('rok'), -1);
|
|
79
|
+
assert.notStrictEqual(jsonObject['profile']['users'].indexOf('asranja'), -1);
|
|
80
|
+
assert.notStrictEqual(jsonObject['profile']['users'].indexOf('chaitanya'), -1);
|
|
81
|
+
assert.strictEqual(jsonObject['profile']['enabled'], false);
|
|
82
|
+
assert.strictEqual(jsonObject['profile']['somefloat'], 97.75);
|
|
83
|
+
assert.strictEqual(jsonObject['profile']['version'], 1173);
|
|
84
|
+
assert.deepStrictEqual(jsonObject['profile']['preimum_level'], { suaggar: "V4", rok: "V5", asranja: { type: "V6" } });
|
|
99
85
|
|
|
100
|
-
|
|
86
|
+
done();
|
|
87
|
+
});
|
|
88
|
+
}
|
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
declare
|
|
3
|
-
declare var fileEncodeType: any;
|
|
4
|
-
declare var fileEncodeType: any;
|
|
5
|
-
declare var fileEncodeType: any;
|
|
1
|
+
/// <reference types="mocha" />
|
|
2
|
+
export declare function runL1ValidateFileEncodingTests(this: Mocha.Suite): void;
|
|
@@ -1,65 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
try {
|
|
55
|
-
fileEncoding.detectFileEncoding('utfShort.txt', new Buffer([20, 0]));
|
|
56
|
-
}
|
|
57
|
-
catch (exception) {
|
|
58
|
-
console.log('Short File Buffer Error');
|
|
59
|
-
}
|
|
60
|
-
try {
|
|
61
|
-
fileEncoding.detectFileEncoding('utfUnknown.txt', new Buffer([0, 10, 20, 30]));
|
|
62
|
-
}
|
|
63
|
-
catch (exception) {
|
|
64
|
-
console.log('Unknown encoding type');
|
|
65
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runL1ValidateFileEncodingTests = void 0;
|
|
4
|
+
const assert = require("assert");
|
|
5
|
+
const fileencoding_1 = require("../fileencoding");
|
|
6
|
+
function runL1ValidateFileEncodingTests() {
|
|
7
|
+
it("UTF-8 with BOM", () => {
|
|
8
|
+
const fileEncodeType = fileencoding_1.detectFileEncoding('utf-8.txt', Buffer.from([239, 187, 191, 0]));
|
|
9
|
+
assert.strictEqual(fileEncodeType[0], 'utf-8');
|
|
10
|
+
assert.strictEqual(fileEncodeType[1], true);
|
|
11
|
+
});
|
|
12
|
+
it("UTF-32LE with BOM", () => {
|
|
13
|
+
assert.throws(() => fileencoding_1.detectFileEncoding('utf-32le.txt', Buffer.from([255, 254, 0, 0])));
|
|
14
|
+
});
|
|
15
|
+
it("UTF-16BE with BOM", () => {
|
|
16
|
+
assert.throws(() => fileencoding_1.detectFileEncoding('utf-16be.txt', Buffer.from([254, 255, 0, 0])));
|
|
17
|
+
});
|
|
18
|
+
it("UTF-16LE with BOM", () => {
|
|
19
|
+
const fileEncodeType = fileencoding_1.detectFileEncoding('utf-16le.txt', Buffer.from([255, 254, 10, 10]));
|
|
20
|
+
assert.strictEqual(fileEncodeType[0], 'utf-16le');
|
|
21
|
+
assert.strictEqual(fileEncodeType[1], true);
|
|
22
|
+
});
|
|
23
|
+
it("UTF-32BE with BOM", () => {
|
|
24
|
+
assert.throws(() => fileencoding_1.detectFileEncoding('utf-32BE.txt', Buffer.from([0, 0, 254, 255])));
|
|
25
|
+
});
|
|
26
|
+
it("UTF-8 without BOM", () => {
|
|
27
|
+
const fileEncodeType = fileencoding_1.detectFileEncoding('utf-8.txt', Buffer.from([10, 11, 12, 13]));
|
|
28
|
+
assert.strictEqual(fileEncodeType[0], 'utf-8');
|
|
29
|
+
assert.strictEqual(fileEncodeType[1], false);
|
|
30
|
+
});
|
|
31
|
+
it("UTF-32LE without BOM", () => {
|
|
32
|
+
assert.throws(() => fileencoding_1.detectFileEncoding('utf-32le.txt', Buffer.from([255, 0, 0, 0])));
|
|
33
|
+
});
|
|
34
|
+
it("UTF-32BE without BOM", () => {
|
|
35
|
+
assert.throws(() => fileencoding_1.detectFileEncoding('utf-32be.txt', Buffer.from([0, 0, 0, 255])));
|
|
36
|
+
});
|
|
37
|
+
it("UTF-16BE without BOM", () => {
|
|
38
|
+
assert.throws(() => fileencoding_1.detectFileEncoding('utf-16be.txt', Buffer.from([0, 10, 0, 20])));
|
|
39
|
+
});
|
|
40
|
+
it("UTF-16LE without BOM", () => {
|
|
41
|
+
const fileEncodeType = fileencoding_1.detectFileEncoding('utf-16le.txt', Buffer.from([20, 0, 10, 0]));
|
|
42
|
+
assert.strictEqual(fileEncodeType[0], 'utf-16le');
|
|
43
|
+
assert.strictEqual(fileEncodeType[1], false);
|
|
44
|
+
});
|
|
45
|
+
it("Short File Buffer Error", () => {
|
|
46
|
+
assert.throws(() => fileencoding_1.detectFileEncoding('utfShort.txt', Buffer.from([20, 0])));
|
|
47
|
+
});
|
|
48
|
+
it("Unknown encoding type", () => {
|
|
49
|
+
assert.throws(() => fileencoding_1.detectFileEncoding('utfUnknown.txt', Buffer.from([0, 10, 20, 30])));
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
exports.runL1ValidateFileEncodingTests = runL1ValidateFileEncodingTests;
|
|
@@ -1,77 +1,61 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
console.log('UTF-16LE without BOM validated');
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
try {
|
|
66
|
-
fileEncoding.detectFileEncoding('utfShort.txt', new Buffer([20, 0]));
|
|
67
|
-
}
|
|
68
|
-
catch(exception) {
|
|
69
|
-
console.log('Short File Buffer Error');
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
try {
|
|
73
|
-
fileEncoding.detectFileEncoding('utfUnknown.txt', new Buffer([0, 10, 20, 30]));
|
|
74
|
-
}
|
|
75
|
-
catch(exception) {
|
|
76
|
-
console.log('Unknown encoding type')
|
|
77
|
-
}
|
|
1
|
+
import * as assert from 'assert';
|
|
2
|
+
import { detectFileEncoding } from '../fileencoding';
|
|
3
|
+
|
|
4
|
+
export function runL1ValidateFileEncodingTests(this: Mocha.Suite): void {
|
|
5
|
+
|
|
6
|
+
it("UTF-8 with BOM", () => {
|
|
7
|
+
const fileEncodeType = detectFileEncoding('utf-8.txt', Buffer.from([239, 187, 191, 0]));
|
|
8
|
+
assert.strictEqual(fileEncodeType[0], 'utf-8');
|
|
9
|
+
assert.strictEqual(fileEncodeType[1], true);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it("UTF-32LE with BOM", () => {
|
|
13
|
+
assert.throws(() => detectFileEncoding('utf-32le.txt', Buffer.from([255, 254, 0, 0])));
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("UTF-16BE with BOM", () => {
|
|
17
|
+
assert.throws(() => detectFileEncoding('utf-16be.txt', Buffer.from([254, 255, 0, 0])));
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("UTF-16LE with BOM", () => {
|
|
21
|
+
const fileEncodeType = detectFileEncoding('utf-16le.txt', Buffer.from([255, 254, 10, 10]));
|
|
22
|
+
assert.strictEqual(fileEncodeType[0], 'utf-16le');
|
|
23
|
+
assert.strictEqual(fileEncodeType[1], true);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("UTF-32BE with BOM", () => {
|
|
27
|
+
assert.throws(() => detectFileEncoding('utf-32BE.txt', Buffer.from([0, 0, 254, 255])));
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("UTF-8 without BOM", () => {
|
|
31
|
+
const fileEncodeType = detectFileEncoding('utf-8.txt', Buffer.from([10, 11, 12, 13]));
|
|
32
|
+
assert.strictEqual(fileEncodeType[0], 'utf-8');
|
|
33
|
+
assert.strictEqual(fileEncodeType[1], false);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("UTF-32LE without BOM", () => {
|
|
37
|
+
assert.throws(() => detectFileEncoding('utf-32le.txt', Buffer.from([255, 0, 0, 0])));
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("UTF-32BE without BOM", () => {
|
|
41
|
+
assert.throws(() => detectFileEncoding('utf-32be.txt', Buffer.from([0, 0, 0, 255])));
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("UTF-16BE without BOM", () => {
|
|
45
|
+
assert.throws(() => detectFileEncoding('utf-16be.txt', Buffer.from([0, 10, 0 ,20])));
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("UTF-16LE without BOM", () => {
|
|
49
|
+
const fileEncodeType = detectFileEncoding('utf-16le.txt', Buffer.from([20, 0, 10, 0]));
|
|
50
|
+
assert.strictEqual(fileEncodeType[0], 'utf-16le');
|
|
51
|
+
assert.strictEqual(fileEncodeType[1], false);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("Short File Buffer Error", () => {
|
|
55
|
+
assert.throws(() => detectFileEncoding('utfShort.txt', Buffer.from([20, 0])));
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it("Unknown encoding type", () => {
|
|
59
|
+
assert.throws(() => detectFileEncoding('utfUnknown.txt', Buffer.from([0, 10, 20, 30])));
|
|
60
|
+
});
|
|
61
|
+
}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
declare
|
|
3
|
-
declare var xdtTransform: any;
|
|
1
|
+
/// <reference types="mocha" />
|
|
2
|
+
export declare function runL1XdtTransformTests(this: Mocha.Suite): void;
|
package/Tests/L1XdtTransform.js
CHANGED
|
@@ -1,6 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runL1XdtTransformTests = void 0;
|
|
4
|
+
const tl = require("azure-pipelines-task-lib");
|
|
5
|
+
const assert = require("assert");
|
|
6
|
+
const fs = require("fs");
|
|
7
|
+
const path = require("path");
|
|
8
|
+
const ltx = require("ltx");
|
|
9
|
+
const xdttransformationutility_1 = require("../xdttransformationutility");
|
|
10
|
+
const fileencoding_1 = require("../fileencoding");
|
|
11
|
+
function runL1XdtTransformTests() {
|
|
12
|
+
this.timeout(parseInt(process.env.TASK_TEST_TIMEOUT) || 20000);
|
|
13
|
+
beforeEach(done => {
|
|
14
|
+
tl.cp(getAbsolutePath('Web.config'), getAbsolutePath('Web_test.config'), '-f', false);
|
|
15
|
+
done();
|
|
16
|
+
});
|
|
17
|
+
afterEach(done => {
|
|
18
|
+
try {
|
|
19
|
+
tl.rmRF(getAbsolutePath('Web_test.config'));
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
tl.debug(error);
|
|
23
|
+
}
|
|
24
|
+
finally {
|
|
25
|
+
done();
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
it('Runs successfully with XML Transformation (L1)', function (done) {
|
|
29
|
+
if (tl.getPlatform() !== tl.Platform.Windows) {
|
|
30
|
+
this.skip();
|
|
31
|
+
}
|
|
32
|
+
xdttransformationutility_1.applyXdtTransformation(getAbsolutePath('Web_test.config'), getAbsolutePath('Web.Debug.config'));
|
|
33
|
+
const resultFile = readXmlFile(getAbsolutePath('Web_test.config'));
|
|
34
|
+
const expectFile = readXmlFile(getAbsolutePath('Web_Expected.config'));
|
|
35
|
+
assert(ltx.equal(resultFile, expectFile), 'Should Transform attributes on Web.config');
|
|
36
|
+
done();
|
|
37
|
+
});
|
|
38
|
+
function getAbsolutePath(file) {
|
|
39
|
+
return path.join(__dirname, 'L1XdtTransform', file);
|
|
40
|
+
}
|
|
41
|
+
function readXmlFile(path) {
|
|
42
|
+
const buffer = fs.readFileSync(path);
|
|
43
|
+
const encoding = fileencoding_1.detectFileEncoding(path, buffer)[0].toString();
|
|
44
|
+
const xml = buffer.toString(encoding).replace(/(?<!\r)[\n]+/gm, "\r\n");
|
|
45
|
+
return ltx.parse(xml);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.runL1XdtTransformTests = runL1XdtTransformTests;
|
package/Tests/L1XdtTransform.ts
CHANGED
|
@@ -1,6 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import * as tl from 'azure-pipelines-task-lib';
|
|
2
|
+
import * as assert from 'assert';
|
|
3
|
+
import * as fs from 'fs';
|
|
4
|
+
import * as path from 'path';
|
|
5
|
+
import * as ltx from 'ltx';
|
|
6
|
+
|
|
7
|
+
import { applyXdtTransformation } from "../xdttransformationutility";
|
|
8
|
+
import { detectFileEncoding } from "../fileencoding";
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
export function runL1XdtTransformTests(this: Mocha.Suite) {
|
|
12
|
+
|
|
13
|
+
this.timeout(parseInt(process.env.TASK_TEST_TIMEOUT) || 20000);
|
|
14
|
+
|
|
15
|
+
beforeEach(done => {
|
|
16
|
+
tl.cp(getAbsolutePath('Web.config'), getAbsolutePath('Web_test.config'), '-f', false);
|
|
17
|
+
|
|
18
|
+
done();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
afterEach(done => {
|
|
22
|
+
try {
|
|
23
|
+
tl.rmRF(getAbsolutePath('Web_test.config'));
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
tl.debug(error);
|
|
27
|
+
}
|
|
28
|
+
finally {
|
|
29
|
+
done();
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('Runs successfully with XML Transformation (L1)', function(done: Mocha.Done) {
|
|
34
|
+
if (tl.getPlatform() !== tl.Platform.Windows) {
|
|
35
|
+
this.skip();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
applyXdtTransformation(getAbsolutePath('Web_test.config'), getAbsolutePath('Web.Debug.config'));
|
|
39
|
+
|
|
40
|
+
const resultFile = readXmlFile(getAbsolutePath('Web_test.config'));
|
|
41
|
+
const expectFile = readXmlFile(getAbsolutePath('Web_Expected.config'));
|
|
42
|
+
assert(ltx.equal(resultFile, expectFile), 'Should Transform attributes on Web.config');
|
|
43
|
+
done();
|
|
44
|
+
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
function getAbsolutePath(file: string): string {
|
|
48
|
+
return path.join(__dirname, 'L1XdtTransform', file);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function readXmlFile(path: string): ltx.Element {
|
|
52
|
+
const buffer = fs.readFileSync(path);
|
|
53
|
+
const encoding = detectFileEncoding(path, buffer)[0].toString();
|
|
54
|
+
const xml = buffer.toString(encoding).replace( /(?<!\r)[\n]+/gm, "\r\n" );
|
|
55
|
+
return ltx.parse(xml);
|
|
56
|
+
}
|
|
57
|
+
}
|
package/Tests/L1XmlVarSub.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
declare
|
|
3
|
-
declare function xmlVarSub(): Promise<void>;
|
|
1
|
+
/// <reference types="mocha" />
|
|
2
|
+
export declare function runL1XmlVarSubTests(this: Mocha.Suite): void;
|