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

Merge with Develop 20240924 #2306

Merged
merged 2 commits into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 2 additions & 1 deletion .coderabbit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ reviews:
drafts: false
base_branches:
- develop
- main
chat:
auto_reply: true
auto_reply: true
4 changes: 3 additions & 1 deletion .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,6 @@ If applicable, add screenshots to help explain your problem.
Add any other context or screenshots about the feature request here.

**Potential internship candidates**
Please read this if you are planning to apply for a Palisadoes Foundation internship https://github.com/PalisadoesFoundation/talawa/issues/359

Please read this if you are planning to apply for a Palisadoes Foundation internship
- https://github.com/PalisadoesFoundation/talawa/issues/359
4 changes: 3 additions & 1 deletion .github/ISSUE_TEMPLATE/feature-request.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ A clear and concise description of approach to be followed.
Add any other context or screenshots about the feature request here.

**Potential internship candidates**
Please read this if you are planning to apply for a Palisadoes Foundation internship https://github.com/PalisadoesFoundation/talawa/issues/359

Please read this if you are planning to apply for a Palisadoes Foundation internship
- https://github.com/PalisadoesFoundation/talawa/issues/359
68 changes: 68 additions & 0 deletions .github/workflows/check-tsdoc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import fs from 'fs/promises'; // Import fs.promises for async operations
import path from 'path';

// List of files to skip
const filesToSkip = [
'index.tsx',
'EventActionItems.tsx',
'OrgPostCard.tsx',
'UsersTableItem.tsx',
'FundCampaignPledge.tsx'
];

// Recursively find all .tsx files, excluding files listed in filesToSkip
async function findTsxFiles(dir) {
let results = [];
try {
const list = await fs.readdir(dir);
for (const file of list) {
const filePath = path.join(dir, file);
const stat = await fs.stat(filePath);
if (stat.isDirectory()) {
results = results.concat(await findTsxFiles(filePath));
} else if (
filePath.endsWith('.tsx') &&
!filePath.endsWith('.test.tsx') &&
!filesToSkip.includes(path.relative(dir, filePath))
) {
results.push(filePath);
}
}
} catch (err) {
console.error(`Error reading directory ${dir}: ${err.message}`);
}
return results;
}

// Check if a file contains at least one TSDoc comment
async function containsTsDocComment(filePath) {
try {
const content = await fs.readFile(filePath, 'utf8');
return /\/\*\*[\s\S]*?\*\//.test(content);
} catch (err) {
console.error(`Error reading file ${filePath}: ${err.message}`);
return false;
}
}

// Main function to run the validation
async function run() {
const dir = process.argv[2] || './src'; // Allow directory path as a command-line argument
const files = await findTsxFiles(dir);
const filesWithoutTsDoc = [];

for (const file of files) {
if (!await containsTsDocComment(file)) {
filesWithoutTsDoc.push(file);
}
}

if (filesWithoutTsDoc.length > 0) {
filesWithoutTsDoc.forEach(file => {
console.error(`No TSDoc comment found in file: ${file}`);
});
process.exit(1);
}
}

run();
30 changes: 28 additions & 2 deletions .github/workflows/compare_translations.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,31 @@ def compare_translations(default_translation,
errors.append(error_msg)
return errors

def flatten_json(nested_json, parent_key=""):
"""
Flattens a nested JSON, concatenating keys to represent the hierarchy.

Args:
nested_json (dict): The JSON object to flatten.
parent_key (str): The base key for recursion (used to track key hierarchy).

Returns:
dict: A flattened dictionary with concatenated keys.
"""
flat_dict = {}

for key, value in nested_json.items():
# Create the new key by concatenating parent and current key
new_key = f"{parent_key}.{key}" if parent_key else key

if isinstance(value, dict):
# Recursively flatten the nested dictionary
flat_dict.update(flatten_json(value, new_key))
else:
# Assign the value to the flattened key
flat_dict[new_key] = value

return flat_dict

def load_translation(filepath):
"""Load translation from a file.
Expand All @@ -104,7 +129,8 @@ def load_translation(filepath):
if not content.strip():
raise ValueError(f"File {filepath} is empty.")
translation = json.loads(content)
return translation
flattened_translation = flatten_json(translation)
return flattened_translation
except json.JSONDecodeError as e:
raise ValueError(f"Error decoding JSON from file {filepath}: {e}")

Expand Down Expand Up @@ -170,7 +196,7 @@ def main():
"--directory",
type=str,
nargs="?",
default=os.path.join(os.getcwd(), "locales"),
default=os.path.join(os.getcwd(), "public/locales"),
help="Directory containing translation files(relative to the root directory).",
)
args = parser.parse_args()
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
node-version: '22.x'

- name: Install Dependencies
run: npm install
Expand Down Expand Up @@ -58,6 +58,9 @@ jobs:
CHANGED_FILES: ${{ steps.changed_files.outputs.all_changed_files }}
run: npx eslint ${CHANGED_FILES}

- name: Check for TSDoc comments
run: npm run check-tsdoc # Run the TSDoc check script

- name: Check for localStorage Usage
run: |
chmod +x scripts/githooks/check-localstorage-usage.js
Expand Down Expand Up @@ -173,7 +176,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
node-version: '22.x'

- name: Install Dependencies
run: npm install
Expand Down Expand Up @@ -218,7 +221,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
node-version: '22.x'

- name: resolve dependency
run: npm install -g @graphql-inspector/cli
Expand Down
127 changes: 1 addition & 126 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x]
node-version: [22.x]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
Expand Down Expand Up @@ -58,128 +58,3 @@ jobs:
fail_ci_if_error: false
name: '${{env.CODECOV_UNIQUE_NAME}}'

Generate-Documentation:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/automated-docs'
steps:
- name: Checkout the Repository
uses: actions/checkout@v4
# with:
# ref: develop

# - name: Pull latest changes from develop
# run: git pull origin develop

- name: Node.js Version
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Restore node_modules from cache
id: cache-npm
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
path: |
~/.npm
node_modules
key: ${{ runner.os }}-generate-docs-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-generate-docs-${{ env.cache-name }}-
${{ runner.os }}-generate-docs-
${{ runner.os }}-

- name: Install dependencies
run: npm install

- name: Install TypeScript Globally and add GraphQL tag
run: yarn global add typescript
- run: yarn add graphql-tag

- name: Update Dependencies
run: yarn upgrade

- name: Generate Documentation of Markdown pages
run: |
npm install --global typedoc
npm install typedoc-plugin-markdown
npm install --save-dev @types/node
npx typedoc --entryPoints src/components src/screens --out talawa-admin-docs --plugin typedoc-plugin-markdown --theme markdown --entryPointStrategy expand --exclude "**/*.test.ts" --exclude "**/*.css"

- name: Make Markdown Files MDX Compatible
run: python ./.github/workflows/md_mdx_format_adjuster.py --directory talawa-admin-docs


- name: Checking doc updated
id: DocUpdated
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "updateDoc=true" >> $GITHUB_OUTPUT
echo -e "Documentation has been updated!!"
else
Green='0;32'
NoColor='\033[0m'
echo -e "${Green}No documentation updated${NoColor}"
fi

- name: Set env variables
if: steps.DocUpdated.outputs.updateDoc
run: |
echo "commit_id=$(echo $(git rev-parse HEAD))" >> $GITHUB_ENV
echo "email=$(echo $(git log --pretty=format:"%ae" $commit_id))" >> $GITHUB_ENV

- name: Update Doc
if: steps.DocUpdated.outputs.updateDoc
run: |
Green='0;32'
NoColor='\033[0m'
git config --global user.name "${{github.actor}}"
git config --global user.email "${{env.email}}"
git add .
git commit -m "Update documentation"
git push origin develop:automated-docs --force
echo -e "🚀${Green} Hurrah! doc updated${NoColor}"

- name: Create Documentation Artifact
uses: actions/upload-artifact@v2
with:
name: documentation-admin
path: talawa-admin-docs

Empty-Commit:
name: Create Empty Commit
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/develop'
needs: Generate-Documentation
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false
token: ${{ secrets.TALAWA_DOCS_SYNC }}
- name: Empty Commit
run: |
git config --global user.name "${{github.actor}}"
git config --global user.email "${{env.email}}"
git config --global url.https://${{ secrets.TALAWA_DOCS_SYNC }}@github.com/.insteadOf https://github.com/
git commit --allow-empty -m "Trigger Documentation Workflow"
git push origin develop:automated-docs --force

Copy-docs-to-talawa-docs:
if: github.ref == 'refs/heads/automated-docs'
needs: Generate-Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dmnemec/[email protected]
env:
API_TOKEN_GITHUB: ${{secrets.TALAWA_DOCS_SYNC}}
with:
source_file: 'talawa-admin-docs/'
destination_repo: 'PalisadoesFoundation/talawa-docs'
destination_branch: 'develop'
destination_folder: 'docs/'
user_email: '${{env.email}}'
user_name: '${{github.actor}}'
commit_message: 'Talawa Admin docs updated'
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v20.10.0
v22.7.0
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ If you are new to contributing to open source, please read the Open Source Guide
<!-- toc -->

- [Code of Conduct](#code-of-conduct)
- [Videos](#videos)
- [Ways to Contribute](#ways-to-contribute)
- [Our Development Process](#our-development-process)
- [Issues](#issues)
Expand All @@ -31,6 +32,7 @@ No one should fear voicing their opinion. Respones must be respectful.

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.

## Ways to Contribute

If you are ready to start contributing code right away, get ready!
Expand Down
8 changes: 8 additions & 0 deletions config/babel.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
presets: [
'@babel/preset-env', // Transforms modern JavaScript
'@babel/preset-typescript', // Transforms TypeScript
'@babel/preset-react', // Transforms JSX
],
plugins: ['babel-plugin-transform-import-meta'],
};
30 changes: 30 additions & 0 deletions config/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import viteTsconfigPaths from 'vite-tsconfig-paths';
import svgrPlugin from 'vite-plugin-svgr';
import EnvironmentPlugin from 'vite-plugin-environment';

export default defineConfig({
// depending on your application, base can also be "/"
build: {
outDir: 'build',
},
base: '',
plugins: [
react(),
viteTsconfigPaths(),
EnvironmentPlugin('all'),
svgrPlugin({
svgrOptions: {
icon: true,
// ...svgr options (https://react-svgr.com/docs/options/)
},
}),
],
server: {
// this ensures that the browser opens upon server start
open: true,
// this sets a default port to 3000
port: 4321,
},
});
Loading
Loading