Skip to content

🎥 Make videos programmatically with React

adding delete tf command when tf file is from another project

Matt McGillivray178682ec0fd2
diff --git a/packages/cloudrun/gcpInstaller/installerScripts/components/checkTerraformStateFile.mjs b/packages/cloudrun/gcpInstaller/installerScripts/components/checkTerraformStateFile.mjs
index 25339e091f..5c5a61ade7 100644
--- a/packages/cloudrun/gcpInstaller/installerScripts/components/checkTerraformStateFile.mjs
+++ b/packages/cloudrun/gcpInstaller/installerScripts/components/checkTerraformStateFile.mjs
@@ -1,41 +1,43 @@
-import { execSync } from "child_process";
-import { existsSync, readFileSync } from "fs";
-import { colorCode } from "./colorCodes.mjs";
+import {execSync} from 'child_process';
+import {existsSync, readFileSync} from 'fs';
+import {colorCode} from './colorCodes.mjs';
export function checkTerraformStateFile(projectID) {
- /****************************************
- * Check for existing Terraform State
- ****************************************/
+ /****************************************
+ * Check for existing Terraform State
+ ****************************************/
- if (existsSync("terraform.tfstate")) {
- execSync(
- 'echo "Terraform State file exists. Checking it is for the current Remotion project...\n"',
- { stdio: "inherit" }
- );
+ if (existsSync('terraform.tfstate')) {
+ execSync(
+ 'echo "Terraform State file exists. Checking it is for the current Remotion project...\n"',
+ {stdio: 'inherit'}
+ );
- const tfstate = JSON.parse(readFileSync("terraform.tfstate", "utf-8"));
+ const tfstate = JSON.parse(readFileSync('terraform.tfstate', 'utf-8'));
- const tfstateProject = tfstate.outputs?.remotion_project_id?.value;
+ const tfstateProject = tfstate.outputs?.remotion_project_id?.value;
- if (tfstateProject === undefined) {
- execSync(
- `echo "${colorCode.redText}Terraform state file is not from a Remotion project.\nChange directory, or delete all existing terraform files within the current directory, before trying again.\nTo delete all terraform files, run: ${colorCode.resetText}rm -rf .terraform terraform.tfstate terraform.tfstate.backup .terraform.lock.hcl terraform.tfstate.*.backup"`,
- { stdio: "inherit" }
- );
- process.exit(1);
- }
+ const deleteTfFilesString = `Change directory, or delete all existing terraform files within the current directory, before trying again.\nTo delete all terraform files, run: ${colorCode.resetText}rm -rf .terraform terraform.tfstate terraform.tfstate.backup .terraform.lock.hcl terraform.tfstate.*.backup${colorCode.resetText}`;
- if (tfstateProject === projectID) {
- execSync(
- `echo "${colorCode.greenText}Terraform state file is for the current Remotion project - ${projectID}. Continuing...${colorCode.resetText}\n"`,
- { stdio: "inherit" }
- );
- } else {
- execSync(
- `echo "${colorCode.redText}Terraform state file is for project ${colorCode.redBackground}${tfstateProject}${colorCode.redText}.\nThe current project is ${colorCode.redBackground}${projectID}${colorCode.redText}.\nChange directory, or delete all existing terraform files within the current directory, before trying again.${colorCode.resetText}"`,
- { stdio: "inherit" }
- );
- process.exit(1);
- }
- }
+ if (tfstateProject === undefined) {
+ execSync(
+ `echo "${colorCode.redText}Terraform state file is not from a Remotion project.\n${deleteTfFilesString}"`,
+ {stdio: 'inherit'}
+ );
+ process.exit(1);
+ }
+
+ if (tfstateProject === projectID) {
+ execSync(
+ `echo "${colorCode.greenText}Terraform state file is for the current Remotion project - ${projectID}. Continuing...${colorCode.resetText}\n"`,
+ {stdio: 'inherit'}
+ );
+ } else {
+ execSync(
+ `echo "${colorCode.redText}Terraform state file is for project ${colorCode.redBackground}${tfstateProject}${colorCode.redText}.\nThe current project is ${colorCode.redBackground}${projectID}${colorCode.redText}.\n${deleteTfFilesString}"`,
+ {stdio: 'inherit'}
+ );
+ process.exit(1);
+ }
+ }
}