terraform-generator
Advanced tools
Comparing version 5.1.0 to 5.1.1
@@ -19,3 +19,3 @@ "use strict"; | ||
constructor(type, args) { | ||
super('backend', [type], args); | ||
super('backend', [type], args, undefined, true); | ||
this.type = type; | ||
@@ -22,0 +22,0 @@ } |
@@ -16,4 +16,8 @@ import { Argument, Attribute } from '../arguments'; | ||
*/ | ||
constructor(type: string, names: string[], args?: Record<string, any>, innerBlocks?: Block[]); | ||
constructor(type: string, names: string[], args?: Record<string, any>, innerBlocks?: Block[], insideTerraformBlock?: boolean); | ||
/** | ||
* Is this block to be placed inside top-level terrafrom block. | ||
*/ | ||
isInsideTerraformBlock(): boolean; | ||
/** | ||
* Get arguments. | ||
@@ -20,0 +24,0 @@ */ |
@@ -13,3 +13,3 @@ "use strict"; | ||
}; | ||
var _Block_instances, _Block_arguments, _Block_innerBlocks, _Block_validateIdentifier; | ||
var _Block_instances, _Block_arguments, _Block_innerBlocks, _Block_insideTerraformBlock, _Block_validateIdentifier; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -29,6 +29,7 @@ exports.Block = void 0; | ||
*/ | ||
constructor(type, names, args, innerBlocks) { | ||
constructor(type, names, args, innerBlocks, insideTerraformBlock = false) { | ||
_Block_instances.add(this); | ||
_Block_arguments.set(this, void 0); | ||
_Block_innerBlocks.set(this, void 0); | ||
_Block_insideTerraformBlock.set(this, void 0); | ||
__classPrivateFieldGet(this, _Block_instances, "m", _Block_validateIdentifier).call(this, type); | ||
@@ -42,4 +43,11 @@ names.forEach(name => { | ||
__classPrivateFieldSet(this, _Block_innerBlocks, innerBlocks ? innerBlocks : [], "f"); | ||
__classPrivateFieldSet(this, _Block_insideTerraformBlock, insideTerraformBlock, "f"); | ||
} | ||
/** | ||
* Is this block to be placed inside top-level terrafrom block. | ||
*/ | ||
isInsideTerraformBlock() { | ||
return __classPrivateFieldGet(this, _Block_insideTerraformBlock, "f"); | ||
} | ||
/** | ||
* Get arguments. | ||
@@ -125,3 +133,3 @@ */ | ||
exports.Block = Block; | ||
_Block_arguments = new WeakMap(), _Block_innerBlocks = new WeakMap(), _Block_instances = new WeakSet(), _Block_validateIdentifier = function _Block_validateIdentifier(identifier) { | ||
_Block_arguments = new WeakMap(), _Block_innerBlocks = new WeakMap(), _Block_insideTerraformBlock = new WeakMap(), _Block_instances = new WeakSet(), _Block_validateIdentifier = function _Block_validateIdentifier(identifier) { | ||
if (!identifier.match(/^[a-zA-Z_\-]{1}[0-9a-zA-Z_\-]*$/)) { | ||
@@ -128,0 +136,0 @@ throw new Error(`Invalid identifier: ${identifier}`); |
@@ -278,7 +278,7 @@ "use strict"; | ||
let str = ''; | ||
if (__classPrivateFieldGet(this, _TerraformGenerator_arguments, "f") || __classPrivateFieldGet(this, _TerraformGenerator_blocks, "f").filter(block => block instanceof blocks_1.Backend).length > 0) { | ||
if (__classPrivateFieldGet(this, _TerraformGenerator_arguments, "f") || __classPrivateFieldGet(this, _TerraformGenerator_blocks, "f").filter(block => block.isInsideTerraformBlock()).length > 0) { | ||
str += 'terraform {\n'; | ||
str += Util_1.Util.argumentsToString(__classPrivateFieldGet(this, _TerraformGenerator_arguments, "f")); | ||
__classPrivateFieldGet(this, _TerraformGenerator_blocks, "f").forEach(block => { | ||
if (block instanceof blocks_1.Backend) { | ||
if (block.isInsideTerraformBlock()) { | ||
str += block.toTerraform(); | ||
@@ -290,3 +290,3 @@ } | ||
__classPrivateFieldGet(this, _TerraformGenerator_blocks, "f").forEach(block => { | ||
if (!(block instanceof blocks_1.Backend)) { | ||
if (!block.isInsideTerraformBlock()) { | ||
str += block.toTerraform(); | ||
@@ -293,0 +293,0 @@ } |
{ | ||
"name": "terraform-generator", | ||
"version": "5.1.0", | ||
"version": "5.1.1", | ||
"author": "Chang Zhe Jiet", | ||
@@ -46,16 +46,16 @@ "description": "Generate Terraform configurations with Node.js.", | ||
"devDependencies": { | ||
"@types/jest": "^26.0.24", | ||
"@types/jest": "^27.0.2", | ||
"@types/shelljs": "^0.8.9", | ||
"@typescript-eslint/eslint-plugin": "^4.33.0", | ||
"@typescript-eslint/parser": "^4.33.0", | ||
"@typescript-eslint/eslint-plugin": "^5.1.0", | ||
"@typescript-eslint/parser": "^5.1.0", | ||
"del-cli": "^3.0.1", | ||
"eslint": "^7.32.0", | ||
"eslint-plugin-import": "^2.24.2", | ||
"eslint": "^8.0.1", | ||
"eslint-plugin-import": "^2.25.2", | ||
"eslint-plugin-security": "^1.4.0", | ||
"jest": "^27.2.4", | ||
"ts-jest": "^27.0.5", | ||
"ts-node": "^10.2.1", | ||
"typedoc": "^0.21.9", | ||
"typescript": "^4.4.3" | ||
"jest": "^27.3.1", | ||
"ts-jest": "^27.0.7", | ||
"ts-node": "^10.3.0", | ||
"typedoc": "^0.22.11", | ||
"typescript": "^4.4.4" | ||
} | ||
} |
69615
1882