unjs / pkg-types

Node.js utilities and TypeScript definitions for package.json and tsconfig.json
Other
248 stars 16 forks source link

workspace (monorepo) utils #117

Open pi0 opened 1 year ago

pi0 commented 1 year ago

Supporting monorepo and workspace detection

Common sources:

Common workspace managers:

Reolve workspace

We already have findworkspaceDir but it is not strict enough to make distinguish between a monorepo and just the closest root dir of a project.

We could introduce a new resolveWorkspace utility that only detects an explicit monorepo workspace with the detected field in package.json or pnpm workspaces lock returning a workspaces config object (array of objects for forward compatibility.

Resolve workspace packages

Another utility like resolveWorkspacePkgs can be introduced to accepd resolved workspace config (from resolveWorkspace or a string to do this) and read all of its packages.

Resolve workspace packages graph

Get array of workspace packages, returning an (ordered and sorted) graph of devDependency and dependency between monorepo packages.

(PR more than welcome 🙏🏼 )

aa900031 commented 1 year ago

@pi0 I don't think it's necessary to include Turbo, because Turbo isn't an independent workspace manager.The document mentions that you need to configure npm, yarn, or pnpm workspaces yourself.