mirror of
https://github.com/whyour/qinglong.git
synced 2025-11-08 15:06:08 +08:00
Fix cron-parser import to use named exports instead of default import
Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>
This commit is contained in:
parent
b90107f524
commit
70d7099abe
|
|
@ -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 { parseExpression } 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()
|
parseExpression(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()
|
parseExpression(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);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import fs from 'fs/promises';
|
import fs from 'fs/promises';
|
||||||
import chokidar from 'chokidar';
|
import chokidar, { FSWatcher } from 'chokidar';
|
||||||
import config from '../config/index';
|
import config from '../config/index';
|
||||||
import { fileExist, promiseExec, rmPath } from '../config/util';
|
import { fileExist, promiseExec, rmPath } from '../config/util';
|
||||||
|
|
||||||
|
|
@ -55,9 +55,9 @@ export default async (src: string = 'deps') => {
|
||||||
const watcher = chokidar.watch(source, {
|
const watcher = chokidar.watch(source, {
|
||||||
ignored: /(^|[\/\\])\../, // ignore dotfiles
|
ignored: /(^|[\/\\])\../, // ignore dotfiles
|
||||||
persistent: true,
|
persistent: true,
|
||||||
});
|
}) as any;
|
||||||
|
|
||||||
watcher
|
watcher
|
||||||
.on('add', (path) => linkToNodeModule(src))
|
.on('add', (_path: string) => linkToNodeModule(src))
|
||||||
.on('change', (path) => linkToNodeModule(src));
|
.on('change', (_path: string) => linkToNodeModule(src));
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -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 { parseExpression } from 'cron-parser';
|
||||||
import {
|
import {
|
||||||
getFileContentByName,
|
getFileContentByName,
|
||||||
fileExist,
|
fileExist,
|
||||||
|
|
@ -670,7 +670,7 @@ export default class CronService {
|
||||||
if (
|
if (
|
||||||
command &&
|
command &&
|
||||||
schedule &&
|
schedule &&
|
||||||
cron_parser.parseExpression(schedule).hasNext()
|
parseExpression(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 { parseExpression } from 'cron-parser';
|
||||||
import { ScheduleType } from '../interface/schedule';
|
import { ScheduleType } from '../interface/schedule';
|
||||||
|
|
||||||
const validateSchedule = (value: string, helpers: any) => {
|
const validateSchedule = (value: string, helpers: any) => {
|
||||||
|
|
@ -11,7 +11,7 @@ const validateSchedule = (value: string, helpers: any) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (cron_parser.parseExpression(value).hasNext()) {
|
if (parseExpression(value).hasNext()) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
||||||
|
|
@ -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 { parseExpression } from 'cron-parser';
|
||||||
import isNil from 'lodash/isNil';
|
import isNil from 'lodash/isNil';
|
||||||
|
|
||||||
const { Option } = Select;
|
const { Option } = Select;
|
||||||
|
|
@ -381,7 +381,7 @@ const SubscriptionModal = ({
|
||||||
if (
|
if (
|
||||||
scheduleType === 'interval' ||
|
scheduleType === 'interval' ||
|
||||||
!value ||
|
!value ||
|
||||||
cron_parser.parseExpression(value).hasNext()
|
parseExpression(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 { parseExpression } from 'cron-parser';
|
||||||
import { ICrontab } from '@/pages/crontab/type';
|
import { ICrontab } from '@/pages/crontab/type';
|
||||||
|
|
||||||
export default function browserType() {
|
export default function browserType() {
|
||||||
|
|
@ -333,7 +333,7 @@ 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 = parseExpression(schedule);
|
||||||
if (time) {
|
if (time) {
|
||||||
return time.next().toDate();
|
return time.next().toDate();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user