Conversation
Owner
Author
There was a problem hiding this comment.
Pull request overview
This PR appears to address issues #1 and #3 by making generated position values configurable (via CLI offsets) and by adjusting how view field definitions are assembled during code generation.
Changes:
- Added CLI options
--views-base-positionand--nav-menu-items-base-positionand threaded their parsed values into generation behavior. - Introduced a shared position “store” utility and switched view/nav-menu generators to use incrementing positions instead of hard-coded
0. - Added a
stringToInthelper and refactoredgenerateTwentyViewFieldsto build output via string concatenation.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/internal/utils/temp-store.ts | New global stores for view/nav-menu positions, currently initialized by calling createCLI() at module import time. |
| src/internal/utils/string-to-int.ts | New helper for converting CLI option values to integers with fallback behavior. |
| src/internal/generators/generate-twenty-view.ts | Uses the new temp store to assign incremental view positions. |
| src/internal/generators/generate-twenty-view-fields.ts | Refactors view-fields string construction and introduces a (fixable) separator naming typo. |
| src/internal/generators/generate-twenty-nav-menu-item.ts | Uses the new temp store to assign incremental nav menu item positions. |
| src/internal/create-cli.ts | Adds new CLI options and converts them to numbers in the .action handler. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+1
to
+5
| import { createCLI } from "../create-cli.js"; | ||
|
|
||
| const { viewsBasePosition, navMenuItemsBasePosition } = | ||
| createCLI(); | ||
|
|
Comment on lines
+3
to
+18
| export const stringToInt = (str: any): number => { | ||
| let num = parseInt(str as string, 10); | ||
|
|
||
| if (isNaN(num)) { | ||
| console.error( | ||
| styleText( | ||
| "red", | ||
| `Cannot convert "${str}" to an integer. Falling back to 0.` | ||
| ) | ||
| ); | ||
|
|
||
| num = 0; | ||
| } | ||
|
|
||
| return num; | ||
| }; |
Comment on lines
+56
to
+58
| const labelFieldSeperator = islabelFieldExists | ||
| ? fieldSeperator | ||
| : "\n"; |
Comment on lines
+89
to
+90
| .option("--views-base-position <number>", "offset for views starting index", DEFAULT_VIEWS_BASE_POSITION) | ||
| .option("--nav-menu-items-base-position <number>", "offset for navigation menu items starting index", DEFAULT_NAV_MENU_ITEMS_BASE_POSITION) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.