mirror of
https://github.com/whyour/qinglong.git
synced 2025-11-13 11:06:07 +08:00
升级 cron-parser
This commit is contained in:
parent
1f2fd8ac02
commit
1deb264913
|
|
@ -3,7 +3,7 @@ import { Container } from 'typedi';
|
||||||
import { Logger } from 'winston';
|
import { Logger } from 'winston';
|
||||||
import SubscriptionService from '../services/subscription';
|
import SubscriptionService from '../services/subscription';
|
||||||
import { celebrate, Joi } from 'celebrate';
|
import { celebrate, Joi } from 'celebrate';
|
||||||
import cron_parser from 'cron-parser';
|
import { CronExpressionParser } from 'cron-parser';
|
||||||
const route = Router();
|
const route = Router();
|
||||||
|
|
||||||
export default (app: Router) => {
|
export default (app: Router) => {
|
||||||
|
|
@ -60,7 +60,7 @@ export default (app: Router) => {
|
||||||
try {
|
try {
|
||||||
if (
|
if (
|
||||||
!req.body.schedule ||
|
!req.body.schedule ||
|
||||||
cron_parser.parseExpression(req.body.schedule).hasNext()
|
CronExpressionParser.parse(req.body.schedule).hasNext()
|
||||||
) {
|
) {
|
||||||
const subscriptionService = Container.get(SubscriptionService);
|
const subscriptionService = Container.get(SubscriptionService);
|
||||||
const data = await subscriptionService.create(req.body);
|
const data = await subscriptionService.create(req.body);
|
||||||
|
|
@ -193,7 +193,7 @@ export default (app: Router) => {
|
||||||
if (
|
if (
|
||||||
!req.body.schedule ||
|
!req.body.schedule ||
|
||||||
typeof req.body.schedule === 'object' ||
|
typeof req.body.schedule === 'object' ||
|
||||||
cron_parser.parseExpression(req.body.schedule).hasNext()
|
CronExpressionParser.parse(req.body.schedule).hasNext()
|
||||||
) {
|
) {
|
||||||
const subscriptionService = Container.get(SubscriptionService);
|
const subscriptionService = Container.get(SubscriptionService);
|
||||||
const data = await subscriptionService.update(req.body);
|
const data = await subscriptionService.update(req.body);
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ export default async () => {
|
||||||
await sequelize.query(
|
await sequelize.query(
|
||||||
'alter table Crontabs add column log_name VARCHAR(255)',
|
'alter table Crontabs add column log_name VARCHAR(255)',
|
||||||
);
|
);
|
||||||
} catch (error) {}
|
} catch (error) { }
|
||||||
try {
|
try {
|
||||||
await sequelize.query('alter table Envs add column isPinned NUMBER');
|
await sequelize.query('alter table Envs add column isPinned NUMBER');
|
||||||
} catch (error) {}
|
} catch (error) {}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import config from '../config';
|
||||||
import { Crontab, CrontabModel, CrontabStatus } from '../data/cron';
|
import { Crontab, CrontabModel, CrontabStatus } from '../data/cron';
|
||||||
import { exec, execSync } from 'child_process';
|
import { exec, execSync } from 'child_process';
|
||||||
import fs from 'fs/promises';
|
import fs from 'fs/promises';
|
||||||
import cron_parser from 'cron-parser';
|
import { CronExpressionParser } from 'cron-parser';
|
||||||
import {
|
import {
|
||||||
getFileContentByName,
|
getFileContentByName,
|
||||||
fileExist,
|
fileExist,
|
||||||
|
|
@ -688,7 +688,7 @@ export default class CronService {
|
||||||
if (
|
if (
|
||||||
command &&
|
command &&
|
||||||
schedule &&
|
schedule &&
|
||||||
cron_parser.parseExpression(schedule).hasNext()
|
CronExpressionParser.parse(schedule).hasNext()
|
||||||
) {
|
) {
|
||||||
const name = namePrefix + '_' + index;
|
const name = namePrefix + '_' + index;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { Joi } from 'celebrate';
|
import { Joi } from 'celebrate';
|
||||||
import cron_parser from 'cron-parser';
|
import { CronExpressionParser } from 'cron-parser';
|
||||||
import { ScheduleType } from '../interface/schedule';
|
import { ScheduleType } from '../interface/schedule';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import config from '../config';
|
import config from '../config';
|
||||||
|
|
@ -13,7 +13,7 @@ const validateSchedule = (value: string, helpers: any) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (cron_parser.parseExpression(value).hasNext()) {
|
if (CronExpressionParser.parse(value).hasNext()) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@
|
||||||
"celebrate": "^15.0.3",
|
"celebrate": "^15.0.3",
|
||||||
"chokidar": "^4.0.1",
|
"chokidar": "^4.0.1",
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"cron-parser": "^4.9.0",
|
"cron-parser": "^5.4.0",
|
||||||
"cross-spawn": "^7.0.6",
|
"cross-spawn": "^7.0.6",
|
||||||
"dayjs": "^1.11.13",
|
"dayjs": "^1.11.13",
|
||||||
"dotenv": "^16.4.6",
|
"dotenv": "^16.4.6",
|
||||||
|
|
|
||||||
|
|
@ -39,8 +39,8 @@ dependencies:
|
||||||
specifier: ^2.8.5
|
specifier: ^2.8.5
|
||||||
version: 2.8.5
|
version: 2.8.5
|
||||||
cron-parser:
|
cron-parser:
|
||||||
specifier: ^4.9.0
|
specifier: ^5.4.0
|
||||||
version: 4.9.0
|
version: 5.4.0
|
||||||
cross-spawn:
|
cross-spawn:
|
||||||
specifier: ^7.0.6
|
specifier: ^7.0.6
|
||||||
version: 7.0.6
|
version: 7.0.6
|
||||||
|
|
@ -6524,6 +6524,13 @@ packages:
|
||||||
luxon: 3.5.0
|
luxon: 3.5.0
|
||||||
dev: false
|
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:
|
/croner@7.0.8:
|
||||||
resolution: {integrity: sha512-4E27J9ZQV9prM9ggU18QGPYPMSblbA9JuGv4Ff3Gk6supX4RszNGQxBgiFBL6wb/L9HuSMpFbQpduMiDRo+z5Q==}
|
resolution: {integrity: sha512-4E27J9ZQV9prM9ggU18QGPYPMSblbA9JuGv4Ff3Gk6supX4RszNGQxBgiFBL6wb/L9HuSMpFbQpduMiDRo+z5Q==}
|
||||||
engines: {node: '>=6.0'}
|
engines: {node: '>=6.0'}
|
||||||
|
|
@ -9792,6 +9799,11 @@ packages:
|
||||||
engines: {node: '>=12'}
|
engines: {node: '>=12'}
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
|
/luxon@3.7.2:
|
||||||
|
resolution: {integrity: sha512-vtEhXh/gNjI9Yg1u4jX/0YVPMvxzHuGgCm6tC5kZyb08yjGWGnqAjGJvcXbqQR2P3MyMEFnRbpcdFS6PBcLqew==}
|
||||||
|
engines: {node: '>=12'}
|
||||||
|
dev: false
|
||||||
|
|
||||||
/make-dir@2.1.0:
|
/make-dir@2.1.0:
|
||||||
resolution: {integrity: sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA==}
|
resolution: {integrity: sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA==}
|
||||||
engines: {node: '>=6'}
|
engines: {node: '>=6'}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ import {
|
||||||
} from 'antd';
|
} from 'antd';
|
||||||
import { request } from '@/utils/http';
|
import { request } from '@/utils/http';
|
||||||
import config from '@/utils/config';
|
import config from '@/utils/config';
|
||||||
import cron_parser from 'cron-parser';
|
import { CronExpressionParser } from 'cron-parser';
|
||||||
import isNil from 'lodash/isNil';
|
import isNil from 'lodash/isNil';
|
||||||
|
|
||||||
const { Option } = Select;
|
const { Option } = Select;
|
||||||
|
|
@ -224,8 +224,8 @@ const SubscriptionModal = ({
|
||||||
type === 'raw'
|
type === 'raw'
|
||||||
? 'file'
|
? 'file'
|
||||||
: url.startsWith('http')
|
: url.startsWith('http')
|
||||||
? 'public-repo'
|
? 'public-repo'
|
||||||
: 'private-repo';
|
: 'private-repo';
|
||||||
|
|
||||||
form.setFieldsValue({
|
form.setFieldsValue({
|
||||||
type: _type,
|
type: _type,
|
||||||
|
|
@ -381,7 +381,7 @@ const SubscriptionModal = ({
|
||||||
if (
|
if (
|
||||||
scheduleType === 'interval' ||
|
scheduleType === 'interval' ||
|
||||||
!value ||
|
!value ||
|
||||||
cron_parser.parseExpression(value).hasNext()
|
CronExpressionParser.parse(value).hasNext()
|
||||||
) {
|
) {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import intl from 'react-intl-universal';
|
import intl from 'react-intl-universal';
|
||||||
import { LANG_MAP, LOG_END_SYMBOL } from './const';
|
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';
|
import { ICrontab } from '@/pages/crontab/type';
|
||||||
|
|
||||||
export default function browserType() {
|
export default function browserType() {
|
||||||
|
|
@ -155,9 +155,9 @@ export default function browserType() {
|
||||||
shell === 'none'
|
shell === 'none'
|
||||||
? {}
|
? {}
|
||||||
: {
|
: {
|
||||||
shell, // wechat qq uc 360 2345 sougou liebao maxthon
|
shell, // wechat qq uc 360 2345 sougou liebao maxthon
|
||||||
shellVs,
|
shellVs,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
|
|
@ -333,11 +333,11 @@ export function getCommandScript(
|
||||||
|
|
||||||
export function parseCrontab(schedule: string): Date | null {
|
export function parseCrontab(schedule: string): Date | null {
|
||||||
try {
|
try {
|
||||||
const time = cron_parser.parseExpression(schedule);
|
const time = CronExpressionParser.parse(schedule);
|
||||||
if (time) {
|
if (time) {
|
||||||
return time.next().toDate();
|
return time.next().toDate();
|
||||||
}
|
}
|
||||||
} catch (error) {}
|
} catch (error) { }
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user