UNPKG

3.07 kBMarkdownView Raw
1<p align="center">
2 <img src="https://github.com/nitayneeman/schematics-utilities/blob/master/images/logo.png?raw=true" alt="Puppeteer Logo">
3</p>
4
5<h1 align="center">Schematics Utilities</h1>
6
7<p align="center">
8 <a href="https://www.npmjs.com/package/schematics-utilities"><img src="https://img.shields.io/npm/v/schematics-utilities.svg?colorB=cb3837" alt="npm"></a>
9 <a href="https://nitayneeman.github.io/schematics-utilities/"><img src="https://img.shields.io/badge/docs-typedoc-green.svg" alt="Docs"></a>
10 <a href="https://www.npmjs.com/package/schematics-utilities"><img src="https://img.shields.io/npm/dt/schematics-utilities?color=blue" alt="Downloads"></a>
11 <a href="https://github.com/nitayneeman/schematics-utilities/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-MIT-lightgray.svg" alt="License"></a>
12</p>
13
14<p align="center">
15 <a href="https://github.com/nitayneeman/schematics-utilities#-how-to-install">Installation</a> ·
16 <a href="https://github.com/nitayneeman/schematics-utilities#-how-to-use">Usage</a> ·
17 <a href="https://github.com/nitayneeman/schematics-utilities#%EF%B8%8F%EF%B8%8F-disclaimer">Disclaimer</a>
18</p>
19
20## ℹ️️ Description
21
22At the moment, none of the utilities from the Angular Schematics package are exported.
23
24This project was created from that purpose - _providing a collection of general and useful utilities for Schematics, based on non-exported existing utilities and further_.
25
26You 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.
27
28<br>
29
30## 🔧 How to Install
31
32To Install using npm, simply do:
33
34```
35npm install schematics-utilities
36```
37
38<br>
39
40## 👨🏻‍🏫 How to Use
41
42```javascript
43import { Rule, Tree } from '@angular-devkit/schematics';
44// 1. Import the needed utilities
45import { addPackageJsonDependency, NodeDependency, NodeDependencyType } from 'schematics-utilities';
46
47function addDependencies(host: Tree): Tree {
48 const dependencies: NodeDependency[] = [{ type: NodeDependencyType.Default, version: '4.17.10', name: 'lodash-es' }];
49
50 // 2. Just use it whenever you need :)
51 dependencies.forEach(dependency => addPackageJsonDependency(host, dependency));
52
53 return host;
54}
55
56export default function(): Rule {
57 return (tree: Tree) => {
58 addDependencies(tree);
59
60 return tree;
61 };
62}
63```
64
65Check out the [API docs](https://nitayneeman.github.io/schematics-utilities/) for the available utilities.
66
67<br>
68
69## ⚠️️ Disclaimer
70
71This repository contains code which is directly taken from:
72
73- [Angular Schematics package](https://github.com/angular/angular-cli/tree/master/packages/schematics)
74- [Angular Material](https://github.com/angular/components/tree/master/src/cdk/schematics/utils)
75
76All credits go to the respective developers! 👏
77
78<br>
79
80## 💁🏻 Contributing
81
82This is an open source project. Any contribution would be greatly appreciated!