nxtend-team / nxtend

MIT License
189 stars 42 forks source link

@nxtend/capacitor - error upon upgrade/migration #461

Open snguyen23 opened 3 years ago

snguyen23 commented 3 years ago

We are attempting to upgrade/migrate our existing @nxtend/capacitor (currently 1.1.0) plugin to the latest version, but running into the following error upon attempting to test the Capacitor commands via nx run my-app:sync --platform iOS & nx run my-app:sync --platform android

stevens-mbp:nevco-one stevennguyen$ nx run controller:sync --platform ios Warning: Fell back to using 'fs' to identify List.plist as deleted. Please open an issue at https://github.com/nrwl/nx so we can investigate.` ng run controller:sync --platform=ios Unknown option: '--platform'

My path to upgrade/migration consisted of the following:

Let me know if you need any further info/details. Thanks!

devinshoemaker commented 3 years ago

Can you let me know what version of Node and Nx you are running?

snguyen23 commented 3 years ago
  @nrwl/angular : 9.6.0
  @nrwl/cli : 9.6.0
  @nrwl/cypress : 9.6.0
  @nrwl/eslint-plugin-nx : Not Found
  @nrwl/express : 9.6.0
  @nrwl/jest : 9.6.0
  @nrwl/linter : 9.6.0
  @nrwl/nest : 9.6.0
  @nrwl/next : Not Found
  @nrwl/node : 9.6.0
  @nrwl/react : Not Found
  @nrwl/schematics : 8.12.11
  @nrwl/tao : 9.6.0
  @nrwl/web : 9.6.0
  @nrwl/workspace : 9.6.0
  typescript : 3.8.3
  Angular CLI: 9.1.12
  Node: 10.16.3
  OS: darwin x64

  Angular: 9.1.12
  ... animations, cli, common, compiler, compiler-cli, core, forms
  ... language-service, platform-browser, platform-browser-dynamic
  ... router, service-worker
  Ivy Workspace: Yes

  Package                           Version
  -----------------------------------------------------------
  @angular-devkit/architect         0.901.12
  @angular-devkit/build-angular     0.901.12
  @angular-devkit/build-optimizer   0.901.12
  @angular-devkit/build-webpack     0.901.12
  @angular-devkit/core              9.1.12
  @angular-devkit/schematics        9.1.12
  @angular/cdk                      9.2.4
  @angular/material                 9.2.4
  @angular/pwa                      0.900.7
  @ngtools/webpack                  9.1.12
  @schematics/angular               9.1.12
  @schematics/update                0.901.12
  rxjs                              6.5.5
  typescript                        3.8.3
  webpack                           4.42.0

We are also using an angular.json file which has different configurations/properties for the two projects (controller & controller-cap - controller being the project that we're migrating the platform folders to)

sdunnin commented 2 years ago

I work with snguyen23 and we have finally reached a point where we are able to commit the time and resources to upgrading our app dev stack. We are close to completing upgrading to Angular 12 and latest Nx. Once that is complete I am going to tackle getting Capacitor to latest (3.3.2) along with nxtend/capacitor.

@devinshoemaker Are there any considerations or gotchas you are aware of getting this lib updated along with Capacitor. Do you think it would be better to start over with a clean implementation of Capacitor for our app rather than the migration steps previously attempted by snguyen23?

devinshoemaker commented 2 years ago

@sdunnin you shouldn't have any issues. @nxtend/capacitor v12 has been released and @nxtend/ionic-angular should be released within a few days. The official Capacitor 3 migration guide should be sufficient for updating the Capacitor portion of your project.

https://capacitorjs.com/docs/updating/3-0

sdunnin commented 2 years ago

I'm experimenting with a clean install of latest Nx/Capacitor/nxtend just to get a feel for build workflow with latest version of the tools. Encountering this issue with init:

$ npx nx generate @nxtend/capacitor:init
Unable to resolve @nxtend/capacitor:init.
Cannot find generator 'init' in C:\Users\sdunning.DOMAIN\Documents\Development\Angular\cap-test\test\node_modules\@nxtend\capacitor\generators.json.
sdunnin commented 2 years ago

I can init, sync, and open in native IDE using the Capacitor CLI. Just can't seem to get anywhere with the nxtend/capacitor plugin. nx generate @nxtend/capacitor:capacitor-project --project mobile which I think maybe creates a capacitor.config in the app directory rather than at project root gives the following result:

$ npx nx generate @nxtend/capacitor:capacitor-project --project mobile
√ What app ID would you like to use? · io.ionic.starter
√ What app name would you like to use? · mobileapp
Cannot set property 'mobile' of undefined

A bit stuck at this point. @devinshoemaker any words of wisdom would be greatly appreciated.

sdunnin commented 2 years ago

Been looking at the @nxtend/capacitor source to see if I could figure out the property set issue. I'm pretty sure it's somewhere in the capacitor-project generator.ts but hard to tell which called function within capacitorProjectGenerator might be the source. They are all using nrwl/devkit in some fashion to make updates and I don't have any understanding of exactly what they are doing without digging down further into source.

sdunnin commented 2 years ago

After some painstaking manual logging in node_modules I've tracked down what might be an issue??

nxtend has a dev dependency of "@nrwl/devkit": "12.8.0" where setProjectConfiguration in project-configuration.js is still looking for the presence of nx.json. The current version of that function no longer processes nx.json

The current version of Nx 13.x appears to enforce project configuration in workspace.json rather than nx.json, hence why there was no project config in my nx.json. If I manually add "projects" property to nx.json to try and satisfy the code constraint Nx generates this error:

 ERROR  As of Nx 13, project configuration should be moved from nx.json to workspace.json/project.json. Please run "nx format" to fix this.

It appears as if the current version of nxtend has package dependencies that will not work with latest Nx? It looks like that is something you are still working on in https://github.com/nxtend-team/nxtend/issues/540

P.S. @devinshoemaker Thanks for everything you are doing on this project and sorry to be a pest.

sdunnin commented 2 years ago

We've successfully migrated to Nx/Angular 12 and Capacitor 3 all working with nxtend/capacitor. From my perspective this issue can probably be closed.