@mutates/angular 1.1.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,3 +1,101 @@
1
1
  # @mutates/angular
2
2
 
3
- [WIP]
3
+ 🌟 **@mutates/angular** is a specialized package within the Mutates toolset, offering powerful tools
4
+ to mutate the Abstract Syntax Tree (AST) of Angular projects. Built on top of `@mutates/core`, this
5
+ package provides Angular-specific transformations, making it easier to work with Angular components,
6
+ directives, services, and more.
7
+
8
+ ## Features
9
+
10
+ - **Angular-Specific Transformations:** Modify the AST of Angular components, directives, modules,
11
+ and services.
12
+ - **Seamless Integration:** Works in conjunction with `@mutates/core` for a smooth development
13
+ experience.
14
+ - **Efficient:** Designed to handle the unique structure and requirements of Angular projects.
15
+
16
+ ## Installation
17
+
18
+ To install the Angular package, use the following command:
19
+
20
+ ```sh
21
+ npm install @mutates/angular @mutates/core
22
+ ```
23
+
24
+ ## Usage
25
+
26
+ ### Basic Example
27
+
28
+ Here is a simple example demonstrating how to use `@mutates/angular` to modify an Angular component:
29
+
30
+ ```typescript
31
+ import { addProviders, getComponents } from '@mutates/angular';
32
+ import { createProject, createSourceFile, saveProject } from '@mutates/core';
33
+
34
+ // Initialize a new Angular project
35
+ createProject();
36
+
37
+ // Add an Angular component file to the project
38
+ createSourceFile(
39
+ 'app.component.ts',
40
+ `
41
+ import { Component } from '@angular/core';
42
+
43
+ @Component({
44
+ selector: 'app-root',
45
+ template: '<h1>Hello, World!</h1>'
46
+ })
47
+ export class AppComponent {}
48
+ `,
49
+ );
50
+
51
+ // Perform some Angular-specific transformations
52
+ addProviders(getComponents('app.component.ts').at(0)!, ['AppService']);
53
+
54
+ // Save the modified file
55
+ saveProject();
56
+ ```
57
+
58
+ For schematics and migrations the package provided special function to connect with Angular Tree.
59
+ Angular Tree is a special tree that is used to work with Angular projects. It is based on the
60
+ `@angular-devkit/schematics` package.
61
+
62
+ ```typescript
63
+ import { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
64
+
65
+ import { createAngularProject } from '@mutates/angular';
66
+ import { saveProject } from '@mutates/core';
67
+
68
+ export function mySchematic(): Rule {
69
+ return (tree: Tree, context: SchematicContext) => {
70
+ // Use Angular Tree to work with Angular projects
71
+ createAngularProject(tree);
72
+
73
+ // Perform Angular-specific transformations
74
+ addProviders(getComponents('app.component.ts').at(0)!, ['AppService']);
75
+
76
+ saveProject();
77
+
78
+ return tree;
79
+ };
80
+ }
81
+ ```
82
+
83
+ ## API Reference
84
+
85
+ For a comprehensive guide on the available APIs and their usage, please refer to the
86
+ [official documentation](https://mutates.katsuba.dev/packages/angular)
87
+
88
+ ## Contributing
89
+
90
+ 🤝 Contributions are welcome! If you have any improvements or suggestions, feel free to open an
91
+ issue or submit a pull request.
92
+
93
+ ## License
94
+
95
+ 📄 @mutates/angular is licensed under the Apache-2.0 License. See the
96
+ [LICENSE](https://github.com/ikatsuba/mutates/blob/main/LICENSE) file for more information.
97
+
98
+ ---
99
+
100
+ For further assistance or to report issues, please visit our
101
+ [GitHub repository](https://github.com/ikatsuba/mutates).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mutates/angular",
3
- "version": "1.1.0",
3
+ "version": "1.2.1",
4
4
  "keywords": [
5
5
  "typescript",
6
6
  "ast",
@@ -23,13 +23,12 @@
23
23
  "main": "./src/index.js",
24
24
  "typings": "./src/index.d.ts",
25
25
  "dependencies": {
26
- "@mutates/core": "1.1.0",
27
- "minimatch": "9.0.3",
28
- "ts-morph": "^22.0.0",
29
26
  "tslib": "^2.3.0"
30
27
  },
31
28
  "peerDependencies": {
32
- "@angular-devkit/schematics": ">=18.0.0"
29
+ "@angular-devkit/schematics": ">=18.0.0",
30
+ "@mutates/core": "0.0.0-development",
31
+ "ts-morph": ">=22.0.0"
33
32
  },
34
33
  "publishConfig": {
35
34
  "access": "public"
@@ -1 +1,4 @@
1
- export * from './match';
1
+ /**
2
+ * @deprecated Use import from `@mutates/core` instead.
3
+ */
4
+ export { match } from '@mutates/core';
@@ -1,5 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./match"), exports);
3
+ exports.match = void 0;
4
+ /**
5
+ * @deprecated Use import from `@mutates/core` instead.
6
+ */
7
+ var core_1 = require("@mutates/core");
8
+ Object.defineProperty(exports, "match", { enumerable: true, get: function () { return core_1.match; } });
5
9
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/angular/src/lib/helpers/index.ts"],"names":[],"mappings":";;;AAAA,kDAAwB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/angular/src/lib/helpers/index.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,sCAAsC;AAA7B,6FAAA,KAAK,OAAA"}
@@ -1,2 +0,0 @@
1
- import { MinimatchOptions } from 'minimatch';
2
- export declare function match(list: string | readonly string[], patterns: string | readonly string[], options?: MinimatchOptions): string[];
@@ -1,41 +0,0 @@
1
- "use strict";
2
- /*
3
- * This file includes code from the library multimatch.
4
- * License for the original code:
5
- *
6
- * MIT License
7
- *
8
- * Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
9
- *
10
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
11
- *
12
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
13
- *
14
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15
- *
16
- * The code was sourced from: https://github.com/sindresorhus/multimatch/blob/main/index.js
17
- */
18
- Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.match = void 0;
20
- const minimatch_1 = require("minimatch");
21
- function match(list, patterns, options) {
22
- list = [list].flat();
23
- patterns = [patterns].flat();
24
- if (list.length === 0 || patterns.length === 0) {
25
- return [];
26
- }
27
- let result = [];
28
- for (const item of list) {
29
- for (let pattern of patterns) {
30
- let process = (res, matches) => res.concat(matches);
31
- if (pattern[0] === '!') {
32
- pattern = pattern.slice(1);
33
- process = (res, matches) => res.filter((x) => !matches.includes(x));
34
- }
35
- result = process(result, minimatch_1.minimatch.match([item], pattern, options));
36
- }
37
- }
38
- return result;
39
- }
40
- exports.match = match;
41
- //# sourceMappingURL=match.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"match.js","sourceRoot":"","sources":["../../../../../../packages/angular/src/lib/helpers/match.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAEH,yCAAwD;AAExD,SAAgB,KAAK,CACnB,IAAgC,EAChC,QAAoC,EACpC,OAA0B;IAE1B,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;IACrB,QAAQ,GAAG,CAAC,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC;IAE7B,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/C,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,IAAI,MAAM,GAAa,EAAE,CAAC;IAC1B,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;QACxB,KAAK,IAAI,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC7B,IAAI,OAAO,GAAG,CAAC,GAAa,EAAE,OAAiB,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAExE,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;gBACvB,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBAC3B,OAAO,GAAG,CAAC,GAAa,EAAE,OAAiB,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;YAC1F,CAAC;YAED,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,qBAAS,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;QACtE,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AA3BD,sBA2BC"}