Skip to content

🎥 Make videos programmatically with React

awesome!

Jonny Burger495a3d8dd613
diff --git a/packages/it-tests/src/templates/validate-templates.test.ts b/packages/it-tests/src/templates/validate-templates.test.ts
index 7e518f06be..dc2e3d0b1d 100644
--- a/packages/it-tests/src/templates/validate-templates.test.ts
+++ b/packages/it-tests/src/templates/validate-templates.test.ts
@@ -1,20 +1,23 @@
import {describe, expect, it} from 'bun:test';
import {CreateVideoInternals, Template} from 'create-video';
+import {existsSync, readFileSync} from 'node:fs';
+import path from 'node:path';
const {FEATURED_TEMPLATES} = CreateVideoInternals;
const getFileForTemplate = (template: Template, file: string) => {
- return `https://github.com/${template.org}/${template.repoName}/raw/${template.defaultBranch}/${file}`;
+ return path.join(process.cwd(), '..', template.templateInMonorepo, file);
};
const findFile = async (options: string[]) => {
let entryPoint: string | null = null;
let contents: string | null = null;
for (const point of options) {
- const res = await fetch(point);
- if (res.ok) {
+ const exists = existsSync(point);
+ if (exists) {
+ const res = readFileSync(point, 'utf-8');
entryPoint = point;
- contents = await res.text();
+ contents = res;
break;
}
}
@@ -27,10 +30,8 @@ describe('Templates should be valid', () => {
it(`${template.shortName} should have a valid package.json`, async () => {
const packageJson = getFileForTemplate(template, 'package.json');
- const res = await fetch(packageJson, {});
-
- expect(res.ok).toBe(true);
- const body = await res.json();
+ const res = readFileSync(packageJson, 'utf8');
+ const body = JSON.parse(res);
if (
!template.shortName.includes('Remix') &&
@@ -41,8 +42,8 @@ describe('Templates should be valid', () => {
expect(body.scripts.build).not.toContain('index');
}
- expect(body.dependencies.remotion).toMatch(/^\^?4/);
- expect(body.dependencies['@remotion/cli']).toMatch(/^\^?4/);
+ expect(body.dependencies.remotion).toBe('workspace:*');
+ expect(body.dependencies['@remotion/cli']).toMatch('workspace:*');
expect(body.dependencies.react).toMatch(/^\^?18/);
expect(body.dependencies['react-dom']).toMatch(/^\^?18/);
@@ -50,58 +51,38 @@ describe('Templates should be valid', () => {
expect(body.dependencies['zod']).toBe('3.22.3');
}
if (body.dependencies['@types/web']) {
- expect(body.dependencies['@types/web']).toInclude('0.0.78');
+ expect(body.dependencies['@types/web']).toInclude('0.0.166');
}
- expect(body.devDependencies.prettier).toMatch(/^\^?((3).\d.\d)/);
+ expect(body.devDependencies.prettier).toMatch('3.3.3');
+ expect(body.private).toBe(true);
+ expect(body.name).toStartWith('template-');
if (!template.shortName.includes('JavaScript')) {
- expect(body.devDependencies.eslint).toMatch(/^\^?(8|9).\d+/);
- expect(body.devDependencies.typescript).toMatch(/^\^?((5).\d.\d)/);
+ expect(body.devDependencies['typescript']).toInclude('5.6.2');
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const eitherPluginOrConfig =
- body.devDependencies['@remotion/eslint-config']?.match(/^\^?4/) ||
- body.devDependencies['@remotion/eslint-plugin']?.match(/^\^?4/);
+ body.devDependencies['@remotion/eslint-config']?.match(
+ 'workspace:*',
+ ) ||
+ body.devDependencies['@remotion/eslint-plugin']?.match('workspace:*');
expect(eitherPluginOrConfig).toBeTruthy();
}
});
- it(
- template.shortName + ' should not have a package-lock.json',
- async () => {
- const packageLockJson = getFileForTemplate(
- template,
- 'package-lock.json',
- );
-
- const res = await fetch(packageLockJson);
- expect(res.status).toBe(404);
- },
- );
-
- it(template.shortName + ' should not have a yarn.lock', async () => {
- const packageLockJson = getFileForTemplate(template, 'yarn.lock');
-
- const res = await fetch(packageLockJson, {});
- expect(res.status).toBe(404);
+ it(`${template.shortName} should not have any lockfiles`, async () => {
+ expect(
+ existsSync(getFileForTemplate(template, 'package-lock.json')),
+ ).toBe(false);
+ expect(existsSync(getFileForTemplate(template, 'yarn.lock'))).toBe(false);
+ expect(existsSync(getFileForTemplate(template, 'pnpm-lock.yaml'))).toBe(
+ false,
+ );
+ expect(existsSync(getFileForTemplate(template, 'bun.lockb'))).toBe(false);
});
- it(template.shortName + ' should not have a pnpm-lock.yaml', async () => {
- const packageLockJson = getFileForTemplate(template, 'pnpm-lock.yaml');
-
- const res = await fetch(packageLockJson, {});
- expect(res.status).toBe(404);
- });
-
- it(template.shortName + ' should not have a bun.lockb', async () => {
- const packageLockJson = getFileForTemplate(template, 'bun.lockb');
-
- const res = await fetch(packageLockJson, {});
-
- expect(res.status).toBe(404);
- });
-
- it(template.shortName + ' should have a standard entry point', async () => {
+ it(`${template.shortName} should have a standard entry point`, async () => {
const {contents, entryPoint} = await findFile([
getFileForTemplate(template, 'src/index.ts'),
getFileForTemplate(template, 'src/index.js'),
@@ -112,33 +93,16 @@ describe('Templates should be valid', () => {
expect(contents).toMatch(/RemotionRoot/);
});
- it(
- template.shortName + ' should not have a standard Root file',
- async () => {
- const {contents, entryPoint} = await findFile([
- getFileForTemplate(template, 'src/Root.tsx'),
- getFileForTemplate(template, 'src/Root.jsx'),
- getFileForTemplate(template, 'remotion/Root.tsx'),
- getFileForTemplate(template, 'app/remotion/Root.tsx'),
- ]);
- expect(entryPoint).toBeTruthy();
- expect(contents).toMatch(/export const RemotionRoot/);
- },
- );
-
- it(
- template.shortName + ' should not have a standard Root file',
- async () => {
- const {contents, entryPoint} = await findFile([
- getFileForTemplate(template, 'src/Root.tsx'),
- getFileForTemplate(template, 'src/Root.jsx'),
- getFileForTemplate(template, 'remotion/Root.tsx'),
- getFileForTemplate(template, 'app/remotion/Root.tsx'),
- ]);
- expect(entryPoint).toBeTruthy();
- expect(contents).toMatch(/export const RemotionRoot/);
- },
- );
+ it(`${template.shortName} should have a standard Root file`, async () => {
+ const {contents, entryPoint} = await findFile([
+ getFileForTemplate(template, 'src/Root.tsx'),
+ getFileForTemplate(template, 'src/Root.jsx'),
+ getFileForTemplate(template, 'remotion/Root.tsx'),
+ getFileForTemplate(template, 'app/remotion/Root.tsx'),
+ ]);
+ expect(entryPoint).toBeTruthy();
+ expect(contents).toMatch(/export const RemotionRoot/);
+ });
it(`${template.shortName} should use the new config file format`, async () => {
const {contents, entryPoint} = await findFile([
@@ -153,7 +117,8 @@ describe('Templates should be valid', () => {
expect(contents).not.toContain('Config.Output');
expect(contents).not.toContain('Config.Preview');
});
- it(template.shortName + ' should use noUnusedLocals', async () => {
+
+ it(`${template.shortName} should use noUnusedLocals`, async () => {
if (template.shortName.includes('JavaScript')) {
return;
}
@@ -161,7 +126,35 @@ describe('Templates should be valid', () => {
const {contents} = await findFile([
getFileForTemplate(template, 'tsconfig.json'),
]);
- expect(contents).toInclude('noUnusedLocals');
+ if (template.shortName.includes('Skia')) {
+ expect(contents).toInclude('noUnusedLocals": false');
+ } else {
+ expect(contents).toInclude('noUnusedLocals": true');
+ }
+ });
+
+ it(`${template.shortName} should use correct prettier`, async () => {
+ const {contents} = await findFile([
+ getFileForTemplate(template, '.prettierrc'),
+ ]);
+ expect(contents).toBe(`{
+ "useTabs": false,
+ "bracketSpacing": true,
+ "tabWidth": 2
+}
+`);
+ });
+ it(`${template.shortName} should be registered in tsconfig.json`, async () => {
+ const tsconfig = path.join(process.cwd(), '..', '..', 'tsconfig.json');
+ const contents = readFileSync(tsconfig, 'utf8');
+ const parsed = JSON.parse(contents);
+
+ const references = parsed.references.map((r: any) =>
+ r.path.replace('./packages/', ''),
+ );
+ if (!template.shortName.includes('JavaScript')) {
+ expect(references).toContain(template.templateInMonorepo);
+ }
});
}
});
diff --git a/packages/template-code-hike/.prettierrc b/packages/template-code-hike/.prettierrc
index 8222cbaae8..37d5071748 100644
--- a/packages/template-code-hike/.prettierrc
+++ b/packages/template-code-hike/.prettierrc
@@ -1,5 +1,5 @@
{
- "singleQuote": false,
- "bracketSpacing": true,
- "useTabs": false
+ "useTabs": false,
+ "bracketSpacing": true,
+ "tabWidth": 2
}
diff --git a/packages/template-code-hike/package.json b/packages/template-code-hike/package.json
index fe7c46f142..1f5c5f8be4 100644
--- a/packages/template-code-hike/package.json
+++ b/packages/template-code-hike/package.json
@@ -1,37 +1,37 @@
{
- "name": "code-animation",
- "version": "1.0.0",
- "description": "My Remotion video",
- "repository": {},
- "license": "UNLICENSED",
- "type": "module",
- "dependencies": {
- "@code-hike/lighter": "0.9.4",
- "@remotion/cli": "workspace:*",
- "@remotion/google-fonts": "workspace:*",
- "@remotion/studio": "workspace:*",
- "@remotion/layout-utils": "workspace:*",
- "codehike": "1.0.0-beta.2",
- "react": "18.3.1",
- "react-dom": "18.3.1",
- "remotion": "workspace:*",
- "twoslash-cdn": "0.2.9",
- "polished": "4.3.1",
- "zod": "3.22.3"
- },
- "devDependencies": {
- "@remotion/eslint-config": "workspace:*",
- "@types/react": "18.3.1",
- "@types/web": "0.0.166",
- "eslint": "8.56.0",
- "prettier": "3.3.3",
- "typescript": "5.6.2"
- },
- "scripts": {
- "start": "remotion studio",
- "build": "remotion render Main out/video.mp4",
- "upgrade": "remotion upgrade",
- "test": "eslint src --ext ts,tsx,js,jsx && tsc"
- },
- "private": true
+ "name": "template-code-hike",
+ "version": "1.0.0",
+ "description": "My Remotion video",
+ "repository": {},
+ "license": "UNLICENSED",
+ "type": "module",
+ "dependencies": {
+ "@code-hike/lighter": "0.9.4",
+ "@remotion/cli": "workspace:*",
+ "@remotion/google-fonts": "workspace:*",
+ "@remotion/studio": "workspace:*",
+ "@remotion/layout-utils": "workspace:*",
+ "codehike": "1.0.0-beta.2",
+ "react": "18.3.1",
+ "react-dom": "18.3.1",
+ "remotion": "workspace:*",
+ "twoslash-cdn": "0.2.9",
+ "polished": "4.3.1",
+ "zod": "3.22.3"
+ },
+ "devDependencies": {
+ "@remotion/eslint-config": "workspace:*",
+ "@types/react": "18.3.1",
+ "@types/web": "0.0.166",
+ "eslint": "8.56.0",
+ "prettier": "3.3.3",
+ "typescript": "5.6.2"
+ },
+ "scripts": {
+ "start": "remotion studio",
+ "build": "remotion render Main out/video.mp4",
+ "upgrade": "remotion upgrade",
+ "test": "eslint src --ext ts,tsx,js,jsx && tsc"
+ },
+ "private": true
}
diff --git a/packages/template-next-app-tailwind/package.json b/packages/template-next-app-tailwind/package.json
index 95a4271ad8..0c2c38384d 100644
--- a/packages/template-next-app-tailwind/package.json
+++ b/packages/template-next-app-tailwind/package.json
@@ -1,5 +1,5 @@
{
- "name": "remotion-next-example",
+ "name": "template-next-app-tailwind",
"version": "0.1.0",
"private": true,
"author": {
diff --git a/packages/template-remix/package.json b/packages/template-remix/package.json
index fc4c414c8b..1bf76ceab6 100644
--- a/packages/template-remix/package.json
+++ b/packages/template-remix/package.json
@@ -1,4 +1,5 @@
{
+ "name": "template-remix",
"private": true,
"type": "module",
"scripts": {
diff --git a/packages/template-skia/.prettierrc b/packages/template-skia/.prettierrc
index dfc8cb62bd..37d5071748 100644
--- a/packages/template-skia/.prettierrc
+++ b/packages/template-skia/.prettierrc
@@ -1,5 +1,5 @@
{
- "useTabs": false,
- "bracketSpacing": true,
- "tabWidth": 2
+ "useTabs": false,
+ "bracketSpacing": true,
+ "tabWidth": 2
}
diff --git a/packages/template-skia/package.json b/packages/template-skia/package.json
index b43c679c38..df14b19a05 100644
--- a/packages/template-skia/package.json
+++ b/packages/template-skia/package.json
@@ -1,33 +1,33 @@
{
- "name": "remotion-template",
- "version": "1.0.0",
- "description": "My Remotion video",
- "scripts": {
- "start": "remotion studio",
- "build": "remotion render HelloSkia out/video.mp4",
- "upgrade": "remotion upgrade",
- "test": "eslint src --ext ts,tsx,js,jsx && tsc"
- },
- "repository": {},
- "license": "UNLICENSED",
- "dependencies": {
- "@remotion/cli": "workspace:*",
- "@remotion/skia": "workspace:*",
- "@remotion/zod-types": "workspace:*",
- "@shopify/react-native-skia": "1.3.13",
- "react": "18.3.1",
- "react-dom": "18.3.1",
- "remotion": "workspace:*",
- "zod": "3.22.3"
- },
- "devDependencies": {
- "@remotion/eslint-config": "workspace:*",
- "@types/dom-webcodecs": "0.1.11",
- "@types/react": "18.3.1",
- "@types/web": "0.0.166",
- "eslint": "8.56.0",
- "prettier": "3.3.3",
- "typescript": "5.6.2"
- },
- "private": true
+ "name": "template-skia",
+ "version": "1.0.0",
+ "description": "My Remotion video",
+ "scripts": {
+ "start": "remotion studio",
+ "build": "remotion render HelloSkia out/video.mp4",
+ "upgrade": "remotion upgrade",
+ "test": "eslint src --ext ts,tsx,js,jsx && tsc"
+ },
+ "repository": {},
+ "license": "UNLICENSED",
+ "dependencies": {
+ "@remotion/cli": "workspace:*",
+ "@remotion/skia": "workspace:*",
+ "@remotion/zod-types": "workspace:*",
+ "@shopify/react-native-skia": "1.3.13",
+ "react": "18.3.1",
+ "react-dom": "18.3.1",
+ "remotion": "workspace:*",
+ "zod": "3.22.3"
+ },
+ "devDependencies": {
+ "@remotion/eslint-config": "workspace:*",
+ "@types/dom-webcodecs": "0.1.11",
+ "@types/react": "18.3.1",
+ "@types/web": "0.0.166",
+ "eslint": "8.56.0",
+ "prettier": "3.3.3",
+ "typescript": "5.6.2"
+ },
+ "private": true
}
diff --git a/packages/template-stargazer/package.json b/packages/template-stargazer/package.json
index f79f095c12..b58a9c778a 100644
--- a/packages/template-stargazer/package.json
+++ b/packages/template-stargazer/package.json
@@ -22,5 +22,6 @@
"eslint": "8.56.0",
"prettier": "3.3.3",
"typescript": "5.6.2"
- }
+ },
+ "private": true
}
diff --git a/packages/template-stargazer/src/Root.tsx b/packages/template-stargazer/src/Root.tsx
index 22349b33bd..a119c0bb6a 100644
--- a/packages/template-stargazer/src/Root.tsx
+++ b/packages/template-stargazer/src/Root.tsx
@@ -6,7 +6,7 @@ import { waitForNoInput } from "./wait-for-no-input";
const FPS = 30;
-export function RemotionVideo() {
+export const RemotionRoot = () => {
const calculateMetadata: CalculateMetadataFunction<MainProps> = useCallback(
async ({ props, abortSignal }) => {
await waitForNoInput(abortSignal, 500);
@@ -48,4 +48,4 @@ export function RemotionVideo() {
}}
/>
);
-}
+};
diff --git a/packages/template-stargazer/src/index.ts b/packages/template-stargazer/src/index.ts
index 556dae4d83..f31c790edb 100644
--- a/packages/template-stargazer/src/index.ts
+++ b/packages/template-stargazer/src/index.ts
@@ -1,4 +1,4 @@
import { registerRoot } from "remotion";
-import { RemotionVideo } from "./Root";
+import { RemotionRoot } from "./Root";
-registerRoot(RemotionVideo);
+registerRoot(RemotionRoot);
diff --git a/packages/template-three/package.json b/packages/template-three/package.json
index 117f8fa41d..52c00ddd43 100644
--- a/packages/template-three/package.json
+++ b/packages/template-three/package.json
@@ -1,5 +1,5 @@
{
- "name": "remotion-template-three",
+ "name": "template-three",
"version": "1.0.0",
"description": "A React Three Fiber Project",
"scripts": {
diff --git a/packages/template-tts-google/.prettierrc b/packages/template-tts-google/.prettierrc
new file mode 100644
index 0000000000..37d5071748
--- /dev/null
+++ b/packages/template-tts-google/.prettierrc
@@ -0,0 +1,5 @@
+{
+ "useTabs": false,
+ "bracketSpacing": true,
+ "tabWidth": 2
+}