Skip to content

Commit

Permalink
adding the exact copy of the webdeployment-common-v2 in common-npm-pa…
Browse files Browse the repository at this point in the history
…ckages
  • Loading branch information
agrataru committed Dec 23, 2020
1 parent 409f46b commit 631fa44
Show file tree
Hide file tree
Showing 65 changed files with 8,658 additions and 0 deletions.
127 changes: 127 additions & 0 deletions common-npm-packages/webdeployment-common-v2/ParameterParserUtility.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
// TODO: This whole file is copied from AzureResourceGroupDeployment task. Move this parser to common lib
// Similar parser is used in Grid UI extension. Try to move the code to some place where all can use it.

export function parse(input: string): {[key: string]: any} {
var result = {};
var index = 0;
var obj = { name: "", value: "" };
while (index < input.length) {
var literalData = findLiteral(input, index);
var nextIndex = literalData.currentPosition;
var specialCharacterFlag = literalData.specialCharacterFlag
var literal = input.substr(index, nextIndex - index).trim();
if (isName(literal, specialCharacterFlag)) {
if (obj.name) {
result[obj.name] = { value: obj.value };
obj = { name: "", value: "" };
}
obj.name = literal.substr(1, literal.length);
}
else {
obj.value = literal;
result[obj.name] = { value: obj.value };
obj = { name: "", value: "" };
}
index = nextIndex + 1;
}
if (obj.name) {
result[obj.name] = { value: obj.value };
}
for (var name in result) {
result[name].value = result[name].value.replace(/^"(.*)"$/, '$1');
}
return result;
}

function isName(literal: string, specialCharacterFlag: boolean): boolean {
return literal[0] === '-' && !specialCharacterFlag && isNaN(Number(literal));
}

function findLiteral(input, currentPosition): {[key: string]: any} {
var specialCharacterFlag = false;
for (; currentPosition < input.length; currentPosition++) {
if (input[currentPosition] == " " || input[currentPosition] == "\t") {
for (; currentPosition < input.length; currentPosition++) {
if (input[currentPosition + 1] != " " && input[currentPosition + 1] != "\t") {
break;
}
}
break;
}
else if (input[currentPosition] == "(") {
currentPosition = findClosingBracketIndex(input, currentPosition + 1, ")");
specialCharacterFlag = true;
}
else if (input[currentPosition] == "[") {
currentPosition = findClosingBracketIndex(input, currentPosition + 1, "]");
specialCharacterFlag = true;
}
else if (input[currentPosition] == "{") {
currentPosition = findClosingBracketIndex(input, currentPosition + 1, "}");
specialCharacterFlag = true;
}
else if (input[currentPosition] == "\"") {
//keep going till this one closes
currentPosition = findClosingQuoteIndex(input, currentPosition + 1, "\"");
specialCharacterFlag = true;
}
else if (input[currentPosition] == "'") {
//keep going till this one closes
currentPosition = findClosingQuoteIndex(input, currentPosition + 1, "'");
specialCharacterFlag = true;
}
else if (input[currentPosition] == "`") {
currentPosition++;
specialCharacterFlag = true;
if (currentPosition >= input.length) {
break;
}
}
}
return { currentPosition: currentPosition, specialCharacterFlag: specialCharacterFlag };
}

function findClosingBracketIndex(input, currentPosition, closingBracket): number {
for (; currentPosition < input.length; currentPosition++) {
if (input[currentPosition] == closingBracket) {
break;
}
else if (input[currentPosition] == "(") {
currentPosition = findClosingBracketIndex(input, currentPosition + 1, ")");
}
else if (input[currentPosition] == "[") {
currentPosition = findClosingBracketIndex(input, currentPosition + 1, "]");
}
else if (input[currentPosition] == "{") {
currentPosition = findClosingBracketIndex(input, currentPosition + 1, "}");
}
else if (input[currentPosition] == "\"") {
currentPosition = findClosingQuoteIndex(input, currentPosition + 1, "\"");
}
else if (input[currentPosition] == "'") {
currentPosition = findClosingQuoteIndex(input, currentPosition + 1, "'");
}
else if (input[currentPosition] == "`") {
currentPosition++;
if (currentPosition >= input.length) {
break;
}
}
}
return currentPosition;
}

