Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,21 @@ Therefore, PRs are merged via one of two strategies:
- rebase - branch cannot contain merge commits ([rebase instead of merge](https://www.atlassian.com/git/tutorials/merging-vs-rebasing)),
- squash - single commit whose message is the PR title (should be in conventional commit format).

## Releases

We use nx release command to create releases for GitHub as well as publish to npm.

**Preconditions:**

- `npm login` - Only users with write access to [code-pushup](https://www.npmjs.com/org/code-pushup) can publish
- (optional) `GITHUB_TOKEN=ghp_...` in `.env` - [Personal access token](https://github.com/settings/personal-access-tokens/new) to create a GitHub release.

**Steps:**

- `git checkout main`, `git pull`
- (recommended optional) `npx nx release --dryRun`
- `npx nx release` and confirm publish prompt

## Project tags

[Nx tags](https://nx.dev/core-features/enforce-module-boundaries) are used to enforce module boundaries in the project graph when linting.
Expand Down
3 changes: 3 additions & 0 deletions code-pushup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ const config: CoreConfig = {
server: 'https://api.staging.code-pushup.dev/graphql',
apiKey: process.env['CP_API_KEY'],
},
persist: {
outputDir: '.code-pushup',
},
}),
plugins: [],
};
Expand Down
2 changes: 1 addition & 1 deletion e2e/nx-plugin-e2e/tests/plugin-create-nodes.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ describe('nx-plugin', () => {
});

it('should consider plugin option projectPrefix in executor target', async () => {
const cwd = path.join(testFileDir, 'configuration-option-bin');
const cwd = path.join(testFileDir, 'configuration-option-projectPrefix');
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

folder name was a duplicate

registerPluginInWorkspace(tree, {
plugin: '@code-pushup/nx-plugin',
options: {
Expand Down
3 changes: 3 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,9 @@
"releaseTagPattern": "v{version}"
},
"plugins": [
{
"plugin": "@code-pushup/nx-plugin"
},
{
"plugin": "@push-based/nx-verdaccio",
"options": {
Expand Down
114 changes: 108 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"node": ">=22.14"
},
"dependencies": {
"@code-pushup/portal-client": "^0.16.0",
"@isaacs/cliui": "^8.0.2",
"@nx/devkit": "21.4.1",
"@poppinss/cliui": "6.4.1",
Expand All @@ -49,10 +48,13 @@
"zod": "^4.0.5"
},
"devDependencies": {
"@code-pushup/portal-client": "^0.16.0",
"@actions/core": "^1.11.1",
"@actions/github": "^6.0.1",
"@beaussan/nx-knip": "^0.0.5-15",
"@code-pushup/cli": "^0.79.1",
"@code-pushup/eslint-config": "^0.14.2",
"@code-pushup/nx-plugin": "^0.79.1",
"@commitlint/cli": "^19.5.0",
"@commitlint/config-conventional": "^19.5.0",
"@commitlint/config-nx-scopes": "^19.5.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/nx-plugin/src/executors/cli/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function parseAutorunExecutorOptions(
options: Partial<AutorunCommandExecutorOptions>,
normalizedContext: NormalizedExecutorContext,
): AutorunCommandExecutorOptions {
const { projectPrefix, persist, upload, command } = options;
const { projectPrefix, persist, upload, command, output } = options;
const needsUploadParams =
command === 'upload' || command === 'autorun' || command === undefined;
const uploadCfg = uploadConfig(
Expand All @@ -46,6 +46,7 @@ export function parseAutorunExecutorOptions(
...parsePrintConfigExecutorOptions(options),
...parseAutorunExecutorOnlyOptions(options),
...globalConfig(options, normalizedContext),
...(output ? { output } : {}),
persist: persistConfig({ projectPrefix, ...persist }, normalizedContext),
// @TODO This is a hack to avoid validation errors of upload config for commands that dont need it.
// Fix: use utils and execute the core logic directly
Expand Down
27 changes: 27 additions & 0 deletions packages/nx-plugin/src/executors/cli/utils.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,33 @@ describe('parseAutorunExecutorOptions', () => {
);
},
);

it.each<Command>(['print-config'])(
'should include output config for command %s',
command => {
const projectName = 'my-app';
const executorOptions = parseAutorunExecutorOptions(
{
command,
output: 'code-pushup.config.json',
},
{
projectName,
workspaceRoot: 'workspaceRoot',
projectConfig: {
name: 'my-app',
root: 'root',
},
},
);

expect(executorOptions).toEqual(
expect.objectContaining({
output: 'code-pushup.config.json',
}),
);
},
);
});

describe('mergeExecutorOptions', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/nx-plugin/src/executors/internal/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function createCliCommandObject(options?: {
logger.error(error.message);
},
onStdout: data => {
logger.log(data);
process.stdout.write(data);
},
},
};
Expand Down
19 changes: 8 additions & 11 deletions packages/nx-plugin/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
import type { CreateNodesV2, NxPlugin } from '@nx/devkit';
import { createNodes, createNodesV2 } from './plugin/index.js';

// default export for nx.json#plugins
const plugin = {
name: '@code-pushup/nx-plugin',
createNodesV2,
// Keep for backwards compatibility with Nx < 21
createNodes,
};

export default plugin;

export { createNodes, createNodesV2 } from './plugin/index.js';
export type { AutorunCommandExecutorOptions } from './executors/cli/schema.js';
export { objectToCliArgs } from './executors/internal/cli.js';
export { generateCodePushupConfig } from './generators/configuration/code-pushup-config.js';
Expand All @@ -22,4 +14,9 @@ export {
type ProcessConfig,
} from './internal/execute-process.js';
export * from './internal/versions.js';
export { createNodes, createNodesV2 } from './plugin/index.js';

export default {
name: 'code-pushup',
createNodesV2: createNodesV2 as CreateNodesV2,
createNodes,
} satisfies NxPlugin;
Loading
Loading