@openrewrite/recipes-nodejs 0.34.0-20251119-220513 → 0.34.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crypto-constructors.d.ts","sourceRoot":"","sources":["../../src/migrate/crypto-constructors.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"crypto-constructors.d.ts","sourceRoot":"","sources":["../../src/migrate/crypto-constructors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAE,MAAM,EAAE,WAAW,EAAC,MAAM,sBAAsB,CAAC;AAI3E,qBAAa,yBAA0B,SAAQ,MAAM;IACjD,QAAQ,CAAC,IAAI,kEAAiE;IAC9E,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAyF;IACrH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAA2M;IACvO,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,CAA0B;IAE3C,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;CAsD9D"}
|
|
@@ -57,13 +57,13 @@ class ReplaceCryptoConstructors extends rewrite_1.Recipe {
|
|
|
57
57
|
if ((constructorType === null || constructorType === void 0 ? void 0 : constructorType.declaringType.kind) == java_1.Type.Kind.Class
|
|
58
58
|
&& constructorType.declaringType.fullyQualifiedName == "crypto") {
|
|
59
59
|
if (constructorType.name == "Hash" && args.length === 1) {
|
|
60
|
-
(0, javascript_1.maybeAddImport)(this, {
|
|
60
|
+
(0, javascript_1.maybeAddImport)(this, { module: "crypto", member: "createHash", onlyIfReferenced: false });
|
|
61
61
|
(0, javascript_1.maybeRemoveImport)(this, "crypto", "Hash");
|
|
62
62
|
return yield (0, javascript_1.template) `createHash(${firstArg})`.apply(newClass, this.cursor);
|
|
63
63
|
}
|
|
64
64
|
else if (constructorType.name == "Hmac" && args.length === 2) {
|
|
65
65
|
const secondArg = args[1].element;
|
|
66
|
-
(0, javascript_1.maybeAddImport)(this, {
|
|
66
|
+
(0, javascript_1.maybeAddImport)(this, { module: "crypto", member: "createHmac", onlyIfReferenced: false });
|
|
67
67
|
(0, javascript_1.maybeRemoveImport)(this, "crypto", "Hmac");
|
|
68
68
|
return yield (0, javascript_1.template) `createHmac(${firstArg}, ${secondArg})`.apply(newClass, this.cursor);
|
|
69
69
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crypto-constructors.js","sourceRoot":"","sources":["../../src/migrate/crypto-constructors.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"crypto-constructors.js","sourceRoot":"","sources":["../../src/migrate/crypto-constructors.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAA2E;AAC3E,gEAA+G;AAC/G,oDAAkD;AAElD,MAAa,yBAA0B,SAAQ,gBAAM;IAArD;;QACa,SAAI,GAAG,8DAA8D,CAAA;QACrE,gBAAW,GAAW,qFAAqF,CAAC;QAC5G,gBAAW,GAAW,uMAAuM,CAAC;QAC9N,SAAI,GAAa,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IAwDrD,CAAC;IAtDS,MAAM;;YACR,OAAO,IAAI,KAAM,SAAQ,8BAAmC;gBACxC,aAAa,CAAC,QAAoB,EAAE,CAAmB;;;;;;wBACnE,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC;wBAC7B,MAAM,IAAI,GAAG,MAAA,QAAQ,CAAC,SAAS,0CAAE,QAAQ,CAAC;wBAE1C,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC;4BACpD,OAAO,OAAM,aAAa,YAAC,QAAQ,EAAE,CAAC,EAAE;wBAC5C,CAAC;wBAED,MAAM,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,O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CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openrewrite/recipes-nodejs",
|
|
3
|
-
"version": "0.34.0
|
|
3
|
+
"version": "0.34.0",
|
|
4
4
|
"license": "Moderne Source Available License",
|
|
5
5
|
"description": "OpenRewrite recipes for Node.js library migrations.",
|
|
6
6
|
"homepage": "https://github.com/moderneinc/rewrite-node",
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
maybeAddImport,
|
|
5
|
-
maybeRemoveImport,
|
|
6
|
-
template,
|
|
7
|
-
usesType
|
|
8
|
-
} from "@openrewrite/rewrite/javascript";
|
|
9
|
-
import {Expression, J, Type} from "@openrewrite/rewrite/java";
|
|
1
|
+
import {ExecutionContext, Recipe, TreeVisitor} from "@openrewrite/rewrite";
|
|
2
|
+
import {JavaScriptVisitor, maybeAddImport, maybeRemoveImport, template} from "@openrewrite/rewrite/javascript";
|
|
3
|
+
import {J, Type} from "@openrewrite/rewrite/java";
|
|
10
4
|
|
|
11
5
|
export class ReplaceCryptoConstructors extends Recipe {
|
|
12
6
|
readonly name = "org.openrewrite.node.migrate.crypto.replace-hash-constructor"
|
|
@@ -52,12 +46,12 @@ export class ReplaceCryptoConstructors extends Recipe {
|
|
|
52
46
|
&& (constructorType.declaringType as Type.Class).fullyQualifiedName == "crypto") {
|
|
53
47
|
|
|
54
48
|
if (constructorType.name == "Hash" && args.length === 1) {
|
|
55
|
-
maybeAddImport(this, {
|
|
49
|
+
maybeAddImport(this, {module: "crypto", member: "createHash", onlyIfReferenced: false});
|
|
56
50
|
maybeRemoveImport(this, "crypto", "Hash");
|
|
57
51
|
return await template`createHash(${firstArg})`.apply(newClass, this.cursor);
|
|
58
52
|
} else if (constructorType.name == "Hmac" && args.length === 2) {
|
|
59
53
|
const secondArg = args[1].element;
|
|
60
|
-
maybeAddImport(this, {
|
|
54
|
+
maybeAddImport(this, {module: "crypto", member: "createHmac", onlyIfReferenced: false});
|
|
61
55
|
maybeRemoveImport(this, "crypto", "Hmac");
|
|
62
56
|
return await template`createHmac(${firstArg}, ${secondArg})`.apply(newClass, this.cursor);
|
|
63
57
|
}
|