Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto path flag broken in latest version (17.5.0) #1086

Closed
ConnerEnders opened this issue Jun 16, 2021 · 13 comments · Fixed by #1112
Closed

Auto path flag broken in latest version (17.5.0) #1086

ConnerEnders opened this issue Jun 16, 2021 · 13 comments · Fixed by #1112
Labels
type: bug Something isn't working

Comments

@ConnerEnders
Copy link

When generating new schematics from the context menu in the file explorer, the path flag is no longer filled out with the correct path.

@ConnerEnders ConnerEnders changed the title Auto path flag broken in latest version Auto path flag broken in latest version (17.5.0) Jun 16, 2021
@Cammisuli
Copy link
Member

Cammisuli commented Jun 16, 2021

Yea, this is expected. We check if there's project option, and if there is, then we don't pre-fill the path. We had to do this because all the different ways generators use the path/directory option.

For example:

  • if we do @nrwl/angular:lib|app or @nrwl/react:library|application, etc. then we need to prefill the path
  • if we do @schematics/angular:component the path is expected to be relative to the root of the workspace (so it needs the whole path).
  • If we do @nrwl/react:component the path is expected to be relative to the project; so if we used the whole path then we would have something generated like this: libs/my-react-lib/libs/my-react-lib/src/my-component.
  • Then finally if we do @nestjs/schematic:controller we need to make sure that the full path is there. But if we use @nrwl/nestjs:controller, then the project option is there, and we don't pre-fill the path.

I hope that clears it up a bit for you 😅

Btw, what generator are you trying to use?

@ConnerEnders
Copy link
Author

Oh I didn't realize there were so many uses for this tool, I should have been more specific!

I am mainly using it for angular schematics, but I noticed the path was missing while generating components, so @schematics/angular:component

So you're saying the path should be missing for that schematic? If so, how was it working before the latest version? And is there any way I could get that behavior back?

@Cammisuli
Copy link
Member

It was working before because the angular schematic expected the full relative path to the workspace root. When we generated from the context menu, we always got the full path, and it worked well for the angular schematic.

So because the angular schematic has the project option (you should see that your project is prefilled when choosing this), the path isn't filled out anymore. We had to do this because of all the different use cases.

We could probably have a special case to see if the schematic is @schematics/angular and just put the path in there too.

@JanOschii
Copy link

JanOschii commented Jun 20, 2021

To be clear, this was the main benefit of using your extension in VSCode with angular for me.
Left mouse on the folder + "ng-generate" + component.
Some settings > done.

Now I have to copy the path manually before. The problem is (at least on windows) the path is written with back-slashes and not forward slashes. To correct the path everytime is more work than going on with the old way and using the cli again.

UPDATE: I found a workaround for the forward-slash-problem.
I use the "Copy Relative Path" extension from "alexdima". This extension is always using the forward slashes.

@Cammisuli
Copy link
Member

Ok, we'll add a check to see if the schematics/generators are angular, use the old behaviour. 👍🏼

@Cammisuli Cammisuli added the type: bug Something isn't working label Jun 21, 2021
@ianvink
Copy link

ianvink commented Jul 14, 2021

Great project. Thank you.

I would like to add my vote to add back, in some way, the Path when creating a component. I used that 99% of the time. It's super helpful. The number 1 reason I use the tool.
image

@Cammisuli
Copy link
Member

The component generation shouldn't have been affected... 🤔 We'll double check on that as well

@ianvink
Copy link

ianvink commented Jul 15, 2021

17.4.1 was the last version where the path was populated on my machine.

thank you for a wonderful project, truly a life saver in terms of time and speed.

@ImCesar
Copy link

ImCesar commented Jul 15, 2021

We were taking advantage of this for custom generators we built as well. It made it easy to generate things in place of the context menu. Maybe there could be some field we could add to the schema.json file to opt in to this behavior?

@dannymcgee
Copy link

As of today's update this seems to no longer be working for @schematics/angular:component. Weirdly enough, I'm not seeing the path field in the form at all anymore, so I can't even manually copy/paste it over. I'm basically stuck using the CLI like some sort of caveman. 🙂

@Cammisuli
Copy link
Member

@dannymcgee can you create a new issue with details of your workspace (angular only, angular+nx, nx only), versions of all those, and OS. Thank you!

@Cammisuli
Copy link
Member

nvm @dannymcgee I have a fix up with #1192, it should be released with 17.3.1

@dannymcgee
Copy link

nvm @dannymcgee I have a fix up with #1192, it should be released with 17.3.1

Beat me to it — thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants