5
5
6
6
import * as vscode from 'vscode'
7
7
import * as fs from 'fs' // eslint-disable-line no-restricted-imports
8
- import * as os from 'os'
9
- import * as xml2js from 'xml2js'
10
8
import path from 'path'
11
9
import { getLogger } from '../../shared/logger'
12
10
import * as CodeWhispererConstants from '../models/constants'
@@ -18,7 +16,6 @@ import {
18
16
FolderInfo ,
19
17
ZipManifest ,
20
18
TransformByQStatus ,
21
- DB ,
22
19
TransformationType ,
23
20
TransformationCandidateProject ,
24
21
} from '../models/model'
@@ -56,7 +53,6 @@ import { MetadataResult } from '../../shared/telemetry/telemetryClient'
56
53
import { submitFeedback } from '../../feedback/vue/submitFeedback'
57
54
import { placeholder } from '../../shared/vscode/commands2'
58
55
import {
59
- AbsolutePathDetectedError ,
60
56
AlternateDependencyVersionsNotFoundError ,
61
57
JavaHomeNotSetError ,
62
58
JobStartError ,
@@ -71,6 +67,7 @@ import {
71
67
getJsonValuesFromManifestFile ,
72
68
highlightPomIssueInProject ,
73
69
parseVersionsListFromPomFile ,
70
+ setMaven ,
74
71
writeLogs ,
75
72
} from '../service/transformByQ/transformFileHandler'
76
73
import { sleep } from '../../shared/utilities/timeoutUtils'
@@ -81,7 +78,6 @@ import { setContext } from '../../shared/vscode/setContext'
81
78
import { makeTemporaryToolkitFolder } from '../../shared'
82
79
import globals from '../../shared/extensionGlobals'
83
80
import { convertDateToTimestamp } from '../../shared/datetime'
84
- import { isWin } from '../../shared/vscode/env'
85
81
import { findStringInDirectory } from '../../shared/utilities/workspaceUtils'
86
82
87
83
function getFeedbackCommentData ( ) {
@@ -111,63 +107,6 @@ export async function processSQLConversionTransformFormInput(pathToProject: stri
111
107
// targetJDKVersion defaults to JDK17, the only supported version, which is fine
112
108
}
113
109
114
- export async function validateSQLMetadataFile ( fileContents : string , message : any ) {
115
- try {
116
- const sctData = await xml2js . parseStringPromise ( fileContents )
117
- const dbEntities = sctData [ 'tree' ] [ 'instances' ] [ 0 ] [ 'ProjectModel' ] [ 0 ] [ 'entities' ] [ 0 ]
118
- const sourceDB = dbEntities [ 'sources' ] [ 0 ] [ 'DbServer' ] [ 0 ] [ '$' ] [ 'vendor' ] . trim ( ) . toUpperCase ( )
119
- const targetDB = dbEntities [ 'targets' ] [ 0 ] [ 'DbServer' ] [ 0 ] [ '$' ] [ 'vendor' ] . trim ( ) . toUpperCase ( )
120
- const sourceServerName = dbEntities [ 'sources' ] [ 0 ] [ 'DbServer' ] [ 0 ] [ '$' ] [ 'name' ] . trim ( )
121
- transformByQState . setSourceServerName ( sourceServerName )
122
- if ( sourceDB !== DB . ORACLE ) {
123
- transformByQState . getChatMessenger ( ) ?. sendUnrecoverableErrorResponse ( 'unsupported-source-db' , message . tabID )
124
- return false
125
- } else if ( targetDB !== DB . AURORA_POSTGRESQL && targetDB !== DB . RDS_POSTGRESQL ) {
126
- transformByQState . getChatMessenger ( ) ?. sendUnrecoverableErrorResponse ( 'unsupported-target-db' , message . tabID )
127
- return false
128
- }
129
- transformByQState . setSourceDB ( sourceDB )
130
- transformByQState . setTargetDB ( targetDB )
131
-
132
- const serverNodeLocations =
133
- sctData [ 'tree' ] [ 'instances' ] [ 0 ] [ 'ProjectModel' ] [ 0 ] [ 'relations' ] [ 0 ] [ 'server-node-location' ]
134
- const schemaNames = new Set < string > ( )
135
- serverNodeLocations . forEach ( ( serverNodeLocation : any ) => {
136
- const schemaNodes = serverNodeLocation [ 'FullNameNodeInfoList' ] [ 0 ] [ 'nameParts' ] [ 0 ] [
137
- 'FullNameNodeInfo'
138
- ] . filter ( ( node : any ) => node [ '$' ] [ 'typeNode' ] . toLowerCase ( ) === 'schema' )
139
- schemaNodes . forEach ( ( node : any ) => {
140
- schemaNames . add ( node [ '$' ] [ 'nameNode' ] . toUpperCase ( ) )
141
- } )
142
- } )
143
- transformByQState . setSchemaOptions ( schemaNames ) // user will choose one of these
144
- getLogger ( ) . info (
145
- `CodeTransformation: Parsed .sct file with source DB: ${ sourceDB } , target DB: ${ targetDB } , source host name: ${ sourceServerName } , and schema names: ${ Array . from ( schemaNames ) } `
146
- )
147
- } catch ( err : any ) {
148
- getLogger ( ) . error ( 'CodeTransformation: Error parsing .sct file. %O' , err )
149
- transformByQState . getChatMessenger ( ) ?. sendUnrecoverableErrorResponse ( 'error-parsing-sct-file' , message . tabID )
150
- return false
151
- }
152
- return true
153
- }
154
-
155
- export async function setMaven ( ) {
156
- let mavenWrapperExecutableName = isWin ( ) ? 'mvnw.cmd' : 'mvnw'
157
- const mavenWrapperExecutablePath = path . join ( transformByQState . getProjectPath ( ) , mavenWrapperExecutableName )
158
- if ( fs . existsSync ( mavenWrapperExecutablePath ) ) {
159
- if ( mavenWrapperExecutableName === 'mvnw' ) {
160
- mavenWrapperExecutableName = './mvnw' // add the './' for non-Windows
161
- } else if ( mavenWrapperExecutableName === 'mvnw.cmd' ) {
162
- mavenWrapperExecutableName = '.\\mvnw.cmd' // add the '.\' for Windows
163
- }
164
- transformByQState . setMavenName ( mavenWrapperExecutableName )
165
- } else {
166
- transformByQState . setMavenName ( 'mvn' )
167
- }
168
- getLogger ( ) . info ( `CodeTransformation: using Maven ${ transformByQState . getMavenName ( ) } ` )
169
- }
170
-
171
110
async function validateJavaHome ( ) : Promise < boolean > {
172
111
const versionData = await getVersionData ( )
173
112
let javaVersionUsedByMaven = versionData [ 1 ]
@@ -290,41 +229,6 @@ export async function finalizeTransformByQ(status: string) {
290
229
}
291
230
}
292
231
293
- export async function parseBuildFile ( ) {
294
- try {
295
- const absolutePaths = [ 'users/' , 'system/' , 'volumes/' , 'c:\\' , 'd:\\' ]
296
- const alias = path . basename ( os . homedir ( ) )
297
- absolutePaths . push ( alias )
298
- const buildFilePath = path . join ( transformByQState . getProjectPath ( ) , 'pom.xml' )
299
- if ( fs . existsSync ( buildFilePath ) ) {
300
- const buildFileContents = fs . readFileSync ( buildFilePath ) . toString ( ) . toLowerCase ( )
301
- const detectedPaths = [ ]
302
- for ( const absolutePath of absolutePaths ) {
303
- if ( buildFileContents . includes ( absolutePath ) ) {
304
- detectedPaths . push ( absolutePath )
305
- }
306
- }
307
- if ( detectedPaths . length > 0 ) {
308
- const warningMessage = CodeWhispererConstants . absolutePathDetectedMessage (
309
- detectedPaths . length ,
310
- path . basename ( buildFilePath ) ,
311
- detectedPaths . join ( ', ' )
312
- )
313
- transformByQState . getChatControllers ( ) ?. errorThrown . fire ( {
314
- error : new AbsolutePathDetectedError ( warningMessage ) ,
315
- tabID : ChatSessionManager . Instance . getSession ( ) . tabID ,
316
- } )
317
- getLogger ( ) . info ( 'CodeTransformation: absolute path potentially in build file' )
318
- return warningMessage
319
- }
320
- }
321
- } catch ( err : any ) {
322
- // swallow error
323
- getLogger ( ) . error ( `CodeTransformation: error scanning for absolute paths, tranformation continuing: ${ err } ` )
324
- }
325
- return undefined
326
- }
327
-
328
232
export async function preTransformationUploadCode ( ) {
329
233
await vscode . commands . executeCommand ( 'aws.amazonq.transformationHub.focus' )
330
234
@@ -499,12 +403,6 @@ export async function openHilPomFile() {
499
403
)
500
404
}
501
405
502
- export async function openBuildLogFile ( ) {
503
- const logFilePath = transformByQState . getPreBuildLogFilePath ( )
504
- const doc = await vscode . workspace . openTextDocument ( logFilePath )
505
- await vscode . window . showTextDocument ( doc )
506
- }
507
-
508
406
export async function terminateHILEarly ( jobID : string ) {
509
407
// Call resume with "REJECTED" state which will put our service
510
408
// back into the normal flow and will not trigger HIL again for this step
0 commit comments