🎥 Make videos programmatically with React
`create-video`: Add help output (#8988)
Jonny Burger71e01360fb0b
diff --git a/packages/create-video/src/help.ts b/packages/create-video/src/help.tsnew file mode 100644index 0000000000..c8b3ac26a7--- /dev/null+++ b/packages/create-video/src/help.ts@@ -0,0 +1,56 @@+import {FEATURED_TEMPLATES} from './templates';++const formatOption = ({+ flag,+ description,+}: {+ flag: string;+ description: string;+}) => {+ return ` ${flag.padEnd(18)}${description}`;+};++const formatTemplateFlags = () => {+ return FEATURED_TEMPLATES.map((template) => ` --${template.cliId}`).join(+ '\n',+ );+};++export const getCreateVideoHelp = () => {+ return [+ 'create-video',+ '',+ 'Scaffold a new Remotion project.',+ '',+ 'Usage:',+ ' npx create-video --yes --blank my-video',+ ' npx create-video [options] [directory]',+ '',+ 'Arguments:',+ ' directory Directory in which the project should be created.',+ '',+ 'Options:',+ formatOption({+ flag: '--yes, -y',+ description:+ 'Enable non-interactive mode. Requires a template flag and a directory, unless --tmp is used.',+ }),+ formatOption({+ flag: '--no-tailwind',+ description: 'Skip installing TailwindCSS when used with --yes.',+ }),+ formatOption({+ flag: '--tmp',+ description: 'Create the project in a temporary directory.',+ }),+ formatOption({+ flag: '--help, -h',+ description: 'Show this help.',+ }),+ '',+ 'Template flags:',+ formatTemplateFlags(),+ '',+ 'Full documentation: https://www.remotion.dev/docs/cli/create-video',+ ].join('\n');+};diff --git a/packages/create-video/src/init.ts b/packages/create-video/src/init.tsindex 260ba71f3f..d0d1984c05 100644--- a/packages/create-video/src/init.ts+++ b/packages/create-video/src/init.ts@@ -7,6 +7,7 @@ import {askSkills} from './ask-skills';import {askTailwind} from './ask-tailwind';import {createPublicFolder} from './create-public-folder';import {degit} from './degit';+import {getCreateVideoHelp} from './help';import {makeHyperlink} from './hyperlinks/make-link';import {installSkills} from './install-skills';import {getLatestRemotionVersion} from './latest-remotion-version';@@ -25,6 +26,7 @@ import prompts from './prompts';import {resolveProjectRoot} from './resolve-project-root';import {getDirectoryArgument,+ isHelpFlagSelected,isNoTailwindFlagSelected,isTmpFlagSelected,isYesFlagSelected,@@ -86,6 +88,11 @@ const getGitStatus = async (root: string): Promise<void> => {};export const init = async () => {+ if (isHelpFlagSelected()) {+ Log.info(getCreateVideoHelp());+ return;+ }+Log.info(`Welcome to ${chalk.blue('Remotion')}!`);// Get directory argument if provideddiff --git a/packages/create-video/src/select-template.ts b/packages/create-video/src/select-template.tsindex 5b29532d16..a4dfcbeaae 100644--- a/packages/create-video/src/select-template.ts+++ b/packages/create-video/src/select-template.ts@@ -11,12 +11,19 @@ type Options = {tmp: boolean;yes: boolean;'no-tailwind': boolean;+ help: boolean;};const parsed = minimist<Options>(process.argv.slice(2), {- boolean: [...ALL_TEMPLATES.map((f) => f.cliId), 'tmp', 'yes', 'no-tailwind'],+ boolean: [+ ...ALL_TEMPLATES.map((f) => f.cliId),+ 'tmp',+ 'yes',+ 'no-tailwind',+ 'help',+ ],string: ['_'],- alias: {y: 'yes'},+ alias: {y: 'yes', h: 'help'},});export const isTmpFlagSelected = () => parsed.tmp;@@ -25,6 +32,8 @@ export const isYesFlagSelected = () => parsed.yes;export const isNoTailwindFlagSelected = () => parsed['no-tailwind'];+export const isHelpFlagSelected = () => parsed.help;+export const getPositionalArguments = () => parsed._;export const getDirectoryArgument = (): string | null => {diff --git a/packages/create-video/src/test/help.test.ts b/packages/create-video/src/test/help.test.tsnew file mode 100644index 0000000000..401f572194--- /dev/null+++ b/packages/create-video/src/test/help.test.ts@@ -0,0 +1,19 @@+import {expect, test} from 'bun:test';+import {getCreateVideoHelp} from '../help';+import {FEATURED_TEMPLATES} from '../templates';++test('prints a concise help output for create-video', () => {+ const help = getCreateVideoHelp();++ expect(help).toContain('npx create-video --yes --blank my-video');+ expect(help).toContain('--yes, -y');+ expect(help).toContain('--no-tailwind');+ expect(help).toContain('--tmp');+ expect(help).toContain('--help, -h');+ expect(help).toContain('https://www.remotion.dev/docs/cli/create-video');+ expect(help).toContain('Template flags:\n --blank\n --hello-world');++ for (const template of FEATURED_TEMPLATES) {+ expect(help).toContain(`\n --${template.cliId}`);+ }+});diff --git a/packages/docs/docs/ai/coding-agents.mdx b/packages/docs/docs/ai/coding-agents.mdxindex 6c00aa4495..b0d3bb09e8 100644--- a/packages/docs/docs/ai/coding-agents.mdx+++ b/packages/docs/docs/ai/coding-agents.mdx@@ -22,14 +22,10 @@ Most coding agents require a paid subscription.Create a new project using the following command:```bash-npx create-video@latest+npx create-video --yes --blank my-video```-This will create a new project - we recommend the following settings:--- Select the [Blank](https://remotion.dev/templates/blank) template-- Say yes to use [TailwindCSS](/docs/tailwind)-- Say yes to install [Skills](/docs/ai/skills)+This creates a [Blank](https://remotion.dev/templates/blank) project in the `my-video` directory.## Start the previewdiff --git a/packages/docs/docs/cli/create-video.mdx b/packages/docs/docs/cli/create-video.mdxindex 36cf46972c..f59f1e335b 100644--- a/packages/docs/docs/cli/create-video.mdx+++ b/packages/docs/docs/cli/create-video.mdx@@ -10,7 +10,7 @@ import {CreateVideoTemplateFlags} from '../../components/CreateVideoTemplateFlagScaffold a new Remotion project.```bash-npx create-video <directory>+npx create-video --yes --blank my-video```If no arguments are passed, an interactive TUI will guide you through the setup.@@ -21,6 +21,12 @@ If no arguments are passed, an interactive TUI will guide you through the setup.The directory in which the project should be created.+The recommended starter command creates a blank project in the `my-video` directory:++```bash+npx create-video --yes --blank my-video+```+## Flags### `--yes`<AvailableFrom v="4.0.439" />@@ -59,6 +65,18 @@ Create the project in a temporary directory instead of specifying a directory nanpx create-video --yes --blank --tmp```+### `--help`<AvailableFrom v="4.0.488" />++Print a short overview of the arguments, flags and template flags.++```bash+npx create-video --help+```++### `-h`<AvailableFrom v="4.0.488" />++Alias for `--help`.+### Template flagsPass a template name as a flag to skip the template selection prompt.diff --git a/packages/docs/src/helpers/system-prompt.ts b/packages/docs/src/helpers/system-prompt.tsindex 7341c4cc37..eadf48c551 100644--- a/packages/docs/src/helpers/system-prompt.ts+++ b/packages/docs/src/helpers/system-prompt.ts@@ -9,7 +9,7 @@ It is based on React.js. All output should be valid React code and be written in# Project structureA Remotion Project consists of an entry file, a Root file and any number of React component files.-A project can be scaffolded using the "npx create-video@latest --blank" command.+A project can be scaffolded using the "npx create-video --yes --blank my-video" command.The entry file is usually named "src/index.ts" and looks like this:\`\`\`tsdiff --git a/packages/docs/static/llms.txt b/packages/docs/static/llms.txtindex 6330955a09..9cf9a7463a 100644--- a/packages/docs/static/llms.txt+++ b/packages/docs/static/llms.txt@@ -6,7 +6,7 @@ It is based on React.js. All output should be valid React code and be written in# Project structureA Remotion Project consists of an entry file, a Root file and any number of React component files.-A project can be scaffolded using the "npx create-video@latest --blank" command.+A project can be scaffolded using the "npx create-video --yes --blank my-video" command.The entry file is usually named "src/index.ts" and looks like this:```tsdiff --git a/packages/promo-pages/src/components/homepage/GetStartedStrip.tsx b/packages/promo-pages/src/components/homepage/GetStartedStrip.tsxindex 6c653969df..d2dc3b7624 100644--- a/packages/promo-pages/src/components/homepage/GetStartedStrip.tsx+++ b/packages/promo-pages/src/components/homepage/GetStartedStrip.tsx@@ -24,13 +24,15 @@ export const GetStarted: React.FC = () => {<ButtonclassName="bg-[#333] text-white rounded-lg px-4 font-mono hover:[#444] cursor-pointer w-full"onClick={() => {- navigator.clipboard.writeText('npx create-video@latest');+ navigator.clipboard.writeText(+ 'npx create-video --yes --blank my-video',+ );setClicked(Date.now());}}title="Click to copy">- $ npx create-video@latest+ $ npx create-video --yes --blank my-video</Button></div></div>