From aeed1f8559e044bf658d930a22fa91f38cfedc6b Mon Sep 17 00:00:00 2001 From: towfiqi Date: Thu, 14 Nov 2024 23:08:54 +0600 Subject: [PATCH] fix: Resolves broken Docker build due to croner package version mismatch. closes #247 --- cron.js | 11 ++++++----- package-lock.json | 11 ++++++----- package.json | 2 +- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/cron.js b/cron.js index 7396e4f..c78f03d 100644 --- a/cron.js +++ b/cron.js @@ -1,7 +1,8 @@ +/* eslint-disable no-new */ const Cryptr = require('cryptr'); const { promises } = require('fs'); const { readFile } = require('fs'); -const Cron = require('croner'); +const { Cron } = require('croner'); require('dotenv').config({ path: './.env.local' }); const getAppSettings = async () => { @@ -71,7 +72,7 @@ const runAppCronJobs = () => { const scrape_interval = settings.scrape_interval || 'daily'; if (scrape_interval !== 'never') { const scrapeCronTime = generateCronTime(scrape_interval); - Cron(scrapeCronTime, () => { + new Cron(scrapeCronTime, () => { // console.log('### Running Keyword Position Cron Job!'); const fetchOpts = { method: 'POST', headers: { Authorization: `Bearer ${process.env.APIKEY}` } }; fetch(`${process.env.NEXT_PUBLIC_APP_URL}/api/cron`, fetchOpts) @@ -89,7 +90,7 @@ const runAppCronJobs = () => { if (notif_interval) { const cronTime = generateCronTime(notif_interval === 'daily' ? 'daily_morning' : notif_interval); if (cronTime) { - Cron(cronTime, () => { + new Cron(cronTime, () => { // console.log('### Sending Notification Email...'); const fetchOpts = { method: 'POST', headers: { Authorization: `Bearer ${process.env.APIKEY}` } }; fetch(`${process.env.NEXT_PUBLIC_APP_URL}/api/notify`, fetchOpts) @@ -106,7 +107,7 @@ const runAppCronJobs = () => { // Run Failed scraping CRON (Every Hour) const failedCronTime = generateCronTime('hourly'); - Cron(failedCronTime, () => { + new Cron(failedCronTime, () => { // console.log('### Retrying Failed Scrapes...'); readFile(`${process.cwd()}/data/failed_queue.json`, { encoding: 'utf-8' }, (err, data) => { @@ -135,7 +136,7 @@ const runAppCronJobs = () => { // Run Google Search Console Scraper Daily if (process.env.SEARCH_CONSOLE_PRIVATE_KEY && process.env.SEARCH_CONSOLE_CLIENT_EMAIL) { const searchConsoleCRONTime = generateCronTime('daily'); - Cron(searchConsoleCRONTime, () => { + new Cron(searchConsoleCRONTime, () => { const fetchOpts = { method: 'POST', headers: { Authorization: `Bearer ${process.env.APIKEY}` } }; fetch(`${process.env.NEXT_PUBLIC_APP_URL}/api/searchconsole`, fetchOpts) .then((res) => res.json()) diff --git a/package-lock.json b/package-lock.json index de625a3..eaaf005 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,7 @@ "cheerio": "^1.0.0", "concurrently": "^7.6.0", "cookies": "^0.8.0", - "croner": "^5.3.5", + "croner": "^9.0.0", "cryptr": "^6.0.3", "dayjs": "^1.11.5", "dotenv": "^16.0.3", @@ -4977,11 +4977,12 @@ } }, "node_modules/croner": { - "version": "5.7.0", - "resolved": "https://registry.npmjs.org/croner/-/croner-5.7.0.tgz", - "integrity": "sha512-9pSLe+tDJnmNak2JeMkz6ZmTCXP5p6vCxSd4kvDqrTJkqAP62j2uAEIZjf8cPDZIakStujqVzh5Y5MIWH3yYAw==", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/croner/-/croner-9.0.0.tgz", + "integrity": "sha512-onMB0OkDjkXunhdW9htFjEhqrD54+M94i6ackoUkjHKbRnXdyEyKRelp4nJ1kAz32+s27jP1FsebpJCVl0BsvA==", + "license": "MIT", "engines": { - "node": ">=6.0" + "node": ">=18.0" } }, "node_modules/cross-fetch": { diff --git a/package.json b/package.json index 3d873c3..2664de6 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "cheerio": "^1.0.0", "concurrently": "^7.6.0", "cookies": "^0.8.0", - "croner": "^5.3.5", + "croner": "^9.0.0", "cryptr": "^6.0.3", "dayjs": "^1.11.5", "dotenv": "^16.0.3",