-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathplugin.ts
More file actions
72 lines (66 loc) · 1.99 KB
/
plugin.ts
File metadata and controls
72 lines (66 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import type {
CreateNodes,
CreateNodesContext,
CreateNodesContextV2,
CreateNodesResult,
CreateNodesResultV2,
CreateNodesV2,
} from '@nx/devkit';
import { PROJECT_JSON_FILE_NAME } from '../internal/constants.js';
import { createTargets } from './target/targets.js';
import type { CreateNodesOptions } from './types.js';
import {
normalizedCreateNodesContext,
normalizedCreateNodesV2Context,
} from './utils.js';
// name has to be "createNodes" to get picked up by Nx <v20
export const createNodes: CreateNodes = [
`**/${PROJECT_JSON_FILE_NAME}`,
async (
projectConfigurationFile: string,
createNodesOptions: unknown,
context: CreateNodesContext,
): Promise<CreateNodesResult> => {
const parsedCreateNodesOptions = createNodesOptions as CreateNodesOptions;
const normalizedContext = await normalizedCreateNodesContext(
context,
projectConfigurationFile,
parsedCreateNodesOptions,
);
return {
projects: {
[normalizedContext.projectRoot]: {
targets: await createTargets(normalizedContext),
},
},
};
},
];
export const createNodesV2: CreateNodesV2 = [
`**/${PROJECT_JSON_FILE_NAME}`,
async (
projectConfigurationFiles: readonly string[],
createNodesOptions: unknown,
context: CreateNodesContextV2,
): Promise<CreateNodesResultV2> => {
const parsedCreateNodesOptions =
(createNodesOptions as CreateNodesOptions) ?? {};
return await Promise.all(
projectConfigurationFiles.map(async projectConfigurationFile => {
const normalizedContext = await normalizedCreateNodesV2Context(
context,
projectConfigurationFile,
parsedCreateNodesOptions,
);
const result: CreateNodesResult = {
projects: {
[normalizedContext.projectRoot]: {
targets: await createTargets(normalizedContext),
},
},
};
return [projectConfigurationFile, result] as const;
}),
);
},
];