Skip to content

Blog tooling: make theme preview commands work in Windows shells (#28) - #40

Merged
HafidIdrissi merged 2 commits into
HafidIdrissi:mainfrom
rajarshikarmakarx:fix/#28-Blog-tooling-make-theme-preview-commands-work-in-Windows-shells
Oct 16, 2026
Merged

HafidIdrissi merged 2 commits into
HafidIdrissi:mainfrom
rajarshikarmakarx:fix/#28-Blog-tooling-make-theme-preview-commands-work-in-Windows-shells

Conversation

@rajarshikarmakarx

@rajarshikarmakarx rajarshikarmakarx commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Replace POSIX-only inline environment assignments in blog/package.json with a portable Node.js launcher (blog/scripts/run-theme.mjs) so theme preview and development server scripts work across Windows (cmd/PowerShell) and POSIX shells.

The launcher preserves the configured theme, port, base URL, and isolated preview output directories. It also restricts cleanup to the permitted preview destinations and propagates child-process exit codes.

What changed and why?

  • Replaced POSIX-only inline environment assignments in blog/package.json with a portable Node.js launcher.
  • Updated the theme preview and development server scripts to use the launcher.
  • Added strict path-confinement checks to prevent cleanup outside the permitted preview directories.
  • Added child-process exit-code and signal propagation.
  • Added blog/scripts/run-theme.test.mjs and the npm run test:launcher script to test the launcher.
  • Updated blog/README.md with theme preview, development server, and shutdown instructions.

Before

  • Windows: POSIX inline environment assignments such as BLOG_THEME=press eleventy --serve --port=8089 are not supported by the default Windows Command Prompt shell and can fail in Windows-based npm scripts.
  • POSIX: The inline assignments worked in Linux and macOS shells, but environment setup and process handling were not centralized in a portable launcher.
  • Cleanup safety: Preview output cleanup did not have the new launcher's explicit path-confinement checks.
  • Documentation: Startup and shutdown instructions for theme previews were not consolidated.

After

  • Portable execution: Theme preview and development server scripts invoke node scripts/run-theme.mjs with the appropriate configuration.
  • Configuration preservation: Theme selection, ports, base URLs, and isolated preview output directories are preserved.
  • Cleanup safety: Cleanup paths are validated against permitted preview destinations before deletion.
  • Process handling: Child-process exit codes and signals are propagated by the launcher.
  • Regression coverage: Automated Node.js tests cover configuration/argument handling, invalid cleanup paths, and nonzero child exit codes.
  • Documentation: blog/README.md explains how to start previews and development servers and stop them using Ctrl+C.

Example:

npm run preview:press

How I tested it

Fedora Linux validation

Environment

  • OS: Fedora Linux 44
  • Node.js: v24.21.0
  • npm: 11.19.0

Commands and results

  1. npm ci — installed project dependencies.
  2. npm run preview:sunroom — succeeded; generated output in ../docs/blog-preview-sunroom, with the corresponding base links verified.
  3. npm run preview:press — succeeded; generated output in ../docs/blog-preview-press, with the corresponding base links verified.
  4. npm run dev:press — Eleventy started at http://localhost:8089/, entered watch mode, and shut down after Ctrl+C.
  5. npm run build — normal production blog build succeeded.
  6. npm run test:launcher — 3 tests passed, 0 failed.

Windows PowerShell validation

Environment

  • OS/shell: Windows PowerShell
  • Node.js: v24.18.0
  • npm: 11.16.0
  • Checkout path: C:\Users\<username with spaces>\downloads\crewlo (contains a space).

Commands and results

  1. npm ci — completed successfully.
  2. npm run test:launcher — 3 tests passed, 0 failed.
  3. npm run preview:sunroom — succeeded; generated output in ../docs/blog-preview-sunroom.
  4. npm run preview:press — succeeded; generated output in ../docs/blog-preview-press.
  5. npm run build — completed successfully, including the postbuild sitemap step.
  6. npm run dev:press — started successfully, entered watch mode, and reported http://localhost:8089/.

The Windows dependency installation reported 12 npm audit findings (3 moderate, 9 high). No automatic audit fixes were applied.

Automated launcher tests

  • Invalid cleanup paths are rejected before file deletion or child-process launch; temporary sentinel files verify that disallowed cleanup does not delete unrelated files.
  • Arguments and environment configuration are passed to the child process as expected.
  • Nonzero child exit codes are propagated by the launcher.

Scope

This PR addresses issue #28 only. It does not intentionally change the production blog base URL or generated archive content.

Checklist

  • This PR addresses one focused change.
  • Checked the diff for secrets, personal data, and unrelated files.
  • Preserved inherited copyright and asset credits.
  • Kept changes scoped to the requested tooling fix.

  Replace POSIX inline environment assignments in blog/package.json with a
  portable Node launcher () so theme preview and
  dev server scripts work across Windows (cmd/PowerShell) and POSIX shells.
  Enforce strict output cleanup confinement, preserve child exit codes, and
  document preview startup and teardown in blog/README.md.
@vercel

vercel Bot commented Oct 14, 2026

Copy link
Copy Markdown

@rajarshikarmakarx is attempting to deploy a commit to the idrissihafez-3729's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

✅ Before and after are both described. Thanks for making the change reviewable.

@HafidIdrissi HafidIdrissi left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks @rajarshikarmakarx. I read #28, CONTRIBUTING.md, the complete three-file diff at 5c0a6f5d0eff73163ee42c15c8c861713d9449cc, package scripts and Eleventy configuration. The Node launcher preserves the configured theme/base/output/ports, confines cleanup to the two existing preview destinations and invokes Node directly rather than using shell-only environment assignment. Keep this PR limited to #28.

Please complete the focused validation before approval:

  1. The failing Before / after evidence check has a concrete formatting cause: both headings have leading spaces ( ## Before, ## After). I read the workflow and failing job log; its section matcher requires # at column one. Remove the leading spaces from those heading lines while keeping the useful text under each. Saving the description reruns this check; no waiver or screenshot is needed for this tooling change.
  2. Your description reports Fedora/Linux runs but says all platforms were verified. Record the actual Node/npm versions, exact commands and outcomes, and mark Windows validation as not performed until observed. From blog/ in a disposable checkout, run npm ci, both npm run preview:sunroom and npm run preview:press, npm run dev:press (port 8089, then Ctrl+C), and the normal npm run build. Validate the same preview commands through Windows' default npm shell/PowerShell, ideally with spaces in the checkout path. Confirm the correct isolated outputs/base links, normal production output and clean server shutdown without leaving the test-owned process running.
  3. Include a focused reproducible launcher check (standard-library Node tests are sufficient): verify environment/arguments, nonzero child exit propagation and refusal of an invalid --clean path before any deletion/child launch. Use temporary sentinel files, never personal files. This covers the behavior introduced by the wrapper rather than relying on a generic cross-platform claim. Report any skipped checks honestly and request a Windows tester if needed.

Current CI run https://github.com/HafidIdrissi/Crewlo/actions/runs/38607431825 and Build blog run https://github.com/HafidIdrissi/Crewlo/actions/runs/38607432508 require maintainer Approve and run. No workflow files changed, and the connector cannot approve execution. The Vercel authorization bot message is separate from these Actions checks. I have not run npm, Windows shells or a browser locally; the Linux checks above are your reported evidence.

Copy link
Copy Markdown
Owner

CI status correction for unchanged head 5c0a6f5d0eff73163ee42c15c8c861713d9449cc: workflow execution approval is resolved. CI 38607431825 and Build blog 38607432508 now succeed; no further Approve and run is needed for these runs. I inspected the build, typecheck and blog logs, testing merge a560084 of this head into main 8cf06818a614e85b292a96aa020ee442480994f9.

This resolves only the execution wait in review 5524228939. The Before/After evidence check still fails; the description's indented headings and requested actual preview/Windows/launcher-validation record remain unchanged. That review stays the reference, with no additional scope or repeated test request. CI results are separate from author-reported Linux checks; I have not run tests or a browser locally.

  - Add  script to package.json using Node.js built-in test runner
  - Expand  with coverage for environment/argument passing, non-zero exit code propagation, and invalid  path security checks
@rajarshikarmakarx

Copy link
Copy Markdown
Contributor Author

Hi, thanks for the detailed review!

I've completed the requested follow-ups:

  • Fixed the PR description's ## Before and ## After heading formatting.
  • Added blog/scripts/run-theme.test.mjs and the npm run test:launcher script.
  • Ran the launcher regression tests: 3 passed, 0 failed. These cover argument/environment handling, nonzero child exit-code propagation, and rejection of invalid cleanup paths before deletion or child-process launch, using temporary sentinel files.
  • Verified npm run dev:press starts Eleventy at http://localhost:8089/, enters watch mode, and shuts down with Ctrl+C.
  • Ran npm ci, both theme preview commands, and npm run build to validate installation, isolated preview outputs/base links, and the normal production build.

Environment: Fedora Linux 44, Node.js v24.21.0, npm 11.19.0.

Windows PowerShell/default npm shell validation has not been performed locally, so Windows execution remains unverified.

The changes remain scoped to this issue. Please let me know if a Windows-specific test run is required before approval.

Thanks!

@rajarshikarmakarx

Copy link
Copy Markdown
Contributor Author

Update: Windows validation completed.

In addition to my Fedora Linux testing, I ran the same validation on a Windows machine using Windows PowerShell, Node.js v24.18.0, and npm 11.16.0.

  • npm ci — passed.
  • npm run test:launcher — 3 passed, 0 failed.
  • npm run preview:sunroom — passed.
  • npm run preview:press — passed.
  • npm run build — passed.
  • npm run dev:press — started successfully on port 8089.

The Windows checkout path contained a space. I've updated the PR description with the environment details and validation results. The dependency installation also reported 12 npm audit findings (3 moderate, 9 high); no automatic audit fixes were applied.

@HafidIdrissi HafidIdrissi left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Reviewed the complete four-file patch at 81fbf26 and the revised Before/After and validation sections. I independently validated this revision on Windows build 26200, Node v24.21.0: npm ci --ignore-scripts completed; npm run test:launcher passed 3/3; both preview builds and the normal production build completed successfully. npm run dev:press served HTTP 200 on localhost:8089, entered watch mode and stopped via Ctrl+C; no listener remained. I also copied the exact launcher into an isolated fixture whose path contains spaces and used a synthetic Eleventy child to assert forwarded theme/preview/base/output variables, serve/port arguments, working directory, and preservation of child exit code 23. The repository's --help test alone does not prove environment forwarding; the independent fixture supplies that evidence. Cleanup remains confined to the two expected preview paths, and the invalid-path sentinel test passes. Existing Crewlo templates retain their current link/theme behavior; this review does not claim to redesign those templates. The author separately reports Windows and Fedora checks. Installation reports 12 existing audit findings; no dependency versions or lockfile are changed here. The new head's workflow runs required approval, which I have now supplied; final merge must await the current CI/build results. Vercel's separate authorization failure remains visible and has not been bypassed.

@HafidIdrissi
HafidIdrissi merged commit ab0e0a5 into HafidIdrissi:main Oct 16, 2026
8 of 9 checks passed
@rajarshikarmakarx

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough review and for independently validating the Windows behavior, especially the environment forwarding and exit-code handling. Appreciate the detailed feedback — learned a lot from this review!

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