nstudio / xplat

Cross-platform (xplat) tools for Nx workspaces.
MIT License
365 stars 52 forks source link

NX 13.4 - can't gen app (serializeJson not a function) #287

Closed wstidolph closed 2 years ago

wstidolph commented 2 years ago

Create a brand new 'empty' workspace (NX ver 13.4.1), install xplat, attempt to generate app (tried both ionic, and plain web/angular):

❯ npx create-nx-workspace@latest upper
✔ What to create in the new workspace · apps
✔ Use Nx Cloud? (It's free and doesn't require registration.) · No

>  NX  Nx is creating your v13.4.1 workspace.

  To make sure the command works reliably in all environments, and that the preset is applied correctly,
  Nx will run "npm install" several times. Please wait.

✔ Installing dependencies with npm
✔ Nx has successfully created the workspace.

———————————————————————————————————————————————

>  NX   NOTE  First time using Nx? Check out this interactive Nx tutorial.

  https://nx.dev/getting-started/nx-core

❯ cd upper
❯ npm i @nstudio/xplat -D

added 34 packages, and audited 559 packages in 2s

❯ npm install

up to date, audited 559 packages in 866ms

❯ 
❯ ng g app
The generate command requires to be run in an Angular project, but a project definition could not be found.
❯ nx g app compariview
✔ What type of app would like to create? · ionic
✔ In which directory should the app be generated? (Just press Enter for the default: directly in 'apps') · 
✔ Would you like to configure routing for this app? (Y/n) · true
✔ Which frontend framework should it use? · angular
✔ Use xplat supporting architecture? (Y/n) · true
SchematicsException [Error]: package.json: TypeError: workspace_1.serializeJson is not a function
    at Object.updateJsonFile (/home/wstidolph/dev/tmp/upper/node_modules/@nstudio/xplat-utils/src/utils/utils.js:86:15)
    at /home/wstidolph/dev/tmp/upper/node_modules/@nstudio/xplat/src/utils/xplat.js:583:42
    at /home/wstidolph/dev/tmp/upper/node_modules/@nstudio/xplat/src/utils/xplat.js:276:19
    at MergeMapSubscriber.project (/home/wstidolph/dev/tmp/upper/node_modules/@angular-devkit/schematics/src/rules/call.js:75:24)
    at MergeMapSubscriber._tryNext (/home/wstidolph/dev/tmp/upper/node_modules/rxjs/internal/operators/mergeMap.js:67:27)
    at MergeMapSubscriber._next (/home/wstidolph/dev/tmp/upper/node_modules/rxjs/internal/operators/mergeMap.js:57:18)
    at MergeMapSubscriber.Subscriber.next (/home/wstidolph/dev/tmp/upper/node_modules/rxjs/internal/Subscriber.js:66:18)
    at Observable._subscribe (/home/wstidolph/dev/tmp/upper/node_modules/rxjs/internal/util/subscribeToArray.js:5:20)
    at Observable._trySubscribe (/home/wstidolph/dev/tmp/upper/node_modules/rxjs/internal/Observable.js:44:25)
    at Observable.subscribe (/home/wstidolph/dev/tmp/upper/node_modules/rxjs/internal/Observable.js:30:22)
package.json: TypeError: workspace_1.serializeJson is not a function
❯ node --version
v16.13.0
NathanWalker commented 2 years ago

Thanks for reporting this @wstidolph - likely a modified api with 13.4.x series. I'll investigate and put a minor version out with a fix in next couple days. In meantime you can use prior minor version:

npx create-nx-workspace@13.3.12 upper
NathanWalker commented 2 years ago

closed via https://github.com/nstudio/xplat/pull/288 published with @nstudio/xplat 13.4.x

wstidolph commented 2 years ago

Thanks - this is great!

Just FYI, on repeating above to create an Ionic app I get:

[NX] Angular devkit called `writeWorkspace`, this may have had unintended consequences in workspace.json
[NX] Double check workspace.json before proceeding

To my eye, workspace.json looks sane, and the generated app runs as expected.

NathanWalker commented 2 years ago

I noticed that, looks to be harmless warning. Nx has moved to @nrwl/devkit as a wrapper around angular's devkit and we're currently revamping all these tools to use @nrwl/devkit solely and no longer use angular's devkit directly which will probably make that warning go away in future.