CodeVetter · Repo Unpack · Behavior traces
lerna/lerna
Source inspection followed startup, task execution, and version persistence through their concrete functions and branches. Publishing was also traced from selection through archive upload and cleanup. These are execution-order descriptions inferred directly from source, not observed runtime traces. Early returns and configuration switches materially change the work performed.
- Startup: cli.ts → importLocal or main(argv) → lernaCLI() → explicit command registration → cli.parse(argv, context); strict parser failures reach cli.exit with a positive error code or 1.
- Shared command startup: constructor → new Project → configureEnvironment → configureOptions → configureProperties → logger → conditional runValidations → detectProjects or reuse preinitialized graph data → runPreparations → runCommand; initialize=false prevents execute.
- lerna run: handler → factory → RunCommand.initialize → filterProjects → target-presence filtering → execute; missing scripts raise ENOSCRIPT, while zero matching targets return false with a success message.
- Default task execution: execute → runScriptsUsingNx → configureNxOutput → prepNxOptions → runOne for one project/one target, otherwise runMany; custom Nx configuration changes dependency and parallel/sort behavior.
- Version selection: initialize validates Git state when required, collects updates, filters private/unversioned packages, checks the working tree when enabled, then calls getVersionsForUpdates → setUpdatesForVersions → confirmVersions.
- Version persistence: updatePackageVersions runs root preversion unless rooted-leaf, then per-package preversion → refresh → version/dependency writes → version hook → optional changelog; afterward it updates fixed-mode configuration and root lockfiles.
- Version completion: execute awaits updatePackageVersions, optional commitAndTagUpdates, optional gitPushToRemote, then optional createRelease; commitAndTagUpdates chooses fixed/independent tags and runs postversion hooks.
- Publishing: initialize selects tagged/unpublished/canary updates or invokes version; execute prepares registry/licenses/private state → rewrites dependency links → serializes → packUpdated → publishPacked → restores private flags → serializes → optional resetChanges/dist-tag promotion.