@cedarjs/codemods 3.0.0-canary.13469 → 3.0.0-canary.13470
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.
|
@@ -33,38 +33,38 @@ __export(prismaV7Prep_exports, {
|
|
|
33
33
|
module.exports = __toCommonJS(prismaV7Prep_exports);
|
|
34
34
|
var import_node_fs = __toESM(require("node:fs"));
|
|
35
35
|
var import_node_path = __toESM(require("node:path"));
|
|
36
|
+
var import_jscodeshift = __toESM(require("jscodeshift"));
|
|
36
37
|
var import_project_config = require("@cedarjs/project-config");
|
|
37
|
-
function transformDbFile(file
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
const existingExport = root.find(j.ExportAllDeclaration, {
|
|
38
|
+
function transformDbFile(file) {
|
|
39
|
+
const root = (0, import_jscodeshift.default)(file.source);
|
|
40
|
+
const existingExport = root.find(import_jscodeshift.default.ExportAllDeclaration, {
|
|
41
41
|
source: { value: "@prisma/client" }
|
|
42
42
|
});
|
|
43
43
|
if (existingExport.length > 0) {
|
|
44
44
|
return file.source;
|
|
45
45
|
}
|
|
46
|
-
const prismaClientImport = root.find(
|
|
46
|
+
const prismaClientImport = root.find(import_jscodeshift.default.ImportDeclaration, {
|
|
47
47
|
source: { value: "@prisma/client" }
|
|
48
48
|
});
|
|
49
49
|
if (prismaClientImport.length === 0) {
|
|
50
50
|
return file.source;
|
|
51
51
|
}
|
|
52
52
|
const importNode = prismaClientImport.get();
|
|
53
|
-
const exportStatement =
|
|
53
|
+
const exportStatement = import_jscodeshift.default.exportAllDeclaration(
|
|
54
|
+
import_jscodeshift.default.literal("@prisma/client"),
|
|
55
|
+
null
|
|
56
|
+
);
|
|
54
57
|
importNode.insertAfter(exportStatement);
|
|
55
58
|
return root.toSource();
|
|
56
59
|
}
|
|
57
|
-
function transformOtherFile(file
|
|
58
|
-
const
|
|
59
|
-
const
|
|
60
|
-
const isInRootScripts = file.path.startsWith(
|
|
61
|
-
import_node_path.default.join((0, import_project_config.getPaths)().scripts, import_node_path.default.sep)
|
|
62
|
-
);
|
|
60
|
+
function transformOtherFile(file) {
|
|
61
|
+
const root = (0, import_jscodeshift.default)(file.source);
|
|
62
|
+
const isInRootScripts = file.path.startsWith((0, import_project_config.getPaths)().scripts + import_node_path.default.sep);
|
|
63
63
|
const importPath = isInRootScripts ? "api/src/lib/db" : "src/lib/db";
|
|
64
|
-
root.find(
|
|
64
|
+
root.find(import_jscodeshift.default.ImportDeclaration, {
|
|
65
65
|
source: { value: "@prisma/client" }
|
|
66
66
|
}).forEach((importDecl) => {
|
|
67
|
-
importDecl.get("source").replace(
|
|
67
|
+
importDecl.get("source").replace(import_jscodeshift.default.literal(importPath));
|
|
68
68
|
});
|
|
69
69
|
return root.toSource();
|
|
70
70
|
}
|
|
@@ -79,11 +79,8 @@ async function prismaV7Prep() {
|
|
|
79
79
|
dbFilePath = dbPathJs;
|
|
80
80
|
}
|
|
81
81
|
if (import_node_fs.default.existsSync(dbFilePath)) {
|
|
82
|
-
const
|
|
83
|
-
const transformed = transformDbFile(
|
|
84
|
-
{ source: fileContent, path: dbFilePath },
|
|
85
|
-
{ jscodeshift: require("jscodeshift") }
|
|
86
|
-
);
|
|
82
|
+
const source = import_node_fs.default.readFileSync(dbFilePath, "utf-8");
|
|
83
|
+
const transformed = transformDbFile({ source, path: dbFilePath });
|
|
87
84
|
import_node_fs.default.writeFileSync(dbFilePath, transformed);
|
|
88
85
|
}
|
|
89
86
|
const dirsToTransform = [paths.api.src, dataMigrationsPath, paths.scripts];
|
|
@@ -91,15 +88,12 @@ async function prismaV7Prep() {
|
|
|
91
88
|
if (!import_node_fs.default.existsSync(dir)) {
|
|
92
89
|
continue;
|
|
93
90
|
}
|
|
94
|
-
const files = import_node_fs.default.readdirSync(dir, { recursive: true }).filter(
|
|
91
|
+
const files = import_node_fs.default.readdirSync(dir, { recursive: true, encoding: "utf8" }).filter(
|
|
95
92
|
(file) => file.endsWith(".ts") || file.endsWith(".cts") || file.endsWith(".mts") || file.endsWith(".tsx") || file.endsWith(".js") || file.endsWith(".cjs") || file.endsWith(".mjs") || file.endsWith(".jsx")
|
|
96
93
|
).map((file) => import_node_path.default.join(dir, file)).filter((file) => import_node_fs.default.statSync(file).isFile()).filter((file) => file !== dbFilePath);
|
|
97
94
|
for (const file of files) {
|
|
98
|
-
const
|
|
99
|
-
const transformed = transformOtherFile(
|
|
100
|
-
{ source: fileContent, path: file },
|
|
101
|
-
{ jscodeshift: require("jscodeshift") }
|
|
102
|
-
);
|
|
95
|
+
const source = import_node_fs.default.readFileSync(file, "utf-8");
|
|
96
|
+
const transformed = transformOtherFile({ source, path: file });
|
|
103
97
|
import_node_fs.default.writeFileSync(file, transformed);
|
|
104
98
|
}
|
|
105
99
|
}
|
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.13470+451685c83",
|
|
4
4
|
"description": "Codemods to ease upgrading a CedarJS Project",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"@babel/plugin-transform-typescript": "^7.26.8",
|
|
31
31
|
"@babel/runtime-corejs3": "7.29.0",
|
|
32
32
|
"@babel/traverse": "7.29.0",
|
|
33
|
-
"@cedarjs/project-config": "3.0.0-canary.
|
|
33
|
+
"@cedarjs/project-config": "3.0.0-canary.13470",
|
|
34
34
|
"@svgr/core": "8.1.0",
|
|
35
35
|
"@svgr/plugin-jsx": "8.1.0",
|
|
36
36
|
"@vscode/ripgrep": "1.17.0",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"yargs": "17.7.2"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@cedarjs/framework-tools": "3.0.0-canary.
|
|
52
|
+
"@cedarjs/framework-tools": "3.0.0-canary.13470",
|
|
53
53
|
"@types/babel__core": "7.20.5",
|
|
54
54
|
"@types/jscodeshift": "0.12.0",
|
|
55
55
|
"@types/yargs": "17.0.35",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"publishConfig": {
|
|
61
61
|
"access": "public"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "451685c8388dfd484f201870e2033354648e02e2"
|
|
64
64
|
}
|