-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core): all graph nodes should have targets block, even if its emp…
…ty (#18625)
- Loading branch information
1 parent
3627df4
commit b2ecea4
Showing
3 changed files
with
119 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import * as memfs from 'memfs'; | ||
|
||
import '../src/utils/testing/mock-fs'; | ||
import { getNxPackageJsonWorkspacesPlugin } from './package-json-workspaces'; | ||
|
||
describe('nx package.json workspaces plugin', () => { | ||
it('should build projects from package.json files', () => { | ||
memfs.vol.fromJSON( | ||
{ | ||
'package.json': JSON.stringify({ | ||
name: 'root', | ||
scripts: { echo: 'echo root project' }, | ||
}), | ||
'packages/lib-a/package.json': JSON.stringify({ | ||
name: 'lib-a', | ||
scripts: { test: 'jest' }, | ||
}), | ||
}, | ||
'/root' | ||
); | ||
|
||
const plugin = getNxPackageJsonWorkspacesPlugin('/root'); | ||
|
||
// Targets from package.json files are handled outside of `createNodes`, | ||
// because they are recognized even if the package.json file is not included | ||
// in the package manager workspaces configuration. | ||
// | ||
// If any project has a package.json file in its root directory, those scripts | ||
// are targets regardless of this plugin. As such, all we have to do here is identify | ||
// that the package.json represents an Nx project, and `normalizeProjectNodes` | ||
// will handle the rest. | ||
expect(plugin.createNodes[1]('package.json', null)).toMatchInlineSnapshot(` | ||
{ | ||
"projects": { | ||
"root": { | ||
"name": "root", | ||
"projectType": "library", | ||
"root": ".", | ||
"sourceRoot": ".", | ||
}, | ||
}, | ||
} | ||
`); | ||
expect(plugin.createNodes[1]('packages/lib-a/package.json', null)) | ||
.toMatchInlineSnapshot(` | ||
{ | ||
"projects": { | ||
"lib-a": { | ||
"name": "lib-a", | ||
"projectType": "library", | ||
"root": "packages/lib-a", | ||
"sourceRoot": "packages/lib-a", | ||
}, | ||
}, | ||
} | ||
`); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import * as memfs from 'memfs'; | ||
|
||
import '../src/utils/testing/mock-fs'; | ||
import { getNxProjectJsonPlugin } from './project-json'; | ||
|
||
describe('nx project.json plugin', () => { | ||
it('should build projects from project.json', () => { | ||
memfs.vol.fromJSON( | ||
{ | ||
'project.json': JSON.stringify({ | ||
name: 'root', | ||
targets: { command: 'echo root project' }, | ||
}), | ||
'packages/lib-a/project.json': JSON.stringify({ | ||
name: 'lib-a', | ||
targets: { | ||
executor: 'nx:run-commands', | ||
options: {}, | ||
}, | ||
}), | ||
}, | ||
'/root' | ||
); | ||
|
||
const plugin = getNxProjectJsonPlugin('/root'); | ||
expect(plugin.createNodes[1]('project.json', null)).toMatchInlineSnapshot(` | ||
{ | ||
"projects": { | ||
"root": { | ||
"name": "root", | ||
"root": ".", | ||
"targets": { | ||
"command": "echo root project", | ||
}, | ||
}, | ||
}, | ||
} | ||
`); | ||
expect(plugin.createNodes[1]('packages/lib-a/project.json', null)) | ||
.toMatchInlineSnapshot(` | ||
{ | ||
"projects": { | ||
"lib-a": { | ||
"name": "lib-a", | ||
"root": "packages/lib-a", | ||
"targets": { | ||
"executor": "nx:run-commands", | ||
"options": {}, | ||
}, | ||
}, | ||
}, | ||
} | ||
`); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
b2ecea4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
nx-dev – ./
nx-dev-git-master-nrwl.vercel.app
nx.dev
nx-dev-nrwl.vercel.app
nx-five.vercel.app