@ronas-it/nx-generators v0.12.1
NX Generators
NX generators for Ronas IT projects.
Usage
- Create monorepo with Expo app using NX Expo preset or with Next.js app using NX Next preset:
# For Expo app:
npx create-nx-workspace@latest my-project --preset=expo --appName=my-app --e2eTestRunner=none --ci=skip
# For Next.js app:
npx create-nx-workspace@latest my-project --preset=next --appName=my-app --nextAppDir=true --nextSrcDir=false --style=scss --e2eTestRunner=none --ci=skip- Install this package:
npm i @ronas-it/nx-generators --save-dev- Run generators:
npx nx g repo-config
npx nx g code-checks
# For Expo app:
npx nx g expo-app
# For Next.js app:
npx nx g next-appOr run all generators at once:
# For Expo app:
npx nx g repo-config && npx nx g code-checks && npx nx g expo-app
# For Next.js app:
npx nx g repo-config && npx nx g code-checks && npx nx g next-app- Start the app:
npx nx start my-app- Continue developing your app by generating libraries and components:
npx nx g react-lib mobile/account/features/profile-settings --withComponent
npx nx g react-componentGenerators overview
Repository
1. repo-config
Setups the monorepo structure for development.
2. code-checks
Configures code checks and formatting with pre-commit hook.
Apps
3. expo-app
Generates and configures an Expo React Native app.
Options
name(optional) - name of the app forapp.config.ts(e.g:my-app)directory(optional) - name of the directory in theapps/folder (e.g:mobile)
Example
npx nx g expo-app --name=my-app --directory=mobileor
npx nx g expo-app my-app mobile4. next-app
Generates and configures a Next.js app.
Options
name(optional) - name of the app (e.g:my-app)directory(optional) - name of the directory in theapps/folder (e.g:web)
Example
npx nx g next-app --name=my-app --directory=webor
npx nx g next-app my-app webLibraries
5. react-lib
Generates a library according to NX notation.
Options
app(optional) - name of an app orshared.scope(optional) - name of a scope orshared. This option is for a library, related to an app.type(optional) - type of library. Possible values arefeatures,data-access,uiandutils.name(optional) - name of a library.withComponent(optional) - generate the library withlib/component.tsxfile. This option is forfeaturesoruilibrary.withComponentForwardRef(optional) - generate a component withforwardRefinlib/component.tsxfile. This option works ifwithComponentistrue.dryRun(optional) - generate the library without creating files
Example
npx nx g react-lib --app=mobile --scope=account --type=features --name=profile-settings --withComponent --withComponentForwardRef --dryRunor
npx nx g react-lib --dryRun6. lib-rename
Renames an existing library and updates imports
Options
currentLibName(optional) - name of the library (e.g.:mobile-account-features-profile-settings)newLibName(optional) - new name of the library (e.g.:user-settings, project name will bemobile-account-features-user-settings)
Example
npx nx g lib-rename --currentLibName="mobile-account-features-profile-settings" --newLibName="user-settings"7. lib-move
Moves the library to a new destination. This utility also calls lib-tags generator.
Options
srcLibName(optional) - name of the library (e.g.:mobile-account-features-profile-settings)app(optional) - name of an app orshared.scope(optional) - name of a scope orshared. This option is for a library, related to an app.type(optional) - type of library. Possible values arefeatures,data-access,uiandutils.name(optional) - name of a library.
Example
npx nx g lib-move --srcLibName="mobile-account-features-profile-settings" --app=mobile --scope=settings --type=features --name="user-settings"8. lib-remove
Removes the library. Before deleting a library you must remove all references to it.
Options
libName(optional) - name of the library (e.g.:mobile-account-features-profile-settings)
Example
npx nx g lib-remove --libName="mobile-account-features-profile-settings"9. lib-tags
Checks and configures NX library tags. If your project does not already use library tags, you can add them using this generator.
Options
silent(optional) - disables all logsskipRepoCheck(optional) - disables check repository status
Example
npx nx g lib-tagsComponents
10. react-component
Creates a React component in particular library.
Options
name(optional) - name of the component (e.g. AppButton)subcomponent(optional) - generate a folder for componentswithForwardRef(optional) - generate a component with forwardRef
Example
npx nx g react-component --name=AppButton --subcomponent --withForwardRefor
npx nx g react-component AppButton --subcomponent --withForwardRef11. form
Generates a form schema class and adds its usage to a component or a hook.
Options
name(optional) - name of the form (e.g:profile-settings)placeOfUse(optional) - name of the component or hook, where the form should be (e.g:ProfileSettingsoruseProfileSettings)
Example
npx nx g form --name=profile-settings --placeOfUse=ProfileSettingsor
npx nx g form profile-settings ProfileSettingsServices
12. entity-api
Creates an API with related entities in API library. It also updates redux store middlewares, reducers.
Options
name(optional) - name of the entity (e.g. User)baseEndpoint(optional) - name of used endpoint in your API (e.g. /users)
Example
npx nx g entity-api --name=User --baseEndpoint=usersNote
Each generator accepts the --help argument to see generator instructions.
npx nx g react-lib --help1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
10 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
10 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago