azure-pipelines-tasks-webdeployment-common 4.230.1 → 4.230.2
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 +23 -0
- package/Tests/L0.ts +22 -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 +91 -100
- package/Tests/L1JSONVarSubWithComments.d.ts +1 -1
- package/Tests/L1JSONVarSubWithComments.js +31 -46
- package/Tests/L1JSONVarSubWithComments.ts +40 -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/L1XmlVarSub.js
CHANGED
|
@@ -1,19 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runL1XmlVarSubTests = void 0;
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const assert = require("assert");
|
|
6
|
+
const ltx = require("ltx");
|
|
7
|
+
const fs = require("fs");
|
|
8
|
+
const tl = require("azure-pipelines-task-lib");
|
|
9
|
+
const xmlvariablesubstitutionutility_1 = require("../xmlvariablesubstitutionutility");
|
|
10
|
+
const fileencoding_1 = require("../fileencoding");
|
|
11
|
+
function runL1XmlVarSubTests() {
|
|
12
|
+
this.timeout(60000);
|
|
13
|
+
beforeEach(function (done) {
|
|
14
|
+
tl.cp(getAbsolutePath('Web.config'), getAbsolutePath('Web_test.config'), '-f', false);
|
|
15
|
+
tl.cp(getAbsolutePath('Web.Debug.config'), getAbsolutePath('Web_test.Debug.config'), '-f', false);
|
|
16
|
+
tl.cp(getAbsolutePath('parameters.xml'), getAbsolutePath('parameters_test.xml'), '-f', false);
|
|
17
|
+
done();
|
|
8
18
|
});
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
19
|
+
afterEach(done => {
|
|
20
|
+
try {
|
|
21
|
+
tl.rmRF(getAbsolutePath('parameters_test.xml'));
|
|
22
|
+
tl.rmRF(getAbsolutePath('Web_test.Debug.config'));
|
|
23
|
+
tl.rmRF(getAbsolutePath('Web_test.config'));
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
tl.debug(error);
|
|
27
|
+
}
|
|
28
|
+
finally {
|
|
29
|
+
done();
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
it("Runs successfully with XML variable substitution", done => {
|
|
33
|
+
const parameterFilePath = getAbsolutePath('parameters_test.xml');
|
|
34
|
+
const tags = ["applicationSettings", "appSettings", "connectionStrings", "configSections"];
|
|
35
|
+
const variableMap = {
|
|
17
36
|
'conntype': 'new_connType',
|
|
18
37
|
"MyDB": "TestDB",
|
|
19
38
|
'webpages:Version': '1.1.7.3',
|
|
@@ -28,10 +47,27 @@ function xmlVarSub() {
|
|
|
28
47
|
'log_level': 'error,warning',
|
|
29
48
|
'Email:ToOverride': ''
|
|
30
49
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
50
|
+
xmlvariablesubstitutionutility_1.substituteXmlVariables(getAbsolutePath('Web_test.config'), tags, variableMap, parameterFilePath);
|
|
51
|
+
xmlvariablesubstitutionutility_1.substituteXmlVariables(getAbsolutePath('Web_test.Debug.config'), tags, variableMap, parameterFilePath);
|
|
52
|
+
assert(compareXmlFiles('Web_test.config', 'Web_Expected.config'), 'Should have substituted variables in Web.config file');
|
|
53
|
+
assert(compareXmlFiles('Web_test.Debug.config', 'Web_Expected.Debug.config'), 'Should have substituted variables in Web.Debug.config file');
|
|
54
|
+
assert(compareXmlFiles('parameters_test.xml', 'parameters_Expected.xml'), 'Should have substituted variables in parameters.xml file');
|
|
55
|
+
done();
|
|
35
56
|
});
|
|
57
|
+
function getAbsolutePath(file) {
|
|
58
|
+
return path.join(__dirname, 'L1XmlVarSub', file);
|
|
59
|
+
}
|
|
60
|
+
function compareXmlFiles(actualFile, expectedFile) {
|
|
61
|
+
const actualFilePath = getAbsolutePath(actualFile);
|
|
62
|
+
const expectedFilePath = getAbsolutePath(expectedFile);
|
|
63
|
+
var actualXml = ltx.parse(readFile(actualFilePath));
|
|
64
|
+
var expectedXml = ltx.parse(readFile(expectedFilePath));
|
|
65
|
+
return ltx.equal(actualXml, expectedXml);
|
|
66
|
+
}
|
|
67
|
+
function readFile(path) {
|
|
68
|
+
const buffer = fs.readFileSync(path);
|
|
69
|
+
const encoding = fileencoding_1.detectFileEncoding(path, buffer)[0].toString();
|
|
70
|
+
return buffer.toString(encoding).replace(/(?<!\r)[\n]+/gm, "\r\n");
|
|
71
|
+
}
|
|
36
72
|
}
|
|
37
|
-
|
|
73
|
+
exports.runL1XmlVarSubTests = runL1XmlVarSubTests;
|
package/Tests/L1XmlVarSub.ts
CHANGED
|
@@ -1,29 +1,86 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
'
|
|
17
|
-
'
|
|
18
|
-
'
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
import * as assert from 'assert';
|
|
3
|
+
import * as ltx from 'ltx';
|
|
4
|
+
import * as fs from 'fs';
|
|
5
|
+
|
|
6
|
+
import * as tl from 'azure-pipelines-task-lib';
|
|
7
|
+
|
|
8
|
+
import { substituteXmlVariables } from '../xmlvariablesubstitutionutility';
|
|
9
|
+
import { detectFileEncoding } from "../fileencoding";
|
|
10
|
+
|
|
11
|
+
export function runL1XmlVarSubTests(this: Mocha.Suite): void {
|
|
12
|
+
|
|
13
|
+
this.timeout(60000);
|
|
14
|
+
|
|
15
|
+
beforeEach(function (done: Mocha.Done) {
|
|
16
|
+
tl.cp(getAbsolutePath('Web.config'), getAbsolutePath('Web_test.config'), '-f', false);
|
|
17
|
+
tl.cp(getAbsolutePath('Web.Debug.config'), getAbsolutePath('Web_test.Debug.config'), '-f', false);
|
|
18
|
+
tl.cp(getAbsolutePath('parameters.xml'), getAbsolutePath('parameters_test.xml'), '-f', false);
|
|
19
|
+
|
|
20
|
+
done();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
afterEach(done => {
|
|
24
|
+
try {
|
|
25
|
+
tl.rmRF(getAbsolutePath('parameters_test.xml'));
|
|
26
|
+
tl.rmRF(getAbsolutePath('Web_test.Debug.config'));
|
|
27
|
+
tl.rmRF(getAbsolutePath('Web_test.config'));
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
tl.debug(error);
|
|
31
|
+
}
|
|
32
|
+
finally {
|
|
33
|
+
done();
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("Runs successfully with XML variable substitution", done => {
|
|
38
|
+
const parameterFilePath = getAbsolutePath('parameters_test.xml');
|
|
39
|
+
const tags = ["applicationSettings", "appSettings", "connectionStrings", "configSections"];
|
|
40
|
+
const variableMap = {
|
|
41
|
+
'conntype': 'new_connType',
|
|
42
|
+
"MyDB": "TestDB",
|
|
43
|
+
'webpages:Version': '1.1.7.3',
|
|
44
|
+
'xdt:Transform': 'DelAttributes',
|
|
45
|
+
'xdt:Locator': 'Match(tag)',
|
|
46
|
+
'DefaultConnection': "Url=https://primary;Database=db1;ApiKey=11111111-1111-1111-1111-111111111111;Failover = {Url:'https://secondary', ApiKey:'11111111-1111-1111-1111-111111111111'}",
|
|
47
|
+
'OtherDefaultConnection': 'connectionStringValue2',
|
|
48
|
+
'ParameterConnection': 'New_Connection_String From xml var subs',
|
|
49
|
+
'connectionString': 'replaced_value',
|
|
50
|
+
'invariantName': 'System.Data.SqlServer',
|
|
51
|
+
'blatvar': 'ApplicationSettingReplacedValue',
|
|
52
|
+
'log_level': 'error,warning',
|
|
53
|
+
'Email:ToOverride': ''
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
substituteXmlVariables(getAbsolutePath('Web_test.config'), tags, variableMap, parameterFilePath);
|
|
57
|
+
substituteXmlVariables(getAbsolutePath('Web_test.Debug.config'), tags, variableMap, parameterFilePath);
|
|
58
|
+
|
|
59
|
+
assert(compareXmlFiles('Web_test.config', 'Web_Expected.config'), 'Should have substituted variables in Web.config file');
|
|
60
|
+
assert(compareXmlFiles('Web_test.Debug.config', 'Web_Expected.Debug.config'), 'Should have substituted variables in Web.Debug.config file');
|
|
61
|
+
assert(compareXmlFiles('parameters_test.xml', 'parameters_Expected.xml'), 'Should have substituted variables in parameters.xml file');
|
|
62
|
+
|
|
63
|
+
done();
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
function getAbsolutePath(file: string): string {
|
|
67
|
+
return path.join(__dirname, 'L1XmlVarSub', file);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function compareXmlFiles(actualFile: string, expectedFile: string): boolean {
|
|
71
|
+
const actualFilePath = getAbsolutePath(actualFile);
|
|
72
|
+
const expectedFilePath = getAbsolutePath(expectedFile);
|
|
73
|
+
|
|
74
|
+
var actualXml = ltx.parse(readFile(actualFilePath));
|
|
75
|
+
var expectedXml = ltx.parse(readFile(expectedFilePath));
|
|
76
|
+
|
|
77
|
+
return ltx.equal(actualXml, expectedXml);
|
|
21
78
|
}
|
|
22
79
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
80
|
+
function readFile(path: string): string {
|
|
81
|
+
const buffer = fs.readFileSync(path);
|
|
82
|
+
const encoding = detectFileEncoding(path, buffer)[0].toString();
|
|
83
|
+
return buffer.toString(encoding).replace(/(?<!\r)[\n]+/gm, "\r\n");
|
|
26
84
|
}
|
|
27
85
|
}
|
|
28
86
|
|
|
29
|
-
xmlVarSub();
|
package/ctt/ctt/ctt.exe
ADDED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "azure-pipelines-tasks-webdeployment-common",
|
|
3
|
-
"version": "4.230.
|
|
3
|
+
"version": "4.230.2",
|
|
4
4
|
"description": "Common Lib for MSDeploy Utility",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+ssh://git@github.com/Microsoft/azure-pipelines-tasks.git"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
|
-
"build": "pwsh build.ps1"
|
|
10
|
+
"build": "pwsh build.ps1",
|
|
11
|
+
"test": "nyc --all --src ./_build mocha ./_build/Tests/L0.js"
|
|
11
12
|
},
|
|
12
13
|
"author": "Microsoft Corporation",
|
|
13
14
|
"license": "MIT",
|
|
@@ -19,6 +20,7 @@
|
|
|
19
20
|
"@types/mocha": "^5.2.7",
|
|
20
21
|
"@types/node": "^10.17.0",
|
|
21
22
|
"@xmldom/xmldom": "git+https://github.com/xmldom/xmldom.git#0.8.6",
|
|
23
|
+
"@types/ltx": "3.0.6",
|
|
22
24
|
"archiver": "1.2.0",
|
|
23
25
|
"azure-pipelines-task-lib": "^4.2.0",
|
|
24
26
|
"decompress-zip": "^0.3.3",
|
|
@@ -29,6 +31,8 @@
|
|
|
29
31
|
"xml2js": "0.6.2"
|
|
30
32
|
},
|
|
31
33
|
"devDependencies": {
|
|
32
|
-
"typescript": "4.0.2"
|
|
34
|
+
"typescript": "4.0.2",
|
|
35
|
+
"mocha": "^6.2.3",
|
|
36
|
+
"nyc": "^15.1.0"
|
|
33
37
|
}
|
|
34
38
|
}
|
package/packageUtility.js
CHANGED
|
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.Package = exports.PackageUtility = exports.PackageType = void 0;
|
|
13
13
|
const tl = require("azure-pipelines-task-lib/task");
|
|
14
14
|
const utility = require("./utility");
|
|
15
|
-
|
|
15
|
+
const ziputility_1 = require("./ziputility");
|
|
16
16
|
const path = require("path");
|
|
17
17
|
var PackageType;
|
|
18
18
|
(function (PackageType) {
|
|
@@ -73,10 +73,11 @@ class Package {
|
|
|
73
73
|
}
|
|
74
74
|
isMSBuildPackage() {
|
|
75
75
|
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
-
if (this._isMSBuildPackage
|
|
77
|
-
this._isMSBuildPackage
|
|
78
|
-
|
|
79
|
-
|
|
76
|
+
if (this._isMSBuildPackage !== undefined)
|
|
77
|
+
return this._isMSBuildPackage;
|
|
78
|
+
const shouldCheckFiles = this.getPackageType() !== PackageType.folder;
|
|
79
|
+
this._isMSBuildPackage = shouldCheckFiles && (yield ziputility_1.checkIfFilesExistsInZip(this._path, ["parameters.xml", "systeminfo.xml"]));
|
|
80
|
+
tl.debug(`Is the package an msdeploy package : ${this._isMSBuildPackage}`);
|
|
80
81
|
return this._isMSBuildPackage;
|
|
81
82
|
});
|
|
82
83
|
}
|
package/utility.js
CHANGED
|
@@ -14,7 +14,7 @@ const path = require("path");
|
|
|
14
14
|
const os = require("os");
|
|
15
15
|
const tl = require("azure-pipelines-task-lib/task");
|
|
16
16
|
const packageUtility_1 = require("./packageUtility");
|
|
17
|
-
|
|
17
|
+
const zipUtility = require("./ziputility");
|
|
18
18
|
/**
|
|
19
19
|
* Validates the input package and finds out input type
|
|
20
20
|
*
|
package/webconfigutil.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
export declare function generateWebConfigFile(webConfigTargetPath: string, appType: string, substitutionParameters:
|
|
1
|
+
export declare function generateWebConfigFile(webConfigTargetPath: string, appType: string, substitutionParameters: {
|
|
2
|
+
[key: string]: string;
|
|
3
|
+
}): void;
|
|
2
4
|
export declare function addWebConfigFile(folderPath: any, webConfigParameters: any, rootDirectoryPath: string): void;
|
|
@@ -21,7 +21,7 @@ exports.expandWildcardPattern = expandWildcardPattern;
|
|
|
21
21
|
*
|
|
22
22
|
*/
|
|
23
23
|
function applyXdtTransformation(sourceFile, transformFile, destinationFile) {
|
|
24
|
-
var cttPath = path.join(__dirname, "
|
|
24
|
+
var cttPath = path.join(__dirname, "ctt", "ctt", "ctt.exe");
|
|
25
25
|
var cttArgsArray = [
|
|
26
26
|
"s:" + sourceFile,
|
|
27
27
|
"t:" + transformFile,
|