Skip to content

fix(cli-helpers): Proper darwin url#1454

Merged
Tobbe merged 1 commit intomainfrom
tobbe-fix-cli-helpers-url-href
Mar 24, 2026
Merged

fix(cli-helpers): Proper darwin url#1454
Tobbe merged 1 commit intomainfrom
tobbe-fix-cli-helpers-url-href

Conversation

@Tobbe
Copy link
Copy Markdown
Member

@Tobbe Tobbe commented Mar 24, 2026

This PR fixes this warning:

11:38:27 PM [vite] (ssr) warning: File URL host must be "localhost" or empty on darwin
  Plugin: vite:dynamic-import-vars
  File: /Users/tobbe/dev/cedarjs/cedar/packages/cli-helpers/src/lib/index.ts
 ✓ src/lib/__tests__/index.test.ts (1 test) 297ms
   ✓ prettify formats tsx content 297ms

 Test Files  1 passed (1)
      Tests  1 passed (1)
   Start at  23:38:27
   Duration  724ms (transform 74ms, setup 0ms, collect 154ms, tests 297ms, environment 0ms, prepare 100ms)

@netlify
Copy link
Copy Markdown

netlify Bot commented Mar 24, 2026

Deploy Preview for cedarjs canceled.

Name Link
🔨 Latest commit f071fe0
🔍 Latest deploy log https://app.netlify.com/projects/cedarjs/deploys/69c314a4d000b40008c33129

@github-actions github-actions Bot added this to the next-release-patch milestone Mar 24, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Mar 24, 2026

Greptile Summary

This PR fixes a Vite SSR warning on macOS by replacing a manually constructed file:// URL template literal with the proper pathToFileURL utility from Node's built-in node:url module when dynamically importing the project's prettier config file.

  • Adds import { pathToFileURL } from 'node:url' to packages/cli-helpers/src/lib/index.ts
  • Replaces `file://${prettierConfigPath}` with pathToFileURL(prettierConfigPath).href in getPrettierOptions
  • pathToFileURL is the idiomatic, correct way to convert a file-system path to a file: URL — it handles special characters, platform differences (Windows drive letters), and produces a properly encoded URL that satisfies Node.js and Vite's URL host validation on darwin

Confidence Score: 5/5

  • This PR is safe to merge — it's a targeted, idiomatic one-liner fix with no risk of regression.
  • The change is minimal (one import + one expression replacement), uses the standard Node.js utility for the job, is cross-platform correct, and directly addresses the reported Vite warning. No logic is altered beyond URL construction.
  • No files require special attention.

Important Files Changed

Filename Overview
packages/cli-helpers/src/lib/index.ts Replaces manual file:// template literal with pathToFileURL from node:url to properly construct file URLs on macOS (darwin), fixing a Vite SSR warning.

Sequence Diagram

sequenceDiagram
    participant C as CLI / Vite SSR
    participant G as getPrettierOptions()
    participant FS as node:fs
    participant URL as node:url (pathToFileURL)
    participant I as dynamic import()

    C->>G: call getPrettierOptions()
    G->>FS: existsSync(cjsPath)
    FS-->>G: true/false → prettierConfigPath
    G->>URL: pathToFileURL(prettierConfigPath).href
    URL-->>G: properly encoded file:/// URL
    G->>I: import(fileURL)
    I-->>G: { default: options }
    G-->>C: options
Loading

Reviews (1): Last reviewed commit: "fix(cli-helpers): Proper darwin url" | Re-trigger Greptile

@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Mar 24, 2026

🤖 Nx Cloud AI Fix

Ensure the fix-ci command is configured to always run in your CI pipeline to get automatic fixes in future runs. For more information, please see https://nx.dev/ci/features/self-healing-ci


View your CI Pipeline Execution ↗ for commit f071fe0

Command Status Duration Result
nx run-many -t build ✅ Succeeded 3m 18s View ↗

☁️ Nx Cloud last updated this comment at 2026-03-24 23:27:26 UTC

@Tobbe Tobbe enabled auto-merge (squash) March 24, 2026 23:22
@Tobbe Tobbe merged commit c614dee into main Mar 24, 2026
65 of 70 checks passed
@Tobbe Tobbe deleted the tobbe-fix-cli-helpers-url-href branch March 24, 2026 23:27
@github-actions
Copy link
Copy Markdown

The changes in this PR are now available on npm.

Try them out by running yarn cedar upgrade -t 4.0.0-canary.13669

Tobbe added a commit that referenced this pull request Mar 25, 2026
@Tobbe Tobbe modified the milestones: next-release-patch, v3.1.0 Mar 25, 2026
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.

1 participant