nstudio / xplat

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

nx.json and workspace.json are out of sync #237

Closed NathanWalker closed 3 years ago

NathanWalker commented 3 years ago

A race condition can cause this to occur when calling externalSchematic in a chain with schematics. If you encounter this you might share the commands you ran which led to it as we are investigating the condition.

beeman commented 3 years ago

I saw the same issue as Chau and figured I'd create a Dockerfile that illustrates it (also to make sure it's nothing machine related)

If you save this content in a file cakked Dockerfile, then run docker build ., the error will appear:

FROM node:14-alpine

WORKDIR /workspace

RUN npm install -g @nrwl/cli create-nx-workspace nativescript

RUN npx create-nx-workspace ns-test --preset empty --no-nx-cloud

WORKDIR /workspace/ns-test

RUN npm install -D @nstudio/xplat

RUN nx generate @nstudio/xplat:application native --platforms nativescript  --routing

RUN nx ios nativescript-native
$ docker build .
[+] Building 3.6s (12/12) FINISHED
 => [internal] load build definition from Dockerfile                                                                         0.1s
 => => transferring dockerfile: 432B                                                                                         0.0s
 => [internal] load .dockerignore                                                                                            0.0s
 => => transferring context: 2B                                                                                              0.0s
 => [internal] load metadata for docker.io/library/node:14-alpine                                                            1.3s
 => [1/9] FROM docker.io/library/node:14-alpine@sha256:2ae9624a39ce437e7f58931a5747fdc60224c6e40f8980db90728de58e22af7c      0.0s
 => CACHED [2/9] WORKDIR /workspace                                                                                          0.0s
 => CACHED [3/9] RUN npm install -g @nrwl/cli create-nx-workspace nativescript                                               0.0s
 => CACHED [4/9] RUN npx create-nx-workspace ns-test                                                                         0.0s
 => CACHED [5/9] RUN npx create-nx-workspace ns-test --preset empty --no-nx-cloud                                            0.0s
 => CACHED [6/9] WORKDIR /workspace/ns-test                                                                                  0.0s
 => CACHED [7/9] RUN npm install -D @nstudio/xplat                                                                           0.0s
 => CACHED [8/9] RUN nx generate @nstudio/xplat:application native --platforms nativescript  --routing                       0.0s
 => ERROR [9/9] RUN nx ios nativescript-native                                                                               2.1s
------
 > [9/9] RUN nx ios nativescript-native:
#12 2.064
#12 2.068 >  NX   ERROR  Configuration Error
#12 2.069
#12 2.069   workspace.json and nx.json are out of sync. The following projects are missing in workspace.json: xplat-nativescript-scss, xplat-nativescript-utils, xplat-nativescript-core, xplat-nativescript-features, xplat-core, xplat-features, xplat-scss, xplat-utils
#12 2.069
------
executor failed running [/bin/sh -c nx ios nativescript-native]: exit code: 1
NathanWalker commented 3 years ago

This is fixed in 11.0.18 now with standard instructions (no need to init platforms):

npx create-nx-workspace@latest

npm install @nstudio/xplat -D

nx generate app

Also, if you're curious with Electron you can generate electron app by targeting any web app in workspace, for example:

nx g app tasks

Choose 'web' to create a standard web app in workspace.

Now you can target it for electron:

nx g app desktop --target=web-tasks

Choose 'electron' to create it, then run npm install to ensure the electron dependencies all get installed.

You'll see the run command print out at top of generation but you can start it given example above with:

npm run start.electron.desktop
m-kashif commented 3 years ago

i will recommend to change following from from ng with nx "build.electron.desktop": "yarn run prepare.electron.desktop && ng build electron-desktop --prod --base-href ./",

"build.electron.desktop": "yarn run prepare.electron.desktop && nx build electron-desktop --prod --base-href ./",

i was getting error The build command requires to be run in an Angular project, but a project definition could not be found.

and also need to add -c.electronVersion=11.1.0 -c.asar=true for building of windows version

"build.electron.desktop.windows": "yarn run build.electron.desktop && cd dist/apps/electron-desktop && npx electron-builder build -c.electronVersion=11.1.0 -c.asar=true --windows",

without this change was getting below error Cannot compute electron version from installed node modules - none of the possible electron modules are installed. See https://github.com/electron-userland/electron-builder/issues/3984#issuecomment-504968246 error Command failed with exit code 1.