( answers: SetupAnswers, )
| 1083 | return answers; |
| 1084 | } |
| 1085 | export async function postgresSetup( |
| 1086 | answers: SetupAnswers, |
| 1087 | ): Promise<SetupAnswers> { |
| 1088 | try { |
| 1089 | answers.POSTGRES_DB = await promptInput( |
| 1090 | "POSTGRES_DB", |
| 1091 | "Postgres database:", |
| 1092 | "talawa", |
| 1093 | ); |
| 1094 | if (answers.CI === "false") { |
| 1095 | answers.POSTGRES_MAPPED_HOST_IP = await promptInput( |
| 1096 | "POSTGRES_MAPPED_HOST_IP", |
| 1097 | "Postgres mapped host IP:", |
| 1098 | "127.0.0.1", |
| 1099 | ); |
| 1100 | answers.POSTGRES_MAPPED_PORT = await promptInput( |
| 1101 | "POSTGRES_MAPPED_PORT", |
| 1102 | "Postgres mapped port:", |
| 1103 | "5432", |
| 1104 | validatePort, |
| 1105 | ); |
| 1106 | } |
| 1107 | // Use already-synced API_POSTGRES_PASSWORD as default if available |
| 1108 | const postgresPasswordDefault = |
| 1109 | answers.API_POSTGRES_PASSWORD ?? |
| 1110 | answers.POSTGRES_PASSWORD ?? |
| 1111 | process.env.POSTGRES_PASSWORD ?? |
| 1112 | "password"; |
| 1113 | answers.POSTGRES_PASSWORD = await promptInput( |
| 1114 | "POSTGRES_PASSWORD", |
| 1115 | "Postgres password:", |
| 1116 | postgresPasswordDefault, |
| 1117 | ); |
| 1118 | // Sync back to API_POSTGRES_PASSWORD if it was set |
| 1119 | if (answers.API_POSTGRES_PASSWORD !== undefined) { |
| 1120 | if (answers.POSTGRES_PASSWORD !== answers.API_POSTGRES_PASSWORD) { |
| 1121 | // User changed POSTGRES_PASSWORD, update API_POSTGRES_PASSWORD to match |
| 1122 | answers.API_POSTGRES_PASSWORD = answers.POSTGRES_PASSWORD; |
| 1123 | process.env.POSTGRES_PASSWORD = answers.POSTGRES_PASSWORD; |
| 1124 | console.log( |
| 1125 | "ℹ️ API_POSTGRES_PASSWORD updated to match POSTGRES_PASSWORD", |
| 1126 | ); |
| 1127 | } |
| 1128 | } else { |
| 1129 | // No API_POSTGRES_PASSWORD set yet, set it now |
| 1130 | answers.API_POSTGRES_PASSWORD = answers.POSTGRES_PASSWORD; |
| 1131 | process.env.POSTGRES_PASSWORD = answers.POSTGRES_PASSWORD; |
| 1132 | } |
| 1133 | answers.POSTGRES_USER = await promptInput( |
| 1134 | "POSTGRES_USER", |
| 1135 | "Postgres user:", |
| 1136 | "talawa", |
| 1137 | ); |
| 1138 | } catch (err) { |
| 1139 | await handlePromptError(err); |
| 1140 | } |
| 1141 | return answers; |
| 1142 | } |
no test coverage detected