10.0.3 • Published 3 years ago

@unitario/angular-devkit v10.0.3

Weekly downloads
1
License
MIT
Repository
github
Last release
3 years ago

Unitario Angular Devkit

This package is a utility library for setting up, configuring and deploying Angular applications.

Its goal is to provide a rich set of tools to enchance the development experience when working with the framework.

Installation

npm install @unitario/angular-devkit --save-dev

Development

Build project

npm run clean

Test project

npm run test

Lint project

npm run lint

Deploy project

npm run deploy

Tools

Builders

Builders allows you to develop Angular Builders with a streamlined interface. It aims to make the process of developing builders easier.

What it does

  • Simplifies the process for developing Angular builders
  • Allows you to pipe multiple builders in a single sequence
  • Minimizes your console logs (only logs what's important)

Usage

import {
  BuilderOutput,
  createBuilder
} from "@angular-devkit/architect";

import {
  builderHandler,
  scheduleBuilder,
  when,
  Options,
  Context 
} from "@unitario/angular-devkit";

interface UserOptions extends Options {
  errorOnDepreciated: boolean;
}

const isLibrary = ({ metadata }: Context) => metadata.projectType === "library";

export default const createHandler<Options>(
  "Building",
  [
    // Builder referenced by package 
    scheduleBuilder("@angular-eslint/builder:lint", "Linting"),
    // Builder with options
    scheduleBuilder("@angular-builders/jest:run", "Testing", { errorOnDepreciated }),
    // Builder with callback
    scheduleBuilder(({ options, context, metadata }) => {
      // Return promise, observable or value
      return new Promise((resolve, reject) => {
        // Errors will be automatically resolved
        return reject("Show this error in console");
      })
    })
    // Builder based on predicate
    when(isLibrary,
      scheduleBuilder("@angular-devkit/build-ng-packagr:build", "Building")
    ),
  ]
);

export default const createBuilder<Options>(builderHandler);