Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance setup.js for Improved Docker Compatibility #2447 #2615

Closed
Show file tree
Hide file tree
Changes from 175 commits
Commits
Show all changes
209 commits
Select commit Hold shift + click to select a range
5821d59
added docker check to workflow
VanshikaSabharwal Nov 8, 2024
1519682
Merge branch 'develop' into docker-1
VanshikaSabharwal Nov 8, 2024
81bbb3e
made recommended changes to docker check in workflow
VanshikaSabharwal Nov 8, 2024
7d04c94
made recommended changes to docker check in workflow
VanshikaSabharwal Nov 8, 2024
f8389f6
added changes to docker check inn workflow as recommended
VanshikaSabharwal Nov 8, 2024
f54dcf2
added changes
VanshikaSabharwal Nov 8, 2024
b93aed6
updated indentation in pull-request.yml file
VanshikaSabharwal Nov 8, 2024
a0ee511
updated indentation in pull-request.yml file
VanshikaSabharwal Nov 8, 2024
235d163
added Dockerfile and Docker-compose.yml file
VanshikaSabharwal Nov 10, 2024
66f4843
added Dockerfile and Docker-compose.yml file
VanshikaSabharwal Nov 10, 2024
aef2485
Merge branch 'develop' into dockerfile-1
VanshikaSabharwal Nov 10, 2024
0fa9fe5
updated .docker-ignore file
VanshikaSabharwal Nov 10, 2024
88626b7
Merge branch 'dockerfile-1' of https://github.com/VanshikaSabharwal/t…
VanshikaSabharwal Nov 10, 2024
6fd1e01
Merge branch 'develop' into docker-1
VanshikaSabharwal Nov 11, 2024
e572cf4
Merge branch 'docker-1' of https://github.com/VanshikaSabharwal/talaw…
VanshikaSabharwal Nov 11, 2024
cfdeff5
added recommended changes by code rabbit
VanshikaSabharwal Nov 11, 2024
e188853
added recommended changes by code rabbit
VanshikaSabharwal Nov 11, 2024
9a2b428
added recommended changes by code rabbit
VanshikaSabharwal Nov 11, 2024
12e5474
added recommended changes by code rabbit
VanshikaSabharwal Nov 11, 2024
17a12f7
added recommended changes by code rabbit
VanshikaSabharwal Nov 11, 2024
a44ecdb
added recommended changes by code rabbit
VanshikaSabharwal Nov 11, 2024
526a2cf
properly formatted code
VanshikaSabharwal Nov 11, 2024
82836f0
chore(deps): bump sass from 1.80.6 to 1.80.7 (#2433)
dependabot[bot] Nov 14, 2024
a97314c
chore(deps): bump eslint-plugin-import from 2.30.0 to 2.31.0 (#2434)
dependabot[bot] Nov 14, 2024
32eb6a9
chore(deps): bump @mui/x-charts from 7.22.1 to 7.22.2 (#2435)
dependabot[bot] Nov 14, 2024
ab509f6
chore(deps): bump @types/react from 18.3.3 to 18.3.12 (#2436)
dependabot[bot] Nov 14, 2024
fb913e1
Update pull-request.yml
palisadoes Nov 14, 2024
d4fca6f
trying to make docker check pass
VanshikaSabharwal Nov 15, 2024
41bb9cf
Merge branch 'develop' into docker-1
VanshikaSabharwal Nov 15, 2024
7966dda
trying to make docker check pass
VanshikaSabharwal Nov 15, 2024
ec8ec5f
Merge branch 'docker-1' of https://github.com/VanshikaSabharwal/talaw…
VanshikaSabharwal Nov 15, 2024
96d5e9a
updated INSTALLATION.md
VanshikaSabharwal Nov 15, 2024
ef08944
updated INSTALLATION.md
VanshikaSabharwal Nov 15, 2024
8236c9a
added recommended changes to INSTALLATION.md
VanshikaSabharwal Nov 15, 2024
b09c696
added recommended changes to INSTALLATION.md
VanshikaSabharwal Nov 15, 2024
c8c42a4
added recommended changes to INSTALLATION.md
VanshikaSabharwal Nov 15, 2024
d16b95e
Update dependabot.yaml
palisadoes Nov 16, 2024
aa1cb05
updated docker workflow
VanshikaSabharwal Nov 17, 2024
5e38619
Merge branch 'develop' into docker-1
VanshikaSabharwal Nov 17, 2024
435c0bd
Merge branch 'docker-1' of https://github.com/VanshikaSabharwal/talaw…
VanshikaSabharwal Nov 17, 2024
97bb5e6
updated INSTALLATION.md
VanshikaSabharwal Nov 17, 2024
0b47923
updated INSTALLATION.md
VanshikaSabharwal Nov 17, 2024
31b4bc5
updated INSTALLATION.md
VanshikaSabharwal Nov 17, 2024
c0884d1
updated setup.ts
VanshikaSabharwal Nov 17, 2024
9412b27
Merge branch 'develop-postgres' into setup
VanshikaSabharwal Nov 17, 2024
eac28f7
did recommended changes to setup.ts
VanshikaSabharwal Nov 17, 2024
f1cd66a
Merge branch 'setup' of https://github.com/VanshikaSabharwal/talawa-a…
VanshikaSabharwal Nov 17, 2024
15282bc
updated setup.ts
VanshikaSabharwal Nov 18, 2024
5830ec7
updated INSTALLATION.md
VanshikaSabharwal Nov 18, 2024
0ebafd5
Merge branch 'develop-postgres' into setup
VanshikaSabharwal Nov 19, 2024
c426e45
Merge branch 'develop-postgres' into setup
VanshikaSabharwal Nov 23, 2024
97dde86
Merge branch 'develop-postgres' into setup
VanshikaSabharwal Nov 24, 2024
f9d03de
pull-request.yml formatted
VanshikaSabharwal Nov 24, 2024
6243659
solved the problem with linting of dockerfile in pull-request.yml file
VanshikaSabharwal Nov 24, 2024
4c539cb
solved the problem with linting of dockerfile in pull-request.yml file
VanshikaSabharwal Nov 24, 2024
39115fb
solved the problem with linting of dockerfile in pull-request.yml file
VanshikaSabharwal Nov 24, 2024
3192d45
made recommended changes to pull-request.yml
VanshikaSabharwal Nov 24, 2024
5cd5a48
testing eslint fix
VanshikaSabharwal Nov 24, 2024
da0113c
testing eslint
VanshikaSabharwal Nov 24, 2024
de5cb43
testing eslint
VanshikaSabharwal Nov 24, 2024
2b4f3a0
added askForDocker file with test file
VanshikaSabharwal Nov 25, 2024
3174ea4
Merge branch 'develop-postgres' into setup
VanshikaSabharwal Nov 25, 2024
7eb38f7
Merge branch 'develop-postgres' into setup
VanshikaSabharwal Nov 26, 2024
af8cd4a
updated setup.ts file
VanshikaSabharwal Nov 28, 2024
594765d
updated askForDocker
VanshikaSabharwal Nov 28, 2024
cd99eb0
Merge branch 'develop-postgres' into setup
VanshikaSabharwal Nov 28, 2024
5c41622
updated linting error
VanshikaSabharwal Nov 29, 2024
f9b02a1
Merge branch 'develop-postgres' into setup
VanshikaSabharwal Dec 1, 2024
05dcfc8
adding
VanshikaSabharwal Dec 2, 2024
bab3153
added vitest
VanshikaSabharwal Dec 2, 2024
99bd739
testing
VanshikaSabharwal Dec 2, 2024
c298068
testing type error issue
VanshikaSabharwal Dec 2, 2024
a8ee09e
updated eslint_disable_check.py
VanshikaSabharwal Dec 2, 2024
425b45f
updated eslint_disable_check.py
VanshikaSabharwal Dec 2, 2024
dd635c4
updated eslint_disable_check.py
VanshikaSabharwal Dec 2, 2024
f27ed9e
updated pull-request.yml
VanshikaSabharwal Dec 2, 2024
9316808
updated pull-request.yml
VanshikaSabharwal Dec 2, 2024
ae3dac5
updated pull-request.yml
VanshikaSabharwal Dec 2, 2024
1f9cacc
updated pull-request.yml
VanshikaSabharwal Dec 2, 2024
e863c6b
updated .eslintrc.json
VanshikaSabharwal Dec 4, 2024
a859d25
updated .eslintrc.json
VanshikaSabharwal Dec 4, 2024
418092e
updated .eslintrc.json
VanshikaSabharwal Dec 4, 2024
65e2b3a
updated .eslintrc.json
VanshikaSabharwal Dec 4, 2024
55a8e7c
updated .eslintrc.json
VanshikaSabharwal Dec 4, 2024
3591428
updated .eslintrc.json
VanshikaSabharwal Dec 4, 2024
c860961
updated .eslintrc.json
VanshikaSabharwal Dec 4, 2024
5be01a6
added linters for dockerfile and markdown file
VanshikaSabharwal Dec 4, 2024
ff4ea49
Revert "updated .eslintrc.json"
VanshikaSabharwal Dec 4, 2024
da04be8
testing
VanshikaSabharwal Dec 4, 2024
557c203
testing changes
VanshikaSabharwal Dec 4, 2024
780ae27
testing changes
VanshikaSabharwal Dec 4, 2024
0018f5b
added changes to pass test
VanshikaSabharwal Dec 7, 2024
04eea57
added changes to pass test
VanshikaSabharwal Dec 7, 2024
e391f42
added changes to pass test
VanshikaSabharwal Dec 7, 2024
a67137c
Merge branch 'develop-postgres' into setup
VanshikaSabharwal Dec 12, 2024
a759a77
Merge branch 'develop-postgres' into setup
VanshikaSabharwal Dec 19, 2024
385f3de
corrected error tagTemplate
VanshikaSabharwal Dec 20, 2024
e0a9962
Merge branch 'develop-postgres' into setup
VanshikaSabharwal Dec 20, 2024
d0ab2cb
Merge branch 'develop-postgres' into setup
VanshikaSabharwal Dec 21, 2024
63ad49e
Merge branch 'develop-postgres' into setup
VanshikaSabharwal Dec 22, 2024
2b4107d
Merge branch 'develop-postgres' into setup
VanshikaSabharwal Dec 23, 2024
7cb6a69
updated jest to vitest in askForDocker file
VanshikaSabharwal Dec 23, 2024
3a207f3
removed unwanted changes from files
VanshikaSabharwal Dec 23, 2024
412a030
Merge branch 'setup' of https://github.com/VanshikaSabharwal/talawa-a…
VanshikaSabharwal Dec 23, 2024
4234bdb
Merge branch 'develop-postgres' into setup
palisadoes Dec 24, 2024
7270b0c
Merge branch 'develop-postgres' into setup
VanshikaSabharwal Dec 25, 2024
876b032
removed the unnecessary code and added vitest to askForDocker
VanshikaSabharwal Dec 25, 2024
dde6967
Merge branch 'setup' of https://github.com/VanshikaSabharwal/talawa-a…
VanshikaSabharwal Dec 25, 2024
43182bd
added formatting to src/style/app.module.css
VanshikaSabharwal Dec 25, 2024
2540094
Merge branch 'develop-postgres' into setup
VanshikaSabharwal Dec 25, 2024
321a124
Merge branch 'develop-postgres' into setup
VanshikaSabharwal Dec 25, 2024
5fa02a6
testing linting error
VanshikaSabharwal Dec 25, 2024
d9f24d4
Merge branch 'setup' of https://github.com/VanshikaSabharwal/talawa-a…
VanshikaSabharwal Dec 25, 2024
ee1104b
testing linting error
VanshikaSabharwal Dec 25, 2024
9e26e52
testing linting error
VanshikaSabharwal Dec 25, 2024
f0a2a46
Merge branch 'develop-postgres' into setup
VanshikaSabharwal Dec 26, 2024
249958d
Merge branch 'develop-postgres' into setup
VanshikaSabharwal Dec 26, 2024
be94ca8
Merge branch 'develop-postgres' into setup
VanshikaSabharwal Dec 29, 2024
c7f5b95
added changes
VanshikaSabharwal Dec 29, 2024
e429cc0
updated files
VanshikaSabharwal Dec 29, 2024
b936212
Update components_OrgUpdate_OrgUpdate.md
VanshikaSabharwal Dec 29, 2024
d4bf53b
Update screens_OrganizationDashboard_OrganizationDashboardMocks.md
VanshikaSabharwal Dec 29, 2024
aec3202
Update README.md
VanshikaSabharwal Dec 29, 2024
2d01e27
Update README.md
VanshikaSabharwal Dec 29, 2024
9d4eab4
Update components_OrgUpdate_OrgUpdateMocks.md
VanshikaSabharwal Dec 29, 2024
1607713
Update screens_Users_UsersMocks.md
VanshikaSabharwal Dec 29, 2024
8fa7750
Update check-localstorage-usage.js
VanshikaSabharwal Dec 29, 2024
be63e45
Update update-toc.js
VanshikaSabharwal Dec 29, 2024
bcab85a
Update PR_GUIDELINES.md
VanshikaSabharwal Dec 29, 2024
e2759a9
Update ISSUE_GUIDELINES.md
VanshikaSabharwal Dec 29, 2024
ae0137b
Update DOCUMENTATION.md
VanshikaSabharwal Dec 29, 2024
c9a6a5f
Update CODE_STYLE.md
VanshikaSabharwal Dec 29, 2024
f501134
Merge branch 'setup' of https://github.com/VanshikaSabharwal/talawa-a…
VanshikaSabharwal Dec 29, 2024
f9c43b7
increased code coverage in askForDocker.spec.ts
VanshikaSabharwal Dec 29, 2024
8cfb45f
increased code coverage in askForDocker.spec.ts
VanshikaSabharwal Dec 29, 2024
b57f8c9
increased code coverage in askForDocker.spec.ts
VanshikaSabharwal Dec 29, 2024
6f34255
increased code coverage in askForDocker.spec.ts
VanshikaSabharwal Dec 29, 2024
e57b8cd
increased code coverage in askForDocker.spec.ts
VanshikaSabharwal Dec 29, 2024
b1e083d
converted files in setup from jest to vitest
VanshikaSabharwal Dec 29, 2024
b7abbd1
updated askForTalawaApiUrl.spec.ts
VanshikaSabharwal Dec 29, 2024
b8a4b28
Merge branch 'develop-postgres' into setup
VanshikaSabharwal Dec 29, 2024
6504641
Merge branch 'develop-postgres' into setup
VanshikaSabharwal Dec 29, 2024
a3aa19f
Merge branch 'develop-postgres' into setup
VanshikaSabharwal Dec 29, 2024
14ce9ec
updated askForTalawaApiUrl.spec.ts
VanshikaSabharwal Dec 29, 2024
0e7f621
Merge branch 'setup' of https://github.com/VanshikaSabharwal/talawa-a…
VanshikaSabharwal Dec 29, 2024
a95cc53
updated askForTalawaApiUrl.spec.ts
VanshikaSabharwal Dec 29, 2024
c212b62
updated askForTalawaApiUrl.spec.ts
VanshikaSabharwal Dec 29, 2024
1f6e219
Merge branch 'develop-postgres' into setup
VanshikaSabharwal Dec 29, 2024
72c5053
Merge branch 'develop-postgres' into setup
VanshikaSabharwal Dec 30, 2024
ea79db4
Merge branch 'develop-postgres' into setup
VanshikaSabharwal Dec 31, 2024
b11ad92
added tests to setup.ts
VanshikaSabharwal Dec 31, 2024
747e4ae
Merge branch 'develop-postgres' into setup
VanshikaSabharwal Dec 31, 2024
78be935
Merge branch 'setup' of https://github.com/VanshikaSabharwal/talawa-a…
VanshikaSabharwal Dec 31, 2024
0aa6145
added tests to setup.ts
VanshikaSabharwal Dec 31, 2024
c113de5
Update package-lock.json
VanshikaSabharwal Dec 31, 2024
d5b114b
increased test coverage
VanshikaSabharwal Jan 1, 2025
16fb1bb
Merge branch 'setup' of https://github.com/VanshikaSabharwal/talawa-a…
VanshikaSabharwal Jan 1, 2025
9b28317
Merge branch 'develop-postgres' into setup
VanshikaSabharwal Jan 1, 2025
21fbf78
increased test coverage
VanshikaSabharwal Jan 1, 2025
a440d61
added tests to setup.ts
VanshikaSabharwal Jan 1, 2025
b5e7da0
Merge branch 'develop-postgres' into setup
VanshikaSabharwal Jan 1, 2025
da7d53e
passing all tests locally
VanshikaSabharwal Jan 2, 2025
49c5a8f
added recommended changes by CodeRabbit
VanshikaSabharwal Jan 3, 2025
dc3ee86
added test code for askForUpdatePort.ts
VanshikaSabharwal Jan 3, 2025
ddf1021
added recommended changes by CodeRabbit
VanshikaSabharwal Jan 3, 2025
913e942
Updated CONTRIBUTING.md
VanshikaSabharwal Jan 3, 2025
4b647d3
Update CONTRIBUTING.md
VanshikaSabharwal Jan 3, 2025
de811ba
formatted CONTRIBUTING.md
VanshikaSabharwal Jan 3, 2025
9771283
formatted CONTRIBUTING.md
VanshikaSabharwal Jan 3, 2025
3ecd0ae
formatted CONTRIBUTING.md
VanshikaSabharwal Jan 3, 2025
723d4a0
formatted CONTRIBUTING.md
VanshikaSabharwal Jan 3, 2025
efd22b8
formatted CONTRIBUTING.md
VanshikaSabharwal Jan 3, 2025
54b73b8
committing in order to make coderabbit approve changes
VanshikaSabharwal Jan 4, 2025
0b80cd6
committing in order to make coderabbit approve changes
VanshikaSabharwal Jan 4, 2025
8cc90a6
Update package-lock.json
VanshikaSabharwal Jan 5, 2025
0e9814c
Update AddOn.tsx
VanshikaSabharwal Jan 5, 2025
96a931d
making code rabbit approve changes
VanshikaSabharwal Jan 5, 2025
0132d83
Delete src/components/CheckIn/tagTemplate.ts
rishav-jha-mech Jan 5, 2025
13c484f
revert changes made to tagTemplate.ts
rishav-jha-mech Jan 5, 2025
66d6ef2
EOL changed
rishav-jha-mech Jan 5, 2025
70f5c88
revert tagTemplate.ts
rishav-jha-mech Jan 5, 2025
6b06271
add tagTemplate.ts via upload
rishav-jha-mech Jan 5, 2025
f505d50
EOL changed
rishav-jha-mech Jan 5, 2025
466e073
reverting changes from tagTemplate and AddOn.tsx
VanshikaSabharwal Jan 6, 2025
7635e20
Merge branch 'setup' of https://github.com/VanshikaSabharwal/talawa-a…
VanshikaSabharwal Jan 6, 2025
3fabff4
reverting changes from tagTemplate and AddOn.tsx
VanshikaSabharwal Jan 6, 2025
af552c6
reverting changes from tagTemplate and AddOn.tsx
VanshikaSabharwal Jan 6, 2025
4c6499d
reverting changes from tagTemplate and AddOn.tsx
VanshikaSabharwal Jan 6, 2025
411e09d
Update README.md
VanshikaSabharwal Jan 6, 2025
6e14ccc
Update PR_GUIDELINES.md
VanshikaSabharwal Jan 6, 2025
45c92c5
Update DOCUMENTATION.md
VanshikaSabharwal Jan 6, 2025
3920bc9
Update CONTRIBUTING.md
VanshikaSabharwal Jan 6, 2025
6954603
Update CODE_OF_CONDUCT.md
VanshikaSabharwal Jan 6, 2025
5589d81
reverting changes from tagTemplate and AddOn.tsx
VanshikaSabharwal Jan 6, 2025
cc87bec
reverting changes from tagTemplate and AddOn.tsx
VanshikaSabharwal Jan 6, 2025
0d60c05
Update CODE_OF_CONDUCT.md
VanshikaSabharwal Jan 6, 2025
26bade5
Update .eslintignore
VanshikaSabharwal Jan 6, 2025
4bf2fca
Update CODE_OF_CONDUCT.md
VanshikaSabharwal Jan 6, 2025
88d19b3
commiting to see
VanshikaSabharwal Jan 6, 2025
c9b5725
Update .eslintignore
VanshikaSabharwal Jan 6, 2025
992ef0b
Update CODE_STYLE.md
VanshikaSabharwal Jan 6, 2025
1e0d100
Update CODE_STYLE.md
VanshikaSabharwal Jan 6, 2025
19f16bb
reverting changes
VanshikaSabharwal Jan 6, 2025
601336f
reverting changes
VanshikaSabharwal Jan 6, 2025
d409ac5
Update README.md
VanshikaSabharwal Jan 6, 2025
c03de17
Update README.md
VanshikaSabharwal Jan 6, 2025
99c9edf
Update README.md
VanshikaSabharwal Jan 6, 2025
2414786
reverting changes
VanshikaSabharwal Jan 6, 2025
a32ab99
reverting changes
VanshikaSabharwal Jan 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
206 changes: 56 additions & 150 deletions setup.ts
Original file line number Diff line number Diff line change
@@ -1,165 +1,48 @@
import dotenv from 'dotenv';
import fs from 'fs';
import inquirer from 'inquirer';
import { checkConnection } from './src/setup/checkConnection/checkConnection';
import { askForTalawaApiUrl } from './src/setup/askForTalawaApiUrl/askForTalawaApiUrl';
import { checkEnvFile } from './src/setup/checkEnvFile/checkEnvFile';
import { validateRecaptcha } from './src/setup/validateRecaptcha/validateRecaptcha';
import { askForCustomPort } from './src/setup/askForCustomPort/askForCustomPort';

export async function main(): Promise<void> {
console.log('Welcome to the Talawa Admin setup! 🚀');

if (!fs.existsSync('.env')) {
fs.openSync('.env', 'w');
const config = dotenv.parse(fs.readFileSync('.env.example'));
for (const key in config) {
fs.appendFileSync('.env', `${key}=${config[key]}\n`);
}
} else {
checkEnvFile();
}

let shouldSetCustomPort: boolean;

if (process.env.PORT) {
console.log(
`\nCustom port for development server already exists with the value:\n${process.env.PORT}`,
);
shouldSetCustomPort = true;
} else {
const { shouldSetCustomPortResponse } = await inquirer.prompt({
import askAndSetDockerOption from './src/setup/askAndSetDockerOption/askAndSetDockerOption';
import updateEnvFile from './src/setup/updateEnvFile/updateEnvFile';
import askAndUpdatePort from './src/setup/askAndUpdatePort/askAndUpdatePort';
import { askAndUpdateTalawaApiUrl } from './src/setup/askForDocker/askForDocker';
VanshikaSabharwal marked this conversation as resolved.
Show resolved Hide resolved

// Ask and set up reCAPTCHA
const askAndSetRecaptcha = async (): Promise<void> => {
try {
const { shouldUseRecaptcha } = await inquirer.prompt({

Check warning on line 14 in setup.ts

View check run for this annotation

Codecov / codecov/patch

setup.ts#L12-L14

Added lines #L12 - L14 were not covered by tests
type: 'confirm',
name: 'shouldSetCustomPortResponse',
message: 'Would you like to set up a custom port?',
name: 'shouldUseRecaptcha',
message: 'Would you like to set up reCAPTCHA?',
default: true,
});
shouldSetCustomPort = shouldSetCustomPortResponse;
}

if (shouldSetCustomPort) {
const customPort = await askForCustomPort();

const port = dotenv.parse(fs.readFileSync('.env')).PORT;

fs.readFile('.env', 'utf8', (err, data) => {
const result = data.replace(`PORT=${port}`, `PORT=${customPort}`);
fs.writeFileSync('.env', result, 'utf8');
});
}

let shouldSetTalawaApiUrl: boolean;

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}`,
);
shouldSetTalawaApiUrl = true;
} else {
const { shouldSetTalawaApiUrlResponse } = await inquirer.prompt({
type: 'confirm',
name: 'shouldSetTalawaApiUrlResponse',
message: 'Would you like to set up talawa-api endpoint?',
default: true,
});
shouldSetTalawaApiUrl = shouldSetTalawaApiUrlResponse;
}

if (shouldSetTalawaApiUrl) {
let isConnected = false,
endpoint = '';

while (!isConnected) {
endpoint = await askForTalawaApiUrl();
const url = new URL(endpoint);
isConnected = await checkConnection(url.origin);
}
const envPath = '.env';
const currentEnvContent = fs.readFileSync(envPath, 'utf8');
const talawaApiUrl = dotenv.parse(currentEnvContent).REACT_APP_TALAWA_URL;

const updatedEnvContent = currentEnvContent.replace(
`REACT_APP_TALAWA_URL=${talawaApiUrl}`,
`REACT_APP_TALAWA_URL=${endpoint}`,
);

fs.writeFileSync(envPath, updatedEnvContent, 'utf8');
const websocketUrl = endpoint.replace(/^http(s)?:\/\//, 'ws$1://');
const currentWebSocketUrl =
dotenv.parse(updatedEnvContent).REACT_APP_BACKEND_WEBSOCKET_URL;

const finalEnvContent = updatedEnvContent.replace(
`REACT_APP_BACKEND_WEBSOCKET_URL=${currentWebSocketUrl}`,
`REACT_APP_BACKEND_WEBSOCKET_URL=${websocketUrl}`,
);

fs.writeFileSync(envPath, finalEnvContent, 'utf8');
}

const { shouldUseRecaptcha } = await inquirer.prompt({
type: 'confirm',
name: 'shouldUseRecaptcha',
message: 'Would you like to set up ReCAPTCHA?',
default: true,
});

if (shouldUseRecaptcha) {
const useRecaptcha = dotenv.parse(
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`,
);
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}`,
);
shouldSetRecaptchaSiteKey = true;
} else {
const { shouldSetRecaptchaSiteKeyResponse } = await inquirer.prompt({
type: 'confirm',
name: 'shouldSetRecaptchaSiteKeyResponse',
message: 'Would you like to set up a reCAPTCHA site key?',
default: true,
});
shouldSetRecaptchaSiteKey = shouldSetRecaptchaSiteKeyResponse;
}

if (shouldSetRecaptchaSiteKey) {
if (shouldUseRecaptcha) {
const { recaptchaSiteKeyInput } = await inquirer.prompt([
{
type: 'input',
name: 'recaptchaSiteKeyInput',
message: 'Enter your reCAPTCHA site key:',
validate: async (input: string): Promise<boolean | string> => {
if (validateRecaptcha(input)) {
return true;
}
return 'Invalid reCAPTCHA site key. Please try again.';
validate: (input: string): boolean | string => {
return (

Check warning on line 28 in setup.ts

View check run for this annotation

Codecov / codecov/patch

setup.ts#L28

Added line #L28 was not covered by tests
validateRecaptcha(input) ||
'Invalid reCAPTCHA site key. Please try again.'
);
},
},
]);

const recaptchaSiteKey = dotenv.parse(
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}`,
);
fs.writeFileSync('.env', result, 'utf8');
});
updateEnvFile('REACT_APP_RECAPTCHA_SITE_KEY', recaptchaSiteKeyInput);

Check warning on line 36 in setup.ts

View check run for this annotation

Codecov / codecov/patch

setup.ts#L36

Added line #L36 was not covered by tests
}
} catch (error) {
console.error('Error setting up reCAPTCHA:', error);
throw new Error('Failed to set up reCAPTCHA');

Check warning on line 40 in setup.ts

View check run for this annotation

Codecov / codecov/patch

setup.ts#L39-L40

Added lines #L39 - L40 were not covered by tests
coderabbitai[bot] marked this conversation as resolved.
Show resolved Hide resolved
}
};

