@orbs-network/polygon
Advanced tools
Comparing version 1.19.0 to 1.20.0
@@ -226,2 +226,4 @@ /** | ||
const workspacePath = this.getWorkspacePath(cloud.name); | ||
await this.resetDestroySnapshot({ workspacePath }); | ||
const successSnapshot = await this.successSnapshotExists({ workspacePath }); | ||
@@ -293,2 +295,9 @@ if (successSnapshot !== false) { | ||
async resetDestroySnapshot({ workspacePath }) { | ||
const targetPath = path.join(workspacePath, 'destroy.json'); | ||
if (fs.existsSync(targetPath)) { | ||
await deleteFile(targetPath).catch(() => { }); | ||
} | ||
} | ||
async storeSuccessSnapshot({ result, workspacePath }) { | ||
@@ -295,0 +304,0 @@ await writeFile(path.join(workspacePath, 'success.json'), JSON.stringify(result)); |
@@ -6,3 +6,4 @@ const path = require('path'); | ||
const util = require('util'); | ||
const { spawn } = require('child_process'); | ||
const { spawn, execSync } = require('child_process'); | ||
const { satisfies, minVersion } = require("semver"); | ||
const writeFile = util.promisify(fs.writeFile); | ||
@@ -33,4 +34,8 @@ const readFile = util.promisify(fs.readFile); | ||
class Terraform { | ||
constructor() { | ||
constructor(skipVersionCheck = false) { | ||
this.outputs = outputs; | ||
if (!skipVersionCheck) { | ||
this.checkSupportedVersions(); | ||
} | ||
} | ||
@@ -415,2 +420,26 @@ | ||
} | ||
version() { | ||
return execSync("terraform -version").toString().split("\n")[0].split(" v")[1]; | ||
} | ||
checkSupportedVersions() { | ||
const supportedVersions = require(`${__dirname}/../../package.json`).supportedTerraformVersion; | ||
let version; | ||
try { | ||
version = this.version() | ||
} catch (e) { | ||
// ignore errors | ||
} | ||
if (!satisfies(version, supportedVersions)) { | ||
const v = minVersion(supportedVersions); | ||
throw new Error(`Terraform version mismatch: found ${version} instead of ${supportedVersions}. | ||
You can fix it by installing tfenv (https://github.com/tfutils/tfenv) and running the following command: | ||
tfenv install ${v && v.version} && tfenv use ${v && v.version} | ||
`); | ||
} | ||
} | ||
} | ||
@@ -417,0 +446,0 @@ |
{ | ||
"name": "@orbs-network/polygon", | ||
"version": "1.19.0", | ||
"version": "1.20.0", | ||
"description": "Polygon is a tool to provision new Orbs Hybrid Blockchain nodes", | ||
@@ -17,2 +17,3 @@ "main": "index.js", | ||
"author": "Itamar Arjuan, Kirill Maksimov", | ||
"supportedTerraformVersion": ">=0.12.23 <=0.12.29", | ||
"license": "ISC", | ||
@@ -36,2 +37,3 @@ "dependencies": { | ||
"request-promise": "^4.2.2", | ||
"semver": "^7.3.2", | ||
"uuid": "^3.3.2", | ||
@@ -38,0 +40,0 @@ "yargs": "^12.0.5" |
@@ -9,3 +9,3 @@ const { describe, it } = require('mocha'); | ||
const { Terraform } = require('./../../lib/services/terraform'); | ||
const tf = new Terraform(); | ||
const tf = new Terraform(true); | ||
@@ -12,0 +12,0 @@ const { validateBoyarUrl, boyarDefaultVersion } = require('./../../lib/services/polygon'); |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
268505
2205
19
21
+ Addedsemver@^7.3.2
+ Addedsemver@7.7.1(transitive)