-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): support inference in generators
- Loading branch information
1 parent
56fe9ee
commit cd0d320
Showing
6 changed files
with
211 additions
and
163 deletions.
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
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
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,60 @@ | ||
import { NxJsonConfiguration } from '../../config/nx-json'; | ||
import { toProjectName } from '../../config/workspaces'; | ||
import { ProjectConfiguration } from '../../config/workspace-json-project-json'; | ||
import { NxPluginV2 } from '../../utils/nx-plugin'; | ||
import { getGlobPatternsFromPackageManagerWorkspaces } from './package-manager-workspaces'; | ||
import { combineGlobPatterns } from '../../utils/glob'; | ||
import { PackageJson } from '../../utils/package-json'; | ||
import { dirname } from 'node:path'; | ||
|
||
export function getNxCoreProjectPlugin( | ||
root: string, | ||
readJson: <T extends Object>(string: any) => T, | ||
nxJson: NxJsonConfiguration<string[] | '*'> | ||
) { | ||
const globPatternsFromPackageManagerWorkspaces = | ||
getGlobPatternsFromPackageManagerWorkspaces(root, readJson); | ||
const nxCorePlugin: NxPluginV2 = { | ||
name: 'nx-core-build-nodes', | ||
processProjectNodes: { | ||
// Load projects from pnpm / npm workspaces | ||
...(globPatternsFromPackageManagerWorkspaces.length | ||
? { | ||
[combineGlobPatterns(globPatternsFromPackageManagerWorkspaces)]: ( | ||
pkgJsonPath | ||
) => { | ||
const json = readJson<PackageJson>(pkgJsonPath); | ||
json.name | ||
return { | ||
projectNodes: { | ||
[json.name]: buildProjectConfigurationFromPackageJson( | ||
pkgJsonPath, | ||
json, | ||
nxJson | ||
), | ||
}, | ||
}; | ||
}, | ||
} | ||
: {}), | ||
// Load projects from project.json files. These will be read second, since | ||
// they are listed last in the plugin, so they will overwrite things from the package.json | ||
// based projects. | ||
'{project.json,**/project.json}': (file) => { | ||
const json = readJson<ProjectConfiguration>(file); | ||
json.name ??= toProjectName(file); | ||
json.root ??= dirname(file).split('\\').join('/'); | ||
return { | ||
projectNodes: { | ||
[json.name]: json, | ||
}, | ||
}; | ||
}, | ||
}, | ||
}; | ||
return nxCorePlugin; | ||
} | ||
function buildProjectConfigurationFromPackageJson(pkgJsonPath: string, json: PackageJson, nxJson: NxJsonConfiguration<string[] | "*">): ProjectConfiguration { | ||
throw new Error('Function not implemented.'); | ||
} | ||
|
Oops, something went wrong.