Adding nx-deploy-it plugin results in error
Describe the bug When I follow the installation instructions precisely (either from the README or from https://medium.com/dev-thought/introducing-nx-deployit-e5cfe89b810c), I get an error https://medium.com/dev-thought/introducing-nx-deployit-e5cfe89b810c
To Reproduce Steps to reproduce the behavior:
1 Install pulumi (version 2.25) and azure CLI, login to Azure (not sure if this step is necessary, but did it anyway)
2. Run npx create-nx-workspace@latest advanced-deployments --preset="angular-nest" --appName="i-love-iac" --style="scss"
3. Run npx nx add @dev-thought/nx-deploy-it
- Select both projects (i-love-iac and api)
- Chose Azure with switzerlandnorth (others wouldn't work either)
- Exits with an error Can not find generated pulumi package.json, only adding
@dev-thought/nx-deploy-itdependency to package.json, nothing more
Expected behavior I would expect the plugin to be installed and configure the pulumi deployment files
Logs
Here's the output from the nx add:
PS C:\prog\projects\inftec\testing\advanced-deployments> npx nx add @dev-thought/nx-deploy-it
ℹ Using package manager: npm
✔ Found compatible package version: @dev-thought/[email protected].
✔ Package information loaded.
✔ Package successfully installed.
We found 2 supported applications.
√ Please select the applications you want to setup. If you don't select one, you will skip this process and you can do it later again. · i-love-iac (angular), api (nestjs)
√ provider · Azure
√ The Azure location to deploy into: · switzerlandnorth
Can not find generated pulumi package.json
PS C:\prog\projects\inftec\testing\advanced-deployments>
It exits with Can not find generated pulumi package.json
Application type: [x] Angular [x] NestJS
Provider: [] AWS [x] Azure [] Google Cloud Platform
nx-deploy-it version 2.0.0
Version of nx: 12.0.8
Additional context I've looked at https://github.com/Dev-Thought/nx-deploy-it-examples and saw that it has the 'infrastructure' sub folders in the app folders.
I've also seen where the error is output: https://github.com/Dev-Thought/nx-plugins/blob/fc36f07a973f9899cb966023e874b8b8a765d6fa/libs/nx-deploy-it/src/schematics/init/schematic.ts#L68 But I don't understand why it's not working...
btw, I've also tried with version 1.4.0 of the nx-deploy-it plugin as this is the one used int he examples. But that version would result in an error Cannot read property 'toString' of null.
Am I missing some prerequisites that are not documented properly?
Ok, I looked deeper into the code and found the following problems (btw, I'm running on Windows 64bit...)
-
pulumi-npm: The way the bin is registered on my machine will execute the
./src/pulumi-wrapper.jsin thesrcfolder, i.e.__dirnamewill be...pulumi-npm/src. However, the binary is installed to...pulumi-npm/tools/.... Currently, the wrapper will expect tools to be within src and it will fail. Can be easily reconstructed withnpx pulumiwhich will result in an error - The way the pulumi binaray is resolved in https://github.com/Dev-Thought/nx-plugins/blob/fc36f07a973f9899cb966023e874b8b8a765d6fa/libs/nx-deploy-it/src/utils/workspace.ts#L23 does not work on Windows. On windows, the correct file name will be
pulumi.cmdand notpulumi. Obviously, there is no proper error handling when the command is called, resulting in nothing being executed and obviously it won't create theinfrastructure/package.jsoneither, resulting in the error message I was experiencing when following the instructions
With pulumi.cmd it is working for you?
The generation of the infrastructure is working with the two manual fixes described above (pulumi-npm tools path and .cmd extension).
However, I ran in another issue when executing npx ng run api:deploy. I was creating the nx workspace with the latest version 12.0.8 and I guess there is a breaking change here: https://github.com/Dev-Thought/nx-plugins/blob/master/libs/nx-deploy-it/src/utils/workspace.ts#L83
It looks like the 12.0.8 version of @nrwl/tao/src/shared/workspace.js does not allow for path to be undefined, eventually resulting in an error The "path" argument must be of type string. Received undefined
See https://github.com/nrwl/nx/blob/master/packages/tao/src/shared/workspace.ts#L258 (if this.root is undefined, it won't work. And in this case, the value will come from the invocation in nx-deploy-it referenced above...
I guess nx-deploy-it doesn't support nx 12.0 yet?
also having the same problem. getting the "Can not find generated pulumi package.json" when I try to deploy on AWS. Is there a patch or workaround for this to work? Is there a manual guide how to deploy the mono repo if I cant use nx-deploy-it plugin?
Not sure if this is still an issue, will close it as it's gotten quite old...