1
1
import assert from "node:assert" ;
2
2
import fs from "node:fs" ;
3
3
import path from "path" ;
4
- import { Box , Text } from "ink" ;
5
- import Table from "ink-table" ;
6
4
import { printWranglerBanner } from "../.." ;
7
5
import { withConfig } from "../../config" ;
8
6
import { confirm } from "../../dialogs" ;
@@ -11,7 +9,6 @@ import { CI } from "../../is-ci";
11
9
import isInteractive from "../../is-interactive" ;
12
10
import { logger } from "../../logger" ;
13
11
import { requireAuth } from "../../user" ;
14
- import { renderToString } from "../../utils/render" ;
15
12
import { createBackup } from "../backups" ;
16
13
import { DEFAULT_MIGRATION_PATH , DEFAULT_MIGRATION_TABLE } from "../constants" ;
17
14
import { executeSql } from "../execute" ;
@@ -112,17 +109,12 @@ export const ApplyHandler = withConfig<ApplyHandlerOptions>(
112
109
} ) ;
113
110
114
111
if ( unappliedMigrations . length === 0 ) {
115
- logger . log ( renderToString ( < Text > ✅ No migrations to apply!</ Text > ) ) ;
112
+ logger . log ( " ✅ No migrations to apply!" ) ;
116
113
return ;
117
114
}
118
- logger . log (
119
- renderToString (
120
- < Box flexDirection = "column" >
121
- < Text > Migrations to be applied:</ Text >
122
- < Table data = { unappliedMigrations } columns = { [ "name" ] } > </ Table >
123
- </ Box >
124
- )
125
- ) ;
115
+ logger . log ( "Migrations to be applied:" ) ;
116
+ logger . table ( unappliedMigrations . map ( ( m ) => ( { name : m . name } ) ) ) ;
117
+
126
118
const ok = await confirm (
127
119
`About to apply ${ unappliedMigrations . length } migration(s)
128
120
Your database may not be available to serve requests during the migration, continue?`
@@ -140,7 +132,7 @@ Your database may not be available to serve requests during the migration, conti
140
132
const accountId = await requireAuth ( config ) ;
141
133
const dbInfo = await getDatabaseInfoFromId ( accountId , databaseInfo ?. uuid ) ;
142
134
if ( dbInfo . version === "alpha" ) {
143
- logger . log ( renderToString ( < Text > 🕒 Creating backup...</ Text > ) ) ;
135
+ logger . log ( " 🕒 Creating backup..." ) ;
144
136
await createBackup ( accountId , databaseInfo . uuid ) ;
145
137
}
146
138
}
@@ -202,24 +194,14 @@ Your database may not be available to serve requests during the migration, conti
202
194
203
195
migration . status = success ? "✅" : "❌" ;
204
196
205
- logger . log (
206
- renderToString (
207
- < Box flexDirection = "column" >
208
- < Table data = { unappliedMigrations } columns = { [ "name" , "status" ] } />
209
- { errorNotes . length > 0 && (
210
- < Box flexDirection = "column" >
211
- < Text > </ Text >
212
- < Text >
213
- ❌ Migration { migration . name } { " " }
214
- { errorNotes . length > 0
215
- ? "failed with the following errors:"
216
- : "" }
217
- </ Text >
218
- </ Box >
219
- ) }
220
- </ Box >
221
- )
197
+ logger . table (
198
+ unappliedMigrations . map ( ( m ) => ( { name : m . name , status : m . status } ) )
222
199
) ;
200
+ if ( errorNotes . length > 0 ) {
201
+ logger . error (
202
+ `Migration ${ migration . name } failed with the following errors:`
203
+ ) ;
204
+ }
223
205
224
206
if ( errorNotes . length > 0 ) {
225
207
throw new UserError (
0 commit comments