Skip to content

Commit

Permalink
fix: failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
disha1202 committed Jan 18, 2024
1 parent 8fa7132 commit d0c419f
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ dotenv.config();
async function checkConnection(url: string): Promise<any> {
console.log('\nChecking Talawa-API connection....');
let isConnected = false;
const resp = await fetch(url).then((res) => {
isConnected = true;
console.log('\nConnection to Talawa-API successful! 🎉');
}).catch((err) => {
console.log(
'\nTalawa-API service is unavailable. Is it running? Check your network connectivity too.'
);
});
await fetch(url)
.then((res) => {
isConnected = true;
console.log('\nConnection to Talawa-API successful! 🎉');
})
.catch((err) => {
console.log(
'\nTalawa-API service is unavailable. Is it running? Check your network connectivity too.',
);
});
return isConnected;
}

Expand All @@ -40,7 +42,7 @@ function checkEnvFile(): void {
if (misplaced.length > 0) {
const config = dotenv.parse(fs.readFileSync('.env.example'));
misplaced.map((key) =>
fs.appendFileSync('.env', `${key}=${config[key]}\n`)
fs.appendFileSync('.env', `${key}=${config[key]}\n`),
);
}
}
Expand All @@ -67,7 +69,7 @@ async function main(): Promise<void> {

if (process.env.REACT_APP_TALAWA_URL) {
console.log(
`\nEndpoint for accessing talawa-api graphql service already exists with the value:\n${process.env.REACT_APP_TALAWA_URL}`
`\nEndpoint for accessing talawa-api graphql service already exists with the value:\n${process.env.REACT_APP_TALAWA_URL}`,
);
shouldSetTalawaApiUrl = true;
} else {
Expand All @@ -91,13 +93,13 @@ async function main(): Promise<void> {
}

const talawaApiUrl = dotenv.parse(
fs.readFileSync('.env')
fs.readFileSync('.env'),
).REACT_APP_TALAWA_URL;

fs.readFile('.env', 'utf8', (err, data) => {
const result = data.replace(
`REACT_APP_TALAWA_URL=${talawaApiUrl}`,
`REACT_APP_TALAWA_URL=${endpoint}`
`REACT_APP_TALAWA_URL=${endpoint}`,
);
fs.writeFileSync('.env', result, 'utf8');
});
Expand All @@ -112,20 +114,20 @@ async function main(): Promise<void> {

if (shouldUseRecaptcha) {
const useRecaptcha = dotenv.parse(
fs.readFileSync('.env')
fs.readFileSync('.env'),
).REACT_APP_USE_RECAPTCHA;

fs.readFile('.env', 'utf8', (err, data) => {
const result = data.replace(
`REACT_APP_USE_RECAPTCHA=${useRecaptcha}`,
`REACT_APP_USE_RECAPTCHA=yes`
`REACT_APP_USE_RECAPTCHA=yes`,
);
fs.writeFileSync('.env', result, 'utf8');
});
let shouldSetRecaptchaSiteKey: boolean;
if (process.env.REACT_APP_RECAPTCHA_SITE_KEY) {
console.log(
`\nreCAPTCHA site key already exists with the value ${process.env.REACT_APP_RECAPTCHA_SITE_KEY}`
`\nreCAPTCHA site key already exists with the value ${process.env.REACT_APP_RECAPTCHA_SITE_KEY}`,
);
shouldSetRecaptchaSiteKey = true;
} else {
Expand Down Expand Up @@ -154,13 +156,13 @@ async function main(): Promise<void> {
]);

const recaptchaSiteKey = dotenv.parse(
fs.readFileSync('.env')
fs.readFileSync('.env'),
).REACT_APP_RECAPTCHA_SITE_KEY;

fs.readFile('.env', 'utf8', (err, data) => {
const result = data.replace(
`REACT_APP_RECAPTCHA_SITE_KEY=${recaptchaSiteKey}`,
`REACT_APP_RECAPTCHA_SITE_KEY=${recaptchaSiteKeyInput}`
`REACT_APP_RECAPTCHA_SITE_KEY=${recaptchaSiteKeyInput}`,
);
fs.writeFileSync('.env', result, 'utf8');
});
Expand All @@ -185,7 +187,7 @@ async function main(): Promise<void> {
}

console.log(
'\nCongratulations! Talawa Admin has been successfully setup! 🥂🎉'
'\nCongratulations! Talawa Admin has been successfully setup! 🥂🎉',
);
}

Expand Down

0 comments on commit d0c419f

Please sign in to comment.