// Ask and set up logging errors in the console
const askAndSetLogErrors = async (): Promise<void> => {

Check warning on line 45 in setup.ts

View check run for this annotation

Codecov / codecov/patch

setup.ts#L45

Added line #L45 was not covered by tests
const { shouldLogErrors } = await inquirer.prompt({
type: 'confirm',
name: 'shouldLogErrors',
Expand All @@ -169,17 +52,40 @@
});

if (shouldLogErrors) {
const logErrors = dotenv.parse(fs.readFileSync('.env')).ALLOW_LOGS;

fs.readFile('.env', 'utf8', (err, data) => {
const result = data.replace(`ALLOW_LOGS=${logErrors}`, 'ALLOW_LOGS=YES');
fs.writeFileSync('.env', result, 'utf8');
});
updateEnvFile('ALLOW_LOGS', 'YES');

Check warning on line 55 in setup.ts

View check run for this annotation

Codecov / codecov/patch

setup.ts#L55

Added line #L55 was not covered by tests
}
};

// Main function to run the setup process
export async function main(): Promise<void> {
try {
console.log('Welcome to the Talawa Admin setup! 🚀');

Check warning on line 62 in setup.ts

View check run for this annotation

Codecov / codecov/patch

setup.ts#L61-L62

Added lines #L61 - L62 were not covered by tests

checkEnvFile();
await askAndSetDockerOption();
const envConfig = dotenv.parse(fs.readFileSync('.env', 'utf8'));
const useDocker = envConfig.USE_DOCKER === 'YES';

Check warning on line 67 in setup.ts

View check run for this annotation

Codecov / codecov/patch

setup.ts#L64-L67

Added lines #L64 - L67 were not covered by tests

console.log(
'\nCongratulations! Talawa Admin has been successfully setup! 🥂🎉',
);
// Only run these commands if Docker is NOT used
if (useDocker) {
console.log(' ');

Check warning on line 71 in setup.ts

View check run for this annotation

Codecov / codecov/patch

setup.ts#L71

Added line #L71 was not covered by tests
VanshikaSabharwal marked this conversation as resolved.
Show resolved Hide resolved
} else {
console.log('Setting up Talawa Admin without Docker...');
await askAndUpdatePort();
await askAndUpdateTalawaApiUrl();

Check warning on line 75 in setup.ts

View check run for this annotation

Codecov / codecov/patch

setup.ts#L73-L75

Added lines #L73 - L75 were not covered by tests
}

await askAndSetRecaptcha();
await askAndSetLogErrors();

Check warning on line 79 in setup.ts

View check run for this annotation

Codecov / codecov/patch

setup.ts#L78-L79

Added lines #L78 - L79 were not covered by tests

console.log(

Check warning on line 81 in setup.ts

View check run for this annotation

Codecov / codecov/patch

setup.ts#L81

Added line #L81 was not covered by tests
'\nCongratulations! Talawa Admin has been successfully set up! 🥂🎉',
);
} catch (error) {
console.error('\n❌ Setup failed:', error);
console.log('\nPlease try again or contact support if the issue persists.');
process.exit(1);

Check warning on line 87 in setup.ts

View check run for this annotation

Codecov / codecov/patch

setup.ts#L85-L87

Added lines #L85 - L87 were not covered by tests
}
VanshikaSabharwal marked this conversation as resolved.
Show resolved Hide resolved
}

main();
4 changes: 1 addition & 3 deletions src/components/AddOn/AddOn.tsx
VanshikaSabharwal marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';

interface InterfaceAddOnProps {
extras?: any;
extras?: string;
VanshikaSabharwal marked this conversation as resolved.
Show resolved Hide resolved
name?: string;
children?: React.ReactNode;
}
Expand All @@ -21,8 +21,6 @@ interface InterfaceAddOnProps {
*/
function AddOn({
children = 'Default text',
extras = {},
VanshikaSabharwal marked this conversation as resolved.
Show resolved Hide resolved
name = '',
}: InterfaceAddOnProps): JSX.Element {
return (
<div className="plugin-container" data-testid="pluginContainer">
Expand Down
2 changes: 1 addition & 1 deletion src/components/CheckIn/tagTemplate.ts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VanshikaSabharwal please revert this file as well, as it is also outside the scope of this PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay i am doing it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually there was some error in the code of this file due to which people were not able to commit changes. So, when i also faced the same issue. i had resolve it to commit changes. However, this issue was fixed by someone else later and got merged. That's why the code in remote develop-postgres branch and in my branch is same. and that's why i cannot edit anything now.

tagTemplate.ts in develop-postgres
image

tagTemplate in my branch
image

The code is same thus i am not able to edit and commit it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@palisadoes i had to make changes in tagTemplate file in order to commit changes and fix the error in that file as other contributors were also facing the same error issue while commiting. i have provided the ss of error, changes.

Error: - Screenshot 2024-12-20 121300

Fixed File: - Screenshot 2024-12-20 124125

Previous File: - image

Reason for error: - In the schema file the name was defined as string but here the name was defined as object due to which there was error in data type.

Can i make this change get merged as a part of my PR as many other contributors were facing the error. Due to which they were not able to make commit.

I have reference this issue in this comment previously. @rishav-jha-mech

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I corrected the code before someone else merged PR for this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thus right now i am not able to revert changes somehow.

Copy link
Contributor

@rishav-jha-mech rishav-jha-mech Jan 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VanshikaSabharwal
Yes i also tried right now, I am unable to do it via web. Once changes made to this file is removed we can merge your PR.

Replace the tagTemplate.ts file you have currently in your local system with the one that is already present on Github, lmk if this works, also make sure your branch is upto date with the base branch

Large diffs are not rendered by default.

61 changes: 61 additions & 0 deletions src/setup/askAndSetDockerOption/askAndSetDockerOption.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';

// Mock modules
vi.mock('inquirer', () => ({
default: {
prompt: vi.fn(),
},
}));

vi.mock('setup/updateEnvFile/updateEnvFile', () => ({
default: vi.fn(),
}));

vi.mock('setup/askForDocker/askForDocker', () => ({
askForDocker: vi.fn(),
}));

// Import after mocking
import askAndSetDockerOption from './askAndSetDockerOption';
import inquirer from 'inquirer';
import updateEnvFile from 'setup/updateEnvFile/updateEnvFile';
import { askForDocker } from 'setup/askForDocker/askForDocker';

describe('askAndSetDockerOption', () => {
beforeEach(() => {
vi.clearAllMocks();
});

it('should set up Docker when user selects yes', async () => {
(inquirer.prompt as unknown as jest.Mock).mockResolvedValueOnce({
useDocker: true,
});
(askForDocker as jest.Mock).mockResolvedValueOnce(8080);

await askAndSetDockerOption();

expect(updateEnvFile).toHaveBeenCalledWith('USE_DOCKER', 'YES');
expect(updateEnvFile).toHaveBeenCalledWith('DOCKER_PORT', 8080);
});

it('should set up without Docker when user selects no', async () => {
(inquirer.prompt as unknown as jest.Mock).mockResolvedValueOnce({
useDocker: false,
});

await askAndSetDockerOption();

expect(updateEnvFile).toHaveBeenCalledWith('USE_DOCKER', 'NO');
});

it('should handle errors when askForDocker fails', async () => {
(inquirer.prompt as unknown as jest.Mock).mockResolvedValueOnce({
useDocker: true,
});
(askForDocker as jest.Mock).mockRejectedValueOnce(
new Error('Docker error'),
);

await expect(askAndSetDockerOption()).rejects.toThrow('Docker error');
});
});
35 changes: 35 additions & 0 deletions src/setup/askAndSetDockerOption/askAndSetDockerOption.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import inquirer from 'inquirer';
import updateEnvFile from 'setup/updateEnvFile/updateEnvFile';
import { askForDocker } from 'setup/askForDocker/askForDocker';

// Function to manage Docker setup
const askAndSetDockerOption = async (): Promise<void> => {
const { useDocker } = await inquirer.prompt({
type: 'confirm',
name: 'useDocker',
message: 'Would you like to set up with Docker?',
default: false,
});

if (useDocker) {
console.log('Setting up with Docker...');
updateEnvFile('USE_DOCKER', 'YES');
const answers = await askForDocker();
const DOCKER_PORT_NUMBER = answers;
updateEnvFile('DOCKER_PORT', DOCKER_PORT_NUMBER);

const DOCKER_NAME = 'talawa-admin';
console.log(`

Run the commands below after setup:-
1. docker build -t ${DOCKER_NAME} .
2. docker run -d -p ${DOCKER_PORT_NUMBER}:${DOCKER_PORT_NUMBER} ${DOCKER_NAME}

`);
} else {
VanshikaSabharwal marked this conversation as resolved.
Show resolved Hide resolved
console.log('Setting up without Docker...');
updateEnvFile('USE_DOCKER', 'NO');
}
};

export default askAndSetDockerOption;
25 changes: 25 additions & 0 deletions src/setup/askAndUpdatePort/askAndUpdatePort.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import updateEnvFile from 'setup/updateEnvFile/updateEnvFile';
import { askForCustomPort } from 'setup/askForCustomPort/askForCustomPort';
import inquirer from 'inquirer';

// Ask and update the custom port
const askAndUpdatePort = async (): Promise<void> => {
const { shouldSetCustomPortResponse } = await inquirer.prompt({
type: 'confirm',
name: 'shouldSetCustomPortResponse',
message:
'Would you like to set up a custom port for running Talawa Admin without Docker?',
default: true,
});

if (shouldSetCustomPortResponse) {
const customPort = await askForCustomPort();
if (customPort < 1024 || customPort > 65535) {
throw new Error('Port must be between 1024 and 65535');
}

updateEnvFile('PORT', String(customPort));
}
};
VanshikaSabharwal marked this conversation as resolved.
Show resolved Hide resolved

export default askAndUpdatePort;
Loading
Loading