mozhost-cli 1.2.0 → 2.0.0
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/package.json +1 -1
- package/src/commands/deploy.js +21 -1
- package/src/utils/api.js +23 -5
package/package.json
CHANGED
package/src/commands/deploy.js
CHANGED
|
@@ -317,7 +317,7 @@ function shouldIgnore(filePath, patterns) {
|
|
|
317
317
|
return false;
|
|
318
318
|
});
|
|
319
319
|
}
|
|
320
|
-
|
|
320
|
+
/*
|
|
321
321
|
async function uploadFiles(containerId, projectDir, files, spinner) {
|
|
322
322
|
const client = await api.getClient();
|
|
323
323
|
const baseURL = await config.getApiUrl();
|
|
@@ -341,6 +341,26 @@ async function uploadFiles(containerId, projectDir, files, spinner) {
|
|
|
341
341
|
}
|
|
342
342
|
}
|
|
343
343
|
}
|
|
344
|
+
*/
|
|
345
|
+
|
|
346
|
+
async function uploadFiles(containerId, projectDir, files, spinner) {
|
|
347
|
+
// Enviar em lotes para evitar timeout
|
|
348
|
+
const BATCH_SIZE = 20;
|
|
349
|
+
|
|
350
|
+
for (let i = 0; i < files.length; i += BATCH_SIZE) {
|
|
351
|
+
const batch = files.slice(i, i + BATCH_SIZE);
|
|
352
|
+
|
|
353
|
+
spinner.text = `Upload: ${Math.min(i + BATCH_SIZE, files.length)}/${files.length} arquivos...`;
|
|
354
|
+
|
|
355
|
+
for (const file of batch) {
|
|
356
|
+
const fullPath = path.join(projectDir, file);
|
|
357
|
+
const content = await fs.readFile(fullPath, 'utf-8');
|
|
358
|
+
|
|
359
|
+
// Usar o método correto do api.js que chama o endpoint /cli-upload
|
|
360
|
+
await api.uploadFile(containerId, file, content);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
344
364
|
|
|
345
365
|
module.exports = {
|
|
346
366
|
init,
|
package/src/utils/api.js
CHANGED
|
@@ -111,12 +111,30 @@ class ApiClient {
|
|
|
111
111
|
|
|
112
112
|
async uploadFile(containerId, filePath, content) {
|
|
113
113
|
const client = await this.getClient();
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
|
|
115
|
+
// 🔍 DEBUG
|
|
116
|
+
console.log('📤 Upload:', {
|
|
117
|
+
endpoint: `/api/files/${containerId}/cli-upload`,
|
|
118
|
+
filePath,
|
|
119
|
+
contentLength: content.length
|
|
117
120
|
});
|
|
118
|
-
|
|
119
|
-
|
|
121
|
+
|
|
122
|
+
try {
|
|
123
|
+
const response = await client.post(`/api/files/${containerId}/cli-upload`, {
|
|
124
|
+
path: filePath,
|
|
125
|
+
content
|
|
126
|
+
});
|
|
127
|
+
return response.data;
|
|
128
|
+
} catch (error) {
|
|
129
|
+
// 🔍 DEBUG - Mostrar erro completo
|
|
130
|
+
console.error('❌ Upload error:', {
|
|
131
|
+
status: error.response?.status,
|
|
132
|
+
data: error.response?.data,
|
|
133
|
+
message: error.message
|
|
134
|
+
});
|
|
135
|
+
throw error;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
120
138
|
|
|
121
139
|
|
|
122
140
|
async uploadFiles(containerId, files) {
|