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: Add automation script to generate component #1039

Merged
merged 9 commits into from
Dec 3, 2021

Conversation

ArthurTriis1
Copy link
Contributor

@ArthurTriis1 ArthurTriis1 commented Nov 30, 2021

What's the purpose of this pull request?

We noticed that every time we wanted to create a new component, we created many new files. So, we thought it might be a good idea to generate these default templates automatically. It will help our development experience and we can waste less time making the "boilerplates files" and jump into the component itself, decreasing the chances of forgetting to update/create a file.

We are using Plop framework to generate those files.

How it works?

  • run yarn generate
# What is your component name? 

ComponentName

#  What is your component atomic group?  (Use arrow keys)

> atoms 
> molecules 
> organisms
  • it will create all the base files with the component given name;

  • It will create a folder for the component under its atomic group;

  • Files generated automatically:

✔  ++ faststore/packages/ui/src/atoms/ComponentName/ComponentName.tsx
✔  ++ faststore/packages/ui/src/atoms/ComponentName/index.tsx
✔  ++ faststore/themes/theme-b2c-tailwind/src/atoms/component-name.css
✔  ++ faststore/packages/ui/src/atoms/ComponentName/ComponentName.test.tsx
✔  ++ faststore/packages/ui/src/atoms/ComponentName/stories/ComponentName.stories.tsx
✔  ++ faststore/packages/ui/src/atoms/ComponentName/stories/ComponentName.mdx
✔  _+ faststore/packages/ui/src/index.ts

And that is it! You will be ready to work on your component. 🎉

  • For the component name, please follow CamelCase pattern, and do not use -, i.e, Component-Name
  • Please try to not rename // Atoms, // Molecules, // Organisms on packages/ui/scr/index.ts file, because we are using it as pattern to update it.

We are using templates files just with the base structure according to what we find helpful to have. You can take a look into it on generators/templates folder.

Are you missing any files? Or is there anything else we can generate automatically? Any suggestions? Please, feel free to leave a comment below 🙃

References

  • Plop js: "micro-generator framework"

Signed-off-by: Arthur Andrade <arthurfelandrade@gmail.com>
Signed-off-by: Arthur Andrade <arthurfelandrade@gmail.com>
@ArthurTriis1 ArthurTriis1 requested a review from a team as a code owner November 30, 2021 16:30
@netlify
Copy link

netlify bot commented Nov 30, 2021

✔️ Deploy Preview for faststoreui ready!

🔨 Explore the source changes: c9d1aac

🔍 Inspect the deploy log: https://app.netlify.com/sites/faststoreui/deploys/61a8dc928b80ea00077bfb29

😎 Browse the preview: https://deploy-preview-1039--faststoreui.netlify.app

@codesandbox-ci
Copy link

codesandbox-ci bot commented Nov 30, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit c9d1aac:

Sandbox Source
Store UI Typescript Configuration

@hellofanny hellofanny added the enhancement New feature or request label Nov 30, 2021
@ArthurTriis1 ArthurTriis1 marked this pull request as draft November 30, 2021 17:10
@hellofanny hellofanny changed the title Feat/add automation to generate component Feat: Add automation script to generate component Nov 30, 2021
@hellofanny
Copy link
Contributor

Is there any readme file that we can add this information? 👀

@ArthurTriis1 ArthurTriis1 marked this pull request as ready for review November 30, 2021 22:55
@tlgimenes
Copy link
Contributor

Is there any readme file that we can add this information? 👀

Maybe add it on contributing.md?

Copy link
Contributor

@tlgimenes tlgimenes left a comment

Choose a reason for hiding this comment

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

AMAZING WORK! 🎉🎉🎉

@igorbrasileiro
Copy link
Contributor

😲 Good addition @ArthurTriis1 !! Can you add a brief instruction inside the docs/component-architecture.md ?

Copy link
Contributor

@lucasfp13 lucasfp13 left a comment

Choose a reason for hiding this comment

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

Great job, guys! 🎉

Copy link
Contributor

@lariciamota lariciamota left a comment

Choose a reason for hiding this comment

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

Nice!! 🚀

CONTRIBUTING.MD Outdated Show resolved Hide resolved
CONTRIBUTING.MD Outdated Show resolved Hide resolved
CONTRIBUTING.MD Outdated Show resolved Hide resolved
CONTRIBUTING.MD Outdated Show resolved Hide resolved
generators/templates/Component.tsx.hbs Outdated Show resolved Hide resolved
hellofanny and others added 5 commits December 1, 2021 18:23
Co-authored-by: Larícia Mota <laricia.mota@vtex.com.br>
Co-authored-by: Larícia Mota <laricia.mota@vtex.com.br>
Co-authored-by: Larícia Mota <laricia.mota@vtex.com.br>
Co-authored-by: Larícia Mota <laricia.mota@vtex.com.br>
Co-authored-by: Larícia Mota <laricia.mota@vtex.com.br>
package.json Show resolved Hide resolved
@hellofanny
Copy link
Contributor

😲 Good addition @ArthurTriis1 !! Can you add a brief instruction inside the docs/component-architecture.md ?

@ArthurTriis1 Actually, I think we can move the instruction from CONTRIBUTING.MD to *docs/component-architecture.md. It makes more sense. 🤔

generators/templates/Component.tsx.hbs Outdated Show resolved Hide resolved
generators/templates/Component.tsx.hbs Outdated Show resolved Hide resolved
generators/templates/Component.tsx.hbs Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
@ArthurTriis1 ArthurTriis1 force-pushed the feat/add-automation-to-generate-component branch from 99c4738 to 501cfdf Compare December 2, 2021 14:33
Signed-off-by: Arthur Andrade <arthurfelandrade@gmail.com>
@ArthurTriis1 ArthurTriis1 force-pushed the feat/add-automation-to-generate-component branch from 501cfdf to c9d1aac Compare December 2, 2021 14:47
Copy link
Contributor

@saranicoly saranicoly left a comment

Choose a reason for hiding this comment

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

Great job guys! It will be very useful.

@ArthurTriis1 ArthurTriis1 merged commit d3e54a2 into master Dec 3, 2021
@ArthurTriis1 ArthurTriis1 deleted the feat/add-automation-to-generate-component branch December 3, 2021 13:54
@eduardoformiga
Copy link
Member

Really good job here, @ArthurTriis1

Do we still need to work? hahaha

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

Successfully merging this pull request may close these issues.

9 participants