thinkncollab-cli 0.0.58 → 0.0.60

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
 
@@ -454,8 +455,8 @@ async function main() {
454
455
  case "create":
455
456
  const roomIdx = args.indexOf("--room");
456
457
  if (roomIdx === -1 || !args[roomIdx + 1]) {
457
- console.log("Usage: tnc-cli create-branch --room <roomId>");
458
- console.log("Example: tnc-cli create-branch --room 507f1f77bcf86cd799439011");
458
+ console.log("Usage: tnc-cli create --room <roomId>");
459
+ console.log("Example: tnc-cli create --room 507f1f77bcf86cd799439011");
459
460
  process.exit(1);
460
461
  }
461
462
 
@@ -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
 
@@ -516,12 +524,17 @@ case "my-tasks": {
516
524
  console.log(" tnc-cli login");
517
525
  console.log(" tnc-cli init");
518
526
  console.log(" tnc-cli push --room <roomId> <path>");
527
+ console.log(" tnc-cli create"); //creating a branch
519
528
  console.log(" tnc-cli pull --room <roomId>");
529
+ console.log(" tnc-cli sync branch --room <roomId>");
530
+ console.log(" tnc-cli merge <roomId>")
520
531
  console.log(" tnc-cli status");
521
532
  console.log(" tnc-cli whoami");
533
+ console.log(" tnc-cli my-tasks <roomId>");
522
534
  console.log(" tnc-cli logout");
523
535
  console.log(" tnc-cli help");
524
536
  console.log(" tnc-cli version");
537
+
525
538
  }
526
539
  }
527
540
 
@@ -4,6 +4,20 @@ import axios from "axios";
4
4
  import os from "os";
5
5
  import inquirer from "inquirer";
6
6
 
7
+ async function updateBranch(branchName) {
8
+ const currenDir = process.cwd();
9
+ const tncmetaFile = path.join(currenDir, ".tncmeta.json")
10
+
11
+ if(!fs.readFileSync(tncmetaFile)) {
12
+
13
+ }
14
+ const content = ` "currentBranch": "${branchName}",`;
15
+
16
+
17
+ fs.writeFileSync(tncmetaFile, content, "utf-8" );
18
+
19
+ }
20
+
7
21
  async function createBranch(roomId) {
8
22
  try {
9
23
  const branchName = await inquirer.prompt([
@@ -47,10 +61,10 @@ async function createBranch(roomId) {
47
61
 
48
62
  if (res.data.success) {
49
63
  console.log(`✅ Branch '${branchName.branchName}' created successfully!`);
64
+ updateBranch(branchName.branchName);
50
65
  } else {
51
66
  console.log(`❌ Failed to create branch: ${res.data.message}`);
52
67
  }
53
-
54
68
  } catch (error) {
55
69
  if (error.response?.data?.message) {
56
70
  console.error(`❌ Error: ${error.response.data.message}`);
@@ -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.58",
4
+ "version": "0.0.60",
5
5
  "description": "CLI tool for ThinkNCollab",
6
6
  "main": "index.js",
7
7
  "bin": {