@code-pushup/ci 0.55.0 → 0.56.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -94,23 +94,26 @@ A `Comment` object has the following required properties:
94
94
 
95
95
  Optionally, you can override default options for further customization:
96
96
 
97
- | Property | Type | Default | Description |
98
- | :---------------- | :------------------------ | :------------------------------- | :----------------------------------------------------------------------------------- |
99
- | `monorepo` | `boolean \| MonorepoTool` | `false` | Enables [monorepo mode](#monorepo-mode) |
100
- | `projects` | `string[] \| null` | `null` | Custom projects configuration for [monorepo mode](#monorepo-mode) |
101
- | `task` | `string` | `'code-pushup'` | Name of command to run Code PushUp per project in [monorepo mode](#monorepo-mode) |
102
- | `directory` | `string` | `process.cwd()` | Directory in which Code PushUp CLI should run |
103
- | `config` | `string \| null` | `null` [^1] | Path to config file (`--config` option) |
104
- | `silent` | `boolean` | `false` | Toggles if logs from CLI commands are printed |
105
- | `bin` | `string` | `'npx --no-install code-pushup'` | Command for executing Code PushUp CLI |
106
- | `detectNewIssues` | `boolean` | `true` | Toggles if new issues should be detected and returned in `newIssues` property |
107
- | `logger` | `Logger` | `console` | Logger for reporting progress and encountered problems |
108
- | `output` | `string` | `'.code-pushup'` | Directory where Code PushUp reports will be created (interpolates project name [^2]) |
97
+ | Property | Type | Default | Description |
98
+ | :----------------- | :------------------------ | :------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------- |
99
+ | `monorepo` | `boolean \| MonorepoTool` | `false` | Enables [monorepo mode](#monorepo-mode) |
100
+ | `projects` | `string[] \| null` | `null` | Custom projects configuration for [monorepo mode](#monorepo-mode) |
101
+ | `task` | `string` | `'code-pushup'` | Name of command to run Code PushUp per project in [monorepo mode](#monorepo-mode) |
102
+ | `nxProjectsFilter` | `string \| string[]` | `'--with-target={task}'` | Arguments passed to [`nx show projects`](https://nx.dev/nx-api/nx/documents/show#projects), only relevant for Nx in [monorepo mode](#monorepo-mode) [^3] |
103
+ | `directory` | `string` | `process.cwd()` | Directory in which Code PushUp CLI should run |
104
+ | `config` | `string \| null` | `null` [^1] | Path to config file (`--config` option) |
105
+ | `silent` | `boolean` | `false` | Toggles if logs from CLI commands are printed |
106
+ | `bin` | `string` | `'npx --no-install code-pushup'` | Command for executing Code PushUp CLI |
107
+ | `detectNewIssues` | `boolean` | `true` | Toggles if new issues should be detected and returned in `newIssues` property |
108
+ | `logger` | `Logger` | `console` | Logger for reporting progress and encountered problems |
109
+ | `output` | `string` | `'.code-pushup'` | Directory where Code PushUp reports will be created (interpolates project name [^2]) |
109
110
 
110
111
  [^1]: By default, the `code-pushup.config` file is autodetected as described in [`@code-pushup/cli` docs](../cli/README.md#configuration).
111
112
 
112
113
  [^2]: In monorepo mode, any occurrence of `{project}` in the `output` path will be replaced with a project name. This separation of folders per project (e.g. `output: '.code-pushup/{project}'`) may be useful for caching purposes.
113
114
 
115
+ [^3]: The `{task}` pattern is replaced with the `task` value, so the default behaviour is to list projects using `npx nx show projects --with-target=code-pushup --json`. The `nxProjectsFilter` options gives Nx users the flexibility to filter projects in alternative ways supported by the Nx CLI (e.g. `--affected`, `--projects`, `--exclude`, `--type`) - refer to [options in Nx docs](https://nx.dev/nx-api/nx/documents/show#options) for details.
116
+
114
117
  The `Logger` object has the following required properties:
115
118
 
116
119
  | Property | Type | Description |
package/index.js CHANGED
@@ -813,6 +813,11 @@ function projectToFilename(project) {
813
813
  // packages/utils/src/lib/git/git.ts
814
814
  import { simpleGit } from "simple-git";
815
815
 
816
+ // packages/utils/src/lib/transform.ts
817
+ function toArray(val) {
818
+ return Array.isArray(val) ? val : [val];
819
+ }
820
+
816
821
  // packages/utils/src/lib/git/git.commits-and-tags.ts
817
822
  import { simpleGit as simpleGit2 } from "simple-git";
818
823
 
@@ -923,22 +928,26 @@ var nxHandler = {
923
928
  tool: "nx",
924
929
  async isConfigured(options) {
925
930
  return await fileExists(join3(options.cwd, "nx.json")) && (await executeProcess({
926
- ...options,
927
931
  command: "npx",
928
- args: ["nx", "report"]
932
+ args: ["nx", "report"],
933
+ cwd: options.cwd,
934
+ observer: options.observer
929
935
  })).code === 0;
930
936
  },
931
937
  async listProjects(options) {
932
938
  const { stdout } = await executeProcess({
933
- ...options,
934
939
  command: "npx",
935
940
  args: [
936
941
  "nx",
937
942
  "show",
938
943
  "projects",
939
- `--with-target=${options.task}`,
944
+ ...toArray(options.nxProjectsFilter).map(
945
+ (arg) => arg.replaceAll("{task}", options.task)
946
+ ),
940
947
  "--json"
941
- ]
948
+ ],
949
+ cwd: options.cwd,
950
+ observer: options.observer
942
951
  });
943
952
  const projects = parseProjects(stdout);
944
953
  return projects.map((project) => ({
@@ -1108,6 +1117,7 @@ function createMonorepoHandlerOptions(settings) {
1108
1117
  return {
1109
1118
  task: settings.task,
1110
1119
  cwd: settings.directory,
1120
+ nxProjectsFilter: settings.nxProjectsFilter,
1111
1121
  ...!settings.silent && {
1112
1122
  observer: {
1113
1123
  onStdout: (stdout) => {
@@ -1354,7 +1364,8 @@ var DEFAULT_SETTINGS = {
1354
1364
  debug: false,
1355
1365
  detectNewIssues: true,
1356
1366
  logger: console,
1357
- output: DEFAULT_PERSIST_OUTPUT_DIR
1367
+ output: DEFAULT_PERSIST_OUTPUT_DIR,
1368
+ nxProjectsFilter: "--with-target={task}"
1358
1369
  };
1359
1370
 
1360
1371
  // packages/ci/src/lib/git.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@code-pushup/ci",
3
- "version": "0.55.0",
3
+ "version": "0.56.0",
4
4
  "description": "CI automation logic for Code PushUp (provider-agnostic)",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/code-pushup/cli/tree/main/packages/ci#readme",
@@ -28,8 +28,8 @@
28
28
  "main": "./index.js",
29
29
  "types": "./src/index.d.ts",
30
30
  "dependencies": {
31
- "@code-pushup/models": "0.55.0",
32
- "@code-pushup/utils": "0.55.0",
31
+ "@code-pushup/models": "0.56.0",
32
+ "@code-pushup/utils": "0.56.0",
33
33
  "glob": "^10.4.5",
34
34
  "simple-git": "^3.20.0",
35
35
  "yaml": "^2.5.1"
@@ -8,6 +8,7 @@ export type Options = {
8
8
  monorepo?: boolean | MonorepoTool;
9
9
  projects?: string[] | null;
10
10
  task?: string;
11
+ nxProjectsFilter?: string | string[];
11
12
  bin?: string;
12
13
  config?: string | null;
13
14
  directory?: string;
@@ -10,6 +10,7 @@ export type MonorepoHandlerOptions = {
10
10
  task: string;
11
11
  cwd: string;
12
12
  observer?: ProcessObserver;
13
+ nxProjectsFilter: string | string[];
13
14
  };
14
15
  export type ProjectConfig = {
15
16
  name: string;