🎥 Make videos programmatically with React
scaffold out npx remotion bundle
Jonny Burger96016270d6cf
diff --git a/packages/cli/src/bundle.ts b/packages/cli/src/bundle.tsnew file mode 100644index 0000000000..4b9cb99b2e--- /dev/null+++ b/packages/cli/src/bundle.ts@@ -0,0 +1,45 @@+import type {LogLevel} from '@remotion/renderer';+import {chalk} from './chalk';+import {findEntryPoint} from './entry-point';+import {getCliOptions} from './get-cli-options';+import {Log} from './log';+import {bundleOnCli} from './setup-cache';+import {shouldUseNonOverlayingLogger} from './should-use-non-overlaying-logger';++export const bundleCommand = async (+ remotionRoot: string,+ args: string[],+ logLevel: LogLevel,+) => {+ const {file} = findEntryPoint(args, remotionRoot, logLevel);++ const updatesDontOverwrite = shouldUseNonOverlayingLogger({logLevel});++ if (!file) {+ // TODO: Proper error handling+ throw new Error('No file found');+ }++ const {publicDir} = await getCliOptions({+ isLambda: false,+ type: 'get-compositions',+ remotionRoot,+ logLevel,+ });++ const output = await bundleOnCli({+ fullPath: file,+ logLevel,+ onDirectoryCreated: () => {},+ bundlingStep: 0,+ indent: false,+ quietProgress: updatesDontOverwrite,+ publicDir,+ steps: 1,+ remotionRoot,+ onProgressCallback: () => {},+ });++ // TODO: Not + if already existed+ Log.infoAdvanced({indent: false, logLevel}, chalk.blue(`+ ${output}`));+};diff --git a/packages/cli/src/index.tsx b/packages/cli/src/index.tsxindex c24784b5b7..840374ac3a 100644--- a/packages/cli/src/index.tsx+++ b/packages/cli/src/index.tsx@@ -2,6 +2,7 @@ import {RenderInternals} from '@remotion/renderer';import {StudioInternals} from '@remotion/studio';import minimist from 'minimist';import {benchmarkCommand} from './benchmark';+import {bundleCommand} from './bundle';import {chalk} from './chalk';import {cleanupBeforeQuit, handleCtrlC} from './cleanup-before-quit';import {cloudrunCommand} from './cloudrun-command';@@ -78,7 +79,9 @@ export const cli = async () => {handleCtrlC({indent: false, logLevel});try {- if (command === 'compositions') {+ if (command === 'bundle') {+ await bundleCommand(remotionRoot, args, logLevel);+ } else if (command === 'compositions') {await listCompositionsCommand(remotionRoot, args, logLevel);} else if (isStudio) {await studioCommand(remotionRoot, args, logLevel);diff --git a/packages/cli/src/print-help.ts b/packages/cli/src/print-help.tsindex 99411222bf..475f0f99fa 100644--- a/packages/cli/src/print-help.ts+++ b/packages/cli/src/print-help.ts@@ -7,13 +7,15 @@ const packagejson = require('../package.json');export const printHelp = () => {Log.info(`@remotion/cli ${packagejson.version}`);- Log.info(`© ${new Date().getFullYear()} The Remotion AG`);+ Log.info(`© ${new Date().getFullYear()} Remotion AG`);Log.info();Log.info('Available commands:');- Log.info('');++ Log.info();Log.info(chalk.blue('remotion studio') + chalk.gray(' <entry-point.ts>'));Log.info('Start the Remotion studio.');Log.info(chalk.gray('https://www.remotion.dev/docs/cli/studio'));+Log.info();Log.info(chalk.blue('remotion render') +@@ -30,6 +32,11 @@ export const printHelp = () => {Log.info('Render a still frame and save it as an image.');Log.info(chalk.gray('https://www.remotion.dev/docs/cli/still'));+ Log.info();+ Log.info(chalk.blue('remotion bundle') + chalk.gray(' <entry-point.ts>'));+ Log.info('Create a Remotion bundle to be deployed to the web.');+ Log.info(chalk.gray('https://www.remotion.dev/docs/cli/bundle'));+Log.info();Log.info(chalk.blue('remotion compositions') + chalk.gray(' <index-file.ts>'),@@ -49,6 +56,7 @@ export const printHelp = () => {Log.info(chalk.blue('remotion ' + VERSIONS_COMMAND));Log.info('Prints and validates versions of all Remotion packages.');Log.info(chalk.gray('https://www.remotion.dev/docs/cli/versions'));+Log.info();Log.info(chalk.blue('remotion ' + GPU_COMMAND));Log.info('Prints information about how Chrome uses the CPU.');diff --git a/packages/cli/src/setup-cache.ts b/packages/cli/src/setup-cache.tsindex e173655437..b6f3a49aca 100644--- a/packages/cli/src/setup-cache.ts+++ b/packages/cli/src/setup-cache.ts@@ -78,7 +78,7 @@ export const bundleOnCliOrTakeServeUrl = async ({};};-const bundleOnCli = async ({+export const bundleOnCli = async ({fullPath,remotionRoot,publicDir,