@aomex/cron 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 geekact
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,52 @@
1
+ import { ConsoleChain, ConsoleMiddleware } from '@aomex/console';
2
+ import { PathToFileOptions } from '@aomex/file-parser';
3
+
4
+ interface CronOptions {
5
+ paths: PathToFileOptions;
6
+ /**
7
+ * 同一个任务的触发模式:
8
+ * - overlap 重叠模式。时间满足就执行,有可能与上一次任务重叠(默认)
9
+ * - sequence 顺序模式。当前任务需等待上一次执行结束
10
+ */
11
+ mode?: 'overlap' | 'sequence';
12
+ }
13
+ declare const cron: (options: CronOptions) => ConsoleChain;
14
+
15
+ interface ScheduleOptions {
16
+ /**
17
+ * 0-59
18
+ */
19
+ second?: string | number;
20
+ /**
21
+ * 0-59
22
+ */
23
+ minute?: string | number;
24
+ /**
25
+ * 0-23
26
+ */
27
+ hour?: string | number;
28
+ /**
29
+ * 1-31
30
+ */
31
+ dayOfMonth?: string | number;
32
+ /**
33
+ * 0-11
34
+ */
35
+ month?: string | number;
36
+ /**
37
+ * 0-6
38
+ */
39
+ dayOfWeek?: string | number;
40
+ args?: (string | number)[];
41
+ }
42
+ declare class ScheduleMiddleware extends ConsoleMiddleware<object> {
43
+ protected readonly options: ScheduleOptions;
44
+ constructor(options: ScheduleOptions);
45
+ get time(): string[];
46
+ get args(): string[];
47
+ get seconds(): number[];
48
+ toCrontab(command: string): string[];
49
+ }
50
+ declare const schedule: (options: ScheduleOptions) => ScheduleMiddleware;
51
+
52
+ export { CronOptions, ScheduleMiddleware, ScheduleOptions, cron, schedule };
package/dist/index.js ADDED
@@ -0,0 +1,297 @@
1
+ // src/cron.ts
2
+ import { chain as chain3 } from "@aomex/core";
3
+
4
+ // src/output.ts
5
+ import { options } from "@aomex/console";
6
+ import { Commander } from "@aomex/console-router";
7
+ import { Chain, chain, middleware as middleware2, rule } from "@aomex/core";
8
+ import {
9
+ fileToModules,
10
+ pathToFiles
11
+ } from "@aomex/file-parser";
12
+ import { chalk } from "@aomex/helper";
13
+ import { mkdir, writeFile } from "node:fs/promises";
14
+ import path, { dirname } from "node:path";
15
+
16
+ // src/output-to-help.ts
17
+ import { scriptName } from "@aomex/console";
18
+ import { middleware } from "@aomex/core";
19
+ var outputToHelp = (commandName) => middleware.help(async (ctx, next) => {
20
+ const { status, yargs } = ctx.cli;
21
+ switch (status) {
22
+ case "show-all":
23
+ yargs.command(commandName, "Create cron-compatibly list");
24
+ return next();
25
+ case "show-detail":
26
+ if (ctx.request.command !== commandName)
27
+ return next();
28
+ yargs.usage(`${scriptName} ${commandName} [options]`);
29
+ outputRule.toHelp(yargs);
30
+ ctx.response.commandMatched = true;
31
+ return;
32
+ default:
33
+ const _ = status;
34
+ assert(_);
35
+ }
36
+ });
37
+
38
+ // src/schedule.ts
39
+ import { ConsoleMiddleware, scriptName as scriptName2 } from "@aomex/console";
40
+ import parser from "cron-parser";
41
+ var ScheduleMiddleware = class extends ConsoleMiddleware {
42
+ constructor(options2) {
43
+ super(async (_, next) => next());
44
+ this.options = options2;
45
+ }
46
+ get time() {
47
+ const { options: opts } = this;
48
+ return [
49
+ opts.minute ?? "*",
50
+ opts.hour ?? "*",
51
+ opts.dayOfMonth ?? "*",
52
+ opts.month ?? "*",
53
+ opts.dayOfWeek ?? "*"
54
+ ].map(String);
55
+ }
56
+ get args() {
57
+ return (this.options.args || []).map(String);
58
+ }
59
+ get seconds() {
60
+ if (!this.options.second)
61
+ return [];
62
+ const seconds = [];
63
+ const interval = parser.parseExpression(`${this.options.second} * * * *`);
64
+ while (true) {
65
+ const second = interval.next().getMinutes();
66
+ if (seconds.includes(second))
67
+ break;
68
+ seconds.push(second);
69
+ }
70
+ return seconds.sort((a, b) => a - b);
71
+ }
72
+ toCrontab(command) {
73
+ const script = this.time;
74
+ const crons = [script];
75
+ for (const second of this.seconds) {
76
+ crons.push(script.concat(`sleep ${second};`));
77
+ }
78
+ return crons.map((item) => {
79
+ const args = this.args.map(
80
+ (value) => value.includes(" ") ? `"${value}"` : value
81
+ );
82
+ return item.concat(["npx", scriptName2, command, ...args]).join(" ");
83
+ });
84
+ }
85
+ };
86
+ var schedule = (options2) => new ScheduleMiddleware(options2);
87
+
88
+ // src/output.ts
89
+ var exportSchedule = "schedule:export";
90
+ var outputRule = options(
91
+ {
92
+ output: rule.string().optional().docs({
93
+ description: "Export to specific file"
94
+ })
95
+ },
96
+ {
97
+ output: ["o"]
98
+ }
99
+ );
100
+ var output = (paths) => chain.console.mount(outputToHelp(exportSchedule)).mount(outputRule).mount(
101
+ middleware2.console(
102
+ async (ctx, next) => {
103
+ if (ctx.request.command !== exportSchedule) {
104
+ Reflect.deleteProperty(ctx, "options");
105
+ return next();
106
+ }
107
+ ctx.response.commandMatched = true;
108
+ const files = await pathToFiles(paths);
109
+ const commanders = await fileToModules(
110
+ files,
111
+ (item) => !!item && item instanceof Commander
112
+ );
113
+ const crons = [];
114
+ for (const commander of commanders) {
115
+ for (const builder of Commander.getBuilders(commander)) {
116
+ for (const middleware5 of Chain.flatten(builder.chain)) {
117
+ if (middleware5 instanceof ScheduleMiddleware) {
118
+ crons.push(...middleware5.toCrontab(builder.commands[0]));
119
+ }
120
+ }
121
+ }
122
+ }
123
+ const { output: outputToFile } = ctx.options;
124
+ if (outputToFile) {
125
+ const file = path.resolve(outputToFile);
126
+ await mkdir(dirname(file), { recursive: true });
127
+ await writeFile(file, crons.join("\n"), {});
128
+ console.log(`Crontab has been created: ${chalk.blue(file)}`);
129
+ } else {
130
+ console.log(crons.join("\n"));
131
+ }
132
+ }
133
+ )
134
+ );
135
+
136
+ // src/run.ts
137
+ import { Commander as Commander2 } from "@aomex/console-router";
138
+ import { middleware as middleware4, Chain as Chain2, chain as chain2 } from "@aomex/core";
139
+ import {
140
+ pathToFiles as pathToFiles2,
141
+ fileToModules as fileToModules2
142
+ } from "@aomex/file-parser";
143
+
144
+ // src/run-to-help.ts
145
+ import { middleware as middleware3 } from "@aomex/core";
146
+ import { scriptName as scriptName3 } from "@aomex/console";
147
+ var runToHelp = (commandName) => middleware3.help(async (ctx, next) => {
148
+ const { status, yargs } = ctx.cli;
149
+ switch (status) {
150
+ case "show-all":
151
+ yargs.command(commandName, "Star cron");
152
+ return next();
153
+ case "show-detail":
154
+ if (ctx.request.command !== commandName)
155
+ return next();
156
+ yargs.usage(`${scriptName3} ${commandName} [options]
157
+ Schedule list:
158
+ `);
159
+ ctx.response.commandMatched = true;
160
+ return;
161
+ default:
162
+ const _ = status;
163
+ assert(_);
164
+ }
165
+ });
166
+
167
+ // src/cron-job.ts
168
+ import { fileURLToPath } from "node:url";
169
+ import { isMainThread, Worker } from "node:worker_threads";
170
+ import cronParser from "cron-parser";
171
+ import { sleep } from "@aomex/helper";
172
+ var CronJob = class {
173
+ constructor(app, schedule2, mode = "overlap") {
174
+ this.app = app;
175
+ this.schedule = schedule2;
176
+ this.mode = mode;
177
+ }
178
+ queue = 0;
179
+ async start() {
180
+ if (this.mode === "sequence")
181
+ this.sequenceLoop();
182
+ const {
183
+ schedule: { seconds }
184
+ } = this;
185
+ const cronExp = this.getCronExp();
186
+ while (true) {
187
+ const nextTime = cronExp.next();
188
+ await sleep(nextTime.getTime() - Date.now());
189
+ if (seconds.length) {
190
+ const nowSecond = nextTime.getSeconds();
191
+ seconds.forEach(async (expectedSecond) => {
192
+ const delay = expectedSecond - nowSecond;
193
+ if (delay >= 0) {
194
+ await sleep(delay * 1e3);
195
+ this.executeOrQueue();
196
+ }
197
+ });
198
+ } else {
199
+ this.executeOrQueue();
200
+ }
201
+ }
202
+ }
203
+ getCronExp() {
204
+ const {
205
+ schedule: { seconds, time }
206
+ } = this;
207
+ const now = /* @__PURE__ */ new Date();
208
+ if (seconds.length) {
209
+ now.setMinutes(now.getMinutes() - 1);
210
+ }
211
+ return cronParser.parseExpression(time, {
212
+ currentDate: now
213
+ });
214
+ }
215
+ executeOrQueue() {
216
+ if (this.mode === "sequence") {
217
+ ++this.queue;
218
+ } else {
219
+ this.execute();
220
+ }
221
+ }
222
+ async execute() {
223
+ if (isMainThread) {
224
+ await this.createWorker();
225
+ } else {
226
+ try {
227
+ await this.app.run(this.schedule.command, ...this.schedule.args);
228
+ } catch {
229
+ }
230
+ }
231
+ }
232
+ createWorker() {
233
+ const worker = new Worker(fileURLToPath(import.meta.url), {
234
+ stdout: true
235
+ });
236
+ return new Promise((resolve) => {
237
+ worker.on("exit", () => {
238
+ resolve(void 0);
239
+ });
240
+ });
241
+ }
242
+ sequenceLoop = () => {
243
+ if (this.queue > 0) {
244
+ --this.queue;
245
+ this.execute().finally(this.sequenceLoop);
246
+ } else {
247
+ setTimeout(this.sequenceLoop, 300);
248
+ }
249
+ };
250
+ };
251
+
252
+ // src/run.ts
253
+ var runSchedule = "schedule:run";
254
+ var run = ({ paths, mode }) => chain2.console.mount(runToHelp(runSchedule)).mount(
255
+ middleware4.console(async (ctx, next) => {
256
+ if (ctx.request.command !== runSchedule)
257
+ return next();
258
+ ctx.response.commandMatched = true;
259
+ const schedules = await getSchedules(paths);
260
+ schedules.forEach(async (schedule2) => {
261
+ const job = new CronJob(ctx.app, schedule2, mode);
262
+ await job.start();
263
+ });
264
+ })
265
+ );
266
+ var getSchedules = async (paths) => {
267
+ const files = await pathToFiles2(paths);
268
+ const commanders = await fileToModules2(
269
+ files,
270
+ (item) => !!item && item instanceof Commander2
271
+ );
272
+ const tasks = [];
273
+ for (const commander of commanders) {
274
+ for (const builder of Commander2.getBuilders(commander)) {
275
+ for (const middleware5 of Chain2.flatten(builder.chain)) {
276
+ if (middleware5 instanceof ScheduleMiddleware) {
277
+ tasks.push({
278
+ time: middleware5.time.join(" "),
279
+ seconds: middleware5.seconds,
280
+ command: builder.commands[0],
281
+ args: middleware5.args
282
+ });
283
+ }
284
+ }
285
+ }
286
+ }
287
+ return tasks;
288
+ };
289
+
290
+ // src/cron.ts
291
+ var cron = (options2) => chain3.console.mount(run(options2)).mount(output(options2.paths));
292
+ export {
293
+ ScheduleMiddleware,
294
+ cron,
295
+ schedule
296
+ };
297
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/cron.ts","../src/output.ts","../src/output-to-help.ts","../src/schedule.ts","../src/run.ts","../src/run-to-help.ts","../src/cron-job.ts"],"sourcesContent":["import type { ConsoleChain } from '@aomex/console';\nimport { chain } from '@aomex/core';\nimport type { PathToFileOptions } from '@aomex/file-parser';\nimport { output } from './output';\nimport { run } from './run';\n\nexport interface CronOptions {\n paths: PathToFileOptions;\n /**\n * 同一个任务的触发模式:\n * - overlap 重叠模式。时间满足就执行,有可能与上一次任务重叠(默认)\n * - sequence 顺序模式。当前任务需等待上一次执行结束\n */\n mode?: 'overlap' | 'sequence';\n}\n\nexport const cron = (options: CronOptions): ConsoleChain =>\n chain.console.mount(run(options)).mount(output(options.paths));\n","import { options } from '@aomex/console';\nimport { Commander } from '@aomex/console-router';\nimport { Chain, chain, Middleware, middleware, rule } from '@aomex/core';\nimport {\n fileToModules,\n PathToFileOptions,\n pathToFiles,\n} from '@aomex/file-parser';\nimport { chalk } from '@aomex/helper';\nimport { mkdir, writeFile } from 'node:fs/promises';\nimport path, { dirname } from 'node:path';\nimport { outputToHelp } from './output-to-help';\nimport { ScheduleMiddleware } from './schedule';\n\nconst exportSchedule = 'schedule:export';\n\nexport const outputRule = options(\n {\n output: rule.string().optional().docs({\n description: 'Export to specific file',\n }),\n },\n {\n output: ['o'],\n },\n);\n\nexport const output = (paths: PathToFileOptions) =>\n chain.console\n .mount(outputToHelp(exportSchedule))\n .mount(outputRule)\n .mount(\n middleware.console<Middleware.Infer<typeof outputRule>>(\n async (ctx, next) => {\n if (ctx.request.command !== exportSchedule) {\n Reflect.deleteProperty(ctx, 'options');\n return next();\n }\n\n ctx.response.commandMatched = true;\n const files = await pathToFiles(paths);\n const commanders = await fileToModules<Commander>(\n files,\n (item) => !!item && item instanceof Commander,\n );\n\n const crons: string[] = [];\n for (const commander of commanders) {\n for (const builder of Commander.getBuilders(commander)) {\n for (const middleware of Chain.flatten(builder.chain)) {\n if (middleware instanceof ScheduleMiddleware) {\n crons.push(...middleware.toCrontab(builder.commands[0]!));\n }\n }\n }\n }\n\n const { output: outputToFile } = ctx.options;\n if (outputToFile) {\n const file = path.resolve(outputToFile);\n await mkdir(dirname(file), { recursive: true });\n await writeFile(file, crons.join('\\n'), {});\n console.log(`Crontab has been created: ${chalk.blue(file)}`);\n } else {\n console.log(crons.join('\\n'));\n }\n },\n ),\n );\n","import { HelpMiddleware, scriptName } from '@aomex/console';\nimport { middleware } from '@aomex/core';\nimport { outputRule } from './output';\n\nexport const outputToHelp = (commandName: string): HelpMiddleware =>\n middleware.help(async (ctx, next) => {\n const { status, yargs } = ctx.cli;\n switch (status) {\n case 'show-all':\n yargs.command(commandName, 'Create cron-compatibly list');\n return next();\n case 'show-detail':\n if (ctx.request.command !== commandName) return next();\n yargs.usage(`${scriptName} ${commandName} [options]`);\n outputRule.toHelp(yargs);\n ctx.response.commandMatched = true;\n return;\n default:\n const _: never = status;\n assert(_);\n }\n });\n","import { ConsoleMiddleware, scriptName } from '@aomex/console';\nimport parser from 'cron-parser';\n\nexport interface ScheduleOptions {\n /**\n * 0-59\n */\n second?: string | number;\n /**\n * 0-59\n */\n minute?: string | number;\n /**\n * 0-23\n */\n hour?: string | number;\n /**\n * 1-31\n */\n dayOfMonth?: string | number;\n /**\n * 0-11\n */\n month?: string | number;\n /**\n * 0-6\n */\n dayOfWeek?: string | number;\n args?: (string | number)[];\n}\n\nexport class ScheduleMiddleware extends ConsoleMiddleware<object> {\n constructor(protected readonly options: ScheduleOptions) {\n super(async (_, next) => next());\n }\n\n public get time(): string[] {\n const { options: opts } = this;\n return [\n opts.minute ?? '*',\n opts.hour ?? '*',\n opts.dayOfMonth ?? '*',\n opts.month ?? '*',\n opts.dayOfWeek ?? '*',\n ].map(String);\n }\n\n public get args() {\n return (this.options.args || []).map(String);\n }\n\n public get seconds(): number[] {\n if (!this.options.second) return [];\n const seconds: number[] = [];\n // second and minute are both 0-59\n const interval = parser.parseExpression(`${this.options.second} * * * *`);\n while (true) {\n const second = interval.next().getMinutes();\n if (seconds.includes(second)) break;\n seconds.push(second);\n }\n return seconds.sort((a, b) => a - b);\n }\n\n public toCrontab(command: string): string[] {\n const script = this.time;\n const crons: string[][] = [script];\n for (const second of this.seconds) {\n crons.push(script.concat(`sleep ${second};`));\n }\n return crons.map((item) => {\n const args = this.args.map((value) =>\n value.includes(' ') ? `\"${value}\"` : value,\n );\n return item.concat(['npx', scriptName, command, ...args]).join(' ');\n });\n }\n}\n\nexport const schedule = (options: ScheduleOptions): ScheduleMiddleware =>\n new ScheduleMiddleware(options);\n","import { Commander } from '@aomex/console-router';\nimport { middleware, Chain, chain } from '@aomex/core';\nimport {\n pathToFiles,\n fileToModules,\n PathToFileOptions,\n} from '@aomex/file-parser';\nimport { ScheduleMiddleware } from './schedule';\nimport { runToHelp } from './run-to-help';\nimport type { CronOptions } from './cron';\nimport { CronJob, CronJobOptions } from './cron-job';\n\nconst runSchedule = 'schedule:run';\n\nexport const run = ({ paths, mode }: CronOptions) =>\n chain.console.mount(runToHelp(runSchedule)).mount(\n middleware.console(async (ctx, next) => {\n if (ctx.request.command !== runSchedule) return next();\n ctx.response.commandMatched = true;\n const schedules = await getSchedules(paths);\n schedules.forEach(async (schedule) => {\n const job = new CronJob(ctx.app, schedule, mode);\n await job.start();\n });\n }),\n );\n\nexport const getSchedules = async (\n paths: PathToFileOptions,\n): Promise<CronJobOptions[]> => {\n const files = await pathToFiles(paths);\n const commanders = await fileToModules<Commander>(\n files,\n (item) => !!item && item instanceof Commander,\n );\n const tasks: CronJobOptions[] = [];\n\n for (const commander of commanders) {\n for (const builder of Commander.getBuilders(commander)) {\n for (const middleware of Chain.flatten(builder.chain)) {\n if (middleware instanceof ScheduleMiddleware) {\n tasks.push({\n time: middleware.time.join(' '),\n seconds: middleware.seconds,\n command: builder.commands[0]!,\n args: middleware.args,\n });\n }\n }\n }\n }\n\n return tasks;\n};\n","import { middleware } from '@aomex/core';\nimport { HelpMiddleware, scriptName } from '@aomex/console';\n\nexport const runToHelp = (commandName: string): HelpMiddleware =>\n middleware.help(async (ctx, next) => {\n const { status, yargs } = ctx.cli;\n switch (status) {\n case 'show-all':\n yargs.command(commandName, 'Star cron');\n return next();\n case 'show-detail':\n if (ctx.request.command !== commandName) return next();\n yargs.usage(`${scriptName} ${commandName} [options]\\nSchedule list:\\n`);\n ctx.response.commandMatched = true;\n return;\n default:\n const _: never = status;\n assert(_);\n }\n });\n","import type { ConsoleApp } from '@aomex/console';\nimport { fileURLToPath } from 'node:url';\nimport { isMainThread, Worker } from 'node:worker_threads';\nimport cronParser from 'cron-parser';\nimport type { CronOptions } from './cron';\nimport { sleep } from '@aomex/helper';\n\nexport interface CronJobOptions {\n time: string;\n seconds: number[];\n args: string[];\n command: string;\n}\n\nexport class CronJob {\n public queue: number = 0;\n\n constructor(\n protected readonly app: ConsoleApp,\n protected readonly schedule: CronJobOptions,\n protected readonly mode: CronOptions['mode'] = 'overlap',\n ) {}\n\n async start(): Promise<void> {\n if (this.mode === 'sequence') this.sequenceLoop();\n\n const {\n schedule: { seconds },\n } = this;\n const cronExp = this.getCronExp();\n\n while (true) {\n const nextTime = cronExp.next();\n await sleep(nextTime.getTime() - Date.now());\n if (seconds.length) {\n const nowSecond = nextTime.getSeconds();\n seconds.forEach(async (expectedSecond) => {\n const delay = expectedSecond - nowSecond;\n if (delay >= 0) {\n await sleep(delay * 1000);\n this.executeOrQueue();\n }\n });\n } else {\n this.executeOrQueue();\n }\n }\n }\n\n getCronExp() {\n const {\n schedule: { seconds, time },\n } = this;\n const now = new Date();\n if (seconds.length) {\n now.setMinutes(now.getMinutes() - 1);\n }\n return cronParser.parseExpression(time, {\n currentDate: now,\n });\n }\n\n executeOrQueue() {\n if (this.mode === 'sequence') {\n ++this.queue;\n } else {\n this.execute();\n }\n }\n\n async execute() {\n if (isMainThread) {\n await this.createWorker();\n } else {\n try {\n await this.app.run(this.schedule.command, ...this.schedule.args);\n } catch {}\n }\n }\n\n createWorker(): Promise<void> {\n const worker = new Worker(fileURLToPath(import.meta.url), {\n stdout: true,\n });\n return new Promise((resolve) => {\n worker.on('exit', () => {\n resolve(void 0);\n });\n });\n }\n\n sequenceLoop = () => {\n if (this.queue > 0) {\n --this.queue;\n this.execute().finally(this.sequenceLoop);\n } else {\n setTimeout(this.sequenceLoop, 300);\n }\n };\n}\n"],"mappings":";AACA,SAAS,SAAAA,cAAa;;;ACDtB,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAC1B,SAAS,OAAO,OAAmB,cAAAC,aAAY,YAAY;AAC3D;AAAA,EACE;AAAA,EAEA;AAAA,OACK;AACP,SAAS,aAAa;AACtB,SAAS,OAAO,iBAAiB;AACjC,OAAO,QAAQ,eAAe;;;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A,EACtC;AACA,QAAM,QAA0B,CAAC;AAEjC,aAAW,aAAa,YAAY;AAClC,eAAW,WAAWA,WAAU,YAAY,SAAS,GAAG;AACtD,iBAAWJ,eAAcK,OAAM,QAAQ,QAAQ,KAAK,GAAG;AACrD,YAAIL,uBAAsB,oBAAoB;AAC5C,gBAAM,KAAK;AAAA,YACT,MAAMA,YAAW,KAAK,KAAK,GAAG;AAAA,YAC9B,SAASA,YAAW;AAAA,YACpB,SAAS,QAAQ,SAAS,CAAC;AAAA,YAC3B,MAAMA,YAAW;AAAA,UACnB,CAAC;AAAA,QACH;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;;;AJrCO,IAAM,OAAO,CAACM,aACnBC,OAAM,QAAQ,MAAM,IAAID,QAAO,CAAC,EAAE,MAAM,OAAOA,SAAQ,KAAK,CAAC;","names":["chain","middleware","scriptName","options","middleware","Commander","middleware","Chain","chain","pathToFiles","fileToModules","middleware","scriptName","schedule","chain","middleware","schedule","pathToFiles","fileToModules","Commander","Chain","options","chain"]}
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@aomex/cron",
3
+ "version": "0.0.2",
4
+ "description": "",
5
+ "type": "module",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.js"
11
+ },
12
+ "./package.json": "./package.json"
13
+ },
14
+ "publishConfig": {
15
+ "access": "public"
16
+ },
17
+ "files": [
18
+ "dist",
19
+ "LICENSE",
20
+ "package.json",
21
+ "README.md",
22
+ "CHANGELOG.md"
23
+ ],
24
+ "keywords": [],
25
+ "repository": "git@github.com:aomex/aomex.git",
26
+ "homepage": "https://aomex.js.org",
27
+ "license": "MIT",
28
+ "peerDependencies": {
29
+ "@aomex/console": "^0.0.5",
30
+ "@aomex/console-router": "^0.0.5",
31
+ "@aomex/core": "^0.0.5"
32
+ },
33
+ "dependencies": {
34
+ "@aomex/file-parser": "^0.0.2",
35
+ "@aomex/helper": "^0.0.3",
36
+ "cron-parser": "^4.7.1"
37
+ },
38
+ "devDependencies": {
39
+ "@aomex/console": "^0.0.5",
40
+ "@aomex/console-router": "^0.0.5",
41
+ "@aomex/core": "^0.0.5"
42
+ },
43
+ "scripts": {}
44
+ }