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

fix locale sort's path and fix format script to sort cypress dir #9070

Merged

Conversation

JavidSumra
Copy link
Contributor

@JavidSumra JavidSumra commented Nov 9, 2024

Proposed Changes

  • Update Locale Path in Sort Script and lint-staged
  • Update format script to also format cypress dir
  • Run project wide format to format cypress files

@ohcnetwork/care-fe-code-reviewers

Merge Checklist

  • Add specs that demonstrate bug / test a new feature.
  • Update product documentation.
  • Ensure that UI text is kept in I18n files.
  • Prep screenshot or demo video for changelog entry, and attach it to issue.
  • Request for Peer Reviews
  • Completion of QA

Summary by CodeRabbit

  • New Features

    • Updated the configuration for locale file paths to enhance organization.
    • Specified the use of npm version 10.9.0 for package management.
    • Improved formatting script to include the Cypress directory for better code consistency.
  • Bug Fixes

    • Adjusted paths in the locale sorting script to align with the new directory structure.

@JavidSumra JavidSumra requested a review from a team as a code owner November 9, 2024 04:25
Copy link

coderabbitai bot commented Nov 9, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The changes involve updates to the package.json and scripts/sort-locales.js files. The package.json file has modified the lint-staged configuration to point to a new directory for JSON locale files and added a packageManager field specifying the use of npm@10.9.0. The scripts/sort-locales.js file has also been updated to reflect the new path for reading and writing locale data, moving from the src directory to the public directory. Additionally, several Cypress test files have undergone reordering of import statements, but their core functionality remains unchanged.

Changes

File Change Summary
package.json Updated lint-staged path from "src/Locale/*.json" to "public/locale/*.json". Added packageManager field with value "npm@10.9.0". Modified format script to include ./cypress.
scripts/sort-locales.js Changed file path for reading and writing locale data from "src/Locale/en.json" to "public/locale/en.json".
cypress/e2e/facility_spec/FacilityLocation.cy.ts Reordered import statements, added uuid import.
cypress/e2e/users_spec/UsersProfile.cy.ts Reordered import statement for UserProfilePage.
cypress/pageobject/Patient/PatientPredefined.ts Reintroduced PatientPage import and included generatePhoneNumber function in imports.
cypress/tsconfig.json Reformatted lib array for readability and added a newline at the end of the file.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Lint
    participant Sorter

    User->>Lint: Trigger lint-staged
    Lint->>Sorter: Read locale data from public/locale/en.json
    Sorter->>Sorter: Sort JSON data
    Sorter->>Lint: Write sorted data back to public/locale/en.json
Loading

🐇 "In the public glade, the locales now play,
With paths all anew, they hop and they sway.
From src they have leapt, to the public they go,
Sorting their keys in a neat little row.
With npm in hand, we dance through the day,
Hooray for the changes, hip-hip-hooray!" 🥳

Possibly related PRs

Suggested labels

needs testing, needs review

Suggested reviewers

  • shivankacker

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

netlify bot commented Nov 9, 2024

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit 2754732
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/672ef5de37886500084c97e2
😎 Deploy Preview https://deploy-preview-9070--care-ohc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@JavidSumra
Copy link
Contributor Author

Hey @rithviknishad can you please review the changes?

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
scripts/sort-locales.js (1)

Line range hint 4-15: Consider adding error handling for file operations.

The script performs file operations without error handling, which could fail silently if the directory or file doesn't exist.

Consider adding basic error handling:

 const fs = require("fs");
 
 const file = "public/locale/en.json";
 
-const data = JSON.parse(fs.readFileSync(file, "utf8"));
+try {
+  const data = JSON.parse(fs.readFileSync(file, "utf8"));
 
-const sortedData = Object.keys(data)
-  .sort()
-  .reduce((acc, key) => {
-    acc[key] = data[key];
-    return acc;
-  }, {});
+  const sortedData = Object.keys(data)
+    .sort()
+    .reduce((acc, key) => {
+      acc[key] = data[key];
+      return acc;
+    }, {});
 
-fs.writeFileSync(file, JSON.stringify(sortedData, null, 2) + "\n");
+  fs.writeFileSync(file, JSON.stringify(sortedData, null, 2) + "\n");
+  console.log(`Successfully sorted locale file: ${file}`);
+} catch (error) {
+  console.error(`Error processing locale file: ${error.message}`);
+  process.exit(1);
+}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 6bd2aa8 and 04f6be6.

📒 Files selected for processing (2)
  • package.json (1 hunks)
  • scripts/sort-locales.js (1 hunks)
