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

feat(generators): support for component subdirectory #2285

Merged
merged 8 commits into from
Mar 29, 2023

Conversation

frankcalise
Copy link
Contributor

@frankcalise frankcalise commented Nov 2, 2022

Please verify the following:

  • yarn test jest tests pass with new tests, if relevant
    • No subdirectory passes
    • Subdirectory generated, relative paths unneeded by adding TS absolute path alias
  • README.md has been updated with your changes, if relevant

Describe your PR

  • Closes Generate a component in specific path/subfolder #1746
  • Supports components to be generated in a subdirectory
  • Supplies frontmatter props with subdirectory (to extend other templates)
  • Added test to check the output of both root components and subdirectory nested components
  • Updated documentation for new prop

image

image

@frankcalise
Copy link
Contributor Author

frankcalise commented Nov 2, 2022

@kateinkim @joshuayoes @jamonholmgren

Any suggestions here to solve the relative path import back to the Text component and theme imports?

I could of course clear out the Text component and remove the associated style.

How do we feel about adding a prop for relativeThemesPath and relativeComponentsPath?

@joshuayoes
Copy link
Contributor

Instead of adding multiple props, what if we just included one relativeAppPath prop? Then we wouldn't need to add props for each app subdirectory

It would make the paths a little more verbose than necessary in the output, but I think it would be more clear writing them in the generator file.

The generator would look something like this:

import { colors, typography } from "<%= props.relativeRootPath %>/theme/colors"
import { Text } from "<%= props.relativeRootPath %>/components/Text"

The test case generate component sub/to/my/Topping would output this:

/app/components/sub/to/my/Topping.tsx

import { colors, typography } from "../../../../../theme/colors"
import { Text } from "../../../../components/Text"

Then the user can manually update it if it bother them

@joshuayoes
Copy link
Contributor

I think the alternative solution here would be to add typescript alias paths to ignite

@frankcalise
Copy link
Contributor Author

I think the alternative solution here would be to add typescript alias paths to ignite

Ah right, which I did in a cookbook recipe. Good thought also.

@kateinkim
Copy link
Contributor

@frankcalise Sorry I'm not feeling so great right now so I might be missing something but I'm not really clear on the distinction we're making here between subdirectory and destinationDir (example here). It seemed like #1746 would be resolved with the existing destinationDir except maybe allowing it to be overwritten via CLI.

@frankcalise
Copy link
Contributor Author

@frankcalise Sorry I'm not feeling so great right now so I might be missing something but I'm not really clear on the distinction we're making here between subdirectory and destinationDir (example here). It seemed like #1746 would be resolved with the existing destinationDir except maybe allowing it to be overwritten via CLI.

Don't be sorry @kateinkim! You are correct in that destinationDir does tell the generator where to stash the new file. From what I gathered in #1746 (and I could be interpreting incorrectly), is that since we were considering the CLI parameter in some fashion that it would be more dynamic then just changing destinationDir each time you were going to generate a component.

@jamonholmgren want to weigh in here?

@joshuayoes
Copy link
Contributor

joshuayoes commented Nov 23, 2022

I wrote another draft PR of an idea to make implementing this easier: #2317

If we go with using a tool like zx with generators, this could potentially be thrown in the ignite cookbook

@frankcalise frankcalise marked this pull request as ready for review March 14, 2023 15:31
Copy link
Contributor

@joshuayoes joshuayoes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good! I'm a fan of the ~/ alias.

Copy link
Member

@jamonholmgren jamonholmgren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@frankcalise frankcalise merged commit 84c5c69 into master Mar 29, 2023
@frankcalise frankcalise deleted the feat-1746/subfolder-path branch March 29, 2023 02:24
infinitered-circleci pushed a commit that referenced this pull request Mar 29, 2023
# [8.6.0](v8.5.2...v8.6.0) (2023-03-29)

### Features

* **generators:** support for component subdirectory ([#2285](#2285) by [@frankcalise](https://github.com/frankcalise)) ([84c5c69](84c5c69))
@infinitered-circleci
Copy link

🎉 This PR is included in version 8.6.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generate a component in specific path/subfolder
6 participants