mozhost-cli 1.0.0 → 1.3.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 +50 -4
- package/src/utils/api.js +22 -3
package/package.json
CHANGED
package/src/commands/deploy.js
CHANGED
|
@@ -136,13 +136,59 @@ async function deploy(containerId, options) {
|
|
|
136
136
|
let targetContainerId = containerId;
|
|
137
137
|
|
|
138
138
|
if (!targetContainerId) {
|
|
139
|
+
// Tentar ler do .mozhost.json
|
|
139
140
|
targetContainerId = await config.getLinkedContainer();
|
|
140
141
|
|
|
141
142
|
if (!targetContainerId) {
|
|
142
|
-
|
|
143
|
-
console.log(chalk.
|
|
144
|
-
|
|
145
|
-
|
|
143
|
+
// Não tem container vinculado - perguntar qual usar
|
|
144
|
+
console.log(chalk.yellow('\n⚠️ Nenhum container vinculado a este projeto'));
|
|
145
|
+
|
|
146
|
+
const spinner = ora('Carregando containers...').start();
|
|
147
|
+
const response = await api.listContainers();
|
|
148
|
+
spinner.stop();
|
|
149
|
+
|
|
150
|
+
if (response.containers.length === 0) {
|
|
151
|
+
console.error(chalk.red('\n❌ Nenhum container encontrado'));
|
|
152
|
+
console.log(chalk.gray(' Crie um container primeiro: mozhost create -n <nome> -t <tipo>'));
|
|
153
|
+
process.exit(1);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (response.containers.length === 1) {
|
|
157
|
+
// Só tem 1 container, usar automaticamente
|
|
158
|
+
targetContainerId = response.containers[0].id;
|
|
159
|
+
console.log(chalk.cyan(`\n🎯 Usando container: ${response.containers[0].name}`));
|
|
160
|
+
} else {
|
|
161
|
+
// Múltiplos containers - perguntar qual usar
|
|
162
|
+
const { selectedContainer } = await inquirer.prompt([
|
|
163
|
+
{
|
|
164
|
+
type: 'list',
|
|
165
|
+
name: 'selectedContainer',
|
|
166
|
+
message: 'Selecione o container para deploy:',
|
|
167
|
+
choices: response.containers.map(c => ({
|
|
168
|
+
name: `${c.name} (${c.type}) - ${c.status}`,
|
|
169
|
+
value: c.id
|
|
170
|
+
}))
|
|
171
|
+
}
|
|
172
|
+
]);
|
|
173
|
+
|
|
174
|
+
targetContainerId = selectedContainer;
|
|
175
|
+
|
|
176
|
+
// Perguntar se quer vincular este container ao projeto
|
|
177
|
+
const { linkContainer } = await inquirer.prompt([
|
|
178
|
+
{
|
|
179
|
+
type: 'confirm',
|
|
180
|
+
name: 'linkContainer',
|
|
181
|
+
message: 'Deseja vincular este container ao projeto?',
|
|
182
|
+
default: true
|
|
183
|
+
}
|
|
184
|
+
]);
|
|
185
|
+
|
|
186
|
+
if (linkContainer) {
|
|
187
|
+
const container = response.containers.find(c => c.id === targetContainerId);
|
|
188
|
+
await config.linkContainer(targetContainerId, container.name);
|
|
189
|
+
console.log(chalk.green('✅ Container vinculado! Próximos deploys usarão este container automaticamente.'));
|
|
190
|
+
}
|
|
191
|
+
}
|
|
146
192
|
}
|
|
147
193
|
}
|
|
148
194
|
|
package/src/utils/api.js
CHANGED
|
@@ -109,14 +109,33 @@ class ApiClient {
|
|
|
109
109
|
return response.data;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
112
|
+
async uploadFile(containerId, filePath, content) {
|
|
113
|
+
const client = await this.getClient();
|
|
114
|
+
|
|
115
|
+
// 🔍 DEBUG
|
|
116
|
+
console.log('📤 Upload:', {
|
|
117
|
+
endpoint: `/api/files/${containerId}/cli-upload`,
|
|
118
|
+
filePath,
|
|
119
|
+
contentLength: content.length
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
try {
|
|
123
|
+
const response = await client.post(`/api/files/${containerId}/cli-upload`, {
|
|
115
124
|
path: filePath,
|
|
116
125
|
content
|
|
117
126
|
});
|
|
118
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;
|
|
119
136
|
}
|
|
137
|
+
}
|
|
138
|
+
|
|
120
139
|
|
|
121
140
|
async uploadFiles(containerId, files) {
|
|
122
141
|
const client = await this.getClient();
|