npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rhm-schematics

v1.2.1

Published

NG Generate schematics for Rush Hour Media projects

Downloads

68

Readme

Getting Started With Schematics

Schematics for Rush Hour Media's Angular front-end apps.

Available blueprints:

  • data adaptor
  • data provider (+ optional data adaptor)
  • site section
  • site sub-section

Next on the to-do list:

  • site section + several sub-sections (simultaneous and all linked and ready)
  • basic app (with authentication and api services ready for use)
  • custom shared component (button, tag label, card...)
  • instructions on how to

Getting started quickly

Creating an empty project for testing

Install the angular client: npm install @angular/cli (you might want to install it globally).

Create a new empty project: ng new MyNewApp && cd MyNewApp

Adding a Data Provider and a Data Adaptor

Install the necessary package: npm install rhm-schematics

Add a User Data Provider with the needed User Data Adaptor: ng generate --collection=rhm-schematics data-provider --name=User --add-data-adaptor=true

Due to issues with the Angular CLI, this is likely needed. Add the following to your angular.json file:

{
  ...,
  "cli": {
    "defaultCollection": "rhm-schematics"
  }
}

Adding a Site Section

Install the necessary package: npm install rhm-schematics

Then add the site section: ng generate --collection=rhm-schematics site-section --name=MyTest

Then add one or more sub section to the previous new site section: ng generate --collection=rhm-schematics site-sub-section --sectionname=MyTest --subsectionname=MyTestDetails

Then, for each sub section:

  1. Manually add the Subsection component to the Site section's .module.ts file, in the declarations:{} and exports:{} sections.
  2. Manually add the routes for each Subsection to the site section's routes ...-routing.module.ts file.

Data Provider

Data provider schematic creates a service in charge of handling data of a specific type (User, Article, Menu...).

Data providers expose only the (simple, clean) front-end model for that type of data, and uses a Data Adaptor to convert back and forth between the front-end and backend models.

The Data Provider is also responsible for fetching data and sending updates to the backend, as well as caching or locally storing the data.

Data Adaptor

Data Adaptor schematic creates a service used to convert back and forth between the front-end and backend models of a specific data type. They also provide interfaces for these models.

Recommended use

Create one Data Provider per category of data (all User related terms, data, roles, permissions). Example:

  • UserDataProvider

Create a separate Data Adaptor for each specific type of data. Example:

  • UserDataAdaptor
  • UserRoleDataAdaptor
  • UserPermissionDataAdaptor

Naming convention

When generating a Data Provider or Data Adaptor for a given data type, provide a singular name (not plural). Correct: user Wrong: users

Resources related to Angular Schematics

How to create your first custom angular schematics with ease

Generating custom code with the angular cli and 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

To-do list

Data providers

  • When generating a data provider, receive a comma-separated list of data types for which to generate data adaptors.
  • For each data adaptor type, create a get() method in the data provider.

Data adaptors

  • When creating, add possibility to specify the GET endpoint to be used. Insert that endpoint into the data adaptor itself, easy to cut-n-paste into the right location.