diff --git a/README.md b/README.md
index c436a81..8c9cc12 100644
--- a/README.md
+++ b/README.md
@@ -1,13 +1,138 @@
# Mutates
-Mutates is a fork of [ng-morph](https://github.com/taiga-family/ng-morph) that is focused on
-mutating the AST of Angular components.
+🚀 **Mutates** is a powerful toolset for mutating the Abstract Syntax Tree (AST) of TypeScript
+files. It is a fork of `ng-morph`, with a broader focus beyond Angular-specific transformations,
+allowing for extensive AST modifications in any TypeScript project.
-The biggest difference is that this fork is not focused on Angular specific transformations.
-`Mutates` is a set of tools that can be used to mutate the AST of any TypeScript file.
+## Features
-All framework-specific transformations have been moved to separate packages (e.g.
-`@mutates/angular`).
+✨ **AST Mutations:** Modify the AST of any TypeScript file.
+🌐 **Framework-Agnostic:** Not limited to Angular; can be used with any TypeScript-based project.
+🔧 **Extensible:** Framework-specific transformations are available through separate packages.
-The main package is `@mutates/core` which provides the core functionality for mutating the AST of
-TypeScript files.
+## Packages
+
+### Core Package
+
+#### @mutates/core
+
+The core package provides the essential functionalities needed to manipulate the AST of TypeScript
+files. It serves as the foundation for other specialized packages.
+
+### Framework-Specific Packages
+
+Framework-specific transformations have been decoupled from the core package and are available as
+separate packages. For example:
+
+#### @mutates/angular
+
+This package includes transformations specific to Angular projects, leveraging the capabilities of
+`@mutates/core` to provide Angular-focused AST modifications.
+
+#### @mutates/nx
+
+This package includes transformations specific to Nx workspaces, allowing for Nx-specific filesystem
+operations and AST modifications.
+
+## Installation
+
+To install the core package, use the following command:
+
+```sh
+npm install @mutates/core
+```
+
+For Angular-specific transformations, install the Angular package as well:
+
+```sh
+npm install @mutates/angular @mutates/core
+```
+
+For Nx-specific transformations, install the Nx package:
+
+```sh
+npm install @mutates/nx @mutates/core
+```
+
+## Usage
+
+### Basic Example
+
+Here is a simple example demonstrating how to use `@mutates/core` to modify a TypeScript file:
+
+```typescript
+import { addFunctions, creataProject, createSourceFile, saveProject } from '@mutates/core';
+
+// Initialize a new project
+createProject();
+
+// Add a TypeScript file to the project
+createSourceFile(
+ 'example.ts',
+ `
+ const greet = (name: string) => {
+ return 'Hello, ' + name;
+ };
+`,
+);
+
+// Perform some transformations
+addFunctions('example.ts', {
+ name: 'farewell',
+ isExported: true,
+ statements: "return 'buy!'",
+});
+
+// Save the modified file
+saveProject();
+```
+
+### Angular Example
+
+To perform Angular-specific transformations, use `@mutates/angular` along with `@mutates/core`:
+
+```typescript
+import { addProviders, getComponents } from '@mutates/angular';
+import { createProject, createSourceFile, saveProject } from '@mutates/core';
+
+// Initialize a new Angular project
+createProject();
+
+// Add an Angular component file to the project
+createSourceFile(
+ 'app.component.ts',
+ `
+ import { Component } from '@angular/core';
+
+ @Component({
+ selector: 'app-root',
+ template: '
Hello, World!
'
+ })
+ export class AppComponent {}
+`,
+);
+
+// Perform some Angular-specific transformations
+addProviders(getComponents('app.component.ts').at(0)!, ['AppService']);
+
+// Save the modified file
+saveProject();
+```
+
+## Contributing
+
+🤝 Contributions are welcome! If you have any improvements or suggestions, feel free to open an
+issue or submit a pull request.
+
+## License
+
+📄 Mutates is licensed under the Apache-2.0 License. See the [LICENSE](./LICENSE) file for more
+information.
+
+---
+
+For more detailed documentation, please visit the
+[official documentation](https://mutates.katsuba.dev).
+
+For further assistance or to report issues, please visit
+[GitHub repository](https://github.com/ikatsuba/mutates).
diff --git a/docs/src/app/packages/angular/page.md b/docs/src/app/packages/angular/page.md
new file mode 100644
index 0000000..7664e13
--- /dev/null
+++ b/docs/src/app/packages/angular/page.md
@@ -0,0 +1,9 @@
+---
+title: '@mutates/angular'
+nextjs:
+ metadata:
+ title: '@mutates/angular'
+ description: How to install `@mutates/angular` and get started.
+---
+
+WIP
diff --git a/docs/src/app/packages/core/page.md b/docs/src/app/packages/core/page.md
new file mode 100644
index 0000000..aaa4551
--- /dev/null
+++ b/docs/src/app/packages/core/page.md
@@ -0,0 +1,9 @@
+---
+title: '@mutates/core'
+nextjs:
+ metadata:
+ title: '@mutates/core'
+ description: How to install `@mutates/core` and get started.
+---
+
+WIP
diff --git a/docs/src/app/packages/nx/page.md b/docs/src/app/packages/nx/page.md
new file mode 100644
index 0000000..667fe3d
--- /dev/null
+++ b/docs/src/app/packages/nx/page.md
@@ -0,0 +1,9 @@
+---
+title: '@mutates/nx'
+nextjs:
+ metadata:
+ title: '@mutates/nx'
+ description: How to install `@mutates/nx` and get started.
+---
+
+WIP
diff --git a/docs/src/lib/navigation.ts b/docs/src/lib/navigation.ts
index 7c11895..925948b 100644
--- a/docs/src/lib/navigation.ts
+++ b/docs/src/lib/navigation.ts
@@ -6,6 +6,23 @@ export const navigation = [
{ title: 'Installation', href: '/installation' },
],
},
+ {
+ title: 'Packages',
+ links: [
+ {
+ title: 'Core',
+ href: '/packages/core',
+ },
+ {
+ title: 'Angular',
+ href: '/packages/angular',
+ },
+ {
+ title: 'Nx',
+ href: '/packages/nx',
+ },
+ ],
+ },
{
title: 'Core concepts',
links: [{ title: 'Testing', href: '/testing' }],
diff --git a/package-lock.json b/package-lock.json
index 6ac3a4f..e01e6fe 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -38,6 +38,7 @@
"@commitlint/cz-commitlint": "^19.2.0",
"@commitlint/prompt-cli": "^19.3.1",
"@ianvs/prettier-plugin-sort-imports": "^4.2.1",
+ "@nx/devkit": "19.3.0",
"@nx/eslint": "19.3.0",
"@nx/eslint-plugin": "19.3.0",
"@nx/js": "19.3.0",
@@ -3200,7 +3201,6 @@
},
"node_modules/@jest/schemas": {
"version": "29.6.3",
- "dev": true,
"license": "MIT",
"dependencies": {
"@sinclair/typebox": "^0.27.8"
@@ -3336,6 +3336,10 @@
"resolved": "packages/core",
"link": true
},
+ "node_modules/@mutates/nx": {
+ "resolved": "packages/nx",
+ "link": true
+ },
"node_modules/@next/env": {
"version": "14.2.3",
"license": "MIT"
@@ -3536,7 +3540,6 @@
"version": "19.3.0",
"resolved": "https://registry.npmjs.org/@nrwl/devkit/-/devkit-19.3.0.tgz",
"integrity": "sha512-WRcph/7U37HkTLIRzQ2oburZVfEFkPHJUn7vmo46gCq+N2cAKy3qwONO0RbthhjFIsG94YPXqFWFlV6k4nXpxA==",
- "dev": true,
"dependencies": {
"@nx/devkit": "19.3.0"
}
@@ -3581,7 +3584,6 @@
"version": "19.3.0",
"resolved": "https://registry.npmjs.org/@nrwl/tao/-/tao-19.3.0.tgz",
"integrity": "sha512-MyGYeHbh9O4Tv9xmz3Du+/leY5sKUHaPy4ancfNyShHgYi21hemX0/YYjzzoYHi44D8GzSc1XG2rAuwba7Kilw==",
- "dev": true,
"dependencies": {
"nx": "19.3.0",
"tslib": "^2.3.0"
@@ -3630,7 +3632,6 @@
"version": "19.3.0",
"resolved": "https://registry.npmjs.org/@nx/devkit/-/devkit-19.3.0.tgz",
"integrity": "sha512-Natya5nzvHH0qTOIL1w/EZtwMgDx87Dgz0LgeY7te2fULaNFcj5fVrP+mUKEJZR+NccO7GPumT2RPhuEl9rPnQ==",
- "dev": true,
"dependencies": {
"@nrwl/devkit": "19.3.0",
"ejs": "^3.1.7",
@@ -3801,7 +3802,6 @@
"cpu": [
"arm64"
],
- "dev": true,
"optional": true,
"os": [
"darwin"
@@ -3817,7 +3817,6 @@
"cpu": [
"x64"
],
- "dev": true,
"optional": true,
"os": [
"darwin"
@@ -3833,7 +3832,6 @@
"cpu": [
"x64"
],
- "dev": true,
"optional": true,
"os": [
"freebsd"
@@ -3849,7 +3847,6 @@
"cpu": [
"arm"
],
- "dev": true,
"optional": true,
"os": [
"linux"
@@ -3865,7 +3862,6 @@
"cpu": [
"arm64"
],
- "dev": true,
"optional": true,
"os": [
"linux"
@@ -3881,7 +3877,6 @@
"cpu": [
"arm64"
],
- "dev": true,
"optional": true,
"os": [
"linux"
@@ -3897,7 +3892,6 @@
"cpu": [
"x64"
],
- "dev": true,
"optional": true,
"os": [
"linux"
@@ -3913,7 +3907,6 @@
"cpu": [
"x64"
],
- "dev": true,
"optional": true,
"os": [
"linux"
@@ -3929,7 +3922,6 @@
"cpu": [
"arm64"
],
- "dev": true,
"optional": true,
"os": [
"win32"
@@ -3945,7 +3937,6 @@
"cpu": [
"x64"
],
- "dev": true,
"optional": true,
"os": [
"win32"
@@ -4205,7 +4196,6 @@
},
"node_modules/@sinclair/typebox": {
"version": "0.27.8",
- "dev": true,
"license": "MIT"
},
"node_modules/@sindresorhus/slugify": {
@@ -4566,7 +4556,7 @@
},
"node_modules/@swc-node/core": {
"version": "1.13.1",
- "dev": true,
+ "devOptional": true,
"license": "MIT",
"engines": {
"node": ">= 10"
@@ -4582,7 +4572,7 @@
},
"node_modules/@swc-node/register": {
"version": "1.9.1",
- "dev": true,
+ "devOptional": true,
"license": "MIT",
"dependencies": {
"@swc-node/core": "^1.13.1",
@@ -4603,7 +4593,7 @@
},
"node_modules/@swc-node/sourcemap-support": {
"version": "0.5.0",
- "dev": true,
+ "devOptional": true,
"license": "MIT",
"dependencies": {
"source-map-support": "^0.5.21",
@@ -4612,7 +4602,7 @@
},
"node_modules/@swc-node/sourcemap-support/node_modules/source-map-support": {
"version": "0.5.21",
- "dev": true,
+ "devOptional": true,
"license": "MIT",
"dependencies": {
"buffer-from": "^1.0.0",
@@ -4621,7 +4611,7 @@
},
"node_modules/@swc/core": {
"version": "1.5.25",
- "dev": true,
+ "devOptional": true,
"hasInstallScript": true,
"license": "Apache-2.0",
"dependencies": {
@@ -4684,7 +4674,7 @@
},
"node_modules/@swc/types": {
"version": "0.1.7",
- "dev": true,
+ "devOptional": true,
"license": "Apache-2.0",
"dependencies": {
"@swc/counter": "^0.1.3"
@@ -6356,12 +6346,10 @@
},
"node_modules/@yarnpkg/lockfile": {
"version": "1.1.0",
- "dev": true,
"license": "BSD-2-Clause"
},
"node_modules/@yarnpkg/parsers": {
"version": "3.0.0-rc.46",
- "dev": true,
"license": "BSD-2-Clause",
"dependencies": {
"js-yaml": "^3.10.0",
@@ -6373,7 +6361,6 @@
},
"node_modules/@yarnpkg/parsers/node_modules/argparse": {
"version": "1.0.10",
- "dev": true,
"license": "MIT",
"dependencies": {
"sprintf-js": "~1.0.2"
@@ -6381,7 +6368,6 @@
},
"node_modules/@yarnpkg/parsers/node_modules/js-yaml": {
"version": "3.14.1",
- "dev": true,
"license": "MIT",
"dependencies": {
"argparse": "^1.0.7",
@@ -6393,7 +6379,6 @@
},
"node_modules/@zkochan/js-yaml": {
"version": "0.0.7",
- "dev": true,
"license": "MIT",
"dependencies": {
"argparse": "^2.0.1"
@@ -6546,7 +6531,6 @@
},
"node_modules/ansi-colors": {
"version": "4.1.3",
- "dev": true,
"license": "MIT",
"engines": {
"node": ">=6"
@@ -6850,12 +6834,10 @@
},
"node_modules/async": {
"version": "3.2.5",
- "dev": true,
"license": "MIT"
},
"node_modules/asynckit": {
"version": "0.4.0",
- "dev": true,
"license": "MIT"
},
"node_modules/at-least-node": {
@@ -6945,7 +6927,6 @@
},
"node_modules/axios": {
"version": "1.7.2",
- "dev": true,
"license": "MIT",
"dependencies": {
"follow-redirects": "^1.15.6",
@@ -7290,7 +7271,7 @@
},
"node_modules/buffer-from": {
"version": "1.1.2",
- "dev": true,
+ "devOptional": true,
"license": "MIT"
},
"node_modules/busboy": {
@@ -7612,7 +7593,6 @@
},
"node_modules/cliui": {
"version": "8.0.1",
- "dev": true,
"license": "ISC",
"dependencies": {
"string-width": "^4.2.0",
@@ -7676,7 +7656,7 @@
},
"node_modules/colorette": {
"version": "2.0.20",
- "dev": true,
+ "devOptional": true,
"license": "MIT"
},
"node_modules/columnify": {
@@ -7693,7 +7673,6 @@
},
"node_modules/combined-stream": {
"version": "1.0.8",
- "dev": true,
"license": "MIT",
"dependencies": {
"delayed-stream": "~1.0.0"
@@ -7957,7 +7936,6 @@
},
"node_modules/concat-map": {
"version": "0.0.1",
- "dev": true,
"license": "MIT"
},
"node_modules/confbox": {
@@ -8651,7 +8629,7 @@
},
"node_modules/debug": {
"version": "4.3.5",
- "dev": true,
+ "devOptional": true,
"license": "MIT",
"dependencies": {
"ms": "2.1.2"
@@ -8802,7 +8780,6 @@
},
"node_modules/define-lazy-prop": {
"version": "2.0.0",
- "dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
@@ -8826,7 +8803,6 @@
},
"node_modules/delayed-stream": {
"version": "1.0.0",
- "dev": true,
"license": "MIT",
"engines": {
"node": ">=0.4.0"
@@ -8923,7 +8899,6 @@
},
"node_modules/diff-sequences": {
"version": "29.6.3",
- "dev": true,
"license": "MIT",
"engines": {
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
@@ -9046,7 +9021,6 @@
},
"node_modules/dotenv": {
"version": "16.3.2",
- "dev": true,
"license": "BSD-2-Clause",
"engines": {
"node": ">=12"
@@ -9057,7 +9031,6 @@
},
"node_modules/dotenv-expand": {
"version": "10.0.0",
- "dev": true,
"license": "BSD-2-Clause",
"engines": {
"node": ">=12"
@@ -9065,7 +9038,6 @@
},
"node_modules/duplexer": {
"version": "0.1.2",
- "dev": true,
"license": "MIT"
},
"node_modules/duplexify": {
@@ -9110,7 +9082,6 @@
"version": "3.1.10",
"resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.10.tgz",
"integrity": "sha512-UeJmFfOrAQS8OJWPZ4qtgHyWExa088/MtK5UEyoJGFH67cDEXkZSviOiKRCZ4Xij0zxI3JECgYs3oKx+AizQBA==",
- "dev": true,
"dependencies": {
"jake": "^10.8.5"
},
@@ -9128,7 +9099,6 @@
},
"node_modules/emoji-regex": {
"version": "8.0.0",
- "dev": true,
"license": "MIT"
},
"node_modules/emojis-list": {
@@ -9148,7 +9118,6 @@
},
"node_modules/end-of-stream": {
"version": "1.4.4",
- "dev": true,
"license": "MIT",
"dependencies": {
"once": "^1.4.0"
@@ -9168,7 +9137,6 @@
},
"node_modules/enquirer": {
"version": "2.3.6",
- "dev": true,
"license": "MIT",
"dependencies": {
"ansi-colors": "^4.1.1"
@@ -9423,7 +9391,6 @@
},
"node_modules/escalade": {
"version": "3.1.2",
- "dev": true,
"license": "MIT",
"engines": {
"node": ">=6"
@@ -9436,7 +9403,6 @@
},
"node_modules/escape-string-regexp": {
"version": "1.0.5",
- "dev": true,
"license": "MIT",
"engines": {
"node": ">=0.8.0"
@@ -10234,7 +10200,6 @@
},
"node_modules/esprima": {
"version": "4.0.1",
- "dev": true,
"license": "BSD-2-Clause",
"bin": {
"esparse": "bin/esparse.js",
@@ -10593,7 +10558,6 @@
},
"node_modules/figures": {
"version": "3.2.0",
- "dev": true,
"license": "MIT",
"dependencies": {
"escape-string-regexp": "^1.0.5"
@@ -10689,7 +10653,6 @@
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.4.tgz",
"integrity": "sha512-w1cEuf3S+DrLCQL7ET6kz+gmlJdbq9J7yXCSjK/OZCPA+qEN1WyF4ZAf0YYJa4/shHJra2t/d/r8SV4Ji+x+8Q==",
- "dev": true,
"dependencies": {
"minimatch": "^5.0.1"
}
@@ -10698,7 +10661,6 @@
"version": "5.1.6",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz",
"integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==",
- "dev": true,
"dependencies": {
"brace-expansion": "^2.0.1"
},
@@ -10813,7 +10775,6 @@
},
"node_modules/flat": {
"version": "5.0.2",
- "dev": true,
"license": "BSD-3-Clause",
"bin": {
"flat": "cli.js"
@@ -10844,7 +10805,6 @@
},
"node_modules/follow-redirects": {
"version": "1.15.6",
- "dev": true,
"funding": [
{
"type": "individual",
@@ -11040,7 +11000,6 @@
},
"node_modules/form-data": {
"version": "4.0.0",
- "dev": true,
"license": "MIT",
"dependencies": {
"asynckit": "^0.4.0",
@@ -11081,7 +11040,6 @@
},
"node_modules/front-matter": {
"version": "4.0.2",
- "dev": true,
"license": "MIT",
"dependencies": {
"js-yaml": "^3.13.1"
@@ -11089,7 +11047,6 @@
},
"node_modules/front-matter/node_modules/argparse": {
"version": "1.0.10",
- "dev": true,
"license": "MIT",
"dependencies": {
"sprintf-js": "~1.0.2"
@@ -11097,7 +11054,6 @@
},
"node_modules/front-matter/node_modules/js-yaml": {
"version": "3.14.1",
- "dev": true,
"license": "MIT",
"dependencies": {
"argparse": "^1.0.7",
@@ -11109,12 +11065,10 @@
},
"node_modules/fs-constants": {
"version": "1.0.0",
- "dev": true,
"license": "MIT"
},
"node_modules/fs-extra": {
"version": "11.2.0",
- "dev": true,
"license": "MIT",
"dependencies": {
"graceful-fs": "^4.2.0",
@@ -11191,7 +11145,6 @@
},
"node_modules/get-caller-file": {
"version": "2.0.5",
- "dev": true,
"license": "ISC",
"engines": {
"node": "6.* || 8.* || >= 10.*"
@@ -11925,7 +11878,6 @@
},
"node_modules/ignore": {
"version": "5.3.1",
- "dev": true,
"license": "MIT",
"engines": {
"node": ">= 4"
@@ -12256,7 +12208,6 @@
},
"node_modules/is-docker": {
"version": "2.2.1",
- "dev": true,
"license": "MIT",
"bin": {
"is-docker": "cli.js"
@@ -12288,7 +12239,6 @@
},
"node_modules/is-fullwidth-code-point": {
"version": "3.0.0",
- "dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
@@ -12591,7 +12541,6 @@
},
"node_modules/is-wsl": {
"version": "2.2.0",
- "dev": true,
"license": "MIT",
"dependencies": {
"is-docker": "^2.0.0"
@@ -12703,7 +12652,6 @@
"version": "10.9.1",
"resolved": "https://registry.npmjs.org/jake/-/jake-10.9.1.tgz",
"integrity": "sha512-61btcOHNnLnsOdtLgA5efqQWjnSi/vow5HbI7HMdKKWqvrKR1bLK3BPlJn9gcSaP2ewuamUSMB5XEy76KUIS2w==",
- "dev": true,
"dependencies": {
"async": "^3.2.3",
"chalk": "^4.0.2",
@@ -12721,7 +12669,6 @@
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
- "dev": true,
"dependencies": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@@ -12731,7 +12678,6 @@
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
"integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
- "dev": true,
"dependencies": {
"brace-expansion": "^1.1.7"
},
@@ -12741,7 +12687,6 @@
},
"node_modules/jest-diff": {
"version": "29.7.0",
- "dev": true,
"license": "MIT",
"dependencies": {
"chalk": "^4.0.0",
@@ -12755,7 +12700,6 @@
},
"node_modules/jest-get-type": {
"version": "29.6.3",
- "dev": true,
"license": "MIT",
"engines": {
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
@@ -12905,12 +12849,10 @@
},
"node_modules/jsonc-parser": {
"version": "3.2.0",
- "dev": true,
"license": "MIT"
},
"node_modules/jsonfile": {
"version": "6.1.0",
- "dev": true,
"license": "MIT",
"dependencies": {
"universalify": "^2.0.0"
@@ -13184,7 +13126,6 @@
},
"node_modules/lines-and-columns": {
"version": "2.0.4",
- "dev": true,
"license": "MIT",
"engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
@@ -13855,7 +13796,6 @@
},
"node_modules/mime-db": {
"version": "1.52.0",
- "dev": true,
"license": "MIT",
"engines": {
"node": ">= 0.6"
@@ -13863,7 +13803,6 @@
},
"node_modules/mime-types": {
"version": "2.1.35",
- "dev": true,
"license": "MIT",
"dependencies": {
"mime-db": "1.52.0"
@@ -13919,7 +13858,6 @@
},
"node_modules/minimist": {
"version": "1.2.8",
- "dev": true,
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/ljharb"
@@ -13965,7 +13903,7 @@
},
"node_modules/ms": {
"version": "2.1.2",
- "dev": true,
+ "devOptional": true,
"license": "MIT"
},
"node_modules/multicast-dns": {
@@ -14298,7 +14236,6 @@
},
"node_modules/node-machine-id": {
"version": "1.1.12",
- "dev": true,
"license": "MIT"
},
"node_modules/node-releases": {
@@ -14338,7 +14275,6 @@
},
"node_modules/npm-run-path": {
"version": "4.0.1",
- "dev": true,
"license": "MIT",
"dependencies": {
"path-key": "^3.0.0"
@@ -14363,7 +14299,6 @@
"version": "19.3.0",
"resolved": "https://registry.npmjs.org/nx/-/nx-19.3.0.tgz",
"integrity": "sha512-WILWiROUkZWwuPJ12tP24Z0NULPEhxFN9i55/fECuVXYaFtkg6FvEne9C4d4bRqhZPcbrz6WhHnzE3NhdjH7XQ==",
- "dev": true,
"hasInstallScript": true,
"dependencies": {
"@nrwl/tao": "19.3.0",
@@ -14588,7 +14523,6 @@
},
"node_modules/once": {
"version": "1.4.0",
- "dev": true,
"license": "ISC",
"dependencies": {
"wrappy": "1"
@@ -14609,7 +14543,6 @@
},
"node_modules/open": {
"version": "8.4.2",
- "dev": true,
"license": "MIT",
"dependencies": {
"define-lazy-prop": "^2.0.0",
@@ -14650,7 +14583,6 @@
},
"node_modules/ora": {
"version": "5.3.0",
- "dev": true,
"license": "MIT",
"dependencies": {
"bl": "^4.0.3",
@@ -14810,7 +14742,6 @@
},
"node_modules/path-key": {
"version": "3.1.1",
- "dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
@@ -14988,7 +14919,7 @@
},
"node_modules/pirates": {
"version": "4.0.6",
- "dev": true,
+ "devOptional": true,
"license": "MIT",
"engines": {
"node": ">= 6"
@@ -15836,7 +15767,6 @@
},
"node_modules/pretty-format": {
"version": "29.7.0",
- "dev": true,
"license": "MIT",
"dependencies": {
"@jest/schemas": "^29.6.3",
@@ -15849,7 +15779,6 @@
},
"node_modules/pretty-format/node_modules/ansi-styles": {
"version": "5.2.0",
- "dev": true,
"license": "MIT",
"engines": {
"node": ">=10"
@@ -15929,7 +15858,6 @@
},
"node_modules/proxy-from-env": {
"version": "1.1.0",
- "dev": true,
"license": "MIT"
},
"node_modules/prr": {
@@ -16068,7 +15996,6 @@
},
"node_modules/react-is": {
"version": "18.3.1",
- "dev": true,
"license": "MIT"
},
"node_modules/read-cache": {
@@ -16220,7 +16147,6 @@
},
"node_modules/require-directory": {
"version": "2.1.1",
- "dev": true,
"license": "MIT",
"engines": {
"node": ">=0.10.0"
@@ -16606,7 +16532,6 @@
},
"node_modules/semver": {
"version": "7.6.2",
- "dev": true,
"license": "ISC",
"bin": {
"semver": "bin/semver.js"
@@ -17005,7 +16930,7 @@
},
"node_modules/source-map": {
"version": "0.6.1",
- "dev": true,
+ "devOptional": true,
"license": "BSD-3-Clause",
"engines": {
"node": ">=0.10.0"
@@ -17099,7 +17024,6 @@
},
"node_modules/sprintf-js": {
"version": "1.0.3",
- "dev": true,
"license": "BSD-3-Clause"
},
"node_modules/sshpk": {
@@ -17180,7 +17104,6 @@
},
"node_modules/string-width": {
"version": "4.2.3",
- "dev": true,
"license": "MIT",
"dependencies": {
"emoji-regex": "^8.0.0",
@@ -17300,7 +17223,6 @@
},
"node_modules/strip-bom": {
"version": "3.0.0",
- "dev": true,
"license": "MIT",
"engines": {
"node": ">=4"
@@ -17346,7 +17268,6 @@
},
"node_modules/strong-log-transformer": {
"version": "2.1.0",
- "dev": true,
"license": "Apache-2.0",
"dependencies": {
"duplexer": "^0.1.1",
@@ -17721,7 +17642,6 @@
},
"node_modules/tar-stream": {
"version": "2.2.0",
- "dev": true,
"license": "MIT",
"dependencies": {
"bl": "^4.0.3",
@@ -17955,7 +17875,6 @@
},
"node_modules/through": {
"version": "2.3.8",
- "dev": true,
"license": "MIT"
},
"node_modules/thunky": {
@@ -17987,7 +17906,6 @@
},
"node_modules/tmp": {
"version": "0.2.3",
- "dev": true,
"license": "MIT",
"engines": {
"node": ">=14.14"
@@ -18156,7 +18074,6 @@
},
"node_modules/tsconfig-paths": {
"version": "4.2.0",
- "dev": true,
"license": "MIT",
"dependencies": {
"json5": "^2.2.2",
@@ -18328,7 +18245,7 @@
},
"node_modules/typescript": {
"version": "5.4.5",
- "dev": true,
+ "devOptional": true,
"license": "Apache-2.0",
"bin": {
"tsc": "bin/tsc",
@@ -18430,7 +18347,6 @@
},
"node_modules/universalify": {
"version": "2.0.1",
- "dev": true,
"license": "MIT",
"engines": {
"node": ">= 10.0.0"
@@ -19414,7 +19330,6 @@
},
"node_modules/wrap-ansi": {
"version": "7.0.0",
- "dev": true,
"license": "MIT",
"dependencies": {
"ansi-styles": "^4.0.0",
@@ -19447,7 +19362,6 @@
},
"node_modules/wrappy": {
"version": "1.0.2",
- "dev": true,
"license": "ISC"
},
"node_modules/ws": {
@@ -19473,7 +19387,6 @@
},
"node_modules/y18n": {
"version": "5.0.8",
- "dev": true,
"license": "ISC",
"engines": {
"node": ">=10"
@@ -19494,7 +19407,6 @@
},
"node_modules/yargs": {
"version": "17.7.2",
- "dev": true,
"license": "MIT",
"dependencies": {
"cliui": "^8.0.1",
@@ -19511,7 +19423,6 @@
},
"node_modules/yargs-parser": {
"version": "21.1.1",
- "dev": true,
"license": "ISC",
"engines": {
"node": ">=12"
@@ -19558,13 +19469,12 @@
"version": "0.0.0-development",
"license": "Apache-2.0",
"dependencies": {
- "@mutates/core": "0.0.0-development",
- "minimatch": "9.0.3",
- "ts-morph": "^22.0.0",
"tslib": "^2.3.0"
},
"peerDependencies": {
- "@angular-devkit/schematics": ">=18.0.0"
+ "@angular-devkit/schematics": ">=18.0.0",
+ "@mutates/core": "0.0.0-development",
+ "ts-morph": "^22.0.0"
}
},
"packages/core": {
@@ -19576,6 +19486,18 @@
"ts-morph": "^22.0.0",
"tslib": "^2.3.0"
}
+ },
+ "packages/nx": {
+ "name": "@mutates/nx",
+ "version": "0.0.1",
+ "dependencies": {
+ "tslib": "^2.3.0"
+ },
+ "peerDependencies": {
+ "@mutates/core": "0.0.0-development",
+ "@nx/devkit": ">= 19.0.0",
+ "ts-morph": "^22.0.0"
+ }
}
}
}
diff --git a/package.json b/package.json
index 5e9b03b..8db1aad 100644
--- a/package.json
+++ b/package.json
@@ -36,6 +36,7 @@
"@commitlint/cz-commitlint": "^19.2.0",
"@commitlint/prompt-cli": "^19.3.1",
"@ianvs/prettier-plugin-sort-imports": "^4.2.1",
+ "@nx/devkit": "19.3.0",
"@nx/eslint": "19.3.0",
"@nx/eslint-plugin": "19.3.0",
"@nx/js": "19.3.0",
diff --git a/packages/angular/README.md b/packages/angular/README.md
index 3dda518..b7ba9de 100644
--- a/packages/angular/README.md
+++ b/packages/angular/README.md
@@ -1,3 +1,101 @@
# @mutates/angular
-[WIP]
+🌟 **@mutates/angular** is a specialized package within the Mutates toolset, offering powerful tools
+to mutate the Abstract Syntax Tree (AST) of Angular projects. Built on top of `@mutates/core`, this
+package provides Angular-specific transformations, making it easier to work with Angular components,
+directives, services, and more.
+
+## Features
+
+- **Angular-Specific Transformations:** Modify the AST of Angular components, directives, modules,
+ and services.
+- **Seamless Integration:** Works in conjunction with `@mutates/core` for a smooth development
+ experience.
+- **Efficient:** Designed to handle the unique structure and requirements of Angular projects.
+
+## Installation
+
+To install the Angular package, use the following command:
+
+```sh
+npm install @mutates/angular @mutates/core
+```
+
+## Usage
+
+### Basic Example
+
+Here is a simple example demonstrating how to use `@mutates/angular` to modify an Angular component:
+
+```typescript
+import { addProviders, getComponents } from '@mutates/angular';
+import { createProject, createSourceFile, saveProject } from '@mutates/core';
+
+// Initialize a new Angular project
+createProject();
+
+// Add an Angular component file to the project
+createSourceFile(
+ 'app.component.ts',
+ `
+ import { Component } from '@angular/core';
+
+ @Component({
+ selector: 'app-root',
+ template: 'Hello, World!
'
+ })
+ export class AppComponent {}
+`,
+);
+
+// Perform some Angular-specific transformations
+addProviders(getComponents('app.component.ts').at(0)!, ['AppService']);
+
+// Save the modified file
+saveProject();
+```
+
+For schematics and migrations the package provided special function to connect with Angular Tree.
+Angular Tree is a special tree that is used to work with Angular projects. It is based on the
+`@angular-devkit/schematics` package.
+
+```typescript
+import { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
+
+import { createAngularProject } from '@mutates/angular';
+import { saveProject } from '@mutates/core';
+
+export function mySchematic(): Rule {
+ return (tree: Tree, context: SchematicContext) => {
+ // Use Angular Tree to work with Angular projects
+ createAngularProject(tree);
+
+ // Perform Angular-specific transformations
+ addProviders(getComponents('app.component.ts').at(0)!, ['AppService']);
+
+ saveProject();
+
+ return tree;
+ };
+}
+```
+
+## API Reference
+
+For a comprehensive guide on the available APIs and their usage, please refer to the
+[official documentation](https://mutates.katsuba.dev/packages/angular)
+
+## Contributing
+
+🤝 Contributions are welcome! If you have any improvements or suggestions, feel free to open an
+issue or submit a pull request.
+
+## License
+
+📄 @mutates/angular is licensed under the Apache-2.0 License. See the
+[LICENSE](https://github.com/ikatsuba/mutates/blob/main/LICENSE) file for more information.
+
+---
+
+For further assistance or to report issues, please visit our
+[GitHub repository](https://github.com/ikatsuba/mutates).
diff --git a/packages/angular/package.json b/packages/angular/package.json
index 9f8e8c6..1f7b2e7 100644
--- a/packages/angular/package.json
+++ b/packages/angular/package.json
@@ -18,13 +18,12 @@
"main": "./src/index.js",
"typings": "./src/index.d.ts",
"dependencies": {
- "@mutates/core": "0.0.0-development",
- "minimatch": "9.0.3",
- "ts-morph": "^22.0.0",
"tslib": "^2.3.0"
},
"peerDependencies": {
- "@angular-devkit/schematics": ">=18.0.0"
+ "@angular-devkit/schematics": ">=18.0.0",
+ "@mutates/core": "0.0.0-development",
+ "ts-morph": ">=22.0.0"
},
"publishConfig": {
"access": "public"
diff --git a/packages/angular/src/lib/helpers/index.ts b/packages/angular/src/lib/helpers/index.ts
index b76a5e8..0c6e9d6 100644
--- a/packages/angular/src/lib/helpers/index.ts
+++ b/packages/angular/src/lib/helpers/index.ts
@@ -1 +1,4 @@
-export * from './match';
+/**
+ * @deprecated Use import from `@mutates/core` instead.
+ */
+export { match } from '@mutates/core';
diff --git a/packages/core/README.md b/packages/core/README.md
index bd44ea5..833be3d 100644
--- a/packages/core/README.md
+++ b/packages/core/README.md
@@ -1,3 +1,73 @@
# @mutates/core
-[WIP]
+🔧 **@mutates/core** is the essential package of the Mutates toolset, providing the core
+functionality to manipulate the Abstract Syntax Tree (AST) of TypeScript files. It serves as the
+backbone for other specialized packages within the Mutates ecosystem.
+
+## Features
+
+- **AST Manipulation:** Modify the AST of any TypeScript file with ease.
+- **TypeScript Focused:** Specifically designed for TypeScript, ensuring optimal integration and
+ performance.
+- **Extensible:** Can be extended with framework-specific packages for additional functionality.
+
+## Installation
+
+To install the core package, use the following command:
+
+```sh
+npm install @mutates/core
+```
+
+## Usage
+
+### Basic Example
+
+Here is a simple example demonstrating how to use `@mutates/core` to modify a TypeScript file:
+
+```typescript
+import { addFunctions, creataProject, createSourceFile, saveProject } from '@mutates/core';
+
+// Initialize a new project
+createProject();
+
+// Add a TypeScript file to the project
+createSourceFile(
+ 'example.ts',
+ `
+ const greet = (name: string) => {
+ return 'Hello, ' + name;
+ };
+`,
+);
+
+// Perform some transformations
+addFunctions('example.ts', {
+ name: 'farewell',
+ isExported: true,
+ statements: "return 'buy!'",
+});
+
+// Save the modified file
+saveProject();
+```
+
+## API Reference
+
+For a comprehensive guide on the available APIs and their usage, please refer to the
+[official documentation](https://mutates.katsuba.dev/packages/core)
+
+## Contributing
+
+🤝 Contributions are welcome! If you have any improvements or suggestions, feel free to open an
+issue or submit a pull request.
+
+## License
+
+📄 `@mutates/core` is licensed under the Apache-2.0 License. See the
+[LICENSE](https://github.com/ikatsuba/mutates/blob/main/LICENSE) file for more information.
+
+---
+
+For further assistance or to report issues, please visit our
+[GitHub repository](https://github.com/ikatsuba/mutates).
diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts
index 7e8f550..0d373eb 100644
--- a/packages/core/src/index.ts
+++ b/packages/core/src/index.ts
@@ -7,6 +7,7 @@ export * from './lib/enums';
export * from './lib/exports';
export * from './lib/fs/file-system';
export * from './lib/functions';
+export * from './lib/helpers';
export * from './lib/imports';
export * from './lib/interfaces';
export * from './lib/methods';
diff --git a/packages/core/src/lib/helpers/index.ts b/packages/core/src/lib/helpers/index.ts
new file mode 100644
index 0000000..b76a5e8
--- /dev/null
+++ b/packages/core/src/lib/helpers/index.ts
@@ -0,0 +1 @@
+export * from './match';
diff --git a/packages/angular/src/lib/helpers/match.ts b/packages/core/src/lib/helpers/match.ts
similarity index 100%
rename from packages/angular/src/lib/helpers/match.ts
rename to packages/core/src/lib/helpers/match.ts
diff --git a/packages/nx/.eslintrc.json b/packages/nx/.eslintrc.json
new file mode 100644
index 0000000..0dc93dd
--- /dev/null
+++ b/packages/nx/.eslintrc.json
@@ -0,0 +1,30 @@
+{
+ "extends": ["../../.eslintrc.json"],
+ "ignorePatterns": ["!**/*"],
+ "overrides": [
+ {
+ "files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
+ "rules": {}
+ },
+ {
+ "files": ["*.ts", "*.tsx"],
+ "rules": {}
+ },
+ {
+ "files": ["*.js", "*.jsx"],
+ "rules": {}
+ },
+ {
+ "files": ["*.json"],
+ "parser": "jsonc-eslint-parser",
+ "rules": {
+ "@nx/dependency-checks": [
+ "error",
+ {
+ "ignoredFiles": ["{projectRoot}/vite.config.{js,ts,mjs,mts}"]
+ }
+ ]
+ }
+ }
+ ]
+}
diff --git a/packages/nx/README.md b/packages/nx/README.md
new file mode 100644
index 0000000..f25b8ed
--- /dev/null
+++ b/packages/nx/README.md
@@ -0,0 +1,65 @@
+# @mutates/nx
+
+🚀 **@mutates/nx** is a specialized package within the Mutates toolset, offering robust tools to
+mutate the Abstract Syntax Tree (AST) of Nx workspaces. Built on top of `@mutates/core`, this
+package provides Nx-specific transformations, making it easier to work with the modular structure of
+Nx projects, including Angular, and other framework integrations.
+
+## Features
+
+- **Nx-Specific Transformations:** Modify the AST of Nx workspace files, including project
+ configurations, library files, and more.
+- **Seamless Integration:** Works in conjunction with `@mutates/core` for a cohesive development
+ experience.
+- **Versatile:** Supports a variety of frameworks within Nx workspaces, such as Angular.
+
+## Installation
+
+To install the Nx package, use the following command:
+
+```sh
+npm install @mutates/nx @mutates/core
+```
+
+## Usage
+
+### Basic Example
+
+For generators and migrations, the package provides special functions to connect with Nx Tree. Nx
+Tree is a special tree that is used to work with Nx workspaces. It is based on the `@nx/devkit`
+package.
+
+```typescript
+import { createTree } from '@nx/devkit/testing';
+
+import { readFileSync } from '@mutates/core';
+import { createNxProject } from '@mutates/nx';
+
+const tree = createTree();
+
+tree.write('/test.ts', `console.log('Hello, world!');`);
+
+createNxProject(tree);
+
+console.log(readFileSync('/test.ts'));
+```
+
+## API Reference
+
+For a comprehensive guide on the available APIs and their usage, please refer to the
+[official documentation](https://mutates.katsuba.dev/packages/nx)
+
+## Contributing
+
+🤝 Contributions are welcome! If you have any improvements or suggestions, feel free to open an
+issue or submit a pull request.
+
+## License
+
+📄 @mutates/nx is licensed under the Apache-2.0 License. For more information, see the
+[LICENSE](https://github.com/ikatsuba/mutates/blob/main/LICENSE) file.
+
+---
+
+For further assistance or to report issues, please visit our
+[GitHub repository](https://github.com/ikatsuba/mutates).
diff --git a/packages/nx/package.json b/packages/nx/package.json
new file mode 100644
index 0000000..eab5650
--- /dev/null
+++ b/packages/nx/package.json
@@ -0,0 +1,15 @@
+{
+ "name": "@mutates/nx",
+ "version": "0.0.1",
+ "type": "commonjs",
+ "main": "./src/index.js",
+ "typings": "./src/index.d.ts",
+ "dependencies": {
+ "tslib": "^2.3.0"
+ },
+ "peerDependencies": {
+ "@mutates/core": "0.0.0-development",
+ "@nx/devkit": ">=19.0.0",
+ "ts-morph": ">=22.0.0"
+ }
+}
diff --git a/packages/nx/project.json b/packages/nx/project.json
new file mode 100644
index 0000000..2a3594a
--- /dev/null
+++ b/packages/nx/project.json
@@ -0,0 +1,39 @@
+{
+ "name": "nx",
+ "$schema": "../../node_modules/nx/schemas/project-schema.json",
+ "sourceRoot": "packages/nx/src",
+ "projectType": "library",
+ "release": {
+ "version": {
+ "generatorOptions": {
+ "packageRoot": "dist/{projectRoot}",
+ "currentVersionResolver": "git-tag"
+ }
+ }
+ },
+ "tags": [],
+ "targets": {
+ "build": {
+ "executor": "@nx/js:tsc",
+ "outputs": ["{options.outputPath}"],
+ "options": {
+ "outputPath": "dist/packages/nx",
+ "main": "packages/nx/src/index.ts",
+ "tsConfig": "packages/nx/tsconfig.lib.json",
+ "assets": ["packages/nx/*.md"]
+ }
+ },
+ "nx-release-publish": {
+ "options": {
+ "packageRoot": "dist/{projectRoot}"
+ }
+ },
+ "test": {
+ "executor": "@nx/vite:test",
+ "outputs": ["{options.reportsDirectory}"],
+ "options": {
+ "reportsDirectory": "../../coverage/packages/nx"
+ }
+ }
+ }
+}
diff --git a/packages/nx/src/index.ts b/packages/nx/src/index.ts
new file mode 100644
index 0000000..666669b
--- /dev/null
+++ b/packages/nx/src/index.ts
@@ -0,0 +1,2 @@
+export * from './lib/create-nx-project';
+export * from './lib/create-nx-project';
diff --git a/packages/nx/src/lib/create-nx-project.spec.ts b/packages/nx/src/lib/create-nx-project.spec.ts
new file mode 100644
index 0000000..780bced
--- /dev/null
+++ b/packages/nx/src/lib/create-nx-project.spec.ts
@@ -0,0 +1,17 @@
+import { createTree } from '@nx/devkit/testing';
+
+import { readFileSync } from '@mutates/core';
+
+import { createNxProject } from './create-nx-project';
+
+describe('createNxProject', () => {
+ it('should call createProject with the correct file system', () => {
+ const tree = createTree();
+
+ tree.write('/test.ts', `console.log('Hello, world!');`);
+
+ createNxProject(tree);
+
+ expect(readFileSync('/test.ts')).toEqual("console.log('Hello, world!');");
+ });
+});
diff --git a/packages/nx/src/lib/create-nx-project.ts b/packages/nx/src/lib/create-nx-project.ts
new file mode 100644
index 0000000..aa7addf
--- /dev/null
+++ b/packages/nx/src/lib/create-nx-project.ts
@@ -0,0 +1,10 @@
+import { Tree } from '@nx/devkit';
+import { Project, ProjectOptions } from 'ts-morph';
+
+import { createProject } from '@mutates/core';
+
+import { NxTreeFileSystem } from './nx-tree-file-system';
+
+export function createNxProject(host: Tree, options?: Omit): Project {
+ return createProject(new NxTreeFileSystem(host), options);
+}
diff --git a/packages/nx/src/lib/nx-tree-file-system.ts b/packages/nx/src/lib/nx-tree-file-system.ts
new file mode 100644
index 0000000..7a2581f
--- /dev/null
+++ b/packages/nx/src/lib/nx-tree-file-system.ts
@@ -0,0 +1,123 @@
+import { basename, join } from 'node:path';
+import type { Tree } from '@nx/devkit';
+import { FileSystemHost, RuntimeDirEntry } from 'ts-morph';
+
+import { match } from '@mutates/core';
+
+export class NxTreeFileSystem implements FileSystemHost {
+ constructor(private readonly tree: Tree) {}
+
+ isCaseSensitive(): boolean {
+ return true;
+ }
+
+ async delete(path: string): Promise {
+ return this.tree.delete(path);
+ }
+
+ deleteSync(path: string): void {
+ return this.tree.delete(path);
+ }
+
+ readDirSync(dirPath: string): RuntimeDirEntry[] {
+ const children = this.tree.children(dirPath);
+
+ return children.map((name) => {
+ const isFile = this.tree.isFile(join(dirPath, name));
+
+ return {
+ name,
+ isFile,
+ isDirectory: !isFile,
+ isSymlink: false,
+ };
+ });
+ }
+
+ async readFile(filePath: string, encoding?: string | undefined): Promise {
+ return this.readFileSync(filePath, encoding);
+ }
+
+ readFileSync(filePath: string, encoding?: string | undefined): string {
+ const result = this.tree.read(filePath, encoding as BufferEncoding);
+
+ return (result ?? '').toString();
+ }
+
+ async writeFile(filePath: string, fileText: string): Promise {
+ this.writeFileSync(filePath, fileText);
+ }
+
+ writeFileSync(filePath: string, fileText: string): void {
+ this.tree.write(filePath, fileText);
+ }
+
+ mkdir(dirPath: string): Promise {
+ return Promise.resolve(undefined);
+ }
+
+ mkdirSync(dirPath: string): void {
+ // empty
+ }
+
+ async move(srcPath: string, destPath: string): Promise {
+ return this.moveSync(srcPath, destPath);
+ }
+
+ moveSync(srcPath: string, destPath: string): void {
+ this.copySync(srcPath, destPath);
+
+ this.deleteSync(srcPath);
+ }
+
+ async copy(srcPath: string, destPath: string): Promise {
+ return this.copySync(srcPath, destPath);
+ }
+
+ copySync(srcPath: string, destPath: string): void {
+ if (this.fileExistsSync(srcPath)) {
+ this.writeFileSync(destPath, this.readFileSync(srcPath));
+ } else if (this.directoryExistsSync(srcPath)) {
+ const paths = this.readDirSync(srcPath);
+
+ paths.forEach((path) => this.copySync(path.name, join(destPath, basename(path.name))));
+ }
+ }
+
+ async fileExists(filePath: string): Promise {
+ return this.fileExistsSync(filePath);
+ }
+
+ fileExistsSync(filePath: string): boolean {
+ return this.tree.exists(filePath);
+ }
+
+ async directoryExists(dirPath: string): Promise {
+ return this.directoryExistsSync(dirPath);
+ }
+
+ directoryExistsSync(dirPath: string): boolean {
+ return this.tree.exists(dirPath);
+ }
+
+ realpathSync(path: string): string {
+ return path;
+ }
+
+ getCurrentDirectory(): string {
+ return '/';
+ }
+
+ async glob(patterns: readonly string[]): Promise {
+ return this.globSync(patterns);
+ }
+
+ globSync(patterns: readonly string[]): string[] {
+ return match(
+ this.readDirSync('/')
+ .filter((entry) => entry.isFile)
+ .map((entry) => entry.name),
+ patterns as string[],
+ );
+ }
+}
diff --git a/packages/nx/tsconfig.json b/packages/nx/tsconfig.json
new file mode 100644
index 0000000..f5b8565
--- /dev/null
+++ b/packages/nx/tsconfig.json
@@ -0,0 +1,22 @@
+{
+ "extends": "../../tsconfig.base.json",
+ "compilerOptions": {
+ "module": "commonjs",
+ "forceConsistentCasingInFileNames": true,
+ "strict": true,
+ "noImplicitOverride": true,
+ "noPropertyAccessFromIndexSignature": true,
+ "noImplicitReturns": true,
+ "noFallthroughCasesInSwitch": true
+ },
+ "files": [],
+ "include": [],
+ "references": [
+ {
+ "path": "./tsconfig.lib.json"
+ },
+ {
+ "path": "./tsconfig.spec.json"
+ }
+ ]
+}
diff --git a/packages/nx/tsconfig.lib.json b/packages/nx/tsconfig.lib.json
new file mode 100644
index 0000000..ce3b531
--- /dev/null
+++ b/packages/nx/tsconfig.lib.json
@@ -0,0 +1,10 @@
+{
+ "extends": "./tsconfig.json",
+ "compilerOptions": {
+ "outDir": "../../dist/out-tsc",
+ "declaration": true,
+ "types": ["node"]
+ },
+ "include": ["src/**/*.ts"],
+ "exclude": ["vite.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]
+}
diff --git a/packages/nx/tsconfig.spec.json b/packages/nx/tsconfig.spec.json
new file mode 100644
index 0000000..0edf3f2
--- /dev/null
+++ b/packages/nx/tsconfig.spec.json
@@ -0,0 +1,20 @@
+{
+ "extends": "./tsconfig.json",
+ "compilerOptions": {
+ "outDir": "../../dist/out-tsc",
+ "types": ["vitest/globals", "vitest/importMeta", "vite/client", "node", "vitest"]
+ },
+ "include": [
+ "vite.config.ts",
+ "vitest.config.ts",
+ "src/**/*.test.ts",
+ "src/**/*.spec.ts",
+ "src/**/*.test.tsx",
+ "src/**/*.spec.tsx",
+ "src/**/*.test.js",
+ "src/**/*.spec.js",
+ "src/**/*.test.jsx",
+ "src/**/*.spec.jsx",
+ "src/**/*.d.ts"
+ ]
+}
diff --git a/packages/nx/vite.config.ts b/packages/nx/vite.config.ts
new file mode 100644
index 0000000..627c7e1
--- /dev/null
+++ b/packages/nx/vite.config.ts
@@ -0,0 +1,24 @@
+import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
+import { defineConfig } from 'vite';
+
+export default defineConfig({
+ root: __dirname,
+ cacheDir: '../../node_modules/.vite/packages/nx',
+
+ plugins: [nxViteTsPaths()],
+
+ // Uncomment this if you are using workers.
+ // worker: {
+ // plugins: [ nxViteTsPaths() ],
+ // },
+
+ test: {
+ watch: false,
+ globals: true,
+ cache: { dir: '../../node_modules/.vitest/packages/nx' },
+ environment: 'node',
+ include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
+ reporters: ['default'],
+ coverage: { reportsDirectory: '../../coverage/packages/nx', provider: 'v8' },
+ },
+});
diff --git a/tsconfig.base.json b/tsconfig.base.json
index 498315a..90f4fe6 100644
--- a/tsconfig.base.json
+++ b/tsconfig.base.json
@@ -17,7 +17,8 @@
"paths": {
"@mutates/angular": ["packages/angular/src/index.ts"],
"@mutates/core": ["packages/core/src/index.ts"],
- "@mutates/core/testing": ["packages/core/src/testing.ts"]
+ "@mutates/core/testing": ["packages/core/src/testing.ts"],
+ "@mutates/nx": ["packages/nx/src/index.ts"]
}
},
"exclude": ["node_modules", "tmp"]