@@ -16,6 +16,7 @@ import { readFile, writeFile } from 'fs/promises';
16
16
import fs from 'fs' ;
17
17
import archiver from 'archiver' ;
18
18
import ora from 'ora' ;
19
+ import { loggerDebug , loggerError , loggerInfo , yellow } from "./logger.js" ;
19
20
20
21
let NAME = '' ;
21
22
let REGION = '' ;
@@ -34,11 +35,6 @@ let APPSYNC_ATTACH_MUTATION = [];
34
35
let SCHEMA_MODEL = null ;
35
36
let thisOutputFolderPath = './output' ;
36
37
37
-
38
- function yellow ( text ) {
39
- return '\x1b[33m' + text + '\x1b[0m' ;
40
- }
41
-
42
38
async function getSchemaFields ( typeName ) {
43
39
/* To be updated as:
44
40
SCHEMA_MODEL.definitions
@@ -69,7 +65,7 @@ async function createDeploymentFile(folderPath, zipFilePath) {
69
65
archive . file ( './output/output.resolver.graphql.js' , { name : 'output.resolver.graphql.js' } )
70
66
await archive . finalize ( ) ;
71
67
} catch ( err ) {
72
- console . error ( 'Creating deployment zip file: ' + err ) ;
68
+ loggerError ( 'Error creating deployment zip file' , err ) ;
73
69
}
74
70
}
75
71
@@ -107,32 +103,32 @@ async function createAWSpipelineCDK({
107
103
108
104
if ( neptuneType === 'neptune-db' ) {
109
105
try {
110
- if ( ! quiet ) console . log ( 'Get Neptune Cluster Info') ;
106
+ loggerInfo ( 'Getting Neptune Cluster Info') ;
111
107
if ( ! quiet ) spinner = ora ( 'Getting ...' ) . start ( ) ;
112
108
neptuneClusterInfo = await getNeptuneClusterDbInfoBy ( NEPTUNE_DB_NAME , REGION ) ;
113
109
if ( ! quiet ) spinner . succeed ( 'Got Neptune Cluster Info' ) ;
114
110
if ( isNeptuneIAMAuth ) {
115
111
if ( ! neptuneClusterInfo . isIAMauth ) {
116
- console . error ( "The Neptune database authentication is set to VPC." ) ;
117
- console . error ( "Remove the --output-aws-pipeline-cdk-neptune-IAM option." ) ;
112
+ loggerError ( "The Neptune database authentication is set to VPC." ) ;
113
+ loggerError ( "Remove the --output-aws-pipeline-cdk-neptune-IAM option." ) ;
118
114
process . exit ( 1 ) ;
119
115
}
120
116
} else {
121
117
if ( neptuneClusterInfo . isIAMauth ) {
122
- console . error ( "The Neptune database authentication is set to IAM." ) ;
123
- console . error ( "Add the --output-aws-pipeline-cdk-neptune-IAM option." ) ;
118
+ loggerError ( "The Neptune database authentication is set to IAM." ) ;
119
+ loggerError ( "Add the --output-aws-pipeline-cdk-neptune-IAM option." ) ;
124
120
process . exit ( 1 ) ;
125
121
} else {
126
- if ( ! quiet ) console . log ( `Subnet Group: ` + yellow ( neptuneClusterInfo . dbSubnetGroup ) ) ;
122
+ loggerDebug ( `Subnet Group: ` + neptuneClusterInfo . dbSubnetGroup , { toConsole : true } ) ;
127
123
}
128
124
}
129
125
130
126
if ( neptuneClusterInfo . version != '' ) {
131
127
const v = neptuneClusterInfo . version ;
132
128
if ( lambdaFilesPath . includes ( 'SDK' ) == true && //semver.satisfies(v, '>=1.2.1.0') ) {
133
- ( v == '1.2.1.0' || v == '1.2.0.2' || v == '1.2.0.1' || v == '1.2.0.0' || v == '1.1.1.0' || v == '1.1.0.0' ) ) {
134
- console . error ( "Neptune SDK query is supported starting with Neptune versions 1.2.1.0.R5" ) ;
135
- console . error ( "Switch to Neptune HTTPS query with option --output-resolver-query-https" ) ;
129
+ ( v == '1.2.1.0' || v == '1.2.0.2' || v == '1.2.0.1' || v == '1.2.0.0' || v == '1.1.1.0' || v == '1.1.0.0' ) ) {
130
+ loggerError ( "Neptune SDK query is supported starting with Neptune versions 1.2.1.0.R5" ) ;
131
+ loggerError ( "Switch to Neptune HTTPS query with option --output-resolver-query-https" ) ;
136
132
process . exit ( 1 ) ;
137
133
}
138
134
}
@@ -143,13 +139,14 @@ async function createAWSpipelineCDK({
143
139
NEPTUNE_IAM_POLICY_RESOURCE = neptuneClusterInfo . iamPolicyResource ;
144
140
145
141
} catch ( error ) {
142
+ loggerError ( 'Error getting Neptune Cluster Info' , error ) ;
146
143
if ( ! quiet ) spinner . fail ( "Error getting Neptune Cluster Info." ) ;
147
144
if ( ! isNeptuneIAMAuth ) {
148
145
spinner . clear ( ) ;
149
- console . error ( "VPC data is not available to proceed." ) ;
146
+ loggerError ( "VPC data is not available to proceed." ) ;
150
147
process . exit ( 1 ) ;
151
148
} else {
152
- if ( ! quiet ) console . log ( "Proceeding without getting Neptune Cluster info." ) ;
149
+ loggerInfo ( "Proceeding without getting Neptune Cluster info." , { toConsole : true } ) ;
153
150
}
154
151
}
155
152
}
0 commit comments