Skip to content

🎥 Make videos programmatically with React

propagate gitSource

Jonny Burgere59680cf80d6
diff --git a/packages/bundler/src/bundle.ts b/packages/bundler/src/bundle.ts
index d7297eae79..1fa4388c36 100644
--- a/packages/bundler/src/bundle.ts
+++ b/packages/bundler/src/bundle.ts
@@ -1,3 +1,4 @@
+import type {GitSource} from '@remotion/studio-shared';
import {SOURCE_MAP_ENDPOINT} from '@remotion/studio-shared';
import fs, {promises} from 'node:fs';
import os from 'node:os';
@@ -86,6 +87,8 @@ export type BundleOptions = {
onProgress?: (progress: number) => void;
ignoreRegisterRootWarning?: boolean;
onDirectoryCreated?: (dir: string) => void;
+ // TODO: Make optional
+ gitSource: GitSource | null;
} & LegacyBundleOptions;
type Arguments =
@@ -107,6 +110,8 @@ const convertArgumentsIntoOptions = (args: Arguments): BundleOptions => {
entryPoint: firstArg,
onProgress: args[1],
...(args[2] ?? {}),
+ // TODO: Remove
+ gitSource: null,
};
}
@@ -119,7 +124,7 @@ const convertArgumentsIntoOptions = (args: Arguments): BundleOptions => {
const recursionLimit = 5;
-export const findClosestFolderWithFile = (
+export const findClosestFolderWithItem = (
currentDir: string,
file: string,
): string | null => {
@@ -138,7 +143,7 @@ export const findClosestFolderWithFile = (
};
const findClosestPackageJsonFolder = (currentDir: string): string | null => {
- return findClosestFolderWithFile(currentDir, 'package.json');
+ return findClosestFolderWithItem(currentDir, 'package.json');
};
const validateEntryPoint = async (entryPoint: string) => {
@@ -270,6 +275,7 @@ export async function bundle(...args: Arguments): Promise<string> {
title: 'Remotion Bundle',
renderDefaults: undefined,
publicFolderExists: baseDir + '/public',
+ gitSource: actualArgs.gitSource,
});
fs.writeFileSync(path.join(outDir, 'index.html'), html);
diff --git a/packages/bundler/src/index-html.ts b/packages/bundler/src/index-html.ts
index 19095a6863..3b95dacb91 100644
--- a/packages/bundler/src/index-html.ts
+++ b/packages/bundler/src/index-html.ts
@@ -1,4 +1,4 @@
-import type {RenderDefaults} from '@remotion/studio';
+import type {GitSource, RenderDefaults} from '@remotion/studio';
import path from 'node:path';
import type {StaticFile} from 'remotion';
import {Internals} from 'remotion';
@@ -18,6 +18,7 @@ export const indexHtml = ({
title,
renderDefaults,
publicFolderExists,
+ gitSource,
}: {
staticHash: string;
baseDir: string;
@@ -33,6 +34,7 @@ export const indexHtml = ({
includeFavicon: boolean;
title: string;
renderDefaults: RenderDefaults | undefined;
+ gitSource: GitSource | null;
}) =>
// Must setup remotion_editorName and remotion.remotion_projectName before bundle.js is loaded
`
@@ -92,6 +94,13 @@ ${
`
: ''
}
+ ${
+ gitSource
+ ? `<script>window.remotion_gitSource = ${JSON.stringify(
+ gitSource,
+ )};</script>`
+ : null
+ }
<script>window.remotion_staticFiles = ${JSON.stringify(publicFiles)}</script>
<script>window.remotion_publicFolderExists = ${
publicFolderExists ? `"${publicFolderExists}"` : 'null'
diff --git a/packages/bundler/src/index.ts b/packages/bundler/src/index.ts
index 9ac9e2d69a..a29f5ef946 100644
--- a/packages/bundler/src/index.ts
+++ b/packages/bundler/src/index.ts
@@ -1,4 +1,4 @@
-import {findClosestFolderWithFile, getConfig} from './bundle';
+import {findClosestFolderWithItem, getConfig} from './bundle';
import {indexHtml} from './index-html';
import {readRecursively} from './read-recursively';
import {cacheExists, clearCache} from './webpack-cache';
@@ -14,9 +14,10 @@ export const BundlerInternals = {
clearCache,
getConfig,
readRecursively,
- findClosestFolderWithFile,
+ findClosestFolderWithItem,
};
+export type {GitSource} from '@remotion/studio';
export {bundle, BundleOptions, LegacyBundleOptions} from './bundle';
export {WebpackConfiguration, WebpackOverrideFn} from './webpack-config';
export {webpack};
diff --git a/packages/cli/src/benchmark.ts b/packages/cli/src/benchmark.ts
index 3594797f3d..0fbff47dc9 100644
--- a/packages/cli/src/benchmark.ts
+++ b/packages/cli/src/benchmark.ts
@@ -229,6 +229,8 @@ export const benchmarkCommand = async (
quietProgress: false,
quietFlag: quietFlagProvided(),
outDir: null,
+ // Not needed for benchmark
+ gitSource: null,
});
registerCleanupJob(() => cleanupBundle());
diff --git a/packages/cli/src/bundle.ts b/packages/cli/src/bundle.ts
index 50e966236d..4e1db9d4d4 100644
--- a/packages/cli/src/bundle.ts
+++ b/packages/cli/src/bundle.ts
@@ -6,6 +6,7 @@ import path from 'path';
import {chalk} from './chalk';
import {findEntryPoint} from './entry-point';
import {getCliOptions} from './get-cli-options';
+import {getGitSource} from './get-github-repository';
import {Log} from './log';
import {parsedCli, quietFlagProvided} from './parse-command-line';
import {bundleOnCli} from './setup-cache';
@@ -55,7 +56,7 @@ export const bundleCommand = async (
? path.resolve(process.cwd(), parsedCli['out-dir'])
: path.join(remotionRoot, 'build');
- const gitignoreFolder = BundlerInternals.findClosestFolderWithFile(
+ const gitignoreFolder = BundlerInternals.findClosestFolderWithItem(
outputPath,
'.gitignore',
);
@@ -77,6 +78,8 @@ export const bundleCommand = async (
rmSync(outputPath, {recursive: true});
}
+ const gitSource = getGitSource(remotionRoot);
+
const output = await bundleOnCli({
fullPath: file,
logLevel,
@@ -105,6 +108,7 @@ export const bundleCommand = async (
},
quietFlag: quietFlagProvided(),
outDir: outputPath,
+ gitSource,
});
Log.infoAdvanced(
diff --git a/packages/cli/src/compositions.ts b/packages/cli/src/compositions.ts
index a2fc9bcb57..ebafe2cb70 100644
--- a/packages/cli/src/compositions.ts
+++ b/packages/cli/src/compositions.ts
@@ -67,6 +67,8 @@ export const listCompositionsCommand = async (
quietProgress: false,
quietFlag: quietFlagProvided(),
outDir: null,
+ // Not needed for compositions
+ gitSource: null,
});
registerCleanupJob(() => cleanupBundle());
diff --git a/packages/cli/src/get-github-repository.ts b/packages/cli/src/get-github-repository.ts
new file mode 100644
index 0000000000..525bf83a94
--- /dev/null
+++ b/packages/cli/src/get-github-repository.ts
@@ -0,0 +1,116 @@
+import {BundlerInternals} from '@remotion/bundler';
+import type {GitSource} from '@remotion/studio';
+import {execSync} from 'child_process';
+import {existsSync, readFileSync} from 'fs';
+import path from 'path';
+
+export type ParsedGitRemote = {
+ type: 'github';
+ org: string;
+ name: string;
+};
+
+const getGitRemotes = (lines: string[]) => {
+ const sections: string[][] = [];
+
+ let open = false;
+ for (const line of lines) {
+ if (line.startsWith('[')) {
+ if (line.startsWith('[remote')) {
+ open = true;
+ sections.push([line]);
+ } else {
+ open = false;
+ }
+ } else if (open) {
+ sections[sections.length - 1].push(line);
+ }
+ }
+
+ return sections.map((s) => {
+ const url = s.find((l) => l.trimStart().startsWith('url = '));
+
+ return {
+ remote: s[0].replace('[remote "', '').replace('"]', ''),
+ url: url ? url.replace('url = ', '').trim() : null,
+ };
+ });
+};
+
+export const getGitRemoteOrigin = (remotionRoot: string) => {
+ const gitFolder = BundlerInternals.findClosestFolderWithItem(
+ remotionRoot,
+ '.git',
+ );
+ if (!gitFolder) {
+ return null;
+ }
+
+ const gitConfig = path.join(gitFolder, '.git', 'config');
+ if (!existsSync(gitConfig)) {
+ return null;
+ }
+
+ const contents = readFileSync(gitConfig, 'utf-8');
+ const lines = contents.split('\n');
+
+ const remotes = getGitRemotes(lines);
+ const origin = remotes.find((r) => r.remote === 'origin');
+ return origin ?? null;
+};
+
+export const normalizeGitRemoteUrl = (url: string): ParsedGitRemote | null => {
+ if (url.startsWith('[email protected]')) {
+ const matched = url.match(/[email protected]:(.*)\/(.*)\.git/);
+ if (matched) {
+ return {
+ type: 'github',
+ name: matched[2],
+ org: matched[1],
+ };
+ }
+ }
+
+ const gitHubMatch = url.match(/https:\/\/github.com\/(.*)\/(.*)\.git/);
+ if (gitHubMatch) {
+ return {
+ type: 'github',
+ name: gitHubMatch[2],
+ org: gitHubMatch[1],
+ };
+ }
+
+ return null;
+};
+
+export const getGifRef = (): string | null => {
+ try {
+ return execSync('git rev-parse --abbrev-ref HEAD').toString('utf-8').trim();
+ } catch (err) {
+ return null;
+ }
+};
+
+export const getGitSource = (remotionRoot: string): GitSource | null => {
+ const ref = getGifRef();
+ if (!ref) {
+ return null;
+ }
+
+ const origin = getGitRemoteOrigin(remotionRoot);
+ if (!origin || !origin.url) {
+ return null;
+ }
+
+ const parsed = normalizeGitRemoteUrl(origin.url);
+ if (!parsed) {
+ return null;
+ }
+
+ return {
+ name: parsed.name,
+ org: parsed.org,
+ ref,
+ type: 'github',
+ };
+};
diff --git a/packages/cli/src/render-flows/render.ts b/packages/cli/src/render-flows/render.ts
index 53aff1e411..c39eea6319 100644
--- a/packages/cli/src/render-flows/render.ts
+++ b/packages/cli/src/render-flows/render.ts
@@ -238,6 +238,8 @@ export const renderVideoFlow = async ({
quietProgress: updatesDontOverwrite,
quietFlag: quietFlagProvided(),
outDir: null,
+ // Not needed for render
+ gitSource: null,
},
);
diff --git a/packages/cli/src/render-flows/still.ts b/packages/cli/src/render-flows/still.ts
index 76de78cf07..e3f6966ec9 100644
--- a/packages/cli/src/render-flows/still.ts
+++ b/packages/cli/src/render-flows/still.ts
@@ -171,6 +171,8 @@ export const renderStillFlow = async ({
quietProgress: updatesDontOverwrite,
quietFlag: quietFlagProvided(),
outDir: null,
+ // Not needed for still
+ gitSource: null,
},
);
diff --git a/packages/cli/src/setup-cache.ts b/packages/cli/src/setup-cache.ts
index 150899d5a1..5e4f5b5773 100644
--- a/packages/cli/src/setup-cache.ts
+++ b/packages/cli/src/setup-cache.ts
@@ -2,6 +2,7 @@ import type {LegacyBundleOptions} from '@remotion/bundler';
import {bundle, BundlerInternals} from '@remotion/bundler';
import type {LogLevel} from '@remotion/renderer';
import {RenderInternals} from '@remotion/renderer';
+import type {GitSource} from '@remotion/studio';
import type {BundlingState, CopyingState} from '@remotion/studio-server';
import {ConfigInternals} from './config';
import {Log} from './log';
@@ -25,6 +26,7 @@ export const bundleOnCliOrTakeServeUrl = async ({
quietProgress,
quietFlag,
outDir,
+ gitSource,
}: {
fullPath: string;
remotionRoot: string;
@@ -41,6 +43,7 @@ export const bundleOnCliOrTakeServeUrl = async ({
quietProgress: boolean;
quietFlag: boolean;
outDir: string | null;
+ gitSource: GitSource | null;
}): Promise<{
urlOrBundle: string;
cleanup: () => void;
@@ -75,6 +78,7 @@ export const bundleOnCliOrTakeServeUrl = async ({
quietProgress,
quietFlag,
outDir,
+ gitSource,
});
return {
@@ -96,6 +100,7 @@ export const bundleOnCli = async ({
quietProgress,
quietFlag,
outDir,
+ gitSource,
}: {
fullPath: string;
remotionRoot: string;
@@ -112,6 +117,7 @@ export const bundleOnCli = async ({
quietProgress: boolean;
quietFlag: boolean;
outDir: string | null;
+ gitSource: GitSource | null;
}) => {
const shouldCache = ConfigInternals.getWebpackCaching();
@@ -231,6 +237,7 @@ export const bundleOnCli = async ({
},
onDirectoryCreated,
outDir: outDir ?? undefined,
+ gitSource,
...options,
});
diff --git a/packages/cli/src/studio.ts b/packages/cli/src/studio.ts
index edf56652f7..e1044df1a3 100644
--- a/packages/cli/src/studio.ts
+++ b/packages/cli/src/studio.ts
@@ -5,6 +5,7 @@ import {getNumberOfSharedAudioTags} from './config/number-of-shared-audio-tags';
import {convertEntryPointToServeUrl} from './convert-entry-point-to-serve-url';
import {findEntryPoint} from './entry-point';
import {getEnvironmentVariables} from './get-env';
+import {getGitSource} from './get-github-repository';
import {getInputProps} from './get-input-props';
import {getRenderDefaults} from './get-render-defaults';
import {Log} from './log';
@@ -82,6 +83,8 @@ export const studioCommand = async (
const keyboardShortcutsEnabled =
ConfigInternals.getKeyboardShortcutsEnabled();
+ const gitSource = getGitSource(remotionRoot);
+
await StudioServerInternals.startStudio({
previewEntry: require.resolve('@remotion/studio/entry'),
browserArgs: parsedCli['browser-args'],
@@ -110,5 +113,6 @@ export const studioCommand = async (
// Minimist quirk: Adding `--no-open` flag will result in {['no-open']: false, open: true}
// @ts-expect-error
parsedCliOpen: parsedCli.open,
+ gitSource,
});
};
diff --git a/packages/cli/src/test/get-github-repo.test.ts b/packages/cli/src/test/get-github-repo.test.ts
new file mode 100644
index 0000000000..a8159e2a6e
--- /dev/null
+++ b/packages/cli/src/test/get-github-repo.test.ts
@@ -0,0 +1,44 @@
+import {expect} from 'bun:test';
+import {test} from 'vitest';
+import {
+ getGifRef,
+ getGitRemoteOrigin,
+ getGitSource,
+ normalizeGitRemoteUrl,
+} from '../get-github-repository';
+
+test('Get GitHub repo', () => {
+ expect(getGitRemoteOrigin(__dirname)).toEqual({
+ remote: 'origin',
+ url: 'https://github.com/remotion-dev/remotion.git',
+ });
+});
+
+test('Should normalize SSH URLs', () => {
+ expect(
+ normalizeGitRemoteUrl('[email protected]:JonnyBurger/website-scroller.git'),
+ ).toEqual({
+ type: 'github',
+ org: 'JonnyBurger',
+ name: 'website-scroller',
+ });
+});
+
+test('Should normalize HTTPS URLs', () => {
+ expect(
+ normalizeGitRemoteUrl('https://github.com/remotion-dev/remotion.git'),
+ ).toEqual({
+ type: 'github',
+ org: 'remotion-dev',
+ name: 'remotion',
+ });
+});
+
+test('Should get Gif Ref', () => {
+ expect(typeof getGifRef() === 'string').toBe(true);
+});
+
+test('Should get Git Source', () => {
+ const git = getGitSource(process.cwd());
+ expect(git).not.toBeNull();
+});
diff --git a/packages/cloudrun/src/api/deploy-site.ts b/packages/cloudrun/src/api/deploy-site.ts
index 0fe80db6d3..28b498deda 100644
--- a/packages/cloudrun/src/api/deploy-site.ts
+++ b/packages/cloudrun/src/api/deploy-site.ts
@@ -1,4 +1,4 @@
-import type {WebpackOverrideFn} from '@remotion/bundler';
+import type {GitSource, WebpackOverrideFn} from '@remotion/bundler';
import {NoReactAPIs} from '@remotion/renderer/pure';
import {cloudrunDeleteFile, cloudrunLs} from '../functions/helpers/io';
import {bundleSite} from '../shared/bundle-site';
@@ -26,6 +26,8 @@ export type DeploySiteInput = {
rootDir?: string;
bypassBucketNameValidation?: boolean;
};
+ // TODO: Make optional and move into options
+ gitSource: GitSource | null;
};
export type DeploySiteOutput = Promise<{
@@ -43,6 +45,7 @@ const deploySiteRaw = async ({
bucketName,
siteName,
options,
+ gitSource,
}: DeploySiteInput): DeploySiteOutput => {
validateBucketName(bucketName, {mustStartWithRemotion: true});
@@ -71,6 +74,7 @@ const deploySiteRaw = async ({
ignoreRegisterRootWarning: options?.ignoreRegisterRootWarning,
onProgress: options?.onBundleProgress ?? (() => undefined),
entryPoint,
+ gitSource,
}),
]);
diff --git a/packages/cloudrun/src/cli/commands/sites/create.ts b/packages/cloudrun/src/cli/commands/sites/create.ts
index 089d6b77cc..31bf9dd63f 100644
--- a/packages/cloudrun/src/cli/commands/sites/create.ts
+++ b/packages/cloudrun/src/cli/commands/sites/create.ts
@@ -156,6 +156,7 @@ export const sitesCreateSubcommand = async (
enableCaching: ConfigInternals.getWebpackCaching(),
webpackOverride: ConfigInternals.getWebpackOverrideFn() ?? ((f) => f),
},
+ gitSource: null,
});
updateProgress();
diff --git a/packages/lambda/src/api/deploy-site.ts b/packages/lambda/src/api/deploy-site.ts
index b3f64c1e57..450eab3008 100644
--- a/packages/lambda/src/api/deploy-site.ts
+++ b/packages/lambda/src/api/deploy-site.ts
@@ -1,4 +1,4 @@
-import type {WebpackOverrideFn} from '@remotion/bundler';
+import type {GitSource, WebpackOverrideFn} from '@remotion/bundler';
import {NoReactAPIs} from '@remotion/renderer/pure';
import fs from 'node:fs';
import {lambdaDeleteFile, lambdaLs} from '../functions/helpers/io';
@@ -33,6 +33,8 @@ export type DeploySiteInput = {
bypassBucketNameValidation?: boolean;
};
privacy?: 'public' | 'no-acl';
+ // TODO: Make optional
+ gitSource: GitSource | null;
};
export type DeploySiteOutput = Promise<{
@@ -52,6 +54,7 @@ const deploySiteRaw = async ({
options,
region,
privacy: passedPrivacy,
+ gitSource,
}: DeploySiteInput): DeploySiteOutput => {
validateAwsRegion(region);
validateBucketName(bucketName, {
@@ -93,6 +96,7 @@ const deploySiteRaw = async ({
ignoreRegisterRootWarning: options?.ignoreRegisterRootWarning,
onProgress: options?.onBundleProgress ?? (() => undefined),
entryPoint,
+ gitSource,
}),
]);
diff --git a/packages/lambda/src/cli/commands/sites/create.ts b/packages/lambda/src/cli/commands/sites/create.ts
index d789bffebc..8954dcef5e 100644
--- a/packages/lambda/src/cli/commands/sites/create.ts
+++ b/packages/lambda/src/cli/commands/sites/create.ts
@@ -151,6 +151,7 @@ export const sitesCreateSubcommand = async (
},
region: getAwsRegion(),
privacy: parsedLambdaCli.privacy as Exclude<Privacy, 'private'> | undefined,
+ gitSource: null,
});
const uploadDuration = Date.now() - uploadStart;
multiProgress.deployProgress = {
diff --git a/packages/lambda/src/shared/bundle-site.ts b/packages/lambda/src/shared/bundle-site.ts
index c9a0d71ac2..4d46148bad 100644
--- a/packages/lambda/src/shared/bundle-site.ts
+++ b/packages/lambda/src/shared/bundle-site.ts
@@ -1,3 +1,4 @@
import {bundle} from '@remotion/bundler';
export const bundleSite = bundle;
+export type {GitSource} from '@remotion/bundler';
diff --git a/packages/lambda/src/test/integration/delete-site.test.ts b/packages/lambda/src/test/integration/delete-site.test.ts
index 23dfdc7ba2..986c5a1026 100644
--- a/packages/lambda/src/test/integration/delete-site.test.ts
+++ b/packages/lambda/src/test/integration/delete-site.test.ts
@@ -23,6 +23,7 @@ test('Return more than 0 total size if site did not exist', async () => {
bucketName,
entryPoint: 'first',
region: 'eu-west-1',
+ gitSource: null,
});
expect(
(
diff --git a/packages/lambda/src/test/integration/deploy-site.test.ts b/packages/lambda/src/test/integration/deploy-site.test.ts
index 69eb122400..5a1de74087 100644
--- a/packages/lambda/src/test/integration/deploy-site.test.ts
+++ b/packages/lambda/src/test/integration/deploy-site.test.ts
@@ -11,6 +11,7 @@ test('Should throw on wrong prefix', async () => {
bucketName: 'wrongprefix',
entryPoint: 'first',
region: 'us-east-1',
+ gitSource: null,
}),
).rejects.toThrow(/The bucketName parameter must start /);
});
@@ -34,6 +35,7 @@ test("Should throw if bucket doesn't exist", () => {
entryPoint: 'first',
region: 'ap-northeast-1',
siteName: 'testing',
+ gitSource: null,
}),
).rejects.toThrow(
/No bucket with the name remotionlambda-non-existed exists/,
@@ -50,6 +52,7 @@ test('Should apply name if given', async () => {
entryPoint: 'first',
region: 'ap-northeast-1',
siteName: 'testing',
+ gitSource: null,
}),
).toEqual({
siteName: 'testing',
@@ -73,6 +76,7 @@ test('Should use a random hash if no siteName is given', async () => {
entryPoint: 'first',
region: 'ap-northeast-1',
siteName: 'testing',
+ gitSource: null,
}),
).toEqual({
siteName: 'testing',
@@ -96,12 +100,14 @@ test('Should delete the previous site if deploying the new one', async () => {
entryPoint: 'first',
region: 'ap-northeast-1',
siteName: 'testing',
+ gitSource: null,
});
await deploySite({
bucketName,
entryPoint: 'second',
region: 'ap-northeast-1',
siteName: 'testing',
+ gitSource: null,
});
const files = await lambdaLs({
@@ -132,12 +138,14 @@ test('Should keep the previous site if deploying the new one with different ID',
entryPoint: 'first',
region: 'ap-northeast-1',
siteName: 'testing',
+ gitSource: null,
});
await deploySite({
bucketName,
entryPoint: 'second',
region: 'ap-northeast-1',
siteName: 'testing-2',
+ gitSource: null,
});
const files = await lambdaLs({
@@ -178,18 +186,21 @@ test('Should not delete site with same prefix', async () => {
});
await deploySite({
+ gitSource: null,
bucketName,
entryPoint: 'first',
region: 'ap-northeast-1',
siteName: 'my-site',
});
await deploySite({
+ gitSource: null,
bucketName,
entryPoint: 'second',
region: 'ap-northeast-1',
siteName: 'my-site-staging',
});
await deploySite({
+ gitSource: null,
bucketName,
entryPoint: 'first',
region: 'ap-northeast-1',
diff --git a/packages/lambda/src/test/integration/get-sites.test.ts b/packages/lambda/src/test/integration/get-sites.test.ts
index 9c3db5a95b..5c22b0636b 100644
--- a/packages/lambda/src/test/integration/get-sites.test.ts
+++ b/packages/lambda/src/test/integration/get-sites.test.ts
@@ -21,6 +21,7 @@ test('Should have a site after deploying', async () => {
entryPoint: 'first',
region: 'eu-central-1',
siteName: 'testing',
+ gitSource: null,
}),
).toEqual({
serveUrl:
diff --git a/packages/studio-server/src/preview-server/start-server.ts b/packages/studio-server/src/preview-server/start-server.ts
index 5999446915..6e0b1223e6 100644
--- a/packages/studio-server/src/preview-server/start-server.ts
+++ b/packages/studio-server/src/preview-server/start-server.ts
@@ -2,7 +2,11 @@ import type {WebpackOverrideFn} from '@remotion/bundler';
import {BundlerInternals, webpack} from '@remotion/bundler';
import type {LogLevel} from '@remotion/renderer';
import {RenderInternals} from '@remotion/renderer';
-import type {RenderDefaults, RenderJob} from '@remotion/studio-shared';
+import type {
+ GitSource,
+ RenderDefaults,
+ RenderJob,
+} from '@remotion/studio-shared';
import {DEFAULT_TIMELINE_TRACKS} from '@remotion/studio-shared';
import type {IncomingMessage} from 'node:http';
import http from 'node:http';
@@ -35,6 +39,7 @@ export const startServer = async (options: {
getRenderDefaults: () => RenderDefaults;
numberOfAudioTags: number;
queueMethods: QueueMethods;
+ gitSource: GitSource | null;
}): Promise<{
port: number;
liveEventsServer: LiveEventsServer;
@@ -90,6 +95,7 @@ export const startServer = async (options: {
getRenderDefaults: options.getRenderDefaults,
numberOfAudioTags: options.numberOfAudioTags,
queueMethods: options.queueMethods,
+ gitSource: options.gitSource,
});
})
.catch((err) => {
diff --git a/packages/studio-server/src/routes.ts b/packages/studio-server/src/routes.ts
index 3bf2e97028..be5fd9505b 100644
--- a/packages/studio-server/src/routes.ts
+++ b/packages/studio-server/src/routes.ts
@@ -2,6 +2,7 @@ import {BundlerInternals} from '@remotion/bundler';
import type {LogLevel} from '@remotion/renderer';
import type {
ApiRoutes,
+ GitSource,
RenderDefaults,
RenderJob,
SymbolicatedStackFrame,
@@ -53,6 +54,7 @@ const handleFallback = async ({
getRenderQueue,
getRenderDefaults,
numberOfAudioTags,
+ gitSource,
}: {
remotionRoot: string;
hash: string;
@@ -63,6 +65,7 @@ const handleFallback = async ({
getRenderQueue: () => RenderJob[];
getRenderDefaults: () => RenderDefaults;
numberOfAudioTags: number;
+ gitSource: GitSource | null;
}) => {
const [edit] = await editorGuess;
const displayName = getDisplayNameForEditor(edit ? edit.command : null);
@@ -88,6 +91,7 @@ const handleFallback = async ({
title: 'Remotion Studio',
renderDefaults: getRenderDefaults(),
publicFolderExists: existsSync(publicDir) ? publicDir : null,
+ gitSource,
}),
);
};
@@ -247,6 +251,7 @@ export const handleRoutes = ({
getRenderDefaults,
numberOfAudioTags,
queueMethods: methods,
+ gitSource,
}: {
staticHash: string;
staticHashPrefix: string;
@@ -265,6 +270,7 @@ export const handleRoutes = ({
getRenderDefaults: () => RenderDefaults;
numberOfAudioTags: number;
queueMethods: QueueMethods;
+ gitSource: GitSource | null;
}) => {
const url = new URL(request.url as string, 'http://localhost');
@@ -366,5 +372,6 @@ export const handleRoutes = ({
getRenderQueue,
getRenderDefaults,
numberOfAudioTags,
+ gitSource,
});
};
diff --git a/packages/studio-server/src/start-studio.ts b/packages/studio-server/src/start-studio.ts
index 06bcbca68a..a0b29c9d7c 100644
--- a/packages/studio-server/src/start-studio.ts
+++ b/packages/studio-server/src/start-studio.ts
@@ -1,7 +1,11 @@
import type {WebpackOverrideFn} from '@remotion/bundler';
import type {LogLevel} from '@remotion/renderer';
import {RenderInternals} from '@remotion/renderer';
-import type {RenderDefaults, RenderJob} from '@remotion/studio-shared';
+import type {
+ GitSource,
+ RenderDefaults,
+ RenderJob,
+} from '@remotion/studio-shared';
import crypto from 'node:crypto';
import {existsSync} from 'node:fs';
import path from 'node:path';
@@ -72,6 +76,7 @@ export const startStudio = async ({
queueMethods,
parsedCliOpen,
previewEntry,
+ gitSource,
}: {
browserArgs: string;
browserFlag: string;
@@ -93,6 +98,7 @@ export const startStudio = async ({
queueMethods: QueueMethods;
parsedCliOpen: boolean;
previewEntry: string;
+ gitSource: GitSource | null;
}) => {
watchRootFile(remotionRoot);
const publicDir = getAbsolutePublicDir({
@@ -150,6 +156,7 @@ export const startStudio = async ({
getRenderQueue,
numberOfAudioTags,
queueMethods,
+ gitSource,
});
setLiveEventsListener(liveEventsServer);
diff --git a/packages/studio-shared/src/git-source.ts b/packages/studio-shared/src/git-source.ts
new file mode 100644
index 0000000000..d0dc26cb44
--- /dev/null
+++ b/packages/studio-shared/src/git-source.ts
@@ -0,0 +1,6 @@
+export type GitSource = {
+ type: 'github';
+ org: string;
+ name: string;
+ ref: string;
+};
diff --git a/packages/studio-shared/src/index.ts b/packages/studio-shared/src/index.ts
index d228c5ded8..6260ef8077 100644
--- a/packages/studio-shared/src/index.ts
+++ b/packages/studio-shared/src/index.ts
@@ -24,6 +24,7 @@ export {
ErrorLocation,
getLocationFromBuildError,
} from './get-location-from-build-error';
+export type {GitSource} from './git-source';
export {
HotMiddlewareMessage,
HotMiddlewareOptions,
diff --git a/packages/studio/src/index.ts b/packages/studio/src/index.ts
index 5aa7e38029..2713c536df 100644
--- a/packages/studio/src/index.ts
+++ b/packages/studio/src/index.ts
@@ -1,2 +1,2 @@
-export type {RenderDefaults} from '@remotion/studio-shared';
+export type {GitSource, RenderDefaults} from '@remotion/studio-shared';
export {Studio} from './Studio';