@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 CHANGED
@@ -17,7 +17,7 @@ yarn add @codenameryuu/adonis-scheduler
17
17
  * Add the package to the `adonisrc.ts` file
18
18
 
19
19
  ```bash
20
- node ace add @codenameryuu/adonis-scheduler
20
+ node ace configure @codenameryuu/adonis-scheduler
21
21
  ```
22
22
 
23
23
  ## Running The Scheduler
@@ -1,9 +1,9 @@
1
1
  import type { ApplicationService } from "@adonisjs/core/types";
2
- import cron from "node-cron";
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: cron.ScheduledTask[];
6
+ tasks: ScheduledTask[];
7
7
  loaders: any[];
8
8
  booted: boolean;
9
9
  kernel: Kernel;
@@ -52,7 +52,10 @@ export class Worker {
52
52
  if (command.config.tag !== tag) {
53
53
  continue;
54
54
  }
55
- this.tasks.push(cron.schedule(command.expression, async () => {
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
- scheduled: command.config.enabled,
98
- timezone: command.config.timezone,
99
- runOnInit: command.config.enabled && command.config.immediate,
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
- "name": "@codenameryuu/adonis-scheduler",
3
- "description": "A task scheduler for AdonisJS",
4
- "version": "1.0.1",
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": "^1.2.1",
38
- "@japa/assert": "^4.0.0",
39
- "@japa/runner": "^3.1.4",
40
- "@swc/core": "^1.3.102",
41
- "@types/async-lock": "^1.4.2",
42
- "@types/luxon": "^3.4.2",
43
- "@types/node": "^22.10.1",
44
- "@types/node-cron": "^3.0.7",
45
- "copyfiles": "^2.4.1",
46
- "prettier": "^2.7.1",
47
- "rimraf": "^3.0.2",
48
- "ts-node-maintained": "^10.9.4",
49
- "typescript": "^5.3.3"
50
- },
51
- "dependencies": {
52
- "async-lock": "^1.4.1",
53
- "chokidar": "^4.0.2",
54
- "cron-parser": "^5.0.4",
55
- "luxon": "^3.5.0",
56
- "node-cron": "^3.0.2",
57
- "string-width": "^7.2.0"
58
- },
59
- "peerDependencies": {
60
- "@adonisjs/core": "^7.0.0"
61
- },
62
- "keywords": [
63
- "adonis",
64
- "scheduler"
65
- ],
66
- "prettier": "@adonisjs/prettier-config",
67
- "publishConfig": {
68
- "tag": "latest",
69
- "access": "public"
70
- },
71
- "main": "build/providers/scheduler_provider.js"
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
+ }