Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

schematics-utilities

nitayneeman55.7kMIT2.0.3TypeScript support: included

🛠️ Useful exported utilities for working with Schematics

schematic, schematics, utility, utilities, util, utils, angular, devkit, material

readme

Puppeteer Logo

Schematics Utilities

npm Docs Downloads License

Installation · Usage · Disclaimer

ℹ️️ Description

At the moment, none of the utilities from the Angular Schematics package are exported.

This project was created from that purpose - providing a collection of general and useful utilities for Schematics, based on non-exported existing utilities and further.

You might use this project as a polyfill until these utilities will be exported officially by the relevant teams (and then just replace the path you import). However, consider sticking with this project for additional and unique utilities which are planned for the future.


🔧 How to Install

To Install using npm, simply do:

npm install schematics-utilities

👨🏻‍🏫 How to Use

import { Rule, Tree } from '@angular-devkit/schematics';
// 1. Import the needed utilities
import { addPackageJsonDependency, NodeDependency, NodeDependencyType } from 'schematics-utilities';

function addDependencies(host: Tree): Tree {
  const dependencies: NodeDependency[] = [{ type: NodeDependencyType.Default, version: '4.17.10', name: 'lodash-es' }];

  // 2. Just use it whenever you need :)
  dependencies.forEach(dependency => addPackageJsonDependency(host, dependency));

  return host;
}

export default function(): Rule {
  return (tree: Tree) => {
    addDependencies(tree);

    return tree;
  };
}

Check out the API docs for the available utilities.


⚠️️ Disclaimer

This repository contains code which is directly taken from:

All credits go to the respective developers! 👏


💁🏻 Contributing

This is an open source project. Any contribution would be greatly appreciated!

changelog

Change Log

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

[2.0.2] - 2020-08-07

Fixed

  • Adjust CDK source files to allow compatibility with Angular v10 (#3a0bdc0) - thanks to @mraible

[2.0.1] - 2020-01-04

Fixed

  • Clone @angular/cdk's schematics code to avoid version conflicts

[2.0.0] - 2019-10-05

Added

  • Add new utility functions:

    • getRouterModuleDeclaration
    • addRouteDeclarationToModule
    • updateWorkspace
    • getConfig
    • relativePathToWorkspaceRoot
    • getProject
    • isWorkspaceSchema
    • isWorkspaceProject
    • hasNgModuleImport
    • appendHtmlElementToHead
    • getHtmlHeadTagElement
    • targetBuildNotFoundError

Changed

  • Change the code to import and reuse the original source

Removed

  • Remove utility functions:

    • getHeadTag
    • addHeadLink
    • getIndexHtmlPath
    • getStylesPath
    • runPostScheduledTasks

[1.1.3] - 2019-08-02

Docs

  • Deploy docs after improving README file

[1.1.2] - 2019-03-15

Changed

  • Adjust code to the original source

[1.1.1] - 2018-09-11

Fixed

  • Change projects to use targets instead of architect

[1.1.0] - 2018-08-03

Added

  • Add new utilities:
    • angular/lint-fix
    • angular/project-targets
    • material/build-component
    • material/get-project
    • material/lib-versions
    • material/testing

Changed

  • Adjust code to the original source

[1.0.1] - 2018-07-19

Removed

  • Remove redundant function: findModuleFromOptionsWithPathHandling

[1.0.0] - 2018-07-15

  • 🎉 Initial release