mirror of
https://github.com/pnpm/pnpm.git
synced 2025-12-24 15:48:06 -05:00
feat: add ignore-workspace-cycles to silence workspace cycle warning (#6308)
This commit is contained in:
8
.changeset/olive-bees-yawn.md
Normal file
8
.changeset/olive-bees-yawn.md
Normal file
@@ -0,0 +1,8 @@
|
||||
---
|
||||
"pnpm": minor
|
||||
"@pnpm/plugin-commands-installation": minor
|
||||
"@pnpm/core": minor
|
||||
"@pnpm/config": minor
|
||||
---
|
||||
|
||||
Add `ignore-workspace-cycles` to silence workspace cycle warning [#6308](https://github.com/pnpm/pnpm/pull/6308).
|
||||
@@ -158,6 +158,7 @@ export interface Config {
|
||||
onlyBuiltDependencies?: string[]
|
||||
dedupePeerDependents?: boolean
|
||||
patchesDir?: string
|
||||
ignoreWorkspaceCycles?: boolean
|
||||
|
||||
registries: Registries
|
||||
ignoreWorkspaceRootCheck: boolean
|
||||
|
||||
@@ -64,6 +64,7 @@ export const types = Object.assign({
|
||||
'ignore-dep-scripts': Boolean,
|
||||
'ignore-pnpmfile': Boolean,
|
||||
'ignore-workspace': Boolean,
|
||||
'ignore-workspace-cycles': Boolean,
|
||||
'ignore-workspace-root-check': Boolean,
|
||||
'include-workspace-root': Boolean,
|
||||
'legacy-dir-filtering': Boolean,
|
||||
@@ -205,6 +206,7 @@ export async function getConfig (
|
||||
'git-branch-lockfile': false,
|
||||
hoist: true,
|
||||
'hoist-pattern': ['*'],
|
||||
'ignore-workspace-cycles': false,
|
||||
'ignore-workspace-root-check': false,
|
||||
'link-workspace-packages': true,
|
||||
'lockfile-include-tarball-url': false,
|
||||
|
||||
@@ -102,6 +102,7 @@ export interface StrictInstallOptions {
|
||||
preferSymlinkedExecutables: boolean
|
||||
resolutionMode: 'highest' | 'time-based' | 'lowest-direct'
|
||||
resolvePeersFromWorkspaceRoot: boolean
|
||||
ignoreWorkspaceCycles: boolean
|
||||
|
||||
publicHoistPattern: string[] | undefined
|
||||
hoistPattern: string[] | undefined
|
||||
@@ -205,6 +206,7 @@ const defaults = async (opts: InstallOptions) => {
|
||||
dedupePeerDependents: true,
|
||||
resolvePeersFromWorkspaceRoot: true,
|
||||
extendNodePath: true,
|
||||
ignoreWorkspaceCycles: false,
|
||||
} as StrictInstallOptions
|
||||
}
|
||||
|
||||
|
||||
@@ -88,6 +88,7 @@ export type ImportCommandOptions = Pick<Config,
|
||||
| 'allProjectsGraph'
|
||||
| 'selectedProjectsGraph'
|
||||
| 'workspaceDir'
|
||||
| 'ignoreWorkspaceCycles'
|
||||
> & CreateStoreControllerOptions & Omit<InstallOptions, 'storeController' | 'lockfileOnly' | 'preferredVersions'>
|
||||
|
||||
export async function handler (
|
||||
@@ -120,7 +121,7 @@ export async function handler (
|
||||
if (selectedProjectsGraph != null) {
|
||||
const sequencedGraph = sequenceGraph(selectedProjectsGraph)
|
||||
// Check and warn if there are cyclic dependencies
|
||||
if (!sequencedGraph.safe) {
|
||||
if (!opts.ignoreWorkspaceCycles && !sequencedGraph.safe) {
|
||||
const cyclicDependenciesInfo = sequencedGraph.cycles.length > 0
|
||||
? `: ${sequencedGraph.cycles.map(deps => deps.join(', ')).join('; ')}`
|
||||
: ''
|
||||
|
||||
@@ -286,6 +286,7 @@ export type InstallCommandOptions = Pick<Config,
|
||||
| 'workspaceDir'
|
||||
| 'extraEnv'
|
||||
| 'resolutionMode'
|
||||
| 'ignoreWorkspaceCycles'
|
||||
> & CreateStoreControllerOptions & {
|
||||
argv: {
|
||||
original: string[]
|
||||
|
||||
@@ -78,6 +78,7 @@ export type InstallDepsOptions = Pick<Config,
|
||||
| 'workspaceConcurrency'
|
||||
| 'workspaceDir'
|
||||
| 'extraEnv'
|
||||
| 'ignoreWorkspaceCycles'
|
||||
> & CreateStoreControllerOptions & {
|
||||
argv: {
|
||||
original: string[]
|
||||
@@ -138,7 +139,7 @@ when running add/update with the --workspace option')
|
||||
if (selectedProjectsGraph != null) {
|
||||
const sequencedGraph = sequenceGraph(selectedProjectsGraph)
|
||||
// Check and warn if there are cyclic dependencies
|
||||
if (!sequencedGraph.safe) {
|
||||
if (!opts.ignoreWorkspaceCycles && !sequencedGraph.safe) {
|
||||
const cyclicDependenciesInfo = sequencedGraph.cycles.length > 0
|
||||
? `: ${sequencedGraph.cycles.map(deps => deps.join(', ')).join('; ')}`
|
||||
: ''
|
||||
|
||||
@@ -43,6 +43,34 @@ test('should warn about cyclic dependencies', async () => {
|
||||
})
|
||||
})
|
||||
|
||||
test('should not warn about cyclic dependencies if ignore-workspace-cycles is set', async () => {
|
||||
preparePackages([
|
||||
{
|
||||
name: 'project-1',
|
||||
version: '1.0.0',
|
||||
dependencies: { 'project-2': 'workspace:*' },
|
||||
},
|
||||
{
|
||||
name: 'project-2',
|
||||
version: '2.0.0',
|
||||
devDependencies: { 'project-1': 'workspace:*' },
|
||||
},
|
||||
])
|
||||
|
||||
const { allProjects, selectedProjectsGraph } = await readProjects(process.cwd(), [])
|
||||
await install.handler({
|
||||
...DEFAULT_OPTS,
|
||||
allProjects,
|
||||
dir: process.cwd(),
|
||||
recursive: true,
|
||||
selectedProjectsGraph,
|
||||
workspaceDir: process.cwd(),
|
||||
ignoreWorkspaceCycles: true,
|
||||
})
|
||||
|
||||
expect(logger.warn).toHaveBeenCalledTimes(0)
|
||||
})
|
||||
|
||||
test('should not warn about cyclic dependencies if there are not', async () => {
|
||||
preparePackages([
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user