|
3 | 3 | * Promotes tested migrations from staging to production with safety checks
|
4 | 4 | */
|
5 | 5 |
|
6 |
| -const Command = require('../../../lib/Command'); |
7 |
| -const MigrationMetadata = require('../../../lib/MigrationMetadata'); |
8 |
| -const fs = require('fs').promises; |
9 |
| -const path = require('path'); |
| 6 | +import Command from '../../../lib/Command.js'; |
| 7 | +import MigrationMetadata from '../../../lib/MigrationMetadata.js'; |
| 8 | +import { promises as fs, statSync } from 'fs'; |
| 9 | +import path from 'path'; |
| 10 | +import { spawn } from 'child_process'; |
10 | 11 |
|
11 | 12 | /**
|
12 | 13 | * Command to promote a tested migration to production
|
| 14 | + * @class |
13 | 15 | */
|
14 | 16 | class MigratePromoteCommand extends Command {
|
15 | 17 | static description = 'Promote tested migration to production';
|
@@ -245,8 +247,6 @@ class MigratePromoteCommand extends Command {
|
245 | 247 | async stageInGit(productionPath) {
|
246 | 248 | this.progress('Staging migration in Git...');
|
247 | 249 |
|
248 |
| - const { spawn } = require('child_process'); |
249 |
| - |
250 | 250 | return new Promise((resolve, reject) => {
|
251 | 251 | const git = spawn('git', ['add', productionPath], {
|
252 | 252 | stdio: ['ignore', 'pipe', 'pipe']
|
@@ -285,7 +285,7 @@ class MigratePromoteCommand extends Command {
|
285 | 285 | while (currentDir !== path.dirname(currentDir)) {
|
286 | 286 | const supabasePath = path.join(currentDir, 'supabase');
|
287 | 287 | try {
|
288 |
| - require('fs').statSync(supabasePath); |
| 288 | + statSync(supabasePath); |
289 | 289 | return supabasePath;
|
290 | 290 | } catch {
|
291 | 291 | currentDir = path.dirname(currentDir);
|
@@ -320,4 +320,17 @@ class MigratePromoteCommand extends Command {
|
320 | 320 | }
|
321 | 321 | }
|
322 | 322 |
|
323 |
| -module.exports = MigratePromoteCommand; |
| 323 | +/** |
| 324 | + * Promote tested migration to production handler |
| 325 | + * @param {Object} args - Command arguments |
| 326 | + * @param {Object} config - Configuration object |
| 327 | + * @param {Object} logger - Logger instance |
| 328 | + * @param {boolean} isProd - Production flag |
| 329 | + * @returns {Promise<Object>} Promotion result |
| 330 | + */ |
| 331 | +export default async function promoteHandler(args, config, logger, isProd) { |
| 332 | + const command = new MigratePromoteCommand(config, logger, isProd); |
| 333 | + return await command.performExecute(args); |
| 334 | +} |
| 335 | + |
| 336 | +export { MigratePromoteCommand }; |
0 commit comments