thinkncollab-cli 0.0.26 → 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/bin/index.js +22 -14
- package/commands/pull.js +40 -19
- package/package.json +1 -1
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
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
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
|
@@ -4,7 +4,6 @@ import axios from "axios";
|
|
|
4
4
|
import https from "https";
|
|
5
5
|
import os from "os";
|
|
6
6
|
|
|
7
|
-
|
|
8
7
|
const RC_FILE = path.join(os.homedir(), ".tncrc");
|
|
9
8
|
const CWD = process.cwd();
|
|
10
9
|
|
|
@@ -121,14 +120,22 @@ export default async function pull(roomId, version = "latest") {
|
|
|
121
120
|
console.log(`🎯 Version: ${version}`);
|
|
122
121
|
console.log("");
|
|
123
122
|
|
|
124
|
-
//
|
|
125
|
-
let url = `http://localhost:3001/
|
|
123
|
+
// Use your existing endpoint
|
|
124
|
+
let url = `http://localhost:3001/folder/${roomId}/download`;
|
|
126
125
|
const params = { projectId };
|
|
127
126
|
|
|
128
127
|
if (version !== "latest") {
|
|
129
|
-
|
|
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
|
+
console.log("🌐 API URL:", url);
|
|
138
|
+
|
|
132
139
|
const response = await axios.get(url, {
|
|
133
140
|
params,
|
|
134
141
|
headers: {
|
|
@@ -137,14 +144,25 @@ export default async function pull(roomId, version = "latest") {
|
|
|
137
144
|
}
|
|
138
145
|
});
|
|
139
146
|
|
|
147
|
+
console.log("✅ API Response received");
|
|
140
148
|
const folderData = response.data;
|
|
141
149
|
|
|
142
|
-
if (!folderData
|
|
143
|
-
console.log("❌ No
|
|
150
|
+
if (!folderData) {
|
|
151
|
+
console.log("❌ No data found in response");
|
|
144
152
|
return;
|
|
145
153
|
}
|
|
146
154
|
|
|
147
|
-
|
|
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`);
|
|
148
166
|
console.log("");
|
|
149
167
|
|
|
150
168
|
// Create backup of current versions file if it exists
|
|
@@ -156,7 +174,7 @@ export default async function pull(roomId, version = "latest") {
|
|
|
156
174
|
}
|
|
157
175
|
|
|
158
176
|
// Process and download files
|
|
159
|
-
const result = await processFolderContent(
|
|
177
|
+
const result = await processFolderContent(rootContent, process.cwd());
|
|
160
178
|
|
|
161
179
|
console.log("");
|
|
162
180
|
console.log("📊 Download Summary:");
|
|
@@ -188,7 +206,7 @@ export default async function pull(roomId, version = "latest") {
|
|
|
188
206
|
}
|
|
189
207
|
};
|
|
190
208
|
|
|
191
|
-
flattenContent(
|
|
209
|
+
flattenContent(rootContent);
|
|
192
210
|
fs.writeFileSync(versionsFile, JSON.stringify(newVersionMap, null, 2));
|
|
193
211
|
|
|
194
212
|
console.log("");
|
|
@@ -196,18 +214,21 @@ export default async function pull(roomId, version = "latest") {
|
|
|
196
214
|
console.log(`🎉 Pull completed successfully!`);
|
|
197
215
|
|
|
198
216
|
} catch (err) {
|
|
217
|
+
console.error("❌ Pull failed with error:", err.message);
|
|
218
|
+
|
|
199
219
|
if (err.response) {
|
|
200
|
-
console.error("
|
|
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
|
+
}
|
|
228
|
+
} else if (err.request) {
|
|
229
|
+
console.error("🌐 No response received from server - check if backend is running on localhost:3001");
|
|
201
230
|
} else {
|
|
202
|
-
console.error("
|
|
231
|
+
console.error("🔧 Configuration error:", err.message);
|
|
203
232
|
}
|
|
204
233
|
}
|
|
205
|
-
}
|
|
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
234
|
}
|