Skip to content

🎥 Make videos programmatically with React

condensed update and setup

Matt McGillivrayfb8fe1eef17c
diff --git a/packages/cloudrun/gcpInstaller/install.mjs b/packages/cloudrun/gcpInstaller/install.mjs
index 4d87b21d51..408113eec1 100644
--- a/packages/cloudrun/gcpInstaller/install.mjs
+++ b/packages/cloudrun/gcpInstaller/install.mjs
@@ -7,7 +7,6 @@ import {taskPrompt} from './installerScripts/components/taskPrompt.mjs';
// Tasks
import {generateEnv} from './installerScripts/tasks/generateEnv.mjs';
import {setupGcpProject} from './installerScripts/tasks/setupGcpProject.mjs';
-import {updateRemotion} from './installerScripts/tasks/updateRemotion.mjs';
/****************************************
* Splash screen for Remotion Cloud Run
@@ -48,10 +47,6 @@ switch (selection) {
await setupGcpProject(projectID);
break;
- case 'updateRemotion':
- await updateRemotion(projectID);
- break;
-
case 'generateEnv':
await generateEnv(projectID);
break;
diff --git a/packages/cloudrun/gcpInstaller/installerScripts/components/taskPrompt.mjs b/packages/cloudrun/gcpInstaller/installerScripts/components/taskPrompt.mjs
index 2d6b492d40..522e92204f 100644
--- a/packages/cloudrun/gcpInstaller/installerScripts/components/taskPrompt.mjs
+++ b/packages/cloudrun/gcpInstaller/installerScripts/components/taskPrompt.mjs
@@ -1,56 +1,48 @@
-import { execSync } from "child_process";
-import readline from "readline";
-import { colorCode } from "./colorCodes.mjs";
+import {execSync} from 'child_process';
+import readline from 'readline';
+import {colorCode} from './colorCodes.mjs';
export function taskPrompt(projectID) {
- return new Promise((resolve) => {
- const rl = readline.createInterface({
- input: process.stdin,
- output: process.stdout,
- });
-
- rl.question(
- `What would you like to do?\n[1] Setup the GCP project ${projectID} as a Remotion Cloud Run environment.\n[2] ${projectID} is already set up for Remotion, update to a newer Remotion version.\n[3] ${projectID} is already set up for Remotion, generate a new .env file or manage keys for the Remotion Service Account.\n${colorCode.blueText}`,
- async (answer) => {
- // reset terminal color
- rl.output.write(`\n${colorCode.resetText}`);
-
- if (answer.trim() === "1") {
- rl.output.write(
- `${colorCode.blueText}<Terraform selected>\n\n${colorCode.resetText}`
- );
- rl.close();
- return resolve("runTerraform");
- }
-
- if (answer.trim() === "2") {
- rl.output.write(
- `${colorCode.blueText}<Update Remotion selected>\n\n${colorCode.resetText}`
- );
- rl.close();
- return resolve("updateRemotion");
- }
-
- if (answer.trim() === "3") {
- rl.output.write(
- `${colorCode.blueText}<.env creation selected>\n\n${colorCode.resetText}`
- );
- rl.close();
- return resolve("generateEnv");
- }
-
- rl.close();
- execSync(
- `echo "${colorCode.redText}Invalid selection. Please enter 1, 2 or 3.\n${colorCode.resetText}"`,
- {
- stdio: "inherit",
- }
- );
-
- const result = await taskPrompt();
-
- resolve(result);
- }
- );
- });
+ return new Promise((resolve) => {
+ const rl = readline.createInterface({
+ input: process.stdin,
+ output: process.stdout,
+ });
+
+ rl.question(
+ `What would you like to do?\n[1] Cloud Run rendering in ${colorCode.blueText}${projectID}${colorCode.resetText} - Setup / Update Remotion version.\n[2] ${colorCode.blueText}${projectID}${colorCode.resetText} is already set up for Remotion, generate a new .env file or manage keys for the Remotion Service Account.\n${colorCode.blueText}`,
+ async (answer) => {
+ // reset terminal color
+ rl.output.write(`\n${colorCode.resetText}`);
+
+ if (answer.trim() === '1') {
+ rl.output.write(
+ `${colorCode.blueText}<Terraform selected>\n\n${colorCode.resetText}`
+ );
+ rl.close();
+ return resolve('runTerraform');
+ }
+
+ if (answer.trim() === '2') {
+ rl.output.write(
+ `${colorCode.blueText}<.env creation selected>\n\n${colorCode.resetText}`
+ );
+ rl.close();
+ return resolve('generateEnv');
+ }
+
+ rl.close();
+ execSync(
+ `echo "${colorCode.redText}Invalid selection. Please enter 1 or 2.\n${colorCode.resetText}"`,
+ {
+ stdio: 'inherit',
+ }
+ );
+
+ const result = await taskPrompt();
+
+ resolve(result);
+ }
+ );
+ });
}
diff --git a/packages/cloudrun/gcpInstaller/installerScripts/tasks/updateRemotion.mjs b/packages/cloudrun/gcpInstaller/installerScripts/tasks/updateRemotion.mjs
deleted file mode 100644
index 24dc873681..0000000000
--- a/packages/cloudrun/gcpInstaller/installerScripts/tasks/updateRemotion.mjs
+++ /dev/null
@@ -1,76 +0,0 @@
-import { execSync } from "child_process";
-// Components
-import { colorCode } from "../components/colorCodes.mjs";
-import { remotionVersionPrompt } from "../components/remotionVersionPrompt.mjs";
-import { terraformApplyPrompt } from "../components/terraformApplyPrompt.mjs";
-import { checkTerraformStateFile } from "../components/checkTerraformStateFile.mjs";
-
-export async function updateRemotion(projectID) {
- checkTerraformStateFile(projectID);
-
- /****************************************
- * Check the existing remotion version
- ****************************************/
-
- const deployedVersion = execSync(
- `gcloud iam service-accounts describe remotion-sa@${projectID}.iam.gserviceaccount.com | grep "description:" | awk '{print $2}'`,
- {
- stdio: ["inherit", "pipe", "pipe"],
- }
- )
- .toString()
- .trim();
-
- execSync(
- `echo "For project ${colorCode.blueText}${projectID}${colorCode.resetText}, Remotion version ${colorCode.blueText}${deployedVersion}${colorCode.resetText} is deployed.\n"`,
- {
- stdio: "inherit",
- }
- );
-
- const remotionVersion = await remotionVersionPrompt();
-
- /****************************************
- * Terraform init, plan and apply. Will prompt user for confirmation before applying.
- ****************************************/
-
- console.log(
- `\n\n${colorCode.greenBackground} Running Terraform ${colorCode.resetText}`
- );
- const terraformVariables = `-var="remotion_version=${remotionVersion}" -var="project_id=${projectID}" -var="service_account_exists=${true}"`;
-
- execSync("terraform init", { stdio: "inherit" });
-
- // If tfstate file exists, remove the role resource from state so that it can be imported fresh
- try {
- execSync("terraform state list", { stdio: "pipe" });
- execSync(`terraform state rm google_project_iam_custom_role.remotion_sa`, {
- stdio: "inherit",
- });
- } catch {}
-
- execSync(
- `terraform import ${terraformVariables} google_project_iam_custom_role.remotion_sa projects/${projectID}/roles/RemotionSA`,
- { stdio: "inherit" }
- );
-
- execSync(
- `terraform import ${terraformVariables} google_service_account.remotion_sa projects/${projectID}/serviceAccounts/remotion-sa@${projectID}.iam.gserviceaccount.com`,
- { stdio: "inherit" }
- );
-
- execSync(`terraform plan ${terraformVariables} -out=remotion.tfplan`, {
- stdio: "inherit",
- });
-
- // After the plan is complete, prompt the user to apply the plan or not
- const applyPlan = await terraformApplyPrompt();
-
- if (applyPlan) {
- execSync("terraform apply remotion.tfplan", { stdio: "inherit" });
- } else {
- console.log(
- "Plan not applied, deployed Remotion version remains unchanged."
- );
- }
-}