Skip to content

Commit

Permalink
checkConnection cahnge and conversation resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
MayankJha014 committed Dec 7, 2024
1 parent c48bd37 commit e1173ef
Show file tree
Hide file tree
Showing 13 changed files with 135 additions and 62 deletions.
9 changes: 1 addition & 8 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"browser": true,
"node": true,
"es6": true,
"jest": true
"vitest": true
},

// Specify the rulesets from other ESLint Plugins tobe used
Expand Down Expand Up @@ -33,7 +33,6 @@
"plugins": [
"react",
"@typescript-eslint",
"jest",
"import",
"eslint-plugin-tsdoc",
"prettier"
Expand Down Expand Up @@ -131,12 +130,6 @@
"react/jsx-equals-spacing": ["warn", "never"],
"react/no-this-in-sfc": "error",

// All tests must need not have an assertion
"jest/expect-expect": 0,
"jest/no-standalone-expect": [
"error",
{ "additionalTestBlockFunctions": ["test", "it"] }
],
// Enforce Strictly functional components
"react/no-unstable-nested-components": ["error", { "allowAsProps": true }],
"react/function-component-definition": [
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- uses: Renato66/auto-label@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/github-script@v6
- uses: actions/github-script@v7
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/pull-request-target.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ jobs:
PR-Greeting:
name: Pull Request Target
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Add the PR Review Policy
uses: thollander/actions-comment-pull-request@v2
uses: thollander/actions-comment-pull-request@1d9b4d9c975f9c4eb1b1c2d3f717b91c4c6e30d1
with:
comment_tag: pr_review_policy
message: |
Expand Down Expand Up @@ -71,7 +73,9 @@ jobs:
2. Read the CONTRIBUTING.md file make
- name: Greeting Message to User
uses: actions/first-interaction@v1
uses: actions/first-interaction@4a1f5866f0b9dcb02a5d9640a1d9b6a0f2203eef
permissions:
pull-requests: write
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
pr-message: "Congratulations on making your first PR! :confetti_ball: If you haven't already, check out our [Contributing Guidelines](https://github.com/PalisadoesFoundation/talawa-admin/blob/-/CONTRIBUTING.md) and [PR Reporting Guidelines](https://github.com/PalisadoesFoundation/talawa-admin/blob/-/PR_GUIDELINES.md) to ensure that you are following our guidelines for contributing and creating PR."
pr-message: "Congratulations on making your first PR! :confetti_ball: If you haven't already, check out our [Contributing Guidelines](https://github.com/PalisadoesFoundation/talawa-admin/blob/develop/CONTRIBUTING.md) and [PR Reporting Guidelines](https://github.com/PalisadoesFoundation/talawa-admin/blob/develop/PR_GUIDELINES.md) to ensure that you are following our guidelines for contributing and creating PR."
7 changes: 6 additions & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '22.x'
node-version: '20.x'

- name: Install Dependencies
run: npm install
Expand Down Expand Up @@ -247,6 +247,11 @@ jobs:
run: |
# Retrieve the complete branch name directly from the GitHub context
FULL_BRANCH_NAME=${{ github.base_ref }}
# Validate branch name
if [[ ! $FULL_BRANCH_NAME =~ ^[a-zA-Z0-9_/-]+$ ]]; then
echo "Invalid branch name"
exit 1
fi
echo "FULL_Branch_NAME: $FULL_BRANCH_NAME"
# Clone the specified repository using the extracted branch name
Expand Down
15 changes: 11 additions & 4 deletions .github/workflows/talawa_admin_md_mdx_format_adjuster.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,23 @@ def process_file(filepath):
Returns:
None, writes the processed content back to the file only if there are changes.
"""
with open(filepath, 'r', encoding='utf-8') as file:
content = file.read()
try:
with open(filepath, 'r', encoding='utf-8') as file:
content = file.read()
except IOError as e:
print(f"Error reading file {filepath}: {e}")
return

# Escape MDX characters
new_content = escape_mdx_characters(content)

# Write the processed content back to the file only if there is a change
if new_content != content:
with open(filepath, 'w', encoding='utf-8') as file:
file.write(new_content)
try:
with open(filepath, 'w', encoding='utf-8') as file:
file.write(new_content)
except IOError as e:
print(f"Error writing file {filepath}: {e}")

def main():
"""
Expand Down
14 changes: 9 additions & 5 deletions ISSUE_GUIDELINES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

In order to give everyone a chance to submit a issues reports and contribute to the Talawa project, we have put restrictions in place. This section outlines the guidelines that should be imposed upon issue reports in the Talawa project.

___
---

## Table of Contents

<!-- toc -->
Expand All @@ -18,15 +19,17 @@ ___

<!-- tocstop -->

___
---

## Issue Management

In all cases please use the [GitHub open issue search](https://github.com/PalisadoesFoundation/talawa-admin/issues) to check whether the issue has already been reported.

### New Issues

To create new issues follow these steps:

1. Your issue may have already been created. Search for duplicate open issues before submitting yours.for similar deficiencies in the code.duplicate issues are created.
1. Your issue may have already been created. Search for duplicate open issues before submitting yours to avoid similar deficiencies in the code.
1. Verify whether the issue has been fixed by trying to reproduce it using the latest master or development branch in the repository.
1. Click on the [`New Issue`](https://github.com/PalisadoesFoundation/talawa-admin/issues/new/choose) button
1. Use the templates to create a standardized report of what needs to be done and why.
Expand All @@ -49,11 +52,12 @@ Working on these types of existing issues is a good way of getting started with

Feature requests are welcome. But take a moment to find out whether your idea fits with the scope and aims of the project. It's up to you to make a strong case to convince the mentors of the merits of this feature. Please provide as much detail and context as possible.

### Monitoring the Creation of New Issues
### Monitoring the Creation of New Issues

1. Join our `#talawa-github` slack channel for automatic issue and pull request updates.

## General Guidelines

1. Discuss issues in our various slack channels when necessary
2. Please do not derail or troll issues.
2. Please do not derail or troll issues.
3. Keep the discussion on topic and respect the opinions of others.
5 changes: 3 additions & 2 deletions PR_GUIDELINES.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ npm run format:check

## Testing

1. All pull requests must have test units. If, for some reason, it is not possible to add tests, please let us know and explain why. In that case, you'll need to tell us what steps you followed to manually test your changes.
1. Please read our [CONTRIBUTING.md](CONTRIBUTING.md) document for details on our testing policy.
1. All pull requests must include Vitest test units. If, for some reason, it is not possible to add tests, please let us know and explain why. In that case, you'll need to tell us what steps you followed to manually test your changes.
1. Please read our [CONTRIBUTING.md](CONTRIBUTING.md) document for details on our Vitest testing policy.

## Pull Request Processing

These are key guidelines for the procedure:

### Only submit PRs against our `develop` branch, not the default `main` branch
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Talawa Admin

[💬 Join the community on Slack](https://github.com/PalisadoesFoundation/)
[💬 Join the community on Slack](https://join.slack.com/t/thepalisadoes-dyb1131/shared_invite/your-actual-slack-invite-link)

![talawa-logo-lite-200x200](https://github.com/PalisadoesFoundation/talawa-admin/assets/16875803/26291ec5-d3c1-4135-8bc7-80885dff613d)

Expand Down Expand Up @@ -44,13 +44,13 @@ Core features include:

1. You can install the software for this repository using the steps in our [INSTALLATION.md](INSTALLATION.md) file.
1. Do you want to contribute to our code base? Look at our [CONTRIBUTING.md](CONTRIBUTING.md) file to get started. There you'll also find links to:
1. Our code of conduct documentation in the [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) file.
1. How we handle the processing of new and existing issues in our [ISSUE_GUIDELINES.md](ISSUE_GUIDELINES.md) file.
1. The methodologies we use to manage our pull requests in our [PR_GUIDELINES.md](PR_GUIDELINES.md) file.
1. Our code of conduct documentation in the [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) file.
1. How we handle the processing of new and existing issues in our [ISSUE_GUIDELINES.md](ISSUE_GUIDELINES.md) file.
1. The methodologies we use to manage our pull requests in our [PR_GUIDELINES.md](PR_GUIDELINES.md) file.
1. The `talawa` documentation can be found at our [docs.talawa.io](https://docs.talawa.io) site.
1. It is automatically generated from the markdown files stored in our [Talawa-Docs GitHub repository](https://github.com/PalisadoesFoundation/talawa-docs). This makes it easy for you to update our documenation.
1. It is automatically generated from the markdown files stored in our [Talawa-Docs GitHub repository](https://github.com/PalisadoesFoundation/talawa-docs). This makes it easy for you to update our documenation.

# Videos
# Videos

1. Visit our [YouTube Channel playlists](https://www.youtube.com/@PalisadoesOrganization/playlists) for more insights
1. The "[Getting Started - Developers](https://www.youtube.com/watch?v=YpBUoHxEeyg&list=PLv50qHwThlJUIzscg9a80a9-HmAlmUdCF&index=1)" videos are extremely helpful for new open source contributors.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "talawa-admin",
"version": "3.0.0",
"version": "0.1.0",
"private": true,
"type": "module",
"config-overrides-path": "scripts/config-overrides",
Expand Down
7 changes: 0 additions & 7 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -779,13 +779,6 @@ type OrganizationCustomField {
type: String!
}

type OrganizationCustomField {
_id: ID!
name: String!
organizationId: String!
type: String!
}

type OrganizationInfoNode {
_id: ID!
apiUrl: URL!
Expand Down
25 changes: 20 additions & 5 deletions scripts/githooks/check-localstorage-usage.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ const containsSkipComment = (file) => {
const getModifiedFiles = () => {
try {
if (scanEntireRepo) {
const result = execSync('git ls-files | grep ".tsx\\?$"', {
const result = execSync('git ls-files "*.ts" "*.tsx"', {
encoding: 'utf-8',
});
return result.trim().split('\n');
return result.trim().split(/\r?\n/).filter(Boolean);
}

const result = execSync('git diff --cached --name-only', {
Expand Down Expand Up @@ -59,8 +59,17 @@ const checkLocalStorageUsage = (file) => {
}

try {
if (existsSync(file)) {
const content = readFileSync(file, 'utf-8');
const absolutePath = path.resolve(file);
if (existsSync(absolutePath)) {
// Quick check if file might be binary
const buffer = readFileSync(absolutePath, { flag: 'r' });

if (buffer.includes(0)) {
console.log(`Skipping binary file: ${file}`);
return;
}

const content = buffer.toString('utf-8');

if (
content.includes('localStorage.getItem') ||
Expand All @@ -73,7 +82,13 @@ const checkLocalStorageUsage = (file) => {
console.log(`File ${file} does not exist.`);
}
} catch (error) {
console.error(`Error reading file ${file}:`, error.message);
if (error.code === 'ENOENT') {
console.error(`File not found: ${file}`);
} else if (error.code === 'EACCES') {
console.error(`Permission denied: ${file}`);
} else {
console.error(`Error reading file ${file}:`, error.message);
}
}
};

Expand Down
52 changes: 38 additions & 14 deletions setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,20 @@ 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', 0o666);
const config = dotenv.parse(fs.readFileSync('.env.example'));
for (const key in config) {
fs.appendFileSync('.env', `${key}=${config[key]}\n`);
try {
if (!fs.existsSync('.env')) {
await fs.promises.open('.env', 'w', 0o666);
const config = dotenv.parse(await fs.promises.readFile('.env.example'));
const envContent = Object.entries(config)
.map(([key, value]) => `${key}=${value}`)
.join('\n');
await fs.promises.writeFile('.env', envContent + '\n');
} else {
checkEnvFile();
}
} else {
checkEnvFile();
} catch (error) {
console.error('Failed to setup environment file:', error);
process.exit(1);
}

let shouldSetCustomPort: boolean;
Expand Down Expand Up @@ -70,7 +76,16 @@ export async function main(): Promise<void> {

while (!isConnected) {
endpoint = await askForTalawaApiUrl();
const url = new URL(endpoint);

// Validate and parse URL directly
let url;
try {
url = new URL(endpoint);
} catch {
console.error('Invalid URL. Please provide a valid Talawa API URL.');
continue;
}

isConnected = await checkConnection(url.origin);
}
const envPath = '.env';
Expand Down Expand Up @@ -107,13 +122,18 @@ export async function main(): Promise<void> {
fs.readFileSync('.env'),
).REACT_APP_USE_RECAPTCHA;

fs.readFile('.env', 'utf8', (err, data) => {
try {
const data = await fs.promises.readFile('.env', 'utf8');
const result = data.replace(
`REACT_APP_USE_RECAPTCHA=${useRecaptcha}`,
`REACT_APP_USE_RECAPTCHA=yes`,
);
fs.writeFileSync('.env', result, 'utf8');
});
await fs.promises.writeFile('.env', result, 'utf8');
} catch (error) {
console.error('Failed to update ReCAPTCHA configuration:', error);
process.exit(1);
}

let shouldSetRecaptchaSiteKey: boolean;
if (process.env.REACT_APP_RECAPTCHA_SITE_KEY) {
console.log(
Expand Down Expand Up @@ -149,13 +169,17 @@ export async function main(): Promise<void> {
fs.readFileSync('.env'),
).REACT_APP_RECAPTCHA_SITE_KEY;

fs.readFile('.env', 'utf8', (err, data) => {
try {
const data = await fs.promises.readFile('.env', 'utf8');
const result = data.replace(
`REACT_APP_RECAPTCHA_SITE_KEY=${recaptchaSiteKey}`,
`REACT_APP_RECAPTCHA_SITE_KEY=${recaptchaSiteKeyInput}`,
);
fs.writeFileSync('.env', result, 'utf8');
});
await fs.promises.writeFile('.env', result, 'utf8');
} catch (error) {
console.error('Failed to update ReCAPTCHA configuration:', error);
process.exit(1);
}
}
}

Expand Down
Loading

0 comments on commit e1173ef

Please sign in to comment.