🔇 Additional comments (4)
scripts/sort-locales.js (1)

4-4: Verify the existence of the new locale directory structure.

The path change from src/Locale/en.json to public/locale/en.json looks good and aligns with common practices of storing static assets in the public directory. However, we should ensure the new structure is properly set up.

Let's verify the directory structure and check for other locale files:

✅ Verification successful

Path change to public/locale/en.json is properly implemented

The verification confirms:

  • The new public/locale directory exists and is properly set up
  • Multiple locale files are present (en.json, hi.json, kn.json, ml.json, mr.json, ta.json)
  • No references to the old path src/Locale were found in the codebase
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify locale directory structure and files

# Check if the new directory exists
if [ -d "public/locale" ]; then
    echo "✓ public/locale directory exists"
else
    echo "✗ public/locale directory not found"
fi

# List all JSON files in the locale directory
echo "Locale files found:"
fd -e json . public/locale

# Check if there are any remaining references to the old path
echo "Checking for old path references:"
rg -i "src/Locale" --type js --type json --type ts

Length of output: 439

package.json (3)

169-171: Ensure sort-locales script is updated.

The lint-staged configuration points to the new locale path. Verify that the sort-locales script in scripts/sort-locales.js has been updated to use the same path.

#!/bin/bash
# Description: Verify sort-locales script is updated with new path

# Check the sort-locales script for path references
echo "Checking sort-locales script..."
rg -i "locale" scripts/sort-locales.js

Line range hint 173-175: Verify npm version compatibility with Node.js requirement.

The package requires Node.js >=22.11.0 but specifies npm@10.9.0. Please verify this combination is compatible, as npm versions typically align with specific Node.js versions.

#!/bin/bash
# Description: Check for any npm version related issues in the repository

# Look for npm-related warnings or errors in package-lock.json
echo "Checking package-lock.json for version conflicts..."
rg -i "npm" package-lock.json

# Check for engine-strict configuration
echo "Checking for engine-strict configuration..."
rg -i "engine-strict" .npmrc

Also applies to: 176-176


169-171: Verify the architectural decision to move locale files.

Moving locale files from src/ to public/ directory represents a significant architectural change. While this makes the files directly accessible at runtime, please ensure this aligns with your build and deployment strategy.

✅ Verification successful

The locale path change is properly implemented and consistent

The verification shows that:

  • No files exist in the old src/Locale directory
  • Multiple locale files (en, hi, kn, ml, mr, ta) are present in the new public/locale directory
  • The sort-locales.js script has been updated to use the new path
  • No other references to the old path exist in the codebase

The architectural change to move locale files to public/locale appears to be complete and consistent across the codebase. This is a valid approach as it makes the locale files directly accessible as static assets.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence and usage of locale files in both old and new locations

# Check if files exist in both locations
echo "Checking locale file locations..."
fd -t f -e json . src/Locale/
fd -t f -e json . public/locale/

# Look for any remaining references to the old path
echo "Checking for references to old path..."
rg -i "src/Locale" -g '!package.json'

Length of output: 515


Script:

#!/bin/bash
# Let's verify the locale file locations and references more thoroughly

# Check for locale files in both locations
echo "=== Checking locale files in src/Locale ==="
fd -t f -e json . "src/Locale"

echo -e "\n=== Checking locale files in public/locale ==="
fd -t f -e json . "public/locale"

# Search for imports or requires of locale files
echo -e "\n=== Checking for locale file imports/requires ==="
rg -l "(?i)(import|require).*locale.*\.json"

# Check for any webpack or build config files that might handle locales
echo -e "\n=== Checking build configurations ==="
fd -e config.js -e webpack.config.js

# Look for references to locale paths in JavaScript/TypeScript files
echo -e "\n=== Checking for locale path references ==="
rg "(?i)(src/Locale|public/locale)" -g "*.{js,jsx,ts,tsx}"

Length of output: 957

Copy link
Member

@rithviknishad rithviknishad left a comment

Choose a reason for hiding this comment

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

Nice find @JavidSumra

@rithviknishad rithviknishad changed the title Update Locale Path fix locale sort's path and fix format script to sort cypress dir Nov 9, 2024
@rithviknishad rithviknishad merged commit 84fdffe into ohcnetwork:develop Nov 9, 2024
19 of 20 checks passed
Copy link

github-actions bot commented Nov 9, 2024

@JavidSumra @JavidSumra Your efforts have helped advance digital healthcare and TeleICU systems. 🚀 Thank you for taking the time out to make CARE better. We hope you continue to innovate and contribute; your impact is immense! 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants