11import type {
22 CreateNodes ,
33 CreateNodesContext ,
4+ CreateNodesContextV2 ,
45 CreateNodesResult ,
6+ CreateNodesResultV2 ,
7+ CreateNodesV2 ,
58} from '@nx/devkit' ;
69import { PROJECT_JSON_FILE_NAME } from '../internal/constants.js' ;
710import { createTargets } from './target/targets.js' ;
811import type { CreateNodesOptions } from './types.js' ;
9- import { normalizedCreateNodesContext } from './utils.js' ;
12+ import {
13+ normalizedCreateNodesContext ,
14+ normalizedCreateNodesV2Context ,
15+ } from './utils.js' ;
1016
1117// name has to be "createNodes" to get picked up by Nx <v20
1218export const createNodes : CreateNodes = [
@@ -32,3 +38,36 @@ export const createNodes: CreateNodes = [
3238 } ;
3339 } ,
3440] ;
41+
42+ export const createNodesV2 : CreateNodesV2 < CreateNodesOptions > = [
43+ `**/${ PROJECT_JSON_FILE_NAME } ` ,
44+ async (
45+ projectConfigurationFiles : readonly string [ ] ,
46+ createNodesOptions : unknown ,
47+ context : CreateNodesContextV2 ,
48+ ) : Promise < CreateNodesResultV2 > => {
49+ const parsedCreateNodesOptions = createNodesOptions as CreateNodesOptions ;
50+
51+ const results = await Promise . all (
52+ projectConfigurationFiles . map ( async projectConfigurationFile => {
53+ const normalizedContext = await normalizedCreateNodesV2Context (
54+ context ,
55+ projectConfigurationFile ,
56+ parsedCreateNodesOptions ,
57+ ) ;
58+
59+ const result : CreateNodesResult = {
60+ projects : {
61+ [ normalizedContext . projectRoot ] : {
62+ targets : await createTargets ( normalizedContext ) ,
63+ } ,
64+ } ,
65+ } ;
66+
67+ return [ projectConfigurationFile , result ] as const ;
68+ } ) ,
69+ ) ;
70+
71+ return results ;
72+ } ,
73+ ] ;
0 commit comments