This is a command line interface (CLI) to enable users to create a new Nx workspace with Genesis defaults and optional plugins. This creates a directory structure like this:
This folder structure is well suited to the needs of the majority of our projects which benefit from libraries and features being shared across multiple applications.
The Genesis CLI uses the create-nx-workspace command to generate files and applies the "App" preset. The benefit of using the create-workspace is that it will allow you to choose which Genesis plugins to automatically install and it will build the project using the most recent supported version of Nx that has been tested with Genesis plugins. That being said Genesis plugins should work fine with all versions of Nx that do not contain a breaking change so use of this CLI is mostly for convenience.
The CLI runs as an NPX script and will prompt you for more input as required. Open a terminal in the folder where you would like to create your project. It will prompt you for a project name and will create files in a directory by that name (in snake case).
To use the utility inside a project you can install the npm dependency like below
First install this package from npm
yarn add @genesisx/create-workspaceor
npm install @genesisx/create-workspace
finally running the below command to use it from some other place outside your project where would like to create the new workspace
nx generate @genesisx/create-workspace
Generators & Plugins
Nx provides a large number of generators and executors that can be used by installing plugins. There are a huge number of communitiy maintained plugins which can be found in the Nx Plugin Directory and officially supported plugins for all major frameworks:
- Application Generator
- Component Generator
- Library Generator
- Hook Generator
- Stories Generator
- Redux Generator
The goal of the Genesis project is to accelerate development and increase quality by providing templates that encapsulate best practices through generators that can be run against your project. Genesis plugins are installed into the node_modules directory and can be run from the command line or from the Nx console in Visual Studio Code. You can also "eject" a plugin which will convert it into a workspace generator which you can customize as required.
To build the CLI run this command in the terminal:
nx run create-workspace:build
To execute lint checks run:
nx run create-workspace:lint
To execute unit test cases run:
nx run create-workspace:test
To publish the package you must first be logged into NPM (npm login) then run this command from the root of the project.
- Make sure the package name in package.json should start with @genesisx/
- Also use the correct version number in package.json same will be used for the published package.
- Use your NPM js credentials (Publicis Sapient) with publish rights
- Verify the package at https://www.npmjs.com/settings/genesisx/packages
npm publish dist/packages/create-workspace --access public