Skip to content

show project: renders duplicate target when using inferred task from package.json#scripts #27143

Description

@Hotell

Current Behavior

nx show projects react-card

renders following web page/nx console detail:

image

it seems the issue comes from metadata.targetGroups which contains non unique Array

JSON CLI output

{
  "root": "packages/react-components/react-card/library",
  "name": "react-card",
  "tags": [
    "npm:public",
    "vNext",
    "platform:web"
  ],
  "metadata": {
    "targetGroups": {
      "NPM Scripts": [
        "build",
        "bundle-size",
        "clean",
        "code-style",
        "e2e",
        "e2e:local",
        "just",
        "lint",
        "start",
        "test",
        "storybook",
        "type-check",
        "generate-api",
        "build",
        "bundle-size",
        "clean",
        "code-style",
        "e2e",
        "e2e:local",
        "just",
        "lint",
        "start",
        "test",
        "storybook",
        "type-check",
        "generate-api"
      ]
    },
    "description": "Card container components for Fluent UI React."
  },
  "targets": {
    "build": {
      "executor": "nx:run-script",
      "metadata": {
        "scriptContent": "just-scripts build",
        "runCommand": "yarn build"
      },
      "dependsOn": [
        "^build"
      ],
      "inputs": [
        "production",
        "^production"
      ],
      "cache": true,
      "options": {
        "script": "build"
      },
      "configurations": {}
    },
    "bundle-size": {
      "executor": "nx:run-script",
      "metadata": {
        "scriptContent": "monosize measure",
        "runCommand": "yarn bundle-size"
      },
      "dependsOn": [
        "^build"
      ],
      "cache": true,
      "options": {
        "script": "bundle-size"
      },
      "configurations": {}
    },
    "clean": {
      "executor": "nx:run-script",
      "metadata": {
        "scriptContent": "just-scripts clean",
        "runCommand": "yarn clean"
      },
      "options": {
        "script": "clean"
      },
      "configurations": {}
    },
    "code-style": {
      "executor": "nx:run-script",
      "metadata": {
        "scriptContent": "just-scripts code-style",
        "runCommand": "yarn code-style"
      },
      "options": {
        "script": "code-style"
      },
      "configurations": {}
    },
    "e2e": {
      "executor": "nx:run-script",
      "metadata": {
        "scriptContent": "cypress run --component",
        "runCommand": "yarn e2e"
      },
      "dependsOn": [],
      "cache": true,
      "inputs": [
        "default",
        "{projectRoot}/cypress.config.ts",
        "!{projectRoot}/**/?(*.)+cy.[jt]s?(x)?"
      ],
      "options": {
        "script": "e2e"
      },
      "configurations": {}
    },
    "e2e:local": {
      "executor": "nx:run-script",
      "metadata": {
        "scriptContent": "cypress open --component",
        "runCommand": "yarn e2e:local"
      },
      "options": {
        "script": "e2e:local"
      },
      "configurations": {}
    },
    "just": {
      "executor": "nx:run-script",
      "metadata": {
        "scriptContent": "just-scripts",
        "runCommand": "yarn just"
      },
      "options": {
        "script": "just"
      },
      "configurations": {}
    },
    "lint": {
      "executor": "nx:run-script",
      "metadata": {
        "scriptContent": "just-scripts lint",
        "runCommand": "yarn lint"
      },
      "dependsOn": [
        "build"
      ],
      "cache": true,
      "inputs": [
        "default",
        "{workspaceRoot}/.eslintrc.json",
        "{workspaceRoot}/.eslintignore",
        "{workspaceRoot}/eslint.config.js"
      ],
      "options": {
        "script": "lint"
      },
      "configurations": {}
    },
    "start": {
      "executor": "nx:run-script",
      "metadata": {
        "scriptContent": "yarn storybook",
        "runCommand": "yarn start"
      },
      "options": {
        "script": "start"
      },
      "configurations": {}
    },
    "test": {
      "executor": "nx:run-script",
      "metadata": {
        "scriptContent": "jest --passWithNoTests",
        "runCommand": "yarn test"
      },
      "dependsOn": [
        "^build"
      ],
      "inputs": [
        "default",
        "^production",
        "{workspaceRoot}/jest.preset.js"
      ],
      "cache": true,
      "options": {
        "script": "test"
      },
      "configurations": {}
    },
    "storybook": {
      "executor": "nx:run-script",
      "metadata": {
        "scriptContent": "yarn --cwd ../stories storybook",
        "runCommand": "yarn storybook"
      },
      "options": {
        "script": "storybook"
      },
      "configurations": {}
    },
    "type-check": {
      "executor": "nx:run-script",
      "metadata": {
        "scriptContent": "just-scripts type-check",
        "runCommand": "yarn type-check"
      },
      "dependsOn": [
        "^build"
      ],
      "cache": true,
      "options": {
        "script": "type-check"
      },
      "configurations": {}
    },
    "generate-api": {
      "executor": "nx:run-script",
      "metadata": {
        "scriptContent": "just-scripts generate-api",
        "runCommand": "yarn generate-api"
      },
      "dependsOn": [
        "^generate-api"
      ],
      "cache": true,
      "options": {
        "script": "generate-api"
      },
      "configurations": {}
    },
    "nx-release-publish": {
      "dependsOn": [
        "^nx-release-publish"
      ],
      "executor": "@nx/js:release-publish",
      "options": {},
      "configurations": {}
    }
  },
  "sourceRoot": "packages/react-components/react-card/library/src",
  "projectType": "library",
  "$schema": "../../../../node_modules/nx/schemas/project-schema.json",
  "implicitDependencies": []
}

Expected Behavior

nx show projects react-card

doesn't render duplicates within web app/nx console

GitHub Repo

https://github.com/microsoft/fluentui

Steps to Reproduce

  1. checkout chore: replace lage with nx for task(targets) orchestration microsoft/fluentui#31949
  2. yarn
  3. yarn nx show project react-card

Nx Report

Node   : 20.15.0
OS     : darwin-arm64
yarn   : 1.23.34

nx                 : 19.3.2
@nx/js             : 19.3.2
@nx/jest           : 19.3.2
@nx/linter         : 19.3.2
@nx/eslint         : 19.3.2
@nx/workspace      : 19.3.2
@nx/devkit         : 19.3.2
@nx/eslint-plugin  : 19.3.2
@nx/node           : 19.3.2
@nx/plugin         : 19.3.2
@nrwl/tao          : 19.3.2
typescript         : 5.0.4
---------------------------------------
Local workspace plugins:
         @fluentui/workspace-plugin

Failure Logs

No response

Package Manager Version

yarn v1

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

Metadata

Metadata

Assignees

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions