-
Notifications
You must be signed in to change notification settings - Fork 1k
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(RedwoodUI) Add setup command for RedwoodUI #11596
base: main
Are you sure you want to change the base?
Conversation
… well, but this is good start
…e same array we were iterating over. Silly me, lol. Fixed, and also fixed some logging.
When you're getting ready to start writing tests for all of this, I think this will be useful to you: |
…dded TODOs for adding it back later on
…oponent + adding a file alongside its dependencies
…uto-installing packages
…g mods are finally nearly working
) | ||
const objectName = namedExportMatch[1] | ||
const namedObjectRegex = new RegExp( | ||
`(const|let|var)\\s+${objectName}(?:\\s*:\\s*[^=]+)?\\s*=\\s*({(?:[^{}]*|\{(?:[^{}]*|\{[^{}]*\})*\})*})`, |
Check failure
Code scanning / CodeQL
Useless regular-expression character escape High
regular expression
) | ||
const objectName = namedExportMatch[1] | ||
const namedObjectRegex = new RegExp( | ||
`(const|let|var)\\s+${objectName}(?:\\s*:\\s*[^=]+)?\\s*=\\s*({(?:[^{}]*|\{(?:[^{}]*|\{[^{}]*\})*\})*})`, |
Check failure
Code scanning / CodeQL
Useless regular-expression character escape High
regular expression
) | ||
const objectName = namedExportMatch[1] | ||
const namedObjectRegex = new RegExp( | ||
`(const|let|var)\\s+${objectName}(?:\\s*:\\s*[^=]+)?\\s*=\\s*({(?:[^{}]*|\{(?:[^{}]*|\{[^{}]*\})*\})*})`, |
Check failure
Code scanning / CodeQL
Useless regular-expression character escape High
regular expression
) | ||
const objectName = namedExportMatch[1] | ||
const namedObjectRegex = new RegExp( | ||
`(const|let|var)\\s+${objectName}(?:\\s*:\\s*[^=]+)?\\s*=\\s*({(?:[^{}]*|\{(?:[^{}]*|\{[^{}]*\})*\})*})`, |
Check failure
Code scanning / CodeQL
Useless regular-expression character escape High
regular expression
property: string, | ||
value: string, | ||
): string => { | ||
const objectRegex = /({(?:[^{}]*|\{(?:[^{}]*|\{[^{}]*\})*\})*})/ |
Check failure
Code scanning / CodeQL
Inefficient regular expression High
property: string, | ||
value: string, | ||
): string => { | ||
const objectRegex = /({(?:[^{}]*|\{(?:[^{}]*|\{[^{}]*\})*\})*})/ |
Check failure
Code scanning / CodeQL
Inefficient regular expression High
|
||
// Handle case where default export is an inline object | ||
const inlineExportRegex = | ||
/export\s+default\s+({(?:[^{}]*|\{(?:[^{}]*|\{[^{}]*\})*\})*})/ |
Check failure
Code scanning / CodeQL
Inefficient regular expression High
|
||
// Handle case where default export is an inline object | ||
const inlineExportRegex = | ||
/export\s+default\s+({(?:[^{}]*|\{(?:[^{}]*|\{[^{}]*\})*\})*})/ |
Check failure
Code scanning / CodeQL
Inefficient regular expression High
Overview
Demo GIF
This demo reflects the following conditions:
What is this?
This setup command adds RedwoodUI to your project. At a high level, this means:
Additionally, the CLI will attempt to only install required packages, and to not downgrade any packages you've already got installed.
Also, this CLI is designed to work with various states of projects — while components and their stories are simply copied directly into your project, all config changes are designed to work alongside various states of existing configuration.
All information required for setting up RedwoodUI is pulled directly from the RedwoodUI repo via the GitHub REST API.
Testing Steps
yarn run build:test-project ../test-redwood-ui
).yarn rwfw project:tarsync
).yarn rw setup ui redwoodui
.4a. The best way to play around with components is in Storybook. We suggest setting that up before installing components, but it's optional — to do that, run
yarn rw storybook
.4b. Currently, this command makes many individual requests to the GitHub API, which means if you don't already have a GitHub token in your local environment, you'll likely hit the unauthenticated limit of 60 requests per hour. I'm exploring temporarily downloading the entire RWUI repo so that we only need to make one request, but for now, the best way around this is to just authenticate with a Personal Access Token (PAT) with the
public_repo
property — create a PAT and store it under the environment variableGH_TOKEN
. You can find instructions on how to do that here.5a. To view available components before you install them, check out the RedwoodUI Storybook.
Any issues specific to components should be opened on the RedwoodUI repo. This is just the setup command.
Some notes
package.json
'sresolutions
and in yourweb/package.json
'sdependencies
. This breaks Storybook, even with thereact-dom-shim
, which seems to only support React 17 and 18. Please therefore switch all versions of React dependencies to be the latest used by Redwood stable, which as of this writing is18.3.1
.Known Issues
TODO