199 lines
9.2 KiB
JavaScript
199 lines
9.2 KiB
JavaScript
"use strict";
|
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.CliInternals = exports.cli = void 0;
|
|
const renderer_1 = require("@remotion/renderer");
|
|
const studio_server_1 = require("@remotion/studio-server");
|
|
const minimist_1 = __importDefault(require("minimist"));
|
|
const add_1 = require("./add");
|
|
const benchmark_1 = require("./benchmark");
|
|
const browser_1 = require("./browser");
|
|
const browser_download_bar_1 = require("./browser-download-bar");
|
|
const bundle_1 = require("./bundle");
|
|
const chalk_1 = require("./chalk");
|
|
const check_for_npm_run_flag_pass_1 = require("./check-for-npm-run-flag-pass");
|
|
const cleanup_before_quit_1 = require("./cleanup-before-quit");
|
|
const cloudrun_command_1 = require("./cloudrun-command");
|
|
const compositions_1 = require("./compositions");
|
|
const determine_image_format_1 = require("./determine-image-format");
|
|
const download_progress_1 = require("./download-progress");
|
|
const entry_point_1 = require("./entry-point");
|
|
const ffmpeg_1 = require("./ffmpeg");
|
|
const get_cli_options_1 = require("./get-cli-options");
|
|
const get_composition_with_dimension_override_1 = require("./get-composition-with-dimension-override");
|
|
const get_config_file_name_1 = require("./get-config-file-name");
|
|
const get_github_repository_1 = require("./get-github-repository");
|
|
const gpu_1 = require("./gpu");
|
|
const is_supported_1 = require("./hyperlinks/is-supported");
|
|
const make_link_1 = require("./hyperlinks/make-link");
|
|
const image_formats_1 = require("./image-formats");
|
|
const initialize_cli_1 = require("./initialize-cli");
|
|
const lambda_command_1 = require("./lambda-command");
|
|
const list_of_remotion_packages_1 = require("./list-of-remotion-packages");
|
|
const log_1 = require("./log");
|
|
const make_progress_bar_1 = require("./make-progress-bar");
|
|
const parsed_cli_1 = require("./parsed-cli");
|
|
const print_compositions_1 = require("./print-compositions");
|
|
const print_error_1 = require("./print-error");
|
|
const print_help_1 = require("./print-help");
|
|
const progress_bar_1 = require("./progress-bar");
|
|
const render_1 = require("./render");
|
|
const should_use_non_overlaying_logger_1 = require("./should-use-non-overlaying-logger");
|
|
const skills_1 = require("./skills");
|
|
const still_1 = require("./still");
|
|
const studio_1 = require("./studio");
|
|
const upgrade_1 = require("./upgrade");
|
|
const versions_1 = require("./versions");
|
|
const cli = async () => {
|
|
const [command, ...args] = parsed_cli_1.parsedCli._;
|
|
const remotionRoot = renderer_1.RenderInternals.findRemotionRoot();
|
|
if (command !== versions_1.VERSIONS_COMMAND && !parsed_cli_1.parsedCli.help) {
|
|
await (0, versions_1.validateVersionsBeforeCommand)(remotionRoot, 'info');
|
|
}
|
|
const logLevel = await (0, initialize_cli_1.initializeCli)(remotionRoot);
|
|
const isBun = typeof Bun !== 'undefined';
|
|
if (isBun) {
|
|
const version = Bun.version.split('.');
|
|
if (version.length === 3) {
|
|
if (Number(version[0]) < 1) {
|
|
throw new Error('Please upgrade to at least Bun 1.0.3');
|
|
}
|
|
if (Number(version[1]) === 0 && Number(version[2]) < 3) {
|
|
throw new Error('Please upgrade to at least Bun 1.0.3');
|
|
}
|
|
}
|
|
log_1.Log.info({ indent: false, logLevel }, 'You are running Remotion with Bun, which is mostly supported. Visit https://remotion.dev/bun for more information.');
|
|
}
|
|
const isStudio = command === 'studio' || command === 'preview';
|
|
const errorSymbolicationLock = isStudio
|
|
? 0
|
|
: renderer_1.RenderInternals.registerErrorSymbolicationLock();
|
|
(0, cleanup_before_quit_1.handleCtrlC)({ indent: false, logLevel });
|
|
(0, check_for_npm_run_flag_pass_1.checkForNpmRunFlagPass)({ indent: false, logLevel });
|
|
try {
|
|
if (command === 'bundle') {
|
|
await (0, bundle_1.bundleCommand)(remotionRoot, args, logLevel);
|
|
}
|
|
else if (command === 'compositions') {
|
|
await (0, compositions_1.listCompositionsCommand)(remotionRoot, args, logLevel);
|
|
}
|
|
else if (isStudio) {
|
|
await (0, studio_1.studioCommand)(remotionRoot, args, logLevel);
|
|
}
|
|
else if (command === 'lambda') {
|
|
await (0, lambda_command_1.lambdaCommand)(remotionRoot, args, logLevel);
|
|
}
|
|
else if (command === 'cloudrun') {
|
|
await (0, cloudrun_command_1.cloudrunCommand)(remotionRoot, args, logLevel);
|
|
}
|
|
else if (command === 'render') {
|
|
await (0, render_1.render)(remotionRoot, args, logLevel);
|
|
}
|
|
else if (command === 'still') {
|
|
await (0, still_1.still)(remotionRoot, args, logLevel);
|
|
}
|
|
else if (command === 'ffmpeg') {
|
|
(0, ffmpeg_1.ffmpegCommand)(process.argv.slice(3), logLevel);
|
|
}
|
|
else if (command === 'gpu') {
|
|
await (0, gpu_1.gpuCommand)(logLevel);
|
|
}
|
|
else if (command === 'ffprobe') {
|
|
(0, ffmpeg_1.ffprobeCommand)(process.argv.slice(3), logLevel);
|
|
}
|
|
else if (command === 'upgrade') {
|
|
await (0, upgrade_1.upgradeCommand)({
|
|
remotionRoot,
|
|
packageManager: parsed_cli_1.parsedCli['package-manager'],
|
|
version: parsed_cli_1.parsedCli.version,
|
|
logLevel,
|
|
args,
|
|
});
|
|
}
|
|
else if (command === 'add') {
|
|
if (args.length === 0) {
|
|
throw new Error('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 (0, add_1.addCommand)({
|
|
remotionRoot,
|
|
packageManager: parsed_cli_1.parsedCli['package-manager'],
|
|
packageNames,
|
|
logLevel,
|
|
args: additionalArgs,
|
|
});
|
|
}
|
|
else if (command === 'skills') {
|
|
await (0, skills_1.skillsCommand)(args, logLevel);
|
|
}
|
|
else if (command === versions_1.VERSIONS_COMMAND) {
|
|
await (0, versions_1.versionsCommand)(remotionRoot, logLevel);
|
|
}
|
|
else if (command === browser_1.BROWSER_COMMAND) {
|
|
await (0, browser_1.browserCommand)(args, logLevel);
|
|
}
|
|
else if (command === 'benchmark') {
|
|
await (0, benchmark_1.benchmarkCommand)(remotionRoot, args, logLevel);
|
|
}
|
|
else if (command === 'help') {
|
|
(0, print_help_1.printHelp)(logLevel);
|
|
process.exit(0);
|
|
}
|
|
else if (parsed_cli_1.parsedCli.help) {
|
|
(0, print_help_1.printHelp)(logLevel);
|
|
}
|
|
else {
|
|
if (command) {
|
|
log_1.Log.error({ indent: false, logLevel }, `Command ${command} not found.`);
|
|
}
|
|
(0, print_help_1.printHelp)(logLevel);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
catch (err) {
|
|
log_1.Log.info({ indent: false, logLevel });
|
|
await (0, print_error_1.printError)(err, logLevel);
|
|
(0, cleanup_before_quit_1.cleanupBeforeQuit)({ indent: false, logLevel });
|
|
process.exit(1);
|
|
}
|
|
finally {
|
|
renderer_1.RenderInternals.unlockErrorSymbolicationLock(errorSymbolicationLock);
|
|
(0, cleanup_before_quit_1.cleanupBeforeQuit)({ indent: false, logLevel });
|
|
}
|
|
};
|
|
exports.cli = cli;
|
|
exports.CliInternals = {
|
|
createOverwriteableCliOutput: progress_bar_1.createOverwriteableCliOutput,
|
|
chalk: chalk_1.chalk,
|
|
makeProgressBar: make_progress_bar_1.makeProgressBar,
|
|
Log: log_1.Log,
|
|
getCliOptions: get_cli_options_1.getCliOptions,
|
|
loadConfig: get_config_file_name_1.loadConfig,
|
|
formatBytes: studio_server_1.StudioServerInternals.formatBytes,
|
|
initializeCli: initialize_cli_1.initializeCli,
|
|
BooleanFlags: parsed_cli_1.BooleanFlags,
|
|
quietFlagProvided: parsed_cli_1.quietFlagProvided,
|
|
parsedCli: parsed_cli_1.parsedCli,
|
|
printError: print_error_1.printError,
|
|
getFileSizeDownloadBar: download_progress_1.getFileSizeDownloadBar,
|
|
determineFinalStillImageFormat: determine_image_format_1.determineFinalStillImageFormat,
|
|
minimist: minimist_1.default,
|
|
findEntryPoint: entry_point_1.findEntryPoint,
|
|
getVideoImageFormat: image_formats_1.getVideoImageFormat,
|
|
printCompositions: print_compositions_1.printCompositions,
|
|
listOfRemotionPackages: list_of_remotion_packages_1.listOfRemotionPackages,
|
|
shouldUseNonOverlayingLogger: should_use_non_overlaying_logger_1.shouldUseNonOverlayingLogger,
|
|
getCompositionWithDimensionOverride: get_composition_with_dimension_override_1.getCompositionWithDimensionOverride,
|
|
defaultBrowserDownloadProgress: browser_download_bar_1.defaultBrowserDownloadProgress,
|
|
LABEL_WIDTH: progress_bar_1.LABEL_WIDTH,
|
|
printFact: progress_bar_1.printFact,
|
|
makeHyperlink: make_link_1.makeHyperlink,
|
|
supportsHyperlink: is_supported_1.supportsHyperlink,
|
|
getGitSource: get_github_repository_1.getGitSource,
|
|
};
|