diff --git a/src/__tests__/cli-argv.test.ts b/src/__tests__/cli-argv.test.ts index 63f56a7d31..1d914b0cda 100644 --- a/src/__tests__/cli-argv.test.ts +++ b/src/__tests__/cli-argv.test.ts @@ -270,4 +270,50 @@ describe('CLI argv parsing', () => { expect(result.stderr).not.toContain('unknown command'); } ); + + testWithBuiltCli( + 'warns on stderr that browser is deprecated, for the command and its subcommands', + () => { + const offline = [ + '--api-key', + 'fc-test', + '--api-url', + 'http://127.0.0.1:9', + ]; + for (const [args, status] of [ + [['browser', ...offline], 0], + [['browser', 'list', ...offline], 1], + ] as const) { + const result = spawnSync(process.execPath, [cliPath, ...args], { + encoding: 'utf8', + env: { ...process.env, FIRECRAWL_NO_UPDATE_CHECK: '1' }, + }); + expect(result.status).toBe(status); + expect(result.stderr).toContain( + '`firecrawl browser` is deprecated and will be removed' + ); + expect(result.stderr).toContain('firecrawl interact'); + expect(result.stdout).not.toContain('deprecated and will be removed'); + } + } + ); + + testWithBuiltCli( + 'shows the browser deprecation warning in browser help and subcommand help', + () => { + for (const args of [ + ['browser', '--help'], + ['browser', 'list', '--help'], + ]) { + const result = spawnSync(process.execPath, [cliPath, ...args], { + encoding: 'utf8', + env: { ...process.env, FIRECRAWL_NO_UPDATE_CHECK: '1' }, + }); + expect(result.status).toBe(0); + expect(result.stdout).toContain( + '`firecrawl browser` is deprecated and will be removed' + ); + } + } + ); }); diff --git a/src/index.ts b/src/index.ts index 64fd32b03a..1271d2f226 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2229,6 +2229,8 @@ function createAgentCommand(): Command { * Create and configure the browser command (deprecated — prefer scrape + interact) */ function createBrowserCommand(): Command { + const deprecationWarning = + 'Warning: `firecrawl browser` is deprecated and will be removed in a future release. Use `firecrawl scrape `, then `firecrawl interact ""` or `firecrawl interact -c ""`. See `firecrawl interact --help`.'; const browserCmd = new Command('browser') .description( '[Deprecated: prefer scrape + interact] Launch cloud browser sessions and execute code remotely via Playwright' @@ -2249,6 +2251,10 @@ function createBrowserCommand(): Command { ) .option('-o, --output ', 'Output file path (default: stdout)') .option('--json', 'Output as JSON format', false) + .hook('preAction', () => { + process.stderr.write(`${deprecationWarning}\n`); + }) + .addHelpText('beforeAll', `${deprecationWarning}\n`) .action(async (code, options) => { if (code) { await handleBrowserQuickExecute({