@microlight/core 0.2.0 → 0.4.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 - ", 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)
@@ -29,7 +29,7 @@ export async function executeTask({
29
29
  };
30
30
  try {
31
31
  const results = await async.auto(workflow);
32
- console.log(results);
32
+ // console.log(results);
33
33
  revalidatePath(`/tasks/${task.slug}`);
34
34
  return {
35
35
  success: true,
@@ -1,14 +1,16 @@
1
1
  export const register = async () => {
2
2
  if (process.env.NEXT_RUNTIME === 'nodejs') {
3
- // // Dynamically import loadSchedules only when we're in Node.js runtime
4
- // const { default: loadSchedules } = await import('./lib/loadSchedules');
5
- // await loadSchedules();
6
- // // const interval = setInterval(async () => {
7
- // // await executeRuns();
8
- // // console.log('Instrumentation check running...');
9
- // // }, 5000);
3
+ // Dynamically import loadSchedules only when we're in Node.js runtime
4
+ const {
5
+ 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
- // // Clean up interval on process exit
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 getAllTasks from "./getAllTasks";
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
@@ -39,18 +38,20 @@ async function executeTask({
39
38
  };
40
39
  }
41
40
  }
42
- export default async function loadSchedules() {
43
- // const tasks = await getAllTasks();
41
+ export async function loadSchedules() {
44
42
  let schedules = [];
45
- tasks.forEach(function (task) {
43
+ Object.keys(taskMap).forEach(function (task_slug) {
44
+ const task = taskMap[task_slug];
45
+
46
46
  // Check if task has schedules
47
47
  if (task.is_enabled && task.schedules && Array.isArray(task.schedules)) {
48
+ // console.log(task);
48
49
  task.schedules.forEach(scheduleConfig => {
49
50
  if (scheduleConfig.is_enabled && scheduleConfig.schedule) {
50
51
  // Create cron job
51
52
  const job = cron.schedule(scheduleConfig.schedule, async () => {
52
53
  try {
53
- console.log('trigger the task');
54
+ // console.log('trigger the task')
54
55
  // Execute task with schedule-specific inputs
55
56
  await executeTask({
56
57
  inputs: scheduleConfig.inputs || {},
@@ -72,6 +73,6 @@ export default async function loadSchedules() {
72
73
  }
73
74
  });
74
75
  console.log('Count of schedules :' + schedules.length);
75
- console.log(schedules);
76
+ // console.log(schedules);
76
77
  return schedules;
77
78
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microlight/core",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "scripts": {
@@ -35,6 +35,7 @@
35
35
  "next": "15.1.4",
36
36
  "next-nprogress-bar": "^2.4.3",
37
37
  "node-cron": "^3.0.3",
38
+ "package-up": "^5.0.0",
38
39
  "pg": "^8.13.1",
39
40
  "pg-hstore": "^2.3.4",
40
41
  "react": "^19.0.0",
@@ -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;