Skip to content

clibuddy: treat pnpm-workspace.yaml as a workspace only when it declares packages #249

Closed

Description

@rqbazan

Problem

Pkg.isMonorepo() in shared/clibuddy/src/pkg.ts returns true whenever a pnpm-workspace.yaml file exists:

isMonorepo() {
  return !!this.#packageJson.workspaces || this.#hasPnpmWorkspace();
}

Since pnpm 10, pnpm-workspace.yaml is also where single-package repos put pnpm settings such as minimumReleaseAge, minimumReleaseAgeExclude, onlyBuiltDependencies or catalog. Such a file has no packages key, and it does not make the repo a monorepo.

When a single-package repo adds one:

  • rr tsc (run-run/cli/src/actions/tsc.ts) and workspace-target.ts take the monorepo path. getWorkspaceProjects() then reads manifest.packages (undefined) and throws Invalid workspace patterns. That breaks rr check and any pre-commit hook that runs it.
  • With packages: ["."] the repo root is filtered out by excludeRoot, so the typecheck runs on nothing and passes silently.

Impact

withvariablelab/theme-toggle (single package, @rrlab/cli ^1.3.0) cannot put minimumReleaseAge: 1440 and minimumReleaseAgeExclude: ["@variablelab/*", "@rrlab/*"] in pnpm-workspace.yaml. It uses .npmrc instead (withvariablelab/theme-toggle#8). That has two costs:

  • The exclude list can't be used in .npmrc. When pnpm is launched through npm (npx pnpm, npm exec, npm run), npm exports the array as one npm_config_minimum_release_age_exclude="@variablelab/*\n\n@rrlab/*" string, and pnpm 10.30.3 then exempts every package. As a result, theme-toggle's own scopes also wait 24 h.
  • Every npm command warns Unknown project config "minimum-release-age", and pnpm 11 stops reading these settings from .npmrc.

Proposed fix

Treat pnpm-workspace.yaml as a workspace only when it declares a non-empty packages array, and treat getWorkspaceProjects() the same way. Add a test for a settings-only pnpm-workspace.yaml (for example, only minimumReleaseAge) and check that rr tsc typechecks the root package.

Follow-up once released

In theme-toggle:

  • Move minimum-release-age and the excludes from .npmrc to pnpm-workspace.yaml.
  • Delete .npmrc.
  • Then publish_mode: oidc-only in release.yml can go back to auto-detection, because preview-release core.ts treats any project .npmrc as token-only. Keeping it explicit also works.

🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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