diff --git a/ThirdPartyNotices.txt b/ThirdPartyNotices.txt index 8e51993f5b..81bb332e9f 100644 --- a/ThirdPartyNotices.txt +++ b/ThirdPartyNotices.txt @@ -72,6 +72,8 @@ expressly granted herein, whether by implication, estoppel or otherwise. vscode-ripgrep: https://github.com/roblourens/vscode-ripgrep vscode-textmate: https://github.com/Microsoft/vscode-textmate winreg: https://github.com/fresc81/node-winreg + xmldom: https://github.com/xmldom/xmldom + xml-formatter: https://github.com/chrisbottin/xml-formatter xterm: https://github.com/sourcelair/xterm.js yargs: https://github.com/yargs/yargs yauzl: https://github.com/thejoshwolfe/yauzl @@ -2225,6 +2227,51 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ========================================= END OF winreg NOTICES AND INFORMATION +%% xmldom NOTICES AND INFORMATION BEGIN HERE +========================================= +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in the +Software without restriction, including without limitation the rights to use, copy, +modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, +and to permit persons to whom the Software is furnished to do so, subject to the +following conditions: + +The above copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +========================================= +END OF xmldom NOTICES AND INFORMATION + +%% xml-formatter NOTICES AND INFORMATION BEGIN HERE +========================================= +The MIT License (MIT) + +Copyright 2019 Chris Bottin (https://github.com/chrisbottin) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software +and associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT +LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +========================================= +END OF xml-formatter NOTICES AND INFORMATION + %% xterm NOTICES AND INFORMATION BEGIN HERE ========================================= Copyright (c) 2014-2016, SourceLair Private Company (https://www.sourcelair.com) diff --git a/extensions/sql-database-projects/package.json b/extensions/sql-database-projects/package.json index 468f46d20e..87f1aa7c57 100644 --- a/extensions/sql-database-projects/package.json +++ b/extensions/sql-database-projects/package.json @@ -258,9 +258,11 @@ ] }, "dependencies": { + "@types/xml-formatter": "^1.1.0", "promisify-child-process": "^3.1.1", "vscode-languageclient": "^5.3.0-next.1", "vscode-nls": "^3.2.1", + "xml-formatter": "^2.1.0", "xmldom": "^0.3.0" }, "devDependencies": { diff --git a/extensions/sql-database-projects/src/models/project.ts b/extensions/sql-database-projects/src/models/project.ts index 21ce0175b6..fc898ca4df 100644 --- a/extensions/sql-database-projects/src/models/project.ts +++ b/extensions/sql-database-projects/src/models/project.ts @@ -7,6 +7,7 @@ import * as path from 'path'; import * as xmldom from 'xmldom'; import * as constants from '../common/constants'; import * as utils from '../common/utils'; +import * as xmlFormat from 'xml-formatter'; import { Uri } from 'vscode'; import { promises as fs } from 'fs'; @@ -305,7 +306,8 @@ export class Project { } private async serializeToProjFile(projFileContents: any) { - const xml = new xmldom.XMLSerializer().serializeToString(projFileContents); // TODO: how to get this to serialize with "pretty" formatting + let xml = new xmldom.XMLSerializer().serializeToString(projFileContents); + xml = xmlFormat(xml, { collapseContent: true, indentation: ' ' }); await fs.writeFile(this.projectFilePath, xml); } diff --git a/extensions/sql-database-projects/src/test/baselines/SSDTProjectAfterUpdateBaseline.xml b/extensions/sql-database-projects/src/test/baselines/SSDTProjectAfterUpdateBaseline.xml index 6cbe572516..9728cd79ab 100644 --- a/extensions/sql-database-projects/src/test/baselines/SSDTProjectAfterUpdateBaseline.xml +++ b/extensions/sql-database-projects/src/test/baselines/SSDTProjectAfterUpdateBaseline.xml @@ -69,4 +69,8 @@ - + + + + + diff --git a/extensions/sql-database-projects/yarn.lock b/extensions/sql-database-projects/yarn.lock index aeda3ef270..949f2fa4df 100644 --- a/extensions/sql-database-projects/yarn.lock +++ b/extensions/sql-database-projects/yarn.lock @@ -205,6 +205,11 @@ resolved "https://registry.yarnpkg.com/@istanbuljs/schema/-/schema-0.1.2.tgz#26520bf09abe4a5644cd5414e37125a8954241dd" integrity sha512-tsAQNx32a8CoFhjhijUIhI4kccIAgmGhy8LZMZgGfmXcpMbPRUqn5LWmgRttILi6yeGmBJd2xsPkFMs0PzgPCw== +"@types/xml-formatter@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@types/xml-formatter/-/xml-formatter-1.1.0.tgz#f7cde70ec33d7b044029b6b6c2f6e69d270ced63" + integrity sha512-1Z8XdMUQ3mLsAwqBzKUea2IgDeLOwvgEWevUHhcu3aF6K0KqeGPRlwEYmVy3wGiaepZdcqsiCuUbNhrU4bIJog== + "@types/xmldom@^0.1.29": version "0.1.29" resolved "https://registry.yarnpkg.com/@types/xmldom/-/xmldom-0.1.29.tgz#c4428b0ca86d3b881475726fd94980b38a27c381" @@ -921,6 +926,18 @@ wrappy@1: resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= +xml-formatter@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/xml-formatter/-/xml-formatter-2.1.0.tgz#ff438be6e2195e480b7525ecd3b06652ed76f390" + integrity sha512-t55v5mfpohwKvNbfd8A0FZSZI22//hqXqx3AwRx3mjZel0IEoRM2p1bvVnvNPxHqdqZ0sDjUrBqfHJNbIfE8fw== + dependencies: + xml-parser-xo "^3.0.0" + +xml-parser-xo@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/xml-parser-xo/-/xml-parser-xo-3.0.0.tgz#4d46f1962e5100f228b5f73f34c61bb798430195" + integrity sha512-MPPexqXBx48m3OFMQXxo7+RYhG6o6kCGflk4q4oL3uQ0b7d5NDKjHFDwUoozOTPT3WFztT13z3R9Sn0QCTIJcQ== + xml@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/xml/-/xml-1.0.1.tgz#78ba72020029c5bc87b8a81a3cfcd74b4a2fc1e5"