@codenameryuu/adonis-scheduler 1.0.1 → 1.0.4
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/README.md +1 -1
- package/build/src/worker.d.ts +2 -2
- package/build/src/worker.js +10 -6
- package/package.json +70 -71
package/README.md
CHANGED
package/build/src/worker.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { ApplicationService } from "@adonisjs/core/types";
|
|
2
|
-
import
|
|
2
|
+
import type { ScheduledTask } from "node-cron";
|
|
3
3
|
import { Kernel } from "@adonisjs/core/ace";
|
|
4
4
|
export declare class Worker {
|
|
5
5
|
app: ApplicationService;
|
|
6
|
-
tasks:
|
|
6
|
+
tasks: ScheduledTask[];
|
|
7
7
|
loaders: any[];
|
|
8
8
|
booted: boolean;
|
|
9
9
|
kernel: Kernel;
|
package/build/src/worker.js
CHANGED
|
@@ -52,7 +52,10 @@ export class Worker {
|
|
|
52
52
|
if (command.config.tag !== tag) {
|
|
53
53
|
continue;
|
|
54
54
|
}
|
|
55
|
-
|
|
55
|
+
const taskOptions = {
|
|
56
|
+
timezone: command.config.timezone,
|
|
57
|
+
};
|
|
58
|
+
const runTask = async () => {
|
|
56
59
|
try {
|
|
57
60
|
switch (command.type) {
|
|
58
61
|
case "command":
|
|
@@ -93,11 +96,12 @@ export class Worker {
|
|
|
93
96
|
catch (error) {
|
|
94
97
|
logger.error(error);
|
|
95
98
|
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
99
|
+
};
|
|
100
|
+
const task = command.config.enabled ? cron.schedule(command.expression, runTask, taskOptions) : cron.createTask(command.expression, runTask, taskOptions);
|
|
101
|
+
if (command.config.enabled && command.config.immediate) {
|
|
102
|
+
void task.execute();
|
|
103
|
+
}
|
|
104
|
+
this.tasks.push(task);
|
|
101
105
|
}
|
|
102
106
|
logger.info(`[${tag}] Schedule worker started successfully.`);
|
|
103
107
|
if (schedule.onStartedCallback) {
|
package/package.json
CHANGED
|
@@ -1,72 +1,71 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
2
|
+
"name": "@codenameryuu/adonis-scheduler",
|
|
3
|
+
"description": "A task scheduler for AdonisJS",
|
|
4
|
+
"version": "1.0.4",
|
|
5
|
+
"author": "codenameryuu",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"homepage": "https://github.com/codenameryuu/adonis-scheduler#readme",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/codenameryuu/adonis-scheduler.git"
|
|
11
|
+
},
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=24.0.0"
|
|
14
|
+
},
|
|
15
|
+
"type": "module",
|
|
16
|
+
"files": [
|
|
17
|
+
"build"
|
|
18
|
+
],
|
|
19
|
+
"exports": {
|
|
20
|
+
".": "./build/index.js",
|
|
21
|
+
"./services/main": "./build/services/main.js",
|
|
22
|
+
"./scheduler_provider": "./build/providers/scheduler_provider.js",
|
|
23
|
+
"./commands": "./build/commands/main.js"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "npm run clean && npm run build-only && npm run copyfiles",
|
|
27
|
+
"copyfiles": "copyfiles \"stubs/**/*.stub\" build",
|
|
28
|
+
"build-only": "tsc && npm run index:commands",
|
|
29
|
+
"clean": "rimraf build",
|
|
30
|
+
"prepublishOnly": "npm run build",
|
|
31
|
+
"index:commands": "adonis-kit index build/commands",
|
|
32
|
+
"test": "node --enable-source-maps --import=ts-node-maintained/register/esm bin/test.ts"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@adonisjs/core": "^7.0.0",
|
|
36
|
+
"@adonisjs/prettier-config": "^1.2.1",
|
|
37
|
+
"@adonisjs/tsconfig": "^2.0.0",
|
|
38
|
+
"@japa/assert": "^4.0.0",
|
|
39
|
+
"@japa/runner": "^5.3.0",
|
|
40
|
+
"@swc/core": "^1.3.102",
|
|
41
|
+
"@types/async-lock": "^1.4.2",
|
|
42
|
+
"@types/luxon": "^3.4.2",
|
|
43
|
+
"@types/node": "^26.0.1",
|
|
44
|
+
"copyfiles": "^2.4.1",
|
|
45
|
+
"prettier": "^3.9.1",
|
|
46
|
+
"rimraf": "^6.1.3",
|
|
47
|
+
"ts-node-maintained": "^10.9.4",
|
|
48
|
+
"typescript": "^6.0.3"
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"async-lock": "^1.4.1",
|
|
52
|
+
"chokidar": "^5.0.0",
|
|
53
|
+
"cron-parser": "^5.0.4",
|
|
54
|
+
"luxon": "^3.5.0",
|
|
55
|
+
"node-cron": "^4.5.0",
|
|
56
|
+
"string-width": "^8.2.1"
|
|
57
|
+
},
|
|
58
|
+
"peerDependencies": {
|
|
59
|
+
"@adonisjs/core": "^7.0.0"
|
|
60
|
+
},
|
|
61
|
+
"keywords": [
|
|
62
|
+
"adonis",
|
|
63
|
+
"scheduler"
|
|
64
|
+
],
|
|
65
|
+
"prettier": "@adonisjs/prettier-config",
|
|
66
|
+
"publishConfig": {
|
|
67
|
+
"tag": "latest",
|
|
68
|
+
"access": "public"
|
|
69
|
+
},
|
|
70
|
+
"main": "build/providers/scheduler_provider.js"
|
|
71
|
+
}
|