Skip to content

v3.0.1

Choose a tag to compare

@cldmv-bot cldmv-bot released this 30 Mar 23:46
· 19 commits to master since this release
v3.0.1
35d52f2

release: v3.0.1 (#75)

release: v3.0.1 (#75)

Release: v3.0.1 β€” Patch: Resolver Fix, CI Hardening, and Resilient Build Pipeline

πŸ› BUG FIX β€” RESOLVE-FROM-CALLER: CALLER index.mjs NO LONGER TREATED AS INTERNAL
β€’ Fix #isSlothletInternal() incorrectly treating any file named index.mjs or index.cjs as an internal Slothlet frame, regardless of location
β€’ Root cause: bare path.basename() check had no location guard β€” a user entry point named index.mjs matched the same condition as the package root index.mjs
β€’ Fix: add SLOTHLET_PKG_ROOT constant (__dirname + ../../..) and scope the basename check to only match files whose parent directory equals the package root
β€’ Add regression fixture tests/vitests/suites/helpers/fixtures/index.mjs and two new tests to resolve-from-caller-paths.test.vitest.mjs covering both the correct resolution target and the directory name
β€’ All 21 resolve-from-caller tests pass

πŸ”§ CI HARDENING β€” SLOTHLET-DEV CONDITION STRIPPING
β€’ Fix buildTestNodeEnv() in test-conditional.mjs using exact token equality (token !== "--conditions=slothlet-dev") to strip the custom export condition from NODE_OPTIONS
β€’ Exact match silently failed for compound conditions (--conditions=slothlet-dev,other) and space-separated form (--conditions slothlet-dev), leaving slothlet-dev active in the post-build node test environment and causing Cannot find module '.../src/slothlet.mjs' errors after ci:cleanup-src
β€’ Fix: replace with a full token-aware parser that handles both --conditions=VALUE and --conditions VALUE forms, stripping any comma-delimited component equal to slothlet-dev
β€’ Fix: replace || undefined fallback (serialized as the string "undefined" by Node 16's child_process.spawn) with delete env.NODE_OPTIONS

πŸ”§ CI HARDENING β€” RUN-ALL-TESTS RESPAWN RACE CONDITION
β€’ Fix run-all-tests.mjs calling if (ensureDevEnvFlags()) process.exit() to handle the respawn-with-slothlet-dev case β€” the parent exited immediately before the child finished, silently discarding the child's real exit code and masking test failures
β€’ Fix: restructure to if (!ensureDevEnvFlags()) { runAllTests(); } β€” parent stays alive, stdio streams directly to terminal, child.on("exit", code => process.exit(code)) propagates the real exit code

πŸ› οΈ BUILD PIPELINE β€” RESILIENT DIST COPY
β€’ Fix build:dist crashing with cp: no such file or directory: src/* when ci:cleanup-src had already run β€” raw shx cp -r src/* dist/ errors out if src/ is absent
β€’ New tools/build/build-dist.mjs: uses fs.cpSync (Node 16.7+), exits cleanly with a warning when src/ is not found rather than crashing the build pipeline
β€’ package.json build:dist script updated to node tools/build/build-dist.mjs

Technical Implementation:

  • SLOTHLET_PKG_ROOT = path.normalize(path.resolve(__dirname, "../../..")) added to resolve-from-caller.mjs; #isSlothletInternal() basename check now only fires when the file's parent directory equals SLOTHLET_PKG_ROOT
  • buildTestNodeEnv() token loop: splits each NODE_OPTIONS token on =, inspects value component for comma-delimited conditions, reconstructs token without slothlet-dev; handles both --conditions=a,b and --conditions a forms
  • run-all-tests.mjs control flow inversion: ensureDevEnvFlags() returns true when the environment is already correct, false when a respawn was initiated; runAllTests() only called when true
  • build-dist.mjs uses existsSync guard before fs.cpSync, exits 0 with a console warning when src/ is absent

Testing Coverage:
Two new regression tests cover the resolve-from-caller fix directly: one asserts the resolved path equals the fixture's own directory (not process.cwd()), the second asserts the path contains "fixtures". Full suite of 21 tests passes. CI hardening changes verified against existing matrix test runs.

Files Changed: 10 files β€” 240 insertions, 30 deletions

package-lock.json                                                      |  4 +-
package.json                                                           | 12 +--
src/lib/helpers/resolve-from-caller.mjs                                | 19 ++-
tests/run-all-tests.mjs                                                | 15 ++-
tests/test-conditional.mjs                                             | 54 +++-
tests/vitests/suites/helpers/fixtures/index.mjs                        | 55 +++ (new)
tests/vitests/suites/helpers/resolve-from-caller-paths.test.vitest.mjs | 36 +++ (new)
tools/build/build-dist.mjs                                             | 72 +++ (new)
types/src/lib/helpers/resolve-from-caller.d.mts.map                    |  2 +-

Full Changelog: v3.0.0...v3.0.1

πŸ‘₯ Contributors