Skip to content

fix(cli): honor PORT, ignore *.log in dev watch, help without side effects - #156

Open
lipowen wants to merge 1 commit into
junebuild:mainfrom
lipowen:fix/cli-dev-friction
Open

fix(cli): honor PORT, ignore *.log in dev watch, help without side effects#156
lipowen wants to merge 1 commit into
junebuild:mainfrom
lipowen:fix/cli-dev-friction

Conversation

@lipowen

@lipowen lipowen commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Three first-run june dev friction points, each hit while building a real app on June and each a few lines to fix.

Fixes

  • PORT is honored. Port precedence is now --port > PORT env > 3000. PORT=4100 june dev was silently ignored (it started on 3000 and walked forward). A shared coercePort also fixes a pre-existing footgun where --port with no value bound port 1 (Number(true) === 1), and rejects junk (PORT=abc, PORT=, out-of-range) with a clean fallback.
  • *.log no longer restarts the dev watcher. A log written into the project tree (e.g. dev.log in CI) matched no ignore rule and looped [june] … changed — restarting forever. A .log is app output, never a source edit — ignored everywhere, alongside the existing .css rule in ignoredPath.
  • --help after a verb prints help instead of running the command. june dev --help started the dev server (and hung); june build --help built. The parser attaches --help to the verb as a flag, so the switch's verb-position help case never caught it. A single guard at the top of run() now prints usage for --help in any position, with no side effect. (june --help / june help still route through the existing switch case — no regression.)

Notes

  • coercePort is exported for unit tests, matching the existing parse export in the same file.
  • PORT is read in the CLI/host layer, not june.configJuneConfig has no port field; the dev port is a runtime concern, not app config.
  • -h after a verb is still unsupported (the minimal parser only recognizes ---prefixed flags); out of scope here, unchanged behavior.

Tests

  • coercePort precedence + boundary matrix (65535 valid, 65536 rejected, boolean/NaN/empty/out-of-range fall back).
  • ignoredPath("dev.log") and app/logs/server.log ignored.
  • run(["dev","--help"]) / run(["build","--help"]) return 0 without starting/building.

Changeset: @junejs/cli patch.

…fects

- june dev port precedence is now --port > PORT env > 3000; a shared coercePort
  also stops --port with no value binding port 1 and rejects junk values.
- *.log files no longer trigger the dev watcher (a dev.log written into the tree
  looped restarts forever).
- --help in any position prints usage instead of running the command (june dev
  --help started the server; june build --help built).

Copilot AI 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.

Pull request overview

Improves june dev startup behavior and prevents unwanted command side effects.

Changes:

  • Honors CLI and environment port configuration.
  • Ignores log files in the development watcher.
  • Handles post-command --help without executing commands.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
.changeset/cli-dev-friction.md Documents the CLI fixes.
packages/cli/src/cli.ts Adds port coercion and help interception.
packages/cli/src/watch.ts Excludes log files from watching.
packages/cli/test/cli.test.ts Tests ports and help behavior.
packages/cli/test/watch.test.ts Tests log-file exclusions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/cli/src/cli.ts
export function coercePort(value: unknown, fallback: number): number {
if (typeof value === "boolean") return fallback;
const n = Number(value);
return Number.isInteger(n) && n > 0 && n < 65536 ? n : fallback;
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