thinkncollab-cli 0.0.86 → 0.0.88

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
@@ -29,16 +29,7 @@ const VERSION_FILE = path.join(process.cwd(), ".tncversions");
29
29
  const BASE_URL = "https://thinkncollab.com/rooms";
30
30
  const CWD = process.cwd();
31
31
 
32
- async function DAPP() {
33
- try {
34
- const res = await axios.get(`http://localhost:4545/logout`);
35
- console.log("✅ Command sent to ThinkNCollab Agent");
36
- console.log(res.data.message);
37
- } catch (err) {
38
- console.error("❌ ThinkNCollab Agent not running");
39
- process.exit(1);
40
- }
41
- }
32
+
42
33
 
43
34
 
44
35
  /** ------------------ LOGIN ------------------ **/
@@ -228,28 +219,57 @@ case "signout": {
228
219
 
229
220
  }
230
221
 
231
- default:
232
- console.log('================================');
233
- console.log(' START REAL SYSTEM SHELL ');
234
- console.log('================================ */ ');
235
- console.log("✅ ThinkNCollab CLI ready!");
236
- console.log("Commands:");
237
- console.log(" tnc-cli login --> to login");
238
- console.log(" tnc-cli init <roomId> --> to use CLI for a room");
239
- // console.log(" tnc-cli push --room <roomId> <path>");
240
- console.log(" tnc-cli create --> to create a branch"); //creating a branch
241
- // console.log(" tnc-cli pull --room <roomId>");
242
- // console.log(" tnc-cli sync branch --room <roomId>");
243
- // console.log(" tnc-cli merge <roomId>")
244
- // console.log(" tnc-cli status");
245
- console.log(" tnc-cli whoami --> to know by which Id you are loggedin");
246
- console.log(" tnc-cli my-tasks --> to get ur tasks from the room ");
247
- console.log(" tnc-cli tasks --> to know thetask details");
248
- console.log(" tnc-cli task-complete --> to change the task status to complete")
249
- console.log(" tnc-cli logout --> to logout");
250
- console.log(" tnc-cli help --> to get help");
251
- console.log(" tnc-cli version --> to know the version of the package");
252
- }
222
+ default:
223
+ console.log("================================");
224
+ console.log(" THINKNCOLLAB CLI");
225
+ console.log("================================\n");
226
+
227
+ console.log("Authentication:");
228
+ console.log(" tnc-cli login Login to your account");
229
+ console.log(" tnc-cli logout Logout from your account");
230
+ console.log(" tnc-cli whoami Show current logged-in user");
231
+ console.log("");
232
+
233
+ console.log("Project / Room:");
234
+ console.log(" tnc-cli init <roomId> Initialize current folder with a room");
235
+ console.log(" tnc-cli connect <roomId> Connect project to a room");
236
+ console.log(" tnc-cli status Show project status");
237
+ console.log("");
238
+
239
+ console.log("Branch:");
240
+ console.log(" tnc-cli create --room <roomId> Create branch for a room");
241
+ console.log("");
242
+
243
+ console.log("File Operations:");
244
+ console.log(" tnc-cli push --room <roomId> <path> Push files/folder");
245
+ console.log(" tnc-cli pull --room <roomId> [--version v] Pull latest or specific version");
246
+ console.log("");
247
+
248
+ console.log("Tasks:");
249
+ console.log(" tnc-cli my-tasks Show your assigned tasks");
250
+ console.log(" tnc-cli create-task Create a new task");
251
+ console.log(" tnc-cli task View task details");
252
+ console.log(" tnc-cli task-complete Mark task as completed");
253
+ console.log("");
254
+
255
+ console.log("Team:");
256
+ console.log(" tnc-cli myteam Show team members");
257
+ console.log(" tnc-cli invite <email> Invite member to room");
258
+ console.log("");
259
+
260
+ console.log("Communication:");
261
+ console.log(" tnc-cli send Send message to room");
262
+ console.log("");
263
+
264
+ console.log("Utility:");
265
+ console.log(" tnc-cli help Show help information");
266
+ console.log(" tnc-cli version Show CLI version");
267
+ console.log(" tnc-cli signout Sign out from DAPP");
268
+ console.log("");
269
+
270
+ break;
271
+ }
272
+
253
273
  }
254
274
 
255
275
  main().catch(err => console.error(err));
@@ -9,14 +9,10 @@ import open from 'open';
9
9
  import http from 'http';
10
10
 
11
11
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
12
- const getVerifyModule = await import("../lib/getVerify.js");
13
- const getVerify = getVerifyModule.default;
14
- const { token } = await getVerify();
12
+
15
13
 
16
14
  const CWD = process.cwd();
17
- const tncmetaPath = path.join(CWD, ".tnc", ".tncmeta.json");
18
- const fileData = fs.existsSync(tncmetaPath) ? JSON.parse(fs.readFileSync(tncmetaPath, "utf-8")) : null;
19
- const roomId = fileData?.roomId || null;
15
+
20
16
 
21
17
  function createSpinner(message) {
22
18
  const frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
@@ -42,6 +38,29 @@ function createSpinner(message) {
42
38
 
43
39
  async function createTask() {
44
40
  try {
41
+ const { default: getVerify } = await import("../lib/getVerify.js");
42
+
43
+ const { token } = await getVerify();
44
+
45
+ const CWD = process.cwd();
46
+ const tncmetaPath = path.join(CWD, ".tnc", ".tncmeta.json");
47
+
48
+ if (!fs.existsSync(tncmetaPath)) {
49
+ console.error(chalk.red("❌ Not inside a ThinkNCollab project."));
50
+ console.log(chalk.yellow("Run `tnc-cli init <roomId>` first."));
51
+ return;
52
+ }
53
+
54
+ const fileData = JSON.parse(
55
+ fs.readFileSync(tncmetaPath, "utf-8")
56
+ );
57
+
58
+ const roomId = fileData.roomId;
59
+
60
+ if (!roomId) {
61
+ console.error(chalk.red("❌ No roomId found."));
62
+ return;
63
+ }
45
64
  console.log(chalk.blue('\n🚀 Task Creation CLI\n'));
46
65
 
47
66
  // Validate roomId and token
@@ -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.88",
5
5
  "description": "CLI tool for ThinkNCollab",
6
6
  "main": "index.js",
7
7
  "bin": {