Skip to content

Update deps#253

Merged
lemon-mint merged 5 commits into
productionfrom
main
Jul 12, 2026
Merged

Update deps#253
lemon-mint merged 5 commits into
productionfrom
main

Conversation

@lemon-mint

@lemon-mint lemon-mint commented Jul 12, 2026

Copy link
Copy Markdown
Member

Summary by Sourcery

Upgrade Tailwind CSS and related frontend tooling, refresh generated styles, and refactor markdown and translation handling for improved robustness and maintainability.

New Features:

  • Introduce a reusable helper for translating and evaluating post fields to enforce minimum quality thresholds.
  • Add CLI usage output and argument validation for translation-related subcommands.
  • Generate cleaner URL slugs for posts using a regex-based sanitizer.
  • Create shared RSS feed item construction to avoid duplication between global and per-language feeds.

Enhancements:

  • Refactor markdown processing into separate metadata filling, file saving, and post update functions to clarify responsibilities.
  • Improve database initialization and atomic update logic with better error handling, syncing, and temporary file cleanup.
  • Modernize file traversal and directory copying utilities using WalkDir for safer error propagation.
  • Update templ-generated components to the latest templ version and attribute resolution semantics.
  • Normalize code block styling across light and dark themes and integrate Tailwind v4 property and theme layers.

Build:

  • Switch Tailwind setup to the v4 CLI, update Tailwind configuration via @import and @theme, and change the build script to use npm instead of Bun.
  • Refresh Node devDependencies including Tailwind, typography plugin, TypeScript typings, and caniuse-lite.
  • Update Go module dependencies (Vertex AI, templ, goldmark, zerolog, tdewolff/minify, klauspost/compress, image, and OpenTelemetry-related libraries) to newer versions.

Documentation:

  • Polish and clarify the managed languages blog post prose and code examples for readability.

@sourcery-ai

sourcery-ai Bot commented Jul 12, 2026

Copy link
Copy Markdown

Reviewer's Guide

This PR upgrades Tailwind and various Go and JS dependencies, refactors markdown processing into smaller functions with safer slug generation and translation handling, hardens database updates and CLI commands, and refreshes RSS/sitemap generation and front-end build/configuration.

Sequence diagram for markdown processing pipeline

sequenceDiagram
  actor Dev
  participant Main as generate_main
  participant PMF as processMarkdownFile
  participant Parse as parseMarkdown
  participant Meta as fillMissingMetadata
  participant Save as saveMarkdownWithMetadata
  participant Update as updatePostAndTranslate

  Dev->>Main: generate_main()
  Main->>PMF: processMarkdownFile(gc, path)
  PMF->>PMF: os.ReadFile(path) / normalize
  PMF->>Parse: parseMarkdown(path, data)
  Parse-->>PMF: *types.Document
  PMF->>Meta: fillMissingMetadata(ctx, doc, path)
  Meta-->>PMF: error?
  PMF->>Save: saveMarkdownWithMetadata(path, doc)
  Save-->>PMF: error?
  PMF->>Update: updatePostAndTranslate(gc, doc, path)
  Update-->>PMF: error?
  PMF-->>Main: *types.Document
Loading

Sequence diagram for translation and evaluation of a post

sequenceDiagram
  participant Gen as translateLang
  participant TAE as translateAndEvaluate
  participant LLM as translate.Translate
  participant Eval as evaluate.EvaluateTranslation

  Gen->>TAE: translateAndEvaluate(ctx, post, lang, name, "title", title)
  TAE->>LLM: Translate(ctx, llmModel, text, fullLangName)
  LLM-->>TAE: translatedText
  TAE->>Eval: EvaluateTranslation(ctx, llmModel, post.Main.Metadata.Language, lang, text, translatedText)
  Eval-->>TAE: score
  alt score < 0.7
    TAE-->>Gen: ErrLowQualityTranslation
  else score >= 0.7
    TAE-->>Gen: translatedText
  end
  Gen->>TAE: translateAndEvaluate(..., "description", description)
  Gen->>TAE: translateAndEvaluate(..., "content", origDocument)
  Gen-->>Gen: build translated metadata & markdown
Loading

Sequence diagram for CLI command argument handling

sequenceDiagram
  actor User
  participant Main as main
  participant RL as remove_lang_main

  User->>Main: website remove_lang <postID> <lang>
  Main->>Main: validate os.Args length
  alt missing args
    Main->>Main: log.Error("missing arguments")
    Main->>Main: printUsage()
    Main->>Main: os.Exit(1)
  else valid args
    Main->>RL: remove_lang_main(postID, lang)
    RL->>RL: initializeDatabase(dbFile)
    RL->>RL: lookup ds.Posts[postID]
    RL->>RL: delete(post.Translated, lang)
    RL->>RL: updateDatabase(dbFile, ds)
  end
Loading

File-Level Changes

Change Details Files
Refactor markdown processing into focused helpers and improve slug/path generation.
  • Split processMarkdownFile into fillMissingMetadata, saveMarkdownWithMetadata, and updatePostAndTranslate for clearer responsibilities and reuse
  • Ensure description generation uses passed context instead of context.Background
  • Add slugRegex and replace manual character replacement with regex-based normalization plus Trim on hyphens in generatePath
markdown.go
Improve translation workflow by centralizing translate+evaluate logic and reusing it for title, description, and content.
  • Introduce translateAndEvaluate helper that runs translation and EvaluateTranslation and enforces a minimum quality score
  • Use translateAndEvaluate for title, description, and body translation in translateLang, removing duplicated logging and scoring code
translate.go
Harden database initialization and atomic updates.
  • Simplify initializeDatabase to use errors.Is for existence checks, create a minimal compressed JSON database when missing, and ensure files/writers are closed on error paths
  • Make updateDatabase write to a temp file, close, fsync, and then rename, with cleanup of the temp file via deferred removal
database.go
Improve CLI entrypoint, argument validation, and usage output.
  • Replace package-level init hack with a standard init function for env and logger setup
  • Refactor remove_lang_main, get_translation_main, and eval_translation_main to accept postID/lang arguments and validate post/translation existence
  • Add printUsage and command-specific argument checks; handle unknown commands with error + usage and exit non‑zero
  • Switch go:generate frontend build command from bun to npm
main.go
build.sh
Update RSS/sitemap generation to use shared item creation and safer path handling.
  • Add createFeedItem helper to construct feeds.Item from Post+Document and reuse it in both global and per-language feeds
  • Use filepath.Join for writing feed.rss and sitemap.xml paths
  • Fix language-specific feed URLs by using string(lang) and correct translation map key type
feeds.go
Modernize filesystem helpers to use WalkDir and propagate errors correctly.
  • Change generateFileList and copyDir from filepath.Walk to filepath.WalkDir, using DirEntry and properly returning errors from callbacks
  • Make copyDir return the error from WalkDir rather than always nil
utils.go
Upgrade Tailwind CSS to v4 and adjust CSS generation, theme, and code styling.
  • Replace large v3 precompiled main.css with Tailwind v4 output using @layer theme/base/components/utilities and new CSS custom properties
  • Adjust root/blog/managed-languages-intro.md content formatting and Markdown tables for better rendering with new typography
  • Change tailwind-main.css to use @import "tailwindcss", Tailwind plugins, @theme configuration, and @source globs; tweak inline code styling and dark-mode behavior
public/main.css
root/blog/managed-languages-intro.md
public/tailwind-main.css
Update JS build tooling and templ-generated view code for newer versions.
  • Update package.json devDependencies to Tailwind v4 CLI, newer typography plugin, Bun types, TypeScript, and caniuse-lite; remove separate dependencies block
  • Regenerate templ components to v0.3.1020, switching from JoinStringErrs+EscapeString to ResolveAttributeValue where appropriate
package.json
view/component_head_templ.go
view/component_gosuda_blog_post_templ.go
view/component_blog_post_templ.go
view/index_templ.go
view/post_templ.go
view/component_blog_footer_templ.go
view/component_blog_header_templ.go
view/component_blog_sidebar_templ.go
view/component_gosuda_blog_index_templ.go
view/component_index_page_body_templ.go
view/component_post_page_body_templ.go
view/sitemap_templ.go
Bump Go module dependencies to newer versions aligned with Tailwind and templ upgrades.
  • Update core deps such as cloud.google.com/go/vertexai, templ, chroma, klauspost/compress, zerolog, goldmark, x/image, and others
  • Refresh indirect dependencies including OpenTelemetry, Google APIs/genai, grpc, golang.org/x/* packages, and regexp2 to latest compatible releases
go.mod
go.sum
Add/refresh ancillary project files related to ignores and JS lockfile.
  • Update .gitignore and package-lock.json to reflect npm-based build and new JS dependency graph
.gitignore
package-lock.json

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

Fixed security issues:

  • golang.org/x/crypto (link)

  • golang.org/x/net (link)

  • google.golang.org/grpc (link)

  • package-lock.json (link)

  • In generateLocalFeed, post.Translated is now indexed with string(lang) instead of lang (types.Lang); unless the map key type was changed elsewhere, this will break lookups and should be aligned with the actual key type.

  • updateDatabase now defers removal of the tmp file and also explicitly closes/syncs before rename, but the defer will still remove the tmp file after a successful rename; consider only deleting on error to avoid removing the new file on platforms where rename doesn’t fully replace atomically.

Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In generateLocalFeed, post.Translated is now indexed with string(lang) instead of lang (types.Lang); unless the map key type was changed elsewhere, this will break lookups and should be aligned with the actual key type.
- updateDatabase now defers removal of the tmp file and also explicitly closes/syncs before rename, but the defer will still remove the tmp file after a successful rename; consider only deleting on error to avoid removing the new file on platforms where rename doesn’t fully replace atomically.

## Individual Comments

### Comment 1
<location path="database.go" line_range="78" />
<code_context>

 func updateDatabase(dbFile string, ds *DataStore) error {
-	f, err := os.OpenFile(dbFile+".tmp", os.O_CREATE|os.O_RDWR|os.O_TRUNC|os.O_EXCL, 0644)
+	tmpFile := dbFile + ".tmp"
+	f, err := os.OpenFile(tmpFile, os.O_CREATE|os.O_RDWR|os.O_TRUNC|os.O_EXCL, 0644)
 	if err != nil {
</code_context>
<issue_to_address>
**issue (bug_risk):** The deferred removal of the temp file can hide data if os.Rename fails and is unnecessary on success.

In `updateDatabase`, the deferred `os.Remove(tmpFile)` runs regardless of whether `os.Rename` succeeds. If `os.Rename` fails (e.g., permissions, concurrent access), the temp file containing the compressed database is deleted, losing potentially useful data for recovery or debugging. On success, the remove is unnecessary because the path is replaced by the renamed file. Consider removing the deferred `os.Remove` and instead only deleting the temp file after a successful rename, or retaining it on failure so callers can inspect or retry.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread database.go

func updateDatabase(dbFile string, ds *DataStore) error {
f, err := os.OpenFile(dbFile+".tmp", os.O_CREATE|os.O_RDWR|os.O_TRUNC|os.O_EXCL, 0644)
tmpFile := dbFile + ".tmp"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): The deferred removal of the temp file can hide data if os.Rename fails and is unnecessary on success.

In updateDatabase, the deferred os.Remove(tmpFile) runs regardless of whether os.Rename succeeds. If os.Rename fails (e.g., permissions, concurrent access), the temp file containing the compressed database is deleted, losing potentially useful data for recovery or debugging. On success, the remove is unnecessary because the path is replaced by the renamed file. Consider removing the deferred os.Remove and instead only deleting the temp file after a successful rename, or retaining it on failure so callers can inspect or retry.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the project's build and dependency configuration by migrating from Bun to npm, upgrading Go and npm dependencies (including Tailwind CSS to v4), and regenerating the templ view files. It also refactors several Go files to improve code quality, such as extracting translation logic, cleaning up database file handling, and simplifying path generation with regular expressions. The review feedback highlights two key improvement opportunities: removing an unnecessary database write operation in get_translation_main to prevent redundant disk I/O, and replacing a fragile strings.TrimPrefix path manipulation with filepath.Rel to ensure robust, cross-platform path resolution.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread main.go
Comment on lines 86 to 90
err = updateDatabase(dbFile, ds)
if err != nil {
log.Fatal().Err(err).Msgf("failed to update database file %s", dbFile)
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

In get_translation_main, the database is only being read to print the translation markdown to stdout. No modifications are made to ds.

Calling updateDatabase here is unnecessary, causes redundant disk I/O, and writes a log message indicating the database was updated. We should remove this call.

}

Comment thread utils.go
Comment on lines 58 to 59
relPath := strings.TrimPrefix(path, src)
dstPath := filepath.Join(dst, relPath)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using strings.TrimPrefix(path, src) to determine the relative path can be fragile and error-prone, especially on Windows where path separators differ (\ vs /). If src contains a trailing slash or uses a different separator style, the prefix match might fail entirely, leading to incorrect destination paths.

Using filepath.Rel(src, path) is the standard, robust, and cross-platform way to compute relative paths in Go.

		relPath, err := filepath.Rel(src, path)
		if err != nil {
			return err
		}
		dstPath := filepath.Join(dst, relPath)

@lemon-mint lemon-mint merged commit f4acbb3 into production Jul 12, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants