File tree Expand file tree Collapse file tree 4 files changed +37
-6
lines changed
libs/vscode/migrate/src/lib Expand file tree Collapse file tree 4 files changed +37
-6
lines changed Original file line number Diff line number Diff line change 1
1
import { getNxWorkspacePath } from '@nx-console/vscode-configuration' ;
2
- import { execSync } from 'child_process' ;
3
- import { existsSync , readFileSync , rmSync } from 'fs' ;
4
- import { join } from 'path' ;
5
2
import { window , commands } from 'vscode' ;
6
3
import { importMigrateUIApi , readMigrationsJsonMetadata } from './utils' ;
7
4
import { logAndShowError } from '@nx-console/vscode-output-channels' ;
Original file line number Diff line number Diff line change @@ -200,3 +200,28 @@ export async function viewDocumentation(migration: MigrationDetailsWithId) {
200
200
201
201
commands . executeCommand ( 'vscode.open' , url ) ;
202
202
}
203
+
204
+ export async function stopMigration ( migration : MigrationDetailsWithId ) {
205
+ try {
206
+ const workspacePath = getNxWorkspacePath ( ) ;
207
+ // TODO: Remove the `as any` cast once the repository is updated to use the latest Nx version that exports the `killMigrationProcess` function.
208
+ const migrateUIApi = ( await importMigrateUIApi ( workspacePath ) ) as any ;
209
+
210
+ const isStopped = migrateUIApi . killMigrationProcess (
211
+ migration . id ,
212
+ workspacePath ,
213
+ ) ;
214
+
215
+ if ( isStopped ) {
216
+ window . showInformationMessage (
217
+ `Migration "${ migration . name } " has been stopped.` ,
218
+ ) ;
219
+ } else {
220
+ window . showWarningMessage (
221
+ `Migration "${ migration . name } " was not running or could not be stopped.` ,
222
+ ) ;
223
+ }
224
+ } catch ( error ) {
225
+ window . showErrorMessage ( `Failed to stop migration: ${ error . message } ` ) ;
226
+ }
227
+ }
Original file line number Diff line number Diff line change @@ -15,10 +15,15 @@ export async function runSingleMigration(
15
15
title : `Running ${ migration . name } ` ,
16
16
} ,
17
17
async ( ) => {
18
- commands . executeCommand ( 'nxMigrate.refreshWebview' ) ;
19
-
20
18
const migrateUiApi = await importMigrateUIApi ( workspacePath ) ;
21
- migrateUiApi . runSingleMigration ( workspacePath , migration , configuration ) ;
19
+ await migrateUiApi . runSingleMigration (
20
+ workspacePath ,
21
+ migration ,
22
+ configuration ,
23
+ ) ;
24
+
25
+ // Refresh after migration completes and writes to migrations.json
26
+ commands . executeCommand ( 'nxMigrate.refreshWebview' ) ;
22
27
} ,
23
28
) ;
24
29
}
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import {
16
16
import {
17
17
cancelMigration ,
18
18
skipMigration ,
19
+ stopMigration ,
19
20
undoMigration ,
20
21
viewDocumentation ,
21
22
viewImplementation ,
@@ -101,6 +102,9 @@ export class MigrateWebview {
101
102
case 'view-documentation' :
102
103
viewDocumentation ( message . payload . migration ) ;
103
104
break ;
105
+ case 'stop-migration' :
106
+ stopMigration ( message . payload . migration ) ;
107
+ break ;
104
108
}
105
109
} ) ;
106
110
You can’t perform that action at this time.
0 commit comments