thinkncollab-cli 0.0.57 → 0.0.59

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
@@ -14,6 +14,7 @@ import help from "../commands/help.js";
14
14
  import version from "../commands/version.js";
15
15
  import createBranch from "../commands/branch.js"
16
16
  import myTask from "../commands/myTask.js"
17
+ import sendInvite from '../commands/sendInvite.js'
17
18
 
18
19
 
19
20
 
@@ -506,7 +507,14 @@ case "my-tasks": {
506
507
  const roomIdx = args.indexOf("my-tasks");
507
508
  const roomId = args[roomIdx + 1]; // fixed typo
508
509
 
509
- await myTask(roomId); // match function name
510
+ await myTask(roomId);
511
+ break;
512
+ }
513
+ case "invite": {
514
+ const roomIdx = args.indexOf("invite");
515
+ const email = args[roomIdx + 1]; // fixed typo
516
+
517
+ await sendInvite(email);
510
518
  break;
511
519
  }
512
520
 
@@ -519,6 +527,7 @@ case "my-tasks": {
519
527
  console.log(" tnc-cli pull --room <roomId>");
520
528
  console.log(" tnc-cli status");
521
529
  console.log(" tnc-cli whoami");
530
+ console.log(" tnc-cli my-tasks <roomId>");
522
531
  console.log(" tnc-cli logout");
523
532
  console.log(" tnc-cli help");
524
533
  console.log(" tnc-cli version");
@@ -4,7 +4,7 @@ import axios from "axios";
4
4
  import os from "os";
5
5
 
6
6
  const homeDir = os.homedir();
7
- const url = "http://localhost:3001/cli/mytasks"; // backend endpoint
7
+ const url = "https://thinkncollab.in/cli/mytasks"; // backend endpoint
8
8
 
9
9
  // Get saved email from ~/.tncrc
10
10
  async function getEmail() {
@@ -0,0 +1,61 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import axios from "axios";
4
+ import os from "os";
5
+
6
+ const homeDir = os.homedir();
7
+ const url = "http://localhost:3001/cli/invite"; // backend endpoint
8
+
9
+ // Get saved email from ~/.tncrc
10
+ async function getEmail() {
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;
21
+ }
22
+ async function getToken() {
23
+ const rcFile = path.join(homeDir, '.tncrc');
24
+ if(!fs.readFileSync(rcFile)){
25
+ console.log("⚠️ Please login first! ")
26
+ }
27
+ const content = fs.readFileSync(rcFile, 'utf-8');
28
+ const token = JSON.parse(content).token;
29
+ return token;
30
+
31
+
32
+ }
33
+
34
+ // Fetch tasks for a given room
35
+ async function sendInvite(inviteeEmail) {
36
+ try {
37
+ const email = await getEmail();
38
+ const token = await getToken();
39
+
40
+ const res = await axios.get(`${url}/${roomId}`, {
41
+ params: { email, token,inviteeEmail }
42
+ });
43
+
44
+ const tasks = res.data.tasks;
45
+
46
+ if (!tasks.length) {
47
+ console.log("📭 No tasks assigned.");
48
+ return;
49
+ }
50
+
51
+ console.log("📋 Your Tasks:");
52
+ tasks.forEach((task, i) => {
53
+ console.log(`${i + 1}. ${task.title} — ${task.status}`);
54
+ });
55
+
56
+ } catch (error) {
57
+ console.error("❌ Error fetching tasks:", error.response?.data || error.message);
58
+ }
59
+ }
60
+
61
+ export default sendInvite;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "thinkncollab-cli",
3
3
  "author": "Raman Singh",
4
- "version": "0.0.57",
4
+ "version": "0.0.59",
5
5
  "description": "CLI tool for ThinkNCollab",
6
6
  "main": "index.js",
7
7
  "bin": {