Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: clean up beta #101

Merged
merged 4 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# TFVM - Terraform Version Manager
*A NodeJS-based CLI tool to manage terraform versions without needing admin access.*
*A NodeJS-based CLI tool to manage terraform and opentofu versions without needing admin access.*

This tool exists despite the existence of [tfswitch](https://tfswitch.warrensbox.com/) and similar tools because we
needed a tool for managing Terraform versions on Windows that worked without needing
needed a tool for managing Terraform and OpenTofu versions on Windows that worked without needing
Administrator-level access. For convenience, we have also made this tool work
for Mac and Linux (though more testing with Linux would be greatly appreciated, as we've only tried it with WSL) as well
so that our trainings and documentation can expect the user to use this tool instead of one of the
Expand Down
3 changes: 1 addition & 2 deletions packages/cli/lib/commands/install.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import chalk from 'chalk'
import deleteExecutable from '../util/deleteExecutable.js'
import fs from 'node:fs/promises'
import { versionRegEx } from '../util/constants.js'
import { versionRegEx, LOWEST_OTF_VERSION } from '../util/constants.js'
import getInstalledVersions from '../util/getInstalledVersions.js'
import download from '../util/download.js'
import unzipFile from '../util/unzipFile.js'
Expand All @@ -16,7 +16,6 @@ import * as semver from 'semver'
const os = getOS()

const LAST_TF_VERSION_WITHOUT_ARM = '1.0.1'
const LOWEST_OTF_VERSION = '1.6.0'

async function install (versionNum) {
try {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/lib/commands/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import { logger } from '../util/logger.js'
import { getOS } from '../util/tfvmOS.js'
import * as semver from 'semver'
import getSettings from '../util/getSettings.js'
import { LOWEST_OTF_VERSION } from '../util/constants.js'
const os = getOS()

const LOWEST_OTF_VERSION = '1.6.0'
async function list () {
try {
const printList = []
Expand Down
3 changes: 1 addition & 2 deletions packages/cli/lib/commands/uninstall.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import chalk from 'chalk'
import { versionRegEx } from '../util/constants.js'
import { versionRegEx, LOWEST_OTF_VERSION } from '../util/constants.js'
import getInstalledVersions from '../util/getInstalledVersions.js'
import getErrorMessage from '../util/errorChecker.js'
import { logger } from '../util/logger.js'
Expand All @@ -9,7 +9,6 @@ import { TfvmFS } from '../util/TfvmFS.js'
import * as semver from 'semver'
const os = getOS()

const LOWEST_OTF_VERSION = '1.6.0'
async function uninstall (uninstallVersion) {
try {
uninstallVersion = 'v' + uninstallVersion
Expand Down
3 changes: 1 addition & 2 deletions packages/cli/lib/commands/use.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import chalk from 'chalk'
import deleteExecutable from '../util/deleteExecutable.js'
import fs from 'node:fs/promises'
import enquirer from 'enquirer'
import { versionRegEx } from '../util/constants.js'
import { versionRegEx, LOWEST_OTF_VERSION } from '../util/constants.js'
import getInstalledVersions from '../util/getInstalledVersions.js'
import { TfvmFS } from '../util/TfvmFS.js'
import getErrorMessage from '../util/errorChecker.js'
Expand All @@ -14,7 +14,6 @@ import { getOS } from '../util/tfvmOS.js'
import * as semver from 'semver'

const os = getOS()
const LOWEST_OTF_VERSION = '1.6.0'
let openTofuCheck = false

async function use (version) {
Expand Down
1 change: 1 addition & 0 deletions packages/cli/lib/util/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export const versionRegEx = /^v[0-9]+\.[0-9]+\.[0-9]+/
// Uses positive-lookbehind to only match versions preceded by 'Terraform ' but without extracting 'Terraform '
export const tfCurrVersionRegEx = /(?<=Terraform )v[0-9]+.{1}[0-9]+.{1}[0-9]+/gm
export const openTofuCurrVersionRegEx = /(?<=OpenTofu )v[0-9]+.{1}[0-9]+.{1}[0-9]+/gm
export const LOWEST_OTF_VERSION = '1.6.0'
3 changes: 1 addition & 2 deletions packages/cli/lib/util/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import getSettings from './getSettings.js'
import axios from 'axios'
import fs from 'node:fs/promises'
import * as semver from 'semver'

const LOWEST_OTF_VERSION = '1.6.0'
import { LOWEST_OTF_VERSION } from './constants.js'

const download = async (url, filePath, version) => {
try {
Expand Down
3 changes: 1 addition & 2 deletions packages/cli/lib/util/getInstalledVersions.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import fs from 'node:fs/promises'
import { versionRegEx } from './constants.js'
import { versionRegEx, LOWEST_OTF_VERSION } from './constants.js'
import { logger } from './logger.js'
import getSettings from './getSettings.js'
import { getOS } from './tfvmOS.js'
import * as semver from 'semver'
const os = getOS()

let installedVersions
const LOWEST_OTF_VERSION = '1.6.0'

/**
* Returns a list of installed tf versions.
Expand Down
1 change: 0 additions & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
"commander": "^9.4.0",
"compare-versions": "^6.0.0",
"enquirer": "^2.3.6",
"follow-redirects": "^1.15.6",
"node-stream-zip": "^1.15.0",
"pino": "^8.15.1",
"pino-pretty": "^10.0.0",
Expand Down