Skip to content

Nx target defaults for standalone setup in nx-plugin #1111

Description

@BioPhoton

Preconditions

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions