@cedarjs/codemods 3.0.0-canary.13470 → 3.0.0-canary.13472

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.
@@ -35,36 +35,44 @@ var import_node_fs = __toESM(require("node:fs"));
35
35
  var import_node_path = __toESM(require("node:path"));
36
36
  var import_jscodeshift = __toESM(require("jscodeshift"));
37
37
  var import_project_config = require("@cedarjs/project-config");
38
+ function getParserForFile(filePath) {
39
+ if (filePath.endsWith(".tsx") || filePath.endsWith(".jsx")) {
40
+ return import_jscodeshift.default.withParser("tsx");
41
+ }
42
+ return import_jscodeshift.default.withParser("ts");
43
+ }
38
44
  function transformDbFile(file) {
39
- const root = (0, import_jscodeshift.default)(file.source);
40
- const existingExport = root.find(import_jscodeshift.default.ExportAllDeclaration, {
45
+ const parser = getParserForFile(file.path);
46
+ const root = parser(file.source);
47
+ const existingExport = root.find(parser.ExportAllDeclaration, {
41
48
  source: { value: "@prisma/client" }
42
49
  });
43
50
  if (existingExport.length > 0) {
44
51
  return file.source;
45
52
  }
46
- const prismaClientImport = root.find(import_jscodeshift.default.ImportDeclaration, {
53
+ const prismaClientImport = root.find(parser.ImportDeclaration, {
47
54
  source: { value: "@prisma/client" }
48
55
  });
49
56
  if (prismaClientImport.length === 0) {
50
57
  return file.source;
51
58
  }
52
59
  const importNode = prismaClientImport.get();
53
- const exportStatement = import_jscodeshift.default.exportAllDeclaration(
54
- import_jscodeshift.default.literal("@prisma/client"),
60
+ const exportStatement = parser.exportAllDeclaration(
61
+ parser.literal("@prisma/client"),
55
62
  null
56
63
  );
57
64
  importNode.insertAfter(exportStatement);
58
65
  return root.toSource();
59
66
  }
60
67
  function transformOtherFile(file) {
61
- const root = (0, import_jscodeshift.default)(file.source);
68
+ const parser = getParserForFile(file.path);
69
+ const root = parser(file.source);
62
70
  const isInRootScripts = file.path.startsWith((0, import_project_config.getPaths)().scripts + import_node_path.default.sep);
63
71
  const importPath = isInRootScripts ? "api/src/lib/db" : "src/lib/db";
64
- root.find(import_jscodeshift.default.ImportDeclaration, {
72
+ root.find(parser.ImportDeclaration, {
65
73
  source: { value: "@prisma/client" }
66
74
  }).forEach((importDecl) => {
67
- importDecl.get("source").replace(import_jscodeshift.default.literal(importPath));
75
+ importDecl.get("source").replace(parser.literal(importPath));
68
76
  });
69
77
  return root.toSource();
70
78
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/codemods",
3
- "version": "3.0.0-canary.13470+451685c83",
3
+ "version": "3.0.0-canary.13472+fb1944e3f",
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.13470",
33
+ "@cedarjs/project-config": "3.0.0-canary.13472",
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.13470",
52
+ "@cedarjs/framework-tools": "3.0.0-canary.13472",
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": "451685c8388dfd484f201870e2033354648e02e2"
63
+ "gitHead": "fb1944e3f1713bc581378d9dde4766cdeae99e7a"
64
64
  }