cli icon indicating copy to clipboard operation
cli copied to clipboard

Nx target defaults for standalone setup in nx-plugin

Open BioPhoton opened this issue 3 months ago • 0 comments

Preconditions

  • #1110
  • #1109
  • #1095
  • [IN_PROGRESS] remove merge logic from executor
  • #1091

User story

As a Nx user I want to have my CodePushup targets set up automatically in standalone mode.

Acceptance criteria

  • [ ] default target
  • [ ] plugin caching
  • [ ] DX when using with or without caching

Implementation details

nx.json

{
  "plugins": [
    {
      "plugin": "@code-pushup/nx-plugin",
      "options": {
        "targetName": "cp",
        "projectPrefix": "cli",
      }
    }
  ]
}

packages/utils/project.json

{
  "targets": {
    "code-pushup": {
      "executor": "@code-pushup/nx-plugin:cli",
      "cache": true,
      "inputs": ["default", "code-pushup-inputs"],
      "outputs": ["{projectRoot}/.code-pushup/**/*"],
      "options": {
        "bin": "node ./packages/cli/src/index.ts",
        "config": "{projectRoot}/code-pushup.config.ts",
        "progress": false,
        "verbose": true,
        "persist": { "outputDir": "{projectRoot}/.code-pushup" }
      },
      "configurations": {
        "autorun": {
          "command": "autorun"
        },
        "print-config": {
          "command": "print-config",
          "output": "{projectRoot}/.code-pushup/code-pushup-config.json"
        },
        "collect": {
          "command": "collect",
          "cache": { "write": true }
        },
        "upload": {
          "command": "upload",
          "upload": { "project": "cli-{projectName}" }
        },

        /* per-plugin “collect” configs (distinct cache keys) */
        "collect-eslint-cache":     { "command": "collect", "onlyPlugins": ["eslint"],     "cache": { "write": true }, "persist": { "skipReports": true } },
        "collect-coverage-cache":   { "command": "collect", "onlyPlugins": ["coverage"],   "cache": { "write": true }, "persist": { "skipReports": true } },
        "collect-typescript-cache": { "command": "collect", "onlyPlugins": ["typescript"], "cache": { "write": true }, "persist": { "skipReports": true } },
        "collect-jsdocs-cache":     { "command": "collect", "onlyPlugins": ["jsdocs"],     "cache": { "write": true }, "persist": { "skipReports": true } },
        "collect-lighthouse-cache": { "command": "collect", "onlyPlugins": ["lighthouse"], "cache": { "write": true }, "persist": { "skipReports": true } },
        "collect-js-packages-cache":{ "command": "collect", "onlyPlugins": ["js-packages"] }
      },
      "defaultConfiguration": "autorun"
    }
  }
}

Run examples:

  • nx run myproj:code-pushup → autorun
  • nx run myproj:code-pushup:collect-eslint → collect eslint only
  • nx run myproj:code-pushup:collect-eslint-cached → for plugin caching setup
  • nx run myproj:code-pushup:upload

BioPhoton avatar Sep 07 '25 18:09 BioPhoton