🎥 Make videos programmatically with React
move installer to typescript
Jonny Burgerae15712dff09
diff --git a/packages/cloudrun/gcpInstaller/gcpInstaller.tar b/packages/cloudrun/gcpInstaller/gcpInstaller.tarindex 97901d4e19..ff73d2e5ba 100644Binary files a/packages/cloudrun/gcpInstaller/gcpInstaller.tar and b/packages/cloudrun/gcpInstaller/gcpInstaller.tar differdiff --git a/packages/cloudrun/gcpInstaller/install.mjs b/packages/cloudrun/gcpInstaller/install.mtssimilarity index 100%rename from packages/cloudrun/gcpInstaller/install.mjsrename to packages/cloudrun/gcpInstaller/install.mtsdiff --git a/packages/cloudrun/gcpInstaller/installerScripts/components/checkEnvFile.mjs b/packages/cloudrun/gcpInstaller/installerScripts/components/checkEnvFile.mjsdeleted file mode 100644index f249bfa745..0000000000--- a/packages/cloudrun/gcpInstaller/installerScripts/components/checkEnvFile.mjs+++ /dev/null@@ -1,51 +0,0 @@-import { execSync } from "child_process";-import { existsSync } from "fs";-import { colorCode } from "./colorCodes.mjs";-import readline from "readline";--function deleteEnvPrompt() {- return new Promise((resolve) => {- const rl = readline.createInterface({- input: process.stdin,- output: process.stdout,- });-- rl.question(- `${colorCode.redText}.env file exists in this directory. Delete and create new .env file [yes, no]? ${colorCode.blueText}`,- async (answer) => {- // reset terminal color- rl.output.write(`\n${colorCode.resetText}`);- rl.close();-- if (["yes", "y"].indexOf(answer.trim().toLowerCase()) >= 0) {- execSync("rm .env");- execSync(- `echo "${colorCode.redText}Deleted .env file.${colorCode.resetText}"`- );- return resolve(true);- }-- if (["no", "n"].indexOf(answer.trim().toLowerCase()) >= 0) {- execSync('echo ".env file present, and not deleted, exiting..."', {- stdio: "inherit",- });- process.exit(1);- }-- console.log("Invalid response.\n");- const result = await deleteEnvPrompt();-- resolve(result);- }- );- });-}--export async function checkEnvFile() {- /****************************************- * Check for existing .env file- ****************************************/- if (existsSync(".env")) {- await deleteEnvPrompt();- }-}diff --git a/packages/cloudrun/gcpInstaller/installerScripts/components/checkEnvFile.mts b/packages/cloudrun/gcpInstaller/installerScripts/components/checkEnvFile.mtsnew file mode 100644index 0000000000..3011d75c3c--- /dev/null+++ b/packages/cloudrun/gcpInstaller/installerScripts/components/checkEnvFile.mts@@ -0,0 +1,51 @@+import {execSync} from 'child_process';+import {existsSync} from 'fs';+import readline from 'readline';+import {colorCode} from './colorCodes.mjs';++function deleteEnvPrompt() {+ return new Promise((resolve) => {+ const rl = readline.createInterface({+ input: process.stdin,+ output: process.stdout,+ });++ rl.question(+ `${colorCode.redText}.env file exists in this directory. Delete and create new .env file [yes, no]? ${colorCode.blueText}`,+ async (answer) => {+ // reset terminal color+ rl.output.write(`\n${colorCode.resetText}`);+ rl.close();++ if (['yes', 'y'].indexOf(answer.trim().toLowerCase()) >= 0) {+ execSync('rm .env');+ execSync(+ `echo "${colorCode.redText}Deleted .env file.${colorCode.resetText}"`+ );+ return resolve(true);+ }++ if (['no', 'n'].indexOf(answer.trim().toLowerCase()) >= 0) {+ execSync('echo ".env file present, and not deleted, exiting..."', {+ stdio: 'inherit',+ });+ process.exit(1);+ }++ console.log('Invalid response.\n');+ const result = await deleteEnvPrompt();++ resolve(result);+ }+ );+ });+}++export async function checkEnvFile() {+ /****************************************+ * Check for existing .env file+ ****************************************/+ if (existsSync('.env')) {+ await deleteEnvPrompt();+ }+}diff --git a/packages/cloudrun/gcpInstaller/installerScripts/components/checkTerraformStateFile.mjs b/packages/cloudrun/gcpInstaller/installerScripts/components/checkTerraformStateFile.mtssimilarity index 100%rename from packages/cloudrun/gcpInstaller/installerScripts/components/checkTerraformStateFile.mjsrename to packages/cloudrun/gcpInstaller/installerScripts/components/checkTerraformStateFile.mtsdiff --git a/packages/cloudrun/gcpInstaller/installerScripts/components/colorCodes.mjs b/packages/cloudrun/gcpInstaller/installerScripts/components/colorCodes.mtssimilarity index 100%rename from packages/cloudrun/gcpInstaller/installerScripts/components/colorCodes.mjsrename to packages/cloudrun/gcpInstaller/installerScripts/components/colorCodes.mtsdiff --git a/packages/cloudrun/gcpInstaller/installerScripts/components/generateEnvPrompt.mjs b/packages/cloudrun/gcpInstaller/installerScripts/components/generateEnvPrompt.mjsdeleted file mode 100644index cdf97a1091..0000000000--- a/packages/cloudrun/gcpInstaller/installerScripts/components/generateEnvPrompt.mjs+++ /dev/null@@ -1,31 +0,0 @@-import readline from "readline";-import { colorCode } from "./colorCodes.mjs";--export function generateEnvPrompt() {- return new Promise((resolve) => {- const rl = readline.createInterface({- input: process.stdin,- output: process.stdout,- });-- rl.question(- `\n${colorCode.greenText}Do you want to generate the .env file for your code base? ${colorCode.blueText}`,- async (answer) => {- // reset terminal color- rl.output.write(`${colorCode.resetText}`);- rl.close();-- if (["yes", "y"].indexOf(answer.trim().toLowerCase()) >= 0)- return resolve(true);-- if (["no", "n"].indexOf(answer.trim().toLowerCase()) >= 0)- return resolve(false);-- console.log("Invalid response.");- const result = await generateEnvPrompt();-- resolve(result);- }- );- });-}diff --git a/packages/cloudrun/gcpInstaller/installerScripts/components/generateEnvPrompt.mts b/packages/cloudrun/gcpInstaller/installerScripts/components/generateEnvPrompt.mtsnew file mode 100644index 0000000000..05a228bf59--- /dev/null+++ b/packages/cloudrun/gcpInstaller/installerScripts/components/generateEnvPrompt.mts@@ -0,0 +1,31 @@+import readline from 'readline';+import {colorCode} from './colorCodes.mjs';++export function generateEnvPrompt() {+ return new Promise((resolve) => {+ const rl = readline.createInterface({+ input: process.stdin,+ output: process.stdout,+ });++ rl.question(+ `\n${colorCode.greenText}Do you want to generate the .env file for your code base? ${colorCode.blueText}`,+ async (answer) => {+ // reset terminal color+ rl.output.write(`${colorCode.resetText}`);+ rl.close();++ if (['yes', 'y'].indexOf(answer.trim().toLowerCase()) >= 0)+ return resolve(true);++ if (['no', 'n'].indexOf(answer.trim().toLowerCase()) >= 0)+ return resolve(false);++ console.log('Invalid response.');+ const result = await generateEnvPrompt();++ resolve(result);+ }+ );+ });+}diff --git a/packages/cloudrun/gcpInstaller/installerScripts/components/projectIdPrompt.mjs b/packages/cloudrun/gcpInstaller/installerScripts/components/projectIdPrompt.mtssimilarity index 100%rename from packages/cloudrun/gcpInstaller/installerScripts/components/projectIdPrompt.mjsrename to packages/cloudrun/gcpInstaller/installerScripts/components/projectIdPrompt.mtsdiff --git a/packages/cloudrun/gcpInstaller/installerScripts/components/remotionVersionPrompt.mjs b/packages/cloudrun/gcpInstaller/installerScripts/components/remotionVersionPrompt.mjsdeleted file mode 100644index 3d43959e08..0000000000--- a/packages/cloudrun/gcpInstaller/installerScripts/components/remotionVersionPrompt.mjs+++ /dev/null@@ -1,60 +0,0 @@-import { execSync } from "child_process";-import readline from "readline";-import { colorCode } from "./colorCodes.mjs";--export function remotionVersionPrompt() {- return new Promise((resolve) => {- // regex to ensure remotionVersion is in semver format- const semverRegex = new RegExp(- /^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/,- "i"- );-- const rl = readline.createInterface({- input: process.stdin,- output: process.stdout,- });-- rl.question(- `What version of Remotion do you want to use (format: 1.0.0)? ${colorCode.blueText}`,- async (answer) => {- rl.write(`\n${colorCode.resetText}`);- rl.close();-- let fileError = false;- if (semverRegex.test(answer.trim())) {- try {- execSync(- `gcloud storage ls gs://remotion-sa/sa-permissions.json`- );- return resolve(answer.trim());- } catch {- fileError = true;- }- }-- if (fileError) {- console.log(- `${- colorCode.redText- }Cannot find permissions file that matches version ${answer.trim()}.\n${- colorCode.resetText- }`- );- } else {- console.log(- `${- colorCode.redText- }${answer.trim()} is not a valid semver version number.\n${- colorCode.resetText- }`- );- }-- const result = await remotionVersionPrompt();-- resolve(result);- }- );- });-}diff --git a/packages/cloudrun/gcpInstaller/installerScripts/components/remotionVersionPrompt.mts b/packages/cloudrun/gcpInstaller/installerScripts/components/remotionVersionPrompt.mtsnew file mode 100644index 0000000000..05daab4d22--- /dev/null+++ b/packages/cloudrun/gcpInstaller/installerScripts/components/remotionVersionPrompt.mts@@ -0,0 +1,58 @@+import {execSync} from 'child_process';+import readline from 'readline';+import {colorCode} from './colorCodes.mjs';++export function remotionVersionPrompt() {+ return new Promise((resolve) => {+ // regex to ensure remotionVersion is in semver format+ const semverRegex = new RegExp(+ /^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/,+ 'i'+ );++ const rl = readline.createInterface({+ input: process.stdin,+ output: process.stdout,+ });++ rl.question(+ `What version of Remotion do you want to use (format: 1.0.0)? ${colorCode.blueText}`,+ async (answer) => {+ rl.write(`\n${colorCode.resetText}`);+ rl.close();++ let fileError = false;+ if (semverRegex.test(answer.trim())) {+ try {+ execSync(`gcloud storage ls gs://remotion-sa/sa-permissions.json`);+ return resolve(answer.trim());+ } catch {+ fileError = true;+ }+ }++ if (fileError) {+ console.log(+ `${+ colorCode.redText+ }Cannot find permissions file that matches version ${answer.trim()}.\n${+ colorCode.resetText+ }`+ );+ } else {+ console.log(+ `${+ colorCode.redText+ }${answer.trim()} is not a valid semver version number.\n${+ colorCode.resetText+ }`+ );+ }++ const result = await remotionVersionPrompt();++ resolve(result);+ }+ );+ });+}diff --git a/packages/cloudrun/gcpInstaller/installerScripts/components/splashScreen.mjs b/packages/cloudrun/gcpInstaller/installerScripts/components/splashScreen.mjsdeleted file mode 100644index 370eeb9c48..0000000000--- a/packages/cloudrun/gcpInstaller/installerScripts/components/splashScreen.mjs+++ /dev/null@@ -1,21 +0,0 @@-import { execSync } from "child_process";-import { colorCode } from "./colorCodes.mjs";-/****************************************- * Splash screen for Remotion Cloud Run- ****************************************/--export function cloudRunSplashScreen() {- execSync(- `echo "\n\n${colorCode.greenBackground} "`,- {- stdio: "inherit",- }- );- execSync('echo " GCP project setup for Remotion Cloud Run "', {- stdio: "inherit",- });- execSync(- `echo " \n\n${colorCode.resetText}"`,- { stdio: "inherit" }- );-}diff --git a/packages/cloudrun/gcpInstaller/installerScripts/components/splashScreen.mts b/packages/cloudrun/gcpInstaller/installerScripts/components/splashScreen.mtsnew file mode 100644index 0000000000..73eedd8492--- /dev/null+++ b/packages/cloudrun/gcpInstaller/installerScripts/components/splashScreen.mts@@ -0,0 +1,21 @@+import {execSync} from 'child_process';+import {colorCode} from './colorCodes.mjs';+/****************************************+ * Splash screen for Remotion Cloud Run+ ****************************************/++export function cloudRunSplashScreen() {+ execSync(+ `echo "\n\n${colorCode.greenBackground} "`,+ {+ stdio: 'inherit',+ }+ );+ execSync('echo " Cloud Run project setup for Remotion Cloud Run "', {+ stdio: 'inherit',+ });+ execSync(+ `echo " \n\n${colorCode.resetText}"`,+ {stdio: 'inherit'}+ );+}diff --git a/packages/cloudrun/gcpInstaller/installerScripts/components/taskPrompt.mjs b/packages/cloudrun/gcpInstaller/installerScripts/components/taskPrompt.mtssimilarity index 100%rename from packages/cloudrun/gcpInstaller/installerScripts/components/taskPrompt.mjsrename to packages/cloudrun/gcpInstaller/installerScripts/components/taskPrompt.mtsdiff --git a/packages/cloudrun/gcpInstaller/installerScripts/components/terraformApplyPrompt.mjs b/packages/cloudrun/gcpInstaller/installerScripts/components/terraformApplyPrompt.mjsdeleted file mode 100644index ec81b2c80f..0000000000--- a/packages/cloudrun/gcpInstaller/installerScripts/components/terraformApplyPrompt.mjs+++ /dev/null@@ -1,31 +0,0 @@-import readline from "readline";-import { colorCode } from "./colorCodes.mjs";--export function terraformApplyPrompt() {- return new Promise((resolve) => {- const rl = readline.createInterface({- input: process.stdin,- output: process.stdout,- });-- rl.question(- `\n${colorCode.greenText}Do you want to apply the above plan? ${colorCode.blueText}`,- async (answer) => {- // reset terminal color- rl.output.write(colorCode.resetText);- rl.close();-- if (["yes", "y"].indexOf(answer.trim().toLowerCase()) >= 0)- return resolve(true);-- if (["no", "n"].indexOf(answer.trim().toLowerCase()) >= 0)- return resolve(false);-- console.log("Invalid response.");- const result = await terraformApplyPrompt();-- resolve(result);- }- );- });-}diff --git a/packages/cloudrun/gcpInstaller/installerScripts/components/terraformApplyPrompt.mts b/packages/cloudrun/gcpInstaller/installerScripts/components/terraformApplyPrompt.mtsnew file mode 100644index 0000000000..010a3fca6d--- /dev/null+++ b/packages/cloudrun/gcpInstaller/installerScripts/components/terraformApplyPrompt.mts@@ -0,0 +1,31 @@+import readline from 'readline';+import {colorCode} from './colorCodes.mjs';++export function terraformApplyPrompt() {+ return new Promise((resolve) => {+ const rl = readline.createInterface({+ input: process.stdin,+ output: process.stdout,+ });++ rl.question(+ `\n${colorCode.greenText}Do you want to apply the above plan? ${colorCode.blueText}`,+ async (answer) => {+ // reset terminal color+ rl.output.write(colorCode.resetText);+ rl.close();++ if (['yes', 'y'].indexOf(answer.trim().toLowerCase()) >= 0)+ return resolve(true);++ if (['no', 'n'].indexOf(answer.trim().toLowerCase()) >= 0)+ return resolve(false);++ console.log('Invalid response.');+ const result = await terraformApplyPrompt();++ resolve(result);+ }+ );+ });+}diff --git a/packages/cloudrun/gcpInstaller/installerScripts/components/tfSuccessScreen.mjs b/packages/cloudrun/gcpInstaller/installerScripts/components/tfSuccessScreen.mtssimilarity index 100%rename from packages/cloudrun/gcpInstaller/installerScripts/components/tfSuccessScreen.mjsrename to packages/cloudrun/gcpInstaller/installerScripts/components/tfSuccessScreen.mtsdiff --git a/packages/cloudrun/gcpInstaller/installerScripts/tasks/generateEnv.mjs b/packages/cloudrun/gcpInstaller/installerScripts/tasks/generateEnv.mtssimilarity index 100%rename from packages/cloudrun/gcpInstaller/installerScripts/tasks/generateEnv.mjsrename to packages/cloudrun/gcpInstaller/installerScripts/tasks/generateEnv.mtsdiff --git a/packages/cloudrun/gcpInstaller/installerScripts/tasks/setupGcpProject.mjs b/packages/cloudrun/gcpInstaller/installerScripts/tasks/setupGcpProject.mtssimilarity index 100%rename from packages/cloudrun/gcpInstaller/installerScripts/tasks/setupGcpProject.mjsrename to packages/cloudrun/gcpInstaller/installerScripts/tasks/setupGcpProject.mtsdiff --git a/packages/cloudrun/src/admin/bundle-installer.ts b/packages/cloudrun/src/admin/bundle-installer.tsindex fa31529078..8319fbe7ca 100644--- a/packages/cloudrun/src/admin/bundle-installer.ts+++ b/packages/cloudrun/src/admin/bundle-installer.ts@@ -14,7 +14,7 @@ const bundleInstaller = async () => {bundle: true,outfile: bundlemjs,format: 'esm',- entryPoints: [path.resolve(__dirname, '../../gcpInstaller/install.mjs')],+ entryPoints: [path.resolve(__dirname, '../../gcpInstaller/install.mts')],});const tfoutfile = path.join(outdir, 'main.tf');