Fix shared-constants module registration - #181
Conversation
📝 WalkthroughWalkthroughThe changes update the module name for shared constants in the ApostropheCMS configuration and modify the script that generates client-side constants. The script now outputs object string representations with single quotes instead of double quotes by introducing a custom stringification function. Changes
Sequence Diagram(s)sequenceDiagram
participant Developer
participant generate_constants.js
participant Client Constants File
Developer->>generate_constants.js: Run script to generate constants
generate_constants.js->>generate_constants.js: Convert object with stringifyWithSingleQuotes
generate_constants.js->>Client Constants File: Write constants with single-quoted object
Possibly related PRs
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (6)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
website/scripts/generate_constants.js(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.{js,jsx}`: Test files have relaxed rules for function length, statements, extraneous requires, and destructuring
**/*.{js,jsx}: Test files have relaxed rules for function length, statements, extraneous requires, and destructuring
website/scripts/generate_constants.js
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: sonarqube
- GitHub Check: e2e-tests
- GitHub Check: security-scan
🔇 Additional comments (1)
website/scripts/generate_constants.js (1)
56-56: LGTM: Trailing comma addition.The trailing comma is a good practice for maintainability and follows modern JavaScript conventions.
Replace manual object literal construction with JSON.stringify to: - Handle all escaping automatically - Preserve original data types - Provide proper formatting with 2-space indentation - Eliminate potential code injection risks
Replace JSON.stringify with custom function that generates single quotes while maintaining proper escaping for security. This ensures the generated code follows project linting rules while preventing code injection risks.
…ation Fix incomplete string escaping by escaping backslashes first, then single quotes to prevent double escaping issues. This addresses the CodeQL 'Incomplete string escaping or encoding' high severity security warning.
Fix the prettier/prettier error by adding trailing comma to the last entry in the generated object. This ensures the auto-generated code follows project formatting rules.
|



Fixes the orphaned module warning by correcting the module name from 'shared-constants' to '@apostrophecms/shared-constants' in app.js configuration. This ensures the module is properly activated and eliminates the warning about unused code. Fixes for generate_constants.js to correctly generate data.