Skip to content

fix(build-scripts): make the docs edited-dates step work on Windows - #17455

Merged
kodiakhq[bot] merged 1 commit into
developfrom
fix/docs-edited-dates-windows-shell
Oct 23, 2026
Merged

kodiakhq[bot] merged 1 commit into
developfrom
fix/docs-edited-dates-windows-shell

Conversation

@medusa-os-bot

@medusa-os-bot medusa-os-bot Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Summary

What — Makes the edited-dates step of the docs yarn prep script work on Windows by removing a POSIX-only shell command and normalizing the project path before comparing it with git's output.

Why — generateEditedDates ran { git diff --name-only ; git diff --name-only --staged ; } | sort | uniq through child_process.exec. On Windows, exec uses cmd.exe, which can't parse { ...; } grouping, so prep crashed for Windows contributors. Even with the command fixed, monorepoRelativePath came from string replacement on an OS path. On Windows it kept backslashes (and a leading \), so it never matched git's forward-slash paths, and changed pages would have been silently skipped.

How — In www/packages/build-scripts/src/generate-edited-dates.ts:

  • monorepoRelativePath is now path.relative(rootPath, projectBasePath) with separators normalized to /.
  • getChangedFiles runs git diff --name-only and git diff --name-only --staged as separate commands, then merges and dedupes the output with a Set instead of sort | uniq.

tsconfig.json now excludes __tests__ from the build, the same way docs-utils does, so tsc doesn't compile the test.

Testing — Added www/packages/build-scripts/src/__tests__/generate-edited-dates.test.ts. It mocks exec to behave like a shell that only accepts plain commands, mocks fs, and runs under both path.posix and path.win32. It checks that unstaged and staged pages of the project are collected and deduped, and that pages of other projects are left out.

  • Before the fix, both cases failed with '{ git diff --name-only ; git diff --name-only --staged ; } | sort | uniq' is not recognized as a command.
  • With only the command fixed, the win32 case still failed: it received [] instead of the three changed pages.
  • After the full fix, both cases pass.

Checklist

  • I have added a changeset for this PR
  • The changes are covered by relevant tests
  • I have verified the code works as intended locally
  • I have linked the related issue(s) if applicable

Additional Context

  • No changeset: build-scripts is a private www/ package and isn't published.
  • build-scripts has no test script, and the www workspace dependencies weren't installed in this environment. I ran the test with the root vitest binary and a minimal throwaway config (environment: "node", inline esbuild tsconfig), because www/vitest.config.mts needs plugins that aren't installed.
  • Not fixed here: on Windows, getAllProjectFiles and the untracked-files branch build keys with path.relative, which gives backslash-separated keys. Also, file.startsWith(monorepoRelativePath) would match a sibling project whose name starts with the same prefix (e.g. www/apps/book-foo).

Fixes #17249

Opened automatically by the Fix Bug workflow. Review carefully before merging.

@changeset-bot

changeset-bot Bot commented Oct 22, 2026

Copy link
Copy Markdown

⚠ïļ No Changeset found

Latest commit: 4bfce92

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@medusa-os-bot

medusa-os-bot Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the contribution! Initial automated review looks good.

Verdict: Looks good for a final review by the team.

Fixes the generateEditedDates build step on Windows by splitting the POSIX-only shell-grouped git diff command into two separate promiseExec calls deduped with a Set, and by normalizing the monorepoRelativePath to forward slashes via path.relative + .split(path.sep).join("/").

Checked: security (no user input reaches the shell commands), correctness (empty-string entries are filtered by startsWith; dedup is sound), performance, conventions, tests (posix and win32 cases both covered).

Triggered by: new PR opened

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
medusa-docs-api-reference 4bfce92 Commit Preview URL

Branch Preview URL
Oct 22 2026, 04:58 PM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
❌ Deployment failed
View logs
medusa-docs-ui 4bfce92 Oct 22 2026, 04:53 PM

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
medusa-docs-resources 4bfce92 Commit Preview URL

Branch Preview URL
Oct 22 2026, 05:01 PM

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
medusa-docs-user-guide 4bfce92 Commit Preview URL

Branch Preview URL
Oct 22 2026, 04:57 PM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
medusa-docs-cloud 4bfce92 Commit Preview URL

Branch Preview URL
Oct 22 2026, 05:01 PM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
medusa-docs-book 4bfce92 Commit Preview URL

Branch Preview URL
Oct 22 2026, 05:02 PM

@kodiakhq
kodiakhq Bot merged commit 79973b3 into develop Oct 23, 2026
52 of 53 checks passed
@kodiakhq
kodiakhq Bot deleted the fix/docs-edited-dates-windows-shell branch October 23, 2026 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs: yarn prep fails on Windows — edited-dates step uses a POSIX-only shell command

1 participant