thinkncollab-cli 0.0.25 → 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,6 +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"; // Add this import
5
6
 
6
7
  const RC_FILE = path.join(os.homedir(), ".tncrc");
7
8
  const CWD = process.cwd();
@@ -120,13 +121,20 @@ export default async function pull(roomId, version = "latest") {
120
121
  console.log("");
121
122
 
122
123
  // Get folder data from server
123
- let url = `http://localhost:3001/folders/${roomId}/download`;
124
+ let url = `http://localhost:3001/folder/${roomId}/download`;
124
125
  const params = { projectId };
125
126
 
126
127
  if (version !== "latest") {
127
- 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;
128
134
  }
129
135
 
136
+ console.log("🔍 Making API request with:", { roomId, projectId, version });
137
+
130
138
  const response = await axios.get(url, {
131
139
  params,
132
140
  headers: {
@@ -135,10 +143,11 @@ export default async function pull(roomId, version = "latest") {
135
143
  }
136
144
  });
137
145
 
146
+ console.log("✅ API Response received");
138
147
  const folderData = response.data;
139
148
 
140
149
  if (!folderData || !folderData.rootContent) {
141
- console.log("❌ No content found to download.");
150
+ console.log("❌ No content found in response");
142
151
  return;
143
152
  }
144
153
 
@@ -194,18 +203,15 @@ export default async function pull(roomId, version = "latest") {
194
203
  console.log(`🎉 Pull completed successfully!`);
195
204
 
196
205
  } catch (err) {
206
+ console.error("❌ Pull failed with error:", err.message);
207
+
197
208
  if (err.response) {
198
- console.error(" Pull failed:", err.response.data.message || err.response.statusText);
199
- } else {
200
- 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");
201
215
  }
202
216
  }
203
217
  }
204
-
205
- /** ------------------ PULL WITH OPTIONS ------------------ **/
206
- export async function pullWithOptions(roomId, options = {}) {
207
- const version = options.version || "latest";
208
- const targetPath = options.targetPath || process.cwd();
209
-
210
- await pull(roomId, version, targetPath);
211
- }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "thinkncollab-cli",
3
3
  "author": "Raman Singh",
4
- "version": "0.0.25",
4
+ "version": "0.0.27",
5
5
  "description": "CLI tool for ThinkNCollab",
6
6
  "main": "index.js",
7
7
  "bin": {