thinkncollab-cli 0.0.73 → 0.0.75

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
@@ -15,6 +15,7 @@ import version from "../commands/version.js";
15
15
  import createBranch from "../commands/branch.js"
16
16
  import myTask from "../commands/myTask.js"
17
17
  import sendInvite from '../commands/sendInvite.js'
18
+ import connect from '../commands/connect.js'
18
19
 
19
20
 
20
21
 
@@ -314,7 +315,7 @@ async function uploadTree(fileTree, folderHex, roomId, token, email, previousVer
314
315
  }
315
316
 
316
317
  /** ------------------ PUSH FUNCTION ------------------ **/
317
- async function push(roomId, targetPath, pushBranch) {
318
+ async function push(roomId, targetPath) {
318
319
  const { token, email } = readToken();
319
320
  const tncMetaPath = path.join(process.cwd(), ".tnc", ".tncmeta.json");
320
321
  if (!fs.existsSync(tncMetaPath)) {
@@ -324,6 +325,16 @@ async function push(roomId, targetPath, pushBranch) {
324
325
  const meta = JSON.parse(fs.readFileSync(tncMetaPath, "utf-8"));
325
326
  const projectId = meta.projectId;
326
327
 
328
+
329
+ const tncPushInfo = path.join(process.cwd(), ".tnc", ".tncpush.json");
330
+ if (!fs.existsSync(tncMetaPath)) {
331
+ console.error("❌ Project not initialized. Run 'tnc init' first.");
332
+ process.exit(1);
333
+ }
334
+ const lastFolderId = JSON.parse(fs.readFileSync(tncPushInfo, "utf-8")).folderId;
335
+
336
+
337
+
327
338
  const stats = fs.statSync(targetPath);
328
339
  const rootFolder = stats.isDirectory() ? targetPath : path.dirname(targetPath);
329
340
  const ignoreList = loadIgnore(rootFolder);
@@ -370,7 +381,7 @@ async function push(roomId, targetPath, pushBranch) {
370
381
  console.log("🗂️ Sending metadata...");
371
382
  const res = await axios.post(
372
383
  `${BASE_URL}/${roomId}/upload`,
373
- { folderId: folderHex, content: uploadedTree, uploadedBy: email, projectId , pushBranch},
384
+ { folderId: folderHex, content: uploadedTree, uploadedBy: email, projectId, latestFolderId: lastFolderId},
374
385
  { headers: { authorization: `Bearer ${token}`, email } }
375
386
  );
376
387
 
@@ -403,7 +414,7 @@ async function push(roomId, targetPath, pushBranch) {
403
414
  roomId: roomId,
404
415
  pushedBy: email,
405
416
  projectId: projectId,
406
- folderId: res.folderId
417
+ folderId: res.data.folderId
407
418
  };
408
419
 
409
420
 
@@ -435,15 +446,14 @@ async function main() {
435
446
  break;
436
447
 
437
448
  case "push": {
438
- const roomIndex = args.indexOf("push");
439
- if (roomIndex === -1 || !args[roomIndex + 2] || !args[roomIndex + 2]) {
449
+ const roomIndex = args.indexOf("--room");
450
+ if (roomIndex === -1 || !args[roomIndex + 1] || !args[roomIndex + 1]) {
440
451
  console.error("Usage: tnc push --room <roomId> <file-or-folder-path>");
441
452
  process.exit(1);
442
453
  }
443
- const roomId = args[roomIndex + 2];
444
- const branch = args[roomIndex+1];
454
+ const roomId = args[roomIndex + 1];
445
455
  const targetPath = args[roomIndex + 3];
446
- await push(roomId, targetPath, branch);
456
+ await push(roomId, targetPath);
447
457
  break;
448
458
  }
449
459
  case "status":
@@ -473,6 +483,17 @@ async function main() {
473
483
  await createBranch(roomId);
474
484
  break;
475
485
 
486
+ case "connect": {
487
+ const idx = args.indexOf("connect");
488
+ const link = args[idx+1];
489
+
490
+ await connect(link);
491
+ break;
492
+
493
+
494
+
495
+ }
496
+
476
497
  case "pull": {
477
498
  const roomIndex = args.indexOf("--room");
478
499
  if (roomIndex === -1 || !args[roomIndex + 1]) {
@@ -0,0 +1,13 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import axios from "axios";
4
+ import os from "os";
5
+ import inquirer from "inquirer";
6
+
7
+
8
+ export async function connect(link) {
9
+
10
+ const res = await axios.get("http://localhost:12");
11
+
12
+ console.log(res.data);
13
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "thinkncollab-cli",
3
3
  "author": "Raman Singh",
4
- "version": "0.0.73",
4
+ "version": "0.0.75",
5
5
  "description": "CLI tool for ThinkNCollab",
6
6
  "main": "index.js",
7
7
  "bin": {