serverless-pseudo-parameters
Advanced tools
Comparing version 2.2.0 to 2.4.0
@@ -6,8 +6,10 @@ 'use strict'; | ||
this.serverless = serverless; | ||
this.options = options; | ||
this.options = options || {}; | ||
this.hooks = { | ||
'after:aws:package:finalize:mergeCustomProviderResources': this.addParameters.bind(this), | ||
'after:aws:package:finalize:mergeCustomProviderResources': this.addParameters.bind(this) | ||
}; | ||
this.skipRegionReplace = get(serverless.service, 'custom.pseudoParameters.skipRegionReplace', true) | ||
this.allowReferences = get(serverless.service, 'custom.pseudoParameters.allowReferences', true) | ||
this.skipRegionReplace = get(serverless.service, 'custom.pseudoParameters.skipRegionReplace', true); | ||
this.allowReferences = get(serverless.service, 'custom.pseudoParameters.allowReferences', true); | ||
this.colors = get(this.serverless,'processedInput.options.color', true); | ||
this.debug = this.options.debug || process.env.SLS_DEBUG; | ||
} | ||
@@ -20,7 +22,9 @@ | ||
const allowReferences = this.allowReferences; | ||
const colors = this.colors; | ||
const debug = this.debug; | ||
const consoleLog = this.serverless.cli.consoleLog; | ||
consoleLog(yellow(underline('AWS Pseudo Parameters'))); | ||
if (debug) consoleLog(yellow(underline('AWS Pseudo Parameters'))); | ||
if (skipRegionReplace) { | ||
if (skipRegionReplace && debug) { | ||
consoleLog('Skipping automatic replacement of regions with account region!'); | ||
@@ -32,3 +36,3 @@ } | ||
Object.keys(template).forEach(identifier => { | ||
replaceChildNodes(template[identifier], identifier) | ||
replaceChildNodes(template[identifier], identifier); | ||
}); | ||
@@ -42,3 +46,3 @@ | ||
function isArray(v) { | ||
return Object.prototype.toString.call(v) === '[object Array]' | ||
return Object.prototype.toString.call(v) === '[object Array]'; | ||
} | ||
@@ -48,22 +52,22 @@ | ||
return [ | ||
"ap-northeast-1", | ||
"ap-northeast-2", | ||
"ap-south-1", | ||
"ap-southeast-1", | ||
"ap-southeast-2", | ||
"ca-central-1", | ||
"eu-central-1", | ||
"eu-west-1", | ||
"eu-west-2", | ||
"eu-west-3", | ||
"sa-east-1", | ||
"us-east-1", | ||
"us-east-2", | ||
"us-west-1", | ||
"us-west-2" | ||
] | ||
'ap-northeast-1', | ||
'ap-northeast-2', | ||
'ap-south-1', | ||
'ap-southeast-1', | ||
'ap-southeast-2', | ||
'ca-central-1', | ||
'eu-central-1', | ||
'eu-west-1', | ||
'eu-west-2', | ||
'eu-west-3', | ||
'sa-east-1', | ||
'us-east-1', | ||
'us-east-2', | ||
'us-west-1', | ||
'us-west-2' | ||
]; | ||
} | ||
function containsRegion(v) { | ||
return new RegExp(regions().join("|")).test(v); | ||
return new RegExp(regions().join('|')).test(v); | ||
} | ||
@@ -77,3 +81,3 @@ | ||
if (typeof value === 'string' && !skipRegionReplace && containsRegion(value)) { | ||
const regionFinder = new RegExp(regions().join("|")); | ||
const regionFinder = new RegExp(regions().join('|')); | ||
value = value.replace(regionFinder, '#{AWS::Region}'); | ||
@@ -86,3 +90,3 @@ } | ||
} else { | ||
aws_regex = /#{(AWS::[a-zA-Z]+)}/g | ||
aws_regex = /#{(AWS::[a-zA-Z]+)}/g; | ||
} | ||
@@ -99,11 +103,14 @@ | ||
dictionary[key] = { | ||
"Fn::Sub": replacedString | ||
'Fn::Sub': replacedString | ||
}; | ||
} | ||
// do some fancy logging | ||
let m = aws_regex.exec(value); | ||
while (m) { | ||
consoleLog('AWS Pseudo Parameter: ' + name + '::' + key + ' Replaced ' + yellow(m[1]) + ' with ' + yellow('${' + m[1] + '}')); | ||
m = aws_regex.exec(value); | ||
if (debug) { | ||
// do some fancy logging | ||
let m = aws_regex.exec(value); | ||
while (m) { | ||
consoleLog('AWS Pseudo Parameter: ' + name + '::' + key + ' Replaced ' + yellow(m[1]) + ' with ' + yellow( | ||
'${' + m[1] + '}')); | ||
m = aws_regex.exec(value); | ||
} | ||
} | ||
@@ -122,7 +129,9 @@ } | ||
function yellow(str) { | ||
return '\u001B[33m' + str + '\u001B[39m'; | ||
if (colors) return '\u001B[33m' + str + '\u001B[39m'; | ||
return str; | ||
} | ||
function underline(str) { | ||
return '\u001B[4m' + str + '\u001B[24m'; | ||
if (colors) return '\u001B[4m' + str + '\u001B[24m'; | ||
return str; | ||
} | ||
@@ -129,0 +138,0 @@ } |
{ | ||
"name": "serverless-pseudo-parameters", | ||
"version": "2.2.0", | ||
"version": "2.4.0", | ||
"devDependencies": { | ||
"jest": "^22.4.2" | ||
"jest": "^22.4.4" | ||
}, | ||
@@ -7,0 +7,0 @@ "license": "MIT", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16300
295
5