@cedarjs/codemods 3.0.0-canary.13646 → 3.0.0-canary.13647
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.
|
@@ -11,11 +11,26 @@ function transform(file, api, options = {}) {
|
|
|
11
11
|
if (alreadyMigrated) {
|
|
12
12
|
return file.source;
|
|
13
13
|
}
|
|
14
|
-
function
|
|
14
|
+
function stealLeadingComments(fromNode, toNode) {
|
|
15
|
+
const fromComments = fromNode.comments;
|
|
16
|
+
if (!fromComments || fromComments.length === 0) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const leading = fromComments.filter((c) => c.leading);
|
|
20
|
+
if (leading.length === 0) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
toNode.comments = [...leading, ...toNode.comments ?? []];
|
|
24
|
+
fromNode.comments = fromComments.filter((c) => !c.leading);
|
|
25
|
+
}
|
|
26
|
+
function insertAdapterImport(importDecl, { takeLeadingComments = false } = {}) {
|
|
15
27
|
const clientImport = root.find(j.ImportDeclaration, {
|
|
16
28
|
source: { value: NEW_CLIENT_PATH }
|
|
17
29
|
});
|
|
18
30
|
if (clientImport.length > 0) {
|
|
31
|
+
if (takeLeadingComments) {
|
|
32
|
+
stealLeadingComments(clientImport.get().node, importDecl);
|
|
33
|
+
}
|
|
19
34
|
clientImport.insertBefore(importDecl);
|
|
20
35
|
} else {
|
|
21
36
|
root.find(j.ImportDeclaration).at(0).insertBefore(importDecl);
|
|
@@ -89,7 +104,8 @@ function transform(file, api, options = {}) {
|
|
|
89
104
|
)
|
|
90
105
|
],
|
|
91
106
|
j.stringLiteral("@prisma/adapter-pg")
|
|
92
|
-
)
|
|
107
|
+
),
|
|
108
|
+
{ takeLeadingComments: true }
|
|
93
109
|
);
|
|
94
110
|
}
|
|
95
111
|
const hasAdapter2 = root.find(j.VariableDeclarator, {
|
|
@@ -134,11 +150,12 @@ function transform(file, api, options = {}) {
|
|
|
134
150
|
source: { value: "@cedarjs/project-config" }
|
|
135
151
|
}).length > 0;
|
|
136
152
|
if (!hasPathImport) {
|
|
137
|
-
|
|
153
|
+
insertAdapterImport(
|
|
138
154
|
j.importDeclaration(
|
|
139
155
|
[j.importDefaultSpecifier(j.identifier("path"))],
|
|
140
156
|
j.stringLiteral("node:path")
|
|
141
|
-
)
|
|
157
|
+
),
|
|
158
|
+
{ takeLeadingComments: true }
|
|
142
159
|
);
|
|
143
160
|
}
|
|
144
161
|
if (!hasAdapterImport) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/codemods",
|
|
3
|
-
"version": "3.0.0-canary.
|
|
3
|
+
"version": "3.0.0-canary.13647+613668eee",
|
|
4
4
|
"description": "Codemods to ease upgrading a CedarJS Project",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"@babel/parser": "7.29.2",
|
|
30
30
|
"@babel/plugin-transform-typescript": "^7.26.8",
|
|
31
31
|
"@babel/traverse": "7.29.0",
|
|
32
|
-
"@cedarjs/cli-helpers": "3.0.0-canary.
|
|
33
|
-
"@cedarjs/project-config": "3.0.0-canary.
|
|
32
|
+
"@cedarjs/cli-helpers": "3.0.0-canary.13647",
|
|
33
|
+
"@cedarjs/project-config": "3.0.0-canary.13647",
|
|
34
34
|
"@svgr/core": "8.1.0",
|
|
35
35
|
"@svgr/plugin-jsx": "8.1.0",
|
|
36
36
|
"@vscode/ripgrep": "1.17.1",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"yargs": "17.7.2"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@cedarjs/framework-tools": "3.0.0-canary.
|
|
51
|
+
"@cedarjs/framework-tools": "3.0.0-canary.13647",
|
|
52
52
|
"@types/babel__core": "7.20.5",
|
|
53
53
|
"@types/jscodeshift": "17.3.0",
|
|
54
54
|
"@types/yargs": "17.0.35",
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"publishConfig": {
|
|
62
62
|
"access": "public"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "613668eee9d4fd02b9cf4962740acb371ac736c8"
|
|
65
65
|
}
|