🎥 Make videos programmatically with React
`@remotion/cli`: Allow disabling the Git Source feature
Jonny Burgerad51cbe6f7c7
diff --git a/packages/cli/src/bundle.ts b/packages/cli/src/bundle.tsindex fc181ed02b..b5b7e8bf97 100644--- a/packages/cli/src/bundle.ts+++ b/packages/cli/src/bundle.ts@@ -13,7 +13,8 @@ import {bundleOnCli} from './setup-cache';import {shouldUseNonOverlayingLogger} from './should-use-non-overlaying-logger';import {yesOrNo} from './yes-or-no';-const {publicPathOption, publicDirOption} = BrowserSafeApis.options;+const {publicPathOption, publicDirOption, disableGitSourceOption} =+ BrowserSafeApis.options;export const bundleCommand = async (remotionRoot: string,@@ -59,6 +60,9 @@ export const bundleCommand = async (const publicPath = publicPathOption.getValue({commandLine: parsedCli}).value;const publicDir = publicDirOption.getValue({commandLine: parsedCli}).value;+ const disableGitSource = disableGitSourceOption.getValue({+ commandLine: parsedCli,+ }).value;const outputPath = parsedCli['out-dir']? path.resolve(process.cwd(), parsedCli['out-dir'])@@ -91,7 +95,7 @@ export const bundleCommand = async (rmSync(outputPath, {recursive: true});}- const gitSource = getGitSource(remotionRoot);+ const gitSource = getGitSource({remotionRoot, disableGitSource});const output = await bundleOnCli({fullPath: file,diff --git a/packages/cli/src/get-github-repository.ts b/packages/cli/src/get-github-repository.tsindex 6825199ec6..572fef4e37 100644--- a/packages/cli/src/get-github-repository.ts+++ b/packages/cli/src/get-github-repository.ts@@ -129,7 +129,17 @@ const getFromEnvVariables = (): GitSource | null => {return null;};-export const getGitSource = (remotionRoot: string): GitSource | null => {+export const getGitSource = ({+ remotionRoot,+ disableGitSource,+}: {+ remotionRoot: string;+ disableGitSource: boolean;+}): GitSource | null => {+ if (disableGitSource) {+ return null;+ }+const fromEnv = getFromEnvVariables();if (fromEnv) {return getFromEnvVariables();diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.tsindex f682afc77d..4e3d0a9b1d 100644--- a/packages/cli/src/index.ts+++ b/packages/cli/src/index.ts@@ -17,6 +17,7 @@ import {ffmpegCommand, ffprobeCommand} from './ffmpeg';import {getCliOptions} from './get-cli-options';import {getCompositionWithDimensionOverride} from './get-composition-with-dimension-override';import {loadConfig} from './get-config-file-name';+import {getGitSource} from './get-github-repository';import {gpuCommand} from './gpu';import {supportsHyperlink} from './hyperlinks/is-supported';import {makeHyperlink} from './hyperlinks/make-link';@@ -171,4 +172,5 @@ export const CliInternals = {printFact,makeHyperlink,supportsHyperlink,+ getGitSource,};diff --git a/packages/cli/src/parsed-cli.ts b/packages/cli/src/parsed-cli.tsindex 6775db77ab..11ba14948d 100644--- a/packages/cli/src/parsed-cli.ts+++ b/packages/cli/src/parsed-cli.ts@@ -27,6 +27,7 @@ export const BooleanFlags = ['no-open','ipv4',BrowserSafeApis.options.beepOnFinishOption.cliFlag,+ BrowserSafeApis.options.disableGitSourceOption.cliFlag,'repro','compatible-only',];diff --git a/packages/cli/src/studio.ts b/packages/cli/src/studio.tsindex 6ad1cbf926..a8d5197baa 100644--- a/packages/cli/src/studio.ts+++ b/packages/cli/src/studio.ts@@ -31,7 +31,8 @@ const getPort = () => {return null;};-const {binariesDirectoryOption, publicDirOption} = BrowserSafeApis.options;+const {binariesDirectoryOption, publicDirOption, disableGitSourceOption} =+ BrowserSafeApis.options;export const studioCommand = async (remotionRoot: string,@@ -96,16 +97,20 @@ export const studioCommand = async (const keyboardShortcutsEnabled =ConfigInternals.getKeyboardShortcutsEnabled();- const gitSource = getGitSource(remotionRoot);-const binariesDirectory = binariesDirectoryOption.getValue({commandLine: parsedCli,}).value;+ const disableGitSource = disableGitSourceOption.getValue({+ commandLine: parsedCli,+ }).value;+const relativePublicDir = publicDirOption.getValue({commandLine: parsedCli,}).value;+ const gitSource = getGitSource({remotionRoot, disableGitSource});+await StudioServerInternals.startStudio({previewEntry: require.resolve('@remotion/studio/entry'),browserArgs: parsedCli['browser-args'],diff --git a/packages/cli/src/test/get-github-repo.test.ts b/packages/cli/src/test/get-github-repo.test.tsindex 23f97171b5..c7b78c37f2 100644--- a/packages/cli/src/test/get-github-repo.test.ts+++ b/packages/cli/src/test/get-github-repo.test.ts@@ -53,7 +53,10 @@ test('Should get Gif Ref', () => {});test('Should get Git Source', () => {- const git = getGitSource(process.cwd());+ const git = getGitSource({+ remotionRoot: process.cwd(),+ disableGitSource: false,+ });expect(git).not.toBeNull();expect(git?.relativeFromGitRoot).toBe(`packages${path.sep}cli`);});@@ -64,7 +67,10 @@ test('Should recognize VERCEL', () => {process.env.VERCEL_GIT_REPO_SLUG = 'remotion';process.env.VERCEL_GIT_REPO_OWNER = 'remotion-dev';- const source = getGitSource('dontmatter');+ const source = getGitSource({+ remotionRoot: 'dontmatter',+ disableGitSource: false,+ });expect(source).not.toBeNull();expect(source?.name).toBe('remotion');expect(source?.org).toBe('remotion-dev');diff --git a/packages/cloudrun/src/api/deploy-site.ts b/packages/cloudrun/src/api/deploy-site.tsindex b4a7707edc..2b98dd1921 100644--- a/packages/cloudrun/src/api/deploy-site.ts+++ b/packages/cloudrun/src/api/deploy-site.ts@@ -1,8 +1,12 @@-import type {GitSource, WebpackOverrideFn} from '@remotion/bundler';-import type {LogLevel} from '@remotion/renderer';+import {+ BundlerInternals,+ type GitSource,+ type WebpackOverrideFn,+} from '@remotion/bundler';+import type {ToOptions} from '@remotion/renderer';+import type {BrowserSafeApis} from '@remotion/renderer/client';import {NoReactAPIs} from '@remotion/renderer/pure';import {cloudrunDeleteFile, cloudrunLs} from '../functions/helpers/io';-import {bundleSite} from '../shared/bundle-site';import {getSitesKey} from '../shared/constants';import {getStorageDiffOperations} from '../shared/get-storage-operations';import {makeStorageServeUrl} from '../shared/make-storage-url';@@ -25,21 +29,25 @@ type Options = {gitSource?: GitSource | null;};+type OptionalParameters = {+ siteName: string;+ options: Options;+} & ToOptions<typeof BrowserSafeApis.optionsMap.deploySiteCloudRun>;+export type RawDeploySiteInput = {entryPoint: string;bucketName: string;siteName: string;options: Options;- logLevel: LogLevel;indent: boolean;-};+} & OptionalParameters;export type DeploySiteInput = {entryPoint: string;bucketName: string;siteName?: string;options?: Options;-};+} & Partial<OptionalParameters>;export type DeploySiteOutput = Promise<{serveUrl: string;@@ -51,7 +59,7 @@ export type DeploySiteOutput = Promise<{};}>;-const internalDeploySiteRaw = async ({+export const internalDeploySiteRaw = async ({entryPoint,bucketName,siteName,@@ -74,16 +82,22 @@ const internalDeploySiteRaw = async ({bucketName,prefix: subFolder,}),- bundleSite({+ BundlerInternals.internalBundle({publicPath: `/${bucketName}/${subFolder}/`,webpackOverride: options?.webpackOverride ?? ((f) => f),enableCaching: options?.enableCaching ?? true,- publicDir: options?.publicDir,- rootDir: options?.rootDir,- ignoreRegisterRootWarning: options?.ignoreRegisterRootWarning,+ publicDir: options?.publicDir ?? null,+ rootDir: options?.rootDir ?? null,+ ignoreRegisterRootWarning: options?.ignoreRegisterRootWarning ?? false,onProgress: options?.onBundleProgress ?? (() => undefined),entryPoint,- gitSource: options?.gitSource,+ gitSource: options?.gitSource ?? null,+ bufferStateDelayInMilliseconds: null,+ maxTimelineTracks: null,+ onDirectoryCreated: () => undefined,+ onPublicDirCopyProgress: () => undefined,+ onSymlinkDetected: () => undefined,+ outDir: null,}),]);diff --git a/packages/cloudrun/src/cli/commands/sites/create.ts b/packages/cloudrun/src/cli/commands/sites/create.tsindex bfd2c8fe90..4405f51868 100644--- a/packages/cloudrun/src/cli/commands/sites/create.ts+++ b/packages/cloudrun/src/cli/commands/sites/create.ts@@ -1,10 +1,11 @@import {CliInternals} from '@remotion/cli';import {ConfigInternals} from '@remotion/cli/config';import type {LogLevel} from '@remotion/renderer';+import {BrowserSafeApis} from '@remotion/renderer/client';import {existsSync, lstatSync} from 'fs';import {Internals} from 'remotion';import {displaySiteInfo} from '.';-import {deploySite} from '../../../api/deploy-site';+import {internalDeploySiteRaw} from '../../../api/deploy-site';import {getOrCreateBucket} from '../../../api/get-or-create-bucket';import {BINARY_NAME} from '../../../shared/constants';import {validateSiteName} from '../../../shared/validate-site-name';@@ -137,7 +138,14 @@ export const sitesCreateSubcommand = async (const bundleStart = Date.now();let uploadStart = Date.now();- const {serveUrl, siteName, stats} = await deploySite({+ const disableGitSource =+ BrowserSafeApis.options.disableGitSourceOption.getValue({+ commandLine: CliInternals.parsedCli,+ }).value;++ const gitSource = CliInternals.getGitSource({remotionRoot, disableGitSource});++ const {serveUrl, siteName, stats} = await internalDeploySiteRaw({entryPoint: file,siteName: desiredSiteName,bucketName,@@ -162,8 +170,14 @@ export const sitesCreateSubcommand = async (},enableCaching: ConfigInternals.getWebpackCaching(),webpackOverride: ConfigInternals.getWebpackOverrideFn() ?? ((f) => f),- gitSource: null,+ gitSource,+ bypassBucketNameValidation: true,+ ignoreRegisterRootWarning: true,+ publicDir: null,+ rootDir: remotionRoot,},+ indent: false,+ logLevel,});updateProgress(false);diff --git a/packages/docs/docs/cli/bundle.mdx b/packages/docs/docs/cli/bundle.mdxindex c95c46be21..98b5de3c55 100644--- a/packages/docs/docs/cli/bundle.mdx+++ b/packages/docs/docs/cli/bundle.mdx@@ -37,3 +37,7 @@ Define the location of the resulting bundle. By default it is a folder called `.### `--public-path`<AvailableFrom v="4.0.127"/><Options id="public-path" />++### `--disable-git-source`<AvailableFrom v="4.0.182" />++<Options id="disable-git-source" />diff --git a/packages/docs/docs/lambda/cli/sites.mdx b/packages/docs/docs/lambda/cli/sites.mdxindex ccde86560f..2a7b5f2bf4 100644--- a/packages/docs/docs/lambda/cli/sites.mdx+++ b/packages/docs/docs/lambda/cli/sites.mdx@@ -2,9 +2,9 @@image: /generated/articles-docs-lambda-cli-sites.pngid: sitessidebar_label: sites-title: "npx remotion lambda sites"+title: 'npx remotion lambda sites'slug: /lambda/cli/sites-crumb: "Lambda CLI Reference"+crumb: 'Lambda CLI Reference'---The `npx remotion lambda sites` command allows to create, view and delete Remotion projects in your S3 bucket.@@ -89,6 +89,11 @@ Either `public` (default) or `no-acl` if you are not using ACL. Sites must have### `--throw-if-site-exists`<AvailableFrom v="4.0.141"/><Options id="throw-if-site-exists" />++### `--disable-git-source`<AvailableFrom v="4.0.182" />++<Options id="disable-git-source" />+<br /><br /><hr />diff --git a/packages/lambda/src/api/deploy-site.ts b/packages/lambda/src/api/deploy-site.tsindex 4cbd1611b8..0b1d5db2d8 100644--- a/packages/lambda/src/api/deploy-site.ts+++ b/packages/lambda/src/api/deploy-site.ts@@ -1,11 +1,14 @@-import type {GitSource, WebpackOverrideFn} from '@remotion/bundler';+import {+ BundlerInternals,+ type GitSource,+ type WebpackOverrideFn,+} from '@remotion/bundler';import type {ToOptions} from '@remotion/renderer';import type {BrowserSafeApis} from '@remotion/renderer/client';import {NoReactAPIs} from '@remotion/renderer/pure';import fs from 'node:fs';import {lambdaDeleteFile, lambdaLs} from '../functions/helpers/io';import type {AwsRegion} from '../pricing/aws-regions';-import {bundleSite} from '../shared/bundle-site';import {getSitesKey} from '../shared/constants';import {getAccountId} from '../shared/get-account-id';import {getS3DiffOperations} from '../shared/get-s3-operations';@@ -93,16 +96,22 @@ const mandatoryDeploySite = async ({// The `/` is important to not accidentially delete sites with the same name but containing a suffix.prefix: `${subFolder}/`,}),- bundleSite({+ BundlerInternals.internalBundle({publicPath: `/${subFolder}/`,webpackOverride: options?.webpackOverride ?? ((f) => f),enableCaching: options?.enableCaching ?? true,- publicDir: options?.publicDir,- rootDir: options?.rootDir,- ignoreRegisterRootWarning: options?.ignoreRegisterRootWarning,+ publicDir: options?.publicDir ?? null,+ rootDir: options?.rootDir ?? null,+ ignoreRegisterRootWarning: options?.ignoreRegisterRootWarning ?? false,onProgress: options?.onBundleProgress ?? (() => undefined),entryPoint,gitSource,+ bufferStateDelayInMilliseconds: null,+ maxTimelineTracks: null,+ onDirectoryCreated: () => undefined,+ onPublicDirCopyProgress: () => undefined,+ onSymlinkDetected: () => undefined,+ outDir: null,}),]);diff --git a/packages/lambda/src/cli/commands/sites/create.ts b/packages/lambda/src/cli/commands/sites/create.tsindex bac910539c..17c4206241 100644--- a/packages/lambda/src/cli/commands/sites/create.ts+++ b/packages/lambda/src/cli/commands/sites/create.ts@@ -27,8 +27,12 @@ import {Log} from '../../log';export const SITES_CREATE_SUBCOMMAND = 'create';-const {folderExpiryOption, publicDirOption, throwIfSiteExistsOption} =- BrowserSafeApis.options;+const {+ folderExpiryOption,+ publicDirOption,+ throwIfSiteExistsOption,+ disableGitSourceOption,+} = BrowserSafeApis.options;export const sitesCreateSubcommand = async (args: string[],@@ -137,6 +141,11 @@ export const sitesCreateSubcommand = async (const throwIfSiteExists = throwIfSiteExistsOption.getValue({commandLine: CliInternals.parsedCli,}).value;+ const disableGitSource = disableGitSourceOption.getValue({+ commandLine: CliInternals.parsedCli,+ }).value;++ const gitSource = CliInternals.getGitSource({remotionRoot, disableGitSource});const {serveUrl, siteName, stats} = await LambdaInternals.internalDeploySite({entryPoint: file,@@ -172,7 +181,7 @@ export const sitesCreateSubcommand = async (region: getAwsRegion(),privacy:(parsedLambdaCli.privacy as Exclude<Privacy, 'private'>) ?? 'public',- gitSource: null,+ gitSource,indent: false,logLevel,throwIfSiteExists,diff --git a/packages/renderer/src/options/disable-git-source.tsx b/packages/renderer/src/options/disable-git-source.tsxnew file mode 100644index 0000000000..a9140d159b--- /dev/null+++ b/packages/renderer/src/options/disable-git-source.tsx@@ -0,0 +1,31 @@+import type {AnyRemotionOption} from './option';++const DEFAULT = false;++const cliFlag = 'disable-git-source';++export const disableGitSourceOption = {+ cliFlag,+ description: () =>+ `Disables the Git Source being connected to the Remotion Studio. Clicking on stack traces and certain menu items will be disabled.`,+ docLink: 'https://remotion.dev/docs/bundle',+ getValue: ({commandLine}) => {+ if (commandLine[cliFlag]) {+ return {+ source: 'cli',+ value: commandLine[cliFlag] as boolean,+ };+ }++ return {+ source: 'default',+ value: DEFAULT,+ };+ },+ name: 'Disable Git source',+ setConfig: () => {+ throw new Error('Not implemented');+ },+ ssrName: 'disableGitSource',+ type: false as boolean,+} satisfies AnyRemotionOption<boolean>;diff --git a/packages/renderer/src/options/index.tsx b/packages/renderer/src/options/index.tsxindex 1dfab10bc0..714f2533b9 100644--- a/packages/renderer/src/options/index.tsx+++ b/packages/renderer/src/options/index.tsx@@ -5,6 +5,7 @@ import {binariesDirectoryOption} from './binaries-directory';import {colorSpaceOption} from './color-space';import {crfOption} from './crf';import {deleteAfterOption} from './delete-after';+import {disableGitSourceOption} from './disable-git-source';import {enableLambdaInsights} from './enable-lambda-insights';import {enableMultiprocessOnLinuxOption} from './enable-multiprocess-on-linux';import {encodingBufferSizeOption} from './encoding-buffer-size';@@ -71,6 +72,7 @@ export const allOptions = {publicDirOption,onBrowserDownloadOption,throwIfSiteExistsOption,+ disableGitSourceOption,};export type AvailableOptions = keyof typeof allOptions;diff --git a/packages/renderer/src/options/options-map.ts b/packages/renderer/src/options/options-map.tsindex 1c5c02f17e..8388c36449 100644--- a/packages/renderer/src/options/options-map.ts+++ b/packages/renderer/src/options/options-map.ts@@ -141,4 +141,7 @@ export const optionsMap = {logLevel: logLevelOption,throwIfSiteExists: throwIfSiteExistsOption,},+ deploySiteCloudRun: {+ logLevel: logLevelOption,+ },} as const;diff --git a/packages/studio/src/components/MenuToolbar.tsx b/packages/studio/src/components/MenuToolbar.tsxindex 56cf063a2d..439ea4b4dc 100644--- a/packages/studio/src/components/MenuToolbar.tsx+++ b/packages/studio/src/components/MenuToolbar.tsx@@ -27,7 +27,7 @@ const flex: React.CSSProperties = {};export const MenuToolbar: React.FC<{- readOnlyStudio: boolean;+ readonly readOnlyStudio: boolean;}> = ({readOnlyStudio}) => {const [selected, setSelected] = useState<string | null>(null);