How edumudu/loctry works
Project Type and Purpose
• This is a Node.js monorepo (managed by Turborepo) that contains a single package: a CLI tool named “loctry.”
• Purpose: streamline local library testing by generating an “npm pack” tarball identical to what you’d publish, then installing that tarball into a local project to verify correct setup.
Top-Level Structure and Key Directories
• Root
• turbo.json – Turborepo config for task orchestration
• .github/workflows/publish.yml – CI/CD pipeline for package publishing
• .husky/* and commitlint.config.js – Git hooks and commit‐message validation
• packages/cli
• bin/index.mjs – CLI entry point (invoked via npx loctry)
• commands/*.mjs – individual command modules (info, install, list, publish, unpublish)
• utils/*.mjs – shared helpers (resolving workdir, pkg.json, file paths)
• config/*.mjs – static settings (agent definitions, path specs)
• package.json – CLI’s manifest and dependency list
Main Components
• Actor: Developer (CLI user)
• Component: loctry CLI
• Bin Loader
• Command Registry (info, install, list, publish, unpublish)
• Utility Layer (file resolution, pkg manifest parsing)
• Config Layer (agents, path rules)
• Subsystems & External Interfaces
• Node.js Runtime (spawn child processes)
• Local File System (read/write package.json, create/read tarball)
• Child Process “npm pack” (generates .tgz)
• Child Process “npm install <tarball>” (injects tarball into target project)
• NPM Registry (HTTP API for publish, unpublish, version listing)
• DevOps Pipeline
• Git Hooks (pre-commit, commit-msg)
• GitHub Actions (CI run, build, test, publish)
Relationships & Data Flow
• Developer → invokes loctry on CLI
• Bin Loader → resolves the requested command module
• Command → uses Utils to locate target workdir & pkg.json
• Command → spawns npm pack → produces tarball → stored on local FS
• Install/List/Info commands → read from tarball or registry via HTTP
• Publish/Unpublish commands → HTTP calls to NPM registry
• All commands report results back to the Developer on stdout
Architectural Patterns & Principles
• Modular Command Pattern: each command in its own file, registered in an index
• Separation of Concerns: bin (bootstrap), commands (business logic), utils (IO + path logic), config (static constants)
• Monorepo with Turborepo: atomic package management, caching, and parallel task execution
• GitOps & CI/CD: commit linting, pre-commit hooks, GitHub Actions publishing flow