diff --git a/back/api/subscription.ts b/back/api/subscription.ts index 85587a16..c4af1565 100644 --- a/back/api/subscription.ts +++ b/back/api/subscription.ts @@ -3,7 +3,7 @@ import { Container } from 'typedi'; import { Logger } from 'winston'; import SubscriptionService from '../services/subscription'; import { celebrate, Joi } from 'celebrate'; -import cron_parser from 'cron-parser'; +import { CronExpressionParser } from 'cron-parser'; const route = Router(); export default (app: Router) => { @@ -60,7 +60,7 @@ export default (app: Router) => { try { if ( !req.body.schedule || - cron_parser.parseExpression(req.body.schedule).hasNext() + CronExpressionParser.parse(req.body.schedule).hasNext() ) { const subscriptionService = Container.get(SubscriptionService); const data = await subscriptionService.create(req.body); @@ -193,7 +193,7 @@ export default (app: Router) => { if ( !req.body.schedule || typeof req.body.schedule === 'object' || - cron_parser.parseExpression(req.body.schedule).hasNext() + CronExpressionParser.parse(req.body.schedule).hasNext() ) { const subscriptionService = Container.get(SubscriptionService); const data = await subscriptionService.update(req.body); diff --git a/back/loaders/db.ts b/back/loaders/db.ts index f2d0a50d..42c2af72 100644 --- a/back/loaders/db.ts +++ b/back/loaders/db.ts @@ -60,7 +60,7 @@ export default async () => { await sequelize.query( 'alter table Crontabs add column log_name VARCHAR(255)', ); - } catch (error) {} + } catch (error) { } try { await sequelize.query('alter table Envs add column isPinned NUMBER'); } catch (error) {} diff --git a/back/services/cron.ts b/back/services/cron.ts index 10e700be..67bfefd2 100644 --- a/back/services/cron.ts +++ b/back/services/cron.ts @@ -4,7 +4,7 @@ import config from '../config'; import { Crontab, CrontabModel, CrontabStatus } from '../data/cron'; import { exec, execSync } from 'child_process'; import fs from 'fs/promises'; -import cron_parser from 'cron-parser'; +import { CronExpressionParser } from 'cron-parser'; import { getFileContentByName, fileExist, @@ -688,7 +688,7 @@ export default class CronService { if ( command && schedule && - cron_parser.parseExpression(schedule).hasNext() + CronExpressionParser.parse(schedule).hasNext() ) { const name = namePrefix + '_' + index; diff --git a/back/validation/schedule.ts b/back/validation/schedule.ts index f396508b..60d82bcd 100644 --- a/back/validation/schedule.ts +++ b/back/validation/schedule.ts @@ -1,5 +1,5 @@ import { Joi } from 'celebrate'; -import cron_parser from 'cron-parser'; +import { CronExpressionParser } from 'cron-parser'; import { ScheduleType } from '../interface/schedule'; import path from 'path'; import config from '../config'; @@ -13,7 +13,7 @@ const validateSchedule = (value: string, helpers: any) => { } try { - if (cron_parser.parseExpression(value).hasNext()) { + if (CronExpressionParser.parse(value).hasNext()) { return value; } } catch (e) { diff --git a/package.json b/package.json index 8c2dbc9e..ab349946 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,7 @@ "celebrate": "^15.0.3", "chokidar": "^4.0.1", "cors": "^2.8.5", - "cron-parser": "^4.9.0", + "cron-parser": "^5.4.0", "cross-spawn": "^7.0.6", "dayjs": "^1.11.13", "dotenv": "^16.4.6", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 50cce37f..3c8e0b0f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -39,8 +39,8 @@ dependencies: specifier: ^2.8.5 version: 2.8.5 cron-parser: - specifier: ^4.9.0 - version: 4.9.0 + specifier: ^5.4.0 + version: 5.4.0 cross-spawn: specifier: ^7.0.6 version: 7.0.6 @@ -6524,6 +6524,13 @@ packages: luxon: 3.5.0 dev: false + /cron-parser@5.4.0: + resolution: {integrity: sha512-HxYB8vTvnQFx4dLsZpGRa0uHp6X3qIzS3ZJgJ9v6l/5TJMgeWQbLkR5yiJ5hOxGbc9+jCADDnydIe15ReLZnJA==} + engines: {node: '>=18'} + dependencies: + luxon: 3.7.2 + dev: false + /croner@7.0.8: resolution: {integrity: sha512-4E27J9ZQV9prM9ggU18QGPYPMSblbA9JuGv4Ff3Gk6supX4RszNGQxBgiFBL6wb/L9HuSMpFbQpduMiDRo+z5Q==} engines: {node: '>=6.0'} @@ -9792,6 +9799,11 @@ packages: engines: {node: '>=12'} dev: false + /luxon@3.7.2: + resolution: {integrity: sha512-vtEhXh/gNjI9Yg1u4jX/0YVPMvxzHuGgCm6tC5kZyb08yjGWGnqAjGJvcXbqQR2P3MyMEFnRbpcdFS6PBcLqew==} + engines: {node: '>=12'} + dev: false + /make-dir@2.1.0: resolution: {integrity: sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA==} engines: {node: '>=6'} diff --git a/src/pages/subscription/modal.tsx b/src/pages/subscription/modal.tsx index 332d61c4..90c2f810 100644 --- a/src/pages/subscription/modal.tsx +++ b/src/pages/subscription/modal.tsx @@ -12,7 +12,7 @@ import { } from 'antd'; import { request } from '@/utils/http'; import config from '@/utils/config'; -import cron_parser from 'cron-parser'; +import { CronExpressionParser } from 'cron-parser'; import isNil from 'lodash/isNil'; const { Option } = Select; @@ -224,8 +224,8 @@ const SubscriptionModal = ({ type === 'raw' ? 'file' : url.startsWith('http') - ? 'public-repo' - : 'private-repo'; + ? 'public-repo' + : 'private-repo'; form.setFieldsValue({ type: _type, @@ -381,7 +381,7 @@ const SubscriptionModal = ({ if ( scheduleType === 'interval' || !value || - cron_parser.parseExpression(value).hasNext() + CronExpressionParser.parse(value).hasNext() ) { return Promise.resolve(); } else { diff --git a/src/utils/index.ts b/src/utils/index.ts index 381a7337..954b35b3 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -1,6 +1,6 @@ import intl from 'react-intl-universal'; import { LANG_MAP, LOG_END_SYMBOL } from './const'; -import cron_parser from 'cron-parser'; +import { CronExpressionParser } from 'cron-parser'; import { ICrontab } from '@/pages/crontab/type'; export default function browserType() { @@ -155,9 +155,9 @@ export default function browserType() { shell === 'none' ? {} : { - shell, // wechat qq uc 360 2345 sougou liebao maxthon - shellVs, - }, + shell, // wechat qq uc 360 2345 sougou liebao maxthon + shellVs, + }, ); console.log( @@ -333,11 +333,11 @@ export function getCommandScript( export function parseCrontab(schedule: string): Date | null { try { - const time = cron_parser.parseExpression(schedule); + const time = CronExpressionParser.parse(schedule); if (time) { return time.next().toDate(); } - } catch (error) {} + } catch (error) { } return null; }