包详细信息

ng-morph

taiga-family227.3kApache-2.04.8.4
typescript, ast, mutations, angular

自述文件

logo ng-morph

npm version downloads telegram chat

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 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

For example, this is how ng-morph setup looks for migrating your own project:

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

Dive into More Examples 🌟🔍

For more examples visit this stackblitz collection

Core team

Igor Katsuba
Igor Katsuba
Roman Sedov
Roman Sedov

ng-morph is a part of 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

Read more about this license here

更新日志

Changelog

All notable changes to this project will be documented in this file. See conventional commits guidelines.

4.8.3 (2024-09-23)

4.8.2 (2024-09-20)

🐞 Bug Fixes

4.8.1 (2024-09-13)

🐞 Bug Fixes

4.8.0 (2024-09-13)

🚀 Features

  • add file path in error result (#885) (3963cec)

4.7.0 (2024-09-13)

🚀 Features

4.6.4 (2024-08-28)

4.6.3 (2024-08-26)

4.6.2 (2024-08-23)

4.6.1 (2024-08-22)

4.6.0 (2024-08-15)

🚀 Features

4.5.4 (2024-07-08)

4.5.3 (2024-07-08)

4.5.2 (2024-07-02)

4.5.1 (2024-06-25)

4.5.0 (2024-06-25)

4.4.0 (2024-06-14)

4.3.2 (2024-06-11)

🐞 Bug Fixes

4.3.1 (2024-06-11)

🐞 Bug Fixes

4.3.0 (2024-06-11)

🚀 Features

4.2.0 (2024-06-11)

🚀 Features

  • initial commit (8798ec5)
  • use taiga-ui npm scope (6da1df9)
  • add blob pattern support for entities (e978551)
  • add utils for working with NgModule metadata (8e45ff9)
  • add more fn (189e39d)
  • add the addImportToModule function (65c68f6)
  • add new addImportToComponent util (74bbc00)
  • docs: add @Inject -> inject migration sample (bd76806)
  • change the addImportToModule declaration (174ed99)
  • added a tree to run ng-morph without schematics (83d83ac)
  • ng-morph: export some classes from secondary points (fb31b94)
  • add the overwrite option in createSourceFile (448b183)
  • add isStandaloneComponent (#602) (c344ae4)
  • add angular 16 (#577) (e1f8bcb)
  • add support for standalone applications (#105) (8ab14cd)

🐞 Bug Fixes

  • change get-module typo (0c162b7)
  • try to save changes in NgMorphTree automatically (0744ec1)
  • new dependabot rules and release (e22af21)
  • add missing multimatch (a204e64)
  • NgMorphTree use deep import for ng16 support (d6a9059)
  • change the homepage url (4218456)
  • set CWD as default path (d9f0b6f)
  • invalid ng entry point (f731772)
  • invalid helpers entry point (#607) (f699a74)
  • bump @angular-eslint/template-parser from 16.2.0 to 17.1.1 (#384) (2b986f7)
  • bump @adobe/css-tools from 4.3.1 to 4.3.2 (#363) (bb2d67a)
  • bump axios from 1.5.1 to 1.6.2 (#362) (7a1042f)
  • bump @angular-devkit/core from 16.2.8 to 17.0.5 (#358) (cc36534)
  • bump @angular/cdk from 16.2.10 to 17.0.2 (#359) (5b3a753)
  • bump @angular-eslint/eslint-plugin-template from 16.2.0 to 17.1.1 (#361) (29429bd)
  • release package (#326) (3485bf3)
  • add missed build artefacts (#313) (6ffd38c)
  • publish (#312) (1a6ccd0)
  • cleanup packages, trigger release (#311) (a2998b4)
  • release and loose package tslib dep (#310) (499fe88)
  • deps: pin tslib to allow install on angular 17 (#308) (cbfa923)
  • ng-morph: update npm readme (#60) (9f694ec)
  • bump ansi-regex (#62) (3d3e6a3)
  • bump async from 2.6.3 to 2.6.4 (#61) (8825d49)
  • bump minimist from 1.2.5 to 1.2.8 (#55) (10858fa)
  • deps: bump url-parse from 1.5.1 to 1.5.10 (#33) (a1512bc)
  • deps: bump nanoid from 3.1.22 to 3.2.0 (#24) (faeb789)
  • deps: bump follow-redirects from 1.13.3 to 1.14.7 (#23) (73c845c)