diff --git a/.changeset/fix-workspace-package-discovery.md b/.changeset/fix-workspace-package-discovery.md new file mode 100644 index 0000000000..137f4e6311 --- /dev/null +++ b/.changeset/fix-workspace-package-discovery.md @@ -0,0 +1,6 @@ +--- +"@pnpm/config": patch +"pnpm": patch +--- + +Fix a regression where `pnpm-workspace.yaml` without a `packages` field caused all directories to be treated as workspace projects. This broke projects that use `pnpm-workspace.yaml` only for settings (e.g. `minimumReleaseAge`) without defining workspace packages [#10909](https://github.com/pnpm/pnpm/issues/10909). diff --git a/config/config/src/index.ts b/config/config/src/index.ts index 2a04b793c6..12649a22ee 100644 --- a/config/config/src/index.ts +++ b/config/config/src/index.ts @@ -367,7 +367,7 @@ export async function getConfig (opts: { if (pnpmConfig.workspaceDir != null) { const workspaceManifest = await readWorkspaceManifest(pnpmConfig.workspaceDir) - pnpmConfig.workspacePackagePatterns = cliOptions['workspace-packages'] as string[] ?? workspaceManifest?.packages + pnpmConfig.workspacePackagePatterns = cliOptions['workspace-packages'] as string[] ?? workspaceManifest?.packages ?? ['.'] if (workspaceManifest) { const newSettings = Object.assign(getOptionsFromPnpmSettings(pnpmConfig.workspaceDir, workspaceManifest, pnpmConfig.rootProjectManifest), configFromCliOpts) for (const [key, value] of Object.entries(newSettings)) { diff --git a/config/config/test/fixtures/workspace-yaml-without-packages/pnpm-workspace.yaml b/config/config/test/fixtures/workspace-yaml-without-packages/pnpm-workspace.yaml new file mode 100644 index 0000000000..01c03eeb60 --- /dev/null +++ b/config/config/test/fixtures/workspace-yaml-without-packages/pnpm-workspace.yaml @@ -0,0 +1 @@ +minimumReleaseAge: '4320' diff --git a/config/config/test/index.ts b/config/config/test/index.ts index a54cbc119b..d30a9c136b 100644 --- a/config/config/test/index.ts +++ b/config/config/test/index.ts @@ -640,6 +640,21 @@ test('reads workspacePackagePatterns', async () => { expect(config.workspacePackagePatterns).toEqual(['packages/*']) }) +test('workspacePackagePatterns defaults to ["."] when pnpm-workspace.yaml has no packages field', async () => { + const workspaceDir = path.join(__dirname, 'fixtures/workspace-yaml-without-packages') + process.chdir(workspaceDir) + const { config } = await getConfig({ + cliOptions: {}, + packageManager: { + name: 'pnpm', + version: '1.0.0', + }, + workspaceDir, + }) + + expect(config.workspacePackagePatterns).toEqual(['.']) +}) + test('setting workspace-concurrency to negative number', async () => { const workspaceDir = path.join(__dirname, 'fixtures/pkg-with-valid-workspace-yaml') process.chdir(workspaceDir) diff --git a/pnpm/test/recursive/misc.ts b/pnpm/test/recursive/misc.ts index 52e1e42e23..fceb272be9 100644 --- a/pnpm/test/recursive/misc.ts +++ b/pnpm/test/recursive/misc.ts @@ -315,6 +315,7 @@ test('recursive command with filter from config', async () => { fs.writeFileSync('package.json', '{}', 'utf8') writeYamlFile('pnpm-workspace.yaml', { + packages: ['*'], filter: ['project-1', 'project-2'], }) await execPnpm(['recursive', 'install'])