0.1.2 • Published 5 years ago

@rubedo/devkit v0.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

devkit schematics usage

Install angular schematics globally

yarn global add @angular-devkit/schematics-cli

Install rubedo schematics to your project

yarn add -D @rubedo/schematics

From your project directory run

schematics @rubedo/devkit:devkit

You will get a CLI checklist, a multi-select from which you can check with Space button tools that you want to be scaffolded. You can select multiple tools to be scaffolded at once. After you've selected desired tools for scaffolding, hit Enter. Your package.json and / or project file structure will be updated depending on which tools you chose. You will get a console output stating what was updated and how (package.json: scripts, dependencies, devDependencies / project file structure).

Getting Started With Schematics

This repository is a basic Schematic implementation that serves as a starting point to create and publish Schematics to NPM.

Testing

To test locally, install @angular-devkit/schematics-cli globally and use the schematics command line tool. That tool acts the same as the generate command of the Angular CLI, but also has a debug mode.

Check the documentation with

schematics --help

Unit Testing

npm run test will run the unit tests, using Jasmine as a runner and test framework.

Publishing

To publish, simply do:

npm run build
npm publish

Building and testing locally

After cloning the project:

npm i --ignore-scripts

You can publish the schematic locally to test against any Nx workspace using verdaccio:

npm i -g verdaccio
verdaccio  // to start the private local npm registry
  1. Publish the schematic to verdaccio with the following:
npm run build
npm publish --registry http://localhost:4873
  1. Setup a fresh Nx workspace to test with:
create-nx-workspace myworkspace
  1. Open the workspace and add .npmrc to root with the following:
@nstudio:registry=http://localhost:4873
  1. You can now install your schematic changes with:
npm i @nstudio/schematics -D --registry http://localhost:4873 --force

Anytime you make further changes to the schematic just rebuild/republish:

npm run build
npm publish --registry http://localhost:4873
// then repeat Step #4 to install latest 

If you get this error:

npm ERR! code EPUBLISHCONFLICT
npm ERR! publish fail Cannot publish over existing version.
npm ERR! publish fail Update the 'version' field in package.json and try again.
npm ERR! publish fail 
npm ERR! publish fail To automatically increment version numbers, see:
npm ERR! publish fail     npm help version

You can simply unpublish and publish like this:

npm unpublish --registry http://localhost:4873 --force
npm publish --registry http://localhost:4873

Unit Tests

npm test

All tests must pass. Please add tests for any new functionality.


In order to test schematics locally in debug mode (without writing files) run

schematics .:schematicName

or in normal mode

schematics .:schematicName --debug=false