thinkncollab-cli 0.0.53 → 0.0.55

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/bin/index.js CHANGED
@@ -13,7 +13,7 @@ import whoami from "../commands/whoami.js";
13
13
  import help from "../commands/help.js";
14
14
  import version from "../commands/version.js";
15
15
  import createBranch from "../commands/branch.js"
16
- import MyTasks from "../commands/myTask.js"
16
+ import myTask from "../commands/myTask.js"
17
17
 
18
18
 
19
19
 
@@ -502,15 +502,14 @@ async function main() {
502
502
  await version();
503
503
  break;
504
504
 
505
- case "my-tasks":{
505
+ case "my-tasks": {
506
+ const roomIdx = args.indexOf("my-tasks");
507
+ const roomId = args[roomIdx + 1]; // fixed typo
506
508
 
507
-
508
- const roomIdx = args.indexOf("my-tasks");
509
- const roomId = agrs[roomIdx+1];
509
+ await myTask(roomId); // match function name
510
+ break;
511
+ }
510
512
 
511
- await MyTasks(roomId);
512
- break;
513
- }
514
513
  default:
515
514
  console.log("✅ TNC CLI ready!");
516
515
  console.log("Commands:");
@@ -1,25 +1,49 @@
1
- import fs from "fs"
2
- import axios from "axios"
3
- import os from "os"
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import axios from "axios";
4
+ import os from "os";
5
+
4
6
  const homeDir = os.homedir();
5
- const url = "http://localhost:3001/cli/mytasks";
7
+ const url = "http://localhost:3001/cli/mytasks"; // backend endpoint
6
8
 
9
+ // Get saved email from ~/.tncrc
7
10
  async function getEmail() {
8
- const rcFile = path.join(homeDir, '.tncrc');
9
- if(!rcFile) {
10
- console.log("Please Login")
11
- }
12
- const content = fs.readFileSync(rcFile);
13
- const email = JSON.parse(content).email;
14
- return email;
11
+ const rcFile = path.join(homeDir, ".tncrc");
12
+
13
+ if (!fs.existsSync(rcFile)) {
14
+ console.log("⚠️ Please login first!");
15
+ process.exit(1);
16
+ }
17
+
18
+ const content = fs.readFileSync(rcFile, "utf-8");
19
+ const email = JSON.parse(content).email;
20
+ return email;
15
21
  }
16
22
 
23
+ // Fetch tasks for a given room
17
24
  async function myTask(roomId) {
18
- const email = getEmail();
19
- const res = await axios.post(`${url}/${roomId}`,{
20
- " email": email
25
+ try {
26
+ const email = await getEmail();
27
+
28
+ const res = await axios.get(`${url}/${roomId}`, {
29
+ params: { email } // since backend uses req.query
21
30
  });
22
31
 
23
- console.log(res);
32
+ const tasks = res.data.tasks;
33
+
34
+ if (!tasks.length) {
35
+ console.log("📭 No tasks assigned.");
36
+ return;
37
+ }
38
+
39
+ console.log("📋 Your Tasks:");
40
+ tasks.forEach((task, i) => {
41
+ console.log(`${i + 1}. ${task.title} — ${task.status}`);
42
+ });
43
+
44
+ } catch (error) {
45
+ console.error("❌ Error fetching tasks:", error.response?.data || error.message);
46
+ }
24
47
  }
25
- export default myTask;
48
+
49
+ export default myTask;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "thinkncollab-cli",
3
3
  "author": "Raman Singh",
4
- "version": "0.0.53",
4
+ "version": "0.0.55",
5
5
  "description": "CLI tool for ThinkNCollab",
6
6
  "main": "index.js",
7
7
  "bin": {