Skip to content

fix(devcheck): condition-only trigger + execArgv detection + scoped-install guard - #10

Merged
Shinrai merged 6 commits into
nextfrom
fix/devcheck-condition-detection
Aug 9, 2026
Merged

fix(devcheck): condition-only trigger + execArgv detection + scoped-install guard#10
Shinrai merged 6 commits into
nextfrom
fix/devcheck-condition-detection

Conversation

@cldmv-bot

@cldmv-bot cldmv-bot Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

🚀 What's Changed

💥 Breaking Changes

No breaking changes

✨ Features

No new features

🐛 Bug Fixes

📦 Dependencies

No dependency updates

🔧 Other Changes

👥 Contributors

…nstall guard

Backports the corrected devcheck from @cldmv/holdmytask (CLDMV/holdmytask#12);
addresses the bugs filed in #9. The `uuid-dev` namespacing was already correct;
the check logic around it was not.

- Trigger is now condition-only. Only `--conditions=uuid-dev` selects src/ (via
  the ./main export); NODE_ENV does not affect resolution, so the old
  `!nodeEnv || (!["","development"].includes(nodeEnv) && !hasUUIDDev)` was wrong
  both ways: NODE_ENV=development without the condition stayed silent while
  actually on dist/ (false negative), and the condition set without NODE_ENV
  nagged though correctly on src/ (false positive).
- Detect the condition in process.execArgv as well as NODE_OPTIONS. `node
  --conditions=uuid-dev file.mjs` puts it in execArgv, and that's how vitest
  passes it to workers (worker NODE_OPTIONS is undefined; execArgv carries the
  flag) - so the NODE_OPTIONS-only check missed the CLI/worker form.
- Skip when installed as a dependency, detecting a `node_modules` segment
  anywhere above the file so it works for the scoped `node_modules/@cldmv/uuid`
  layout (a "parent === node_modules" check would miss it). Guards against a
  git/tarball install exiting inside a consumer's app.
- Fix the copy-paste `@Project: @cldmv/slothlet` header to `@cldmv/uuid`.
- Add tests/DevCheck.test.vitest.mjs (9 cases): nags without the condition;
  silent with it via NODE_OPTIONS and via execArgv; NODE_ENV=development alone
  does not silence; still nags after a dist/ build; generic development
  condition rejected; skips in CI; skips when installed as a scoped dep; does
  nothing with no src/.

The nag remains intentional whenever src/ is present and the condition is unset
(even after a build): a source checkout should run from src/ via the condition,
so flagging that you're silently on dist/ is the point.
@cldmv-bot cldmv-bot Bot added ! fix → next v4 flow: fix contributor PR targeting the next integration branch area: tests Touches test files, fixtures, or test infrastructure labels Aug 8, 2026
@Shinrai

Shinrai commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Resolves #9 — closed when this ships to the default branch.

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

This PR refines the devcheck.mjs “source-checkout guard” so it only triggers when the uuid-dev condition is missing (including when passed via process.execArgv), and adds a Vitest suite to validate behavior across common execution contexts (CI, NODE_OPTIONS, execArgv, installed under node_modules/).

Changes:

  • Update devcheck.mjs to: (1) ignore NODE_ENV, (2) detect uuid-dev via both NODE_OPTIONS and process.execArgv, and (3) skip when running from an installed package path containing node_modules.
  • Add tests/DevCheck.test.vitest.mjs to run devcheck.mjs in isolated fixture directories and assert expected exit codes/output.

Reviewed changes

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

File Description
devcheck.mjs Switches devcheck gating to condition-based detection (NODE_OPTIONS + execArgv) and skips execution when run from installed dependency paths.
tests/DevCheck.test.vitest.mjs Adds an isolated subprocess-based test suite covering the new devcheck triggering/skipping rules.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread devcheck.mjs Outdated
Shinrai added a commit to CLDMV/holdmytask that referenced this pull request Aug 8, 2026
…odule in ssr conditions

Addresses PR #12 Copilot review:

- devcheck.mjs: parse the actual `--conditions` values (from execArgv and
  NODE_OPTIONS, handling `=`/space/`-C`/comma forms) and match `holdmytask-dev`
  EXACTLY, instead of a substring `.includes()` that would false-positive on
  e.g. `--conditions=not-holdmytask-dev`. (Same fix as CLDMV/uuid#10.) Added
  regression tests: rejects a substring-containing condition; accepts
  holdmytask-dev among comma-separated conditions.
- .configs/vitest.config.mjs: removed the `test.env.NODE_ENV=holdmytask-dev`
  override - it doesn't select the conditional export (that's `--conditions`,
  carried via nodeOptions) and forcing a non-standard NODE_ENV can confuse deps
  keying off test/development/production. Added `module` to ssr.resolve.conditions
  so a dependency's `module`-keyed export resolves the same under Vitest's SSR
  pipeline as in the non-SSR resolver.
Shinrai added 2 commits August 8, 2026 09:54
Addresses PR #10 Copilot review: `flags.includes("uuid-dev")` would
false-positive on any flag value containing that substring (e.g.
`--conditions=not-uuid-dev`), spuriously silencing devcheck. Parse the actual
`--conditions` values from execArgv and NODE_OPTIONS (handling `=`/space/`-C`/
comma forms) and match `uuid-dev` exactly. Added regression tests: rejects a
substring-containing condition; accepts uuid-dev among comma-separated
conditions.
The `./devcheck` -> `./devcheck.mjs` export pointed at a file not in the
published `files` allowlist (verified via npm pack: devcheck.mjs isn't in the
tarball), so `import "@cldmv/uuid/devcheck"` 404s for consumers. devcheck is an
internal dev-time guard that index.mjs loads via a relative import, not the
package export - nothing imports the subpath. Removing the dead export makes
package.json honest. Same cleanup as CLDMV/holdmytask.
@cldmv-bot cldmv-bot Bot added the type: dependencies Relates to dependency updates, version bumps, or package management label Aug 8, 2026
@Shinrai
Shinrai requested a lite review from Copilot August 8, 2026 18:55

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

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

Suppressed comments (3)

devcheck.mjs:2

  • The file header’s @Project value was changed to @cldmv/uuid, but the rest of the repository headers (and the tools/fix-headers.mjs config) still use @cldmv/slothlet. This makes devcheck.mjs inconsistent with the established header convention and likely to get rewritten by the header-fixing tooling. Either migrate headers/tooling repo-wide in a dedicated change, or keep this file consistent for now.
 *	@Project: @cldmv/uuid

devcheck.mjs:62

  • --conditions values are comma-separated by Node. Splitting on | here can create false positives (e.g. --conditions=foo|uuid-dev would be treated as enabling uuid-dev by devcheck, but Node would treat foo|uuid-dev as a single condition value). This can incorrectly silence the devcheck warning.
	const collect = (value) => {
		if (value) for (const c of value.split(/[,|]/)) if (c.trim()) conditions.push(c.trim());
	};

tests/DevCheck.test.vitest.mjs:3

  • All other test files under tests/ include the standard project/file header block, but this new test file does not. If header checks (or the npm run fix:headers tooling) are part of the repo workflow, this file will be an outlier and may fail validation or get rewritten later.
import { test, expect, describe, beforeAll, afterAll } from "vitest";
import { spawnSync } from "node:child_process";
import { mkdtempSync, mkdirSync, copyFileSync, rmSync } from "node:fs";

…r; add test header

Addresses the second Copilot re-review on PR #10 (3 suppressed comments):

- devcheck.mjs: stop splitting condition values on `,`/`|`. Node treats each
  `--conditions` occurrence as ONE literal condition and does not split on comma
  or pipe (verified: `--conditions=uuid-dev,x` and `--conditions=uuid-dev|production`
  do NOT enable uuid-dev). The old split caused a false negative - e.g.
  `uuid-dev|production` would silence devcheck while Node actually resolved to
  dist/. Now collect each value whole and match exactly. Fixed the test that
  wrongly asserted comma-joined silences (now asserts it nags), added pipe-joined
  nag, space-separated (`--conditions uuid-dev`) and repeated-flag silent cases.
- devcheck.mjs: reverted the `@Project` header to `@cldmv/slothlet` to match the
  rest of the repo and tools/fix-headers.mjs (`projectName: @cldmv/slothlet`);
  a single-file change to `@cldmv/uuid` is an outlier that fix:headers would
  revert. The repo-wide @project correction (config + restamp of all files) is a
  separate, dedicated change.
- tests/DevCheck.test.vitest.mjs: added the standard project header block so it
  isn't an outlier vs the other test files.
@Shinrai

Shinrai commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Addressing the 3 suppressed comments from the latest review — fixed in 6b5a670:

  • devcheck.mjs:62 — splitting condition values on ,/|. Real false-negative: I verified Node treats each --conditions occurrence as one literal condition and does not split on comma or pipe (--conditions=uuid-dev|production resolves to dist/), so the split would have silenced devcheck while the developer was on dist/. Removed the splitting — collect each value whole, match exactly. Updated tests: comma-joined and pipe-joined now assert nag; added space-separated and repeated-flag silent cases.
  • devcheck.mjs:2@Project header inconsistency. Reverted to @cldmv/slothlet to match the rest of the repo and tools/fix-headers.mjs (projectName: "@cldmv/slothlet") — a single-file change to @cldmv/uuid is an outlier that fix:headers would revert. The correct fix is repo-wide (flip the tooling projectName + restamp all files); that's a noisy, dedicated change (~47 files, timestamp churn), not something to fold into this devcheck PR. Happy to do it as a separate PR.
  • tests/DevCheck.test.vitest.mjs:3 — missing header block. Added the standard project header block.

…wide

The header @project across the repo was a copy-paste leftover from the slothlet
template, and tools/fix-headers.mjs was hardcoded to projectName
"@cldmv/slothlet" so `npm run fix:headers` kept re-stamping it. Set projectName
to "@cldmv/uuid" and ran fix:headers, correcting @project on all files (and
re-stamping @Last-modified). This also makes devcheck.mjs's header consistent
rather than an outlier (the earlier single-file change was reverted for exactly
that reason). Folded into this PR per maintainer request.
@cldmv-bot cldmv-bot Bot added the area: core Touches core library / runtime source code label Aug 9, 2026
@Shinrai
Shinrai requested a lite review from Copilot August 9, 2026 00:16

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

Copilot reviewed 48 out of 48 changed files in this pull request and generated no new comments.

Suppressed comments (1)

.configs/tsconfig.dts.jsonc:16

  • This file now contains two consecutive header blocks (the newly added /** ... / header and the pre-existing / ... */ header). Keeping both is redundant and can confuse tooling that expects a single canonical header at the top of each file.
 */

/*
 * @Project: @cldmv/uuid
 * @Filename: /.configs/tsconfig.dts.jsonc

The repo-wide fix:headers run added a second header block to
.configs/tsconfig.dts.jsonc: the file's pre-existing header used a legacy
single-star `/* ... */` block, which @cldmv/fix-headers does not recognize as
its managed header (it manages the JSDoc `/** ... */` form), so it added a new
`/** */` block on top instead of updating in place. Removed the legacy `/* */`
block, leaving a single recognized `/** */` header. Verified fix:headers is now
idempotent on the file (dry-run reports 0 updates). Addresses the suppressed
Copilot comment on PR #10.
@Shinrai

Shinrai commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Addressing the suppressed comment from the latest review (.configs/tsconfig.dts.jsonc:16 — two consecutive header blocks):

Fixed in 5805b4c. Root cause: that file's pre-existing header was a legacy single-star /* ... */ block, which @cldmv/fix-headers doesn't recognize as its managed header (it manages the JSDoc /** ... */ form) — so the repo-wide run added a /** */ block on top instead of updating in place. Removed the legacy /* */ block, leaving a single recognized /** */ header, and verified fix:headers --dry-run now reports 0 updates (idempotent).

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

Copilot reviewed 48 out of 48 changed files in this pull request and generated no new comments.

@Shinrai
Shinrai merged commit 7f2f29c into next Aug 9, 2026
23 checks passed
@cldmv-bot
cldmv-bot Bot deleted the fix/devcheck-condition-detection branch August 9, 2026 03:11
@Shinrai

Shinrai commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Heads up — pushed 0140802 to sync the devcheck scanner fix from CLDMV/holdmytask#12 into this PR (the scanner here was identical). Two changes: advance the loop index past a consumed --conditions/-C value token (so a flag-like value isn't double-processed), and drop the unreachable -C= branch (Node rejects -C=value outright). Added -C short-flag test coverage. Full suite green (280).

Copilot's latest review here didn't flag these — they were only surfaced on #12 — but since it's the same code I fixed it here too rather than leave the two repos divergent. Note this new commit likely dismisses the prior approval; a re-approve may be needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: core Touches core library / runtime source code area: tests Touches test files, fixtures, or test infrastructure ! fix → next v4 flow: fix contributor PR targeting the next integration branch type: dependencies Relates to dependency updates, version bumps, or package management

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants