Add --json arg to switch to json output#32
Conversation
add --json option to speedTest function Co-authored-by: aider (openrouter/qwen/qwen-2.5-coder-32b-instruct) <aider@aider.chat>
- Added Jest testing framework with comprehensive test coverage - Created test suite with network function mocks for HTTPS requests - Separated logic into lib.js for testability while keeping cli.js as entry point - Fixed jitter function to handle single value edge case - Set up proper Makefile with phony targets for test commands - Add target to create a binary with deno - Added 31 tests covering network functions, measurements, statistics, logging, and CLI parsing - Updated CLAUDE.md with testing documentation and architecture changes 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add CONTRIBUTING.md following conventions - Created CLAUDE.md and QWEN.md symlinks for the respective tools - Added guidance for editorconfig compliance (final newlines, no trailing whitespace) Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Summary of Changes
Hello @hexmode, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request significantly enhances the Cloudflare speed test CLI by adding a new --json output option, making the results programmatically consumable. To facilitate this and improve overall maintainability, the core application logic has been refactored into a dedicated library file. Furthermore, the project's development workflow is improved with the addition of a Makefile for Deno-based compilation and a comprehensive Jest test suite, ensuring the reliability and robustness of the changes.
Highlights
- JSON Output Mode: Introduced a new
--jsoncommand-line argument that allows the speed test results to be output in a structured JSON format, addressing issue #31. - Codebase Refactoring: Extracted the core speed test logic, including network requests, measurement functions, and logging, from
cli.jsinto a newlib.jsmodule. This significantly improves modularity and prepares the codebase for future enhancements. - Build System Integration: Added a
Makefileto streamline the build process, enabling the compilation of the Node.js CLI into a standalone binary using Deno. This also includes targets for cleaning and running integration tests. - Enhanced Test Coverage: Implemented a comprehensive Jest test suite with new files (
test/cli.test.js,test/stats.test.js,test/mocks.js) to cover various aspects of the application, including network interactions, measurement calculations, logging, and argument parsing. Thepackage.jsonwas updated to use Jest for testing. - Developer Documentation: Added a detailed
CONTRIBUTING.mdguide to provide clear development guidelines for contributors, covering testing, building, code quality, and architectural overview.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
|
Also adds tests and a CONTRIBUTING.md doc but, if those aren't wanted I can trim the PR. |
There was a problem hiding this comment.
Code Review
This pull request introduces a new --json output format, refactors the code into a library and an executable, adds a Makefile for building, and includes comprehensive tests. My review focuses on improving the new lib.js file's robustness and maintainability. I've identified a critical issue with error handling when using JSON output, a high-priority suggestion to improve code clarity by refactoring how data is passed, and a medium-priority correction for the JSDoc. I've also found a small documentation issue in the new CONTRIBUTING.md file.
Update JSDoc per suggestion. KNawm#32 (comment) Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Fixes #31 and also makes a rudimentary start on #26