thinkncollab-cli 0.0.26 → 0.0.27

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
@@ -415,22 +415,30 @@ async function main() {
415
415
  case "init":
416
416
  await projectInit();
417
417
  break;
418
-
418
+
419
419
  case "pull": {
420
- const roomIndex = args.indexOf("--room");
421
- const versionIndex = args.indexOf("--version");
422
-
423
- if (roomIndex === -1 || !args[roomIndex + 1]) {
424
- console.error("Usage: tnc pull --room <roomId> [--version <version>]");
425
- process.exit(1);
426
- }
427
-
428
- const roomId = args[roomIndex + 1];
429
- const version = versionIndex !== -1 && args[versionIndex + 1] ? args[versionIndex + 1] : "latest";
430
-
431
- await pull(roomId, version);
432
- break;
420
+ const roomIndex = args.indexOf("--room");
421
+ const versionIndex = args.indexOf("--version");
422
+
423
+ if (roomIndex === -1 || !args[roomIndex + 1]) {
424
+ console.error("Usage: tnc pull --room <roomId> [--version <version>]");
425
+ process.exit(1);
426
+ }
427
+
428
+ const roomId = args[roomIndex + 1];
429
+ let version = "latest";
430
+ if (versionIndex !== -1 && args[versionIndex + 1]) {
431
+ version = args[versionIndex + 1];
432
+ } else {
433
+ const possibleVersionIndex = roomIndex + 2;
434
+ if (args[possibleVersionIndex] && !args[possibleVersionIndex].startsWith("--")) {
435
+ version = args[possibleVersionIndex];
433
436
  }
437
+ }
438
+
439
+ await pull(roomId, version);
440
+ break;
441
+ }
434
442
 
435
443
  default:
436
444
  console.log("✅ TNC CLI ready!");
package/commands/pull.js CHANGED
@@ -2,8 +2,7 @@ import fs from "fs";
2
2
  import path from "path";
3
3
  import axios from "axios";
4
4
  import https from "https";
5
- import os from "os";
6
-
5
+ import os from "os"; // Add this import
7
6
 
8
7
  const RC_FILE = path.join(os.homedir(), ".tncrc");
9
8
  const CWD = process.cwd();
@@ -122,13 +121,20 @@ export default async function pull(roomId, version = "latest") {
122
121
  console.log("");
123
122
 
124
123
  // Get folder data from server
125
- let url = `http://localhost:3001/folders/${roomId}/download`;
124
+ let url = `http://localhost:3001/folder/${roomId}/download`;
126
125
  const params = { projectId };
127
126
 
128
127
  if (version !== "latest") {
129
- params.version = version;
128
+ const versionNum = parseInt(version);
129
+ if (isNaN(versionNum)) {
130
+ console.error("❌ Version must be a number");
131
+ return;
132
+ }
133
+ params.version = versionNum;
130
134
  }
131
135
 
136
+ console.log("🔍 Making API request with:", { roomId, projectId, version });
137
+
132
138
  const response = await axios.get(url, {
133
139
  params,
134
140
  headers: {
@@ -137,10 +143,11 @@ export default async function pull(roomId, version = "latest") {
137
143
  }
138
144
  });
139
145
 
146
+ console.log("✅ API Response received");
140
147
  const folderData = response.data;
141
148
 
142
149
  if (!folderData || !folderData.rootContent) {
143
- console.log("❌ No content found to download.");
150
+ console.log("❌ No content found in response");
144
151
  return;
145
152
  }
146
153
 
@@ -196,18 +203,15 @@ export default async function pull(roomId, version = "latest") {
196
203
  console.log(`🎉 Pull completed successfully!`);
197
204
 
198
205
  } catch (err) {
206
+ console.error("❌ Pull failed with error:", err.message);
207
+
199
208
  if (err.response) {
200
- console.error(" Pull failed:", err.response.data.message || err.response.statusText);
201
- } else {
202
- console.error("❌ Pull failed:", err.message);
209
+ console.error("📡 Server response:", {
210
+ status: err.response.status,
211
+ data: err.response.data
212
+ });
213
+ } else if (err.request) {
214
+ console.error("🌐 No response received from server");
203
215
  }
204
216
  }
205
217
  }
206
-
207
- /** ------------------ PULL WITH OPTIONS ------------------ **/
208
- export async function pullWithOptions(roomId, options = {}) {
209
- const version = options.version || "latest";
210
- const targetPath = options.targetPath || process.cwd();
211
-
212
- await pull(roomId, version, targetPath);
213
- }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "thinkncollab-cli",
3
3
  "author": "Raman Singh",
4
- "version": "0.0.26",
4
+ "version": "0.0.27",
5
5
  "description": "CLI tool for ThinkNCollab",
6
6
  "main": "index.js",
7
7
  "bin": {