v3.0.1
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 toresolve-from-caller.mjs;#isSlothletInternal()basename check now only fires when the file's parent directory equalsSLOTHLET_PKG_ROOTbuildTestNodeEnv()token loop: splits eachNODE_OPTIONStoken on=, inspects value component for comma-delimited conditions, reconstructs token withoutslothlet-dev; handles both--conditions=a,band--conditions aformsrun-all-tests.mjscontrol flow inversion:ensureDevEnvFlags()returnstruewhen the environment is already correct,falsewhen a respawn was initiated;runAllTests()only called whentruebuild-dist.mjsusesexistsSyncguard beforefs.cpSync, exits0with a console warning whensrc/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