nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.29k stars 2.32k forks source link

Nx Plugin not working on Angular Workspace, unable to locate project #14013

Closed dianjuar closed 1 year ago

dianjuar commented 1 year ago

Current Behavior

An Nx plugin built with Nx V15.4.0 is not detecting projects (at least a library) in an Angular Workspace.

I maintain a NxPlugin called ngx-deploy-npm. The problem is located in the executor "deploy" to publish a library to NPM. When it's executed on an Angular Workspace, it's unable to locate the library.

ngx-deploy-npm, first builds the library before publishing; is here when the problem is located. The exact breakpoint is executing runExecutor.

Making some debugging seems to be that the parameter context: ExecutorContext passed to the executor is not populated correctly, the list of projects is empty image

Expected Behavior

It should be able to run runExecutor without any problem as it was doing on previous versions

Github Repo

https://github.com/bikecoders/ngx-deploy-npm

Steps to Reproduce

You will need to run an Nx Plugin executor on an Angular Workspace. That executor must use the function @nrwl/devkit/runExecutor.

I have a simple script to test this behavior on ngx-deploy-npm, you can use it to reproduce the problem quickly

  1. Clone the repo https://github.com/bikecoders/ngx-deploy-npm
    • git clone https://github.com/bikecoders/ngx-deploy-npm
  2. Step on the branch with the problematic nx version
    • git checkout migrate-nx-15-4
  3. Install new nx version with the issue
    • yarn install
  4. Build the plubin
    • npx build
  5. Execute the Script to test the plugin on an Angular Workspace
    • ./tools/create-angular-workspace.sh

Nx Report

Node : 18.12.1
   OS   : darwin x64
   yarn : 1.22.15

   nx : 15.4.0
   @nrwl/angular : Not Found
   @nrwl/cypress : Not Found
   @nrwl/detox : Not Found
   @nrwl/devkit : 15.4.0
   @nrwl/esbuild : Not Found
   @nrwl/eslint-plugin-nx : 15.4.0
   @nrwl/expo : Not Found
   @nrwl/express : Not Found
   @nrwl/jest : 15.4.0
   @nrwl/js : 15.4.0
   @nrwl/linter : 15.4.0
   @nrwl/nest : Not Found
   @nrwl/next : Not Found
   @nrwl/node : Not Found
   @nrwl/nx-cloud : Not Found
   @nrwl/nx-plugin : 15.4.0
   @nrwl/react : Not Found
   @nrwl/react-native : Not Found
   @nrwl/rollup : Not Found
   @nrwl/schematics : Not Found
   @nrwl/storybook : Not Found
   @nrwl/web : Not Found
   @nrwl/webpack : Not Found
   @nrwl/workspace : 15.4.0
   @nrwl/vite : Not Found
   typescript : 4.9.3
   ---------------------------------------
   Local workspace plugins:
         ngx-deploy-npm
   ---------------------------------------
   Community plugins:
         @jscutlery/semver: 2.27.2

Failure Logs

Error: Could not find project "angular-lib"
    at validateProject (/Users/dianjuar/Documents/programing/ngx-deploy-npm/repo/node_modules/nx/src/command-line/run.js:22:15)
    at /Users/dianjuar/Documents/programing/ngx-deploy-npm/repo/node_modules/nx/src/command-line/run.js:80:9
    at Generator.next (<anonymous>)
    at /Users/dianjuar/Documents/programing/ngx-deploy-npm/repo/node_modules/tslib/tslib.js:118:75
    at new Promise (<anonymous>)
    at Object.__awaiter (/Users/dianjuar/Documents/programing/ngx-deploy-npm/repo/node_modules/tslib/tslib.js:114:16)
    at runExecutorInternal (/Users/dianjuar/Documents/programing/ngx-deploy-npm/repo/node_modules/nx/src/command-line/run.js:79:20)
    at /Users/dianjuar/Documents/programing/ngx-deploy-npm/repo/node_modules/nx/src/command-line/run.js:163:22
    at Generator.next (<anonymous>)
    at /Users/dianjuar/Documents/programing/ngx-deploy-npm/repo/node_modules/tslib/tslib.js:118:75
Error when trying to publish the library

Additional Information

Failing Log

https://github.com/bikecoders/ngx-deploy-npm/actions/runs/3767050151/jobs/6404249820


Angular Workspace

The Angular Workspace tested has the following characteristics:

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/

Angular CLI: 15.0.4
Node: 16.18.0
Package Manager: npm 8.19.2
OS: darwin x64

Angular: 15.0.4
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1500.4
@angular-devkit/build-angular   15.0.4
@angular-devkit/core            15.0.4
@angular-devkit/schematics      15.0.4
@schematics/angular             15.0.4
ng-packagr                      15.0.3
rxjs                            7.5.7
typescript                      4.8.4
IslombekHasan commented 1 year ago

Also, Angular Language Service in VS Code is not working with brand new workspaces generated with 15.4.1 as well.

AgentEnder commented 1 year ago

Also, Angular Language Service in VS Code is not working with brand new workspaces generated with 15.4.1 as well.

This is a separate issue, can you open it separately?

dianjuar commented 1 year ago

This is the PR on the Nx Plugin that I maintain. It might be helpful https://github.com/bikecoders/ngx-deploy-npm/pull/448

dianjuar commented 1 year ago

This problem is fixed on V15.5.1.

The NxPlugin stills need to be fixed to work on Angular Workspaces, though. The function readTargetOptions is causing a problem. I will open a new issue to specify better the problem

github-actions[bot] commented 1 year ago

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.