function findClosingQuoteIndex(input, currentPosition, closingQuote) {
for (; currentPosition < input.length; currentPosition++) {
if (input[currentPosition] == closingQuote) {
break;
}
else if (input[currentPosition] == "`") {
currentPosition++;
if (currentPosition >= input.length) {
break;
}
}
}
return currentPosition;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"loc.messages.Updatemachinetoenablesecuretlsprotocol": "Make sure the machine is using TLS 1.2 protocol or higher. Check https://aka.ms/enableTlsv2 for more information on how to enable TLS in your machine.",
"loc.messages.JarPathNotPresent": "Java jar path is not present",
"loc.messages.JSONvariablesubstitutionappliedsuccessfully": "JSON variable substitution applied successfully.",
"loc.messages.XMLvariablesubstitutionappliedsuccessfully": "XML variable substitution applied successfully.",
"loc.messages.XDTTransformationsappliedsuccessfully": "XML Transformations applied successfully",
"loc.messages.CannotPerformXdtTransformationOnNonWindowsPlatform": "Cannot perform XML transformations on a non-Windows platform.",
"loc.messages.XdtTransformationErrorWhileTransforming": "XML transformation error while transforming %s using %s.",
"loc.messages.JSONParseError": "Unable to parse JSON file: %s. Error: %s",
"loc.messages.NOJSONfilematchedwithspecificpattern": "NO JSON file matched with specific pattern: %s.",
"loc.messages.FailedToApplyTransformation": "Unable to apply transformation for the given package. Verify the following.",
"loc.messages.MissingArgumentsforXMLTransformation": "Incomplete or missing arguments. Expected format -transform <transform file> -xml <source file> -result <destinamtion file>. Transformation and source file are mandatory inputs."
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"loc.messages.Updatemachinetoenablesecuretlsprotocol": "Make sure the machine is using TLS 1.2 protocol or higher. Check https://aka.ms/enableTlsv2 for more information on how to enable TLS in your machine.",
"loc.messages.JarPathNotPresent": "Java jar path is not present",
"loc.messages.JSONvariablesubstitutionappliedsuccessfully": "JSON variable substitution applied successfully.",
"loc.messages.XMLvariablesubstitutionappliedsuccessfully": "XML variable substitution applied successfully.",
"loc.messages.XDTTransformationsappliedsuccessfully": "XML Transformations applied successfully",
"loc.messages.CannotPerformXdtTransformationOnNonWindowsPlatform": "Cannot perform XML transformations on a non-Windows platform.",
"loc.messages.XdtTransformationErrorWhileTransforming": "XML transformation error while transforming %s using %s.",
"loc.messages.JSONParseError": "Unable to parse JSON file: %s. Error: %s",
"loc.messages.NOJSONfilematchedwithspecificpattern": "NO JSON file matched with specific pattern: %s.",
"loc.messages.FailedToApplyTransformation": "Unable to apply transformation for the given package. Verify the following.",
"loc.messages.FailedToApplySpecialTransformation": "Unable to apply transformation for the given package.",
"loc.messages.FailedToApplySpecialTransformationReason1": "Unable to apply transformation for the given package - Changes are already present in the package.",
"loc.messages.FailedToApplyTransformationReason1": "1. Whether the Transformation is already applied for the MSBuild generated package during build. If yes, remove the <DependentUpon> tag for each config in the csproj file and rebuild. ",
"loc.messages.FailedToApplyTransformationReason2": "2. Ensure that the config file and transformation files are present in the same folder inside the package.",
"loc.messages.FailedToApplyXMLvariablesubstitutionReason1": "Failed to apply XML variable substitution. Changes are already present in the package.",
"loc.messages.MissingArgumentsforXMLTransformation": "Incomplete or missing arguments. Expected format -transform <transform file> -xml <source file> -result <destinamtion file>. Transformation and source file are mandatory inputs.",
"loc.messages.MorethanonepackagematchedwithspecifiedpatternPleaserestrainthesearchpattern": "More than one package matched with specified pattern: %s. Please restrain the search pattern.",
"loc.messages.JSONvariableSubstitution": "Applying JSON variable substitution for %s",
"loc.messages.SubstitutingValueonKey": "Substituting value on key: %s",
"loc.messages.SubstitutingValueonKeyWithNumber": "Substituting value on key %s with (number) value: %s",
"loc.messages.SubstitutingValueonKeyWithBoolean": "Substituting value on key %s with (boolean) value: %s",
"loc.messages.SubstitutingValueonKeyWithObject": "Substituting value on key %s with (object) value: %s",
"loc.messages.SubstitutingValueonKeyWithString": "Substituting value on key %s with (string) value: %s",
"loc.messages.ApplyingXDTtransformation": "Applying XDT Transformation from transformation file %s -> source file %s ",
"loc.messages.SubstitutionForXmlNode": "Processing substitution for xml node : %s",
"loc.messages.UpdatingKeyWithTokenValue": "Updating value for key= %s with token value: %s",
"loc.messages.SubstitutingConnectionStringValue": "Substituting connectionString value for connectionString = %s with token value: %s ",
"loc.messages.VariableSubstitutionInitiated": "Initiated variable substitution in config file : %s",
"loc.messages.ConfigFileUpdated": "Config file : %s updated.",
"loc.messages.SkippedUpdatingFile": "Skipped Updating file: %s"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"loc.messages.Updatemachinetoenablesecuretlsprotocol": "Make sure the machine is using TLS 1.2 protocol or higher. Check https://aka.ms/enableTlsv2 for more information on how to enable TLS in your machine.",
"loc.messages.JarPathNotPresent": "Java jar path is not present",
"loc.messages.JSONvariablesubstitutionappliedsuccessfully": "JSON variable substitution applied successfully.",
"loc.messages.XMLvariablesubstitutionappliedsuccessfully": "XML variable substitution applied successfully.",
"loc.messages.XDTTransformationsappliedsuccessfully": "XML Transformations applied successfully",
"loc.messages.CannotPerformXdtTransformationOnNonWindowsPlatform": "Cannot perform XML transformations on a non-Windows platform.",
"loc.messages.XdtTransformationErrorWhileTransforming": "XML transformation error while transforming %s using %s.",
"loc.messages.JSONParseError": "Unable to parse JSON file: %s. Error: %s",
"loc.messages.NOJSONfilematchedwithspecificpattern": "NO JSON file matched with specific pattern: %s.",
"loc.messages.FailedToApplyTransformation": "Unable to apply transformation for the given package. Verify the following.",
"loc.messages.MissingArgumentsforXMLTransformation": "Incomplete or missing arguments. Expected format -transform <transform file> -xml <source file> -result <destinamtion file>. Transformation and source file are mandatory inputs."
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"loc.messages.Updatemachinetoenablesecuretlsprotocol": "Make sure the machine is using TLS 1.2 protocol or higher. Check https://aka.ms/enableTlsv2 for more information on how to enable TLS in your machine.",
"loc.messages.JarPathNotPresent": "Java jar path is not present",
"loc.messages.JSONvariablesubstitutionappliedsuccessfully": "JSON variable substitution applied successfully.",
"loc.messages.XMLvariablesubstitutionappliedsuccessfully": "XML variable substitution applied successfully.",
"loc.messages.XDTTransformationsappliedsuccessfully": "XML Transformations applied successfully",
"loc.messages.CannotPerformXdtTransformationOnNonWindowsPlatform": "Cannot perform XML transformations on a non-Windows platform.",
"loc.messages.XdtTransformationErrorWhileTransforming": "XML transformation error while transforming %s using %s.",
"loc.messages.JSONParseError": "Unable to parse JSON file: %s. Error: %s",
"loc.messages.NOJSONfilematchedwithspecificpattern": "NO JSON file matched with specific pattern: %s.",
"loc.messages.FailedToApplyTransformation": "Unable to apply transformation for the given package. Verify the following.",
"loc.messages.MissingArgumentsforXMLTransformation": "Incomplete or missing arguments. Expected format -transform <transform file> -xml <source file> -result <destinamtion file>. Transformation and source file are mandatory inputs."
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"loc.messages.Updatemachinetoenablesecuretlsprotocol": "Make sure the machine is using TLS 1.2 protocol or higher. Check https://aka.ms/enableTlsv2 for more information on how to enable TLS in your machine.",
"loc.messages.JarPathNotPresent": "Java jar path is not present",
"loc.messages.JSONvariablesubstitutionappliedsuccessfully": "JSON variable substitution applied successfully.",
"loc.messages.XMLvariablesubstitutionappliedsuccessfully": "XML variable substitution applied successfully.",
"loc.messages.XDTTransformationsappliedsuccessfully": "XML Transformations applied successfully",
"loc.messages.CannotPerformXdtTransformationOnNonWindowsPlatform": "Cannot perform XML transformations on a non-Windows platform.",
"loc.messages.XdtTransformationErrorWhileTransforming": "XML transformation error while transforming %s using %s.",
"loc.messages.JSONParseError": "Unable to parse JSON file: %s. Error: %s",
"loc.messages.NOJSONfilematchedwithspecificpattern": "NO JSON file matched with specific pattern: %s.",
"loc.messages.FailedToApplyTransformation": "Unable to apply transformation for the given package. Verify the following.",
"loc.messages.MissingArgumentsforXMLTransformation": "Incomplete or missing arguments. Expected format -transform <transform file> -xml <source file> -result <destinamtion file>. Transformation and source file are mandatory inputs."
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"loc.messages.Updatemachinetoenablesecuretlsprotocol": "Make sure the machine is using TLS 1.2 protocol or higher. Check https://aka.ms/enableTlsv2 for more information on how to enable TLS in your machine.",
"loc.messages.JarPathNotPresent": "Java jar path is not present",
"loc.messages.JSONvariablesubstitutionappliedsuccessfully": "JSON variable substitution applied successfully.",
"loc.messages.XMLvariablesubstitutionappliedsuccessfully": "XML variable substitution applied successfully.",
"loc.messages.XDTTransformationsappliedsuccessfully": "XML Transformations applied successfully",
"loc.messages.CannotPerformXdtTransformationOnNonWindowsPlatform": "Cannot perform XML transformations on a non-Windows platform.",
"loc.messages.XdtTransformationErrorWhileTransforming": "XML transformation error while transforming %s using %s.",
"loc.messages.JSONParseError": "Unable to parse JSON file: %s. Error: %s",
"loc.messages.NOJSONfilematchedwithspecificpattern": "NO JSON file matched with specific pattern: %s.",
"loc.messages.FailedToApplyTransformation": "Unable to apply transformation for the given package. Verify the following.",
"loc.messages.MissingArgumentsforXMLTransformation": "Incomplete or missing arguments. Expected format -transform <transform file> -xml <source file> -result <destinamtion file>. Transformation and source file are mandatory inputs."
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"loc.messages.Updatemachinetoenablesecuretlsprotocol": "Make sure the machine is using TLS 1.2 protocol or higher. Check https://aka.ms/enableTlsv2 for more information on how to enable TLS in your machine.",
"loc.messages.JarPathNotPresent": "Java jar path is not present",
"loc.messages.JSONvariablesubstitutionappliedsuccessfully": "JSON variable substitution applied successfully.",
"loc.messages.XMLvariablesubstitutionappliedsuccessfully": "XML variable substitution applied successfully.",
"loc.messages.XDTTransformationsappliedsuccessfully": "XML Transformations applied successfully",
"loc.messages.CannotPerformXdtTransformationOnNonWindowsPlatform": "Cannot perform XML transformations on a non-Windows platform.",
"loc.messages.XdtTransformationErrorWhileTransforming": "XML transformation error while transforming %s using %s.",
"loc.messages.JSONParseError": "Unable to parse JSON file: %s. Error: %s",
"loc.messages.NOJSONfilematchedwithspecificpattern": "NO JSON file matched with specific pattern: %s.",
"loc.messages.FailedToApplyTransformation": "Unable to apply transformation for the given package. Verify the following.",
"loc.messages.MissingArgumentsforXMLTransformation": "Incomplete or missing arguments. Expected format -transform <transform file> -xml <source file> -result <destinamtion file>. Transformation and source file are mandatory inputs."
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"loc.messages.Updatemachinetoenablesecuretlsprotocol": "Make sure the machine is using TLS 1.2 protocol or higher. Check https://aka.ms/enableTlsv2 for more information on how to enable TLS in your machine.",
"loc.messages.JarPathNotPresent": "Java jar path is not present",
"loc.messages.JSONvariablesubstitutionappliedsuccessfully": "JSON variable substitution applied successfully.",
"loc.messages.XMLvariablesubstitutionappliedsuccessfully": "XML variable substitution applied successfully.",
"loc.messages.XDTTransformationsappliedsuccessfully": "XML Transformations applied successfully",
"loc.messages.CannotPerformXdtTransformationOnNonWindowsPlatform": "Cannot perform XML transformations on a non-Windows platform.",
"loc.messages.XdtTransformationErrorWhileTransforming": "XML transformation error while transforming %s using %s.",
"loc.messages.JSONParseError": "Unable to parse JSON file: %s. Error: %s",
"loc.messages.NOJSONfilematchedwithspecificpattern": "NO JSON file matched with specific pattern: %s.",
"loc.messages.FailedToApplyTransformation": "Unable to apply transformation for the given package. Verify the following.",
"loc.messages.MissingArgumentsforXMLTransformation": "Incomplete or missing arguments. Expected format -transform <transform file> -xml <source file> -result <destinamtion file>. Transformation and source file are mandatory inputs."
}
Loading

0 comments on commit 631fa44

Please sign in to comment.