json-server-schematics

2.0.0 • Public • Published

Commitizen friendly

JSON-SERVER-SCHEMATICS

This repository is a basic Schematic implementation that serves to quickly add and configure json-server to an Angular project.

What it does

The schematic does four things:

  1. Installs json-server as a dev dependency into your project
  2. Creates a directory for your json server files with example db.json and routes.json files
  3. Add a proxy configuration to your Angular project so that http requrests to /api/* will be pointed to json server
  4. Adds convienience scripts to the project's package.json to start and serve your project with json-server or run it on its own.

Getting Started

Call the schematic with the Angular cli and follow the prompt to tell the Schematic where to create your json-server files.

ng add json-server-schematics

That's all you need to do!

Development

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

Additionally this project has a sandbox Angular project for ease of use when developing locally. To use the Schematic in the project you must:

  1. build the Schematic
  2. link the Schematic to the sandbox project
  3. navigate into the sandbox project and call the schematic.
  4. remove created files generated by the schematic between runs

There are a number of convinience scripts included that assist in this process.

# build the project
npm run build

# link the schematic
npm run link:schematic

# execute the schematic in the sandbox
npm test

# clean the sanddbox after the test before running again
npm run clean

Publishing

To publish, simply do:

npm run build
npm publish

That's it!

/json-server-schematics/

    Package Sidebar

    Install

    npm i json-server-schematics

    Weekly Downloads

    4

    Version

    2.0.0

    License

    MIT

    Unpacked Size

    20.8 kB

    Total Files

    19

    Last publish

    Collaborators

    • bniedermeyer