mozhost-cli 1.0.0 → 1.2.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mozhost-cli",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "description": "Command-line interface for MozHost container platform",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -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
- console.error(chalk.red('❌ Nenhum container especificado'));
143
- console.log(chalk.gray(' Use: mozhost deploy <container-id>'));
144
- console.log(chalk.gray(' Ou: mozhost init (para vincular)'));
145
- process.exit(1);
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,15 @@ class ApiClient {
109
109
  return response.data;
110
110
  }
111
111
 
112
- async uploadFile(containerId, filePath, content) {
113
- const client = await this.getClient();
114
- const response = await client.post(`/api/files/${containerId}`, {
115
- path: filePath,
116
- content
117
- });
118
- return response.data;
119
- }
112
+ async uploadFile(containerId, filePath, content) {
113
+ const client = await this.getClient();
114
+ const response = await client.post(`/api/files/${containerId}/cli-upload`, { // ← Mudar!
115
+ path: filePath,
116
+ content
117
+ });
118
+ return response.data;
119
+ }
120
+
120
121
 
121
122
  async uploadFiles(containerId, files) {
122
123
  const client = await this.getClient();