@danieljaurellmevorach/javascript-recipe-starter 1.0.0
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/LICENSE +201 -0
- package/README.md +71 -0
- package/dist/find-method-calls.d.ts +20 -0
- package/dist/find-method-calls.d.ts.map +1 -0
- package/dist/find-method-calls.js +93 -0
- package/dist/find-method-calls.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +41 -0
- package/dist/index.js.map +1 -0
- package/dist/migrate-util-functions.d.ts +8 -0
- package/dist/migrate-util-functions.d.ts.map +1 -0
- package/dist/migrate-util-functions.js +62 -0
- package/dist/migrate-util-functions.js.map +1 -0
- package/dist/say-hello-recipe.d.ts +8 -0
- package/dist/say-hello-recipe.d.ts.map +1 -0
- package/dist/say-hello-recipe.js +73 -0
- package/dist/say-hello-recipe.js.map +1 -0
- package/dist/semantic-matching.d.ts +8 -0
- package/dist/semantic-matching.d.ts.map +1 -0
- package/dist/semantic-matching.js +58 -0
- package/dist/semantic-matching.js.map +1 -0
- package/dist/update-function-origin-sensitive.d.ts +8 -0
- package/dist/update-function-origin-sensitive.d.ts.map +1 -0
- package/dist/update-function-origin-sensitive.js +53 -0
- package/dist/update-function-origin-sensitive.js.map +1 -0
- package/dist/updateFunctionName.d.ts +8 -0
- package/dist/updateFunctionName.d.ts.map +1 -0
- package/dist/updateFunctionName.js +53 -0
- package/dist/updateFunctionName.js.map +1 -0
- package/package.json +53 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# JavaScript Recipe Starter
|
|
2
|
+
|
|
3
|
+
A starter repository for learning how to create [OpenRewrite](https://github.com/openrewrite/rewrite) recipes for JavaScript and TypeScript. This repo includes example recipes with comprehensive tests, demonstrating the full project setup you need to author and test your own recipes.
|
|
4
|
+
|
|
5
|
+
## Getting started
|
|
6
|
+
|
|
7
|
+
New to OpenRewrite JavaScript recipe development? Start by checking out the [OpenRewrite documentation](https://docs.openrewrite.org/) and our [JavaScript LST examples doc](https://docs.openrewrite.org/concepts-and-explanations/javascript-lst-examples).
|
|
8
|
+
|
|
9
|
+
## Quick start
|
|
10
|
+
|
|
11
|
+
Clone this repository and install dependencies:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
git clone git@github.com:moderneinc/javascript-recipe-starter.git
|
|
15
|
+
cd javascript-recipe-starter
|
|
16
|
+
npm install
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Run the tests:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm test
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Example recipes
|
|
26
|
+
|
|
27
|
+
This repository includes example recipes that demonstrate different authoring approaches and OpenRewrite capabilities:
|
|
28
|
+
|
|
29
|
+
### Transformation recipes
|
|
30
|
+
|
|
31
|
+
- **[MigrateUtilFunctions](./src/migrate-util-functions.ts)** - Replaces deprecated Node.js `util` type checking methods (like `util.isArray()`) with native JavaScript equivalents (like `Array.isArray()`). Demonstrates pattern-based, declarative recipe authoring using `pattern` and `rewrite()` rules with type context.
|
|
32
|
+
|
|
33
|
+
- **[SayHelloRecipe](./src/say-hello-recipe.ts)** - Adds a `hello()` method to JavaScript/TypeScript classes that don't already have one. Demonstrates visitor-based recipe authoring with manual LST manipulation and the template API.
|
|
34
|
+
|
|
35
|
+
- **[SemanticForwardRefMigration](./src/semantic-matching.ts)** - Wraps React `forwardRef()` calls with `memo()` for better performance. Demonstrates **semantic type matching** that works across different import styles (named, namespace, default, and aliased imports). Shows how one pattern with type context can match syntactically different but semantically equivalent code.
|
|
36
|
+
|
|
37
|
+
### Search recipes
|
|
38
|
+
|
|
39
|
+
- **[FindMethodCalls](./src/find-method-calls.ts)** - Finds and records all calls to a specified method name in a data table. Demonstrates **search recipes** that collect findings without modifying code, useful for impact analysis before migrations. Shows the `@Option` decorator for configurable recipes and `@Column` for data table structure. Results can be exported to CSV.
|
|
40
|
+
|
|
41
|
+
## Project structure
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
javascript-recipe-starter/
|
|
45
|
+
├── src/
|
|
46
|
+
│ ├── migrate-util-functions.ts
|
|
47
|
+
│ ├── say-hello-recipe.ts
|
|
48
|
+
│ ├── semantic-matching.ts
|
|
49
|
+
│ ├── find-method-calls.ts
|
|
50
|
+
│ └── index.ts
|
|
51
|
+
├── test/
|
|
52
|
+
│ ├── migrate-util-functions.test.ts
|
|
53
|
+
│ ├── say-hello-recipe.test.ts
|
|
54
|
+
│ ├── semantic-matching.test.ts
|
|
55
|
+
│ └── find-method-calls.test.ts
|
|
56
|
+
├── package.json
|
|
57
|
+
├── tsconfig.json
|
|
58
|
+
└── jest.config.js
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Running your recipes
|
|
62
|
+
|
|
63
|
+
To run these recipes against your own JavaScript/TypeScript codebase, you'll need to use the [Moderne CLI](https://docs.moderne.io/user-documentation/moderne-cli/getting-started/cli-intro) and [configure it to use JavaScript LSTs](https://docs.moderne.io/user-documentation/moderne-cli/how-to-guides/javascript):
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
mod run . --recipe=MigrateUtilFunctions
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## License
|
|
70
|
+
|
|
71
|
+
See [LICENSE](./LICENSE) file for details.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ExecutionContext, Recipe, TreeVisitor, DataTable } from "@openrewrite/rewrite";
|
|
2
|
+
export declare class MethodCallRecord {
|
|
3
|
+
readonly sourceFile: string;
|
|
4
|
+
readonly methodName: string;
|
|
5
|
+
readonly code: string;
|
|
6
|
+
constructor(sourceFile: string, methodName: string, code: string);
|
|
7
|
+
static dataTable: DataTable<MethodCallRecord>;
|
|
8
|
+
}
|
|
9
|
+
export declare class FindMethodCalls extends Recipe {
|
|
10
|
+
name: string;
|
|
11
|
+
displayName: string;
|
|
12
|
+
description: string;
|
|
13
|
+
methodName: string;
|
|
14
|
+
constructor(options: {
|
|
15
|
+
methodName: string;
|
|
16
|
+
});
|
|
17
|
+
findings: DataTable<MethodCallRecord>;
|
|
18
|
+
editor(): Promise<TreeVisitor<any, ExecutionContext>>;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=find-method-calls.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-method-calls.d.ts","sourceRoot":"","sources":["../src/find-method-calls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAU,MAAM,EAAa,WAAW,EAAE,SAAS,EAA4B,MAAM,sBAAsB,CAAC;AAOpI,qBAAa,gBAAgB;IAKzB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAM5B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAM5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEV,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAMhE,MAAM,CAAC,SAAS,8BAKd;CACL;AAWD,qBAAa,eAAgB,SAAQ,MAAM;IACvC,IAAI,SAAiC;IACrC,WAAW,SAAuB;IAClC,WAAW,SAA2E;IAMtF,UAAU,EAAG,MAAM,CAAC;gBAER,OAAO,EAAE;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE;IAK3C,QAAQ,8BAA8B;IAEhC,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;CAqC9D"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
9
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
10
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
12
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
13
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
14
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.FindMethodCalls = exports.MethodCallRecord = void 0;
|
|
19
|
+
const rewrite_1 = require("@openrewrite/rewrite");
|
|
20
|
+
const javascript_1 = require("@openrewrite/rewrite/javascript");
|
|
21
|
+
class MethodCallRecord {
|
|
22
|
+
constructor(sourceFile, methodName, code) {
|
|
23
|
+
this.sourceFile = sourceFile;
|
|
24
|
+
this.methodName = methodName;
|
|
25
|
+
this.code = code;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.MethodCallRecord = MethodCallRecord;
|
|
29
|
+
MethodCallRecord.dataTable = new rewrite_1.DataTable("org.example.method-calls", "Method call findings", "All occurrences of the target method call", MethodCallRecord);
|
|
30
|
+
__decorate([
|
|
31
|
+
(0, rewrite_1.Column)({
|
|
32
|
+
displayName: "Source file",
|
|
33
|
+
description: "The source file containing the method call"
|
|
34
|
+
})
|
|
35
|
+
], MethodCallRecord.prototype, "sourceFile", void 0);
|
|
36
|
+
__decorate([
|
|
37
|
+
(0, rewrite_1.Column)({
|
|
38
|
+
displayName: "Method name",
|
|
39
|
+
description: "The name of the method being called"
|
|
40
|
+
})
|
|
41
|
+
], MethodCallRecord.prototype, "methodName", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, rewrite_1.Column)({
|
|
44
|
+
displayName: "Code snippet",
|
|
45
|
+
description: "The code snippet of the method call"
|
|
46
|
+
})
|
|
47
|
+
], MethodCallRecord.prototype, "code", void 0);
|
|
48
|
+
class FindMethodCalls extends rewrite_1.Recipe {
|
|
49
|
+
constructor(options) {
|
|
50
|
+
super(options);
|
|
51
|
+
this.name = "org.example.FindMethodCalls";
|
|
52
|
+
this.displayName = "Find method calls";
|
|
53
|
+
this.description = "Finds all calls to a specific method and records them in a data table";
|
|
54
|
+
this.findings = MethodCallRecord.dataTable;
|
|
55
|
+
}
|
|
56
|
+
editor() {
|
|
57
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
+
const methodName = this.methodName;
|
|
59
|
+
const findings = this.findings;
|
|
60
|
+
return new class extends javascript_1.JavaScriptVisitor {
|
|
61
|
+
visitMethodInvocation(method, ctx) {
|
|
62
|
+
const _super = Object.create(null, {
|
|
63
|
+
visitMethodInvocation: { get: () => super.visitMethodInvocation }
|
|
64
|
+
});
|
|
65
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
var _a, _b, _c, _d;
|
|
67
|
+
method = (yield _super.visitMethodInvocation.call(this, method, ctx));
|
|
68
|
+
if (method.name.simpleName === methodName) {
|
|
69
|
+
const cu = this.cursor.firstEnclosing((t) => t !== null && typeof t === 'object' && 'sourcePath' in t);
|
|
70
|
+
const sourceFile = (_a = cu === null || cu === void 0 ? void 0 : cu.sourcePath) !== null && _a !== void 0 ? _a : "unknown";
|
|
71
|
+
const argCount = (_d = (_c = (_b = method.arguments) === null || _b === void 0 ? void 0 : _b.elements) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0;
|
|
72
|
+
const code = `${methodName}(${argCount > 0 ? '...' : ''})`;
|
|
73
|
+
findings.insertRow(ctx, new MethodCallRecord(sourceFile, methodName, code));
|
|
74
|
+
return (0, rewrite_1.foundSearchResult)(method);
|
|
75
|
+
}
|
|
76
|
+
return method;
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
exports.FindMethodCalls = FindMethodCalls;
|
|
84
|
+
__decorate([
|
|
85
|
+
(0, rewrite_1.Option)({
|
|
86
|
+
displayName: "Method name",
|
|
87
|
+
description: "The method name to search for"
|
|
88
|
+
})
|
|
89
|
+
], FindMethodCalls.prototype, "methodName", void 0);
|
|
90
|
+
__decorate([
|
|
91
|
+
rewrite_1.Transient
|
|
92
|
+
], FindMethodCalls.prototype, "findings", void 0);
|
|
93
|
+
//# sourceMappingURL=find-method-calls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-method-calls.js","sourceRoot":"","sources":["../src/find-method-calls.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,kDAAoI;AACpI,gEAAkE;AAMlE,MAAa,gBAAgB;IAmBzB,YAAY,UAAkB,EAAE,UAAkB,EAAE,IAAY;QAC5D,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC;;AAvBL,4CA+BC;AANU,0BAAS,GAAG,IAAI,mBAAS,CAC5B,0BAA0B,EAC1B,sBAAsB,EACtB,2CAA2C,EAC3C,gBAAgB,CACnB,CAAC;AAzBO;IAJR,IAAA,gBAAM,EAAC;QACJ,WAAW,EAAE,aAAa;QAC1B,WAAW,EAAE,4CAA4C;KAC5D,CAAC;oDAC0B;AAMnB;IAJR,IAAA,gBAAM,EAAC;QACJ,WAAW,EAAE,aAAa;QAC1B,WAAW,EAAE,qCAAqC;KACrD,CAAC;oDAC0B;AAMnB;IAJR,IAAA,gBAAM,EAAC;QACJ,WAAW,EAAE,cAAc;QAC3B,WAAW,EAAE,qCAAqC;KACrD,CAAC;8CACoB;AAyB1B,MAAa,eAAgB,SAAQ,gBAAM;IAWvC,YAAY,OAA+B;QACvC,KAAK,CAAC,OAAO,CAAC,CAAC;QAXnB,SAAI,GAAG,6BAA6B,CAAC;QACrC,gBAAW,GAAG,mBAAmB,CAAC;QAClC,gBAAW,GAAG,uEAAuE,CAAC;QAatF,aAAQ,GAAG,gBAAgB,CAAC,SAAS,CAAC;IAHtC,CAAC;IAKK,MAAM;;YACR,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;YACnC,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;YAE/B,OAAO,IAAI,KAAM,SAAQ,8BAAmC;gBACxC,qBAAqB,CACjC,MAA0B,EAC1B,GAAqB;;;;;;wBAErB,MAAM,GAAG,CAAC,MAAM,OAAM,qBAAqB,YAAC,MAAM,EAAE,GAAG,CAAC,CAAuB,CAAC;wBAEhF,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,KAAK,UAAU,EAAE,CAAC;4BAGxC,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,EAAY,EAAE,CAClD,CAAC,KAAK,IAAI,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,YAAY,IAAI,CAAC,CAC3D,CAAC;4BACF,MAAM,UAAU,GAAG,MAAA,EAAE,aAAF,EAAE,uBAAF,EAAE,CAAE,UAAU,mCAAI,SAAS,CAAC;4BAG/C,MAAM,QAAQ,GAAG,MAAA,MAAA,MAAA,MAAM,CAAC,SAAS,0CAAE,QAAQ,0CAAE,MAAM,mCAAI,CAAC,CAAC;4BACzD,MAAM,IAAI,GAAG,GAAG,UAAU,IAAI,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC;4BAE3D,QAAQ,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,gBAAgB,CACxC,UAAU,EACV,UAAU,EACV,IAAI,CACP,CAAC,CAAC;4BAGH,OAAO,IAAA,2BAAiB,EAAC,MAAM,CAAC,CAAC;wBACrC,CAAC;wBAED,OAAO,MAAM,CAAC;oBAClB,CAAC;iBAAA;aACJ,CAAA;QACL,CAAC;KAAA;CACJ;AAvDD,0CAuDC;AA9CG;IAJC,IAAA,gBAAM,EAAC;QACJ,WAAW,EAAE,aAAa;QAC1B,WAAW,EAAE,+BAA+B;KAC/C,CAAC;mDACkB;AAOpB;IADC,mBAAS;iDAC4B"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RecipeMarketplace } from '@openrewrite/rewrite';
|
|
2
|
+
export { MigrateUtilFunctions } from './migrate-util-functions';
|
|
3
|
+
export { SayHelloRecipe } from './say-hello-recipe';
|
|
4
|
+
export { FindMethodCalls } from './find-method-calls';
|
|
5
|
+
export { SemanticForwardRefMigration } from './semantic-matching';
|
|
6
|
+
export { MigrateFictionalLoggerV2 } from './updateFunctionName';
|
|
7
|
+
export declare function activate(marketplace: RecipeMarketplace): Promise<void>;
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,iBAAiB,EAAC,MAAM,sBAAsB,CAAC;AAQnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAQhE,wBAAsB,QAAQ,CAAC,WAAW,EAAE,iBAAiB,iBAO5D"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.MigrateFictionalLoggerV2 = exports.SemanticForwardRefMigration = exports.FindMethodCalls = exports.SayHelloRecipe = exports.MigrateUtilFunctions = void 0;
|
|
13
|
+
exports.activate = activate;
|
|
14
|
+
const rewrite_1 = require("@openrewrite/rewrite");
|
|
15
|
+
const find_method_calls_1 = require("./find-method-calls");
|
|
16
|
+
const migrate_util_functions_1 = require("./migrate-util-functions");
|
|
17
|
+
const say_hello_recipe_1 = require("./say-hello-recipe");
|
|
18
|
+
const semantic_matching_1 = require("./semantic-matching");
|
|
19
|
+
const update_function_origin_sensitive_1 = require("./update-function-origin-sensitive");
|
|
20
|
+
const updateFunctionName_1 = require("./updateFunctionName");
|
|
21
|
+
var migrate_util_functions_2 = require("./migrate-util-functions");
|
|
22
|
+
Object.defineProperty(exports, "MigrateUtilFunctions", { enumerable: true, get: function () { return migrate_util_functions_2.MigrateUtilFunctions; } });
|
|
23
|
+
var say_hello_recipe_2 = require("./say-hello-recipe");
|
|
24
|
+
Object.defineProperty(exports, "SayHelloRecipe", { enumerable: true, get: function () { return say_hello_recipe_2.SayHelloRecipe; } });
|
|
25
|
+
var find_method_calls_2 = require("./find-method-calls");
|
|
26
|
+
Object.defineProperty(exports, "FindMethodCalls", { enumerable: true, get: function () { return find_method_calls_2.FindMethodCalls; } });
|
|
27
|
+
var semantic_matching_2 = require("./semantic-matching");
|
|
28
|
+
Object.defineProperty(exports, "SemanticForwardRefMigration", { enumerable: true, get: function () { return semantic_matching_2.SemanticForwardRefMigration; } });
|
|
29
|
+
var updateFunctionName_2 = require("./updateFunctionName");
|
|
30
|
+
Object.defineProperty(exports, "MigrateFictionalLoggerV2", { enumerable: true, get: function () { return updateFunctionName_2.MigrateFictionalLoggerV2; } });
|
|
31
|
+
function activate(marketplace) {
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
yield marketplace.install(find_method_calls_1.FindMethodCalls, rewrite_1.JavaScript);
|
|
34
|
+
yield marketplace.install(migrate_util_functions_1.MigrateUtilFunctions, rewrite_1.JavaScript);
|
|
35
|
+
yield marketplace.install(say_hello_recipe_1.SayHelloRecipe, rewrite_1.JavaScript);
|
|
36
|
+
yield marketplace.install(semantic_matching_1.SemanticForwardRefMigration, rewrite_1.JavaScript);
|
|
37
|
+
yield marketplace.install(update_function_origin_sensitive_1.MigrateUuidV4, rewrite_1.JavaScript);
|
|
38
|
+
yield marketplace.install(updateFunctionName_1.MigrateFictionalLoggerV2, rewrite_1.JavaScript);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAoBA,4BAOC;AA3BD,kDAAmE;AACnE,2DAAoD;AACpD,qEAA8D;AAC9D,yDAAkD;AAClD,2DAAgE;AAChE,yFAAmE;AACnE,6DAAgE;AAEhE,mEAAgE;AAAvD,8HAAA,oBAAoB,OAAA;AAC7B,uDAAoD;AAA3C,kHAAA,cAAc,OAAA;AACvB,yDAAsD;AAA7C,oHAAA,eAAe,OAAA;AACxB,yDAAkE;AAAzD,gIAAA,2BAA2B,OAAA;AACpC,2DAAgE;AAAvD,8HAAA,wBAAwB,OAAA;AAQjC,SAAsB,QAAQ,CAAC,WAA8B;;QACzD,MAAM,WAAW,CAAC,OAAO,CAAC,mCAAe,EAAE,oBAAU,CAAC,CAAC;QACvD,MAAM,WAAW,CAAC,OAAO,CAAC,6CAAoB,EAAE,oBAAU,CAAC,CAAC;QAC5D,MAAM,WAAW,CAAC,OAAO,CAAC,iCAAc,EAAE,oBAAU,CAAC,CAAC;QACtD,MAAM,WAAW,CAAC,OAAO,CAAC,+CAA2B,EAAE,oBAAU,CAAC,CAAC;QACnE,MAAM,WAAW,CAAC,OAAO,CAAC,gDAAa,EAAE,oBAAU,CAAC,CAAC;QACrD,MAAM,WAAW,CAAC,OAAO,CAAC,6CAAwB,EAAE,oBAAU,CAAC,CAAC;IACpE,CAAC;CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ExecutionContext, Recipe, TreeVisitor } from '@openrewrite/rewrite';
|
|
2
|
+
export declare class MigrateUtilFunctions extends Recipe {
|
|
3
|
+
readonly name = "com.yourorg.MigrateUtilFunctions";
|
|
4
|
+
readonly displayName = "Migrate util type checking functions";
|
|
5
|
+
readonly description = "Replace deprecated util.isX() methods with native JavaScript equivalents";
|
|
6
|
+
editor(): Promise<TreeVisitor<any, ExecutionContext>>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=migrate-util-functions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate-util-functions.d.ts","sourceRoot":"","sources":["../src/migrate-util-functions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,gBAAgB,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAiBpF,qBAAa,oBAAqB,SAAQ,MAAM;IAC5C,QAAQ,CAAC,IAAI,sCAAsC;IACnD,QAAQ,CAAC,WAAW,0CAA0C;IAC9D,QAAQ,CAAC,WAAW,8EAA8E;IAE5F,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;CAO9D"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.MigrateUtilFunctions = void 0;
|
|
13
|
+
const rewrite_1 = require("@openrewrite/rewrite");
|
|
14
|
+
const javascript_1 = require("@openrewrite/rewrite/javascript");
|
|
15
|
+
class MigrateUtilFunctions extends rewrite_1.Recipe {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(...arguments);
|
|
18
|
+
this.name = "com.yourorg.MigrateUtilFunctions";
|
|
19
|
+
this.displayName = "Migrate util type checking functions";
|
|
20
|
+
this.description = "Replace deprecated util.isX() methods with native JavaScript equivalents";
|
|
21
|
+
}
|
|
22
|
+
editor() {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
return (0, rewrite_1.check)((0, javascript_1.usesMethod)("util is*(..)"), new MigrateUtilFunctionsVisitor());
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.MigrateUtilFunctions = MigrateUtilFunctions;
|
|
29
|
+
class MigrateUtilFunctionsVisitor extends javascript_1.JavaScriptVisitor {
|
|
30
|
+
constructor() {
|
|
31
|
+
super(...arguments);
|
|
32
|
+
this.patternConfig = {
|
|
33
|
+
context: ["import * as util from 'util';"],
|
|
34
|
+
dependencies: { '@types/node': '^22.0.0' }
|
|
35
|
+
};
|
|
36
|
+
this.arg = (0, javascript_1.capture)();
|
|
37
|
+
this.isArrayRule = (0, javascript_1.rewrite)(() => ({
|
|
38
|
+
before: (0, javascript_1.pattern) `util.isArray(${this.arg})`.configure(this.patternConfig),
|
|
39
|
+
after: (0, javascript_1.template) `Array.isArray(${this.arg})`
|
|
40
|
+
}));
|
|
41
|
+
this.isBooleanRule = (0, javascript_1.rewrite)(() => ({
|
|
42
|
+
before: (0, javascript_1.pattern) `util.isBoolean(${this.arg})`.configure(this.patternConfig),
|
|
43
|
+
after: (0, javascript_1.template) `typeof ${this.arg} === 'boolean'`
|
|
44
|
+
}));
|
|
45
|
+
this.isStringRule = (0, javascript_1.rewrite)(() => ({
|
|
46
|
+
before: (0, javascript_1.pattern) `util.isString(${this.arg})`.configure(this.patternConfig),
|
|
47
|
+
after: (0, javascript_1.template) `typeof ${this.arg} === 'string'`
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
visitMethodInvocation(method, ctx) {
|
|
51
|
+
const _super = Object.create(null, {
|
|
52
|
+
visitMethodInvocation: { get: () => super.visitMethodInvocation }
|
|
53
|
+
});
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
return (yield this.isArrayRule.tryOn(this.cursor, method))
|
|
56
|
+
|| (yield this.isBooleanRule.tryOn(this.cursor, method))
|
|
57
|
+
|| (yield this.isStringRule.tryOn(this.cursor, method))
|
|
58
|
+
|| (yield _super.visitMethodInvocation.call(this, method, ctx));
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=migrate-util-functions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate-util-functions.js","sourceRoot":"","sources":["../src/migrate-util-functions.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAAoF;AACpF,gEAAqH;AAgBrH,MAAa,oBAAqB,SAAQ,gBAAM;IAAhD;;QACa,SAAI,GAAG,kCAAkC,CAAC;QAC1C,gBAAW,GAAG,sCAAsC,CAAC;QACrD,gBAAW,GAAG,0EAA0E,CAAC;IAStG,CAAC;IAPS,MAAM;;YAER,OAAO,IAAA,eAAK,EACR,IAAA,uBAAU,EAAC,cAAc,CAAC,EAC1B,IAAI,2BAA2B,EAAE,CACpC,CAAC;QACN,CAAC;KAAA;CACJ;AAZD,oDAYC;AAKD,MAAM,2BAA4B,SAAQ,8BAAmC;IAA7E;;QAGY,kBAAa,GAAG;YACpB,OAAO,EAAE,CAAC,+BAA+B,CAAC;YAG1C,YAAY,EAAE,EAAE,aAAa,EAAE,SAAS,EAAE;SAC7C,CAAC;QAGM,QAAG,GAAG,IAAA,oBAAO,GAAE,CAAC;QAKhB,gBAAW,GAAG,IAAA,oBAAO,EAAC,GAAG,EAAE,CAAC,CAAC;YACjC,MAAM,EAAE,IAAA,oBAAO,EAAA,gBAAgB,IAAI,CAAC,GAAG,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,aAAa,CAAC;YACxE,KAAK,EAAE,IAAA,qBAAQ,EAAA,iBAAiB,IAAI,CAAC,GAAG,GAAG;SAC9C,CAAC,CAAC,CAAC;QAEI,kBAAa,GAAG,IAAA,oBAAO,EAAC,GAAG,EAAE,CAAC,CAAC;YACnC,MAAM,EAAE,IAAA,oBAAO,EAAA,kBAAkB,IAAI,CAAC,GAAG,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,aAAa,CAAC;YAC1E,KAAK,EAAE,IAAA,qBAAQ,EAAA,UAAU,IAAI,CAAC,GAAG,gBAAgB;SACpD,CAAC,CAAC,CAAC;QAEI,iBAAY,GAAG,IAAA,oBAAO,EAAC,GAAG,EAAE,CAAC,CAAC;YAClC,MAAM,EAAE,IAAA,oBAAO,EAAA,iBAAiB,IAAI,CAAC,GAAG,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,aAAa,CAAC;YACzE,KAAK,EAAE,IAAA,qBAAQ,EAAA,UAAU,IAAI,CAAC,GAAG,eAAe;SACnD,CAAC,CAAC,CAAC;IAYR,CAAC;IAVmB,qBAAqB,CACjC,MAA0B,EAC1B,GAAqB;;;;;YAGrB,OAAO,CAAA,MAAM,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC;oBACjD,MAAM,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;oBACnD,MAAM,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;oBAClD,MAAM,OAAM,qBAAqB,YAAC,MAAM,EAAE,GAAG,CAAC,CAAA,CAAC;QAC1D,CAAC;KAAA;CACJ"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Recipe, ExecutionContext, TreeVisitor } from '@openrewrite/rewrite';
|
|
2
|
+
export declare class SayHelloRecipe extends Recipe {
|
|
3
|
+
readonly name = "com.yourorg.SayHelloRecipe";
|
|
4
|
+
readonly displayName = "Say Hello";
|
|
5
|
+
readonly description = "Adds a hello() method to classes that don't have one";
|
|
6
|
+
editor(): Promise<TreeVisitor<any, ExecutionContext>>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=say-hello-recipe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"say-hello-recipe.d.ts","sourceRoot":"","sources":["../src/say-hello-recipe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAa7E,qBAAa,cAAe,SAAQ,MAAM;IACtC,QAAQ,CAAC,IAAI,gCAAgC;IAC7C,QAAQ,CAAC,WAAW,eAAe;IACnC,QAAQ,CAAC,WAAW,0DAA0D;IAExE,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;CAG9D"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.SayHelloRecipe = void 0;
|
|
13
|
+
const rewrite_1 = require("@openrewrite/rewrite");
|
|
14
|
+
const javascript_1 = require("@openrewrite/rewrite/javascript");
|
|
15
|
+
const java_1 = require("@openrewrite/rewrite/java");
|
|
16
|
+
const mutative_1 = require("mutative");
|
|
17
|
+
class SayHelloRecipe extends rewrite_1.Recipe {
|
|
18
|
+
constructor() {
|
|
19
|
+
super(...arguments);
|
|
20
|
+
this.name = "com.yourorg.SayHelloRecipe";
|
|
21
|
+
this.displayName = "Say Hello";
|
|
22
|
+
this.description = "Adds a hello() method to classes that don't have one";
|
|
23
|
+
}
|
|
24
|
+
editor() {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
return new SayHelloVisitor();
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.SayHelloRecipe = SayHelloRecipe;
|
|
31
|
+
class SayHelloVisitor extends javascript_1.JavaScriptVisitor {
|
|
32
|
+
visitClassDeclaration(classDecl, ctx) {
|
|
33
|
+
const _super = Object.create(null, {
|
|
34
|
+
visitClassDeclaration: { get: () => super.visitClassDeclaration }
|
|
35
|
+
});
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
const visited = yield _super.visitClassDeclaration.call(this, classDecl, ctx);
|
|
38
|
+
if (!visited) {
|
|
39
|
+
return visited;
|
|
40
|
+
}
|
|
41
|
+
const updatedClass = visited;
|
|
42
|
+
const hasHelloMethod = this.classHasHelloMethod(updatedClass);
|
|
43
|
+
if (!hasHelloMethod) {
|
|
44
|
+
const tempClass = yield (0, javascript_1.template) `class Temp {
|
|
45
|
+
hello() {
|
|
46
|
+
return "Hello from " + this.constructor.name + "!";
|
|
47
|
+
}
|
|
48
|
+
}`.apply(updatedClass, this.cursor);
|
|
49
|
+
if (tempClass && tempClass.body) {
|
|
50
|
+
const helloMethod = tempClass.body.statements[0];
|
|
51
|
+
return (0, mutative_1.create)(updatedClass, (draft) => {
|
|
52
|
+
draft.body.statements = [...draft.body.statements, helloMethod];
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return updatedClass;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
classHasHelloMethod(classDecl) {
|
|
60
|
+
if (!classDecl.body || !classDecl.body.statements) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
return classDecl.body.statements.some((stmt) => {
|
|
64
|
+
const element = stmt.element;
|
|
65
|
+
if (element.kind === java_1.J.Kind.MethodDeclaration) {
|
|
66
|
+
const method = element;
|
|
67
|
+
return method.name.simpleName === 'hello';
|
|
68
|
+
}
|
|
69
|
+
return false;
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=say-hello-recipe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"say-hello-recipe.js","sourceRoot":"","sources":["../src/say-hello-recipe.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAA6E;AAC7E,gEAA8E;AAC9E,oDAA8C;AAC9C,uCAAyC;AAUzC,MAAa,cAAe,SAAQ,gBAAM;IAA1C;;QACa,SAAI,GAAG,4BAA4B,CAAC;QACpC,gBAAW,GAAG,WAAW,CAAC;QAC1B,gBAAW,GAAG,sDAAsD,CAAC;IAKlF,CAAC;IAHS,MAAM;;YACR,OAAO,IAAI,eAAe,EAAE,CAAC;QACjC,CAAC;KAAA;CACJ;AARD,wCAQC;AAKD,MAAM,eAAgB,SAAQ,8BAAmC;IAC7C,qBAAqB,CACjC,SAA6B,EAC7B,GAAqB;;;;;YAGrB,MAAM,OAAO,GAAG,MAAM,OAAM,qBAAqB,YAAC,SAAS,EAAE,GAAG,CAAC,CAAC;YAClE,IAAI,CAAC,OAAO,EAAE,CAAC;gBACX,OAAO,OAAO,CAAC;YACnB,CAAC;YAED,MAAM,YAAY,GAAG,OAA6B,CAAC;YAGnD,MAAM,cAAc,GAAG,IAAI,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC;YAE9D,IAAI,CAAC,cAAc,EAAE,CAAC;gBAElB,MAAM,SAAS,GAAG,MAAM,IAAA,qBAAQ,EAAA;;;;EAI1C,CAAC,KAAK,CAAC,YAAY,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;gBAExB,IAAI,SAAS,IAAK,SAAgC,CAAC,IAAI,EAAE,CAAC;oBAEtD,MAAM,WAAW,GAAI,SAAgC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;oBAGzE,OAAO,IAAA,iBAAM,EAAC,YAAY,EAAE,CAAC,KAAgC,EAAE,EAAE;wBAC7D,KAAK,CAAC,IAAI,CAAC,UAAU,GAAG,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;oBACpE,CAAC,CAAC,CAAC;gBACP,CAAC;YACL,CAAC;YAED,OAAO,YAAY,CAAC;QACxB,CAAC;KAAA;IAKO,mBAAmB,CAAC,SAA6B;QACrD,IAAI,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YAChD,OAAO,KAAK,CAAC;QACjB,CAAC;QAED,OAAO,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;YAE3C,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;YAC7B,IAAI,OAAO,CAAC,IAAI,KAAK,QAAC,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC;gBAC5C,MAAM,MAAM,GAAG,OAA8B,CAAC;gBAC9C,OAAO,MAAM,CAAC,IAAI,CAAC,UAAU,KAAK,OAAO,CAAC;YAC9C,CAAC;YACD,OAAO,KAAK,CAAC;QACjB,CAAC,CAAC,CAAC;IACP,CAAC;CACJ"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ExecutionContext, Recipe, TreeVisitor } from "@openrewrite/rewrite";
|
|
2
|
+
export declare class SemanticForwardRefMigration extends Recipe {
|
|
3
|
+
name: string;
|
|
4
|
+
displayName: string;
|
|
5
|
+
description: string;
|
|
6
|
+
editor(): Promise<TreeVisitor<any, ExecutionContext>>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=semantic-matching.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"semantic-matching.d.ts","sourceRoot":"","sources":["../src/semantic-matching.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAE,MAAM,EAAE,WAAW,EAAC,MAAM,sBAAsB,CAAC;AAgB3E,qBAAa,2BAA4B,SAAQ,MAAM;IACnD,IAAI,SAA6C;IACjD,WAAW,SAAoC;IAC/C,WAAW,SAAmE;IAExE,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;CAmC9D"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.SemanticForwardRefMigration = void 0;
|
|
13
|
+
const rewrite_1 = require("@openrewrite/rewrite");
|
|
14
|
+
const javascript_1 = require("@openrewrite/rewrite/javascript");
|
|
15
|
+
class SemanticForwardRefMigration extends rewrite_1.Recipe {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(...arguments);
|
|
18
|
+
this.name = "org.example.SemanticForwardRefMigration";
|
|
19
|
+
this.displayName = "Migrate React.forwardRef usage";
|
|
20
|
+
this.description = "Demonstrates semantic matching across different import styles";
|
|
21
|
+
}
|
|
22
|
+
editor() {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
const comp = (0, javascript_1.capture)('comp');
|
|
25
|
+
const pat = (0, javascript_1.pattern) `forwardRef(${comp})`
|
|
26
|
+
.configure({
|
|
27
|
+
context: [`import { forwardRef } from 'react'`],
|
|
28
|
+
dependencies: { '@types/react': '^18.0.0' }
|
|
29
|
+
});
|
|
30
|
+
return new class extends javascript_1.JavaScriptVisitor {
|
|
31
|
+
visitMethodInvocation(method, ctx) {
|
|
32
|
+
const _super = Object.create(null, {
|
|
33
|
+
visitMethodInvocation: { get: () => super.visitMethodInvocation }
|
|
34
|
+
});
|
|
35
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
method = (yield _super.visitMethodInvocation.call(this, method, ctx));
|
|
37
|
+
const match = yield pat.match(method, this.cursor);
|
|
38
|
+
if (match) {
|
|
39
|
+
const tmpl = (0, javascript_1.template) `memo(forwardRef(${comp}))`
|
|
40
|
+
.configure({
|
|
41
|
+
context: [
|
|
42
|
+
`import { forwardRef, memo } from 'react'`
|
|
43
|
+
],
|
|
44
|
+
dependencies: { '@types/react': '^18.0.0' }
|
|
45
|
+
});
|
|
46
|
+
(0, javascript_1.maybeAddImport)(this, { module: 'react', member: 'forwardRef', onlyIfReferenced: false });
|
|
47
|
+
(0, javascript_1.maybeAddImport)(this, { module: 'react', member: 'memo', onlyIfReferenced: false });
|
|
48
|
+
return yield tmpl.apply(method, this.cursor, { values: match });
|
|
49
|
+
}
|
|
50
|
+
return method;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.SemanticForwardRefMigration = SemanticForwardRefMigration;
|
|
58
|
+
//# sourceMappingURL=semantic-matching.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"semantic-matching.js","sourceRoot":"","sources":["../src/semantic-matching.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAA2E;AAC3E,gEAA8G;AAe9G,MAAa,2BAA4B,SAAQ,gBAAM;IAAvD;;QACI,SAAI,GAAG,yCAAyC,CAAC;QACjD,gBAAW,GAAG,gCAAgC,CAAC;QAC/C,gBAAW,GAAG,+DAA+D,CAAC;IAqClF,CAAC;IAnCS,MAAM;;YACR,MAAM,IAAI,GAAG,IAAA,oBAAO,EAAC,MAAM,CAAC,CAAC;YAC7B,MAAM,GAAG,GAAG,IAAA,oBAAO,EAAA,cAAc,IAAI,GAAG;iBACnC,SAAS,CAAC;gBACP,OAAO,EAAE,CAAC,oCAAoC,CAAC;gBAC/C,YAAY,EAAE,EAAE,cAAc,EAAE,SAAS,EAAE;aAC9C,CAAC,CAAC;YAEP,OAAO,IAAI,KAAM,SAAQ,8BAAmC;gBACxC,qBAAqB,CACjC,MAA0B,EAC1B,GAAqB;;;;;wBAErB,MAAM,GAAG,CAAC,MAAM,OAAM,qBAAqB,YAAC,MAAM,EAAE,GAAG,CAAC,CAAuB,CAAC;wBAEhF,MAAM,KAAK,GAAG,MAAM,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;wBACnD,IAAI,KAAK,EAAE,CAAC;4BAER,MAAM,IAAI,GAAG,IAAA,qBAAQ,EAAA,mBAAmB,IAAI,IAAI;iCAC3C,SAAS,CAAC;gCACP,OAAO,EAAE;oCACL,0CAA0C;iCAC7C;gCACD,YAAY,EAAE,EAAE,cAAc,EAAE,SAAS,EAAE;6BAC9C,CAAC,CAAC;4BAEP,IAAA,2BAAc,EAAC,IAAI,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,gBAAgB,EAAE,KAAK,EAAE,CAAC,CAAC;4BACzF,IAAA,2BAAc,EAAC,IAAI,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,KAAK,EAAE,CAAC,CAAC;4BACnF,OAAO,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,EAAC,MAAM,EAAE,KAAK,EAAC,CAAC,CAAC;wBAClE,CAAC;wBAED,OAAO,MAAM,CAAC;oBAClB,CAAC;iBAAA;aACJ,CAAA;QACL,CAAC;KAAA;CACJ;AAxCD,kEAwCC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ExecutionContext, Recipe, TreeVisitor } from '@openrewrite/rewrite';
|
|
2
|
+
export declare class MigrateUuidV4 extends Recipe {
|
|
3
|
+
readonly name = "com.yourorg.MigrateUuidV4";
|
|
4
|
+
readonly displayName = "Migrate uuid.v4() to rewrittenV4()";
|
|
5
|
+
readonly description = "Migrates `v4()` from `uuid` to `rewrittenV4()`.";
|
|
6
|
+
editor(): Promise<TreeVisitor<any, ExecutionContext>>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=update-function-origin-sensitive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-function-origin-sensitive.d.ts","sourceRoot":"","sources":["../src/update-function-origin-sensitive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,gBAAgB,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAUpF,qBAAa,aAAc,SAAQ,MAAM;IACrC,QAAQ,CAAC,IAAI,+BAA+B;IAC5C,QAAQ,CAAC,WAAW,wCAAwC;IAC5D,QAAQ,CAAC,WAAW,qDAAqD;IAEnE,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;CAM9D"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.MigrateUuidV4 = void 0;
|
|
13
|
+
const rewrite_1 = require("@openrewrite/rewrite");
|
|
14
|
+
const javascript_1 = require("@openrewrite/rewrite/javascript");
|
|
15
|
+
class MigrateUuidV4 extends rewrite_1.Recipe {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(...arguments);
|
|
18
|
+
this.name = "com.yourorg.MigrateUuidV4";
|
|
19
|
+
this.displayName = "Migrate uuid.v4() to rewrittenV4()";
|
|
20
|
+
this.description = "Migrates `v4()` from `uuid` to `rewrittenV4()`.";
|
|
21
|
+
}
|
|
22
|
+
editor() {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
return (0, rewrite_1.check)((0, javascript_1.usesMethod)("uuid v4(..)"), new MigrateUuidV4Visitor());
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.MigrateUuidV4 = MigrateUuidV4;
|
|
29
|
+
class MigrateUuidV4Visitor extends javascript_1.JavaScriptVisitor {
|
|
30
|
+
constructor() {
|
|
31
|
+
super(...arguments);
|
|
32
|
+
this.beforeConfig = {
|
|
33
|
+
context: ["import { v4 } from 'uuid';"]
|
|
34
|
+
};
|
|
35
|
+
this.afterConfig = {
|
|
36
|
+
context: ["import { rewrittenV4 } from 'uuid';"]
|
|
37
|
+
};
|
|
38
|
+
this.callRule = (0, javascript_1.rewrite)(() => ({
|
|
39
|
+
before: (0, javascript_1.pattern) `v4()`.configure(this.beforeConfig),
|
|
40
|
+
after: (0, javascript_1.template) `rewrittenV4()`.configure(this.afterConfig)
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
visitMethodInvocation(method, ctx) {
|
|
44
|
+
const _super = Object.create(null, {
|
|
45
|
+
visitMethodInvocation: { get: () => super.visitMethodInvocation }
|
|
46
|
+
});
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
return (yield this.callRule.tryOn(this.cursor, method))
|
|
49
|
+
|| (yield _super.visitMethodInvocation.call(this, method, ctx));
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=update-function-origin-sensitive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-function-origin-sensitive.js","sourceRoot":"","sources":["../src/update-function-origin-sensitive.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAAoF;AACpF,gEAMyC;AAGzC,MAAa,aAAc,SAAQ,gBAAM;IAAzC;;QACa,SAAI,GAAG,2BAA2B,CAAC;QACnC,gBAAW,GAAG,oCAAoC,CAAC;QACnD,gBAAW,GAAG,iDAAiD,CAAC;IAQ7E,CAAC;IANS,MAAM;;YACR,OAAO,IAAA,eAAK,EACR,IAAA,uBAAU,EAAC,aAAa,CAAC,EACzB,IAAI,oBAAoB,EAAE,CAC7B,CAAC;QACN,CAAC;KAAA;CACJ;AAXD,sCAWC;AAED,MAAM,oBAAqB,SAAQ,8BAAmC;IAAtE;;QACY,iBAAY,GAAG;YACnB,OAAO,EAAE,CAAC,4BAA4B,CAAC;SAC1C,CAAC;QAEM,gBAAW,GAAG;YAGlB,OAAO,EAAE,CAAC,qCAAqC,CAAC;SACnD,CAAC;QAEM,aAAQ,GAAG,IAAA,oBAAO,EAAC,GAAG,EAAE,CAAC,CAAC;YAC9B,MAAM,EAAE,IAAA,oBAAO,EAAA,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC;YAClD,KAAK,EAAE,IAAA,qBAAQ,EAAA,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC;SAC7D,CAAC,CAAC,CAAC;IAUR,CAAC;IARmB,qBAAqB,CACjC,MAA0B,EAC1B,GAAqB;;;;;YAGrB,OAAO,CAAA,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC;oBAC9C,MAAM,OAAM,qBAAqB,YAAC,MAAM,EAAE,GAAG,CAAC,CAAA,CAAC;QAC1D,CAAC;KAAA;CACJ"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ExecutionContext, Recipe, TreeVisitor } from '@openrewrite/rewrite';
|
|
2
|
+
export declare class MigrateFictionalLoggerV2 extends Recipe {
|
|
3
|
+
readonly name = "com.belfius.UpdateFictionalLogger";
|
|
4
|
+
readonly displayName = "Migration Fictional Logger to V2";
|
|
5
|
+
readonly description = "Rename logging functional definition, calls.";
|
|
6
|
+
editor(): Promise<TreeVisitor<any, ExecutionContext>>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=updateFunctionName.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updateFunctionName.d.ts","sourceRoot":"","sources":["../src/updateFunctionName.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,gBAAgB,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAUpF,qBAAa,wBAAyB,SAAQ,MAAM;IAChD,QAAQ,CAAC,IAAI,uCAAuC;IACpD,QAAQ,CAAC,WAAW,sCAAsC;IAC1D,QAAQ,CAAC,WAAW,kDAAkD;IAEhE,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;CAM9D"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.MigrateFictionalLoggerV2 = void 0;
|
|
13
|
+
const rewrite_1 = require("@openrewrite/rewrite");
|
|
14
|
+
const javascript_1 = require("@openrewrite/rewrite/javascript");
|
|
15
|
+
class MigrateFictionalLoggerV2 extends rewrite_1.Recipe {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(...arguments);
|
|
18
|
+
this.name = "com.belfius.UpdateFictionalLogger";
|
|
19
|
+
this.displayName = "Migration Fictional Logger to V2";
|
|
20
|
+
this.description = "Rename logging functional definition, calls.";
|
|
21
|
+
}
|
|
22
|
+
editor() {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
return (0, rewrite_1.check)((0, javascript_1.usesMethod)("logging(..)"), new MigrateLoggerVisitor());
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.MigrateFictionalLoggerV2 = MigrateFictionalLoggerV2;
|
|
29
|
+
class MigrateLoggerVisitor extends javascript_1.JavaScriptVisitor {
|
|
30
|
+
constructor() {
|
|
31
|
+
super(...arguments);
|
|
32
|
+
this.beforeConfig = {
|
|
33
|
+
context: ["import { logging } from '@danieljaurellmevorach/fictional-logger';"]
|
|
34
|
+
};
|
|
35
|
+
this.afterConfig = {
|
|
36
|
+
context: ["import { logV2 } from '@danieljaurellmevorach/fictional-logger';"]
|
|
37
|
+
};
|
|
38
|
+
this.callRule = (0, javascript_1.rewrite)(() => ({
|
|
39
|
+
before: (0, javascript_1.pattern) `logging()`.configure(this.beforeConfig),
|
|
40
|
+
after: (0, javascript_1.template) `logV2()`.configure(this.afterConfig)
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
visitMethodInvocation(method, ctx) {
|
|
44
|
+
const _super = Object.create(null, {
|
|
45
|
+
visitMethodInvocation: { get: () => super.visitMethodInvocation }
|
|
46
|
+
});
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
return (yield this.callRule.tryOn(this.cursor, method))
|
|
49
|
+
|| (yield _super.visitMethodInvocation.call(this, method, ctx));
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=updateFunctionName.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updateFunctionName.js","sourceRoot":"","sources":["../src/updateFunctionName.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAAoF;AACpF,gEAMyC;AAGzC,MAAa,wBAAyB,SAAQ,gBAAM;IAApD;;QACa,SAAI,GAAG,mCAAmC,CAAC;QAC3C,gBAAW,GAAG,kCAAkC,CAAC;QACjD,gBAAW,GAAG,8CAA8C,CAAC;IAQ1E,CAAC;IANS,MAAM;;YACR,OAAO,IAAA,eAAK,EACR,IAAA,uBAAU,EAAC,aAAa,CAAC,EACzB,IAAI,oBAAoB,EAAE,CAC7B,CAAC;QACN,CAAC;KAAA;CACJ;AAXD,4DAWC;AAED,MAAM,oBAAqB,SAAQ,8BAAmC;IAAtE;;QACY,iBAAY,GAAG;YACnB,OAAO,EAAE,CAAC,oEAAoE,CAAC;SAClF,CAAC;QAEM,gBAAW,GAAG;YAClB,OAAO,EAAE,CAAC,kEAAkE,CAAC;SAChF,CAAC;QAEM,aAAQ,GAAG,IAAA,oBAAO,EAAC,GAAG,EAAE,CAAC,CAAC;YAC9B,MAAM,EAAE,IAAA,oBAAO,EAAA,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC;YACvD,KAAK,EAAE,IAAA,qBAAQ,EAAA,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC;SACvD,CAAC,CAAC,CAAC;IAUR,CAAC;IARmB,qBAAqB,CACjC,MAA0B,EAC1B,GAAqB;;;;;YAGrB,OAAO,CAAA,MAAO,IAAY,CAAC,QAAQ,CAAC,KAAK,CAAE,IAAY,CAAC,MAAM,EAAE,MAAM,CAAC;oBAChE,MAAM,OAAM,qBAAqB,YAAC,MAAM,EAAE,GAAG,CAAC,CAAA,CAAC;QAC1D,CAAC;KAAA;CACJ"}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@danieljaurellmevorach/javascript-recipe-starter",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Example OpenRewrite JavaScript recipes and tests to help you get started",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist/**"
|
|
9
|
+
],
|
|
10
|
+
"license": "Apache-2.0",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/moderneinc/javascript-recipe-starter.git"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"openrewrite",
|
|
17
|
+
"moderne",
|
|
18
|
+
"recipe",
|
|
19
|
+
"refactoring",
|
|
20
|
+
"javascript",
|
|
21
|
+
"typescript",
|
|
22
|
+
"codemods",
|
|
23
|
+
"ast"
|
|
24
|
+
],
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/moderneinc/javascript-recipe-starter/issues"
|
|
27
|
+
},
|
|
28
|
+
"homepage": "https://docs.openrewrite.org/",
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "rimraf ./dist && tsc --build tsconfig.build.json",
|
|
31
|
+
"test": "npm run build && jest",
|
|
32
|
+
"test:watch": "jest --watch",
|
|
33
|
+
"prepublishOnly": "npm run build"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@openrewrite/rewrite": "^8.70.4"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/jest": "^29.5.14",
|
|
40
|
+
"@types/node": "^22.9.0",
|
|
41
|
+
"@types/react": "^18.3.0",
|
|
42
|
+
"mutative": "^1.2.0",
|
|
43
|
+
"jest": "^29.7.0",
|
|
44
|
+
"rimraf": "^6.1.0",
|
|
45
|
+
"tmp-promise": "^3.0.3",
|
|
46
|
+
"ts-jest": "^29.2.5",
|
|
47
|
+
"typescript": "^5.7.2"
|
|
48
|
+
},
|
|
49
|
+
"overrides": {
|
|
50
|
+
"glob": "^11.0.0",
|
|
51
|
+
"inflight": "^2.0.0"
|
|
52
|
+
}
|
|
53
|
+
}
|