@typeorm/codemod 1.0.0 → 1.0.1

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.
Files changed (240) hide show
  1. package/README.md +12 -10
  2. package/dist/cli/print-guide.js +2 -2
  3. package/dist/cli/print-summary.js +3 -2
  4. package/dist/cli/print-summary.js.map +1 -1
  5. package/dist/cli/print-usage.js +1 -1
  6. package/dist/cli/print-usage.js.map +1 -1
  7. package/dist/cli/run-transforms.js +16 -2
  8. package/dist/cli/run-transforms.js.map +1 -1
  9. package/dist/dependencies/v1.js +22 -9
  10. package/dist/dependencies/v1.js.map +1 -1
  11. package/dist/transforms/ast-helpers.js +150 -14
  12. package/dist/transforms/ast-helpers.js.map +1 -1
  13. package/dist/transforms/todo.js +25 -2
  14. package/dist/transforms/todo.js.map +1 -1
  15. package/dist/transforms/v1/column-readonly.js +28 -13
  16. package/dist/transforms/v1/column-readonly.js.map +1 -1
  17. package/dist/transforms/v1/column-unsigned-numeric.js +6 -8
  18. package/dist/transforms/v1/column-unsigned-numeric.js.map +1 -1
  19. package/dist/transforms/v1/column-width-zerofill.js +2 -1
  20. package/dist/transforms/v1/column-width-zerofill.js.map +1 -1
  21. package/dist/transforms/v1/connection-manager.js +82 -0
  22. package/dist/transforms/v1/connection-manager.js.map +1 -0
  23. package/dist/transforms/v1/connection-options-reader.js +198 -0
  24. package/dist/transforms/v1/connection-options-reader.js.map +1 -0
  25. package/dist/transforms/v1/connection-to-datasource.js +285 -56
  26. package/dist/transforms/v1/connection-to-datasource.js.map +1 -1
  27. package/dist/transforms/v1/datasource-mongodb.js +40 -28
  28. package/dist/transforms/v1/datasource-mongodb.js.map +1 -1
  29. package/dist/transforms/v1/datasource-mssql.js +1 -3
  30. package/dist/transforms/v1/datasource-mssql.js.map +1 -1
  31. package/dist/transforms/v1/datasource-mysql-connector.js +3 -0
  32. package/dist/transforms/v1/datasource-mysql-connector.js.map +1 -1
  33. package/dist/transforms/v1/datasource-name.js +2 -0
  34. package/dist/transforms/v1/datasource-name.js.map +1 -1
  35. package/dist/transforms/v1/datasource-sap.js +21 -8
  36. package/dist/transforms/v1/datasource-sap.js.map +1 -1
  37. package/dist/transforms/v1/datasource-sqlite-options.js +48 -13
  38. package/dist/transforms/v1/datasource-sqlite-options.js.map +1 -1
  39. package/dist/transforms/v1/datasource-sqlite-type.js +28 -7
  40. package/dist/transforms/v1/datasource-sqlite-type.js.map +1 -1
  41. package/dist/transforms/v1/file-logger.js +182 -0
  42. package/dist/transforms/v1/file-logger.js.map +1 -0
  43. package/dist/transforms/v1/find-options-join.js +84 -0
  44. package/dist/transforms/v1/find-options-join.js.map +1 -0
  45. package/dist/transforms/v1/find-options-lock-modes.js +26 -21
  46. package/dist/transforms/v1/find-options-lock-modes.js.map +1 -1
  47. package/dist/transforms/v1/find-options-string-relations.js +2 -0
  48. package/dist/transforms/v1/find-options-string-relations.js.map +1 -1
  49. package/dist/transforms/v1/find-options-string-select.js +2 -0
  50. package/dist/transforms/v1/find-options-string-select.js.map +1 -1
  51. package/dist/transforms/v1/global-functions.js +92 -64
  52. package/dist/transforms/v1/global-functions.js.map +1 -1
  53. package/dist/transforms/v1/index.js +10 -2
  54. package/dist/transforms/v1/index.js.map +1 -1
  55. package/dist/transforms/v1/migrations-get-all.js +25 -9
  56. package/dist/transforms/v1/migrations-get-all.js.map +1 -1
  57. package/dist/transforms/v1/mongodb-stats.js +3 -0
  58. package/dist/transforms/v1/mongodb-stats.js.map +1 -1
  59. package/dist/transforms/v1/query-builder-native-parameters.js +2 -0
  60. package/dist/transforms/v1/query-builder-native-parameters.js.map +1 -1
  61. package/dist/transforms/v1/query-builder-on-conflict.js +2 -1
  62. package/dist/transforms/v1/query-builder-on-conflict.js.map +1 -1
  63. package/dist/transforms/v1/query-builder-or-update.js +8 -4
  64. package/dist/transforms/v1/query-builder-or-update.js.map +1 -1
  65. package/dist/transforms/v1/query-builder-print-sql.js +3 -0
  66. package/dist/transforms/v1/query-builder-print-sql.js.map +1 -1
  67. package/dist/transforms/v1/query-builder-replace-property-names.js +3 -0
  68. package/dist/transforms/v1/query-builder-replace-property-names.js.map +1 -1
  69. package/dist/transforms/v1/query-runner-loaded-tables-views.js +1 -5
  70. package/dist/transforms/v1/query-runner-loaded-tables-views.js.map +1 -1
  71. package/dist/transforms/v1/relation-count.js +75 -12
  72. package/dist/transforms/v1/relation-count.js.map +1 -1
  73. package/dist/transforms/v1/repository-abstract.js +2 -5
  74. package/dist/transforms/v1/repository-abstract.js.map +1 -1
  75. package/dist/transforms/v1/repository-exist.js +2 -0
  76. package/dist/transforms/v1/repository-exist.js.map +1 -1
  77. package/dist/transforms/v1/repository-find-by-ids.js +0 -3
  78. package/dist/transforms/v1/repository-find-by-ids.js.map +1 -1
  79. package/dist/transforms/v1/repository-find-one-by-id.js +3 -0
  80. package/dist/transforms/v1/repository-find-one-by-id.js.map +1 -1
  81. package/dist/transforms/v1/use-container.js +5 -3
  82. package/dist/transforms/v1/use-container.js.map +1 -1
  83. package/package.json +3 -1
  84. package/dist/cli/colors.d.ts +0 -7
  85. package/dist/cli/colors.js +0 -12
  86. package/dist/cli/colors.js.map +0 -1
  87. package/dist/cli/error.d.ts +0 -1
  88. package/dist/cli/error.js +0 -11
  89. package/dist/cli/error.js.map +0 -1
  90. package/dist/cli/list-transforms.d.ts +0 -1
  91. package/dist/cli/parse-args.d.ts +0 -10
  92. package/dist/cli/print-guide.d.ts +0 -1
  93. package/dist/cli/print-summary.d.ts +0 -17
  94. package/dist/cli/print-todos.d.ts +0 -1
  95. package/dist/cli/print-usage.d.ts +0 -1
  96. package/dist/cli/run-dependencies.d.ts +0 -6
  97. package/dist/cli/run-transforms.d.ts +0 -21
  98. package/dist/cli/run.d.ts +0 -9
  99. package/dist/dependencies/config.d.ts +0 -24
  100. package/dist/dependencies/find-package-json.d.ts +0 -5
  101. package/dist/dependencies/index.d.ts +0 -5
  102. package/dist/dependencies/upgrade.d.ts +0 -11
  103. package/dist/dependencies/v1.d.ts +0 -2
  104. package/dist/index.d.ts +0 -2
  105. package/dist/lib/colors.d.ts +0 -9
  106. package/dist/lib/error.d.ts +0 -1
  107. package/dist/lib/format-time.d.ts +0 -1
  108. package/dist/lib/highlight.d.ts +0 -1
  109. package/dist/lib/spinner.d.ts +0 -5
  110. package/dist/transforms/ast-helpers.d.ts +0 -50
  111. package/dist/transforms/index.d.ts +0 -7
  112. package/dist/transforms/resolve.d.ts +0 -1
  113. package/dist/transforms/scan.d.ts +0 -4
  114. package/dist/transforms/scan.js +0 -33
  115. package/dist/transforms/scan.js.map +0 -1
  116. package/dist/transforms/stats.d.ts +0 -11
  117. package/dist/transforms/todo.d.ts +0 -2
  118. package/dist/transforms/transformer.d.ts +0 -8
  119. package/dist/transforms/v1/column-readonly.d.ts +0 -6
  120. package/dist/transforms/v1/column-unsigned-numeric.d.ts +0 -6
  121. package/dist/transforms/v1/column-width-zerofill.d.ts +0 -6
  122. package/dist/transforms/v1/connection-to-datasource.d.ts +0 -6
  123. package/dist/transforms/v1/datasource-mongodb.d.ts +0 -7
  124. package/dist/transforms/v1/datasource-mssql-domain.d.ts +0 -7
  125. package/dist/transforms/v1/datasource-mssql-domain.js +0 -35
  126. package/dist/transforms/v1/datasource-mssql-domain.js.map +0 -1
  127. package/dist/transforms/v1/datasource-mssql.d.ts +0 -7
  128. package/dist/transforms/v1/datasource-mysql-connector.d.ts +0 -6
  129. package/dist/transforms/v1/datasource-name.d.ts +0 -6
  130. package/dist/transforms/v1/datasource-sap.d.ts +0 -6
  131. package/dist/transforms/v1/datasource-sqlite-options.d.ts +0 -6
  132. package/dist/transforms/v1/datasource-sqlite-type.d.ts +0 -6
  133. package/dist/transforms/v1/find-options-lock-modes.d.ts +0 -6
  134. package/dist/transforms/v1/find-options-string-relations.d.ts +0 -6
  135. package/dist/transforms/v1/find-options-string-select.d.ts +0 -6
  136. package/dist/transforms/v1/global-functions.d.ts +0 -7
  137. package/dist/transforms/v1/index.d.ts +0 -40
  138. package/dist/transforms/v1/migrations-get-all.d.ts +0 -7
  139. package/dist/transforms/v1/mongodb-stats.d.ts +0 -7
  140. package/dist/transforms/v1/mongodb-types.d.ts +0 -6
  141. package/dist/transforms/v1/query-builder-native-parameters.d.ts +0 -6
  142. package/dist/transforms/v1/query-builder-on-conflict.d.ts +0 -7
  143. package/dist/transforms/v1/query-builder-or-update.d.ts +0 -6
  144. package/dist/transforms/v1/query-builder-print-sql.d.ts +0 -7
  145. package/dist/transforms/v1/query-builder-replace-property-names.d.ts +0 -7
  146. package/dist/transforms/v1/query-builder-where-expression.d.ts +0 -6
  147. package/dist/transforms/v1/query-runner-loaded-tables-views.d.ts +0 -7
  148. package/dist/transforms/v1/relation-count.d.ts +0 -7
  149. package/dist/transforms/v1/remove-abstract-repository.d.ts +0 -5
  150. package/dist/transforms/v1/remove-abstract-repository.js +0 -93
  151. package/dist/transforms/v1/remove-abstract-repository.js.map +0 -1
  152. package/dist/transforms/v1/remove-connector-package.d.ts +0 -4
  153. package/dist/transforms/v1/remove-connector-package.js +0 -19
  154. package/dist/transforms/v1/remove-connector-package.js.map +0 -1
  155. package/dist/transforms/v1/remove-datasource-name.d.ts +0 -4
  156. package/dist/transforms/v1/remove-datasource-name.js +0 -56
  157. package/dist/transforms/v1/remove-datasource-name.js.map +0 -1
  158. package/dist/transforms/v1/remove-mongodb-options.d.ts +0 -5
  159. package/dist/transforms/v1/remove-mongodb-options.js +0 -86
  160. package/dist/transforms/v1/remove-mongodb-options.js.map +0 -1
  161. package/dist/transforms/v1/remove-relation-count.d.ts +0 -5
  162. package/dist/transforms/v1/remove-relation-count.js +0 -49
  163. package/dist/transforms/v1/remove-relation-count.js.map +0 -1
  164. package/dist/transforms/v1/remove-replace-property-names.d.ts +0 -5
  165. package/dist/transforms/v1/remove-replace-property-names.js +0 -35
  166. package/dist/transforms/v1/remove-replace-property-names.js.map +0 -1
  167. package/dist/transforms/v1/remove-sap-options.d.ts +0 -4
  168. package/dist/transforms/v1/remove-sap-options.js +0 -54
  169. package/dist/transforms/v1/remove-sap-options.js.map +0 -1
  170. package/dist/transforms/v1/remove-unsigned-numeric.d.ts +0 -4
  171. package/dist/transforms/v1/remove-unsigned-numeric.js +0 -76
  172. package/dist/transforms/v1/remove-unsigned-numeric.js.map +0 -1
  173. package/dist/transforms/v1/remove-use-container.d.ts +0 -5
  174. package/dist/transforms/v1/remove-use-container.js +0 -63
  175. package/dist/transforms/v1/remove-use-container.js.map +0 -1
  176. package/dist/transforms/v1/remove-width-zerofill.d.ts +0 -4
  177. package/dist/transforms/v1/remove-width-zerofill.js +0 -29
  178. package/dist/transforms/v1/remove-width-zerofill.js.map +0 -1
  179. package/dist/transforms/v1/rename-connection-to-datasource.d.ts +0 -4
  180. package/dist/transforms/v1/rename-connection-to-datasource.js +0 -111
  181. package/dist/transforms/v1/rename-connection-to-datasource.js.map +0 -1
  182. package/dist/transforms/v1/rename-exist-to-exists.d.ts +0 -4
  183. package/dist/transforms/v1/rename-exist-to-exists.js +0 -25
  184. package/dist/transforms/v1/rename-exist-to-exists.js.map +0 -1
  185. package/dist/transforms/v1/rename-find-by-ids.d.ts +0 -4
  186. package/dist/transforms/v1/rename-find-by-ids.js +0 -64
  187. package/dist/transforms/v1/rename-find-by-ids.js.map +0 -1
  188. package/dist/transforms/v1/rename-get-all-migrations.d.ts +0 -5
  189. package/dist/transforms/v1/rename-get-all-migrations.js +0 -32
  190. package/dist/transforms/v1/rename-get-all-migrations.js.map +0 -1
  191. package/dist/transforms/v1/rename-loaded-tables-views.d.ts +0 -5
  192. package/dist/transforms/v1/rename-loaded-tables-views.js +0 -48
  193. package/dist/transforms/v1/rename-loaded-tables-views.js.map +0 -1
  194. package/dist/transforms/v1/rename-or-update-overload.d.ts +0 -4
  195. package/dist/transforms/v1/rename-or-update-overload.js +0 -46
  196. package/dist/transforms/v1/rename-or-update-overload.js.map +0 -1
  197. package/dist/transforms/v1/rename-print-sql-to-log-query.d.ts +0 -4
  198. package/dist/transforms/v1/rename-print-sql-to-log-query.js +0 -25
  199. package/dist/transforms/v1/rename-print-sql-to-log-query.js.map +0 -1
  200. package/dist/transforms/v1/replace-global-functions.d.ts +0 -5
  201. package/dist/transforms/v1/replace-global-functions.js +0 -92
  202. package/dist/transforms/v1/replace-global-functions.js.map +0 -1
  203. package/dist/transforms/v1/replace-lock-modes.d.ts +0 -4
  204. package/dist/transforms/v1/replace-lock-modes.js +0 -75
  205. package/dist/transforms/v1/replace-lock-modes.js.map +0 -1
  206. package/dist/transforms/v1/replace-mongodb-stats.d.ts +0 -5
  207. package/dist/transforms/v1/replace-mongodb-stats.js +0 -54
  208. package/dist/transforms/v1/replace-mongodb-stats.js.map +0 -1
  209. package/dist/transforms/v1/replace-mongodb-types.d.ts +0 -4
  210. package/dist/transforms/v1/replace-mongodb-types.js +0 -72
  211. package/dist/transforms/v1/replace-mongodb-types.js.map +0 -1
  212. package/dist/transforms/v1/replace-mssql-domain.d.ts +0 -5
  213. package/dist/transforms/v1/replace-mssql-domain.js +0 -25
  214. package/dist/transforms/v1/replace-mssql-domain.js.map +0 -1
  215. package/dist/transforms/v1/replace-on-conflict.d.ts +0 -5
  216. package/dist/transforms/v1/replace-on-conflict.js +0 -49
  217. package/dist/transforms/v1/replace-on-conflict.js.map +0 -1
  218. package/dist/transforms/v1/replace-readonly-column.d.ts +0 -4
  219. package/dist/transforms/v1/replace-readonly-column.js +0 -28
  220. package/dist/transforms/v1/replace-readonly-column.js.map +0 -1
  221. package/dist/transforms/v1/replace-set-native-parameters.d.ts +0 -4
  222. package/dist/transforms/v1/replace-set-native-parameters.js +0 -25
  223. package/dist/transforms/v1/replace-set-native-parameters.js.map +0 -1
  224. package/dist/transforms/v1/replace-sqlite-options.d.ts +0 -4
  225. package/dist/transforms/v1/replace-sqlite-options.js +0 -29
  226. package/dist/transforms/v1/replace-sqlite-options.js.map +0 -1
  227. package/dist/transforms/v1/replace-sqlite-type.d.ts +0 -4
  228. package/dist/transforms/v1/replace-sqlite-type.js +0 -22
  229. package/dist/transforms/v1/replace-sqlite-type.js.map +0 -1
  230. package/dist/transforms/v1/replace-where-expression-type.d.ts +0 -4
  231. package/dist/transforms/v1/replace-where-expression-type.js +0 -41
  232. package/dist/transforms/v1/replace-where-expression-type.js.map +0 -1
  233. package/dist/transforms/v1/repository-abstract.d.ts +0 -7
  234. package/dist/transforms/v1/repository-exist.d.ts +0 -6
  235. package/dist/transforms/v1/repository-find-by-ids.d.ts +0 -6
  236. package/dist/transforms/v1/repository-find-one-by-id.d.ts +0 -6
  237. package/dist/transforms/v1/upgrade-dependencies.d.ts +0 -15
  238. package/dist/transforms/v1/upgrade-dependencies.js +0 -163
  239. package/dist/transforms/v1/upgrade-dependencies.js.map +0 -1
  240. package/dist/transforms/v1/use-container.d.ts +0 -7
