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 +7 -8
- package/commands/myTask.js +40 -16
- package/package.json +1 -1
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
|
|
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
|
-
|
|
505
|
+
case "my-tasks": {
|
|
506
|
+
const roomIdx = args.indexOf("my-tasks");
|
|
507
|
+
const roomId = args[roomIdx + 1]; // fixed typo
|
|
506
508
|
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
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:");
|
package/commands/myTask.js
CHANGED
|
@@ -1,25 +1,49 @@
|
|
|
1
|
-
import fs from "fs"
|
|
2
|
-
import
|
|
3
|
-
import
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
19
|
-
const
|
|
20
|
-
|
|
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
|
-
|
|
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
|
-
|
|
48
|
+
|
|
49
|
+
export default myTask;
|