-
Notifications
You must be signed in to change notification settings - Fork 23
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
Fetch settings from JSON API #86
Conversation
Edited the help file, so it shows the user how settings can be fetched
📝 WalkthroughWalkthroughThe change involves an update to the destructuring assignment in the Changes
Poem
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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.
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 (2)
nodejs-write-code.md (2)
11-11
: Approved: Addition ofsettings
property aligns with PR objectives.The inclusion of the
settings
property in the destructuring assignment is consistent with the PR's goal of fetching settings from a JSON API. This change enhances the plugin's capability to handle configuration data.However, to improve the documentation:
- Consider adding an explanation of the
settings
property's purpose and structure.- Provide an example of how to use the
settings
object within the plugin code.Here's a suggested addition to the documentation:
### 8. Using settings The `settings` object, extracted alongside `method` and `parameters`, contains configuration data fetched from the JSON API. You can use these settings to customize your plugin's behavior. For example: ```js if (method === "query") { const customGreeting = settings.greeting || "Hello World"; console.log(JSON.stringify({ "result": [{ "Title": customGreeting, "Subtitle": `Showing your query parameters: ${parameters}. Click to open Flow's website`, // ... rest of the result object }] })); }This example demonstrates how to use a custom greeting from the
settings
object, falling back to a default value if not provided.--- Line range hint `1-100`: **Enhance documentation with error handling and testing sections** The current documentation provides a comprehensive guide for basic plugin development. To further improve its value, consider adding the following sections: 1. Error Handling: Explain how to implement robust error handling in the plugin, including how to communicate errors back to Flow Launcher. 2. Testing: Provide guidance on writing and running tests for the plugin to ensure its reliability and ease of maintenance. These additions would help developers create more robust and maintainable plugins. Here's a suggested outline for these new sections: ```markdown ### 9. Error Handling Implement proper error handling to ensure your plugin gracefully handles unexpected situations: ```js try { // Your plugin logic here } catch (error) { console.log(JSON.stringify({ "result": [{ "Title": "An error occurred", "Subtitle": error.message, "IcoPath": "Images\\error.png" }] })); }
10. Testing
Write tests to ensure your plugin functions correctly:
- Install a testing framework like Jest:
npm install --save-dev jest
- Create a
__tests__
directory and add test files, e.g.,main.test.js
- Write tests for your plugin's functions
- Run tests with
npm test
Example test:
test('do_something_for_query opens correct URL', () => { const mockOpen = jest.fn(); jest.mock('open', () => mockOpen); do_something_for_query('https://example.com'); expect(mockOpen).toHaveBeenCalledWith('https://example.com'); });<details> <summary>:toolbox: Tools</summary> <details> <summary>Markdownlint</summary><blockquote> 14-14: Column: 1 Hard tabs (MD010, no-hard-tabs) </blockquote></details> </details> </blockquote></details> </blockquote></details> <details> <summary>:scroll: Review details</summary> **Configuration used: CodeRabbit UI** **Review profile: CHILL** <details> <summary>:inbox_tray: Commits</summary> Files that changed from the base of the PR and between 015d00f90dda641daeb3828e8841deb40ca348bb and 7d8da3a72c285903c6784a26527f83b7d8681006. </details> <details> <summary>:ledger: Files selected for processing (1)</summary> * nodejs-write-code.md (1 hunks) </details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Edited the help file, so it shows the user how plugin settings can be fetched