ante-erp-cli 1.11.1 → 1.11.3
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/clone-db.js +7 -32
- package/src/utils/docker.js +7 -3
- package/src/utils/mongodb.js +1 -1
package/package.json
CHANGED
package/src/commands/clone-db.js
CHANGED
|
@@ -251,40 +251,22 @@ export async function cloneDb(sourceUrl, options = {}) {
|
|
|
251
251
|
}
|
|
252
252
|
console.log('');
|
|
253
253
|
|
|
254
|
-
// Track Prisma
|
|
255
|
-
let generateSuccess = false;
|
|
254
|
+
// Track Prisma migration result
|
|
256
255
|
let migrateSuccess = false;
|
|
257
256
|
|
|
258
|
-
// Step 7: Run Prisma
|
|
257
|
+
// Step 7: Run Prisma migrations (if not skipped)
|
|
259
258
|
if (!options.noPrisma) {
|
|
260
|
-
console.log(chalk.yellow('Step 7/7: Running Prisma
|
|
259
|
+
console.log(chalk.yellow('Step 7/7: Running Prisma migrations...'));
|
|
261
260
|
|
|
262
|
-
//
|
|
263
|
-
const
|
|
264
|
-
const generateStartTime = Date.now();
|
|
265
|
-
try {
|
|
266
|
-
await execInContainer(
|
|
267
|
-
composeFile,
|
|
268
|
-
'backend',
|
|
269
|
-
['npx', 'prisma', 'generate']
|
|
270
|
-
);
|
|
271
|
-
const generateDuration = ((Date.now() - generateStartTime) / 1000).toFixed(1);
|
|
272
|
-
generateSpinner.succeed(chalk.green(`Prisma client generated (${generateDuration}s)`));
|
|
273
|
-
generateSuccess = true;
|
|
274
|
-
} catch (error) {
|
|
275
|
-
generateSpinner.fail(chalk.red('Prisma generate failed'));
|
|
276
|
-
console.log(chalk.yellow(' Warning: You may need to run "npx prisma generate" manually in the backend container'));
|
|
277
|
-
console.log(chalk.gray(` Error: ${error.message}`));
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
// Run Prisma migrations
|
|
281
|
-
const migrateSpinner = ora('Running Prisma migrations...').start();
|
|
261
|
+
// Run Prisma migrations with timeout
|
|
262
|
+
const migrateSpinner = ora('Applying Prisma migrations...').start();
|
|
282
263
|
const migrateStartTime = Date.now();
|
|
283
264
|
try {
|
|
284
265
|
await execInContainer(
|
|
285
266
|
composeFile,
|
|
286
267
|
'backend',
|
|
287
|
-
['npx', 'prisma', 'migrate', 'deploy']
|
|
268
|
+
['npx', 'prisma', 'migrate', 'deploy'],
|
|
269
|
+
{ timeout: 180000 } // 3 minutes timeout
|
|
288
270
|
);
|
|
289
271
|
const migrateDuration = ((Date.now() - migrateStartTime) / 1000).toFixed(1);
|
|
290
272
|
migrateSpinner.succeed(chalk.green(`Prisma migrations completed (${migrateDuration}s)`));
|
|
@@ -316,13 +298,6 @@ export async function cloneDb(sourceUrl, options = {}) {
|
|
|
316
298
|
}
|
|
317
299
|
|
|
318
300
|
if (!options.noPrisma) {
|
|
319
|
-
// Show Prisma generate status
|
|
320
|
-
if (generateSuccess) {
|
|
321
|
-
console.log(chalk.gray(' ✓ Prisma client generated'));
|
|
322
|
-
} else {
|
|
323
|
-
console.log(chalk.yellow(' ⚠ Prisma client generation failed - run manually if needed'));
|
|
324
|
-
}
|
|
325
|
-
|
|
326
301
|
// Show Prisma migrate status
|
|
327
302
|
if (migrateSuccess) {
|
|
328
303
|
console.log(chalk.gray(' ✓ Prisma migrations applied'));
|
package/src/utils/docker.js
CHANGED
|
@@ -140,9 +140,11 @@ export async function getLogs(composeFile, service, options = {}) {
|
|
|
140
140
|
* @param {string} composeFile - Path to docker-compose.yml
|
|
141
141
|
* @param {string} service - Service name
|
|
142
142
|
* @param {string[]} command - Command to execute
|
|
143
|
+
* @param {Object} options - Optional execution options
|
|
144
|
+
* @param {number} options.timeout - Timeout in milliseconds (default: no timeout)
|
|
143
145
|
* @returns {Promise<string>}
|
|
144
146
|
*/
|
|
145
|
-
export async function execInContainer(composeFile, service, command) {
|
|
147
|
+
export async function execInContainer(composeFile, service, command, options = {}) {
|
|
146
148
|
const { stdout } = await execa('docker', [
|
|
147
149
|
'compose',
|
|
148
150
|
'-f',
|
|
@@ -151,8 +153,10 @@ export async function execInContainer(composeFile, service, command) {
|
|
|
151
153
|
'-T',
|
|
152
154
|
service,
|
|
153
155
|
...command
|
|
154
|
-
]
|
|
155
|
-
|
|
156
|
+
], {
|
|
157
|
+
timeout: options.timeout
|
|
158
|
+
});
|
|
159
|
+
|
|
156
160
|
return stdout;
|
|
157
161
|
}
|
|
158
162
|
|