🎥 Make videos programmatically with React
`@remotion/cli`: Show command options in `--help`
JonnyBurgera84dbd3666be
diff --git a/packages/cli/src/cloudrun-command.ts b/packages/cli/src/cloudrun-command.tsindex 37c2c04437..93429be846 100644--- a/packages/cli/src/cloudrun-command.ts+++ b/packages/cli/src/cloudrun-command.ts@@ -2,6 +2,27 @@ import type {LogLevel} from '@remotion/renderer';import {StudioServerInternals} from '@remotion/studio-server';import {Log} from './log';+export const tryPrintCloudrunHelp = (+ remotionRoot: string,+ args: string[],+ logLevel: LogLevel,+) => {+ try {+ const path = require.resolve('@remotion/cloudrun', {+ paths: [remotionRoot],+ });+ const {CloudrunInternals} = require(path);+ if (typeof CloudrunInternals?.printHelp !== 'function') {+ return false;+ }++ CloudrunInternals.printHelp(args, logLevel);+ return true;+ } catch {+ return false;+ }+};+export const cloudrunCommand = async (remotionRoot: string,args: string[],diff --git a/packages/cli/src/command-help.ts b/packages/cli/src/command-help.tsnew file mode 100644index 0000000000..a3f68a33a5--- /dev/null+++ b/packages/cli/src/command-help.ts@@ -0,0 +1,134 @@+import {chalk} from './chalk';++export type CommandHelpOption = {+ flag: string;+ description: string;+};++export type CommandHelpEntry = {+ path: readonly string[];+ args: string;+ description: string;+ documentation: string;+ options: readonly CommandHelpOption[];+ listed?: boolean;+};++type RemotionOptionForHelp = {+ cliFlag: string;+ name: string;+ type: unknown;+};++export const makeCommandHelpOption = ({+ option,+ description,+ value,+}: {+ option: RemotionOptionForHelp;+ description?: string;+ value?: string | null;+}): CommandHelpOption => {+ const valueSuffix =+ value === null+ ? ''+ : ` ${value ?? (typeof option.type === 'boolean' ? '' : '<value>')}`;++ return {+ flag: `--${option.cliFlag}${valueSuffix}`.trimEnd(),+ description: description ?? option.name,+ };+};++const commandMatches = (+ command: CommandHelpEntry,+ selectedPath: readonly string[],+) =>+ command.path.every((part, index) => selectedPath[index] === part) &&+ selectedPath.length >= command.path.length;++const formatOption = (option: CommandHelpOption, width: number) => {+ return ` ${chalk.blue(option.flag.padEnd(width))}${option.description}`;+};++export const getCommandHelp = ({+ binaryName,+ commands,+ selectedPath,+ rootDocumentation,+}: {+ binaryName: string;+ commands: readonly CommandHelpEntry[];+ selectedPath: readonly string[];+ rootDocumentation: string;+}): string[] => {+ const selectedCommand = commands+ .filter((command) => commandMatches(command, selectedPath))+ .sort((a, b) => b.path.length - a.path.length)[0];++ if (selectedCommand) {+ const displayPath = selectedPath+ .slice(0, selectedCommand.path.length)+ .join(' ');+ const selectedBinaryName = displayPath+ ? `${binaryName} ${displayPath}`+ : binaryName;+ const children = commands.filter(+ (command) =>+ command.listed !== false &&+ command.path.length === selectedCommand.path.length + 1 &&+ selectedCommand.path.every(+ (part, index) => command.path[index] === part,+ ),+ );+ const options = [+ ...selectedCommand.options,+ {flag: '--help', description: 'Show this help.'},+ ];+ const optionWidth =+ Math.max(...options.map((option) => option.flag.length)) + 2;+ const commandLines = [+ '',+ chalk.blue(selectedBinaryName) + chalk.gray(selectedCommand.args),+ selectedCommand.description,+ ];++ if (children.length > 0) {+ commandLines.push('', 'Commands:');+ for (const child of children) {+ commandLines.push(+ '',+ chalk.blue(`${binaryName} ${child.path.join(' ')}`) ++ chalk.gray(child.args),+ child.description,+ );+ }+ }++ commandLines.push(+ '',+ 'Options:',+ ...options.map((option) => formatOption(option, optionWidth)),+ '',+ chalk.gray(`Full documentation: ${selectedCommand.documentation}`),+ );+ return commandLines;+ }++ const lines = ['', 'Available commands:'];+ for (const command of commands) {+ if (command.path.length !== 1 || command.listed === false) {+ continue;+ }++ lines.push(+ '',+ chalk.blue(`${binaryName} ${command.path[0]}`) + chalk.gray(command.args),+ command.description,+ chalk.gray(command.documentation),+ );+ }++ lines.push('', `Visit ${rootDocumentation} for browsable CLI documentation.`);+ return lines;+};diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.tsindex 4beffb8197..8771cfadd5 100644--- a/packages/cli/src/index.ts+++ b/packages/cli/src/index.ts@@ -14,7 +14,8 @@ import {handleCtrlC,registerCtrlCHandler,} from './cleanup-before-quit';-import {cloudrunCommand} from './cloudrun-command';+import {cloudrunCommand, tryPrintCloudrunHelp} from './cloudrun-command';+import {getCommandHelp, makeCommandHelpOption} from './command-help';import {listCompositionsCommand} from './compositions';import {determineFinalStillImageFormat} from './determine-image-format';import {getFileSizeDownloadBar} from './download-progress';@@ -28,7 +29,7 @@ import {gpuCommand} from './gpu';import {supportsHyperlink} from './hyperlinks/is-supported';import {makeHyperlink} from './hyperlinks/make-link';import {initializeCli} from './initialize-cli';-import {lambdaCommand} from './lambda-command';+import {lambdaCommand, tryPrintLambdaHelp} from './lambda-command';import {listOfRemotionPackages} from './list-of-remotion-packages';import {Log} from './log';import {makeProgressBar} from './make-progress-bar';@@ -59,7 +60,18 @@ const {packageManagerOption, skipSkillsOption, versionFlagOption} =export const cli = async () => {const [command, ...args] = parsedCli._;if (parsedCli.help) {- printHelp('info', command ?? null);+ if (command === 'lambda' || command === 'cloudrun') {+ const helpRemotionRoot = RenderInternals.findRemotionRoot();+ const printed =+ command === 'lambda'+ ? tryPrintLambdaHelp(helpRemotionRoot, args, 'info')+ : tryPrintCloudrunHelp(helpRemotionRoot, args, 'info');+ if (printed) {+ return;+ }+ }++ printHelp('info', parsedCli._);return;}@@ -165,14 +177,14 @@ export const cli = async () => {} else if (command === 'benchmark') {await benchmarkCommand(remotionRoot, args, logLevel);} else if (command === 'help') {- printHelp(logLevel, null);+ printHelp(logLevel, []);process.exit(0);} else {if (command) {Log.error({indent: false, logLevel}, `Command ${command} not found.`);}- printHelp(logLevel, null);+ printHelp(logLevel, []);process.exit(1);}} catch (err) {@@ -213,6 +225,8 @@ export const CliInternals = {makeHyperlink,supportsHyperlink,getGitSource,+ getCommandHelp,+ makeCommandHelpOption,handleCtrlC,registerCtrlCHandler,};diff --git a/packages/cli/src/lambda-command.ts b/packages/cli/src/lambda-command.tsindex 3359542228..7b1c0e589f 100644--- a/packages/cli/src/lambda-command.ts+++ b/packages/cli/src/lambda-command.ts@@ -2,6 +2,27 @@ import type {LogLevel} from '@remotion/renderer';import {StudioServerInternals} from '@remotion/studio-server';import {Log} from './log';+export const tryPrintLambdaHelp = (+ remotionRoot: string,+ args: string[],+ logLevel: LogLevel,+) => {+ try {+ const path = require.resolve('@remotion/lambda', {+ paths: [remotionRoot],+ });+ const {LambdaInternals} = require(path);+ if (typeof LambdaInternals?.printHelp !== 'function') {+ return false;+ }++ LambdaInternals.printHelp(args, logLevel);+ return true;+ } catch {+ return false;+ }+};+export const lambdaCommand = async (remotionRoot: string,args: string[],diff --git a/packages/cli/src/print-help.ts b/packages/cli/src/print-help.tsindex c177f83ba6..efd51ad500 100644--- a/packages/cli/src/print-help.ts+++ b/packages/cli/src/print-help.ts@@ -1,163 +1,467 @@import type {LogLevel} from '@remotion/renderer';+import {BrowserSafeApis} from '@remotion/renderer/client';import {BROWSER_COMMAND} from './browser';-import {chalk} from './chalk';+import {+ type CommandHelpEntry,+ type CommandHelpOption,+ getCommandHelp,+ makeCommandHelpOption,+} from './command-help';import {GPU_COMMAND} from './gpu';import {Log} from './log';import {VERSIONS_COMMAND} from './versions';const packagejson = require('../package.json');-type CommandHelp = {- name: string;- aliases: readonly string[];- args: string;- description: string;- documentation: string;+const rendererOptions = Object.values(BrowserSafeApis.options);++const cliOnlyOptions: Record<string, CommandHelpOption> = {+ output: {+ flag: '--output <path>',+ description: 'Set the output path instead of using a positional argument.',+ },+ 'browser-args': {+ flag: '--browser-args <arguments>',+ description: 'Pass command line arguments to the browser.',+ },+ quiet: {+ flag: '--quiet, -q',+ description: 'Reduce console output.',+ },+};++const options = (+ flags: readonly string[],+ descriptionOverrides: Record<string, string> = {},+): CommandHelpOption[] => {+ return flags.map((flag) => {+ const cliOnlyOption = cliOnlyOptions[flag];+ if (cliOnlyOption) {+ return cliOnlyOption;+ }++ const rendererOption = rendererOptions.find(+ (candidate) => candidate.cliFlag === flag,+ );+ if (!rendererOption) {+ throw new Error(`No CLI help metadata exists for --${flag}`);+ }++ return makeCommandHelpOption({+ option: rendererOption,+ description: descriptionOverrides[flag],+ });+ });};-const commandHelp: readonly CommandHelp[] = [+const studioOptions = options([+ 'props',+ 'config',+ 'env-file',+ 'log',+ 'port',+ 'public-dir',+ 'binaries-directory',+ 'disable-git-source',+ 'audio-latency-hint',+ 'disable-keyboard-shortcuts',+ 'disable-interactivity',+ 'allow-html-in-canvas',+ 'editor',+ 'coding-agent',+ 'rspack',+ 'webpack-poll',+ 'no-open',+ 'browser',+ 'browser-args',+ 'beep-on-finish',+ 'ipv4',+ 'number-of-shared-audio-tags',+ 'experimental-keep-audio-context-alive',+ 'preview-sample-rate',+ 'cross-site-isolation',+ 'disable-ask-ai',+ 'force-new',+ 'public-license-key',+]);++const commandHelp: readonly CommandHelpEntry[] = [+ {+ path: ['studio'],+ args: ' <entry-point>?',+ description: 'Start the Remotion Studio.',+ documentation: 'https://www.remotion.dev/docs/cli/studio',+ options: studioOptions,+ },{- name: 'studio',- aliases: ['preview'],+ path: ['preview'],args: ' <entry-point>?',description: 'Start the Remotion Studio.',documentation: 'https://www.remotion.dev/docs/cli/studio',+ options: studioOptions,+ listed: false,},{- name: 'render',- aliases: [],- args: ' <entry-point|serve-url>? <composition-id> <output-location>',+ path: ['render'],+ args: ' [<entry-point|serve-url>] [<composition-id>] [<output-location>]',description: 'Render video, audio or an image sequence.',documentation: 'https://www.remotion.dev/docs/cli/render',+ options: options(+ [+ 'props',+ 'height',+ 'width',+ 'fps',+ 'duration',+ 'concurrency',+ 'pixel-format',+ 'image-format',+ 'image-sequence-pattern',+ 'config',+ 'env-file',+ 'jpeg-quality',+ 'output',+ 'overwrite',+ 'sequence',+ 'codec',+ 'audio-codec',+ 'audio-bitrate',+ 'video-bitrate',+ 'buffer-size',+ 'max-rate',+ 'prores-profile',+ 'x264-preset',+ 'gop',+ 'crf',+ 'browser-executable',+ 'chrome-mode',+ 'scale',+ 'frames',+ 'every-nth-frame',+ 'muted',+ 'enforce-audio-track',+ 'disallow-parallel-encoding',+ 'number-of-gif-loops',+ 'color-space',+ 'hardware-acceleration',+ 'bundle-cache',+ 'log',+ 'port',+ 'public-dir',+ 'public-path',+ 'audio-latency-hint',+ 'timeout',+ 'ignore-certificate-errors',+ 'disable-web-security',+ 'disable-headless',+ 'dark-mode',+ 'gl',+ 'user-agent',+ 'media-cache-size-in-bytes',+ 'offthreadvideo-cache-size-in-bytes',+ 'offthreadvideo-video-threads',+ 'enable-multiprocess-on-linux',+ 'repro',+ 'binaries-directory',+ 'rspack',+ 'disable-ask-ai',+ 'disable-keyboard-shortcuts',+ 'quiet',+ 'public-license-key',+ 'sample-rate',+ 'for-seamless-aac-concatenation',+ 'separate-audio-to',+ 'metadata',+ ],+ {'image-format': 'Video Image Format'},+ ),},{- name: 'still',- aliases: [],+ path: ['still'],args: ' <serve-url|entry-point>? [<composition-id>] [<output-location>]',description: 'Render a still frame and save it as an image.',documentation: 'https://www.remotion.dev/docs/cli/still',+ options: options([+ 'props',+ 'height',+ 'width',+ 'fps',+ 'duration',+ 'image-format',+ 'config',+ 'env-file',+ 'jpeg-quality',+ 'output',+ 'overwrite',+ 'browser-executable',+ 'scale',+ 'frame',+ 'bundle-cache',+ 'log',+ 'port',+ 'public-dir',+ 'public-path',+ 'audio-latency-hint',+ 'timeout',+ 'ignore-certificate-errors',+ 'disable-web-security',+ 'disable-headless',+ 'dark-mode',+ 'chrome-mode',+ 'gl',+ 'user-agent',+ 'media-cache-size-in-bytes',+ 'offthreadvideo-cache-size-in-bytes',+ 'offthreadvideo-video-threads',+ 'enable-multiprocess-on-linux',+ 'binaries-directory',+ 'rspack',+ 'disable-ask-ai',+ 'disable-keyboard-shortcuts',+ 'quiet',+ 'public-license-key',+ ]),},{- name: 'compositions',- aliases: [],+ path: ['compositions'],args: ' <serve-url|entry-file>?',- description: 'Prints the available compositions.',+ description: 'Print the available compositions.',documentation: 'https://www.remotion.dev/docs/cli/compositions',+ options: options([+ 'props',+ 'browser-executable',+ 'config',+ 'env-file',+ 'bundle-cache',+ 'log',+ 'port',+ 'public-dir',+ 'public-path',+ 'audio-latency-hint',+ 'timeout',+ 'ignore-certificate-errors',+ 'disable-web-security',+ 'disable-headless',+ 'dark-mode',+ 'gl',+ 'enable-multiprocess-on-linux',+ 'user-agent',+ 'media-cache-size-in-bytes',+ 'offthreadvideo-cache-size-in-bytes',+ 'offthreadvideo-video-threads',+ 'binaries-directory',+ 'chrome-mode',+ 'quiet',+ 'rspack',+ 'disable-ask-ai',+ 'disable-keyboard-shortcuts',+ ]),},{- name: 'lambda',- aliases: [],+ path: ['lambda'],args: ' <command>',description: 'Control Remotion Lambda.',documentation: 'https://www.remotion.dev/docs/lambda/cli',+ options: [],},{- name: 'bundle',- aliases: [],+ path: ['bundle'],args: ' <serve-url|entry-file>?',description: 'Create a Remotion bundle to be deployed to the web.',documentation: 'https://www.remotion.dev/docs/cli/bundle',+ options: options([+ 'config',+ 'log',+ 'public-dir',+ 'out-dir',+ 'public-path',+ 'disable-git-source',+ 'bundle-cache',+ 'audio-latency-hint',+ 'rspack',+ 'disable-ask-ai',+ 'disable-keyboard-shortcuts',+ 'quiet',+ ]),},{- name: BROWSER_COMMAND,- aliases: [],+ path: [BROWSER_COMMAND],args: ' <command>',description: 'Ensure Remotion has a browser it can use for rendering.',documentation: 'https://www.remotion.dev/docs/cli/browser',+ options: [],+ },+ {+ path: [BROWSER_COMMAND, 'ensure'],+ args: '',+ description: 'Ensure Remotion has a browser it can use for rendering.',+ documentation: 'https://www.remotion.dev/docs/cli/browser/ensure',+ options: options(['browser-executable', 'log', 'quiet']),},{- name: 'cloudrun',- aliases: [],+ path: ['cloudrun'],args: ' <command>',description: 'Control Remotion Cloud Run.',documentation: 'https://www.remotion.dev/docs/cloudrun/cli',+ options: [],},{- name: 'benchmark',- aliases: [],- args: ' <entry-point> [composition-ids]',- description:- 'Benchmarks rendering a composition. Same options as for render.',+ path: ['benchmark'],+ args: ' [<entry-point>] [composition-ids]',+ description: 'Benchmark rendering one or more compositions.',documentation: 'https://www.remotion.dev/docs/cli/benchmark',+ options: options(+ [+ 'runs',+ 'concurrencies',+ 'concurrency',+ 'codec',+ 'crf',+ 'frames',+ 'height',+ 'width',+ 'fps',+ 'duration',+ 'image-format',+ 'pixel-format',+ 'props',+ 'prores-profile',+ 'x264-preset',+ 'gop',+ 'jpeg-quality',+ 'log',+ 'ignore-certificate-errors',+ 'disable-web-security',+ 'dark-mode',+ 'disable-headless',+ 'enable-multiprocess-on-linux',+ 'gl',+ 'chrome-mode',+ 'timeout',+ 'scale',+ 'port',+ 'number-of-gif-loops',+ 'every-nth-frame',+ 'muted',+ 'enforce-audio-track',+ 'disallow-parallel-encoding',+ 'browser-executable',+ 'user-agent',+ 'public-dir',+ 'public-path',+ 'config',+ 'env-file',+ 'bundle-cache',+ 'video-bitrate',+ 'audio-bitrate',+ 'buffer-size',+ 'max-rate',+ 'color-space',+ 'hardware-acceleration',+ 'offthreadvideo-cache-size-in-bytes',+ 'offthreadvideo-video-threads',+ 'media-cache-size-in-bytes',+ 'binaries-directory',+ 'rspack',+ 'overwrite',+ 'metadata',+ 'sample-rate',+ 'for-seamless-aac-concatenation',+ 'disable-ask-ai',+ 'disable-keyboard-shortcuts',+ 'quiet',+ ],+ {'image-format': 'Video Image Format'},+ ),},{- name: 'skills',- aliases: [],+ path: ['skills'],args: ' <add | update>',description: 'Install or update skills from remotion-dev/skills.',documentation: 'https://www.remotion.dev/docs/cli/skills',+ options: [],},{- name: VERSIONS_COMMAND,- aliases: [],+ path: ['skills', 'add'],+ args: ' [options]',+ description: 'Install skills from remotion-dev/skills.',+ documentation: 'https://www.remotion.dev/docs/cli/skills',+ options: [],+ },+ {+ path: ['skills', 'update'],+ args: ' [options]',+ description: 'Update skills from remotion-dev/skills.',+ documentation: 'https://www.remotion.dev/docs/cli/skills',+ options: [],+ },+ {+ path: [VERSIONS_COMMAND],args: '',- description: 'Prints and validates versions of all Remotion packages.',+ description: 'Print and validate versions of all Remotion packages.',documentation: 'https://www.remotion.dev/docs/cli/versions',+ options: [],},{- name: 'upgrade',- aliases: [],+ path: ['upgrade'],args: '',description: 'Ensure Remotion is on the newest version.',documentation: 'https://www.remotion.dev/docs/cli/upgrade',+ options: options(['package-manager', 'version', 'skip-skills']),},{- name: 'add',- aliases: [],+ path: ['add'],args: ' <package-name...>',description: 'Add Remotion packages with the correct version.',documentation: 'https://www.remotion.dev/docs/cli/add',+ options: options(['package-manager']),},{- name: GPU_COMMAND,- aliases: [],+ path: [GPU_COMMAND],args: '',- description: 'Prints information about how Chrome uses the GPU.',+ description: 'Print information about how Chrome uses the GPU.',documentation: 'https://www.remotion.dev/docs/cli/gpu',+ options: options([+ 'log',+ 'gl',+ 'chrome-mode',+ 'browser-executable',+ 'user-agent',+ 'disable-web-security',+ 'ignore-certificate-errors',+ 'enable-multiprocess-on-linux',+ 'timeout',+ 'disable-headless',+ 'dark-mode',+ 'quiet',+ ]),},{- name: 'ffmpeg',- aliases: [],+ path: ['ffmpeg'],args: ' <arguments...>',- description: 'Execute an FFmpeg command.',+ description: 'Execute FFmpeg with all arguments forwarded.',documentation: 'https://www.remotion.dev/docs/cli/ffmpeg',+ options: [],},{- name: 'ffprobe',- aliases: [],+ path: ['ffprobe'],args: ' <arguments...>',- description: 'Execute an FFprobe command.',+ description: 'Execute FFprobe with all arguments forwarded.',documentation: 'https://www.remotion.dev/docs/cli/ffprobe',+ options: [],},{- name: 'help',- aliases: [],+ path: ['help'],args: '',description: 'Print available commands and flags for the Remotion CLI.',documentation: 'https://www.remotion.dev/docs/cli/help',+ options: [],},];-const printCommandHelp = ({- command,- displayName,- logLevel,-}: {- command: CommandHelp;- displayName: string;- logLevel: LogLevel;-}) => {- Log.info(- {indent: false, logLevel},- chalk.blue(`remotion ${displayName}`) + chalk.gray(command.args),- );- Log.info({indent: false, logLevel}, command.description);- Log.info({indent: false, logLevel}, chalk.gray(command.documentation));-};-export const printHelp = (logLevel: LogLevel,- selectedCommand: string | null,+ selectedPath: readonly string[],) => {Log.info({indent: false, logLevel}, `@remotion/cli ${packagejson.version}`);Log.info(@@ -165,34 +469,12 @@ export const printHelp = (`© ${new Date().getFullYear()} Remotion AG`,);- if (selectedCommand !== null) {- const selectedCommandHelp = commandHelp.find(- (command) =>- command.name === selectedCommand ||- command.aliases.includes(selectedCommand),- );- if (selectedCommandHelp) {- Log.info({indent: false, logLevel});- printCommandHelp({- command: selectedCommandHelp,- displayName: selectedCommand,- logLevel,- });- return;- }- }-- Log.info({indent: false, logLevel});- Log.info({indent: false, logLevel}, 'Available commands:');-- for (const command of commandHelp) {- Log.info({indent: false, logLevel});- printCommandHelp({command, displayName: command.name, logLevel});+ for (const line of getCommandHelp({+ binaryName: 'remotion',+ commands: commandHelp,+ selectedPath,+ rootDocumentation: 'https://www.remotion.dev/docs/cli',+ })) {+ Log.info({indent: false, logLevel}, line);}-- Log.info({indent: false, logLevel});- Log.info(- {indent: false, logLevel},- 'Visit https://www.remotion.dev/docs/cli for browsable CLI documentation.',- );};diff --git a/packages/cli/src/test/help.test.ts b/packages/cli/src/test/help.test.tsindex 8211e866ed..897cd60528 100644--- a/packages/cli/src/test/help.test.ts+++ b/packages/cli/src/test/help.test.ts@@ -6,28 +6,79 @@ import path from 'node:path';const cliPath = path.join(__dirname, '..', '..', 'remotion-cli.js');-const commandHelpPages = [- {args: ['render'], documentation: '/docs/cli/render'},- {args: ['studio'], documentation: '/docs/cli/studio'},- {args: ['preview'], documentation: '/docs/cli/studio'},- {args: ['still'], documentation: '/docs/cli/still'},- {args: ['compositions'], documentation: '/docs/cli/compositions'},- {args: ['lambda'], documentation: '/docs/lambda/cli'},- {args: ['bundle'], documentation: '/docs/cli/bundle'},- {args: ['browser'], documentation: '/docs/cli/browser'},- {args: ['browser', 'ensure'], documentation: '/docs/cli/browser'},- {args: ['cloudrun'], documentation: '/docs/cloudrun/cli'},- {args: ['benchmark'], documentation: '/docs/cli/benchmark'},- {args: ['skills'], documentation: '/docs/cli/skills'},- {args: ['skills', 'add'], documentation: '/docs/cli/skills'},- {args: ['skills', 'update'], documentation: '/docs/cli/skills'},- {args: ['versions'], documentation: '/docs/cli/versions'},- {args: ['upgrade'], documentation: '/docs/cli/upgrade'},- {args: ['add'], documentation: '/docs/cli/add'},- {args: ['gpu'], documentation: '/docs/cli/gpu'},- {args: ['ffmpeg'], documentation: '/docs/cli/ffmpeg'},- {args: ['ffprobe'], documentation: '/docs/cli/ffprobe'},- {args: ['help'], documentation: '/docs/cli/help'},+const commandHelpPages: readonly {+ args: readonly string[];+ documentation: string;+ options: readonly string[];+ excludedOptions?: readonly string[];+}[] = [+ {+ args: ['render'],+ documentation: '/docs/cli/render',+ options: ['--codec', '--sequence', '--public-path', '--public-license-key'],+ },+ {+ args: ['studio'],+ documentation: '/docs/cli/studio',+ options: ['--editor', '--port'],+ },+ {+ args: ['preview'],+ documentation: '/docs/cli/studio',+ options: ['--editor', '--port'],+ },+ {+ args: ['still'],+ documentation: '/docs/cli/still',+ options: ['--frame', '--image-format', '--height', '--audio-latency-hint'],+ },+ {+ args: ['compositions'],+ documentation: '/docs/cli/compositions',+ options: ['--props', '--browser-executable', '--gl'],+ },+ {args: ['lambda'], documentation: '/docs/lambda/cli', options: []},+ {+ args: ['bundle'],+ documentation: '/docs/cli/bundle',+ options: ['--out-dir', '--bundle-cache', '--quiet'],+ },+ {args: ['browser'], documentation: '/docs/cli/browser', options: []},+ {+ args: ['browser', 'ensure'],+ documentation: '/docs/cli/browser/ensure',+ options: ['--browser-executable', '--quiet'],+ excludedOptions: ['--chrome-mode'],+ },+ {args: ['cloudrun'], documentation: '/docs/cloudrun/cli', options: []},+ {+ args: ['benchmark'],+ documentation: '/docs/cli/benchmark',+ options: ['--runs', '--concurrencies', '--concurrency', '--x264-preset'],+ excludedOptions: ['--audio-codec'],+ },+ {args: ['skills'], documentation: '/docs/cli/skills', options: []},+ {args: ['skills', 'add'], documentation: '/docs/cli/skills', options: []},+ {args: ['skills', 'update'], documentation: '/docs/cli/skills', options: []},+ {args: ['versions'], documentation: '/docs/cli/versions', options: []},+ {+ args: ['upgrade'],+ documentation: '/docs/cli/upgrade',+ options: ['--package-manager'],+ },+ {+ args: ['add'],+ documentation: '/docs/cli/add',+ options: ['--package-manager'],+ },+ {+ args: ['gpu'],+ documentation: '/docs/cli/gpu',+ options: ['--gl', '--browser-executable', '--timeout', '--quiet'],+ },+ {args: ['ffmpeg'], documentation: '/docs/cli/ffmpeg', options: []},+ {args: ['ffprobe'], documentation: '/docs/cli/ffprobe', options: []},+ {args: ['help'], documentation: '/docs/cli/help', options: []},] as const;test('prints command-specific help without running the command', () => {@@ -41,7 +92,12 @@ test('prints command-specific help without running the command', () => {const initialFiles = readdirSync(temporaryDirectory);try {- for (const {args, documentation} of commandHelpPages) {+ for (const {+ args,+ documentation,+ options,+ excludedOptions = [],+ } of commandHelpPages) {const result = spawnSync('node',[cliPath, ...args, '--help', '--log=error'],@@ -61,15 +117,33 @@ test('prints command-specific help without running the command', () => {expect(result.signal).toBeNull();expect(result.status).toBe(0);expect(result.stderr).toBe('');- expect(result.stdout).toContain(`remotion ${args[0]}`);+ expect(result.stdout).toContain(`remotion ${args.join(' ')}`);expect(result.stdout).toContain(`https://www.remotion.dev${documentation}`,);expect(result.stdout).not.toContain('Available commands:');+ expect(result.stdout).toContain('Options:');+ for (const option of ['--help', ...options]) {+ const optionLine = result.stdout.split('\n').find((line) => {+ const trimmed = line.trimStart();+ return (+ trimmed.startsWith(`${option} `) || trimmed.startsWith(`${option},`)+ );+ });+ if (!optionLine) {+ throw new Error(+ `Expected \`remotion ${args.join(' ')} --help\` to document ${option}`,+ );+ }+ }++ for (const option of excludedOptions) {+ expect(result.stdout).not.toContain(option);+ }}expect(readdirSync(temporaryDirectory)).toEqual(initialFiles);} finally {rmSync(temporaryDirectory, {recursive: true, force: true});}-}, 30_000);+}, 60_000);diff --git a/packages/cloudrun/src/cli/help.ts b/packages/cloudrun/src/cli/help.tsindex 301a5ca659..622e0adeb7 100644--- a/packages/cloudrun/src/cli/help.ts+++ b/packages/cloudrun/src/cli/help.ts@@ -1,66 +1,362 @@import {CliInternals} from '@remotion/cli';import type {LogLevel} from '@remotion/renderer';+import {BrowserSafeApis} from '@remotion/renderer/client';import {BINARY_NAME} from '../shared/constants';import {PERMISSIONS_COMMAND} from './commands/permissions';import {REGIONS_COMMAND} from './commands/regions';import {RENDER_COMMAND} from './commands/render';import {SERVICES_COMMAND} from './commands/services';+import {CLOUD_RUN_DEPLOY_SUBCOMMAND} from './commands/services/deploy';+import {SERVICES_LS_SUBCOMMAND} from './commands/services/ls';+import {SERVICES_RM_SUBCOMMAND} from './commands/services/rm';+import {SERVICES_RMALL_SUBCOMMAND} from './commands/services/rmall';import {SITES_COMMAND} from './commands/sites';+import {SITES_CREATE_SUBCOMMAND} from './commands/sites/create';+import {SITES_LS_SUBCOMMAND} from './commands/sites/ls';+import {SITES_RM_COMMAND} from './commands/sites/rm';+import {SITES_RMALL_COMMAND} from './commands/sites/rmall';import {STILL_COMMAND} from './commands/still';import {Log} from './log';const packagejson = require('../../package.json');-export const printHelp = (logLevel: LogLevel) => {- Log.info(- {indent: false, logLevel},- `${BINARY_NAME} ${- packagejson.version- } © ${new Date().getFullYear()} The Remotion developers`,- );- Log.info({indent: false, logLevel});- Log.info({indent: false, logLevel}, 'Available commands:');- Log.info({indent: false, logLevel}, '');+const rendererOptions = Object.values(BrowserSafeApis.options);- Log.info({indent: false, logLevel});- Log.info({indent: false, logLevel}, `${BINARY_NAME} ${RENDER_COMMAND}`);- Log.info(- {indent: false, logLevel},- CliInternals.chalk.gray('Render Remotion media on GCP Cloud Run.'),- );+const cloudrunOnlyOptions = {+ region: {+ flag: '--region <region>',+ description: 'Select the GCP region.',+ },+ privacy: {+ flag: '--privacy <public|private|no-acl>',+ description: 'Set the privacy of the rendered output.',+ },+ 'force-bucket-name': {+ flag: '--force-bucket-name <bucket-name>',+ description: 'Store the output in a specific Cloud Storage bucket.',+ },+ 'out-name': {+ flag: '--out-name <file-name>',+ description: 'Set the output file name in Cloud Storage.',+ },+ 'cloud-run-url': {+ flag: '--cloud-run-url <url>',+ description: 'Use a specific Cloud Run service URL.',+ },+ 'service-name': {+ flag: '--service-name <service-name>',+ description: 'Use a specific deployed Cloud Run service.',+ },+ webhook: {+ flag: '--webhook <url>',+ description: 'POST render progress to this URL.',+ },+ 'render-id-override': {+ flag: '--render-id-override <id>',+ description: 'Use a specific render ID.',+ },+ memoryLimit: {+ flag: '--memoryLimit <limit>',+ description: 'Set the maximum memory available to each service instance.',+ },+ cpuLimit: {+ flag: '--cpuLimit <limit>',+ description: 'Set the maximum CPU available to each service instance.',+ },+ minInstances: {+ flag: '--minInstances <count>',+ description: 'Set the minimum number of service instances.',+ },+ maxInstances: {+ flag: '--maxInstances <count>',+ description: 'Set the maximum number of service instances.',+ },+ timeoutSeconds: {+ flag: '--timeoutSeconds <seconds>',+ description: 'Set the request timeout for the service.',+ },+ onlyAllocateCpuDuringRequestProcessing: {+ flag: '--onlyAllocateCpuDuringRequestProcessing',+ description: 'Allocate CPU only while a request is being processed.',+ },+ quiet: {+ flag: '--quiet, -q',+ description: 'Reduce console output.',+ },+ yes: {+ flag: '--yes, -y',+ description: 'Skip deletion confirmation prompts.',+ },+ 'site-name': {+ flag: '--site-name <name>',+ description: 'Set the deployed site name.',+ },+ 'all-regions': {+ flag: '--all-regions',+ description: 'Include sites from every region.',+ },+} as const;- Log.info({indent: false, logLevel});- Log.info({indent: false, logLevel}, `${BINARY_NAME} ${STILL_COMMAND}`);- Log.info(- {indent: false, logLevel},- CliInternals.chalk.gray('Render Remotion still on GCP Cloud Run.'),- );+const options = (+ flags: readonly string[],+ descriptionOverrides: Record<string, string> = {},+) => {+ return flags.map((flag) => {+ const cloudrunOnlyOption =+ cloudrunOnlyOptions[flag as keyof typeof cloudrunOnlyOptions];+ if (cloudrunOnlyOption) {+ return cloudrunOnlyOption;+ }- Log.info({indent: false, logLevel});- Log.info({indent: false, logLevel}, `${BINARY_NAME} ${SERVICES_COMMAND}`);- Log.info(- {indent: false, logLevel},- CliInternals.chalk.gray('Deploy and manage Cloud Run services on GCP.'),- );+ const rendererOption = rendererOptions.find(+ (candidate) => candidate.cliFlag === flag,+ );+ if (!rendererOption) {+ throw new Error(`No Cloud Run CLI help metadata exists for --${flag}`);+ }- Log.info({indent: false, logLevel});- Log.info({indent: false, logLevel}, `${BINARY_NAME} ${SITES_COMMAND}`);- Log.info(- {indent: false, logLevel},- CliInternals.chalk.gray('Deploy and manage Remotion projects.'),- );+ return CliInternals.makeCommandHelpOption({+ option: rendererOption,+ description: descriptionOverrides[flag],+ });+ });+};- Log.info({indent: false, logLevel});- Log.info({indent: false, logLevel}, `${BINARY_NAME} ${PERMISSIONS_COMMAND}`);- Log.info(- {indent: false, logLevel},- CliInternals.chalk.gray('View and validate required GCP permissions.'),- );+const renderOptions = options(+ [+ 'region',+ 'props',+ 'privacy',+ 'force-bucket-name',+ 'concurrency',+ 'height',+ 'width',+ 'fps',+ 'duration',+ 'jpeg-quality',+ 'image-format',+ 'scale',+ 'env-file',+ 'out-name',+ 'cloud-run-url',+ 'service-name',+ 'codec',+ 'audio-codec',+ 'audio-bitrate',+ 'video-bitrate',+ 'buffer-size',+ 'max-rate',+ 'webhook',+ 'render-id-override',+ 'prores-profile',+ 'x264-preset',+ 'gop',+ 'crf',+ 'pixel-format',+ 'every-nth-frame',+ 'number-of-gif-loops',+ 'frames',+ 'browser-executable',+ 'user-agent',+ 'disable-web-security',+ 'ignore-certificate-errors',+ 'enable-multiprocess-on-linux',+ 'gl',+ 'disable-headless',+ 'dark-mode',+ 'timeout',+ 'binaries-directory',+ 'muted',+ 'enforce-audio-track',+ 'quiet',+ 'media-cache-size-in-bytes',+ 'offthreadvideo-cache-size-in-bytes',+ 'offthreadvideo-video-threads',+ 'color-space',+ 'metadata',+ 'sample-rate',+ ],+ {'image-format': 'Video Image Format'},+);- Log.info({indent: false, logLevel});- Log.info({indent: false, logLevel}, `${BINARY_NAME} ${REGIONS_COMMAND}`);+const commandHelp = [+ {+ path: [],+ args: ' <command>',+ description: 'Control Remotion Cloud Run.',+ documentation: 'https://www.remotion.dev/docs/cloudrun/cli',+ options: [],+ },+ {+ path: [RENDER_COMMAND],+ args: ' <serve-url|site-name> [<composition-id>] [<output-location>]',+ description: 'Render Remotion media on GCP Cloud Run.',+ documentation: 'https://www.remotion.dev/docs/cloudrun/cli/render',+ options: renderOptions,+ },+ {+ path: [STILL_COMMAND],+ args: ' <serve-url|site-name> [<still-id>] [<output-location>]',+ description: 'Render a Remotion still on GCP Cloud Run.',+ documentation: 'https://www.remotion.dev/docs/cloudrun/cli/still',+ options: options([+ 'region',+ 'props',+ 'frame',+ 'privacy',+ 'force-bucket-name',+ 'height',+ 'width',+ 'fps',+ 'duration',+ 'jpeg-quality',+ 'image-format',+ 'scale',+ 'env-file',+ 'out-name',+ 'cloud-run-url',+ 'service-name',+ 'browser-executable',+ 'user-agent',+ 'disable-web-security',+ 'ignore-certificate-errors',+ 'enable-multiprocess-on-linux',+ 'gl',+ 'disable-headless',+ 'dark-mode',+ 'timeout',+ 'binaries-directory',+ 'quiet',+ 'media-cache-size-in-bytes',+ 'offthreadvideo-cache-size-in-bytes',+ ]),+ },+ {+ path: [SERVICES_COMMAND],+ args: ' <command>',+ description: 'Deploy and manage Cloud Run services on GCP.',+ documentation: 'https://www.remotion.dev/docs/cloudrun/cli/services',+ options: [],+ },+ {+ path: [SERVICES_COMMAND, CLOUD_RUN_DEPLOY_SUBCOMMAND],+ args: '',+ description: 'Deploy a new Cloud Run service.',+ documentation: 'https://www.remotion.dev/docs/cloudrun/cli/services/deploy',+ options: options([+ 'region',+ 'memoryLimit',+ 'cpuLimit',+ 'minInstances',+ 'maxInstances',+ 'timeoutSeconds',+ 'onlyAllocateCpuDuringRequestProcessing',+ 'quiet',+ ]),+ },+ {+ path: [SERVICES_COMMAND, SERVICES_LS_SUBCOMMAND],+ args: '',+ description: 'List deployed Cloud Run services.',+ documentation: 'https://www.remotion.dev/docs/cloudrun/cli/services/ls',+ options: options(['region', 'quiet']),+ },+ {+ path: [SERVICES_COMMAND, SERVICES_RM_SUBCOMMAND],+ args: ' <service-name...>',+ description: 'Delete one or more Cloud Run services.',+ documentation: 'https://www.remotion.dev/docs/cloudrun/cli/services/rm',+ options: options(['region', 'yes']),+ },+ {+ path: [SERVICES_COMMAND, SERVICES_RMALL_SUBCOMMAND],+ args: '',+ description: 'Delete all Cloud Run services in the selected region.',+ documentation: 'https://www.remotion.dev/docs/cloudrun/cli/services/rmall',+ options: options(['region', 'yes']),+ },+ {+ path: [SITES_COMMAND],+ args: ' <command>',+ description: 'Deploy and manage Remotion projects.',+ documentation: 'https://www.remotion.dev/docs/cloudrun/cli/sites',+ options: [],+ },+ {+ path: [SITES_COMMAND, SITES_CREATE_SUBCOMMAND],+ args: ' <entry-point>?',+ description: 'Bundle and upload a Remotion project.',+ documentation: 'https://www.remotion.dev/docs/cloudrun/cli/sites/create',+ options: options([+ 'region',+ 'site-name',+ 'privacy',+ 'disable-git-source',+ 'bundle-cache',+ 'rspack',+ 'disable-ask-ai',+ 'disable-keyboard-shortcuts',+ 'quiet',+ ]),+ },+ {+ path: [SITES_COMMAND, SITES_LS_SUBCOMMAND],+ args: '',+ description: 'List deployed Remotion projects.',+ documentation: 'https://www.remotion.dev/docs/cloudrun/cli/sites/ls',+ options: options(['region', 'all-regions', 'quiet']),+ },+ {+ path: [SITES_COMMAND, SITES_RM_COMMAND],+ args: ' <site-name...>',+ description: 'Delete one or more deployed Remotion projects.',+ documentation: 'https://www.remotion.dev/docs/cloudrun/cli/sites/rm',+ options: options(['region', 'yes']),+ },+ {+ path: [SITES_COMMAND, SITES_RMALL_COMMAND],+ args: '',+ description: 'Delete all deployed Remotion projects.',+ documentation: 'https://www.remotion.dev/docs/cloudrun/cli/sites/rmall',+ options: options(['region', 'all-regions', 'yes']),+ },+ {+ path: [PERMISSIONS_COMMAND],+ args: '',+ description: 'View and validate required GCP permissions.',+ documentation: 'https://www.remotion.dev/docs/cloudrun/cli/permissions',+ options: [],+ },+ {+ path: [REGIONS_COMMAND],+ args: '',+ description: 'Show the supported GCP regions.',+ documentation: 'https://www.remotion.dev/docs/cloudrun/cli/regions',+ options: [],+ },+] as const;++export const getCloudrunHelp = (selectedPath: readonly string[]) => {+ return CliInternals.getCommandHelp({+ binaryName: BINARY_NAME,+ commands: commandHelp,+ selectedPath,+ rootDocumentation: 'https://www.remotion.dev/docs/cloudrun/cli',+ });+};++export const printHelp = (+ selectedPath: readonly string[],+ logLevel: LogLevel,+) => {Log.info({indent: false, logLevel},- CliInternals.chalk.gray('Show the list of GCP regions supported.'),+ `${BINARY_NAME} ${+ packagejson.version+ } © ${new Date().getFullYear()} The Remotion developers`,);++ for (const line of getCloudrunHelp(selectedPath)) {+ Log.info({indent: false, logLevel}, line);+ }};diff --git a/packages/cloudrun/src/cli/index.ts b/packages/cloudrun/src/cli/index.tsindex bf1264f197..ef02743490 100644--- a/packages/cloudrun/src/cli/index.ts+++ b/packages/cloudrun/src/cli/index.ts@@ -18,7 +18,7 @@ const matchCommand = (logLevel: LogLevel,) => {if (parsedCloudrunCli.help || args.length === 0 || args[0] === 'help') {- printHelp(logLevel);+ printHelp(args[0] === 'help' ? args.slice(1) : args, logLevel);quit(0);}@@ -52,7 +52,7 @@ const matchCommand = (}Log.error({indent: false, logLevel}, `Command ${args[0]} not found.`);- printHelp(logLevel);+ printHelp([], logLevel);quit(1);};diff --git a/packages/cloudrun/src/internals.ts b/packages/cloudrun/src/internals.tsindex 048bf33c32..3c01a2c763 100644--- a/packages/cloudrun/src/internals.ts+++ b/packages/cloudrun/src/internals.ts@@ -1,4 +1,6 @@+import {printHelp} from './cli/help';import {executeCommand} from './cli/index';export const CloudrunInternals = {executeCommand,+ printHelp,};diff --git a/packages/cloudrun/src/test/cli-help.test.ts b/packages/cloudrun/src/test/cli-help.test.tsnew file mode 100644index 0000000000..b04efb1c1a--- /dev/null+++ b/packages/cloudrun/src/test/cli-help.test.ts@@ -0,0 +1,158 @@+import {expect, test} from 'bun:test';+import {spawnSync} from 'node:child_process';+import {mkdtempSync, readdirSync, rmSync, writeFileSync} from 'node:fs';+import path from 'node:path';+import {getCloudrunHelp} from '../cli/help';++const commandHelpPages = [+ {args: [], documentation: '/docs/cloudrun/cli', option: null},+ {+ args: ['render'],+ documentation: '/docs/cloudrun/cli/render',+ option: '--service-name',+ },+ {+ args: ['still'],+ documentation: '/docs/cloudrun/cli/still',+ option: '--image-format',+ },+ {+ args: ['services'],+ documentation: '/docs/cloudrun/cli/services',+ option: null,+ },+ {+ args: ['services', 'deploy'],+ documentation: '/docs/cloudrun/cli/services/deploy',+ option: '--memoryLimit',+ },+ {+ args: ['services', 'ls'],+ documentation: '/docs/cloudrun/cli/services/ls',+ option: '--quiet',+ },+ {+ args: ['services', 'rm'],+ documentation: '/docs/cloudrun/cli/services/rm',+ option: '--yes',+ },+ {+ args: ['services', 'rmall'],+ documentation: '/docs/cloudrun/cli/services/rmall',+ option: '--yes',+ },+ {args: ['sites'], documentation: '/docs/cloudrun/cli/sites', option: null},+ {+ args: ['sites', 'create'],+ documentation: '/docs/cloudrun/cli/sites/create',+ option: '--site-name',+ },+ {+ args: ['sites', 'ls'],+ documentation: '/docs/cloudrun/cli/sites/ls',+ option: '--all-regions',+ },+ {+ args: ['sites', 'rm'],+ documentation: '/docs/cloudrun/cli/sites/rm',+ option: '--yes',+ },+ {+ args: ['sites', 'rmall'],+ documentation: '/docs/cloudrun/cli/sites/rmall',+ option: '--all-regions',+ },+ {+ args: ['permissions'],+ documentation: '/docs/cloudrun/cli/permissions',+ option: null,+ },+ {+ args: ['regions'],+ documentation: '/docs/cloudrun/cli/regions',+ option: null,+ },+] as const;++test('defines help for every Cloud Run command', () => {+ for (const {args, documentation, option} of commandHelpPages) {+ const lines = getCloudrunHelp(args);+ const output = lines.join('\n');+ const command = `remotion cloudrun${args.length === 0 ? '' : ` ${args.join(' ')}`}`;++ expect(output).toContain(command);+ expect(output).toContain(`https://www.remotion.dev${documentation}`);+ expect(output).toContain('Options:');+ const helpLine = lines.find((line) => line.includes('--help'));+ expect(helpLine).toContain('Show this help.');++ if (option) {+ const optionLine = lines.find((line) => line.includes(option));+ expect(optionLine).toBeDefined();+ expect(optionLine?.length).toBeGreaterThan(option.length + 2);+ }+ }++ const renderHelp = getCloudrunHelp(['render']).join('\n');+ expect(renderHelp).toContain('--buffer-size <value>');+ expect(renderHelp).toContain('--browser-executable <value>');+ expect(renderHelp).toContain('--quiet, -q');++ const stillHelp = getCloudrunHelp(['still']).join('\n');+ expect(stillHelp).toContain('--frame <value>');+ expect(stillHelp).toContain('--height <value>');+ expect(stillHelp).not.toContain('--offthreadvideo-video-threads');++ const createSiteHelp = getCloudrunHelp(['sites', 'create']).join('\n');+ expect(createSiteHelp).toContain('--bundle-cache');+ expect(createSiteHelp).toContain('--disable-ask-ai');+});++test('the Remotion CLI delegates Cloud Run help before loading config', () => {+ const exampleDirectory = path.join(__dirname, '..', '..', '..', 'example');+ const temporaryDirectory = mkdtempSync(+ path.join(exampleDirectory, '.tmp-cloudrun-cli-help-'),+ );+ writeFileSync(path.join(temporaryDirectory, 'package.json'), '{}\n');+ writeFileSync(+ path.join(temporaryDirectory, 'remotion.config.ts'),+ `throw new Error('The config file must not be loaded for --help');\n`,+ );+ const initialFiles = readdirSync(temporaryDirectory);++ try {+ const result = spawnSync(+ 'node',+ [+ path.join(exampleDirectory, '..', 'cli', 'remotion-cli.js'),+ 'cloudrun',+ 'render',+ '--help',+ '--log=error',+ ],+ {+ cwd: temporaryDirectory,+ encoding: 'utf8',+ env: {...process.env, NO_COLOR: '1'},+ stdio: ['ignore', 'pipe', 'pipe'],+ timeout: 10_000,+ },+ );++ if (result.error) {+ throw result.error;+ }++ expect(result.signal).toBeNull();+ expect(result.status).toBe(0);+ expect(result.stderr).toBe('');+ expect(result.stdout).toContain('remotion cloudrun render');+ expect(result.stdout).toContain('--service-name <service-name>');+ expect(result.stdout).toContain(+ 'https://www.remotion.dev/docs/cloudrun/cli/render',+ );+ expect(readdirSync(temporaryDirectory)).toEqual(initialFiles);+ } finally {+ rmSync(temporaryDirectory, {recursive: true, force: true});+ }+}, 15_000);diff --git a/packages/lambda/src/cli/help.ts b/packages/lambda/src/cli/help.tsindex c6f26015ef..89cfe394d1 100644--- a/packages/lambda/src/cli/help.ts+++ b/packages/lambda/src/cli/help.ts@@ -1,6 +1,7 @@import {CliInternals} from '@remotion/cli';import {BINARY_NAME} from '@remotion/lambda-client/constants';import type {LogLevel} from '@remotion/renderer';+import {BrowserSafeApis} from '@remotion/renderer/client';import {COMPOSITIONS_COMMAND} from './commands/compositions';import {FUNCTIONS_COMMAND} from './commands/functions';import {POLICIES_COMMAND} from './commands/policies/policies';@@ -12,75 +13,489 @@ import {STILL_COMMAND} from './commands/still';import {Log} from './log';const packagejson = require('../../package.json');+const rendererOptions = Object.values(BrowserSafeApis.options);-export const printHelp = (logLevel: LogLevel) => {- Log.info(- {indent: false, logLevel},- `${BINARY_NAME} ${- packagejson.version- } © ${new Date().getFullYear()} The Remotion developers`,- );- Log.info({indent: false, logLevel});- Log.info({indent: false, logLevel}, 'Available commands:');- Log.info({indent: false, logLevel}, '');+type HelpOption = ReturnType<typeof CliInternals.makeCommandHelpOption>;+export type PrintHelp = (+ selectedPath: readonly string[],+ logLevel: LogLevel,+) => void;- Log.info(- {indent: false, logLevel},- `${BINARY_NAME} ${RENDER_COMMAND} <s3-url> <composition-id>`,- );- Log.info(- {indent: false, logLevel},- CliInternals.chalk.gray('Render a video in the cloud.'),- );+const lambdaOptions: Record<string, HelpOption> = {+ region: {flag: '--region <region>', description: 'AWS region to use.'},+ privacy: {+ flag: '--privacy <public|private|no-acl>',+ description: 'Set the privacy of the rendered output.',+ },+ 'site-privacy': {+ flag: '--privacy <public|no-acl>',+ description: 'Set the privacy of the deployed site.',+ },+ 'max-retries': {+ flag: '--max-retries <count>',+ description: 'Set how many times a failed chunk may be retried.',+ },+ 'frames-per-lambda': {+ flag: '--frames-per-lambda <count>',+ description: 'Set the number of frames rendered per Lambda invocation.',+ },+ 'concurrency-per-lambda': {+ flag: '--concurrency-per-lambda <count>',+ description: 'Set the concurrency within each Lambda invocation.',+ },+ 'out-name': {+ flag: '--out-name <key>',+ description: 'Set the S3 key of the rendered output.',+ },+ 's3-output-provider-endpoint': {+ flag: '--s3-output-provider-endpoint <url>',+ description: 'Use a custom S3-compatible endpoint for the output.',+ },+ 's3-output-provider-region': {+ flag: '--s3-output-provider-region <region>',+ description: 'Set the region of the custom S3 output provider.',+ },+ 's3-output-provider-force-path-style': {+ flag: '--s3-output-provider-force-path-style',+ description: 'Use path-style URLs for the custom S3 output provider.',+ },+ webhook: {+ flag: '--webhook <url>',+ description: 'Call a webhook when the render finishes.',+ },+ 'webhook-secret': {+ flag: '--webhook-secret <secret>',+ description: 'Sign webhook requests with a secret.',+ },+ 'function-name': {+ flag: '--function-name <name>',+ description: 'Use a specific Lambda function.',+ },+ 'renderer-function-name': {+ flag: '--renderer-function-name <name>',+ description: 'Use a specific renderer Lambda function.',+ },+ 'force-bucket-name': {+ flag: '--force-bucket-name <name>',+ description: 'Use a specific S3 bucket.',+ },+ 'force-path-style': {+ flag: '--force-path-style',+ description: 'Use path-style S3 URLs.',+ },+ 'storage-class': {+ flag: '--storage-class <class>',+ description: 'Set the S3 storage class of the output.',+ },+ memory: {+ flag: '--memory <megabytes>',+ description: 'Set the memory size of the Lambda function.',+ },+ disk: {+ flag: '--disk <megabytes>',+ description: 'Set the ephemeral disk size of the Lambda function.',+ },+ 'retention-period': {+ flag: '--retention-period <days>',+ description: 'Set the CloudWatch log retention period.',+ },+ 'disable-cloudwatch': {+ flag: '--disable-cloudwatch',+ description: 'Disable CloudWatch logging.',+ },+ 'custom-role-arn': {+ flag: '--custom-role-arn <arn>',+ description: 'Use a custom IAM role.',+ },+ 'custom-layer-arns': {+ flag: '--custom-layer-arns <arns>',+ description: 'Attach custom Lambda layers.',+ },+ 'vpc-subnet-ids': {+ flag: '--vpc-subnet-ids <ids>',+ description: 'Attach the function to VPC subnets.',+ },+ 'vpc-security-group-ids': {+ flag: '--vpc-security-group-ids <ids>',+ description: 'Attach VPC security groups to the function.',+ },+ 'runtime-preference': {+ flag: '--runtime-preference <default|apple-emojis|cjk>',+ description: 'Choose the bundled font and emoji runtime.',+ },+ 'function-timeout': {+ flag: '--timeout <seconds>',+ description: 'Set the Lambda function timeout.',+ },+ 'compatible-only': {+ flag: '--compatible-only',+ description: 'Only list resources compatible with this version.',+ },+ '--yes': {+ flag: '--yes, -y',+ description: 'Skip the confirmation prompt.',+ },+ '--force': {+ flag: '--force, -f',+ description: 'Force the requested operation.',+ },+ 'site-name': {+ flag: '--site-name <name>',+ description: 'Set the deployed site name.',+ },+ 'default-only': {+ flag: '--default-only',+ description: 'Only show default AWS regions.',+ },+ quiet: {flag: '--quiet, -q', description: 'Reduce console output.'},+};- Log.info(- {indent: false, logLevel},- `${BINARY_NAME} ${STILL_COMMAND} <s3-url> <composition-id>`,- );- Log.info(- {indent: false, logLevel},- CliInternals.chalk.gray('Render a still image in the cloud.'),- );+const options = (+ flags: readonly string[],+ descriptionOverrides: Record<string, string> = {},+): HelpOption[] => {+ return flags.map((flag) => {+ const lambdaOption = lambdaOptions[flag];+ if (lambdaOption) {+ return lambdaOption;+ }- Log.info({indent: false, logLevel});- Log.info({indent: false, logLevel}, `${BINARY_NAME} ${FUNCTIONS_COMMAND}`);- Log.info(- {indent: false, logLevel},- CliInternals.chalk.gray('Deploy and manage AWS Lambda functions.'),- );+ const rendererOption = rendererOptions.find(+ (candidate) => candidate.cliFlag === flag,+ );+ if (!rendererOption) {+ throw new Error(`No Lambda CLI help metadata exists for --${flag}`);+ }- Log.info({indent: false, logLevel});- Log.info({indent: false, logLevel}, `${BINARY_NAME} ${SITES_COMMAND}`);- Log.info(- {indent: false, logLevel},- CliInternals.chalk.gray('Deploy and manage Remotion projects.'),- );+ return CliInternals.makeCommandHelpOption({+ option: rendererOption,+ description: descriptionOverrides[flag],+ });+ });+};- Log.info({indent: false, logLevel});- Log.info({indent: false, logLevel}, `${BINARY_NAME} ${COMPOSITIONS_COMMAND}`);- Log.info(- {indent: false, logLevel},- CliInternals.chalk.gray('Print list of composition IDs from a serve URL.'),- );+const commandHelp = [+ {+ path: [],+ args: ' <command>',+ description: 'Control Remotion Lambda.',+ documentation: 'https://www.remotion.dev/docs/lambda/cli',+ options: [],+ },+ {+ path: [RENDER_COMMAND],+ args: ' <serve-url> [<composition-id>] [<output-location>]',+ description: 'Render a video in the cloud.',+ documentation: 'https://www.remotion.dev/docs/lambda/cli/render',+ options: options(+ [+ 'region',+ 'enable-cancellation',+ 'props',+ 'log',+ 'privacy',+ 'max-retries',+ 'frames-per-lambda',+ 'concurrency',+ 'concurrency-per-lambda',+ 'jpeg-quality',+ 'muted',+ 'codec',+ 'audio-codec',+ 'audio-bitrate',+ 'video-bitrate',+ 'buffer-size',+ 'max-rate',+ 'prores-profile',+ 'x264-preset',+ 'gop',+ 'crf',+ 'pixel-format',+ 'image-format',+ 'scale',+ 'env-file',+ 'frames',+ 'every-nth-frame',+ 'number-of-gif-loops',+ 'timeout',+ 'out-name',+ 's3-output-provider-endpoint',+ 's3-output-provider-region',+ 's3-output-provider-force-path-style',+ 'overwrite',+ 'webhook',+ 'webhook-secret',+ 'height',+ 'width',+ 'fps',+ 'duration',+ 'function-name',+ 'renderer-function-name',+ 'force-bucket-name',+ 'browser-executable',+ 'ignore-certificate-errors',+ 'disable-web-security',+ 'disable-headless',+ 'dark-mode',+ 'gl',+ 'enable-multiprocess-on-linux',+ 'user-agent',+ 'media-cache-size-in-bytes',+ 'offthreadvideo-cache-size-in-bytes',+ 'offthreadvideo-video-threads',+ 'delete-after',+ 'webhook-custom-data',+ 'color-space',+ 'prefer-lossless',+ 'metadata',+ 'sample-rate',+ 'force-path-style',+ 'storage-class',+ 'license-key',+ 'binaries-directory',+ 'quiet',+ ],+ {'image-format': 'Video Image Format'},+ ),+ },+ {+ path: [STILL_COMMAND],+ args: ' <serve-url> [<composition-id>] [<output-location>]',+ description: 'Render a still image in the cloud.',+ documentation: 'https://www.remotion.dev/docs/lambda/cli/still',+ options: options([+ 'frame',+ 'region',+ 'props',+ 'env-file',+ 'scale',+ 'log',+ 'privacy',+ 'max-retries',+ 'out-name',+ 's3-output-provider-endpoint',+ 's3-output-provider-region',+ 's3-output-provider-force-path-style',+ 'image-format',+ 'jpeg-quality',+ 'timeout',+ 'height',+ 'width',+ 'fps',+ 'duration',+ 'function-name',+ 'force-bucket-name',+ 'browser-executable',+ 'ignore-certificate-errors',+ 'disable-web-security',+ 'disable-headless',+ 'dark-mode',+ 'gl',+ 'enable-multiprocess-on-linux',+ 'user-agent',+ 'media-cache-size-in-bytes',+ 'offthreadvideo-cache-size-in-bytes',+ 'offthreadvideo-video-threads',+ 'delete-after',+ 'force-path-style',+ 'storage-class',+ 'license-key',+ 'binaries-directory',+ 'quiet',+ ]),+ },+ {+ path: [COMPOSITIONS_COMMAND],+ args: ' <serve-url>',+ description: 'Print composition IDs from a serve URL.',+ documentation: 'https://www.remotion.dev/docs/lambda/cli/compositions',+ options: options([+ 'region',+ 'function-name',+ 'props',+ 'config',+ 'env-file',+ 'log',+ 'timeout',+ 'ignore-certificate-errors',+ 'disable-web-security',+ 'dark-mode',+ 'disable-headless',+ 'gl',+ 'enable-multiprocess-on-linux',+ 'quiet',+ 'force-bucket-name',+ 'user-agent',+ ]),+ },+ {+ path: [FUNCTIONS_COMMAND],+ args: ' <command>',+ description: 'Deploy and manage AWS Lambda functions.',+ documentation: 'https://www.remotion.dev/docs/lambda/cli/functions',+ options: [],+ },+ {+ path: [FUNCTIONS_COMMAND, 'deploy'],+ args: '',+ description: 'Deploy a Lambda function.',+ documentation: 'https://www.remotion.dev/docs/lambda/cli/functions/deploy',+ options: options([+ 'region',+ 'memory',+ 'disk',+ 'function-timeout',+ 'disable-cloudwatch',+ 'retention-period',+ 'enable-lambda-insights',+ 'custom-role-arn',+ 'custom-layer-arns',+ 'quiet',+ 'vpc-subnet-ids',+ 'vpc-security-group-ids',+ 'runtime-preference',+ ]),+ },+ {+ path: [FUNCTIONS_COMMAND, 'ls'],+ args: '',+ description: 'List deployed Lambda functions.',+ documentation: 'https://www.remotion.dev/docs/lambda/cli/functions/ls',+ options: options(['compatible-only', 'region', 'quiet']),+ },+ {+ path: [FUNCTIONS_COMMAND, 'rm'],+ args: ' <function-name...>',+ description: 'Delete one or more Lambda functions.',+ documentation: 'https://www.remotion.dev/docs/lambda/cli/functions/rm',+ options: options(['region', '--yes', '--force', 'quiet']),+ },+ {+ path: [FUNCTIONS_COMMAND, 'rmall'],+ args: '',+ description: 'Delete all Lambda functions.',+ documentation: 'https://www.remotion.dev/docs/lambda/cli/functions/rmall',+ options: options(['region', '--yes', '--force', 'quiet']),+ },+ {+ path: [SITES_COMMAND],+ args: ' <command>',+ description: 'Deploy and manage Remotion projects.',+ documentation: 'https://www.remotion.dev/docs/lambda/cli/sites',+ options: [],+ },+ {+ path: [SITES_COMMAND, 'create'],+ args: ' [<entry-point>]',+ description: 'Deploy a Remotion project.',+ documentation: 'https://www.remotion.dev/docs/lambda/cli/sites/create',+ options: options([+ 'region',+ 'site-name',+ 'force-bucket-name',+ 'site-privacy',+ 'public-dir',+ 'enable-folder-expiry',+ 'throw-if-site-exists',+ 'disable-git-source',+ 'force-path-style',+ 'bundle-cache',+ 'rspack',+ 'disable-ask-ai',+ 'disable-keyboard-shortcuts',+ 'quiet',+ ]),+ },+ {+ path: [SITES_COMMAND, 'ls'],+ args: '',+ description: 'List deployed Remotion projects.',+ documentation: 'https://www.remotion.dev/docs/lambda/cli/sites/ls',+ options: options(['region', 'quiet', 'compatible-only']),+ },+ {+ path: [SITES_COMMAND, 'rm'],+ args: ' <site-id...>',+ description: 'Delete one or more Remotion projects.',+ documentation: 'https://www.remotion.dev/docs/lambda/cli/sites/rm',+ options: options(['region', '--yes', '--force', 'force-bucket-name']),+ },+ {+ path: [SITES_COMMAND, 'rmall'],+ args: '',+ description: 'Delete all Remotion projects.',+ documentation: 'https://www.remotion.dev/docs/lambda/cli/sites/rmall',+ options: options(['region', '--yes', '--force', 'force-bucket-name']),+ },+ {+ path: [POLICIES_COMMAND],+ args: ' <role | user | validate>',+ description: 'View and validate AWS policy files.',+ documentation: 'https://www.remotion.dev/docs/lambda/cli/policies',+ options: [],+ },+ {+ path: [POLICIES_COMMAND, 'role'],+ args: '',+ description: 'Print the required AWS role policy.',+ documentation: 'https://www.remotion.dev/docs/lambda/cli/policies',+ options: options(['region']),+ },+ {+ path: [POLICIES_COMMAND, 'user'],+ args: '',+ description: 'Print the required AWS user policy.',+ documentation: 'https://www.remotion.dev/docs/lambda/cli/policies',+ options: options(['region']),+ },+ {+ path: [POLICIES_COMMAND, 'validate'],+ args: '',+ description: 'Validate the current AWS policies.',+ documentation: 'https://www.remotion.dev/docs/lambda/cli/policies',+ options: options(['region']),+ },+ {+ path: [REGIONS_COMMAND],+ args: '',+ description: 'Show the supported AWS regions.',+ documentation: 'https://www.remotion.dev/docs/lambda/cli/regions',+ options: options(['default-only']),+ },+ {+ path: [QUOTAS_COMMAND],+ args: '',+ description: 'Show the AWS service quotas.',+ documentation: 'https://www.remotion.dev/docs/lambda/cli/quotas',+ options: options(['region']),+ },+ {+ path: [QUOTAS_COMMAND, 'increase'],+ args: '',+ description: 'Request an increase to the AWS service quotas.',+ documentation: 'https://www.remotion.dev/docs/lambda/cli/quotas',+ options: options(['region', '--yes', '--force']),+ },+] satisfies Parameters<typeof CliInternals.getCommandHelp>[0]['commands'];- Log.info({indent: false, logLevel});- Log.info({indent: false, logLevel}, `${BINARY_NAME} ${POLICIES_COMMAND}`);- Log.info(- {indent: false, logLevel},- CliInternals.chalk.gray('View and validate AWS policy files.'),- );+export const getLambdaHelp = (selectedPath: readonly string[]) => {+ return CliInternals.getCommandHelp({+ binaryName: BINARY_NAME,+ commands: commandHelp,+ selectedPath,+ rootDocumentation: 'https://www.remotion.dev/docs/lambda/cli',+ });+};- Log.info({indent: false, logLevel});- Log.info({indent: false, logLevel}, `${BINARY_NAME} ${REGIONS_COMMAND}`);+export const printHelp: PrintHelp = (selectedPath, logLevel) => {Log.info({indent: false, logLevel},- CliInternals.chalk.gray('Show the list of AWS regions supported.'),+ `${BINARY_NAME} ${+ packagejson.version+ } © ${new Date().getFullYear()} The Remotion developers`,);- Log.info({indent: false, logLevel});- Log.info({indent: false, logLevel}, `${BINARY_NAME} ${QUOTAS_COMMAND}`);- Log.info(- {indent: false, logLevel},- CliInternals.chalk.gray('Shows AWS quotas and allows to increase them.'),- );+ for (const line of getLambdaHelp(selectedPath)) {+ Log.info({indent: false, logLevel}, line);+ }};diff --git a/packages/lambda/src/cli/index.ts b/packages/lambda/src/cli/index.tsindex 072f5a0664..109c8fb286 100644--- a/packages/lambda/src/cli/index.ts+++ b/packages/lambda/src/cli/index.ts@@ -60,7 +60,7 @@ const matchCommand = ({fullClientSpecifics: FullClientSpecifics<AwsProvider>;}) => {if (parsedLambdaCli.help || args.length === 0) {- printHelp(logLevel);+ printHelp(args, logLevel);quit(0);}@@ -169,7 +169,7 @@ const matchCommand = ({}Log.error({indent: false, logLevel}, `Command ${args[0]} not found.`);- printHelp(logLevel);+ printHelp(args, logLevel);quit(1);};diff --git a/packages/lambda/src/internals.ts b/packages/lambda/src/internals.tsindex df569da341..13ecbf47c9 100644--- a/packages/lambda/src/internals.ts+++ b/packages/lambda/src/internals.ts@@ -13,6 +13,7 @@ import type {InternalDeploySiteInput,} from './api/deploy-site';import {internalDeploySite} from './api/deploy-site';+import type {PrintHelp} from './cli/help';import {executeCommand} from './cli/index';import {getLayers} from './shared/get-layers';import type {AwsLayer} from './shared/hosted-layers';@@ -25,6 +26,7 @@ export const LambdaInternals: {providerSpecifics: ProviderSpecifics<AwsProvider> | null,fullClientSpecifics: FullClientSpecifics<AwsProvider> | null,) => Promise<void>;+ printHelp: (selectedPath: readonly string[], logLevel: LogLevel) => void;internalDeploySite: (input: InternalDeploySiteInput) => DeploySiteOutput;getLayers: (options: {option: RuntimePreference;@@ -32,6 +34,10 @@ export const LambdaInternals: {}) => AwsLayer[];} = {executeCommand,+ printHelp: (selectedPath, logLevel) => {+ const {printHelp} = require('./cli/help') as {printHelp: PrintHelp};+ printHelp(selectedPath, logLevel);+ },internalDeploySite,getLayers,};diff --git a/packages/lambda/src/test/unit/cli-help.test.ts b/packages/lambda/src/test/unit/cli-help.test.tsnew file mode 100644index 0000000000..c5da80bd1a--- /dev/null+++ b/packages/lambda/src/test/unit/cli-help.test.ts@@ -0,0 +1,211 @@+import {expect, test} from 'bun:test';+import {spawnSync} from 'node:child_process';+import {mkdtempSync, readdirSync, rmSync, writeFileSync} from 'node:fs';+import path from 'node:path';+import {getLambdaHelp} from '../../cli/help';++const commandHelpPages = [+ {args: [], documentation: '/docs/lambda/cli', option: null},+ {+ args: ['render'],+ documentation: '/docs/lambda/cli/render',+ option: '--region',+ },+ {args: ['still'], documentation: '/docs/lambda/cli/still', option: '--frame'},+ {+ args: ['compositions'],+ documentation: '/docs/lambda/cli/compositions',+ option: '--props',+ },+ {+ args: ['functions'],+ documentation: '/docs/lambda/cli/functions',+ option: null,+ },+ {+ args: ['functions', 'deploy'],+ documentation: '/docs/lambda/cli/functions/deploy',+ option: '--memory',+ },+ {+ args: ['functions', 'ls'],+ documentation: '/docs/lambda/cli/functions/ls',+ option: '--compatible-only',+ },+ {+ args: ['functions', 'rm'],+ documentation: '/docs/lambda/cli/functions/rm',+ option: '--yes',+ },+ {+ args: ['functions', 'rmall'],+ documentation: '/docs/lambda/cli/functions/rmall',+ option: '--yes',+ },+ {args: ['sites'], documentation: '/docs/lambda/cli/sites', option: null},+ {+ args: ['sites', 'create'],+ documentation: '/docs/lambda/cli/sites/create',+ option: '--site-name',+ },+ {+ args: ['sites', 'ls'],+ documentation: '/docs/lambda/cli/sites/ls',+ option: '--compatible-only',+ },+ {+ args: ['sites', 'rm'],+ documentation: '/docs/lambda/cli/sites/rm',+ option: '--yes',+ },+ {+ args: ['sites', 'rmall'],+ documentation: '/docs/lambda/cli/sites/rmall',+ option: '--yes',+ },+ {+ args: ['policies'],+ documentation: '/docs/lambda/cli/policies',+ option: null,+ },+ {+ args: ['policies', 'role'],+ documentation: '/docs/lambda/cli/policies',+ option: null,+ },+ {+ args: ['policies', 'user'],+ documentation: '/docs/lambda/cli/policies',+ option: null,+ },+ {+ args: ['policies', 'validate'],+ documentation: '/docs/lambda/cli/policies',+ option: null,+ },+ {+ args: ['regions'],+ documentation: '/docs/lambda/cli/regions',+ option: '--default-only',+ },+ {+ args: ['quotas'],+ documentation: '/docs/lambda/cli/quotas',+ option: '--region',+ },+ {+ args: ['quotas', 'increase'],+ documentation: '/docs/lambda/cli/quotas',+ option: '--force',+ },+] as const;++test('defines help for every Lambda command', () => {+ for (const {args, documentation, option} of commandHelpPages) {+ const lines = getLambdaHelp(args);+ const output = lines.join('\n');+ const command = `remotion lambda${args.length === 0 ? '' : ` ${args.join(' ')}`}`;++ expect(output).toContain(command);+ expect(output).toContain(`https://www.remotion.dev${documentation}`);+ expect(output).toContain('Options:');+ const helpLine = lines.find((line) => line.includes('--help'));+ expect(helpLine).toContain('Show this help.');++ if (option) {+ const optionLine = lines.find((line) => line.includes(option));+ expect(optionLine).toBeDefined();+ expect(optionLine?.length).toBeGreaterThan(option.length + 2);+ }+ }++ const renderHelp = getLambdaHelp(['render']).join('\n');+ expect(renderHelp).toContain('--buffer-size <value>');+ expect(renderHelp).toContain('--enable-multiprocess-on-linux');++ const stillHelp = getLambdaHelp(['still']).join('\n');+ expect(stillHelp).toContain('--function-name <name>');+ expect(stillHelp).toContain('--height <value>');++ const compositionsHelp = getLambdaHelp(['compositions']).join('\n');+ expect(compositionsHelp).toContain('--region <region>');+ expect(compositionsHelp).toContain('--function-name <name>');+ expect(compositionsHelp).not.toContain('--media-cache-size-in-bytes');+ expect(compositionsHelp).not.toContain('--offthreadvideo-video-threads');+ expect(compositionsHelp).not.toContain('--force-path-style');++ const deployFunctionHelp = getLambdaHelp(['functions', 'deploy']).join('\n');+ expect(deployFunctionHelp).toContain('--timeout <seconds>');+ expect(deployFunctionHelp).toContain(+ '--runtime-preference <default|apple-emojis|cjk>',+ );++ const removeFunctionHelp = getLambdaHelp(['functions', 'rm']).join('\n');+ expect(removeFunctionHelp).toContain('--force, -f');++ const createSiteHelp = getLambdaHelp(['sites', 'create']).join('\n');+ expect(createSiteHelp).toContain('--privacy <public|no-acl>');+ expect(createSiteHelp).not.toContain('public|private|no-acl');++ const listSitesHelp = getLambdaHelp(['sites', 'ls']).join('\n');+ expect(listSitesHelp).not.toContain('--force-path-style');++ const policyHelp = getLambdaHelp(['policies', 'validate']).join('\n');+ expect(policyHelp).toContain('--region <region>');+});++test('the Remotion CLI delegates Lambda help before loading config', () => {+ const exampleDirectory = path.join(+ __dirname,+ '..',+ '..',+ '..',+ '..',+ 'example',+ );+ const temporaryDirectory = mkdtempSync(+ path.join(exampleDirectory, '.tmp-lambda-cli-help-'),+ );+ writeFileSync(path.join(temporaryDirectory, 'package.json'), '{}\n');+ writeFileSync(+ path.join(temporaryDirectory, 'remotion.config.ts'),+ `throw new Error('The config file must not be loaded for --help');\n`,+ );+ const initialFiles = readdirSync(temporaryDirectory);++ try {+ const result = spawnSync(+ 'node',+ [+ path.join(exampleDirectory, '..', 'cli', 'remotion-cli.js'),+ 'lambda',+ 'render',+ '--help',+ '--log=error',+ ],+ {+ cwd: temporaryDirectory,+ encoding: 'utf8',+ env: {...process.env, NO_COLOR: '1'},+ stdio: ['ignore', 'pipe', 'pipe'],+ timeout: 10_000,+ },+ );++ if (result.error) {+ throw result.error;+ }++ expect(result.signal).toBeNull();+ expect(result.status).toBe(0);+ expect(result.stderr).toBe('');+ expect(result.stdout).toContain('remotion lambda render');+ expect(result.stdout).toContain('--frames-per-lambda <count>');+ expect(result.stdout).toContain(+ 'https://www.remotion.dev/docs/lambda/cli/render',+ );+ expect(readdirSync(temporaryDirectory)).toEqual(initialFiles);+ } finally {+ rmSync(temporaryDirectory, {recursive: true, force: true});+ }+}, 15_000);