Repository navigation
Enhance hn: real README, full test suite, entity decoding, least-privilege docs CI - #1
Merged
Merged
Conversation
The text fields carried raw HTML entities straight from HN, so URLs in comment and story bodies came out as https://example.com. Switch stripTags to html.UnescapeString, which covers the numeric and hex forms HN leans on, and turn <p> into a paragraph break instead of dropping it. Add a Change record and Updates.Changes() so the updates firehose flattens into the same flat records every other surface emits, and make the two API base URLs fields on Client so tests can point them at an httptest server. Modernize a couple of min() clamps along the way and stop echoing a story's own id back as story_id on story search hits.
updates printed nothing reusable before. Flatten it through Updates.Changes() so it renders in any output format like the rest of the commands, and let -n cap the firehose the way it caps the story lists.
httptest-backed tests for the Firebase and Algolia paths (rank order, deleted items dropped, comment-tree flatten and depth, not-found mapping, Algolia filter building and endpoint selection), table-driven tests for the entity decoding and record conversions, the renderer across all seven formats with --fields/--no-header/--template, and the cobra layer for exit-code mapping and flag wiring.
Replace the scaffold stub with the actual command surface, the output formats with worked examples, the search filters, the exit-code table, and the layout. The example output is from real runs.
The token was write-capable for every job. Make it read-only by default and grant pages:write and id-token:write only to the Pages deploy job, so the build job and the Cloudflare job (which handles the API secret) never hold a write token. Document the minimum Cloudflare API token scope next to where the secret is used.
One script to enable Pages in workflow mode and set the Cloudflare secrets on a fresh repo.
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.
First pass of the *-cli quality review, with hackernews-cli as the pilot.
Library
html.UnescapeString. Comment and story bodies were leaking raw entities, so URLs came out ashttps://example.com.<p>now becomes a paragraph break instead of being dropped.Changerecord andUpdates.Changes()so the updates firehose flattens into the same flat records as every other surface.Clientso tests can point them at an httptest server. No public API change.story_idon story search hits; comment hits still carry the parent thread's id and title.CLI
updatesnow renders structured records in any output format and honors-n.Tests
--fields,--no-header,--template.Docs and CI
pages:write+id-token:writeonly on the Pages deploy job. The build job and the Cloudflare job (which handles the API secret) never hold a write token. The minimum Cloudflare API token scope is documented next to the secret.Verification
gofmt,go vet,go test ./...,golangci-lint runall clean.Tagging v0.1.1 follows once this merges.