Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ firecrawl setup mcp
To make Firecrawl the default web provider for supported AI agents:

```bash
firecrawl setup defaults
firecrawl setup defaults # or: firecrawl make default
```

This disables native web fetch/search where supported so agents route web work
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "firecrawl-cli",
"version": "1.19.15",
"version": "1.19.16",
"description": "Command-line interface for Firecrawl. Scrape, crawl, and extract data from any website directly from your terminal.",
"main": "dist/index.js",
"bin": {
Expand Down
10 changes: 10 additions & 0 deletions src/__tests__/commands/setup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { mkdtempSync, readFileSync, rmSync } from 'fs';
import os from 'os';
import path from 'path';
import {
handleMakeDefaultCommand,
handleSetupCommand,
installHermesMcp,
installOpenClawMcp,
Expand Down Expand Up @@ -73,6 +74,15 @@ describe('handleSetupCommand', () => {
);
});

it('configures Firecrawl as the default web provider via make default', async () => {
await handleMakeDefaultCommand({ yes: true });

expect(configureWebDefaults).toHaveBeenCalledWith({
undo: false,
agents: undefined,
});
});

it('installs the default setup bundle with --yes', async () => {
await handleSetupCommand(undefined, { yes: true });

Expand Down
184 changes: 184 additions & 0 deletions src/__tests__/utils/update-notice.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
import fs from 'fs';
import os from 'os';
import path from 'path';
import packageJson from '../../../package.json';
import {
maybeShowUpdateNotice,
formatUpdateNotice,
type UpdateNoticeOptions,
} from '../../utils/update-notice';
import { getLatestVersion } from '../../utils/npm-registry';

vi.mock('../../utils/npm-registry', async () => {
const actual = await vi.importActual<
typeof import('../../utils/npm-registry')
>('../../utils/npm-registry');
return {
...actual,
getLatestVersion: vi.fn(),
};
});

describe('update notice', () => {
let tmpDir: string;
let originalNoUpdateCheck: string | undefined;
let write: ReturnType<typeof vi.fn>;

beforeEach(() => {
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'firecrawl-update-test-'));
originalNoUpdateCheck = process.env.FIRECRAWL_NO_UPDATE_CHECK;
delete process.env.FIRECRAWL_NO_UPDATE_CHECK;
vi.mocked(getLatestVersion).mockReset();
write = vi.fn();
});

afterEach(() => {
fs.rmSync(tmpDir, { recursive: true, force: true });
if (originalNoUpdateCheck === undefined) {
delete process.env.FIRECRAWL_NO_UPDATE_CHECK;
} else {
process.env.FIRECRAWL_NO_UPDATE_CHECK = originalNoUpdateCheck;
}
vi.restoreAllMocks();
});

function stderr(isTTY = true): UpdateNoticeOptions['stderr'] {
return { isTTY, write: write as unknown as NodeJS.WriteStream['write'] };
}

it('formats a bordered update notice', () => {
const notice = formatUpdateNotice('99.99.99');

expect(notice).toContain(
`✨ Update available! ${packageJson.version} -> 99.99.99`
);
expect(notice).toContain('Run npm install -g firecrawl-cli to update.');
expect(notice).toContain(
'https://github.com/firecrawl/cli/releases/latest'
);
expect(notice.startsWith('╭')).toBe(true);
expect(notice.endsWith('╯')).toBe(true);
});

it('does not check or print outside a TTY', async () => {
await maybeShowUpdateNotice({ cacheDir: tmpDir, stderr: stderr(false) });

expect(getLatestVersion).not.toHaveBeenCalled();
expect(write).not.toHaveBeenCalled();
});

it('prints a cached newer version', async () => {
fs.writeFileSync(
path.join(tmpDir, 'update-check.json'),
JSON.stringify({
latestVersion: '99.99.99',
checkedAt: new Date('2026-06-04T12:00:00.000Z').toISOString(),
})
);

await maybeShowUpdateNotice({
cacheDir: tmpDir,
now: new Date('2026-06-04T13:00:00.000Z'),
stderr: stderr(),
});

expect(getLatestVersion).not.toHaveBeenCalled();
// The notice colorizes "Update available!" with ANSI codes on a TTY, so
// assert on the (uncolorized) version portion that survives formatting.
expect(write).toHaveBeenCalledWith(
expect.stringContaining(`${packageJson.version} -> 99.99.99`)
);
});

it('does not print the same update twice within 12 hours', async () => {
fs.writeFileSync(
path.join(tmpDir, 'update-check.json'),
JSON.stringify({
latestVersion: '99.99.99',
checkedAt: new Date('2026-06-04T12:00:00.000Z').toISOString(),
lastShownVersion: '99.99.99',
lastShownAt: new Date('2026-06-04T12:30:00.000Z').toISOString(),
})
);

await maybeShowUpdateNotice({
cacheDir: tmpDir,
now: new Date('2026-06-04T13:00:00.000Z'),
stderr: stderr(),
});

expect(getLatestVersion).not.toHaveBeenCalled();
expect(write).not.toHaveBeenCalled();
});

it('prints the same update again after 12 hours', async () => {
fs.writeFileSync(
path.join(tmpDir, 'update-check.json'),
JSON.stringify({
latestVersion: '99.99.99',
checkedAt: new Date('2026-06-04T12:00:00.000Z').toISOString(),
lastShownVersion: '99.99.99',
lastShownAt: new Date('2026-06-04T00:00:00.000Z').toISOString(),
})
);

await maybeShowUpdateNotice({
cacheDir: tmpDir,
now: new Date('2026-06-04T13:00:00.000Z'),
stderr: stderr(),
});

expect(write).toHaveBeenCalledWith(expect.stringContaining('99.99.99'));
});

it('prints a different newer version even inside the cooldown', async () => {
fs.writeFileSync(
path.join(tmpDir, 'update-check.json'),
JSON.stringify({
latestVersion: '100.0.0',
checkedAt: new Date('2026-06-04T12:00:00.000Z').toISOString(),
lastShownVersion: '99.99.99',
lastShownAt: new Date('2026-06-04T12:30:00.000Z').toISOString(),
})
);

await maybeShowUpdateNotice({
cacheDir: tmpDir,
now: new Date('2026-06-04T13:00:00.000Z'),
stderr: stderr(),
});

expect(write).toHaveBeenCalledWith(expect.stringContaining('100.0.0'));
});

it('refreshes a stale cache from npm', async () => {
vi.mocked(getLatestVersion).mockResolvedValue({
version: '99.99.99',
unreachable: false,
});

await maybeShowUpdateNotice({
cacheDir: tmpDir,
now: new Date('2026-06-04T13:00:00.000Z'),
stderr: stderr(),
});

expect(getLatestVersion).toHaveBeenCalledWith('firecrawl-cli', 750);
expect(write).toHaveBeenCalledWith(expect.stringContaining('99.99.99'));

const cached = JSON.parse(
fs.readFileSync(path.join(tmpDir, 'update-check.json'), 'utf-8')
);
expect(cached.latestVersion).toBe('99.99.99');
});

it('respects FIRECRAWL_NO_UPDATE_CHECK', async () => {
process.env.FIRECRAWL_NO_UPDATE_CHECK = '1';

await maybeShowUpdateNotice({ cacheDir: tmpDir, stderr: stderr() });

expect(getLatestVersion).not.toHaveBeenCalled();
expect(write).not.toHaveBeenCalled();
});
});
3 changes: 3 additions & 0 deletions src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@ function printNextSteps(
` ${arrow} ${dim}Default web:${reset} ${bold}firecrawl setup defaults${reset}`
);
}
console.log(
` ${arrow} ${dim}Make default:${reset} ${bold}firecrawl make default${reset}`
);
console.log(
` ${arrow} ${dim}All commands:${reset} ${bold}firecrawl --help${reset}`
);
Expand Down
26 changes: 25 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ import {
findTemplate,
stepAuth,
} from './commands/init';
import { handleSetupCommand } from './commands/setup';
import { handleMakeDefaultCommand, handleSetupCommand } from './commands/setup';
import type { SetupSubcommand } from './commands/setup';
import { handleEnvPullCommand } from './commands/env';
import { handleStatusCommand } from './commands/status';
Expand All @@ -66,6 +66,7 @@ import { isUrl, normalizeUrl } from './utils/url';
import { parseScrapeOptions } from './utils/options';
import { isJobId } from './utils/job';
import { ensureAuthenticated, printBanner } from './utils/auth';
import { maybeShowUpdateNotice } from './utils/update-notice';
import packageJson from '../package.json';
import type { SearchSource, SearchCategory } from './types/search';
import type { ScrapeFormat } from './types/scrape';
Expand Down Expand Up @@ -2194,6 +2195,27 @@ program
await handleSetupCommand(subcommand, options);
});

program
.command('make')
.description('Make Firecrawl the default provider for supported workflows')
.argument('<target>', 'What to make default: "default"')
.option(
'--undo',
'Undo default provider config by re-enabling native web tools where supported'
)
.action(async (target, options) => {
if (target !== 'default') {
console.error(`Unknown make target: ${target}`);
console.log('\nAvailable targets:');
console.log(
' default Make Firecrawl the default web provider for supported AI agents'
);
process.exit(1);
}

await handleMakeDefaultCommand(options);
});

program
.command('launch')
.alias('launcher')
Expand Down Expand Up @@ -2332,6 +2354,8 @@ async function main() {
return;
}

await maybeShowUpdateNotice();

// If no arguments or just help flags, check auth and show appropriate message
if (args.length === 0) {
const { isAuthenticated } = await import('./utils/auth');
Expand Down
Loading
Loading