1
- import type {
1
+ import {
2
2
CreateNodes ,
3
3
CreateNodesContext ,
4
4
CreateNodesResult ,
5
+ CreateNodesV2 ,
6
+ createNodesFromFiles ,
5
7
} from '@nx/devkit' ;
6
- import { PROJECT_JSON_FILE_NAME } from '../internal/constants.js ' ;
7
- import { createTargets } from './target/targets.js ' ;
8
- import type { CreateNodesOptions } from './types.js ' ;
9
- import { normalizedCreateNodesContext } from './utils.js ' ;
8
+ import { PROJECT_JSON_FILE_NAME } from '../internal/constants' ;
9
+ import { createTargets } from './target/targets' ;
10
+ import type { CreateNodesOptions } from './types' ;
11
+ import { normalizedCreateNodesContext } from './utils' ;
10
12
11
13
// name has to be "createNodes" to get picked up by Nx
14
+
12
15
export const createNodes : CreateNodes = [
13
16
`**/${ PROJECT_JSON_FILE_NAME } ` ,
14
17
async (
@@ -32,3 +35,31 @@ export const createNodes: CreateNodes = [
32
35
} ;
33
36
} ,
34
37
] ;
38
+
39
+ export const createNodesV2 : CreateNodesV2 < any > = [
40
+ `**/${ PROJECT_JSON_FILE_NAME } ` ,
41
+
42
+ async ( configFiles , options , context ) => {
43
+ return await createNodesFromFiles (
44
+ async ( globMatchingFile , internalOptions ) => {
45
+ const parsedCreateNodesOptions = internalOptions as CreateNodesOptions ;
46
+
47
+ const normalizedContext = await normalizedCreateNodesContext (
48
+ context ,
49
+ globMatchingFile ,
50
+ parsedCreateNodesOptions ,
51
+ ) ;
52
+ return {
53
+ projects : {
54
+ [ normalizedContext . projectRoot ] : {
55
+ targets : await createTargets ( normalizedContext ) ,
56
+ } ,
57
+ } ,
58
+ } ;
59
+ } ,
60
+ configFiles ,
61
+ options ,
62
+ context ,
63
+ ) ;
64
+ } ,
65
+ ] ;
0 commit comments