@@ -14,19 +14,16 @@ const columnUnsignedNumeric = (file, api) => {
14
14
  const j = api.jscodeshift;
15
15
  const root = j(file.source);
16
16
  let hasChanges = false;
17
- // Find @Column("decimal", { unsigned: true }) style calls
18
17
  root.find(j.CallExpression, {
19
18
  callee: { type: "Identifier", name: "Column" },
20
19
  }).forEach((path) => {
21
20
  const args = path.node.arguments;
22
21
  if (args.length < 2)
23
22
  return;
24
- // First arg must be a string literal with a numeric type
25
23
  const firstArg = args[0];
26
24
  const typeName = (0, ast_helpers_1.getStringValue)(firstArg);
27
25
  if (!typeName || !numericTypes.has(typeName))
28
26
  return;
29
- // Second arg should be an object with unsigned property
30
27
  const secondArg = args[1];
31
28
  if (secondArg.type !== "ObjectExpression")
32
29
  return;
@@ -34,7 +31,6 @@ const columnUnsignedNumeric = (file, api) => {
34
31
  hasChanges = true;
35
32
  }
36
33
  });
37
- // Also find decorator calls via @Column({ type: "decimal", unsigned: true })
38
34
  root.find(j.CallExpression, {
39
35
  callee: { type: "Identifier", name: "Column" },
40
36
  }).forEach((path) => {
@@ -44,10 +40,12 @@ const columnUnsignedNumeric = (file, api) => {
44
40
  const arg = args[0];
45
41
  if (arg.type !== "ObjectExpression")
46
42
  return;
47
- // Check if type is a numeric type
48
- const typeProp = arg.properties.find((p) => p.type === "ObjectProperty" &&
49
- p.key.type === "Identifier" &&
50
- p.key.name === "type");
43
+ const typeProp = arg.properties.find((p) => {
44
+ if (p.type !== "ObjectProperty")
45
+ return false;
46
+ const keyName = p.key.type === "Identifier" ? p.key.name : (0, ast_helpers_1.getStringValue)(p.key);
47
+ return keyName === "type";
48
+ });
51
49
  if (typeProp?.type !== "ObjectProperty")
52
50
  return;
53
51
  const typeValue = (0, ast_helpers_1.getStringValue)(typeProp.value);
@@ -1 +1 @@
1
- {"version":3,"file":"column-unsigned-numeric.js","sourceRoot":"","sources":["../../../src/transforms/v1/column-unsigned-numeric.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA4B;AAE5B,gDAAuE;AAE1D,QAAA,IAAI,GAAG,mBAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,mBAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAA;AAC1D,QAAA,WAAW,GACpB,gEAAgE,CAAA;AAEpE,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,CAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAA;AACvE,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAA;AAEpC,MAAM,qBAAqB,GAAG,CAAC,IAAc,EAAE,GAAQ,EAAE,EAAE;IAC9D,MAAM,CAAC,GAAG,GAAG,CAAC,WAAW,CAAA;IACzB,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAC3B,IAAI,UAAU,GAAG,KAAK,CAAA;IAEtB,0DAA0D;IAC1D,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc,EAAE;QACxB,MAAM,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE;KACjD,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAChB,MAAM,IAAI,G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AAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;YACvC,IAAI,CAAC,CAAC,IAAI,KAAK,gBAAgB;gBAAE,OAAO,KAAK,CAAA;YAC7C,MAAM,OAAO,GACT,CAAC,CAAC,GAAG,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,IAAA,4BAAc,EAAC,CAAC,CAAC,GAAG,CAAC,CAAA;YACpE,OAAO,OAAO,KAAK,MAAM,CAAA;QAC7B,CAAC,CAAC,CAAA;QAEF,IAAI,QAAQ,EAAE,IAAI,KAAK,gBAAgB;YAAE,OAAM;QAE/C,MAAM,SAAS,GAAG,IAAA,4BAAc,EAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;QAEhD,IAAI,CAAC,SAAS,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,SAAS,CAAC;YAAE,OAAM;QAEtD,IAAI,IAAA,oCAAsB,EAAC,GAAG,EAAE,aAAa,CAAC,EAAE,CAAC;YAC7C,UAAU,GAAG,IAAI,CAAA;QACrB,CAAC;IACL,CAAC,CAAC,CAAA;IAEF,OAAO,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS,CAAA;AACnD,CAAC,CAAA;AApDY,QAAA,qBAAqB,yBAoDjC;AAEY,QAAA,EAAE,GAAG,6BAAqB,CAAA;AACvC,kBAAe,UAAE,CAAA"}
@@ -13,11 +13,12 @@ const columnWidthZerofill = (file, api) => {
13
13
  const j = api.jscodeshift;
14
14
  const root = j(file.source);
15
15
  let hasChanges = false;
16
+ const decoratorLocalNames = (0, ast_helpers_1.expandLocalNamesForImports)(root, j, "typeorm", ast_helpers_1.TYPEORM_COLUMN_DECORATORS);
16
17
  (0, ast_helpers_1.forEachDecoratorObjectArg)(root, j, (obj) => {
17
18
  if ((0, ast_helpers_1.removeObjectProperties)(obj, propsToRemove)) {
18
19
  hasChanges = true;
19
20
  }
20
- });
21
+ }, decoratorLocalNames);
21
22
  return hasChanges ? root.toSource() : undefined;
22
23
  };
23
24
  exports.columnWidthZerofill = columnWidthZerofill;
@@ -1 +1 @@
1
- {"version":3,"file":"column-width-zerofill.js","sourceRoot":"","sources":["../../../src/transforms/v1/column-width-zerofill.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA4B;AAE5B,gDAGuB;AAEV,QAAA,IAAI,GAAG,mBAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,mBAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAA;AAC1D,QAAA,WAAW,GACpB,sDAAsD,CAAA;AAE1D,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAA;AAE7C,MAAM,mBAAmB,GAAG,CAAC,IAAc,EAAE,GAAQ,EAAE,EAAE;IAC5D,MAAM,CAAC,GAAG,GAAG,CAAC,WAAW,CAAA;IACzB,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAC3B,IAAI,UAAU,GAAG,KAAK,CAAA;IAEtB,IAAA,uCAAyB,EAAC,IAAI,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE;QACvC,IAAI,IAAA,oCAAsB,EAAC,GAAG,EAAE,aAAa,CAAC,EAAE,CAAC;YAC7C,UAAU,GAAG,IAAI,CAAA;QACrB,CAAC;IACL,CAAC,CAAC,CAAA;IAEF,OAAO,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS,CAAA;AACnD,CAAC,CAAA;AAZY,QAAA,mBAAmB,uBAY/B;AAEY,QAAA,EAAE,GAAG,2BAAmB,CAAA;AACrC,kBAAe,UAAE,CAAA"}
1
+ {"version":3,"file":"column-width-zerofill.js","sourceRoot":"","sources":["../../../src/transforms/v1/column-width-zerofill.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA4B;AAE5B,gDAKuB;AAEV,QAAA,IAAI,GAAG,mBAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,mBAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAA;AAC1D,QAAA,WAAW,GACpB,sDAAsD,CAAA;AAE1D,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAA;AAE7C,MAAM,mBAAmB,GAAG,CAAC,IAAc,EAAE,GAAQ,EAAE,EAAE;IAC5D,MAAM,CAAC,GAAG,GAAG,CAAC,WAAW,CAAA;IACzB,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAC3B,IAAI,UAAU,GAAG,KAAK,CAAA;IAEtB,MAAM,mBAAmB,GAAG,IAAA,wCAA0B,EAClD,IAAI,EACJ,CAAC,EACD,SAAS,EACT,uCAAyB,CAC5B,CAAA;IACD,IAAA,uCAAyB,EACrB,IAAI,EACJ,CAAC,EACD,CAAC,GAAG,EAAE,EAAE;QACJ,IAAI,IAAA,oCAAsB,EAAC,GAAG,EAAE,aAAa,CAAC,EAAE,CAAC;YAC7C,UAAU,GAAG,IAAI,CAAA;QACrB,CAAC;IACL,CAAC,EACD,mBAAmB,CACtB,CAAA;IAED,OAAO,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS,CAAA;AACnD,CAAC,CAAA;AAvBY,QAAA,mBAAmB,uBAuB/B;AAEY,QAAA,EAAE,GAAG,2BAAmB,CAAA;AACrC,kBAAe,UAAE,CAAA"}
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.fn = exports.connectionManager = exports.manual = exports.description = exports.name = void 0;
7
+ const node_path_1 = __importDefault(require("node:path"));
8
+ const ast_helpers_1 = require("../ast-helpers");
9
+ const todo_1 = require("../todo");
10
+ const stats_1 = require("../stats");
11
+ exports.name = node_path_1.default.basename(__filename, node_path_1.default.extname(__filename));
12
+ exports.description = "flag removed `ConnectionManager` class for manual migration to direct `DataSource` instantiation";
13
+ exports.manual = true;
14
+ const MESSAGE = `\`ConnectionManager\` was removed — create and manage \`DataSource\` instances directly instead — there is no replacement class`;
15
+ // Node types on which a leading line-comment survives jscodeshift/recast
16
+ // printing — walking up to one of these keeps the comment visible above
17
+ // the enclosing statement or declaration.
18
+ const isTodoHost = (type) => type.endsWith("Statement") ||
19
+ type === "VariableDeclaration" ||
20
+ type === "ExportDefaultDeclaration" ||
21
+ type === "ExportNamedDeclaration" ||
22
+ type === "ClassProperty" ||
23
+ type === "PropertyDefinition";
24
+ const connectionManager = (file, api) => {
25
+ const j = api.jscodeshift;
26
+ const root = j(file.source);
27
+ let hasChanges = false;
28
+ let hasTodos = false;
29
+ // Collect local aliases bound to the typeorm `ConnectionManager` class
30
+ // via ESM `import { ConnectionManager [as CM] }` and CJS
31
+ // `const { ConnectionManager [: CM] } = require("typeorm")`.
32
+ const localNames = (0, ast_helpers_1.getLocalNamesForImport)(root, j, "typeorm", "ConnectionManager");
33
+ if (localNames.size === 0) {
34
+ return undefined;
35
+ }
36
+ const flagEnclosingStatement = (startPath) => {
37
+ let current = startPath.parent;
38
+ while (current) {
39
+ const node = current.node;
40
+ if (isTodoHost(node.type)) {
41
+ if (!(0, todo_1.hasTodoComment)(node, MESSAGE)) {
42
+ (0, todo_1.addTodoComment)(node, MESSAGE, j);
43
+ hasChanges = true;
44
+ hasTodos = true;
45
+ }
46
+ return;
47
+ }
48
+ current = current.parent;
49
+ }
50
+ };
51
+ root.find(j.NewExpression)
52
+ .filter((p) => {
53
+ const callee = p.node.callee;
54
+ return (callee.type === "Identifier" &&
55
+ localNames.has(callee.name));
56
+ })
57
+ .forEach(flagEnclosingStatement);
58
+ // Flag `: ConnectionManager` type annotations too; otherwise a file
59
+ // that only uses the class as a type would have its import silently
60
+ // removed and be left with a broken reference.
61
+ root.find(j.TSTypeReference)
62
+ .filter((p) => {
63
+ const typeName = p.node.typeName;
64
+ return (typeName.type === "Identifier" &&
65
+ localNames.has(typeName.name));
66
+ })
67
+ .forEach(flagEnclosingStatement);
68
+ // Only drop the import when at least one usage was successfully
69
+ // flagged — leaving a dangling `ConnectionManager` reference without a
70
+ // comment would be worse than leaving the deprecated import in place.
71
+ if (hasTodos) {
72
+ if ((0, ast_helpers_1.removeImportSpecifiers)(root, j, "typeorm", new Set(["ConnectionManager"]))) {
73
+ hasChanges = true;
74
+ }
75
+ stats_1.stats.count.todo(api, exports.name, file);
76
+ }
77
+ return hasChanges ? root.toSource() : undefined;
78
+ };
79
+ exports.connectionManager = connectionManager;
80
+ exports.fn = exports.connectionManager;
81
+ exports.default = exports.fn;
82
+ //# sourceMappingURL=connection-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection-manager.js","sourceRoot":"","sources":["../../../src/transforms/v1/connection-manager.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA4B;AAE5B,gDAA+E;AAC/E,kCAAwD;AACxD,oCAAgC;AAEnB,QAAA,IAAI,GAAG,mBAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,mBAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAA;AAC1D,QAAA,WAAW,GACpB,kGAAkG,CAAA;AACzF,QAAA,MAAM,GAAG,IAAI,CAAA;AAE1B,MAAM,OAAO,GAAG,iIAAiI,CAAA;AAEjJ,yEAAyE;AACzE,wEAAwE;AACxE,0CAA0C;AAC1C,MAAM,UAAU,GAAG,CAAC,IAAY,EAAW,EAAE,CACzC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC;IAC1B,IAAI,KAAK,qBAAqB;IAC9B,IAAI,KAAK,0BAA0B;IACnC,IAAI,KAAK,wBAAwB;IACjC,IAAI,KAAK,eAAe;IACxB,IAAI,KAAK,oBAAoB,CAAA;AA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AK,YAAY;YAC5B,UAAU,CAAC,GAAG,CAAE,MAA2B,CAAC,IAAI,CAAC,CACpD,CAAA;IACL,CAAC,CAAC;SACD,OAAO,CAAC,sBAAsB,CAAC,CAAA;IAEpC,oEAAoE;IACpE,oEAAoE;IACpE,+CAA+C;IAC/C,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,eAAe,CAAC;SACvB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE;QACV,MAAM,QAAQ,GAAG,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAA;QAChC,OAAO,CACH,QAAQ,CAAC,IAAI,KAAK,YAAY;YAC9B,UAAU,CAAC,GAAG,CAAE,QAA6B,CAAC,IAAI,CAAC,CACtD,CAAA;IACL,CAAC,CAAC;SACD,OAAO,CAAC,sBAAsB,CAAC,CAAA;IAEpC,gEAAgE;IAChE,uEAAuE;IACvE,sEAAsE;IACtE,IAAI,QAAQ,EAAE,CAAC;QACX,IACI,IAAA,oCAAsB,EAClB,IAAI,EACJ,CAAC,EACD,SAAS,EACT,IAAI,GAAG,CAAC,CAAC,mBAAmB,CAAC,CAAC,CACjC,EACH,CAAC;YACC,UAAU,GAAG,IAAI,CAAA;QACrB,CAAC;QACD,aAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,YAAI,EAAE,IAAI,CAAC,CAAA;IACrC,CAAC;IAED,OAAO,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS,CAAA;AACnD,CAAC,CAAA;AA7EY,QAAA,iBAAiB,qBA6E7B;AAEY,QAAA,EAAE,GAAG,yBAAiB,CAAA;AACnC,kBAAe,UAAE,CAAA"}
@@ -0,0 +1,198 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.fn = exports.connectionOptionsReader = exports.manual = exports.description = exports.name = void 0;
7
+ const node_path_1 = __importDefault(require("node:path"));
8
+ const ast_helpers_1 = require("../ast-helpers");
9
+ const todo_1 = require("../todo");
10
+ const stats_1 = require("../stats");
11
+ exports.name = node_path_1.default.basename(__filename, node_path_1.default.extname(__filename));
12
+ exports.description = "rename `ConnectionOptionsReader.all()` to `get()` and flag constructor usage for path semantics change";
13
+ exports.manual = true;
14
+ const CONSTRUCTOR_MESSAGE = '`ConnectionOptionsReader` now searches `process.cwd()` instead of the app root — pass `{ root: "/custom/path" }` to override. `get(name)` and `has(name)` were also removed; use `get()` (previously `all()`) and filter the returned array.';
15
+ // Statement-like ancestors that survive jscodeshift/recast's printing when
16
+ // used as a comment host. Walking up to one of these produces a visible
17
+ // comment above the enclosing statement or declaration.
18
+ const isTodoHost = (type) => type.endsWith("Statement") ||
19
+ type === "VariableDeclaration" ||
20
+ type === "FunctionDeclaration" ||
21
+ type === "ExportDefaultDeclaration" ||
22
+ type === "ExportNamedDeclaration" ||
23
+ type === "ClassProperty" ||
24
+ type === "PropertyDefinition";
25
+ const connectionOptionsReader = (file, api) => {
26
+ const j = api.jscodeshift;
27
+ const root = j(file.source);
28
+ let hasChanges = false;
29
+ let hasTodos = false;
30
+ // Quick scope guard — skip files that never touch typeorm.
31
+ if (!(0, ast_helpers_1.fileImportsFrom)(root, j, "typeorm")) {
32
+ return undefined;
33
+ }
34
+ // Returns true when `node` is `require("typeorm")`.
35
+ const isTypeormRequire = (node) => {
36
+ if (node?.type !== "CallExpression")
37
+ return false;
38
+ const call = node;
39
+ if (call.callee.type !== "Identifier" ||
40
+ call.callee.name !== "require") {
41
+ return false;
42
+ }
43
+ const [arg] = call.arguments;
44
+ return !!arg && (0, ast_helpers_1.getStringValue)(arg) === "typeorm";
45
+ };
46
+ // Local identifiers bound to `ConnectionOptionsReader` via an ESM
47
+ // import or a CommonJS destructured require (handles aliases).
48
+ const readerLocalNames = (0, ast_helpers_1.getLocalNamesForImport)(root, j, "typeorm", "ConnectionOptionsReader");
49
+ // Namespace and member-require bindings — both anchor on a
50
+ // `const <id> = require("typeorm")[ .X ]` VariableDeclarator shape so we
51
+ // iterate once and classify by whether the init is the require call
52
+ // itself (namespace) or a member access (`.ConnectionOptionsReader`).
53
+ const namespaceNames = new Set();
54
+ root.find(j.ImportDeclaration, {
55
+ source: { value: "typeorm" },
56
+ }).forEach((p) => {
57
+ for (const s of p.node.specifiers ?? []) {
58
+ if (s.type === "ImportNamespaceSpecifier" &&
59
+ s.local?.type === "Identifier") {
60
+ namespaceNames.add(s.local.name);
61
+ }
62
+ }
63
+ });
64
+ root.find(j.VariableDeclarator).forEach((p) => {
65
+ const init = p.node.init;
66
+ if (!init || p.node.id.type !== "Identifier")
67
+ return;
68
+ const localName = p.node.id.name;
69
+ if (isTypeormRequire(init)) {
70
+ namespaceNames.add(localName);
71
+ }
72
+ else if (init.type === "MemberExpression" &&
73
+ isTypeormRequire(init.object) &&
74
+ init.property.type === "Identifier" &&
75
+ init.property.name === "ConnectionOptionsReader") {
76
+ readerLocalNames.add(localName);
77
+ }
78
+ });
79
+ if (readerLocalNames.size === 0 && namespaceNames.size === 0) {
80
+ return undefined;
81
+ }
82
+ // Returns true when `callee` is one of the recognized constructor forms:
83
+ // a bare identifier from `readerLocalNames` or `namespace.ConnectionOptionsReader`.
84
+ const isReaderConstruction = (astPath) => {
85
+ const callee = astPath.node.callee;
86
+ if (callee.type === "Identifier") {
87
+ return readerLocalNames.has(callee.name);
88
+ }
89
+ if (callee.type === "MemberExpression" &&
90
+ callee.object.type === "Identifier" &&
91
+ namespaceNames.has(callee.object.name) &&
92
+ callee.property.type === "Identifier" &&
93
+ callee.property.name === "ConnectionOptionsReader") {
94
+ return true;
95
+ }
96
+ return false;
97
+ };
98
+ const readerBindings = new Map();
99
+ const flaggedHosts = new WeakSet();
100
+ const recordBinding = (scope, name) => {
101
+ let bucket = readerBindings.get(scope);
102
+ if (!bucket) {
103
+ bucket = new Set();
104
+ readerBindings.set(scope, bucket);
105
+ }
106
+ bucket.add(name);
107
+ };
108
+ root.find(j.NewExpression).forEach((astPath) => {
109
+ if (!isReaderConstruction(astPath))
110
+ return;
111
+ const parent = astPath.parent.node;
112
+ const parentScope = astPath.parent.scope;
113
+ if (parent.type === "VariableDeclarator" &&
114
+ parent.id.type === "Identifier") {
115
+ recordBinding(parentScope, parent.id.name);
116
+ }
117
+ else if (parent.type === "AssignmentExpression" &&
118
+ parent.left.type === "Identifier") {
119
+ recordBinding(parentScope, parent.left.name);
120
+ }
121
+ else if (parent.type === "AssignmentPattern" &&
122
+ parent.left.type === "Identifier") {
123
+ recordBinding(parentScope, parent.left.name);
124
+ }
125
+ let current = astPath.parent;
126
+ while (current) {
127
+ const node = current.node;
128
+ if (isTodoHost(node.type)) {
129
+ if (!flaggedHosts.has(node) &&
130
+ !(0, todo_1.hasTodoComment)(node, CONSTRUCTOR_MESSAGE)) {
131
+ (0, todo_1.addTodoComment)(node, CONSTRUCTOR_MESSAGE, j);
132
+ flaggedHosts.add(node);
133
+ hasChanges = true;
134
+ hasTodos = true;
135
+ }
136
+ break;
137
+ }
138
+ current = current.parent;
139
+ }
140
+ });
141
+ // Resolves an identifier receiver's scope-declared binding and returns
142
+ // true if it was recorded as a reader instance. Returning false for
143
+ // shadowed/reassigned names keeps unrelated `.all()` calls untouched.
144
+ const isTrackedIdentifier = (name, useScope) => {
145
+ if (!useScope)
146
+ return false;
147
+ const declaringScope = useScope.lookup(name);
148
+ if (!declaringScope)
149
+ return false;
150
+ return readerBindings.get(declaringScope)?.has(name) ?? false;
151
+ };
152
+ // Rename `.all()` → `.get()`:
153
+ // * on tracked reader-instance bindings (`r.all()` where `r = new ...`)
154
+ // * on inline constructor receivers (`new X().all()` — safe because
155
+ // the receiver type is statically known)
156
+ // * on the optional-chain variants `r?.all()`, `r.all?.()`, `r?.all?.()`
157
+ //
158
+ // Only rename zero-argument calls: the v0 `all()` never took arguments, so
159
+ // anything passing an arg is unrelated code that happens to share the name.
160
+ const tryRename = (callPath) => {
161
+ const node = callPath.node;
162
+ if (node.arguments.length !== 0)
163
+ return;
164
+ const callee = node.callee;
165
+ if (callee.type !== "MemberExpression" &&
166
+ callee.type !== "OptionalMemberExpression") {
167
+ return;
168
+ }
169
+ const member = callee;
170
+ if (member.property.type !== "Identifier" ||
171
+ member.property.name !== "all") {
172
+ return;
173
+ }
174
+ const receiver = member.object;
175
+ let matches = false;
176
+ if (receiver.type === "Identifier") {
177
+ matches = isTrackedIdentifier(receiver.name, callPath.scope);
178
+ }
179
+ else if (receiver.type === "NewExpression") {
180
+ matches = isReaderConstruction({
181
+ node: receiver,
182
+ });
183
+ }
184
+ if (!matches)
185
+ return;
186
+ member.property.name = "get";
187
+ hasChanges = true;
188
+ };
189
+ root.find(j.CallExpression).forEach(tryRename);
190
+ root.find(j.OptionalCallExpression).forEach(tryRename);
191
+ if (hasTodos)
192
+ stats_1.stats.count.todo(api, exports.name, file);
193
+ return hasChanges ? root.toSource() : undefined;
194
+ };
195
+ exports.connectionOptionsReader = connectionOptionsReader;
196
+ exports.fn = exports.connectionOptionsReader;
197
+ exports.default = exports.fn;
198
+ //# sourceMappingURL=connection-options-reader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection-options-reader.js","sourceRoot":"","sources":["../../../src/transforms/v1/connection-options-reader.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA4B;AAU5B,gDAIuB;AACvB,kCAAwD;AACxD,oCAAgC;AAEnB,QAAA,IAAI,GAAG,mBAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,mBAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAA;AAC1D,QAAA,WAAW,GACpB,wGAAwG,CAAA;AAC/F,QAAA,MAAM,GAAG,IAAI,CAAA;AAE1B,MAAM,mBAAmB,GACrB,8OAA8O,CAAA;AAElP,2EAA2E;AAC3E,wEAAwE;AACxE,wDAAwD;AACxD,MAAM,UAAU,GAAG,CAAC,IAAY,EAAW,EAAE,CACzC,IAAI,CAAC,QAAQ,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