@microlight/core 0.2.0 → 0.3.0
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.
|
@@ -7,11 +7,11 @@ async function getFolderDetails({
|
|
|
7
7
|
params
|
|
8
8
|
}) {
|
|
9
9
|
const dir = params?.f_path?.join('/') || '';
|
|
10
|
-
console.log('\n\n\n\n======');
|
|
11
|
-
console.log("dir - ",
|
|
10
|
+
// console.log('\n\n\n\n======');
|
|
11
|
+
// console.log("dir - ",dir);
|
|
12
12
|
let folderConfig = {};
|
|
13
13
|
folderConfig = folderMap[dir];
|
|
14
|
-
console.log(folderConfig);
|
|
14
|
+
// console.log(folderConfig);
|
|
15
15
|
// console.log('\n\n\n\n\n===========');
|
|
16
16
|
// console.log(dir)
|
|
17
17
|
// console.log(folderMap)
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
export const register = async () => {
|
|
2
2
|
if (process.env.NEXT_RUNTIME === 'nodejs') {
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
//
|
|
9
|
-
//
|
|
3
|
+
// Dynamically import loadSchedules only when we're in Node.js runtime
|
|
4
|
+
const {
|
|
5
|
+
default: loadSchedules
|
|
6
|
+
} = await import("./lib/loadSchedules");
|
|
7
|
+
await loadSchedules();
|
|
8
|
+
// const interval = setInterval(async () => {
|
|
9
|
+
// await executeRuns();
|
|
10
|
+
// console.log('Instrumentation check running...');
|
|
11
|
+
// }, 5000);
|
|
10
12
|
|
|
11
|
-
//
|
|
13
|
+
// Clean up interval on process exit
|
|
12
14
|
process.on('SIGTERM', () => {
|
|
13
15
|
clearInterval(interval);
|
|
14
16
|
});
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import cron from "node-cron";
|
|
2
|
-
import
|
|
2
|
+
import taskMap from "../../taskMap";
|
|
3
3
|
import async from 'async';
|
|
4
4
|
import executeRun from "./executeRun";
|
|
5
5
|
import microlightDB from "../database/microlight";
|
|
6
|
-
import tasks from "../tasks";
|
|
7
6
|
async function executeTask({
|
|
8
7
|
inputs,
|
|
9
8
|
task
|
|
@@ -40,9 +39,9 @@ async function executeTask({
|
|
|
40
39
|
}
|
|
41
40
|
}
|
|
42
41
|
export default async function loadSchedules() {
|
|
43
|
-
// const tasks = await getAllTasks();
|
|
44
42
|
let schedules = [];
|
|
45
|
-
|
|
43
|
+
Object.keys(taskMap).forEach(function (task_slug) {
|
|
44
|
+
const task = taskMap[task_slug];
|
|
46
45
|
// Check if task has schedules
|
|
47
46
|
if (task.is_enabled && task.schedules && Array.isArray(task.schedules)) {
|
|
48
47
|
task.schedules.forEach(scheduleConfig => {
|
|
@@ -50,7 +49,7 @@ export default async function loadSchedules() {
|
|
|
50
49
|
// Create cron job
|
|
51
50
|
const job = cron.schedule(scheduleConfig.schedule, async () => {
|
|
52
51
|
try {
|
|
53
|
-
console.log('trigger the task')
|
|
52
|
+
// console.log('trigger the task')
|
|
54
53
|
// Execute task with schedule-specific inputs
|
|
55
54
|
await executeTask({
|
|
56
55
|
inputs: scheduleConfig.inputs || {},
|
|
@@ -71,7 +70,7 @@ export default async function loadSchedules() {
|
|
|
71
70
|
});
|
|
72
71
|
}
|
|
73
72
|
});
|
|
74
|
-
console.log('Count of schedules :'
|
|
75
|
-
console.log(schedules);
|
|
73
|
+
// console.log('Count of schedules :'+schedules.length);
|
|
74
|
+
// console.log(schedules);
|
|
76
75
|
return schedules;
|
|
77
76
|
}
|
package/package.json
CHANGED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { glob } from 'glob';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { fileURLToPath } from 'url';
|
|
4
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
5
|
-
const __dirname = path.dirname(__filename);
|
|
6
|
-
console.log(__filename);
|
|
7
|
-
console.log(__dirname);
|
|
8
|
-
|
|
9
|
-
// Find all task files and folder files
|
|
10
|
-
const taskFiles = glob.sync(['**/*.task.js', '**/microlight.folder.js'], {
|
|
11
|
-
cwd: __dirname,
|
|
12
|
-
absolute: true
|
|
13
|
-
});
|
|
14
|
-
console.log(taskFiles);
|
|
15
|
-
|
|
16
|
-
// Import all task files dynamically
|
|
17
|
-
const tasks = await Promise.all(taskFiles.map(async filePath => {
|
|
18
|
-
const task = await import(filePath);
|
|
19
|
-
const taskName = path.basename(filePath, '.task.js');
|
|
20
|
-
// return [taskName, task.default];
|
|
21
|
-
return [task?.default?.slug, {
|
|
22
|
-
...task?.default,
|
|
23
|
-
...{
|
|
24
|
-
file_name: taskName
|
|
25
|
-
}
|
|
26
|
-
}];
|
|
27
|
-
}));
|
|
28
|
-
console.log(tasks);
|
|
29
|
-
|
|
30
|
-
// Convert array of entries to an object
|
|
31
|
-
const taskMap = Object.fromEntries(tasks);
|
|
32
|
-
console.log(taskMap);
|
|
33
|
-
export default taskMap;
|