Git Product home page Git Product logo

ricardo-schematics's Introduction

Getting Started With Schematics

Prerequisites:

npm install -g @angular-devkit/schematics-cli

This repository is a basic Schematic implementation that serves as a starting point to create and publish Schematics to NPM created by the following command:

schematics blank --name=ricardo-schematics

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

Welcome to ricardo-schematics

Here you can find the necessary steps to use and develop new schemas

Install the repository dependencies and build the project

In the root of the project run

npm install && npm run build

How to run certain schematic

In the root of the Angular project run:

 ng generate ricardo-schematic:schemaName --options

List of available schemas in the project

Model:

This schema builds the basic template for the following utils:

  • Model
options:
--name=modelName
--path=path/from/src

Important!

Before to run the generate command you must create a json file with the properties and types (see example below)

Json Rules:

1.- The json must be in the same model folder where we want to place our new model

2.- The json name must be the dasherize name of our new model.

json example:

{
 "data": [
   {
     "name": "id",
     "type": "number"
   },
   {
     "name": "title",
     "type": "string"
   },
  ]
}

Steps and example

Desired model:

src/app/modules/home/models/new-model/new-model.ts

Step 1:

Create the following json:

src/app/modules/home/models/new-model/new-model.json

Step 2:

Run the following command:

 ng generate ricardo-schematic:model --name=newModel --path=src/app/modules/home
Note:

In case you forget to add the mentioned json an explained error will be throw:

 Error: new-model.json file configuration not found in src/app/modules/home/models/new-model/new-model.json, please create it.
 If you need help, follow the readme for more instructions:
https://github.com/RicardoR/ricardo-schematics

You want to help ?

Nice because we need you! Please continue reading the next steps to start collaborating

Necessary dependencies

In order to develop schematics you have to install the following global packages:

npm install -g @schematics/schematics
npm install -g @angular-devkit/schematics-cli
npm install -g @angular-devkit/schematics
npm install -g @angular-devkit/core

Create new schema in this repo

In the root of the project run the following command

schematics blank --name=schemaName

Watcher run:

In order to develop quickly you can use the watcher option

npm run build:watch

How to test the generate files here

Instead of testing inside of angular project you can test it locally. Example of model schema:

 schematics .:model --name=modelDemo --path="." --debug=false

NOTE: if you dont use --debug=false files are not going to be created, actions are only logged by default

Publishing

Simply run the following command: npm publish

Documentation / utils from Angular:

https://github.com/angular/schematics-angular-builds https://github.com/angular/angular-cli/tree/master/packages/angular_devkit/core/src/utils

ricardo-schematics's People

Contributors

ricardor avatar

Watchers

 avatar

Forkers

ricardo-roguez

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.