trumbitta / nx-trumbitta

💡An attempt to start collecting all of my Nx-related Open Source work in a mono-repo.
MIT License
47 stars 11 forks source link

Running Target Failed for Both Client Sources & Docs #21

Closed dapperdandev closed 3 years ago

dapperdandev commented 3 years ago

I'm unable to get this to work on Windows, even using just the sample spec.

Environment

Output

⚡ DanielBreen@DBREENBC  C:\..\..\app   master ≢ +3 ~5 -0 ! nx generate @trumbitta/nx-plugin-openapi:api-spec
√ What name would you like to use? · test-spec
√ Do you want me to also create a sample spec file for you? (y/N) · true

UPDATE angular.json
UPDATE nx.json
CREATE libs/test-spec/src/test-spec.openapi.yml
⚡ DanielBreen@DBREENBC  C:\..\..\app   master ≢ +4 ~5 -0 ! nx generate @trumbitta/nx-plugin-openapi:api-lib
√ What name would you like to use? · test-lib
√ Which OpenAPITool generator would you like to use? (https://github.com/OpenAPITools/openapi-generator) · typescript-fetch
√ Is the API spec file published online? (y/N) · false
√ If it's online, what's the URL where I can get the API spec file from? · 
√ If it's online, which authorization headers do you need to add? ·
√ If it's local, what's the name of the lib containing the API spec file? · test-spec
√ If it's local, what's the path of the API spec file starting from the lib root? · src/test-spec.openapi.yml
√ Do you want to specify any additional properties for the generator? key1=value1,key2=value2 (https://openapi-generator.tech/docs/generators) · 
UPDATE angular.json
UPDATE nx.json
CREATE libs/test-lib/README.md
UPDATE tsconfig.base.json     
⚡ DanielBreen@DBREENBC  C:\..\..\app   master ≢ +5 ~5 -0 ! nx run test-lib:generate-sources   

> nx run test-lib:generate-sources 
Deleting outputDir libs/test-lib/src...
Done deleting outputDir libs/test-lib/src.

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

>  NX   ERROR  Running target "test-lib:generate-sources" failed

  Failed tasks:

  - test-lib:generate-sources

Updated 5-26-2021: Include environment details

trumbitta commented 3 years ago

Hey @djbreen7 thanks for taking the time to submit this report 🙏

I'm going to take a look at it and see if I can fix it.

We recently had to update the plugin to Nx 11+ and it wasn't as easy as expected so I was really hoping for someone to spot bugs we didn't spot ourselves :D

trumbitta commented 3 years ago

@djbreen7 Ok, I tried a couple times with the same values from your report but I couldn't reproduce the issue, and every time I was able to generate the sources.

Question time:

Commands: version-manager Manage used / installed generator version author Utilities for authoring generators or customizing templates. batch Generate code in batch via external configs. config-help Config help for chosen lang generate Generate code with the specified generator. help Display help information about openapi-generator list Lists the available generators meta MetaGenerator. Generator for creating a new template set and configuration for Codegen. The output will be based on the language you specify, and includes default templates to include. validate Validate specification version Show version information used in tooling

❯ node_modules/.bin/openapi-generator-cli version 5.1.1

dapperdandev commented 3 years ago

@trumbitta No problem!

Here's everything I can answer in Windows. I'll boot into mac and see what happens.

Can you create a repo here on GitHub with a Nx workspace where this error happens?

https://github.com/djbreen7/nx-openapi-test

Which node and npm version are you using?

Which version of Nx, and of the plugin, are you using?

Right after nx run test-lib:generate-sources fails, can you please check if /node_modules/.bin/openapi-generator-cli exists and if it's executable?

Yes, this is executable

dapperdandev commented 3 years ago

@trumbitta

I develop and test on a Mac. I see you are using Windows. Do you have access to a Mac or Linux machine to try again?

This worked fine for me on Mac.

I have this repo cloned. If I get some time, I'll try to Dx.

dapperdandev commented 3 years ago

@trumbitta

The problem definitely happens here: const child = childProcess.spawn('node_modules/.bin/openapi-generator-cli', args); https://github.com/trumbitta/nx-trumbitta/blob/main/packages/nx-plugin-openapi/src/executors/generate-api-lib-sources/executor.ts#L77

Opening a PR.

It's pretty small. Definitely double-check everything.

trumbitta commented 3 years ago

Thanks @djbreen7 , I'm trying to find the time to review your much welcomed contributions :)