thinkncollab-cli 0.0.86 → 0.0.87

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.
Files changed (2) hide show
  1. package/commands/myTeam.js +48 -17
  2. package/package.json +1 -1
@@ -1,44 +1,75 @@
1
1
  import axios from "axios";
2
2
  import fs from "fs";
3
- import os from "os";
4
3
  import path from "path";
5
4
  import machine from "node-machine-id";
6
5
  import chalk from "chalk";
7
- import FormData from "form-data";
8
6
  import getVerify from "../lib/getVerify.js";
9
7
 
10
8
  const CWD = process.cwd();
11
- const TNC_API_URL = "http://localhost:3001/";
9
+ const TNC_API_URL = "https://thinkncollab.com/";
12
10
  const metaDataFile = path.join(CWD, ".tnc", ".tncmeta.json");
13
- const metaData = JSON.parse(fs.readFileSync(metaDataFile, "utf-8"));
14
- const roomId = metaData.roomId;
15
11
 
16
12
  async function myTeam() {
17
13
  try {
14
+ // ✅ Check initialization first
15
+ if (!fs.existsSync(metaDataFile)) {
16
+ console.log(chalk.red("❌ Project not initialized."));
17
+ console.log(chalk.yellow("👉 Run `tnc init` first."));
18
+ return;
19
+ }
20
+
21
+ const metaData = JSON.parse(
22
+ fs.readFileSync(metaDataFile, "utf-8")
23
+ );
24
+
25
+ if (!metaData.roomId) {
26
+ console.log(chalk.red("❌ No room associated with this project."));
27
+ return;
28
+ }
29
+
30
+ const roomId = metaData.roomId;
31
+
18
32
  const verifyData = await getVerify();
19
33
  const { email, token } = verifyData;
20
- const response = await axios.get(`${TNC_API_URL}cli/myTeam/${roomId}`, {
21
- headers: {
22
- email,
23
- token,
24
- machineId: machine.machineIdSync(),
25
- },
26
- });
34
+
35
+ const response = await axios.get(
36
+ `${TNC_API_URL}cli/myTeam/${roomId}`,
37
+ {
38
+ headers: {
39
+ email,
40
+ token,
41
+ machineId: machine.machineIdSync(),
42
+ },
43
+ }
44
+ );
45
+
27
46
  const teamMembers = response.data.RoomMembers || [];
47
+
28
48
  if (teamMembers.length === 0) {
29
49
  console.log(chalk.yellow("⚠️ You are not part of any team yet."));
30
50
  return;
31
51
  }
32
- console.log(chalk.green("👥 Your Team Members:"))
52
+
53
+ console.log(chalk.green("👥 Your Team Members:"));
33
54
  teamMembers.forEach(member => {
34
- console.log(chalk.blue(`- ${member.name} (${member.email})`));
55
+ console.log(
56
+ chalk.blue(`- ${member.name} (${member.email})`)
57
+ );
35
58
  });
59
+
36
60
  } catch (err) {
37
61
  if (err.response) {
38
- console.error(chalk.red("❌ Error:"), chalk.red(err.response.data.error));
62
+ console.error(
63
+ chalk.red("❌ Error:"),
64
+ chalk.red(err.response.data.error)
65
+ );
39
66
  } else {
40
- console.error(chalk.red("❌ Error:"), chalk.red(err.message));
67
+ console.error(
68
+ chalk.red("❌ Error:"),
69
+ chalk.red(err.message)
70
+ );
41
71
  }
42
72
  }
43
73
  }
44
- export default myTeam;
74
+
75
+ export default myTeam;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "thinkncollab-cli",
3
3
  "author": "Raman Singh",
4
- "version": "0.0.86",
4
+ "version": "0.0.87",
5
5
  "description": "CLI tool for ThinkNCollab",
6
6
  "main": "index.js",
7
7
  "bin": {