π₯ Make videos programmatically with React
<es
JonnyBurger49dae0711be3
diff --git a/packages/cli/src/add.ts b/packages/cli/src/add.tsindex 6cbae2ea00..b55cbc8ac2 100644--- a/packages/cli/src/add.ts+++ b/packages/cli/src/add.ts@@ -8,20 +8,23 @@ import {Log} from './log';export const addCommand = async ({remotionRoot,packageManager,- packageName,+ packageNames,logLevel,args,}: {remotionRoot: string;packageManager: string | undefined;- packageName: string;+ packageNames: string[];logLevel: LogLevel;args: string[];}) => {- // Validate that the package name is a Remotion package- if (!listOfRemotionPackages.includes(packageName)) {+ // Validate that all package names are Remotion packages+ const invalidPackages = packageNames.filter(+ (pkg) => !listOfRemotionPackages.includes(pkg),+ );+ if (invalidPackages.length > 0) {throw new Error(- `Package "${packageName}" is not a Remotion package. Must be one of ${listOfRemotionPackages.join(', ')}.`,+ `The following packages are not Remotion packages: ${invalidPackages.join(', ')}. Must be one of the Remotion packages.`,);}@@ -32,7 +35,7 @@ export const addCommand = async ({peerDependencies,} = StudioServerInternals.getInstalledDependencies(remotionRoot);- // Check if the package is already installed+ // Check if packages are already installedconst allDeps = [...dependencies,...devDependencies,@@ -40,11 +43,19 @@ export const addCommand = async ({...peerDependencies,];- if (allDeps.includes(packageName)) {+ const alreadyInstalled = packageNames.filter((pkg) => allDeps.includes(pkg));+ const toInstall = packageNames.filter((pkg) => !allDeps.includes(pkg));++ // Log already installed packages+ for (const pkg of alreadyInstalled) {Log.info({indent: false, logLevel},- `β ${packageName} ${chalk.gray('(already installed)')}`,+ `β ${pkg} ${chalk.gray('(already installed)')}`,);+ }++ // If nothing to install, return early+ if (toInstall.length === 0) {return;}@@ -66,9 +77,13 @@ export const addCommand = async ({try {const packageJson = require(packageJsonPath);targetVersion = packageJson.version;+ const packageList =+ toInstall.length === 1+ ? toInstall[0]+ : `${toInstall.length} packages (${toInstall.join(', ')})`;Log.info({indent: false, logLevel},- `Installing ${packageName}@${targetVersion} to match your other Remotion packages`,+ `Installing ${packageList}@${targetVersion} to match your other Remotion packages`,);} catch (err) {throw new Error(@@ -92,7 +107,7 @@ export const addCommand = async ({const command = StudioServerInternals.getInstallCommand({manager: manager.manager,- packages: [packageName],+ packages: toInstall,version: targetVersion,additionalArgs: args,});@@ -118,14 +133,23 @@ export const addCommand = async ({if (code === 0) {resolve();} else if (RenderInternals.isEqualOrBelowLogLevel(logLevel, 'info')) {- throw new Error(`Failed to install ${packageName}, see logs above`);+ throw new Error(`Failed to install packages, see logs above`);} else {throw new Error(- `Failed to install ${packageName}, run with --log=info to see logs`,+ `Failed to install packages, run with --log=info to see logs`,);}});});- Log.info({indent: false, logLevel}, `+ ${packageName}@${targetVersion}`);+ for (const pkg of alreadyInstalled) {+ Log.info(+ {indent: false, logLevel},+ `β ${pkg}@${targetVersion} ${chalk.gray('(already installed)')}`,+ );+ }++ for (const pkg of toInstall) {+ Log.info({indent: false, logLevel}, `+ ${pkg}@${targetVersion}`);+ }};diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.tsindex 14fbd5c6f0..e3e7ae7f9e 100644--- a/packages/cli/src/index.ts+++ b/packages/cli/src/index.ts@@ -120,19 +120,23 @@ export const cli = async () => {args,});} else if (command === 'add') {- const packageName = args[0];- if (!packageName) {+ if (args.length === 0) {throw new Error(- 'Please specify a package name. Example: npx remotion add @remotion/transitions',+ 'Please specify at least one package name. Example: npx remotion add @remotion/transitions',);}+ // Find where additional flags start (arguments starting with -)+ const flagIndex = args.findIndex((arg) => arg.startsWith('-'));+ const packageNames = flagIndex === -1 ? args : args.slice(0, flagIndex);+ const additionalArgs = flagIndex === -1 ? [] : args.slice(flagIndex);+await addCommand({remotionRoot,packageManager: parsedCli['package-manager'],- packageName,+ packageNames,logLevel,- args: args.slice(1),+ args: additionalArgs,});} else if (command === VERSIONS_COMMAND) {await versionsCommand(remotionRoot, logLevel);diff --git a/packages/cli/src/print-help.ts b/packages/cli/src/print-help.tsindex 71ad7fcf99..219c27f156 100644--- a/packages/cli/src/print-help.ts+++ b/packages/cli/src/print-help.ts@@ -136,11 +136,11 @@ export const printHelp = (logLevel: LogLevel) => {Log.info({indent: false, logLevel});Log.info({indent: false, logLevel},- chalk.blue('remotion add') + chalk.gray(' <package-name>'),+ chalk.blue('remotion add') + chalk.gray(' <package-name...>'),);Log.info({indent: false, logLevel},- 'Add a Remotion package with the correct version.',+ 'Add Remotion packages with the correct version.',);Log.info({indent: false, logLevel},diff --git a/packages/docs/docs/cli/add.mdx b/packages/docs/docs/cli/add.mdxindex 41c77507f1..d072ccdba6 100644--- a/packages/docs/docs/cli/add.mdx+++ b/packages/docs/docs/cli/add.mdx@@ -5,23 +5,29 @@ sidebar_label: addcrumb: CLI Reference----Adds a Remotion package to your project with the same version as your other Remotion packages.+Adds one or more Remotion packages to your project with the same version as your other Remotion packages.```-npx remotion add <package-name>+npx remotion add <package-name...>```-## Example+## Examples+Add a single package:```bashnpx remotion add @remotion/transitions```+Add multiple packages at once:+```bash+npx remotion add @remotion/transitions @remotion/three @remotion/lottie+```+This command will:-1. Verify that the package name is a valid Remotion package-2. Check if the package is already installed+1. Verify that all package names are valid Remotion packages+2. Check which packages are already installed (and skip them)3. Detect the version of your currently installed Remotion packages-4. Install the specified package with the matching version+4. Install the specified packages with the matching version## Flags@@ -43,10 +49,12 @@ Any additional arguments you pass to this command will be forwarded as flags to## Use case-This command is useful when you want to add a new Remotion package to your project and ensure it's installed with the same version as your other Remotion packages. This helps avoid version mismatches that could cause compatibility issues.+This command is useful when you want to add new Remotion packages to your project and ensure they're installed with the same version as your other Remotion packages. This helps avoid version mismatches that could cause compatibility issues.For example, if you have `[email protected]` installed and you want to add `@remotion/transitions`, running `npx remotion add @remotion/transitions` will install `@remotion/[email protected]`.+When adding multiple packages, the command will install all of them in a single operation with the same version number, making it efficient to set up multiple dependencies at once.+## See also- [npx remotion upgrade](/docs/cli/upgrade)diff --git a/packages/docs/docs/cli/table-of-contents.tsx b/packages/docs/docs/cli/table-of-contents.tsxindex 91b4db3a10..077b4ac4dc 100644--- a/packages/docs/docs/cli/table-of-contents.tsx+++ b/packages/docs/docs/cli/table-of-contents.tsx@@ -52,7 +52,7 @@ export const TableOfContents: React.FC = () => {</TOCItem><TOCItem link="/docs/cli/add"><strong>add</strong>- <div>Add a Remotion package with matching version</div>+ <div>Add Remotion packages with matching version</div></TOCItem><TOCItem link="/docs/cli/gpu"><strong>gpu</strong>