@danieljaurellmevorach/javascript-recipe-starter 1.0.3 → 1.0.4

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.
@@ -2,7 +2,7 @@ import { ExecutionContext, Recipe, TreeVisitor } from '@openrewrite/rewrite';
2
2
  export declare class MigrateFictionalLoggerV2 extends Recipe {
3
3
  readonly name = "com.yourorg.UpdateFictionalLogger";
4
4
  readonly displayName = "Migration Fictional Logger to V2";
5
- readonly description = "Rename logging functional definition, calls.";
6
- editor(): Promise<TreeVisitor<any, ExecutionContext>>;
5
+ readonly description = "Rename logging functional definition and map arguments.";
6
+ getVisitor(): Promise<TreeVisitor<any, ExecutionContext>>;
7
7
  }
8
8
  //# sourceMappingURL=updateFunctionName.d.ts.map
@@ -1 +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"}
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,6DAA6D;IAG3E,UAAU,IAAI,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;CAMlE"}
@@ -17,11 +17,11 @@ class MigrateFictionalLoggerV2 extends rewrite_1.Recipe {
17
17
  super(...arguments);
18
18
  this.name = "com.yourorg.UpdateFictionalLogger";
19
19
  this.displayName = "Migration Fictional Logger to V2";
20
- this.description = "Rename logging functional definition, calls.";
20
+ this.description = "Rename logging functional definition and map arguments.";
21
21
  }
22
- editor() {
22
+ getVisitor() {
23
23
  return __awaiter(this, void 0, void 0, function* () {
24
- return (0, rewrite_1.check)((0, javascript_1.usesMethod)("* logging(..)"), new MigrateLoggerVisitor());
24
+ return yield (0, rewrite_1.check)((0, javascript_1.usesMethod)("* logging(..)"), new MigrateLoggerVisitor());
25
25
  });
26
26
  }
27
27
  }
@@ -35,9 +35,13 @@ class MigrateLoggerVisitor extends javascript_1.JavaScriptVisitor {
35
35
  this.afterConfig = {
36
36
  context: ["import { logV2 } from '@danieljaurellmevorach/fictional-logger';"]
37
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)
38
+ this.callRuleWithMeta = (0, javascript_1.rewrite)(() => ({
39
+ before: (0, javascript_1.pattern) `logging(#{msg:any()}, #{meta:any()})`.configure(this.beforeConfig),
40
+ after: (0, javascript_1.template) `logV2({ message: #{msg}, metadata: #{meta} })`.configure(this.afterConfig)
41
+ }));
42
+ this.callRuleSimple = (0, javascript_1.rewrite)(() => ({
43
+ before: (0, javascript_1.pattern) `logging(#{msg:any()})`.configure(this.beforeConfig),
44
+ after: (0, javascript_1.template) `logV2({ message: #{msg} })`.configure(this.afterConfig)
41
45
  }));
42
46
  }
43
47
  visitMethodInvocation(method, ctx) {
@@ -45,8 +49,12 @@ class MigrateLoggerVisitor extends javascript_1.JavaScriptVisitor {
45
49
  visitMethodInvocation: { get: () => super.visitMethodInvocation }
46
50
  });
47
51
  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));
52
+ let m = yield _super.visitMethodInvocation.call(this, method, ctx);
53
+ m = (yield this.callRuleWithMeta.tryOn(this.cursor, m)) || m;
54
+ if (m === method) {
55
+ m = (yield this.callRuleSimple.tryOn(this.cursor, m)) || m;
56
+ }
57
+ return m;
50
58
  });
51
59
  }
52
60
  }
@@ -1 +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,eAAe,CAAC,EAC3B,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,MAAM,IAAI,CAAC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,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC;SAC1E,CAAC,CAAC,CAAC;IAqBR,CAAC;IAlBS,qBAAqB,CACvB,MAA0B,EAC1B,GAAqB;;;;;YAIrB,IAAI,CAAC,GAAG,MAAM,OAAM,qBAAqB,YAAC,MAAM,EAAE,GAAG,CAAuB,CAAC;YAG7E,CAAC,GAAG,CAAA,MAAM,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAuB,KAAI,CAAC,CAAC;YAGjF,IAAI,CAAC,KAAK,MAAM,EAAE,CAAC;gBACf,CAAC,GAAG,CAAA,MAAM,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAuB,KAAI,CAAC,CAAC;YACnF,CAAC;YAED,OAAO,CAAC,CAAC;QACb,CAAC;KAAA;CACJ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danieljaurellmevorach/javascript-recipe-starter",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Example OpenRewrite JavaScript recipes and tests to help you get started",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",