Skip to content

Commit 09ec54b

Browse files
committed
chore: add plugin to nx.json
1 parent 5b4069a commit 09ec54b

File tree

5 files changed

+23
-26
lines changed

5 files changed

+23
-26
lines changed

e2e/nx-plugin-e2e/tests/plugin-create-nodes.e2e.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ describe('nx-plugin', () => {
229229
});
230230

231231
it('should consider plugin option projectPrefix in executor target', async () => {
232-
const cwd = path.join(testFileDir, 'configuration-option-bin');
232+
const cwd = path.join(testFileDir, 'configuration-option-projectPrefix');
233233
registerPluginInWorkspace(tree, {
234234
plugin: '@code-pushup/nx-plugin',
235235
options: {

packages/nx-plugin/src/index.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
1+
import type { CreateNodesV2, NxPlugin } from '@nx/devkit';
12
import { createNodes, createNodesV2 } from './plugin/index.js';
23

3-
// default export for nx.json#plugins
4-
const plugin = {
5-
name: '@code-pushup/nx-plugin',
6-
createNodesV2,
7-
// Keep for backwards compatibility with Nx < 21
8-
createNodes,
9-
};
10-
11-
export default plugin;
12-
4+
export { createNodes, createNodesV2 } from './plugin/index.js';
135
export type { AutorunCommandExecutorOptions } from './executors/cli/schema.js';
146
export { objectToCliArgs } from './executors/internal/cli.js';
157
export { generateCodePushupConfig } from './generators/configuration/code-pushup-config.js';
@@ -22,4 +14,9 @@ export {
2214
type ProcessConfig,
2315
} from './internal/execute-process.js';
2416
export * from './internal/versions.js';
25-
export { createNodes, createNodesV2 } from './plugin/index.js';
17+
18+
export default {
19+
name: 'code-pushup',
20+
createNodesV2: createNodesV2 as CreateNodesV2,
21+
createNodes,
22+
} satisfies NxPlugin;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,12 @@
1+
import { NxPlugin } from '@nx/devkit';
2+
import { createNodesV2 } from './plugin.js';
3+
14
export { createNodes, createNodesV2 } from './plugin.js';
25
export type { CreateNodesOptions } from './types.js';
6+
7+
const plugin = {
8+
createNodesV2,
9+
name: 'code-pushup-nx-plugin',
10+
} satisfies NxPlugin;
11+
12+
export default plugin;

packages/nx-plugin/src/plugin/plugin.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,11 @@ export const createNodesV2: CreateNodesV2<CreateNodesOptions> = [
4343
`**/${PROJECT_JSON_FILE_NAME}`,
4444
async (
4545
projectConfigurationFiles: readonly string[],
46-
createNodesOptions: unknown,
46+
createNodesOptions: CreateNodesOptions | undefined,
4747
context: CreateNodesContextV2,
4848
): Promise<CreateNodesResultV2> => {
49-
const parsedCreateNodesOptions = createNodesOptions as CreateNodesOptions;
49+
const parsedCreateNodesOptions =
50+
(createNodesOptions as CreateNodesOptions) ?? {};
5051

5152
return await Promise.all(
5253
projectConfigurationFiles.map(async projectConfigurationFile => {

project.json

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
11
{
22
"name": "cli-workspace",
33
"$schema": "node_modules/nx/schemas/project-schema.json",
4-
"targets": {
5-
"code-pushup": {
6-
"executor": "nx:run-commands",
7-
"options": {
8-
"command": "node packages/cli/src/index.ts --no-progress --verbose",
9-
"env": {
10-
"NODE_OPTIONS": "--import tsx",
11-
"TSX_TSCONFIG_PATH": "tsconfig.base.json"
12-
}
13-
}
14-
}
15-
}
4+
"targets": {}
165
}

0 commit comments

Comments
 (0)