Skip to content

🎥 Make videos programmatically with React

added prettier

Jonny Burger7f05ee2b70fe
diff --git a/packages/gcp/.prettierrc.js b/packages/gcp/.prettierrc.js
new file mode 100644
index 0000000000..7129f6a51c
--- /dev/null
+++ b/packages/gcp/.prettierrc.js
@@ -0,0 +1,14 @@
+module.exports = {
+ singleQuote: true,
+ bracketSpacing: false,
+ useTabs: true,
+ overrides: [
+ {
+ files: ["*.yml"],
+ options: {
+ singleQuote: false,
+ },
+ },
+ ],
+ plugins: [require.resolve("prettier-plugin-organize-imports")],
+};
diff --git a/packages/gcp/package.json b/packages/gcp/package.json
index b0e055e8d1..8d1c67709d 100644
--- a/packages/gcp/package.json
+++ b/packages/gcp/package.json
@@ -1,34 +1,35 @@
{
- "name": "@remotion/gcp",
- "version": "0.0.1",
- "description": "GCP alternative to lambda rendering",
- "main": "dist/index.js",
- "scripts": {
- "build": "tsc -d && pnpm run buildContainer",
- "buildContainer": "ts-node src/admin/bundle-renderLogic.ts",
- "start": "functions-framework --target=TypescriptFunction",
- "watch": "tsc -w",
- "lint": "eslint src --ext ts,tsx"
- },
- "bin": {
- "remotion-gcp": "remotion-gcp-cli.mjs"
- },
- "dependencies": {
- "@google-cloud/functions-framework": "^3.1.3",
- "@google-cloud/storage": "^6.9.1",
- "@google-cloud/run": "^0.4.0",
- "@remotion/bundler": "3.3.51",
- "@remotion/cli": "3.3.51",
- "@remotion/renderer": "3.3.51",
- "remotion": "3.3.51"
- },
- "devDependencies": {
- "prettier-plugin-organize-imports": "^3.2.2",
- "typescript": "^4.7.0",
- "@remotion/compositor-linux-x64-musl": "3.3.51",
- "ts-node": "^10.8.0",
- "@types/minimist": "1.2.2",
- "eslint": "8.25.0",
- "@jonny/eslint-config": "3.0.266"
- }
+ "name": "@remotion/gcp",
+ "version": "0.0.1",
+ "description": "GCP alternative to lambda rendering",
+ "main": "dist/index.js",
+ "scripts": {
+ "build": "tsc -d && pnpm run buildContainer",
+ "buildContainer": "ts-node src/admin/bundle-renderLogic.ts",
+ "start": "functions-framework --target=TypescriptFunction",
+ "watch": "tsc -w",
+ "lint": "eslint src --ext ts,tsx"
+ },
+ "bin": {
+ "remotion-gcp": "remotion-gcp-cli.mjs"
+ },
+ "dependencies": {
+ "@google-cloud/functions-framework": "^3.1.3",
+ "@google-cloud/storage": "^6.9.1",
+ "@google-cloud/run": "^0.4.0",
+ "@remotion/bundler": "3.3.51",
+ "@remotion/cli": "3.3.51",
+ "@remotion/renderer": "3.3.51",
+ "remotion": "3.3.51"
+ },
+ "devDependencies": {
+ "prettier-plugin-organize-imports": "^3.2.2",
+ "typescript": "^4.7.0",
+ "prettier": "^2.7.1",
+ "@remotion/compositor-linux-x64-musl": "3.3.51",
+ "ts-node": "^10.8.0",
+ "@types/minimist": "1.2.2",
+ "eslint": "8.25.0",
+ "@jonny/eslint-config": "3.0.266"
+ }
}
diff --git a/packages/gcp/src/api/deploy-site.ts b/packages/gcp/src/api/deploy-site.ts
index 5cabaa735d..22943e1e89 100644
--- a/packages/gcp/src/api/deploy-site.ts
+++ b/packages/gcp/src/api/deploy-site.ts
@@ -1,4 +1,4 @@
-import type { WebpackOverrideFn } from 'remotion';
+import type { WebpackOverrideFn } from '@remotion/bundler';
import { gcpLs, gcpDeleteFile } from '../functions/helpers/io';
import { bundleSite } from '../shared/bundle-site';
import { getSitesKey } from '../shared/constants';
diff --git a/packages/gcp/src/cli/commands/sites/create.ts b/packages/gcp/src/cli/commands/sites/create.ts
index 9a2a0e6ca6..ece99e1ec4 100644
--- a/packages/gcp/src/cli/commands/sites/create.ts
+++ b/packages/gcp/src/cli/commands/sites/create.ts
@@ -1,175 +1,176 @@
-import { CliInternals, ConfigInternals } from '@remotion/cli';
-import { quit } from '../../helpers/quit';
-import { Log } from '../../log';
-import { BINARY_NAME } from '../../../shared/constants';
-import { existsSync, lstatSync } from 'fs';
-import path from 'path';
-import { Internals } from 'remotion';
-import { parsedGcpCli } from '../../args';
-import { validateSiteName } from '../../../shared/validate-site-name';
-import { getGcpRegion } from '../../get-gcp-region';
-import { getOrCreateBucket } from '../../../api/get-or-create-bucket';
+import { CliInternals, ConfigInternals } from "@remotion/cli";
+import { quit } from "../../helpers/quit";
+import { Log } from "../../log";
+import { BINARY_NAME } from "../../../shared/constants";
+import { existsSync, lstatSync } from "fs";
+import path from "path";
+import { Internals } from "remotion";
+import { parsedGcpCli } from "../../args";
+import { validateSiteName } from "../../../shared/validate-site-name";
+import { getGcpRegion } from "../../get-gcp-region";
+import { getOrCreateBucket } from "../../../api/get-or-create-bucket";
+import type {
+ BucketCreationProgress,
+ BundleProgress,
+ DeployToStorageProgress,
+} from "../../helpers/progress-bar";
import {
- BucketCreationProgress,
- BundleProgress,
- DeployToStorageProgress,
-} from '../../helpers/progress-bar';
-import {
- makeBucketProgress,
- makeBundleProgress,
- makeDeployProgressBar,
-} from '../../helpers/progress-bar';
-import { deploySite } from '../../../api/deploy-site';
+ makeBucketProgress,
+ makeBundleProgress,
+ makeDeployProgressBar,
+} from "../../helpers/progress-bar";
+import { deploySite } from "../../../api/deploy-site";
-export const SITES_CREATE_SUBCOMMAND = 'create';
+export const SITES_CREATE_SUBCOMMAND = "create";
export const sitesCreateSubcommand = async (
- args: string[],
- remotionRoot: string) => {
- const { file, reason } = CliInternals.findEntryPoint(args, remotionRoot);
- if (!file) {
- Log.error('No entry file passed.');
- Log.info(
- 'Pass an additional argument specifying the entry file of your Remotion project:'
- );
- Log.info();
- Log.info(`${BINARY_NAME} deploy <entry-file.ts>`);
- quit(1);
- return;
- }
-
- Log.verbose('Entry point:', file, 'Reason:', reason);
-
- const absoluteFile = path.join(process.cwd(), file);
- if (!existsSync(absoluteFile)) {
- Log.error(
- `No file exists at ${absoluteFile}. Make sure the path exists and try again.`
- );
- quit(1);
- }
-
- if (lstatSync(absoluteFile).isDirectory()) {
- Log.error(
- `You passed a path ${absoluteFile} but it is a directory. Pass a file instead.`
- );
- quit(1);
- }
-
- const desiredSiteName = parsedGcpCli['site-name'] ?? undefined;
- if (desiredSiteName !== undefined) {
- validateSiteName(desiredSiteName);
- }
-
- const progressBar = CliInternals.createOverwriteableCliOutput(
- CliInternals.quietFlagProvided()
- );
-
- const multiProgress: {
- bundleProgress: BundleProgress;
- bucketProgress: BucketCreationProgress;
- deployProgress: DeployToStorageProgress;
- } = {
- bundleProgress: {
- doneIn: null,
- progress: 0,
- },
- bucketProgress: {
- bucketCreated: false,
- doneIn: null,
- },
- deployProgress: {
- doneIn: null,
- totalSize: null,
- sizeUploaded: 0,
- stats: null,
- },
- };
-
- const updateProgress = () => {
- progressBar.update(
- [
- makeBundleProgress(multiProgress.bundleProgress),
- makeBucketProgress(multiProgress.bucketProgress),
- makeDeployProgressBar(multiProgress.deployProgress),
- ].join('\n')
- );
- };
-
- const bucketStart = Date.now();
-
- const { bucketName } = await getOrCreateBucket({
- region: getGcpRegion(),
- onBucketEnsured: () => {
- multiProgress.bucketProgress.bucketCreated = true;
- updateProgress();
- },
- });
-
- multiProgress.bucketProgress.doneIn = Date.now() - bucketStart;
- updateProgress();
-
- const bundleStart = Date.now();
-
- const { serveUrl, siteName, stats } = await deploySite({
- entryPoint: absoluteFile,
- siteName: desiredSiteName,
- bucketName,
- options: {
- onBundleProgress: (progress: number) => {
- multiProgress.bundleProgress = {
- progress,
- doneIn: progress === 100 ? Date.now() - bundleStart : null,
- };
- },
- onUploadProgress: (p) => {
- multiProgress.deployProgress = {
- sizeUploaded: p.sizeUploaded,
- totalSize: p.totalSize,
- doneIn: null,
- stats: null,
- };
- updateProgress();
- },
- enableCaching: ConfigInternals.getWebpackCaching(),
- webpackOverride: ConfigInternals.getWebpackOverrideFn() ?? ((f) => f),
- },
- });
-
- updateProgress();
-
- const uploadStart = Date.now();
-
- const uploadDuration = Date.now() - uploadStart;
- multiProgress.deployProgress = {
- sizeUploaded: 1,
- totalSize: 1,
- doneIn: uploadDuration,
- stats: {
- addedFiles: stats.uploadedFiles,
- removedFiles: stats.deletedFiles,
- untouchedFiles: stats.untouchedFiles,
- },
- };
- updateProgress();
-
- Log.info();
- Log.info();
- Log.info('Deployed to GCP Storage!');
-
- Log.info(`Serve URL: ${serveUrl}`);
- Log.info(`Site Name: ${siteName}`);
-
- Log.info();
- Log.info(
- CliInternals.chalk.blueBright(
- 'ℹ️ If you make changes to your code, you need to redeploy the site. You can overwrite the existing site by running:'
- )
- );
- Log.info(
- CliInternals.chalk.blueBright(
- ['npx remotion gcp sites create', args[0], `--site-name=${siteName}`]
- .filter(Internals.truthy)
- .join(' ')
- )
- );
-}
\ No newline at end of file
+ args: string[],
+ remotionRoot: string
+) => {
+ const { file, reason } = CliInternals.findEntryPoint(args, remotionRoot);
+ if (!file) {
+ Log.error("No entry file passed.");
+ Log.info(
+ "Pass an additional argument specifying the entry file of your Remotion project:"
+ );
+ Log.info();
+ Log.info(`${BINARY_NAME} deploy <entry-file.ts>`);
+ quit(1);
+ return;
+ }
+
+ Log.verbose("Entry point:", file, "Reason:", reason);
+
+ const absoluteFile = path.join(process.cwd(), file);
+ if (!existsSync(absoluteFile)) {
+ Log.error(
+ `No file exists at ${absoluteFile}. Make sure the path exists and try again.`
+ );
+ quit(1);
+ }
+
+ if (lstatSync(absoluteFile).isDirectory()) {
+ Log.error(
+ `You passed a path ${absoluteFile} but it is a directory. Pass a file instead.`
+ );
+ quit(1);
+ }
+
+ const desiredSiteName = parsedGcpCli["site-name"] ?? undefined;
+ if (desiredSiteName !== undefined) {
+ validateSiteName(desiredSiteName);
+ }
+
+ const progressBar = CliInternals.createOverwriteableCliOutput(
+ CliInternals.quietFlagProvided()
+ );
+
+ const multiProgress: {
+ bundleProgress: BundleProgress;
+ bucketProgress: BucketCreationProgress;
+ deployProgress: DeployToStorageProgress;
+ } = {
+ bundleProgress: {
+ doneIn: null,
+ progress: 0,
+ },
+ bucketProgress: {
+ bucketCreated: false,
+ doneIn: null,
+ },
+ deployProgress: {
+ doneIn: null,
+ totalSize: null,
+ sizeUploaded: 0,
+ stats: null,
+ },
+ };
+
+ const updateProgress = () => {
+ progressBar.update(
+ [
+ makeBundleProgress(multiProgress.bundleProgress),
+ makeBucketProgress(multiProgress.bucketProgress),
+ makeDeployProgressBar(multiProgress.deployProgress),
+ ].join("\n")
+ );
+ };
+
+ const bucketStart = Date.now();
+
+ const { bucketName } = await getOrCreateBucket({
+ region: getGcpRegion(),
+ onBucketEnsured: () => {
+ multiProgress.bucketProgress.bucketCreated = true;
+ updateProgress();
+ },
+ });
+
+ multiProgress.bucketProgress.doneIn = Date.now() - bucketStart;
+ updateProgress();
+
+ const bundleStart = Date.now();
+
+ const { serveUrl, siteName, stats } = await deploySite({
+ entryPoint: absoluteFile,
+ siteName: desiredSiteName,
+ bucketName,
+ options: {
+ onBundleProgress: (progress: number) => {
+ multiProgress.bundleProgress = {
+ progress,
+ doneIn: progress === 100 ? Date.now() - bundleStart : null,
+ };
+ },
+ onUploadProgress: (p) => {
+ multiProgress.deployProgress = {
+ sizeUploaded: p.sizeUploaded,
+ totalSize: p.totalSize,
+ doneIn: null,
+ stats: null,
+ };
+ updateProgress();
+ },
+ enableCaching: ConfigInternals.getWebpackCaching(),
+ webpackOverride: ConfigInternals.getWebpackOverrideFn() ?? ((f) => f),
+ },
+ });
+
+ updateProgress();
+
+ const uploadStart = Date.now();
+
+ const uploadDuration = Date.now() - uploadStart;
+ multiProgress.deployProgress = {
+ sizeUploaded: 1,
+ totalSize: 1,
+ doneIn: uploadDuration,
+ stats: {
+ addedFiles: stats.uploadedFiles,
+ removedFiles: stats.deletedFiles,
+ untouchedFiles: stats.untouchedFiles,
+ },
+ };
+ updateProgress();
+
+ Log.info();
+ Log.info();
+ Log.info("Deployed to GCP Storage!");
+
+ Log.info(`Serve URL: ${serveUrl}`);
+ Log.info(`Site Name: ${siteName}`);
+
+ Log.info();
+ Log.info(
+ CliInternals.chalk.blueBright(
+ "ℹ️ If you make changes to your code, you need to redeploy the site. You can overwrite the existing site by running:"
+ )
+ );
+ Log.info(
+ CliInternals.chalk.blueBright(
+ ["npx remotion gcp sites create", args[0], `--site-name=${siteName}`]
+ .filter(Internals.truthy)
+ .join(" ")
+ )
+ );
+};
diff --git a/packages/gcp/src/shared/validate-project-id.ts b/packages/gcp/src/shared/validate-project-id.ts
index 87f8f47007..925ad3dd6c 100644
--- a/packages/gcp/src/shared/validate-project-id.ts
+++ b/packages/gcp/src/shared/validate-project-id.ts
@@ -1,35 +1,35 @@
-import { exec } from 'child_process';
+import { exec } from "child_process";
export const validateProjectID = (projectID: unknown) => {
- if (typeof projectID === 'undefined') {
- throw new TypeError(
- `The 'project-id' argument must be provided, but is missing.`
- );
- }
+ if (typeof projectID === "undefined") {
+ throw new TypeError(
+ `The 'project-id' argument must be provided, but is missing.`
+ );
+ }
- if (typeof projectID !== 'string') {
- throw new TypeError(
- `The 'project-id' argument must be a string, but is ${JSON.stringify(
- projectID
- )}`
- );
- }
+ if (typeof projectID !== "string") {
+ throw new TypeError(
+ `The 'project-id' argument must be a string, but is ${JSON.stringify(
+ projectID
+ )}`
+ );
+ }
- // TODO: Complete this with the node API instead of gcloud
- exec(`gcloud projects describe ${projectID}`,
- (error) => {
- if (error !== null) {
- throw new Error(`project-id ${projectID} not found in GCP. It either does not exist, or you do not have access to it.`)
- } else {
- return
- }
- });
+ // TODO: Complete this with the node API instead of gcloud
+ exec(`gcloud projects describe ${projectID}`, (error) => {
+ if (error !== null) {
+ throw new Error(
+ `project-id ${projectID} not found in GCP. It either does not exist, or you do not have access to it.`
+ );
+ } else {
+ }
+ });
- if (!projectID.match(/^[a-zA-Z][a-zA-Z0-9-]{0,48}[a-zA-Z0-9]$/g)) {
- throw new Error(
- "The `project-id` must match the RegExp `/^[a-zA-Z][a-zA-Z0-9-]{0,48}[a-zA-Z0-9]$/g`. This means it may only start with a letter, end with a letter or number, and contain up to 49 lowercase letters, numbers or hyphens. You passed: " +
- projectID +
- '. Check for invalid characters.'
- );
- }
+ if (!projectID.match(/^[a-zA-Z][a-zA-Z0-9-]{0,48}[a-zA-Z0-9]$/g)) {
+ throw new Error(
+ "The `project-id` must match the RegExp `/^[a-zA-Z][a-zA-Z0-9-]{0,48}[a-zA-Z0-9]$/g`. This means it may only start with a letter, end with a letter or number, and contain up to 49 lowercase letters, numbers or hyphens. You passed: " +
+ projectID +
+ ". Check for invalid characters."
+ );
+ }
};
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 5611c48008..a84a8196bf 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -574,6 +574,7 @@ importers:
'@remotion/renderer': 3.3.51
'@types/minimist': 1.2.2
eslint: 8.25.0
+ prettier: ^2.7.1
prettier-plugin-organize-imports: ^3.2.2
remotion: 3.3.51
ts-node: ^10.8.0
@@ -591,6 +592,7 @@ importers:
'@remotion/compositor-linux-x64-musl': link:../compositor-linux-x64-musl
'@types/minimist': 1.2.2
eslint: 8.25.0
+ prettier: 2.7.1
prettier-plugin-organize-imports: 3.2.2_j2odc4yr77iddtreafyicbq5hi
ts-node: 10.8.0_vnj66vw6pmisrnpmmxy72mdbpa
typescript: 4.7.2
@@ -796,6 +798,8 @@ importers:
remotion: 3.3.51
typescript: ^4.7.0
dependencies:
+ react: 18.0.0
+ react-dom: [email protected]
remotion: link:../core
devDependencies:
'@jonny/eslint-config': 3.0.266_t54va6jeo5lf3vtqih5uiyrm5e
@@ -804,8 +808,6 @@ importers:
eslint: 8.25.0
prettier: 2.7.1
prettier-plugin-organize-imports: 2.3.4_j2odc4yr77iddtreafyicbq5hi
- react: 18.0.0
- react-dom: [email protected]
typescript: 4.7.2
packages/motion-blur: