thinkncollab-cli 0.0.27 → 0.0.28
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/commands/pull.js +30 -13
- package/package.json +1 -1
package/commands/pull.js
CHANGED
|
@@ -2,7 +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";
|
|
5
|
+
import os from "os";
|
|
6
6
|
|
|
7
7
|
const RC_FILE = path.join(os.homedir(), ".tncrc");
|
|
8
8
|
const CWD = process.cwd();
|
|
@@ -120,7 +120,7 @@ export default async function pull(roomId, version = "latest") {
|
|
|
120
120
|
console.log(`🎯 Version: ${version}`);
|
|
121
121
|
console.log("");
|
|
122
122
|
|
|
123
|
-
//
|
|
123
|
+
// Use your existing endpoint
|
|
124
124
|
let url = `http://localhost:3001/folder/${roomId}/download`;
|
|
125
125
|
const params = { projectId };
|
|
126
126
|
|
|
@@ -134,6 +134,7 @@ export default async function pull(roomId, version = "latest") {
|
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
console.log("🔍 Making API request with:", { roomId, projectId, version });
|
|
137
|
+
console.log("🌐 API URL:", url);
|
|
137
138
|
|
|
138
139
|
const response = await axios.get(url, {
|
|
139
140
|
params,
|
|
@@ -146,12 +147,22 @@ export default async function pull(roomId, version = "latest") {
|
|
|
146
147
|
console.log("✅ API Response received");
|
|
147
148
|
const folderData = response.data;
|
|
148
149
|
|
|
149
|
-
if (!folderData
|
|
150
|
-
console.log("❌ No
|
|
150
|
+
if (!folderData) {
|
|
151
|
+
console.log("❌ No data found in response");
|
|
151
152
|
return;
|
|
152
153
|
}
|
|
153
154
|
|
|
154
|
-
|
|
155
|
+
// Handle different response formats
|
|
156
|
+
let rootContent = folderData.rootContent || folderData.content || folderData;
|
|
157
|
+
let folderVersion = folderData.version || 1;
|
|
158
|
+
|
|
159
|
+
if (!rootContent || !Array.isArray(rootContent)) {
|
|
160
|
+
console.log("❌ No valid content found in response");
|
|
161
|
+
console.log("📋 Response structure:", Object.keys(folderData));
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
console.log(`📦 Found version ${folderVersion} with ${rootContent.length} items`);
|
|
155
166
|
console.log("");
|
|
156
167
|
|
|
157
168
|
// Create backup of current versions file if it exists
|
|
@@ -163,7 +174,7 @@ export default async function pull(roomId, version = "latest") {
|
|
|
163
174
|
}
|
|
164
175
|
|
|
165
176
|
// Process and download files
|
|
166
|
-
const result = await processFolderContent(
|
|
177
|
+
const result = await processFolderContent(rootContent, process.cwd());
|
|
167
178
|
|
|
168
179
|
console.log("");
|
|
169
180
|
console.log("📊 Download Summary:");
|
|
@@ -195,7 +206,7 @@ export default async function pull(roomId, version = "latest") {
|
|
|
195
206
|
}
|
|
196
207
|
};
|
|
197
208
|
|
|
198
|
-
flattenContent(
|
|
209
|
+
flattenContent(rootContent);
|
|
199
210
|
fs.writeFileSync(versionsFile, JSON.stringify(newVersionMap, null, 2));
|
|
200
211
|
|
|
201
212
|
console.log("");
|
|
@@ -206,12 +217,18 @@ export default async function pull(roomId, version = "latest") {
|
|
|
206
217
|
console.error("❌ Pull failed with error:", err.message);
|
|
207
218
|
|
|
208
219
|
if (err.response) {
|
|
209
|
-
console.error("📡 Server response:",
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
220
|
+
console.error("📡 Server response status:", err.response.status);
|
|
221
|
+
if (err.response.data) {
|
|
222
|
+
if (typeof err.response.data === 'object') {
|
|
223
|
+
console.error("📡 Server message:", err.response.data.message || err.response.data);
|
|
224
|
+
} else {
|
|
225
|
+
console.error("📡 Server response:", err.response.data);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
213
228
|
} else if (err.request) {
|
|
214
|
-
console.error("🌐 No response received from server");
|
|
229
|
+
console.error("🌐 No response received from server - check if backend is running on localhost:3001");
|
|
230
|
+
} else {
|
|
231
|
+
console.error("🔧 Configuration error:", err.message);
|
|
215
232
|
}
|
|
216
233
|
}
|
|
217
|
-
}
|
|
234
|
+
}
|