guigrpa / oao

A Yarn-based, opinionated monorepo management tool

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Updating dependencies to match master version

jozanza opened this issue · comments

I'm wondering if it's useful for users of this library to have their package.json version as well as any subpackage dependency versions updated to the master version either in an explicitly invoked command or during the publish command.

I'm currently doing this in a fork, and it looks like this:

for (const pkgA of pkgNames) {
  const { specPath: specPathA, specs: specsA } = allSpecs[pkgA];
  mainStory.info(`Updating`, `${pkgA} ${specsA.version} -> ${nextVersion}`)
  specsA.version = nextVersion;
  if (!specsA.dependencies || specsA.private) continue
  for (const pkgB of pkgNames) {
    const { specPath: specPathB, specs: specsB } = allSpecs[pkgA];
    if (specsA.dependencies[pkgB]) {
      specsA.dependencies[pkgB] = nextVersion
    }
  }
  writeSpecs(specPathA, specsA);
}

The rationale is that it's pretty easy to publish versions of your subpackages that work locally, but are broken when installed outside of the monorepo via yarn/npm because the dependencies specify non-published versions of subpackages.

Use case: In my monorepo, I have all subpackage dependencies set to version 0.0.0. Only the root package.json tracks the master version. I want to avoid publishing packages that specify dependencies with version 0.0.0. So on publish, I want to briefly update subpackage versions and their dependency versions, then revert them back to 0.0.0 after publish.

Of course, my use case my be weird. Or maybe there's a better/recommended way of managing this? In any case, I'd love to have your input on this @guigrpa.

I'm not sure I get your point. The typical way of using oao would be to have the master version in the root package (as you also do) and subpackages more or less aligned to it. For example, if you release version 2.3.1 of several subpackages, those would be at 2.3.1, the root would be at 2.3.1, and other subpackages may be left behind, e.g. 2.3.0.

This structure is used for example in the storyboard monorepo. Subpackage dependencies are specified via ranges, e.g. storyboard-preset-console@3.1.1 depends on storyboard-listener-console@^3.1.1.

Closed due to lack of activity; please reopen if needed.