diff --git a/back/api/subscription.ts b/back/api/subscription.ts index 85587a16..bc7e70ce 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 { parseExpression } 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() + parseExpression(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() + parseExpression(req.body.schedule).hasNext() ) { const subscriptionService = Container.get(SubscriptionService); const data = await subscriptionService.update(req.body); diff --git a/back/loaders/deps.ts b/back/loaders/deps.ts index 767b9dfd..8f2c788e 100644 --- a/back/loaders/deps.ts +++ b/back/loaders/deps.ts @@ -1,6 +1,6 @@ import path from 'path'; import fs from 'fs/promises'; -import chokidar from 'chokidar'; +import chokidar, { FSWatcher } from 'chokidar'; import config from '../config/index'; import { fileExist, promiseExec, rmPath } from '../config/util'; @@ -55,9 +55,9 @@ export default async (src: string = 'deps') => { const watcher = chokidar.watch(source, { ignored: /(^|[\/\\])\../, // ignore dotfiles persistent: true, - }); + }) as any; watcher - .on('add', (path) => linkToNodeModule(src)) - .on('change', (path) => linkToNodeModule(src)); + .on('add', (_path: string) => linkToNodeModule(src)) + .on('change', (_path: string) => linkToNodeModule(src)); }; diff --git a/back/services/cron.ts b/back/services/cron.ts index a838ce9e..3353efd4 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 { parseExpression } from 'cron-parser'; import { getFileContentByName, fileExist, @@ -670,7 +670,7 @@ export default class CronService { if ( command && schedule && - cron_parser.parseExpression(schedule).hasNext() + parseExpression(schedule).hasNext() ) { const name = namePrefix + '_' + index; diff --git a/back/validation/schedule.ts b/back/validation/schedule.ts index a280156a..6556497f 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 { parseExpression } from 'cron-parser'; import { ScheduleType } from '../interface/schedule'; const validateSchedule = (value: string, helpers: any) => { @@ -11,7 +11,7 @@ const validateSchedule = (value: string, helpers: any) => { } try { - if (cron_parser.parseExpression(value).hasNext()) { + if (parseExpression(value).hasNext()) { return value; } } catch (e) { diff --git a/src/pages/subscription/modal.tsx b/src/pages/subscription/modal.tsx index 332d61c4..cbf891f3 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 { parseExpression } from 'cron-parser'; import isNil from 'lodash/isNil'; const { Option } = Select; @@ -381,7 +381,7 @@ const SubscriptionModal = ({ if ( scheduleType === 'interval' || !value || - cron_parser.parseExpression(value).hasNext() + parseExpression(value).hasNext() ) { return Promise.resolve(); } else { diff --git a/src/utils/index.ts b/src/utils/index.ts index 381a7337..7a864dfc 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 { parseExpression } from 'cron-parser'; import { ICrontab } from '@/pages/crontab/type'; export default function browserType() { @@ -333,7 +333,7 @@ export function getCommandScript( export function parseCrontab(schedule: string): Date | null { try { - const time = cron_parser.parseExpression(schedule); + const time = parseExpression(schedule); if (time) { return time.next().toDate(); }