Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/taiga-family/ng-morph
Code mutations in your project or schematics were never easier than now.
https://github.com/taiga-family/ng-morph
angular ast hacktoberfest mutations schematics ts-morph typescript
Last synced: 5 days ago
JSON representation
Code mutations in your project or schematics were never easier than now.
- Host: GitHub
- URL: https://github.com/taiga-family/ng-morph
- Owner: taiga-family
- License: apache-2.0
- Created: 2021-04-20T13:11:39.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-11-29T03:09:36.000Z (13 days ago)
- Last Synced: 2024-11-30T03:28:29.076Z (12 days ago)
- Topics: angular, ast, hacktoberfest, mutations, schematics, ts-morph, typescript
- Language: TypeScript
- Homepage: https://taiga-family.github.io/ng-morph
- Size: 64.3 MB
- Stars: 156
- Watchers: 5
- Forks: 7
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
- awesome-angular - ng-morph - Code mutations in your project or schematics were never easier than now. (Table of contents / Angular)
- fucking-awesome-angular - ng-morph - Code mutations in your project or schematics were never easier than now. (Table of contents / Angular)
- fucking-awesome-angular - ng-morph - Code mutations in your project or schematics were never easier than now. (Table of contents / Angular)
README
# ng-morph
[![npm version](https://img.shields.io/npm/v/ng-morph.svg)](https://npmjs.com/package/ng-morph)
[![downloads](https://img.shields.io/npm/dy/ng-morph?color=dark-green)](https://npmjs.com/package/ng-morph)
[![telegram chat](https://img.shields.io/badge/support-Contact%20us-blue)](https://t.me/taiga_ui)Code mutations were never easier than now.
```
npm i --save-dev ng-morph
```You also need `@angular-devkit/core` and `@angular-devkit/schematics` to be installed.
## What is it?
It is a large set of tools for both global code base 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.## Why is it better than default schematics?
๐ฆ You can quickly write migrations for your own project and run it as a simple script
๐ There are many tools made for working with Angular. You can easily find and manipulate TS and Ng entities.
โ You work with an abstract tree and it can be replaced, for example, with virtual tree for testing instead of real
file system. So, you can test your schematics rapidly fast.## How to start
Install the package and visit our [documentation](https://taiga-family.github.io/ng-morph)
For example, this is how `ng-morph` setup looks for migrating your own project:
```typescript
import {setActiveProject, createProject, getImports, NgMorphTree} from 'ng-morph';/**
* set all ng-morph functions to work with the all TS and JSON files
* of the current project
* */
setActiveProject(createProject(new NgMorphTree(), '/', ['**/*.ts', '**/*.json']));/**
* This simple migration gets all imports from the project TS files and
* replaces 'old' substring with 'new'
* */
const imports = getImports('some/path/**.ts', {
moduleSpecifier: '@morph-old*',
});editImports(imports, (importEntity) => ({
moduleSpecifier: importEntity.moduleSpecifier.replace('old', 'new'),
}));/**
* All changes are made in a virtual project.
* You can save them when it is time
* */
saveActiveProject();
```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)## Dive into More Examples ๐๐
- [Add readonly for unchanged ๐๐](https://stackblitz.com/edit/ts-angular-13-web-container-starter-55t636?file=ng-morph-scripts%2Fscript.ts)
- [Upgrade constructor DI to inject ๐ ๏ธ๐ฉ](https://stackblitz.com/edit/ts-angular-13-web-container-starter-ozrudz?file=ng-morph-scripts%2Fscript.ts)
- [Remove unused deps ๐งนโ](https://stackblitz.com/edit/ts-angular-13-web-container-starter-d4rb9b?file=ng-morph-scripts%2Fscript.ts)
- [Prefix for selector ๐ท๏ธโจ](https://stackblitz.com/edit/ts-angular-13-web-container-starter-9dawcd?file=ng-morph-scripts%2Fscript.ts)For more examples visit [this stackblitz collection](https://stackblitz.com/@MarsiBarsi/collections/ng-morph-examples)
## Core team
Roman Sedov
ng-morph is a part of [Taiga UI](https://github.com/taiga-family/taiga-ui) libraries family which is backed and used by
a large enterprise. This means you can rely on timely support and continuous development.## License
๐ Feel free to use our library in your commercial and private applications
All ng-morph packages are covered by [Apache 2.0](/LICENSE)
Read more about this license [here](https://choosealicense.com/licenses/apache-2.0/)