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

Adding logic for React modules in create command #44

Closed
wants to merge 8 commits into from

Conversation

TanyaScales
Copy link
Member

@TanyaScales TanyaScales commented Jan 11, 2024

Description and Context

With the advent of React modules being used in the CMS at HubSpot -- there is a need to include the ability to quickly scaffold a React module from the hs create module command.

This PR adds logic so that a dev can call hs create module and within the creation prompt, a new question has been added for creating a React type module. If this is selected, then the command will pull from the React sample asset in the cms-sample-assets repo.

There is also some refining of the code after a React module has been downloaded to add the meta data information to the index.tsx file -- Additionally, if the internal flag is passed, there are some regex replacements that happen to include some bits of code required by our internal team, as well as some additional files downloaded from the sample asset repo that pertain more to them.

Screenshots

Loom of the command: https://www.loom.com/share/ea1e16ea73d946d685af94223a522bec?sid=8b5a1ee8-ceaf-49f6-b75f-1438c0e2d647

TODO

modules.js Show resolved Hide resolved
@TanyaScales TanyaScales requested review from jsines and j-malt January 12, 2024 16:00
Copy link

@bran-van-d bran-van-d left a comment

Choose a reason for hiding this comment

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

Looks great, thanks for the Loom showcasing it!

I realize this isn't documented anywhere right now and our repos currently have a mixed state of react-modules and jsr-modules -- we want to move towards react-modules broadly as "JSR" is an internal acronym and we find that "react-modules" are more a bit more clear.

modules.js Outdated Show resolved Hide resolved
modules.js Outdated Show resolved Hide resolved
@j-malt
Copy link

j-malt commented Jan 12, 2024

Has there been any discussion around supporting JSX files in the create as well?

I don't think every developer uses Typescript for their JSR repos right now. For example the hello world repo is still predominantly written in JSX.

Copy link

@j-malt j-malt left a comment

Choose a reason for hiding this comment

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

Few comments, looks good.

modules.js Outdated Show resolved Hide resolved
modules.js Show resolved Hide resolved
modules.js Outdated Show resolved Hide resolved
@TanyaScales
Copy link
Member Author

Has there been any discussion around supporting JSX files in the create as well?

I don't think every developer uses Typescript for their JSR repos right now. For example the hello world repo is still predominantly written in JSX.

Its a good question - I don't think there has been a ton of discussion around this -- With this particular request coming from the internal team. We should consider this. Maybe a follow up to this would be to add a question to the prompt if a React module is created to ask about it being TS or not.

@TanyaScales
Copy link
Member Author

New issue created here for JSX module support: https://git.hubteam.com/HubSpot/hubspot-cli-issues/issues/498

* @param {object} metaData - an object containing the module's metadata
*/

const transformFileContents = (file, metaData, getInternalVersion) => {
Copy link

Choose a reason for hiding this comment

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

Is there an issue here where this function is doing async callbacky things bu there is no returned promise of async/await handling?

@TanyaScales
Copy link
Member Author

Closing out as the CLI was migrated to local-dev-lib and changes have been ported over there to mirror this PR

@TanyaScales TanyaScales closed this Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants