thinkncollab-cli 0.0.32 → 0.0.34
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 +14 -6
- package/commands/pull.js +14 -24
- package/package.json +1 -1
package/bin/index.js
CHANGED
|
@@ -85,10 +85,11 @@ function shouldIgnore(relativePath, ignoreList) {
|
|
|
85
85
|
});
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
/** ------------------ SCAN FOLDER ------------------ **/
|
|
88
|
+
/** ------------------ SCAN FOLDER - FIXED ------------------ **/
|
|
89
89
|
function scanFolder(folderPath, ignoreList, rootPath = folderPath) {
|
|
90
90
|
const items = fs.readdirSync(folderPath, { withFileTypes: true });
|
|
91
91
|
const result = [];
|
|
92
|
+
|
|
92
93
|
for (const item of items) {
|
|
93
94
|
const fullPath = path.join(folderPath, item.name);
|
|
94
95
|
const relativePath = path.relative(rootPath, fullPath);
|
|
@@ -102,15 +103,15 @@ function scanFolder(folderPath, ignoreList, rootPath = folderPath) {
|
|
|
102
103
|
result.push({
|
|
103
104
|
name: item.name,
|
|
104
105
|
type: "folder",
|
|
105
|
-
children: scanFolder(fullPath, ignoreList, rootPath),
|
|
106
|
-
path:
|
|
106
|
+
children: scanFolder(fullPath, ignoreList, rootPath), // ✅ Keep same rootPath
|
|
107
|
+
path: item.name // ✅ Only store folder name, not full path
|
|
107
108
|
});
|
|
108
109
|
} else {
|
|
109
110
|
const stats = fs.statSync(fullPath);
|
|
110
111
|
result.push({
|
|
111
112
|
name: item.name,
|
|
112
113
|
type: "file",
|
|
113
|
-
path: relativePath,
|
|
114
|
+
path: relativePath, // ✅ Keep relative path for files
|
|
114
115
|
size: stats.size
|
|
115
116
|
});
|
|
116
117
|
}
|
|
@@ -238,11 +239,18 @@ async function uploadFileSigned(filePath, folder, roomId, token, email) {
|
|
|
238
239
|
return cloudRes.data.secure_url;
|
|
239
240
|
}
|
|
240
241
|
|
|
242
|
+
/** ------------------ UPLOAD TREE - FIXED PATH CONSTRUCTION ------------------ **/
|
|
241
243
|
async function uploadTree(fileTree, folderHex, roomId, token, email, previousVersions, parentPath = "") {
|
|
242
244
|
const uploaded = [];
|
|
243
245
|
|
|
244
246
|
for (const node of fileTree) {
|
|
245
|
-
|
|
247
|
+
// ✅ FIXED: Correct path construction without duplication
|
|
248
|
+
let relativePath;
|
|
249
|
+
if (parentPath) {
|
|
250
|
+
relativePath = path.join(parentPath, node.name).replace(/\\/g, "/");
|
|
251
|
+
} else {
|
|
252
|
+
relativePath = node.path || node.name;
|
|
253
|
+
}
|
|
246
254
|
|
|
247
255
|
if (node.type === "folder") {
|
|
248
256
|
const children = await uploadTree(node.children, folderHex, roomId, token, email, previousVersions, relativePath);
|
|
@@ -259,7 +267,7 @@ async function uploadTree(fileTree, folderHex, roomId, token, email, previousVer
|
|
|
259
267
|
if (node.changed) {
|
|
260
268
|
try {
|
|
261
269
|
console.log(`📤 Uploading changed file: ${relativePath}`);
|
|
262
|
-
const url = await uploadFileSigned(node.path, `tnc_uploads/${folderHex}`, roomId, token, email);
|
|
270
|
+
const url = await uploadFileSigned(path.join(CWD, node.path), `tnc_uploads/${folderHex}`, roomId, token, email);
|
|
263
271
|
console.log(`✅ Uploaded: ${relativePath}`);
|
|
264
272
|
|
|
265
273
|
uploaded.push({
|
package/commands/pull.js
CHANGED
|
@@ -54,33 +54,26 @@ async function processFolderContent(content, basePath = "") {
|
|
|
54
54
|
let errorCount = 0;
|
|
55
55
|
|
|
56
56
|
for (const item of content) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
skippedCount++;
|
|
57
|
+
// Skip folders entirely - only process files
|
|
58
|
+
if (item.type === "folder" && item.children) {
|
|
59
|
+
const result = await processFolderContent(item.children, basePath);
|
|
60
|
+
downloadedCount += result.downloadedCount;
|
|
61
|
+
skippedCount += result.skippedCount;
|
|
62
|
+
errorCount += result.errorCount;
|
|
64
63
|
continue;
|
|
65
64
|
}
|
|
66
65
|
|
|
67
|
-
//
|
|
68
|
-
if (item.type === "
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
errorCount += result.errorCount;
|
|
66
|
+
// Only process files
|
|
67
|
+
if (item.type === "file" && item.url) {
|
|
68
|
+
const itemPath = path.join(basePath, item.path);
|
|
69
|
+
|
|
70
|
+
// Skip .tnc files
|
|
71
|
+
if (itemPath.includes('.tnc')) {
|
|
72
|
+
skippedCount++;
|
|
73
|
+
continue;
|
|
76
74
|
}
|
|
77
|
-
continue; // Skip the folder itself
|
|
78
|
-
}
|
|
79
75
|
|
|
80
|
-
// ✅ ONLY FILE PROCESSING LOGIC
|
|
81
|
-
if (item.type === "file" && item.url) {
|
|
82
76
|
try {
|
|
83
|
-
// downloadFile will create necessary directories automatically
|
|
84
77
|
if (fs.existsSync(itemPath)) {
|
|
85
78
|
const existingStats = fs.statSync(itemPath);
|
|
86
79
|
if (existingStats.size === item.size) {
|
|
@@ -98,9 +91,6 @@ async function processFolderContent(content, basePath = "") {
|
|
|
98
91
|
console.error(chalk.red(`❌ Failed to download ${itemPath}: ${err.message}`));
|
|
99
92
|
errorCount++;
|
|
100
93
|
}
|
|
101
|
-
} else if (item.type === "file" && !item.url) {
|
|
102
|
-
console.log(chalk.magenta(`⚠️ No URL available for: ${itemPath}`));
|
|
103
|
-
skippedCount++;
|
|
104
94
|
}
|
|
105
95
|
}
|
|
106
96
|
|