@crawlee/cli 4.0.0-beta.33 → 4.0.0-beta.331
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -11
- package/commands/{CreateProjectCommand.d.ts → create-project-command.d.ts} +0 -1
- package/commands/{CreateProjectCommand.js → create-project-command.js} +4 -6
- package/commands/{InstallPlaywrightBrowsersCommand.d.ts → install-playwright-browsers-command.d.ts} +0 -1
- package/commands/{InstallPlaywrightBrowsersCommand.js → install-playwright-browsers-command.js} +0 -1
- package/commands/{RunProjectCommand.d.ts → run-project-command.d.ts} +0 -1
- package/commands/{RunProjectCommand.js → run-project-command.js} +0 -1
- package/commands/upgrade-command.d.ts +19 -0
- package/commands/upgrade-command.js +150 -0
- package/index.d.ts +0 -1
- package/index.js +16 -5
- package/package.json +10 -10
- package/skills/crawlee-upgrade/SKILL.md +20 -0
- package/skills/crawlee-upgrade-v4/SKILL.md +45 -0
- package/skills/crawlee-upgrade-v4/guide/autoscaling.md +256 -0
- package/skills/crawlee-upgrade-v4/guide/browser-management.md +174 -0
- package/skills/crawlee-upgrade-v4/guide/http-clients.md +108 -0
- package/skills/crawlee-upgrade-v4/guide/internals.md +130 -0
- package/skills/crawlee-upgrade-v4/guide/removed-symbols.md +63 -0
- package/skills/crawlee-upgrade-v4/guide/request-loaders.md +241 -0
- package/skills/crawlee-upgrade-v4/guide/sessions-and-proxies.md +164 -0
- package/skills/crawlee-upgrade-v4/guide/statistics.md +56 -0
- package/skills/crawlee-upgrade-v4/guide/storage-backends.md +170 -0
- package/skills/crawlee-upgrade-v4/guide/upgrading-v4.md +1310 -0
- package/skills/crawlee-upgrade-v4/guide/utils-and-types.md +52 -0
- package/commands/CreateProjectCommand.d.ts.map +0 -1
- package/commands/CreateProjectCommand.js.map +0 -1
- package/commands/InstallPlaywrightBrowsersCommand.d.ts.map +0 -1
- package/commands/InstallPlaywrightBrowsersCommand.js.map +0 -1
- package/commands/RunProjectCommand.d.ts.map +0 -1
- package/commands/RunProjectCommand.js.map +0 -1
- package/index.d.ts.map +0 -1
- package/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
<h1 align="center">
|
|
2
2
|
<a href="https://crawlee.dev">
|
|
3
3
|
<picture>
|
|
4
|
-
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/apify/crawlee/master/website/static/img/crawlee-dark.svg?sanitize=true"
|
|
5
|
-
<img alt="Crawlee" src="https://raw.githubusercontent.com/apify/crawlee/master/website/static/img/crawlee-light.svg?sanitize=true" width="500"
|
|
4
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/apify/crawlee/master/website/static/img/crawlee-dark.svg?sanitize=true" />
|
|
5
|
+
<img alt="Crawlee" src="https://raw.githubusercontent.com/apify/crawlee/master/website/static/img/crawlee-light.svg?sanitize=true" width="500" />
|
|
6
6
|
</picture>
|
|
7
7
|
</a>
|
|
8
|
-
<br
|
|
8
|
+
<br />
|
|
9
9
|
<small>A web scraping and browser automation library</small>
|
|
10
10
|
</h1>
|
|
11
11
|
|
|
12
|
-
<p align=center>
|
|
13
|
-
<a href="https://trendshift.io/repositories/5179" target="_blank"><img src="https://trendshift.io/api/badge/repositories/5179" alt="apify%2Fcrawlee | Trendshift"
|
|
12
|
+
<p align="center">
|
|
13
|
+
<a href="https://trendshift.io/repositories/5179" target="_blank"><img src="https://trendshift.io/api/badge/repositories/5179" alt="apify%2Fcrawlee | Trendshift" width="250" height="55"/></a>
|
|
14
14
|
</p>
|
|
15
15
|
|
|
16
|
-
<p align=center>
|
|
17
|
-
<a href="https://www.npmjs.com/package/@crawlee/core" rel="nofollow"><img src="https://img.shields.io/npm/v/@crawlee/core.svg" alt="NPM latest version" data-canonical-src="https://img.shields.io/npm/v/@crawlee/core/next.svg"
|
|
18
|
-
<a href="https://www.npmjs.com/package/@crawlee/core" rel="nofollow"><img src="https://img.shields.io/npm/dm/@crawlee/core.svg" alt="Downloads" data-canonical-src="https://img.shields.io/npm/dm/@crawlee/core.svg"
|
|
19
|
-
<a href="https://discord.gg/jyEM2PRvMU" rel="nofollow"><img src="https://img.shields.io/discord/801163717915574323?label=discord" alt="Chat on discord" data-canonical-src="https://img.shields.io/discord/801163717915574323?label=discord"
|
|
20
|
-
<a href="https://github.com/apify/crawlee/actions/workflows/test-ci.yml"><img src="https://github.com/apify/crawlee/actions/workflows/test-ci.yml/badge.svg?branch=master" alt="Build Status"
|
|
16
|
+
<p align="center">
|
|
17
|
+
<a href="https://www.npmjs.com/package/@crawlee/core" rel="nofollow"><img src="https://img.shields.io/npm/v/@crawlee/core.svg" alt="NPM latest version" data-canonical-src="https://img.shields.io/npm/v/@crawlee/core/next.svg" /></a>
|
|
18
|
+
<a href="https://www.npmjs.com/package/@crawlee/core" rel="nofollow"><img src="https://img.shields.io/npm/dm/@crawlee/core.svg" alt="Downloads" data-canonical-src="https://img.shields.io/npm/dm/@crawlee/core.svg" /></a>
|
|
19
|
+
<a href="https://discord.gg/jyEM2PRvMU" rel="nofollow"><img src="https://img.shields.io/discord/801163717915574323?label=discord" alt="Chat on discord" data-canonical-src="https://img.shields.io/discord/801163717915574323?label=discord" /></a>
|
|
20
|
+
<a href="https://github.com/apify/crawlee/actions/workflows/test-ci.yml"><img src="https://github.com/apify/crawlee/actions/workflows/test-ci.yml/badge.svg?branch=master" alt="Build Status" /></a>
|
|
21
21
|
</p>
|
|
22
22
|
|
|
23
23
|
Crawlee covers your crawling and scraping end-to-end and **helps you build reliable scrapers. Fast.**
|
|
@@ -34,7 +34,7 @@ Crawlee is available as the [`crawlee`](https://www.npmjs.com/package/crawlee) N
|
|
|
34
34
|
|
|
35
35
|
We recommend visiting the [Introduction tutorial](https://crawlee.dev/js/docs/introduction) in Crawlee documentation for more information.
|
|
36
36
|
|
|
37
|
-
> Crawlee requires **Node.js
|
|
37
|
+
> Crawlee requires **Node.js 22.13 or higher**.
|
|
38
38
|
|
|
39
39
|
### With Crawlee CLI
|
|
40
40
|
|
|
@@ -144,6 +144,10 @@ Crawlee is open-source and runs anywhere, but since it's developed by [Apify](ht
|
|
|
144
144
|
|
|
145
145
|
If you find any bug or issue with Crawlee, please [submit an issue on GitHub](https://github.com/apify/crawlee/issues). For questions, you can ask on [Stack Overflow](https://stackoverflow.com/questions/tagged/apify), in GitHub Discussions or you can join our [Discord server](https://discord.com/invite/jyEM2PRvMU).
|
|
146
146
|
|
|
147
|
+
## Supported versions
|
|
148
|
+
|
|
149
|
+
New features and bug fixes land in the latest major version. The previous major version keeps receiving fixes for high and critical severity vulnerabilities for 12 months after the next major is released, and reaches end of life after that. See the [security policy](https://github.com/apify/crawlee/security/policy) for the current status of each version and for how to report a vulnerability.
|
|
150
|
+
|
|
147
151
|
## Contributing
|
|
148
152
|
|
|
149
153
|
Your code contributions are welcome, and you'll be praised to eternity! If you have any ideas for improvements, either submit an issue or create a pull request. For contribution guidelines and the code of conduct, see [CONTRIBUTING.md](https://github.com/apify/crawlee/blob/master/CONTRIBUTING.md).
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { execSync } from 'node:child_process';
|
|
2
2
|
import { mkdirSync } from 'node:fs';
|
|
3
|
-
import { readFile, writeFile } from 'node:fs/promises';
|
|
3
|
+
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
4
4
|
import { get } from 'node:https';
|
|
5
5
|
import { dirname, join, resolve } from 'node:path';
|
|
6
6
|
import { setTimeout } from 'node:timers/promises';
|
|
7
7
|
import { fetchManifest } from '@crawlee/templates';
|
|
8
8
|
import { input, select } from '@inquirer/prompts';
|
|
9
9
|
import colors from 'ansi-colors';
|
|
10
|
-
import { ensureDir } from 'fs-extra/esm';
|
|
11
10
|
function validateProjectName(name) {
|
|
12
11
|
if (name.length === 0) {
|
|
13
12
|
throw new Error('The project name cannot be empty string.');
|
|
@@ -49,7 +48,7 @@ async function downloadTemplateFilesToDisk(template, destinationDirectory) {
|
|
|
49
48
|
// Make sure the folder for the file exists
|
|
50
49
|
const fileDirName = dirname(file.path);
|
|
51
50
|
const fileFolder = resolve(destinationDirectory, fileDirName);
|
|
52
|
-
await
|
|
51
|
+
await mkdir(fileFolder, { recursive: true });
|
|
53
52
|
// Write the actual file
|
|
54
53
|
await writeFile(resolve(destinationDirectory, file.path), buffer);
|
|
55
54
|
});
|
|
@@ -122,7 +121,7 @@ export class CreateProjectCommand {
|
|
|
122
121
|
if (!template) {
|
|
123
122
|
template = await select({
|
|
124
123
|
message: 'Please select the template for your new Crawlee project',
|
|
125
|
-
default: choices[0],
|
|
124
|
+
default: choices[0]?.value,
|
|
126
125
|
choices,
|
|
127
126
|
});
|
|
128
127
|
}
|
|
@@ -142,9 +141,8 @@ export class CreateProjectCommand {
|
|
|
142
141
|
await downloadTemplateFilesToDisk(templateData, projectDir);
|
|
143
142
|
await rewrite(resolve(projectDir, 'package.json'), (pkg) => pkg.replace(/"name": "[\w-]+"/, `"name": "${projectName}"`));
|
|
144
143
|
// Run npm install in project dir.
|
|
145
|
-
const npm =
|
|
144
|
+
const npm = process.platform.startsWith('win') ? 'npm.cmd' : 'npm';
|
|
146
145
|
execSync(`${npm} install`, { cwd: projectDir, stdio: 'inherit' });
|
|
147
146
|
console.log(colors.green(`Project ${projectName} was created. To run it, run "cd ${projectName}" and "npm start".`));
|
|
148
147
|
}
|
|
149
148
|
}
|
|
150
|
-
//# sourceMappingURL=CreateProjectCommand.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ArgumentsCamelCase, Argv, CommandModule } from 'yargs';
|
|
2
|
+
interface UpgradeArgs {
|
|
3
|
+
from?: number;
|
|
4
|
+
to?: number;
|
|
5
|
+
export?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class UpgradeCommand<T> implements CommandModule<T, UpgradeArgs> {
|
|
8
|
+
command: string;
|
|
9
|
+
describe: string;
|
|
10
|
+
builder: (args: Argv<T>) => Argv<T & {
|
|
11
|
+
from: number | undefined;
|
|
12
|
+
} & {
|
|
13
|
+
to: number | undefined;
|
|
14
|
+
} & {
|
|
15
|
+
export: string | undefined;
|
|
16
|
+
}>;
|
|
17
|
+
handler(args: ArgumentsCamelCase<UpgradeArgs>): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { cp, readFile, readdir } from 'node:fs/promises';
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
3
|
+
import { dirname, join, resolve } from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import semver from 'semver';
|
|
6
|
+
const runtimePackages = new Set([
|
|
7
|
+
'crawlee',
|
|
8
|
+
...[
|
|
9
|
+
'basic',
|
|
10
|
+
'browser',
|
|
11
|
+
'browser-pool',
|
|
12
|
+
'cheerio',
|
|
13
|
+
'core',
|
|
14
|
+
'fs-storage',
|
|
15
|
+
'http',
|
|
16
|
+
'http-client',
|
|
17
|
+
'impit-client',
|
|
18
|
+
'got-scraping-client',
|
|
19
|
+
'playwright',
|
|
20
|
+
'puppeteer',
|
|
21
|
+
'stagehand',
|
|
22
|
+
'types',
|
|
23
|
+
'utils',
|
|
24
|
+
'otel',
|
|
25
|
+
].map((name) => `@crawlee/${name}`),
|
|
26
|
+
]);
|
|
27
|
+
async function detectProjectMajor() {
|
|
28
|
+
let directory = process.cwd();
|
|
29
|
+
let manifestPath;
|
|
30
|
+
let manifest;
|
|
31
|
+
while (true) {
|
|
32
|
+
manifestPath = join(directory, 'package.json');
|
|
33
|
+
try {
|
|
34
|
+
manifest = JSON.parse(await readFile(manifestPath, 'utf8'));
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
if (error.code !== 'ENOENT')
|
|
39
|
+
throw error;
|
|
40
|
+
const parent = dirname(directory);
|
|
41
|
+
if (parent === directory) {
|
|
42
|
+
throw new Error('No project package.json found. Run inside the project or specify --from <major>.');
|
|
43
|
+
}
|
|
44
|
+
directory = parent;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const require = createRequire(manifestPath);
|
|
48
|
+
const majors = new Set();
|
|
49
|
+
for (const section of ['dependencies', 'devDependencies', 'optionalDependencies', 'peerDependencies']) {
|
|
50
|
+
for (const [name, specifier] of Object.entries(manifest[section] ?? {})) {
|
|
51
|
+
if (!runtimePackages.has(name))
|
|
52
|
+
continue;
|
|
53
|
+
const range = typeof specifier === 'string' ? semver.validRange(specifier.replace(/^workspace:/, '')) : null;
|
|
54
|
+
let installedVersion = null;
|
|
55
|
+
try {
|
|
56
|
+
const installed = JSON.parse(await readFile(require.resolve(`${name}/package.json`), 'utf8'));
|
|
57
|
+
installedVersion = semver.valid(installed.version);
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
if (!['MODULE_NOT_FOUND', 'ERR_PACKAGE_PATH_NOT_EXPORTED', 'ENOENT'].includes(error.code ?? '')) {
|
|
61
|
+
throw error;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (installedVersion &&
|
|
65
|
+
(!range || semver.satisfies(installedVersion, range, { includePrerelease: true }))) {
|
|
66
|
+
majors.add(semver.major(installedVersion));
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
const minimum = range ? semver.minVersion(range) : null;
|
|
70
|
+
if (!minimum ||
|
|
71
|
+
!semver.subset(range, `>=${minimum.major}.0.0-0 <${minimum.major + 1}.0.0-0`, {
|
|
72
|
+
includePrerelease: true,
|
|
73
|
+
})) {
|
|
74
|
+
throw new Error(`Cannot determine the Crawlee major from ${name}: ${specifier} in ${manifestPath}. Install project dependencies or specify --from <major>.`);
|
|
75
|
+
}
|
|
76
|
+
majors.add(minimum.major);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (majors.size !== 1) {
|
|
80
|
+
const reason = majors.size
|
|
81
|
+
? `Crawlee dependencies use different majors (${[...majors].sort().join(', ')})`
|
|
82
|
+
: 'No Crawlee runtime dependency found';
|
|
83
|
+
throw new Error(`${reason} in ${manifestPath}. Run in the relevant workspace package or specify --from <major>.`);
|
|
84
|
+
}
|
|
85
|
+
return [...majors][0];
|
|
86
|
+
}
|
|
87
|
+
function body(markdown) {
|
|
88
|
+
return markdown.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n+/, '').trim();
|
|
89
|
+
}
|
|
90
|
+
export class UpgradeCommand {
|
|
91
|
+
command = 'upgrade';
|
|
92
|
+
describe = 'Prints an AI migration prompt, upgrading one Crawlee major at a time';
|
|
93
|
+
builder = (args) => args
|
|
94
|
+
.option('from', { type: 'number', describe: 'Starting major version; defaults to the project version' })
|
|
95
|
+
.option('to', {
|
|
96
|
+
type: 'number',
|
|
97
|
+
describe: 'Target major version; defaults to the newest bundled migration',
|
|
98
|
+
})
|
|
99
|
+
.option('export', {
|
|
100
|
+
type: 'string',
|
|
101
|
+
describe: 'Copy the migration guides into this directory and link the prompt to that copy',
|
|
102
|
+
});
|
|
103
|
+
async handler(args) {
|
|
104
|
+
for (const [name, value] of Object.entries({ from: args.from, to: args.to })) {
|
|
105
|
+
if (value !== undefined && (!Number.isSafeInteger(value) || value < 1)) {
|
|
106
|
+
throw new Error(`--${name} must be a positive major version number.`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
const skillsUrl = new URL('../skills/', import.meta.url);
|
|
110
|
+
const migrations = new Map();
|
|
111
|
+
for (const entry of await readdir(skillsUrl, { withFileTypes: true })) {
|
|
112
|
+
const match = /^crawlee-upgrade-v(\d+)$/.exec(entry.name);
|
|
113
|
+
if (entry.isDirectory() && match)
|
|
114
|
+
migrations.set(Number(match[1]), new URL(`${entry.name}/`, skillsUrl));
|
|
115
|
+
}
|
|
116
|
+
if (!migrations.size)
|
|
117
|
+
throw new Error('No migration guides are bundled with this CLI.');
|
|
118
|
+
const from = args.from ?? (await detectProjectMajor());
|
|
119
|
+
const to = args.to ?? Math.max(...migrations.keys());
|
|
120
|
+
if (from >= to) {
|
|
121
|
+
throw new Error(`The project is already on Crawlee v${from}; the target must be newer. Use --from to explicitly review an earlier migration.`);
|
|
122
|
+
}
|
|
123
|
+
const steps = [];
|
|
124
|
+
const guides = [];
|
|
125
|
+
for (let major = from + 1; major <= to; major++) {
|
|
126
|
+
const skillUrl = migrations.get(major);
|
|
127
|
+
if (!skillUrl)
|
|
128
|
+
throw new Error(`No bundled migration from v${major - 1} to v${major}. Choose a supported --to version or use a CLI with that guide.`);
|
|
129
|
+
let skillPath = fileURLToPath(skillUrl);
|
|
130
|
+
if (args.export !== undefined) {
|
|
131
|
+
const target = join(resolve(args.export), `crawlee-upgrade-v${major}`);
|
|
132
|
+
await cp(skillPath, target, { recursive: true });
|
|
133
|
+
skillPath = target;
|
|
134
|
+
}
|
|
135
|
+
const skillRoot = skillPath.replace(/\\/g, '/').replace(/\/$/, '');
|
|
136
|
+
const prompt = await readFile(new URL('SKILL.md', skillUrl), 'utf8');
|
|
137
|
+
steps.push(`${steps.length + 1}. Upgrade v${major - 1} to v${major}, then verify before continuing.`);
|
|
138
|
+
guides.push(body(prompt).replaceAll('{SKILL_ROOT}', () => skillRoot));
|
|
139
|
+
}
|
|
140
|
+
const template = await readFile(new URL('crawlee-upgrade/SKILL.md', skillsUrl), 'utf8');
|
|
141
|
+
const replacements = {
|
|
142
|
+
FROM_MAJOR: String(from),
|
|
143
|
+
TO_MAJOR: String(to),
|
|
144
|
+
MIGRATION_PLAN: steps.join('\n'),
|
|
145
|
+
MIGRATION_GUIDES: guides.join('\n\n---\n\n'),
|
|
146
|
+
};
|
|
147
|
+
const prompt = body(template).replace(/\{(FROM_MAJOR|TO_MAJOR|MIGRATION_PLAN|MIGRATION_GUIDES)\}/g, (_, key) => replacements[key]);
|
|
148
|
+
process.stdout.write(`${prompt}\n`);
|
|
149
|
+
}
|
|
150
|
+
}
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// eslint-disable-next-line
|
|
3
|
-
import { CreateProjectCommand } from './commands/
|
|
4
|
-
import { InstallPlaywrightBrowsersCommand } from './commands/
|
|
5
|
-
import { RunProjectCommand } from './commands/
|
|
3
|
+
import { CreateProjectCommand } from './commands/create-project-command.js';
|
|
4
|
+
import { InstallPlaywrightBrowsersCommand } from './commands/install-playwright-browsers-command.js';
|
|
5
|
+
import { RunProjectCommand } from './commands/run-project-command.js';
|
|
6
|
+
import { UpgradeCommand } from './commands/upgrade-command.js';
|
|
6
7
|
import { createRequire } from 'node:module';
|
|
7
8
|
import yargs from 'yargs';
|
|
8
9
|
const require = createRequire(import.meta.url);
|
|
@@ -26,8 +27,19 @@ const cli = yargs()
|
|
|
26
27
|
.command(new CreateProjectCommand())
|
|
27
28
|
.command(new RunProjectCommand())
|
|
28
29
|
.command(new InstallPlaywrightBrowsersCommand())
|
|
30
|
+
.command(new UpgradeCommand())
|
|
29
31
|
.recommendCommands()
|
|
30
|
-
.showHelpOnFail(
|
|
32
|
+
.showHelpOnFail(false)
|
|
33
|
+
.fail((message, error, instance) => {
|
|
34
|
+
if (error) {
|
|
35
|
+
console.error(error.message);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
instance.showHelp();
|
|
39
|
+
console.error(`\n${message}`);
|
|
40
|
+
}
|
|
41
|
+
process.exit(1);
|
|
42
|
+
})
|
|
31
43
|
.demandCommand(1, '')
|
|
32
44
|
.strict();
|
|
33
45
|
void (async () => {
|
|
@@ -36,4 +48,3 @@ void (async () => {
|
|
|
36
48
|
yargs(process.argv.slice(2)).showHelp();
|
|
37
49
|
}
|
|
38
50
|
})();
|
|
39
|
-
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crawlee/cli",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.331",
|
|
4
4
|
"description": "The scalable web crawling and scraping library for JavaScript/Node.js. Enables development of data extraction and web automation jobs (not only) with headless Chrome and Puppeteer.",
|
|
5
5
|
"engines": {
|
|
6
|
-
"node": ">=22.
|
|
6
|
+
"node": ">=22.13.0"
|
|
7
7
|
},
|
|
8
8
|
"bin": {
|
|
9
9
|
"crawlee": "./index.js"
|
|
@@ -36,21 +36,21 @@
|
|
|
36
36
|
},
|
|
37
37
|
"homepage": "https://crawlee.dev",
|
|
38
38
|
"scripts": {
|
|
39
|
-
"build": "
|
|
39
|
+
"build": "pnpm clean && pnpm compile && pnpm copy",
|
|
40
40
|
"clean": "rimraf ./dist",
|
|
41
41
|
"compile": "tsc -p tsconfig.build.json",
|
|
42
|
-
"copy": "tsx ../../scripts/copy.ts"
|
|
42
|
+
"copy": "node scripts/copy-skills.mjs && tsx ../../scripts/copy.ts"
|
|
43
43
|
},
|
|
44
44
|
"publishConfig": {
|
|
45
45
|
"access": "public"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@crawlee/templates": "4.0.0-beta.
|
|
49
|
-
"@inquirer/prompts": "^
|
|
48
|
+
"@crawlee/templates": "4.0.0-beta.331",
|
|
49
|
+
"@inquirer/prompts": "^8.8.1",
|
|
50
50
|
"ansi-colors": "^4.1.3",
|
|
51
|
-
"
|
|
52
|
-
"tslib": "^2.
|
|
53
|
-
"yargs": "^18.
|
|
51
|
+
"semver": "^7.8.5",
|
|
52
|
+
"tslib": "^2.9.1",
|
|
53
|
+
"yargs": "^18.2.0"
|
|
54
54
|
},
|
|
55
55
|
"lerna": {
|
|
56
56
|
"command": {
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "7ad8afd8a8b83aaa763f813f570c684842fe3b61"
|
|
63
63
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: crawlee-upgrade
|
|
3
|
+
description: Plan and perform a Crawlee upgrade using the bundled migration guides, completing one major version at a time.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Crawlee upgrade plan: v{FROM_MAJOR} to v{TO_MAJOR}
|
|
7
|
+
|
|
8
|
+
Inspect this project and confirm its Crawlee versions before changing files. The guides below link local files; if they are unreadable from here, run `npx crawlee@{TO_MAJOR} upgrade --export <dir>` with a readable directory and use the prompt it prints instead. The CLI selected v{FROM_MAJOR} as the starting major from the project or an explicit `--from` override. If that does not match the code and dependencies, resolve the discrepancy with the user.
|
|
9
|
+
|
|
10
|
+
## Migration sequence
|
|
11
|
+
|
|
12
|
+
{MIGRATION_PLAN}
|
|
13
|
+
|
|
14
|
+
Apply the guides below in this order. Complete each major upgrade, install compatible dependencies, and run its verification before starting the next. Do not jump directly to the final major or mix changes from different steps. If a step fails verification, fix it or report the blocker before proceeding.
|
|
15
|
+
|
|
16
|
+
Follow the Git permission and incremental-commit instructions in the guides. One approval covers the full sequence; commit each coherent, verified change before continuing. Preserve user edits and data throughout the migration.
|
|
17
|
+
|
|
18
|
+
## Migration guides
|
|
19
|
+
|
|
20
|
+
{MIGRATION_GUIDES}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: crawlee-upgrade-v4
|
|
3
|
+
description: Migrate a JavaScript or TypeScript Crawlee project from v3 to v4 while preserving crawl behavior and persistence.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Upgrade Crawlee from v3 to v4
|
|
7
|
+
|
|
8
|
+
Inspect, plan, migrate and verify this project. The breaking changes are described in the bundled copy of the [v4 upgrade guide](<{SKILL_ROOT}/guide/upgrading-v4.md>), which is the same text as the [published guide](https://crawlee.dev/js/docs/next/upgrading/upgrading-to-v4).
|
|
9
|
+
|
|
10
|
+
## Read the guide
|
|
11
|
+
|
|
12
|
+
Read the guide's rename cheat sheet and all of "Changes most users will hit" before planning. Each "Only if you…" section applies only when the project uses what its title names; most of them summarize a detail page, so read that page when the section applies:
|
|
13
|
+
|
|
14
|
+
| Project usage or migration error | Detail page |
|
|
15
|
+
| --- | --- |
|
|
16
|
+
| Crawler subclasses, protected overrides, private fields, explicit generics, hook types, `RecoverableState` | [Internals](<{SKILL_ROOT}/guide/internals.md>) |
|
|
17
|
+
| `SessionPool`, `Session`, `createSessionFunction`, proxy tiers, `newUrlFunction` | [Sessions and proxies](<{SKILL_ROOT}/guide/sessions-and-proxies.md>) |
|
|
18
|
+
| `browserPoolOptions`, `browserController`, `launchContext`, rendering type predictor | [Browser management](<{SKILL_ROOT}/guide/browser-management.md>) |
|
|
19
|
+
| `statisticsOptions`, custom `Statistics`, persisted counters | [Statistics](<{SKILL_ROOT}/guide/statistics.md>) |
|
|
20
|
+
| `gotScraping`, `BaseHttpClient`, custom HTTP clients | [HTTP clients](<{SKILL_ROOT}/guide/http-clients.md>) |
|
|
21
|
+
| `RequestList`, sitemap loaders, custom request managers, per-domain throttling | [Request loaders](<{SKILL_ROOT}/guide/request-loaders.md>) |
|
|
22
|
+
| `StorageClient`, custom storage backends, `RequestQueue` or `Dataset` internals | [Storage backends](<{SKILL_ROOT}/guide/storage-backends.md>) |
|
|
23
|
+
| `autoscaledPoolOptions`, `crawler.autoscaledPool`, snapshotting, load signals | [Autoscaling](<{SKILL_ROOT}/guide/autoscaling.md>) |
|
|
24
|
+
| Imports from `@crawlee/utils` or `@crawlee/types` | [Utils and types](<{SKILL_ROOT}/guide/utils-and-types.md>) |
|
|
25
|
+
| An import the compiler no longer finds | [Removed symbols](<{SKILL_ROOT}/guide/removed-symbols.md>) |
|
|
26
|
+
|
|
27
|
+
Skip the guide's "Upgrade with an AI coding tool" section: it describes the command that printed this prompt.
|
|
28
|
+
|
|
29
|
+
## Inspect and plan
|
|
30
|
+
|
|
31
|
+
Inspect manifests, lockfiles, crawler code, tests, runtime versions, CI and Dockerfiles. Inventory `crawlee`, `@crawlee/*`, `apify`, `apify-*` and `@apify/*` across workspace dependency sections. Update the Crawlee packages together to compatible v4 releases and refresh the lockfile. Actor projects also move to `apify@4`; other Apify packages version independently, so update them only when compatibility requires it.
|
|
32
|
+
|
|
33
|
+
Search the project for what the guide's sections name. Plan the changes around the project's crawler types, custom collaborators, storage persistence and queue reuse. Ask about behavior the code does not establish. If the project is already on v4, address the remaining migration gaps.
|
|
34
|
+
|
|
35
|
+
Apply the Node.js and optional-dependency requirements everywhere the project sets them: every Dockerfile build and runtime stage, base images selected through `ARG`, Compose or CI variables, install and prune scripts, and package-manager configuration. Preserve the image family, browser support, dev-dependency omission and frozen-lockfile behavior.
|
|
36
|
+
|
|
37
|
+
## Git
|
|
38
|
+
|
|
39
|
+
For a Git project, inspect the branch and working tree. Ask once for permission to create a migration branch and make incremental commits, unless both are already authorized. Wait for approval before those Git actions.
|
|
40
|
+
|
|
41
|
+
If approved, verify and commit each coherent step before continuing. Stage only migration changes; preserve existing edits and ask about overlaps. Do not push unless asked. If branching or commits are declined, continue the migration without them.
|
|
42
|
+
|
|
43
|
+
## Verify
|
|
44
|
+
|
|
45
|
+
Run the project's type check, relevant tests and build. Use fixtures or a bounded crawl with isolated storage to check affected behavior, including that native HTTP and filesystem binaries load in the target container. Do not purge user storage or run a production crawl as verification. Report changes, failed or unavailable checks, and unresolved decisions.
|