Skip to content

Commit 9f694ec

Browse files
authoredMay 11, 2023
fix(ng-morph): update npm readme (#60)
* fix(ng-morph): update npm readme * chore(docs): remove schematics info
1 parent 3d3e6a3 commit 9f694ec

File tree

2 files changed

+54
-10
lines changed

2 files changed

+54
-10
lines changed
 

‎README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![npm version](https://img.shields.io/npm/v/ng-morph.svg)](https://npmjs.com/package/ng-morph)
44
[![downloads](https://img.shields.io/npm/dy/ng-morph?color=dark-green)](https://npmjs.com/package/ng-morph)
55

6-
Code mutations in schematics were never easier than now.
6+
Code mutations were never easier than now.
77

88
```
99
npm i --save-dev ng-morph

‎libs/ng-morph/README.md

+53-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# <img src="apps/demo/src/assets/images/ng-morph.png" alt="logo" width="48px"> ng-morph
22

33
[![npm version](https://img.shields.io/npm/v/ng-morph.svg)](https://npmjs.com/package/ng-morph)
4+
[![downloads](https://img.shields.io/npm/dy/ng-morph?color=dark-green)](https://npmjs.com/package/ng-morph)
45

5-
Code mutations in schematics were never easier than now.
6+
Code mutations were never easier than now.
67

78
```
89
npm i --save-dev ng-morph
@@ -12,10 +13,13 @@ You also need `@angular-devkit/core` and `@angular-devkit/schematics` to be inst
1213

1314
## What is it?
1415

15-
It is a large set of tools that speeds up your work with Angular schematics. It has [ts-morph](https://ts-morph.com/) under the hood and allows you to manipulate with safe TypeScript AST.
16+
It is a large set of tools for both global code base
17+
updates in your project and speeding up your work on Angular schematics. It has [ts-morph](https://ts-morph.com/) under the hood and allows you to manipulate with safe TypeScript AST.
1618

1719
## Why is it better than default schematics?
1820

21+
🦅 You can quickly write migrations for your own project and run it as a simple script
22+
1923
🛠 There are many tools made for working with Angular. You can easily find and manipulate TS and Ng entities.
2024

2125
✅ You work with an abstract tree and it can be replaced,
@@ -24,7 +28,46 @@ So, you can test your schematics rapidly fast.
2428

2529
## How to start
2630

27-
Install the package and visit our [documentation](https://tinkoff.github.io/ng-morph/)
31+
Install the package and visit our [documentation](https://tinkoff.github.io/ng-morph)
32+
33+
For example, this is how `ng-morph` setup looks for migrating your own project:
34+
35+
```typescript
36+
import {
37+
setActiveProject,
38+
createProject,
39+
getImports,
40+
NgMorphTree,
41+
} from 'ng-morph';
42+
43+
/**
44+
* set all ng-morph functions to work with the all TS and JSON files
45+
* of the current project
46+
* */
47+
setActiveProject(
48+
createProject(new NgMorphTree(), '/', ['**/*.ts', '**/*.json'])
49+
);
50+
51+
/**
52+
* This simple migration gets all imports from the project TS files and
53+
* replaces 'old' substring with 'new'
54+
* */
55+
const imports = getImports('some/path/**.ts', {
56+
moduleSpecifier: '@morph-old*',
57+
});
58+
59+
editImports(imports, (importEntity) => ({
60+
moduleSpecifier: importEntity.moduleSpecifier.replace('old', 'new'),
61+
}));
62+
63+
/**
64+
* All changes are made in a virtual project.
65+
* You can save them when it is time
66+
* */
67+
saveActiveProject();
68+
```
69+
70+
You can check it out on [Stackblitz playground](https://stackblitz.com/edit/ts-angular-13-web-container-starter-nzd2ew?file=ng-morph-scripts%2Fscript.ts,src%2Fapp%2Fapp.component.ts)
2871

2972
## Core team
3073

@@ -46,19 +89,19 @@ Install the package and visit our [documentation](https://tinkoff.github.io/ng-m
4689
><img
4790
style="width: 16px;"
4891
width="16"
49-
src="https://raw.githubusercontent.com/feathericons/feather/master/icons/twitter.svg"
92+
src="https://raw.githubusercontent.com/MarsiBarsi/readme-icons/main/twitter.svg"
5093
/></a>
5194
<a href="https://github.com/IKatsuba" title="Github"
5295
><img
5396
width="16"
54-
src="https://raw.githubusercontent.com/feathericons/feather/master/icons/github.svg"
97+
src="https://raw.githubusercontent.com/MarsiBarsi/readme-icons/main/github.svg"
5598
/></a>
5699
<a
57100
href="https://t.me/Katsuba"
58101
title="Telegram"
59102
><img
60103
width="16"
61-
src="https://raw.githubusercontent.com/feathericons/feather/master/icons/send.svg"
104+
src="https://raw.githubusercontent.com/MarsiBarsi/readme-icons/main/send.svg"
62105
/></a>
63106
</div>
64107
</td>
@@ -77,25 +120,26 @@ Install the package and visit our [documentation](https://tinkoff.github.io/ng-m
77120
title="Twitter"
78121
><img
79122
width="16"
80-
src="https://raw.githubusercontent.com/feathericons/feather/master/icons/twitter.svg"
123+
src="https://raw.githubusercontent.com/MarsiBarsi/readme-icons/main/twitter.svg"
81124
/></a>
82125
<a
83126
href="https://github.com/marsibarsi"
84127
title="GitHub"
85128
><img
86129
width="16"
87-
src="https://raw.githubusercontent.com/feathericons/feather/master/icons/github.svg"
130+
src="https://raw.githubusercontent.com/MarsiBarsi/readme-icons/main/github.svg"
88131
/></a>
89132
<a
90133
href="https://t.me/marsibarsi"
91134
title="Telegram"
92135
><img
93136
width="16"
94-
src="https://raw.githubusercontent.com/feathericons/feather/master/icons/send.svg"
137+
src="https://raw.githubusercontent.com/MarsiBarsi/readme-icons/main/send.svg"
95138
/></a>
96139
</div>
97140
</td>
98141
</tr>
142+
99143
</table>
100144

101145
## License

0 commit comments

Comments
 (0)
Please sign in to comment.