ante-erp-cli 1.11.31 ā 1.11.32
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/install.js +69 -1
package/package.json
CHANGED
package/src/commands/install.js
CHANGED
|
@@ -10,7 +10,7 @@ import { fileURLToPath } from 'url';
|
|
|
10
10
|
import { runSystemChecks, checkAndInstallDocker } from '../utils/validation.js';
|
|
11
11
|
import { generateCredentials } from '../utils/password.js';
|
|
12
12
|
import { saveInstallConfig, detectInstallation } from '../utils/config.js';
|
|
13
|
-
import { pullImagesSilent, startServicesSilent, waitForServiceHealthy, runMigrations } from '../utils/docker.js';
|
|
13
|
+
import { pullImagesSilent, startServicesSilent, waitForServiceHealthy, runMigrations, downServices } from '../utils/docker.js';
|
|
14
14
|
import { generateDockerCompose } from '../templates/docker-compose.yml.js';
|
|
15
15
|
import { generateEnv } from '../templates/env.js';
|
|
16
16
|
import { detectPublicIPWithFeedback, buildURL } from '../utils/network.js';
|
|
@@ -189,6 +189,74 @@ export async function install(options) {
|
|
|
189
189
|
} else {
|
|
190
190
|
console.log(chalk.green('ā Preserving existing credentials from .env file\n'));
|
|
191
191
|
}
|
|
192
|
+
|
|
193
|
+
// Ask about cleaning up existing data
|
|
194
|
+
const composeFile = join(existing, 'docker-compose.yml');
|
|
195
|
+
if (existsSync(composeFile)) {
|
|
196
|
+
console.log(chalk.yellow('\nš¦ Existing Docker volumes detected\n'));
|
|
197
|
+
|
|
198
|
+
const { cleanupChoice } = await inquirer.prompt([
|
|
199
|
+
{
|
|
200
|
+
type: 'list',
|
|
201
|
+
name: 'cleanupChoice',
|
|
202
|
+
message: 'How would you like to handle existing data?',
|
|
203
|
+
choices: [
|
|
204
|
+
{
|
|
205
|
+
name: 'Remove all data and start fresh (recommended)',
|
|
206
|
+
value: 'clean'
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
name: 'Keep existing data (may cause issues if credentials changed)',
|
|
210
|
+
value: 'keep'
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
name: 'Cancel installation',
|
|
214
|
+
value: 'cancel'
|
|
215
|
+
}
|
|
216
|
+
],
|
|
217
|
+
default: 'clean'
|
|
218
|
+
}
|
|
219
|
+
]);
|
|
220
|
+
|
|
221
|
+
if (cleanupChoice === 'cancel') {
|
|
222
|
+
console.log(chalk.yellow('\nInstallation cancelled.\n'));
|
|
223
|
+
process.exit(0);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
if (cleanupChoice === 'clean') {
|
|
227
|
+
// Require confirmation for destructive action
|
|
228
|
+
console.log(chalk.red('\nā ļø WARNING: This will permanently delete all data!'));
|
|
229
|
+
console.log(chalk.yellow(' ⢠PostgreSQL database'));
|
|
230
|
+
console.log(chalk.yellow(' ⢠MongoDB database'));
|
|
231
|
+
console.log(chalk.yellow(' ⢠Redis cache'));
|
|
232
|
+
console.log(chalk.yellow(' ⢠Uploaded files\n'));
|
|
233
|
+
|
|
234
|
+
const { confirmDelete } = await inquirer.prompt([
|
|
235
|
+
{
|
|
236
|
+
type: 'input',
|
|
237
|
+
name: 'confirmDelete',
|
|
238
|
+
message: chalk.red('Type "DELETE ALL DATA" to confirm:'),
|
|
239
|
+
validate: (input) => {
|
|
240
|
+
if (input === 'DELETE ALL DATA') return true;
|
|
241
|
+
return 'You must type the exact phrase to continue';
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
]);
|
|
245
|
+
|
|
246
|
+
if (confirmDelete === 'DELETE ALL DATA') {
|
|
247
|
+
console.log(chalk.yellow('\nStopping services and removing volumes...'));
|
|
248
|
+
try {
|
|
249
|
+
await downServices(composeFile, true); // true = remove volumes
|
|
250
|
+
console.log(chalk.green('ā Cleanup complete\n'));
|
|
251
|
+
} catch (error) {
|
|
252
|
+
console.log(chalk.yellow(`ā Cleanup warning: ${error.message}`));
|
|
253
|
+
console.log(chalk.gray('Continuing with installation...\n'));
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
} else {
|
|
257
|
+
console.log(chalk.yellow('\nā Keeping existing data. If installation fails, try again with cleanup.\n'));
|
|
258
|
+
}
|
|
259
|
+
}
|
|
192
260
|
}
|
|
193
261
|
|
|
194
262
|
// Calculate total steps
|