Skip to content

Commit

Permalink
Merge branch 'PalisadoesFoundation:develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
AVtheking authored Feb 4, 2024
2 parents 7728a36 + 02d8832 commit ad9a412
Show file tree
Hide file tree
Showing 473 changed files with 9,022 additions and 4,326 deletions.
6 changes: 5 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,8 @@ LOG_LEVEL = info

REDIS_HOST=
REDIS_PORT=
REDIS_PASSWORD=
REDIS_PASSWORD=

# this environment variable is for setting the environment variable for Image Upload size

IMAGE_SIZE_LIMIT_KB=3000
2 changes: 1 addition & 1 deletion .github/workflows/authorized-changes-detection.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:
paths:
- '.github/**'
- '.husky/**'
- '.scripts/**'
- 'scripts/**'
- '.env.sample'
- 'tsconfig.json'
- '.gitignore'
Expand Down
24 changes: 0 additions & 24 deletions .github/workflows/deploy.yml

This file was deleted.

97 changes: 97 additions & 0 deletions .github/workflows/md_mdx_format_adjuster.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
"""
Script to make Markdown files MDX compatible.
This script scans Markdown files and escapes special characters (<, >, {, })
to make them compatible with the MDX standard used in Docusaurus v3.
This script complies with:
1) Pylint
2) Pydocstyle
3) Pycodestyle
4) Flake8
"""

import os
import argparse
import re

def escape_mdx_characters(text):
"""
Escape special characters in a text string for MDX compatibility.
Avoids escaping already escaped characters.
Args:
text: A string containing the text to be processed.
Returns:
A string with special characters (<, >, {, }) escaped, avoiding
double escaping.
"""
# Regular expressions to find unescaped special characters
patterns = {
"<": r"(?<!\\)<",
">": r"(?<!\\)>",
"{": r"(?<!\\){",
"}": r"(?<!\\)}"
}

# Replace unescaped special characters
for char, pattern in patterns.items():
text = re.sub(pattern, f"\\{char}", text)

return text

def process_file(filepath):
"""
Process a single Markdown file for MDX compatibility.
Args:
filepath: The path to the Markdown file to process.
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()

# 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)

def main():
"""
Main function to process all Markdown files in a given directory.
Scans for all Markdown files in the specified directory and processes each
one for MDX compatibility.
Args:
None
Returns:
None
"""
parser = argparse.ArgumentParser(description="Make Markdown files MDX compatible.")
parser.add_argument(
"--directory",
type=str,
required=True,
help="Directory containing Markdown files to process."
)

args = parser.parse_args()

# Process each Markdown file in the directory
for root, _, files in os.walk(args.directory):
for file in files:
if file.lower().endswith(".md"):
process_file(os.path.join(root, file))

if __name__ == "__main__":
main()
4 changes: 1 addition & 3 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
run: npm ci

- name: Run ESLint to check for linting errors in modified files
run: npx eslint $(git diff --name-only --diff-filter=d -- '***.ts' ${{ github.event.before }} ${{ github.sha }})
run: npx eslint $(git diff --name-only --diff-filter=d ${{ github.event.before }} ${{ github.sha }} -- '***.ts')

- name: Check for formatting errors
run: npm run format:check
Expand Down Expand Up @@ -114,8 +114,6 @@ jobs:
MONGO_DB_URL: mongodb://localhost:27017/talawa-test-db
REDIS_HOST: localhost
REDIS_PORT: 6379
# ACCESS_TOKEN_SECRET: ${{ secrets.ACCESS_TOKEN_SECRET }}
# REFRESH_TOKEN_SECRET: ${{ secrets.REFRESH_TOKEN_SECRET }}

steps:
- name: Checkout repository
Expand Down
42 changes: 40 additions & 2 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ jobs:
npm install typedoc-plugin-markdown
npm i --save-dev @types/node
npx typedoc --entryPoints src --out talawa-api-docs --plugin typedoc-plugin-markdown --theme markdown --entryPointStrategy expand
- name: Make Markdown Files MDX Compatible
run: python3 .github/workflows/md_mdx_format_adjuster.py --directory talawa-api-docs

- name: Checking doc updated
id: DocUpdated
Expand Down Expand Up @@ -155,7 +158,7 @@ jobs:
- uses: actions/checkout@v3
- uses: dmnemec/copy_file_to_another_repo_action@v1.1.1
env:
API_TOKEN_GITHUB: ${{secrets.API_TOKEN_GITHUB}}
API_TOKEN_GITHUB: ${{secrets.TALAWA_DOCS_SYNC}}
with:
source_file: 'talawa-api-docs/'
destination_repo: 'PalisadoesFoundation/talawa-docs'
Expand All @@ -164,4 +167,39 @@ jobs:
user_email: '${{env.email}}'
user_name: '${{github.actor}}'
commit_message: 'Talawa API docs updated'


# You can find the deployment instructions in the scripts/cloud-api-demo/README.md file
Deploy-Workflow:
name: Deploying Application to Cloud VPS
needs: Push-Workflow
runs-on: ubuntu-latest
steps:
- name: Generate Access Token Secret
run: |
secret=$(openssl rand -hex 32)
echo "INPUT_ACCESS_TOKEN_SECRET=$secret" >> $GITHUB_ENV
echo "::add-mask::$secret"
- name: Generate Refresh Token Secret
run: |
secret=$(openssl rand -hex 32)
echo "INPUT_REFRESH_TOKEN_SECRET=$secret" >> $GITHUB_ENV
echo "::add-mask::$secret"
- name: Execute remote ssh commands
uses: appleboy/ssh-action@v1.0.3
env:
INPUT_RECAPTCHA_SECRET_KEY: ${{ secrets.API_DEMO_RECAPTCHA_SECRET_KEY }}
INPUT_MAIL_USERNAME: ${{ secrets.API_DEMO_MAIL_USERNAME }}
INPUT_MAIL_PASSWORD: ${{ secrets.API_DEMO_MAIL_PASSWORD }}
INPUT_LAST_RESORT_SUPERADMIN_EMAIL: ${{ secrets.API_DEMO_LAST_RESORT_SUPERADMIN_EMAIL }}
with:
host: ${{ secrets.API_DEMO_HOST }}
username: ${{ secrets.API_DEMO_USERNAME }}
key: ${{ secrets.API_DEMO_SSH_KEY }}
port: ${{ secrets.API_DEMO_SSH_PORT}}
allenvs: true
command_timeout: 30m
script: |
python3 /usr/local/bin/scripts/create_env.py --access_token_secret $INPUT_ACCESS_TOKEN_SECRET --refresh_token_secret $INPUT_REFRESH_TOKEN_SECRET --recaptcha_secret_key $INPUT_RECAPTCHA_SECRET_KEY --mail_username $INPUT_MAIL_USERNAME --mail_password $INPUT_MAIL_PASSWORD --last_resort_superadmin_email $INPUT_LAST_RESORT_SUPERADMIN_EMAIL
python3 /usr/local/bin/scripts/deploy.py --path ~/develop --branch develop
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# Checks code for typescript type errors and throws errors if found.
npm run typecheck

# Formats code using prettier
# Formats staged code using prettier
# Checks and fixes all lint issues in code which don't require manual intervention.
# Throws errors if lint issues requiring manual intervention are found in code.
npm run lint-staged
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Talawa API

💬 Join the community on Slack. The link can be found in the `Talawa` [README.md](https://github.com/PalisadoesFoundation/talawa) file.

[![N|Solid](public/markdown/images/talawa-logo-lite-200x200.png)](https://github.com/PalisadoesFoundation/talawa-api)
Expand Down
7 changes: 5 additions & 2 deletions codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ const config: CodegenConfig = {
// functionality is useful because what we retrieve from the database and what we choose to return from a graphql server
// could be completely different fields. Address to models here is relative to the location of generated types.
mappers: {
ActionItem: "../models/ActionItem#InterfaceActionItem",

ActionItemCategory:
"../models/ActionItemCategory#InterfaceActionItemCategory",

CheckIn: "../models/CheckIn#InterfaceCheckIn",

MessageChat: "../models/MessageChat#InterfaceMessageChat",
Expand Down Expand Up @@ -73,8 +78,6 @@ const config: CodegenConfig = {
UserTag: "../models/OrganizationTagUser#InterfaceOrganizationTagUser",

User: "../models/User#InterfaceUser",

UserToReturn: "../models/User#InterfaceUserToReturn",
},

useTypeImports: true,
Expand Down
Loading

0 comments on commit ad9a412

Please sign in to comment.