-
Notifications
You must be signed in to change notification settings - Fork 114
Eleven cli #956
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
Open
LeeMellon
wants to merge
18
commits into
eleven
Choose a base branch
from
eleven-cli
base: eleven
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Eleven cli #956
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
7891635
chore: add drupal root prompt.
IMGoodrich 8b6a911
chore: update README.md
IMGoodrich 653dc54
chore: Update prompts and associated types to reflect planned changes.
IMGoodrich 20efda2
chore: Update base generator logic.
IMGoodrich f036da0
chore: cleanup unused types.
IMGoodrich 46c8ef8
chore: minor R/F and cleanup of unused prompts.
IMGoodrich 0328729
chore: Clean up _propmtUser().
IMGoodrich 1d673a5
chore: cleanup.
IMGoodrich 3f6ff9b
chore: Update types.
IMGoodrich 8d1f272
chore: Add cleanup func, update _promptUser.
IMGoodrich d05dc69
fix: Temp comment while working on new approach.
IMGoodrich af55606
chore: Separate string validation to own func. R/F and rename various…
IMGoodrich b53f297
chore: Snapshot save. Pared down multi bundle approach.
IMGoodrich a71b9db
chore: Update package.json, and base generator, remove depricated types.
IMGoodrich 7f9304e
chore: update storybook genereator, including adding new test-compone…
IMGoodrich 082bf4e
chore: Add components generator to incorporate stencilJs.
IMGoodrich 83ba3e7
chore: R/F build commands to ensure TS installs before SB. Add docs.
IMGoodrich 466fb32
chore: Remove duplicate storybook addons, and minor cleanup.
IMGoodrich File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
220 changes: 15 additions & 205 deletions
220
packages/generator-particle-base/src/generators/app/generatePromptOptions.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,217 +1,27 @@ | ||
| import inquirer from 'inquirer' | ||
|
|
||
| import { | ||
| CustomAnswers, | ||
| ConfigOptions, | ||
| ConfigurationAnswers, | ||
| CSSLibraryOptions, | ||
| ComponentLibraryOptions, | ||
| FrontendFrameworkOptions, | ||
| TestingLibraryOptions, | ||
| } from '@phase2/particle-types' | ||
|
|
||
| const minMaxOptionsValidate = ({ min, max }: { min: number; max?: number }) => ( | ||
| answer: Record<string, string>[] | ||
| const validateString = (length: number, defaultVal?:string ) => ( | ||
| answer: string | ||
| ) => { | ||
| if (answer.length < min || (!max ? false : answer.length > max)) { | ||
| return `You must choose a minimum of ${min} option(s)${ | ||
| max ? ` and a maximum of ${max} option(s)` : '' | ||
| }` | ||
| const defaultText = defaultVal ? `\n Recommended: ${defaultVal}` : '' | ||
| if (!answer || answer.length < length) { | ||
| return `Please enter a value of at least ${length} characters length.${defaultText}` | ||
| } | ||
| if (answer.indexOf(' ') > 0) { | ||
| return 'Please enter a value name with no spaces' | ||
| } | ||
| return true | ||
| } | ||
|
|
||
| export const options: Record<string, CustomAnswers> = { | ||
| [ConfigOptions.MODERN_REACT]: { | ||
| cssLibrary: CSSLibraryOptions.TAILWIND, | ||
| componentLibraryTypes: [ComponentLibraryOptions.STORYBOOK], | ||
| frontendFramework: [FrontendFrameworkOptions.REACT], | ||
| hasSVG: true, | ||
| hasTypescript: true, | ||
| testingLibraries: [TestingLibraryOptions.JEST], | ||
| typescriptEsm: false, | ||
| }, | ||
| [ConfigOptions.DRUPAL]: { | ||
| cssLibrary: CSSLibraryOptions.TAILWIND, | ||
| componentLibraryTypes: [ComponentLibraryOptions.PATTERN_LAB], | ||
| frontendFramework: [FrontendFrameworkOptions.TWIG], | ||
| hasSVG: true, | ||
| hasTypescript: false, // TODO find out if there is much benefit especially if most things are TWIG centric | ||
| testingLibraries: [ | ||
| TestingLibraryOptions.CYPRESS, | ||
| TestingLibraryOptions.PA11Y, | ||
| ], // How much JS are we actually using for Twig centric functions | ||
| typescriptEsm: false, | ||
| }, | ||
| } | ||
|
|
||
| export const configurationPrompt = [ | ||
| { | ||
| type: 'input', | ||
| message: 'choose a project name using kebab case, example: "p2-project"', | ||
| name: 'projectName', | ||
| validate: (name: string) => { | ||
| if (!name || name.length < 4) { | ||
| return 'Please enter a project name of more than 4 characters length' | ||
| } | ||
| if (name.indexOf(' ') > 0) { | ||
| return 'Please enter a two word project name with no spaces' | ||
| } | ||
| return true | ||
| }, | ||
| }, | ||
| export const propOptions = [ | ||
| { | ||
| type: 'input', | ||
| message: | ||
| 'choose a component library name using kebab case. example "project-default"', | ||
| name: 'componentLibraryName', | ||
| default: 'project-default', | ||
| validate: (name: string) => { | ||
| if (!name || name.length < 4) { | ||
| return 'Please enter a library name of more than 4 characters length' | ||
| } | ||
| return true | ||
| }, | ||
| message: 'Choose a abbreviation for your/client\'s name. (min 3 chars)', | ||
| name: 'nameSpace', | ||
| validate: validateString(2) | ||
| }, | ||
| { | ||
| type: 'input', | ||
| message: | ||
| 'Where does your component library exist relative to the root of the project', | ||
| default: (answers: ConfigurationAnswers) => | ||
| `./source/${answers.componentLibraryName}/`, | ||
| name: 'componentLibraryPath', | ||
| }, | ||
| { | ||
| type: 'list', | ||
| message: 'Choose a configuration', | ||
| name: 'config', | ||
| choices: [ | ||
| { | ||
| name: | ||
| 'modern react (storybook, tailwind, react, typescript, jest | cypress, svgs)', | ||
| value: ConfigOptions.MODERN_REACT, | ||
| }, | ||
| { | ||
| name: 'drupal only (Pattern Lab, Tailwind, Svgs)', | ||
| value: ConfigOptions.DRUPAL, | ||
| }, | ||
| { name: 'custom', value: 'custom' }, | ||
| ], | ||
| }, | ||
| ] | ||
|
|
||
| export const customPromptOptions = [ | ||
| { | ||
| type: 'checkbox', | ||
| message: 'choose a Component Library', | ||
| name: 'componentLibraryTypes', | ||
| choices: [ | ||
| new inquirer.Separator('-- Component Library choose(1 or both)--'), | ||
| { | ||
| name: 'Storybook', | ||
| value: ComponentLibraryOptions.STORYBOOK, | ||
| checked: true, | ||
| }, | ||
| { | ||
| name: 'Pattern Lab', | ||
| value: ComponentLibraryOptions.PATTERN_LAB, | ||
| }, | ||
| ], | ||
| validate: minMaxOptionsValidate({ min: 1 }), | ||
| }, | ||
| { | ||
| type: 'checkbox', | ||
| message: 'What frontend framework are you using with Storybook?', | ||
| name: 'frontendFramework', | ||
| choices: [ | ||
| { | ||
| name: 'React', | ||
| checked: true, | ||
| value: FrontendFrameworkOptions.REACT, | ||
| }, | ||
| { | ||
| name: 'Webcomponents', | ||
| value: FrontendFrameworkOptions.WEBCOMPONENTS, | ||
| }, | ||
| ], | ||
| // PR up for docs on inquirer to annotate second param answers https://github.com/SBoudrias/Inquirer.js/pull/936 | ||
| filter: (value: FrontendFrameworkOptions[], answers: CustomAnswers) => { | ||
| if ( | ||
| answers.componentLibraryTypes.includes( | ||
| ComponentLibraryOptions.PATTERN_LAB | ||
| ) | ||
| ) { | ||
| return [FrontendFrameworkOptions.TWIG, ...value] | ||
| } | ||
| return value | ||
| // throw new Error(answers.componentLibrary) | ||
| // input will { answers, values } as we are modifying the return value in the choices section | ||
| }, | ||
| when: (answers: CustomAnswers) => { | ||
| // Checks to see if we enabled typescript previously then asks the prompt | ||
| if ( | ||
| new Set(answers.componentLibraryTypes).has( | ||
| ComponentLibraryOptions.STORYBOOK | ||
| ) | ||
| ) { | ||
| return true | ||
| } | ||
|
|
||
| // Mutates answers object adds twig to selected choice (does not prompt user) | ||
| answers.frontendFramework = [FrontendFrameworkOptions.TWIG] | ||
|
|
||
| return false | ||
| }, | ||
| }, | ||
| { | ||
| type: 'list', | ||
| message: 'Choose a CSS library', | ||
| name: 'cssLibrary', | ||
| choices: [ | ||
| { name: 'Tailwind', checked: true, value: CSSLibraryOptions.TAILWIND }, | ||
| { name: 'Sass', value: CSSLibraryOptions.SASS }, | ||
| { | ||
| name: 'Bootstrap', | ||
| disabled: true, | ||
| value: CSSLibraryOptions.BOOTSTRAP, | ||
| }, | ||
| ], | ||
| }, | ||
| { | ||
| type: 'confirm', | ||
| message: 'Do you want to use typescript?', | ||
| name: 'hasTypescript', | ||
| }, | ||
| { | ||
| type: 'confirm', | ||
| message: 'Do you want ESModule support for typescript?', | ||
| name: 'typescriptEsm', | ||
| when: (answer: CustomAnswers) => { | ||
| // Checks to see if we enabled typescript previously then asks the prompt | ||
| if (answer.hasTypescript) { | ||
| return true | ||
| } | ||
| return false | ||
| }, | ||
| }, | ||
| { | ||
| type: 'confirm', | ||
| name: 'Are you using SVGs?', | ||
| }, | ||
| { | ||
| type: 'checkbox', | ||
| message: 'What testing libraries do you want to use?', | ||
| name: 'testingLibraries', | ||
| choices: [ | ||
| { name: 'Jest', value: TestingLibraryOptions.JEST }, | ||
| { name: 'Cypress', value: TestingLibraryOptions.CYPRESS }, | ||
| { name: 'Selenium', value: TestingLibraryOptions.SELENIUM }, | ||
| { | ||
| name: 'Loki (Storybook only VRT)', | ||
| value: TestingLibraryOptions.LOKI, | ||
| }, | ||
| { name: 'Pa11y', value: TestingLibraryOptions.PA11Y }, | ||
| ], | ||
| validate: minMaxOptionsValidate({ min: 1 }), | ||
| message: 'Choose a name for the overall project using kebab case. (min 4 chars) Ex: "website", or "saphire-dagger"', | ||
| name: 'projectName', | ||
| validate: validateString(4) | ||
| }, | ||
| ] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.