Skip to content

enterPre() always creates pre.json at the top level of a monorepo #1824

@BryceLTaylor

Description

@BryceLTaylor

We only use changsets in one package (called core) in our monorepo. When I run npx changesets pre enter testingtesting from that package it creates a pre.json in a folder at the top level of the repository, even though my changeset md files are in the .changeset folder in core and where pre.json is. We recently changed to a monoreop architecture and everything worked fine before.

However, if I exit pre mode with npx changsets pre exit from that package it will change the pre.json in core.

setting preStatePath

Looking through the code, it seems to be because in enterPre you set your preStatePath like this:

 let packages = await getPackages(cwd);
 let preStatePath = path.resolve(packages.root.dir, ".changeset", "pre.json");

However in exitPre you set preStatePath like this:

let preStatePath = path.resolve(cwd, ".changeset", "pre.json");

Which results in a very different file path to the pre.json

get packages

getPackages always finds the root of the monorepo because of the way it calls getPackage from @manypkg/get-packages so I will never be able to enter pre mode in the core package.

enterPre() calls getPackages() from @manypkg/get-packages which says it

Given a starting folder, search that folder and its parents until a supported monorepo
is found, and return the collection of packages and a corresponding monorepo Tool
object.

Tat is because it calls findRoot() which:

Given a starting folder, search that folder and its parents until a supported monorepo
is found, and return a MonorepoRoot

It's possible I'm missing something and there is an easy fix, but I need to be able to enter pre mode in just one of my packages.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions