-
Notifications
You must be signed in to change notification settings - Fork 494
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow passing a custom glob to find packages #654
Comments
After looking into the source code of the changeset github action I realize that the action needs some changes as well. It needs to accept a custom glob as well. But it is totally doable. |
Could you expand on that? What makes it difficult? If we could support Nx out-of-the-box that would be preferable.
Is this standard for Nx or is this your custom setup? In the past, I've suggested that one can temporarily apply changes to, let's say,
Could you expand on this one? I guess if we get to it I would see what do you mean in the PR but if you already know what would have to be changed I could take a look sooner at the plan you have for those changes. |
Thanks for the quick feedback @Andarist! We do use a standard nx setup. Nx has a concept of generators to generate new "projects". And you can generate "publishable" projects. That means that when "building" that project nx will pack everything up in a tidy package that can be published to a npm registry. But it will put it in the I've actually written a minimal wrapper script around changesets that sets The reason I decided not to push this to I tidied up my fork and pushed a proposal to https://github.com/adambrgmn/changesets/tree/adambrgmn/packages-glob. If you feel it's easier I would happily provide a PR instead. Another approach I though about was making a specific solution for nx repos which included looking into the Then, a third option which I thought of was adding new configuration options to {
// Either as an array which applies to all commands
"packages": ["libs/*"]
// or as an object which would make it possible to configure on a per command basis
"packages": {
"default": ["libs/*"],
"publish": ["dist/libs/*"],
}
} The github action uses |
We could extend somehow manypkg - obviously, it would have to become aware of this distinction and it would either expose a single object with 2 properties (like source and publish) where they both would be the same for other tools or it would expose an additional function that one could choose to select "publishable" packages. This would require the user to select the appropriate function - which is probably not that great. If this is the standard Nx setup - having sources and packed packages in completely separate directories then I think it's worth adding support for smth like this into both manypkg and Changesets. cc @mitchellhamilton , wdyt? |
I'm trying to think of ways that manypkg could support this with an as simple api as possible. But it is hard since there are so many ways in which you can configure nx. You could set up some restrictions though. The project needs to be tagged with e.g. It is hard 😅 And the more I think about it maybe this edge case shouldn't be a concern for neither |
Another idea that I just got would be if we could expose a new config option in {
"getPacakges": "../path/to/custom/package-resolver.js"
} That file could export a We could then create a new package called something like It's an idea but would require some changes to the architecture since |
Could you at least showcase 2 so I could assess how different they are etc and what is involved in each one of those? |
I might have been a bit misleading in my comment. There aren't that many ways to configure NX libraries that are relevant to this discussion. You have the source code living in As of now we only have one package, which we can handle with manual releases. But I see value in being able to use I built a POC a few weeks back (https://github.com/adambrgmn/changesets/tree/adambrgmn/get-packages). It needs some tweaking and should probably use built-in NX logic instead of my naive approach. The way you would use it is like this:
{
"getPackages": "@changesets/get-packages/nx"
} |
I'm encountering a similar issue, albeit with Angular rather than Nx, and something like the proposed In my case I have a monorepo containing various packages for a design system. Today I was adding an Angular library for the first time (all the other existing stuff is non-Angular, btw). I created it using their
As per Angular's docs, to publish your package you're supposed to do something like:
All well and good when you're manually doing that. But I'm using changesets and want it to update versions in my |
Affected Packages
@changesets/cli
Problem
I'm trying to advocate at work to use
changesets
as a tool to automate the release of packages that we have. Today the release process is very manual and cumbersome. But I have an issue – we work in a monorepo but we don't follow the setup of eitheryarn
,lerna
,pnpm
orbolt
. Instead we usenx
. It is a rather special setup, I realize that. But a tweak to thechangesets
cli would enable us to actually use it.The thing with
nx
is that we have a singlepackage.json
in the root with all dependencies. Then we have placeholderpackage.json
's in the libraries that we want to publish, with only metadata such as name and version. And when packaging the packages into publishable versions they end up in adist
-folder, with apackage.json
and everything.That means we would like to run
add
andversion
agains one set of packages. And thenpublish
against what's indist
.This doesn't work with
changesets
for two reasons:@manypkg/get-packages
can't determine that we use an nx repo setup and aren't able to find our packageslibs/package-a
->dist/libs/package-a
Proposed solution
First I thought of making a PR against
@manypkg/get-packages
. But I realize that nx-repos function very differently than others which means it is not suitable for that project.I have a working solution locally. The proposed solution is to be able to pass a
--packages=<glob>
flag to theadd
,version
,publish
andstatus
cli commands.Then the workflow for an nx monorepo would be something like this:
yarn changeset --packages="libs/*"
yarn changeset version
will check for the source libs so that the changelog and everything ends up where it shouldyarn build
packages the module into the dist folder, with distributable files and a package.json and everythingyarn changeset publish
will publish the packages in the dist folderAs I said I have a rough solution locally and I would be happy to polish it and supply a PR if this is a feature that you are interested in.
The text was updated successfully, but these errors were encountered: