Crawlee—A web scraping and browser automation library for Node.js to build reliable crawlers. In JavaScript and TypeScript. Extract data for AI, LLMs, RAG, or GPTs. Download HTML, PDF, JPG, PNG, and other files from websites. Works with Puppeteer, Playwright, Cheerio, JSDOM, and raw HTTP. Both headful and headless mode. With proxy rotation.
TypeScript apifyautomationcrawlercrawlingheadlessheadless-chromejavascriptnodejsnpmplaywrightpuppeteerscraperscrapingtypescriptweb-crawlerweb-crawlingweb-scraping
Add option to disable outdated warning (#703)
Ondra Urban62013d3932ac
diff --git a/src/utils.js b/src/utils.jsindex c4095994a..d4666df03 100644--- a/src/utils.js+++ b/src/utils.js@@ -40,6 +40,12 @@ const URL_NO_COMMAS_REGEX = RegExp('https?://(www\\.)?[\\p{L}0-9][-\\p{L}0-9@:%.*/const URL_WITH_COMMAS_REGEX = RegExp('https?://(www\\.)?[\\p{L}0-9][-\\p{L}0-9@:%._\\+~#=]{0,254}[\\p{L}0-9]\\.[a-z]{2,63}(:\\d{1,5})?(/[-\\p{L}0-9@:%_\\+,.~#?&//=\\(\\)]*)?', 'giu'); // eslint-disable-line+/**+ * Allows turning off the warning that gets printed whenever an actor is run with an outdated SDK on the Apify Platform.+ * @type {string}+ */+const DISABLE_OUTDATED_WARNING = 'APIFY_DISABLE_OUTDATED_WARNING';+const ensureDirPromised = util.promisify(fsExtra.ensureDir);const psTreePromised = util.promisify(psTree);@@ -672,6 +678,7 @@ export const snakeCaseToCamelCase = (snakeCaseStr) => {* @ignore*/export const printOutdatedSdkWarning = () => {+ if (process.env[DISABLE_OUTDATED_WARNING]) return;const latestApifyVersion = process.env[ENV_VARS.SDK_LATEST_VERSION];if (!latestApifyVersion || !semver.lt(apifyVersion, latestApifyVersion)) return;diff --git a/test/utils.test.js b/test/utils.test.jsindex f363ff1ce..fce8c90e6 100644--- a/test/utils.test.js+++ b/test/utils.test.js@@ -903,6 +903,13 @@ describe('utils.printOutdatedSdkWarning()', () => {utils.printOutdatedSdkWarning();});+ test('should do nothing when APIFY_DISABLE_OUTDATED_WARNING is set', () => {+ process.env.APIFY_DISABLE_OUTDATED_WARNING = '1';+ logMock.expects('warning').never();+ utils.printOutdatedSdkWarning();+ delete process.env.APIFY_DISABLE_OUTDATED_WARNING;+ });+test('should correctly work when outdated', () => {process.env[ENV_VARS.SDK_LATEST_VERSION] = semver.inc(currentVersion, 'minor');console.log(process.env[ENV_VARS.SDK_LATEST_VERSION]);