@typeorm/codemod 1.0.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.
- package/README.md +59 -0
- package/dist/cli/colors.d.ts +7 -0
- package/dist/cli/colors.js +12 -0
- package/dist/cli/colors.js.map +1 -0
- package/dist/cli/error.d.ts +1 -0
- package/dist/cli/error.js +11 -0
- package/dist/cli/error.js.map +1 -0
- package/dist/cli/list-transforms.d.ts +1 -0
- package/dist/cli/list-transforms.js +27 -0
- package/dist/cli/list-transforms.js.map +1 -0
- package/dist/cli/parse-args.d.ts +10 -0
- package/dist/cli/parse-args.js +52 -0
- package/dist/cli/parse-args.js.map +1 -0
- package/dist/cli/print-guide.d.ts +1 -0
- package/dist/cli/print-guide.js +15 -0
- package/dist/cli/print-guide.js.map +1 -0
- package/dist/cli/print-summary.d.ts +17 -0
- package/dist/cli/print-summary.js +70 -0
- package/dist/cli/print-summary.js.map +1 -0
- package/dist/cli/print-todos.d.ts +1 -0
- package/dist/cli/print-todos.js +13 -0
- package/dist/cli/print-todos.js.map +1 -0
- package/dist/cli/print-usage.d.ts +1 -0
- package/dist/cli/print-usage.js +31 -0
- package/dist/cli/print-usage.js.map +1 -0
- package/dist/cli/run-dependencies.d.ts +6 -0
- package/dist/cli/run-dependencies.js +45 -0
- package/dist/cli/run-dependencies.js.map +1 -0
- package/dist/cli/run-transforms.d.ts +21 -0
- package/dist/cli/run-transforms.js +119 -0
- package/dist/cli/run-transforms.js.map +1 -0
- package/dist/cli/run.d.ts +9 -0
- package/dist/cli/run.js +30 -0
- package/dist/cli/run.js.map +1 -0
- package/dist/dependencies/config.d.ts +24 -0
- package/dist/dependencies/config.js +3 -0
- package/dist/dependencies/config.js.map +1 -0
- package/dist/dependencies/find-package-json.d.ts +5 -0
- package/dist/dependencies/find-package-json.js +34 -0
- package/dist/dependencies/find-package-json.js.map +1 -0
- package/dist/dependencies/index.d.ts +5 -0
- package/dist/dependencies/index.js +14 -0
- package/dist/dependencies/index.js.map +1 -0
- package/dist/dependencies/upgrade.d.ts +11 -0
- package/dist/dependencies/upgrade.js +128 -0
- package/dist/dependencies/upgrade.js.map +1 -0
- package/dist/dependencies/v1.d.ts +2 -0
- package/dist/dependencies/v1.js +32 -0
- package/dist/dependencies/v1.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +45 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/colors.d.ts +9 -0
- package/dist/lib/colors.js +14 -0
- package/dist/lib/colors.js.map +1 -0
- package/dist/lib/error.d.ts +1 -0
- package/dist/lib/error.js +11 -0
- package/dist/lib/error.js.map +1 -0
- package/dist/lib/format-time.d.ts +1 -0
- package/dist/lib/format-time.js +12 -0
- package/dist/lib/format-time.js.map +1 -0
- package/dist/lib/highlight.d.ts +1 -0
- package/dist/lib/highlight.js +7 -0
- package/dist/lib/highlight.js.map +1 -0
- package/dist/lib/spinner.d.ts +5 -0
- package/dist/lib/spinner.js +39 -0
- package/dist/lib/spinner.js.map +1 -0
- package/dist/transforms/ast-helpers.d.ts +50 -0
- package/dist/transforms/ast-helpers.js +153 -0
- package/dist/transforms/ast-helpers.js.map +1 -0
- package/dist/transforms/index.d.ts +7 -0
- package/dist/transforms/index.js +41 -0
- package/dist/transforms/index.js.map +1 -0
- package/dist/transforms/resolve.d.ts +1 -0
- package/dist/transforms/resolve.js +28 -0
- package/dist/transforms/resolve.js.map +1 -0
- package/dist/transforms/scan.d.ts +4 -0
- package/dist/transforms/scan.js +33 -0
- package/dist/transforms/scan.js.map +1 -0
- package/dist/transforms/stats.d.ts +11 -0
- package/dist/transforms/stats.js +42 -0
- package/dist/transforms/stats.js.map +1 -0
- package/dist/transforms/todo.d.ts +2 -0
- package/dist/transforms/todo.js +10 -0
- package/dist/transforms/todo.js.map +1 -0
- package/dist/transforms/transformer.d.ts +8 -0
- package/dist/transforms/transformer.js +19 -0
- package/dist/transforms/transformer.js.map +1 -0
- package/dist/transforms/v1/column-readonly.d.ts +6 -0
- package/dist/transforms/v1/column-readonly.js +37 -0
- package/dist/transforms/v1/column-readonly.js.map +1 -0
- package/dist/transforms/v1/column-unsigned-numeric.d.ts +6 -0
- package/dist/transforms/v1/column-unsigned-numeric.js +65 -0
- package/dist/transforms/v1/column-unsigned-numeric.js.map +1 -0
- package/dist/transforms/v1/column-width-zerofill.d.ts +6 -0
- package/dist/transforms/v1/column-width-zerofill.js +26 -0
- package/dist/transforms/v1/column-width-zerofill.js.map +1 -0
- package/dist/transforms/v1/connection-to-datasource.d.ts +6 -0
- package/dist/transforms/v1/connection-to-datasource.js +205 -0
- package/dist/transforms/v1/connection-to-datasource.js.map +1 -0
- package/dist/transforms/v1/datasource-mongodb.d.ts +7 -0
- package/dist/transforms/v1/datasource-mongodb.js +96 -0
- package/dist/transforms/v1/datasource-mongodb.js.map +1 -0
- package/dist/transforms/v1/datasource-mssql-domain.d.ts +7 -0
- package/dist/transforms/v1/datasource-mssql-domain.js +35 -0
- package/dist/transforms/v1/datasource-mssql-domain.js.map +1 -0
- package/dist/transforms/v1/datasource-mssql.d.ts +7 -0
- package/dist/transforms/v1/datasource-mssql.js +82 -0
- package/dist/transforms/v1/datasource-mssql.js.map +1 -0
- package/dist/transforms/v1/datasource-mysql-connector.d.ts +6 -0
- package/dist/transforms/v1/datasource-mysql-connector.js +25 -0
- package/dist/transforms/v1/datasource-mysql-connector.js.map +1 -0
- package/dist/transforms/v1/datasource-name.d.ts +6 -0
- package/dist/transforms/v1/datasource-name.js +46 -0
- package/dist/transforms/v1/datasource-name.js.map +1 -0
- package/dist/transforms/v1/datasource-sap.d.ts +6 -0
- package/dist/transforms/v1/datasource-sap.js +63 -0
- package/dist/transforms/v1/datasource-sap.js.map +1 -0
- package/dist/transforms/v1/datasource-sqlite-options.d.ts +6 -0
- package/dist/transforms/v1/datasource-sqlite-options.js +35 -0
- package/dist/transforms/v1/datasource-sqlite-options.js.map +1 -0
- package/dist/transforms/v1/datasource-sqlite-type.d.ts +6 -0
- package/dist/transforms/v1/datasource-sqlite-type.js +28 -0
- package/dist/transforms/v1/datasource-sqlite-type.js.map +1 -0
- package/dist/transforms/v1/find-options-lock-modes.d.ts +6 -0
- package/dist/transforms/v1/find-options-lock-modes.js +81 -0
- package/dist/transforms/v1/find-options-lock-modes.js.map +1 -0
- package/dist/transforms/v1/find-options-string-relations.d.ts +6 -0
- package/dist/transforms/v1/find-options-string-relations.js +69 -0
- package/dist/transforms/v1/find-options-string-relations.js.map +1 -0
- package/dist/transforms/v1/find-options-string-select.d.ts +6 -0
- package/dist/transforms/v1/find-options-string-select.js +36 -0
- package/dist/transforms/v1/find-options-string-select.js.map +1 -0
- package/dist/transforms/v1/global-functions.d.ts +7 -0
- package/dist/transforms/v1/global-functions.js +98 -0
- package/dist/transforms/v1/global-functions.js.map +1 -0
- package/dist/transforms/v1/index.d.ts +40 -0
- package/dist/transforms/v1/index.js +109 -0
- package/dist/transforms/v1/index.js.map +1 -0
- package/dist/transforms/v1/migrations-get-all.d.ts +7 -0
- package/dist/transforms/v1/migrations-get-all.js +39 -0
- package/dist/transforms/v1/migrations-get-all.js.map +1 -0
- package/dist/transforms/v1/mongodb-stats.d.ts +7 -0
- package/dist/transforms/v1/mongodb-stats.js +52 -0
- package/dist/transforms/v1/mongodb-stats.js.map +1 -0
- package/dist/transforms/v1/mongodb-types.d.ts +6 -0
- package/dist/transforms/v1/mongodb-types.js +84 -0
- package/dist/transforms/v1/mongodb-types.js.map +1 -0
- package/dist/transforms/v1/query-builder-native-parameters.d.ts +6 -0
- package/dist/transforms/v1/query-builder-native-parameters.js +20 -0
- package/dist/transforms/v1/query-builder-native-parameters.js.map +1 -0
- package/dist/transforms/v1/query-builder-on-conflict.d.ts +7 -0
- package/dist/transforms/v1/query-builder-on-conflict.js +56 -0
- package/dist/transforms/v1/query-builder-on-conflict.js.map +1 -0
- package/dist/transforms/v1/query-builder-or-update.d.ts +6 -0
- package/dist/transforms/v1/query-builder-or-update.js +56 -0
- package/dist/transforms/v1/query-builder-or-update.js.map +1 -0
- package/dist/transforms/v1/query-builder-print-sql.d.ts +7 -0
- package/dist/transforms/v1/query-builder-print-sql.js +49 -0
- package/dist/transforms/v1/query-builder-print-sql.js.map +1 -0
- package/dist/transforms/v1/query-builder-replace-property-names.d.ts +7 -0
- package/dist/transforms/v1/query-builder-replace-property-names.js +42 -0
- package/dist/transforms/v1/query-builder-replace-property-names.js.map +1 -0
- package/dist/transforms/v1/query-builder-where-expression.d.ts +6 -0
- package/dist/transforms/v1/query-builder-where-expression.js +39 -0
- package/dist/transforms/v1/query-builder-where-expression.js.map +1 -0
- package/dist/transforms/v1/query-runner-loaded-tables-views.d.ts +7 -0
- package/dist/transforms/v1/query-runner-loaded-tables-views.js +54 -0
- package/dist/transforms/v1/query-runner-loaded-tables-views.js.map +1 -0
- package/dist/transforms/v1/relation-count.d.ts +7 -0
- package/dist/transforms/v1/relation-count.js +41 -0
- package/dist/transforms/v1/relation-count.js.map +1 -0
- package/dist/transforms/v1/remove-abstract-repository.d.ts +5 -0
- package/dist/transforms/v1/remove-abstract-repository.js +93 -0
- package/dist/transforms/v1/remove-abstract-repository.js.map +1 -0
- package/dist/transforms/v1/remove-connector-package.d.ts +4 -0
- package/dist/transforms/v1/remove-connector-package.js +19 -0
- package/dist/transforms/v1/remove-connector-package.js.map +1 -0
- package/dist/transforms/v1/remove-datasource-name.d.ts +4 -0
- package/dist/transforms/v1/remove-datasource-name.js +56 -0
- package/dist/transforms/v1/remove-datasource-name.js.map +1 -0
- package/dist/transforms/v1/remove-mongodb-options.d.ts +5 -0
- package/dist/transforms/v1/remove-mongodb-options.js +86 -0
- package/dist/transforms/v1/remove-mongodb-options.js.map +1 -0
- package/dist/transforms/v1/remove-relation-count.d.ts +5 -0
- package/dist/transforms/v1/remove-relation-count.js +49 -0
- package/dist/transforms/v1/remove-relation-count.js.map +1 -0
- package/dist/transforms/v1/remove-replace-property-names.d.ts +5 -0
- package/dist/transforms/v1/remove-replace-property-names.js +35 -0
- package/dist/transforms/v1/remove-replace-property-names.js.map +1 -0
- package/dist/transforms/v1/remove-sap-options.d.ts +4 -0
- package/dist/transforms/v1/remove-sap-options.js +54 -0
- package/dist/transforms/v1/remove-sap-options.js.map +1 -0
- package/dist/transforms/v1/remove-unsigned-numeric.d.ts +4 -0
- package/dist/transforms/v1/remove-unsigned-numeric.js +76 -0
- package/dist/transforms/v1/remove-unsigned-numeric.js.map +1 -0
- package/dist/transforms/v1/remove-use-container.d.ts +5 -0
- package/dist/transforms/v1/remove-use-container.js +63 -0
- package/dist/transforms/v1/remove-use-container.js.map +1 -0
- package/dist/transforms/v1/remove-width-zerofill.d.ts +4 -0
- package/dist/transforms/v1/remove-width-zerofill.js +29 -0
- package/dist/transforms/v1/remove-width-zerofill.js.map +1 -0
- package/dist/transforms/v1/rename-connection-to-datasource.d.ts +4 -0
- package/dist/transforms/v1/rename-connection-to-datasource.js +111 -0
- package/dist/transforms/v1/rename-connection-to-datasource.js.map +1 -0
- package/dist/transforms/v1/rename-exist-to-exists.d.ts +4 -0
- package/dist/transforms/v1/rename-exist-to-exists.js +25 -0
- package/dist/transforms/v1/rename-exist-to-exists.js.map +1 -0
- package/dist/transforms/v1/rename-find-by-ids.d.ts +4 -0
- package/dist/transforms/v1/rename-find-by-ids.js +64 -0
- package/dist/transforms/v1/rename-find-by-ids.js.map +1 -0
- package/dist/transforms/v1/rename-get-all-migrations.d.ts +5 -0
- package/dist/transforms/v1/rename-get-all-migrations.js +32 -0
- package/dist/transforms/v1/rename-get-all-migrations.js.map +1 -0
- package/dist/transforms/v1/rename-loaded-tables-views.d.ts +5 -0
- package/dist/transforms/v1/rename-loaded-tables-views.js +48 -0
- package/dist/transforms/v1/rename-loaded-tables-views.js.map +1 -0
- package/dist/transforms/v1/rename-or-update-overload.d.ts +4 -0
- package/dist/transforms/v1/rename-or-update-overload.js +46 -0
- package/dist/transforms/v1/rename-or-update-overload.js.map +1 -0
- package/dist/transforms/v1/rename-print-sql-to-log-query.d.ts +4 -0
- package/dist/transforms/v1/rename-print-sql-to-log-query.js +25 -0
- package/dist/transforms/v1/rename-print-sql-to-log-query.js.map +1 -0
- package/dist/transforms/v1/replace-global-functions.d.ts +5 -0
- package/dist/transforms/v1/replace-global-functions.js +92 -0
- package/dist/transforms/v1/replace-global-functions.js.map +1 -0
- package/dist/transforms/v1/replace-lock-modes.d.ts +4 -0
- package/dist/transforms/v1/replace-lock-modes.js +75 -0
- package/dist/transforms/v1/replace-lock-modes.js.map +1 -0
- package/dist/transforms/v1/replace-mongodb-stats.d.ts +5 -0
- package/dist/transforms/v1/replace-mongodb-stats.js +54 -0
- package/dist/transforms/v1/replace-mongodb-stats.js.map +1 -0
- package/dist/transforms/v1/replace-mongodb-types.d.ts +4 -0
- package/dist/transforms/v1/replace-mongodb-types.js +72 -0
- package/dist/transforms/v1/replace-mongodb-types.js.map +1 -0
- package/dist/transforms/v1/replace-mssql-domain.d.ts +5 -0
- package/dist/transforms/v1/replace-mssql-domain.js +25 -0
- package/dist/transforms/v1/replace-mssql-domain.js.map +1 -0
- package/dist/transforms/v1/replace-on-conflict.d.ts +5 -0
- package/dist/transforms/v1/replace-on-conflict.js +49 -0
- package/dist/transforms/v1/replace-on-conflict.js.map +1 -0
- package/dist/transforms/v1/replace-readonly-column.d.ts +4 -0
- package/dist/transforms/v1/replace-readonly-column.js +28 -0
- package/dist/transforms/v1/replace-readonly-column.js.map +1 -0
- package/dist/transforms/v1/replace-set-native-parameters.d.ts +4 -0
- package/dist/transforms/v1/replace-set-native-parameters.js +25 -0
- package/dist/transforms/v1/replace-set-native-parameters.js.map +1 -0
- package/dist/transforms/v1/replace-sqlite-options.d.ts +4 -0
- package/dist/transforms/v1/replace-sqlite-options.js +29 -0
- package/dist/transforms/v1/replace-sqlite-options.js.map +1 -0
- package/dist/transforms/v1/replace-sqlite-type.d.ts +4 -0
- package/dist/transforms/v1/replace-sqlite-type.js +22 -0
- package/dist/transforms/v1/replace-sqlite-type.js.map +1 -0
- package/dist/transforms/v1/replace-where-expression-type.d.ts +4 -0
- package/dist/transforms/v1/replace-where-expression-type.js +41 -0
- package/dist/transforms/v1/replace-where-expression-type.js.map +1 -0
- package/dist/transforms/v1/repository-abstract.d.ts +7 -0
- package/dist/transforms/v1/repository-abstract.js +83 -0
- package/dist/transforms/v1/repository-abstract.js.map +1 -0
- package/dist/transforms/v1/repository-exist.d.ts +6 -0
- package/dist/transforms/v1/repository-exist.js +20 -0
- package/dist/transforms/v1/repository-exist.js.map +1 -0
- package/dist/transforms/v1/repository-find-by-ids.d.ts +6 -0
- package/dist/transforms/v1/repository-find-by-ids.js +74 -0
- package/dist/transforms/v1/repository-find-by-ids.js.map +1 -0
- package/dist/transforms/v1/repository-find-one-by-id.d.ts +6 -0
- package/dist/transforms/v1/repository-find-one-by-id.js +55 -0
- package/dist/transforms/v1/repository-find-one-by-id.js.map +1 -0
- package/dist/transforms/v1/upgrade-dependencies.d.ts +15 -0
- package/dist/transforms/v1/upgrade-dependencies.js +163 -0
- package/dist/transforms/v1/upgrade-dependencies.js.map +1 -0
- package/dist/transforms/v1/use-container.d.ts +7 -0
- package/dist/transforms/v1/use-container.js +54 -0
- package/dist/transforms/v1/use-container.js.map +1 -0
- package/package.json +50 -0
|
@@ -0,0 +1,205 @@
|
|
|
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.connectionToDataSource = exports.description = exports.name = void 0;
|
|
7
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
+
const ast_helpers_1 = require("../ast-helpers");
|
|
9
|
+
exports.name = node_path_1.default.basename(__filename, node_path_1.default.extname(__filename));
|
|
10
|
+
exports.description = "migrate from `Connection` to `DataSource`";
|
|
11
|
+
const connectionToDataSource = (file, api) => {
|
|
12
|
+
const j = api.jscodeshift;
|
|
13
|
+
const root = j(file.source);
|
|
14
|
+
let hasChanges = false;
|
|
15
|
+
// Type/class renames
|
|
16
|
+
const typeRenames = {
|
|
17
|
+
Connection: "DataSource",
|
|
18
|
+
ConnectionOptions: "DataSourceOptions",
|
|
19
|
+
BaseConnectionOptions: "BaseDataSourceOptions",
|
|
20
|
+
MysqlConnectionOptions: "MysqlDataSourceOptions",
|
|
21
|
+
MariaDbConnectionOptions: "MariaDbDataSourceOptions",
|
|
22
|
+
PostgresConnectionOptions: "PostgresDataSourceOptions",
|
|
23
|
+
CockroachConnectionOptions: "CockroachDataSourceOptions",
|
|
24
|
+
SqlServerConnectionOptions: "SqlServerDataSourceOptions",
|
|
25
|
+
OracleConnectionOptions: "OracleDataSourceOptions",
|
|
26
|
+
SqliteConnectionOptions: "BetterSqlite3DataSourceOptions",
|
|
27
|
+
BetterSqlite3ConnectionOptions: "BetterSqlite3DataSourceOptions",
|
|
28
|
+
SapConnectionOptions: "SapDataSourceOptions",
|
|
29
|
+
MongoConnectionOptions: "MongoDataSourceOptions",
|
|
30
|
+
CordovaConnectionOptions: "CordovaDataSourceOptions",
|
|
31
|
+
NativescriptConnectionOptions: "NativescriptDataSourceOptions",
|
|
32
|
+
ReactNativeConnectionOptions: "ReactNativeDataSourceOptions",
|
|
33
|
+
ExpoConnectionOptions: "ExpoDataSourceOptions",
|
|
34
|
+
AuroraMysqlConnectionOptions: "AuroraMysqlDataSourceOptions",
|
|
35
|
+
AuroraPostgresConnectionOptions: "AuroraPostgresDataSourceOptions",
|
|
36
|
+
SpannerConnectionOptions: "SpannerDataSourceOptions",
|
|
37
|
+
};
|
|
38
|
+
// Method renames on DataSource/Connection instances
|
|
39
|
+
const methodRenames = {
|
|
40
|
+
connect: "initialize",
|
|
41
|
+
close: "destroy",
|
|
42
|
+
};
|
|
43
|
+
// TypeORM types whose instances have a `.connection` property
|
|
44
|
+
// that was renamed to `.dataSource` in v1
|
|
45
|
+
const typesWithConnectionProp = new Set([
|
|
46
|
+
"QueryRunner",
|
|
47
|
+
"EntityManager",
|
|
48
|
+
"Repository",
|
|
49
|
+
"TreeRepository",
|
|
50
|
+
"MongoRepository",
|
|
51
|
+
"SelectQueryBuilder",
|
|
52
|
+
"InsertQueryBuilder",
|
|
53
|
+
"UpdateQueryBuilder",
|
|
54
|
+
"DeleteQueryBuilder",
|
|
55
|
+
"SoftDeleteQueryBuilder",
|
|
56
|
+
"RelationQueryBuilder",
|
|
57
|
+
]);
|
|
58
|
+
// Collect local names imported from "typeorm" that need renaming
|
|
59
|
+
const localRenames = new Map();
|
|
60
|
+
root.find(j.ImportDeclaration, {
|
|
61
|
+
source: { value: "typeorm" },
|
|
62
|
+
}).forEach((path) => {
|
|
63
|
+
path.node.specifiers?.forEach((spec) => {
|
|
64
|
+
if (spec.type === "ImportSpecifier" &&
|
|
65
|
+
spec.imported.type === "Identifier") {
|
|
66
|
+
const oldImported = spec.imported.name;
|
|
67
|
+
if (typeRenames[oldImported]) {
|
|
68
|
+
const localName = spec.local?.type === "Identifier"
|
|
69
|
+
? spec.local.name
|
|
70
|
+
: oldImported;
|
|
71
|
+
localRenames.set(localName, typeRenames[oldImported]);
|
|
72
|
+
// Rename the import specifier itself
|
|
73
|
+
spec.imported.name = typeRenames[oldImported];
|
|
74
|
+
if (spec.local?.type === "Identifier" &&
|
|
75
|
+
spec.local.name === localName) {
|
|
76
|
+
spec.local.name = typeRenames[oldImported];
|
|
77
|
+
}
|
|
78
|
+
hasChanges = true;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
// Rename only identifiers that were imported from "typeorm"
|
|
84
|
+
for (const [oldName, newName] of localRenames) {
|
|
85
|
+
// TSTypeReference (e.g. const x: Connection = ...)
|
|
86
|
+
root.find(j.TSTypeReference, {
|
|
87
|
+
typeName: { name: oldName },
|
|
88
|
+
}).forEach((path) => {
|
|
89
|
+
if (path.node.typeName.type === "Identifier") {
|
|
90
|
+
path.node.typeName.name = newName;
|
|
91
|
+
hasChanges = true;
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
// NewExpression (e.g. new Connection(...))
|
|
95
|
+
root.find(j.NewExpression, {
|
|
96
|
+
callee: { type: "Identifier", name: oldName },
|
|
97
|
+
}).forEach((path) => {
|
|
98
|
+
if (path.node.callee.type === "Identifier") {
|
|
99
|
+
path.node.callee.name = newName;
|
|
100
|
+
hasChanges = true;
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
// Collect variable names known to be Connection/DataSource instances
|
|
105
|
+
const connectionTypeNames = new Set(Object.keys(typeRenames));
|
|
106
|
+
connectionTypeNames.add("DataSource");
|
|
107
|
+
const connectionVarNames = new Set();
|
|
108
|
+
// Variables assigned from new Connection(...) / new DataSource(...)
|
|
109
|
+
root.find(j.VariableDeclarator).forEach((path) => {
|
|
110
|
+
const init = path.node.init;
|
|
111
|
+
if (init?.type === "NewExpression" &&
|
|
112
|
+
init.callee.type === "Identifier" &&
|
|
113
|
+
connectionTypeNames.has(init.callee.name)) {
|
|
114
|
+
if (path.node.id.type === "Identifier") {
|
|
115
|
+
connectionVarNames.add(path.node.id.name);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
// Variables with Connection/DataSource type annotations
|
|
120
|
+
root.find(j.VariableDeclarator).forEach((path) => {
|
|
121
|
+
const id = path.node.id;
|
|
122
|
+
if (id.type === "Identifier" &&
|
|
123
|
+
id.typeAnnotation?.type === "TSTypeAnnotation") {
|
|
124
|
+
const ann = id.typeAnnotation.typeAnnotation;
|
|
125
|
+
if (ann.type === "TSTypeReference" &&
|
|
126
|
+
ann.typeName.type === "Identifier" &&
|
|
127
|
+
connectionTypeNames.has(ann.typeName.name)) {
|
|
128
|
+
connectionVarNames.add(id.name);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
// Rename method calls: .connect() → .initialize(), .close() → .destroy()
|
|
133
|
+
// Only on variables known to be Connection/DataSource instances
|
|
134
|
+
for (const [oldMethod, newMethod] of Object.entries(methodRenames)) {
|
|
135
|
+
root.find(j.CallExpression, {
|
|
136
|
+
callee: {
|
|
137
|
+
type: "MemberExpression",
|
|
138
|
+
property: { name: oldMethod },
|
|
139
|
+
},
|
|
140
|
+
}).forEach((path) => {
|
|
141
|
+
if (path.node.callee.type === "MemberExpression" &&
|
|
142
|
+
path.node.callee.property.type === "Identifier") {
|
|
143
|
+
const obj = path.node.callee.object;
|
|
144
|
+
if (obj.type === "Identifier" &&
|
|
145
|
+
connectionVarNames.has(obj.name)) {
|
|
146
|
+
path.node.callee.property.name = newMethod;
|
|
147
|
+
hasChanges = true;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
// Collect variable/param names typed as TypeORM types with .connection
|
|
153
|
+
const connectionPropVarNames = new Set();
|
|
154
|
+
const collectTypedIdentifier = (id) => {
|
|
155
|
+
if (!id.name || !id.typeAnnotation)
|
|
156
|
+
return;
|
|
157
|
+
if (id.typeAnnotation.type !== "TSTypeAnnotation")
|
|
158
|
+
return;
|
|
159
|
+
const ann = id.typeAnnotation;
|
|
160
|
+
if (ann.typeAnnotation.type !== "TSTypeReference")
|
|
161
|
+
return;
|
|
162
|
+
const ref = ann.typeAnnotation;
|
|
163
|
+
if (ref.typeName.type === "Identifier" &&
|
|
164
|
+
typesWithConnectionProp.has(ref.typeName.name)) {
|
|
165
|
+
connectionPropVarNames.add(id.name);
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
// Variable declarations with type annotations
|
|
169
|
+
root.find(j.VariableDeclarator).forEach((path) => {
|
|
170
|
+
if ((0, ast_helpers_1.isIdentifier)(path.node.id))
|
|
171
|
+
collectTypedIdentifier(path.node.id);
|
|
172
|
+
});
|
|
173
|
+
// Function/method/arrow parameters and constructor parameter properties
|
|
174
|
+
(0, ast_helpers_1.forEachIdentifierParam)(root, j, collectTypedIdentifier);
|
|
175
|
+
// Rename .isConnected → .isInitialized on Connection/DataSource instances
|
|
176
|
+
root.find(j.MemberExpression, {
|
|
177
|
+
property: { name: "isConnected" },
|
|
178
|
+
}).forEach((path) => {
|
|
179
|
+
if (path.node.property.type === "Identifier") {
|
|
180
|
+
const obj = path.node.object;
|
|
181
|
+
if (obj.type === "Identifier" && connectionVarNames.has(obj.name)) {
|
|
182
|
+
path.node.property.name = "isInitialized";
|
|
183
|
+
hasChanges = true;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
// Rename .connection → .dataSource on known TypeORM instances
|
|
188
|
+
root.find(j.MemberExpression, {
|
|
189
|
+
property: { name: "connection" },
|
|
190
|
+
}).forEach((path) => {
|
|
191
|
+
if (path.node.property.type === "Identifier") {
|
|
192
|
+
const obj = path.node.object;
|
|
193
|
+
if (obj.type === "Identifier" &&
|
|
194
|
+
connectionPropVarNames.has(obj.name)) {
|
|
195
|
+
path.node.property.name = "dataSource";
|
|
196
|
+
hasChanges = true;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
return hasChanges ? root.toSource() : undefined;
|
|
201
|
+
};
|
|
202
|
+
exports.connectionToDataSource = connectionToDataSource;
|
|
203
|
+
exports.fn = exports.connectionToDataSource;
|
|
204
|
+
exports.default = exports.fn;
|
|
205
|
+
//# sourceMappingURL=connection-to-datasource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection-to-datasource.js","sourceRoot":"","sources":["../../../src/transforms/v1/connection-to-datasource.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA4B;AAE5B,gDAAqE;AAExD,QAAA,IAAI,GAAG,mBAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,mBAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAA;AAC1D,QAAA,WAAW,GAAG,2CAA2C,CAAA;AAE/D,MAAM,sBAAsB,GAAG,CAAC,IAAc,EAAE,GAAQ,EAAE,EAAE;IAC/D,MAAM,CAAC,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IAAI,CAAC,EACtC,CAAC;gBACC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,GAAG,YAAY,CAAA;gBACtC,UAAU,GAAG,IAAI,CAAA;YACrB,CAAC;QACL,CAAC;IACL,CAAC,CAAC,CAAA;IAEF,OAAO,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS,CAAA;AACnD,CAAC,CAAA;AAjOY,QAAA,sBAAsB,0BAiOlC;AAEY,QAAA,EAAE,GAAG,8BAAsB,CAAA;AACxC,kBAAe,UAAE,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { API, FileInfo } from "jscodeshift";
|
|
2
|
+
export declare const name: string;
|
|
3
|
+
export declare const description = "remove and rename deprecated MongoDB connection options";
|
|
4
|
+
export declare const manual = true;
|
|
5
|
+
export declare const datasourceMongodb: (file: FileInfo, api: API) => string | undefined;
|
|
6
|
+
export declare const fn: (file: FileInfo, api: API) => string | undefined;
|
|
7
|
+
export default fn;
|
|
@@ -0,0 +1,96 @@
|
|
|
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.datasourceMongodb = 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 = "remove and rename deprecated MongoDB connection options";
|
|
13
|
+
exports.manual = true;
|
|
14
|
+
const datasourceMongodb = (file, api) => {
|
|
15
|
+
const j = api.jscodeshift;
|
|
16
|
+
const root = j(file.source);
|
|
17
|
+
if (!(0, ast_helpers_1.fileImportsFrom)(root, j, "typeorm"))
|
|
18
|
+
return undefined;
|
|
19
|
+
let hasChanges = false;
|
|
20
|
+
let hasTodos = false;
|
|
21
|
+
const removeProps = new Set([
|
|
22
|
+
"useNewUrlParser",
|
|
23
|
+
"useUnifiedTopology",
|
|
24
|
+
"keepAlive",
|
|
25
|
+
"keepAliveInitialDelay",
|
|
26
|
+
"sslCRL",
|
|
27
|
+
]);
|
|
28
|
+
const simpleRenames = {
|
|
29
|
+
appname: "appName",
|
|
30
|
+
ssl: "tls",
|
|
31
|
+
sslCA: "tlsCAFile",
|
|
32
|
+
sslCert: "tlsCertificateKeyFile",
|
|
33
|
+
sslKey: "tlsCertificateKeyFile",
|
|
34
|
+
sslPass: "tlsCertificateKeyFilePassword",
|
|
35
|
+
};
|
|
36
|
+
const writeConcernProps = new Set([
|
|
37
|
+
"fsync",
|
|
38
|
+
"j",
|
|
39
|
+
"w",
|
|
40
|
+
"wtimeout",
|
|
41
|
+
"wtimeoutMS",
|
|
42
|
+
]);
|
|
43
|
+
// Remove deprecated options
|
|
44
|
+
root.find(j.ObjectProperty).forEach((path) => {
|
|
45
|
+
if (path.node.key.type !== "Identifier" &&
|
|
46
|
+
path.node.key.type !== "StringLiteral") {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const name = path.node.key.type === "Identifier"
|
|
50
|
+
? path.node.key.name
|
|
51
|
+
: path.node.key.value;
|
|
52
|
+
if (removeProps.has(name)) {
|
|
53
|
+
j(path).remove();
|
|
54
|
+
hasChanges = true;
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
// Simple renames
|
|
58
|
+
if (simpleRenames[name]) {
|
|
59
|
+
if (path.node.key.type === "Identifier") {
|
|
60
|
+
path.node.key.name = simpleRenames[name];
|
|
61
|
+
}
|
|
62
|
+
else if (path.node.key.type === "StringLiteral") {
|
|
63
|
+
path.node.key.value = simpleRenames[name];
|
|
64
|
+
}
|
|
65
|
+
hasChanges = true;
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
// sslValidate → tlsAllowInvalidCertificates (inverted boolean — add TODO)
|
|
69
|
+
if (name === "sslValidate") {
|
|
70
|
+
if (path.node.key.type === "Identifier") {
|
|
71
|
+
path.node.key.name = "tlsAllowInvalidCertificates";
|
|
72
|
+
}
|
|
73
|
+
else if (path.node.key.type === "StringLiteral") {
|
|
74
|
+
path.node.key.value = "tlsAllowInvalidCertificates";
|
|
75
|
+
}
|
|
76
|
+
// Add TODO comment about inverted boolean
|
|
77
|
+
(0, todo_1.addTodoComment)(path.node, "`sslValidate` was renamed to `tlsAllowInvalidCertificates` with inverted boolean logic. Review and invert the value.", j);
|
|
78
|
+
hasChanges = true;
|
|
79
|
+
hasTodos = true;
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
// writeConcern-related props → add TODO
|
|
83
|
+
if (writeConcernProps.has(name)) {
|
|
84
|
+
(0, todo_1.addTodoComment)(path.node, `\`${name}\` was removed — migrate to \`writeConcern: { ... }\``, j);
|
|
85
|
+
hasChanges = true;
|
|
86
|
+
hasTodos = true;
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
if (hasTodos)
|
|
90
|
+
stats_1.stats.count.todo(api, exports.name, file);
|
|
91
|
+
return hasChanges ? root.toSource() : undefined;
|
|
92
|
+
};
|
|
93
|
+
exports.datasourceMongodb = datasourceMongodb;
|
|
94
|
+
exports.fn = exports.datasourceMongodb;
|
|
95
|
+
exports.default = exports.fn;
|
|
96
|
+
//# sourceMappingURL=datasource-mongodb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datasource-mongodb.js","sourceRoot":"","sources":["../../../src/transforms/v1/datasource-mongodb.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA4B;AAE5B,gDAAgD;AAChD,kCAAwC;AACxC,oCAAgC;AAEnB,QAAA,IAAI,GAAG,mBAAI,CAAC,QAAQ,CAAC,UAAU,EAA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T,sHAAsH,EACtH,CAAC,CACJ,CAAA;YACD,UAAU,GAAG,IAAI,CAAA;YACjB,QAAQ,GAAG,IAAI,CAAA;YACf,OAAM;QACV,CAAC;QAED,wCAAwC;QACxC,IAAI,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YAC9B,IAAA,qBAAc,EACV,IAAI,CAAC,IAAI,EACT,KAAK,IAAI,uDAAuD,EAChE,CAAC,CACJ,CAAA;YACD,UAAU,GAAG,IAAI,CAAA;YACjB,QAAQ,GAAG,IAAI,CAAA;QACnB,CAAC;IACL,CAAC,CAAC,CAAA;IAEF,IAAI,QAAQ;QAAE,aAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,YAAI,EAAE,IAAI,CAAC,CAAA;IAE/C,OAAO,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS,CAAA;AACnD,CAAC,CAAA;AAlGY,QAAA,iBAAiB,qBAkG7B;AAEY,QAAA,EAAE,GAAG,yBAAiB,CAAA;AACnC,kBAAe,UAAE,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { API, FileInfo } from "jscodeshift";
|
|
2
|
+
export declare const name: string;
|
|
3
|
+
export declare const description = "flag removed `domain` MSSQL option for manual migration";
|
|
4
|
+
export declare const manual = true;
|
|
5
|
+
export declare const datasourceMssqlDomain: (file: FileInfo, api: API) => string | undefined;
|
|
6
|
+
export declare const fn: (file: FileInfo, api: API) => string | undefined;
|
|
7
|
+
export default fn;
|
|
@@ -0,0 +1,35 @@
|
|
|
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.datasourceMssqlDomain = 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 `domain` MSSQL option for manual migration";
|
|
13
|
+
exports.manual = true;
|
|
14
|
+
const datasourceMssqlDomain = (file, api) => {
|
|
15
|
+
const j = api.jscodeshift;
|
|
16
|
+
const root = j(file.source);
|
|
17
|
+
if (!(0, ast_helpers_1.fileImportsFrom)(root, j, "typeorm"))
|
|
18
|
+
return undefined;
|
|
19
|
+
let hasChanges = false;
|
|
20
|
+
let hasTodos = false;
|
|
21
|
+
root.find(j.ObjectProperty, {
|
|
22
|
+
key: { type: "Identifier", name: "domain" },
|
|
23
|
+
}).forEach((path) => {
|
|
24
|
+
(0, todo_1.addTodoComment)(path.node, '`domain` was removed — restructure to `authentication: { type: "ntlm", options: { domain: "..." } }`', j);
|
|
25
|
+
hasChanges = true;
|
|
26
|
+
hasTodos = true;
|
|
27
|
+
});
|
|
28
|
+
if (hasTodos)
|
|
29
|
+
stats_1.stats.count.todo(api, exports.name, file);
|
|
30
|
+
return hasChanges ? root.toSource() : undefined;
|
|
31
|
+
};
|
|
32
|
+
exports.datasourceMssqlDomain = datasourceMssqlDomain;
|
|
33
|
+
exports.fn = exports.datasourceMssqlDomain;
|
|
34
|
+
exports.default = exports.fn;
|
|
35
|
+
//# sourceMappingURL=datasource-mssql-domain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datasource-mssql-domain.js","sourceRoot":"","sources":["../../../src/transforms/v1/datasource-mssql-domain.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA4B;AAE5B,gDAAgD;AAChD,kCAAwC;AACxC,oCAAgC;AAEnB,QAAA,IAAI,GAAG,mBAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,mBAAI,CAAC,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migrate removed MSSQL `domain` option and fix isolation level format";
|
|
4
|
+
export declare const manual = true;
|
|
5
|
+
export declare const datasourceMssql: (file: FileInfo, api: API) => string | undefined;
|
|
6
|
+
export declare const fn: (file: FileInfo, api: API) => string | undefined;
|
|
7
|
+
export default fn;
|
|
@@ -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.datasourceMssql = 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 = "migrate removed MSSQL `domain` option and fix isolation level format";
|
|
13
|
+
exports.manual = true;
|
|
14
|
+
const isolationValueRenames = {
|
|
15
|
+
READ_UNCOMMITTED: "READ UNCOMMITTED",
|
|
16
|
+
READ_COMMITTED: "READ COMMITTED",
|
|
17
|
+
REPEATABLE_READ: "REPEATABLE READ",
|
|
18
|
+
};
|
|
19
|
+
const datasourceMssql = (file, api) => {
|
|
20
|
+
const j = api.jscodeshift;
|
|
21
|
+
const root = j(file.source);
|
|
22
|
+
if (!(0, ast_helpers_1.fileImportsFrom)(root, j, "typeorm"))
|
|
23
|
+
return undefined;
|
|
24
|
+
let hasChanges = false;
|
|
25
|
+
let hasTodos = false;
|
|
26
|
+
// Find object literals with `type: "mssql"`
|
|
27
|
+
root.find(j.ObjectExpression).forEach((objPath) => {
|
|
28
|
+
const props = objPath.node.properties;
|
|
29
|
+
const isMssql = props.some((p) => p.type === "ObjectProperty" &&
|
|
30
|
+
p.key.type === "Identifier" &&
|
|
31
|
+
p.key.name === "type" &&
|
|
32
|
+
p.value.type === "StringLiteral" &&
|
|
33
|
+
p.value.value === "mssql");
|
|
34
|
+
if (!isMssql)
|
|
35
|
+
return;
|
|
36
|
+
// Flag removed `domain` option with TODO
|
|
37
|
+
for (const prop of props) {
|
|
38
|
+
if (prop.type === "ObjectProperty" &&
|
|
39
|
+
prop.key.type === "Identifier" &&
|
|
40
|
+
prop.key.name === "domain") {
|
|
41
|
+
(0, todo_1.addTodoComment)(prop, '`domain` was removed — restructure to `authentication: { type: "ntlm", options: { domain: "..." } }`', j);
|
|
42
|
+
hasChanges = true;
|
|
43
|
+
hasTodos = true;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
// Find the `options` nested object
|
|
47
|
+
const optionsProp = props.find((p) => p.type === "ObjectProperty" &&
|
|
48
|
+
p.key.type === "Identifier" &&
|
|
49
|
+
p.key.name === "options" &&
|
|
50
|
+
p.value.type === "ObjectExpression");
|
|
51
|
+
if (!optionsProp ||
|
|
52
|
+
optionsProp.type !== "ObjectProperty" ||
|
|
53
|
+
optionsProp.value.type !== "ObjectExpression")
|
|
54
|
+
return;
|
|
55
|
+
for (const innerProp of optionsProp.value.properties) {
|
|
56
|
+
if (innerProp.type !== "ObjectProperty" ||
|
|
57
|
+
innerProp.key.type !== "Identifier")
|
|
58
|
+
continue;
|
|
59
|
+
// Rename `isolation` → `isolationLevel`
|
|
60
|
+
if (innerProp.key.name === "isolation") {
|
|
61
|
+
innerProp.key.name = "isolationLevel";
|
|
62
|
+
hasChanges = true;
|
|
63
|
+
}
|
|
64
|
+
// Fix isolation value format on isolationLevel / connectionIsolationLevel
|
|
65
|
+
if ((innerProp.key.name === "isolationLevel" ||
|
|
66
|
+
innerProp.key.name === "connectionIsolationLevel") &&
|
|
67
|
+
innerProp.value.type === "StringLiteral" &&
|
|
68
|
+
isolationValueRenames[innerProp.value.value]) {
|
|
69
|
+
innerProp.value.value =
|
|
70
|
+
isolationValueRenames[innerProp.value.value];
|
|
71
|
+
hasChanges = true;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
if (hasTodos)
|
|
76
|
+
stats_1.stats.count.todo(api, exports.name, file);
|
|
77
|
+
return hasChanges ? root.toSource() : undefined;
|
|
78
|
+
};
|
|
79
|
+
exports.datasourceMssql = datasourceMssql;
|
|
80
|
+
exports.fn = exports.datasourceMssql;
|
|
81
|
+
exports.default = exports.fn;
|
|
82
|
+
//# sourceMappingURL=datasource-mssql.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datasource-mssql.js","sourceRoot":"","sources":["../../../src/transforms/v1/datasource-mssql.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA4B;AAE5B,gDAAgD;AAChD,kCAAwC;AACxC,oCAAgC;AAEnB,QAAA,IAAI,GAAG,mBAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,mBAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAA;AAC1D,QAAA,WAAW,GACpB,sEAAsE,CAAA;AAC7D,QAAA,MAAM,GAAG,IAAI,CAAA;AAE1B,MAAM,qBAAqB,GAA2B;IAClD,gBAAgB,EAAE,kBAAkB;IACpC,cAAc,EAAE,gBAAgB;IAChC,eAAe,EAAE,iBAAiB;CACrC,CAAA;AAEM,MAAM,eAAe,GAAG,CAAC,IAAc,EAAE,GAAQ,EAAE,EAAE;IACxD,MAAM,CAAC,GAAG,GAAG,CAAC,WAAW,CAAA;IACzB,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAE3B,IAAI,CAAC,IAAA,6BAAe,EAAC,IAAI,EAAE,CAAC,EAAE,SAAS,CAAC;QAAE,OAAO,SAAS,CAAA;IAE1D,IAAI,UAAU,GAAG,KAAK,CAAA;IACtB,IAAI,QAAQ,GAAG,KAAK,CAAA;IAEpB,4CAA4C;IAC5C,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,gBAAgB,CAAC,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7C,OAAM;QAEV,KAAK,MAAM,SAAS,IAAI,WAAW,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;YACnD,IACI,SAAS,CAAC,IAAI,KAAK,gBAAgB;gBACnC,SAAS,CAAC,GAAG,CAAC,IAAI,KAAK,YAAY;gBAEnC,SAAQ;YAEZ,wCAAwC;YACxC,IAAI,SAAS,CAAC,GAAG,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;gBACrC,SAAS,CAAC,GAAG,CAAC,IAAI,GAAG,gBAAgB,CAAA;gBACrC,UAAU,GAAG,IAAI,CAAA;YACrB,CAAC;YAED,0EAA0E;YAC1E,IACI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,KAAK,gBAAgB;gBACpC,SAAS,CAAC,GAAG,CAAC,IAAI,KAAK,0BAA0B,CAAC;gBACtD,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,eAAe;gBACxC,qBAAqB,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,EAC9C,CAAC;gBACC,SAAS,CAAC,KAAK,CAAC,KAAK;oBACjB,qBAAqB,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;gBAChD,UAAU,GAAG,IAAI,CAAA;YACrB,CAAC;QACL,CAAC;IACL,CAAC,CAAC,CAAA;IAEF,IAAI,QAAQ;QAAE,aAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,YAAI,EAAE,IAAI,CAAC,CAAA;IAE/C,OAAO,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS,CAAA;AACnD,CAAC,CAAA;AApFY,QAAA,eAAe,mBAoF3B;AAEY,QAAA,EAAE,GAAG,uBAAe,CAAA;AACjC,kBAAe,UAAE,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { API, FileInfo } from "jscodeshift";
|
|
2
|
+
export declare const name: string;
|
|
3
|
+
export declare const description = "remove deprecated `connectorPackage` option from MySQL config";
|
|
4
|
+
export declare const datasourceMysqlConnector: (file: FileInfo, api: API) => string | undefined;
|
|
5
|
+
export declare const fn: (file: FileInfo, api: API) => string | undefined;
|
|
6
|
+
export default fn;
|
|
@@ -0,0 +1,25 @@
|
|
|
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.datasourceMysqlConnector = exports.description = exports.name = void 0;
|
|
7
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
+
exports.name = node_path_1.default.basename(__filename, node_path_1.default.extname(__filename));
|
|
9
|
+
exports.description = "remove deprecated `connectorPackage` option from MySQL config";
|
|
10
|
+
const datasourceMysqlConnector = (file, api) => {
|
|
11
|
+
const j = api.jscodeshift;
|
|
12
|
+
const root = j(file.source);
|
|
13
|
+
let hasChanges = false;
|
|
14
|
+
root.find(j.ObjectProperty, {
|
|
15
|
+
key: { type: "Identifier", name: "connectorPackage" },
|
|
16
|
+
}).forEach((path) => {
|
|
17
|
+
j(path).remove();
|
|
18
|
+
hasChanges = true;
|
|
19
|
+
});
|
|
20
|
+
return hasChanges ? root.toSource() : undefined;
|
|
21
|
+
};
|
|
22
|
+
exports.datasourceMysqlConnector = datasourceMysqlConnector;
|
|
23
|
+
exports.fn = exports.datasourceMysqlConnector;
|
|
24
|
+
exports.default = exports.fn;
|
|
25
|
+
//# sourceMappingURL=datasource-mysql-connector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datasource-mysql-connector.js","sourceRoot":"","sources":["../../../src/transforms/v1/datasource-mysql-connector.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA4B;AAGf,QAAA,IAAI,GAAG,mBAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,mBAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAA;AAC1D,QAAA,WAAW,GACpB,+DAA+D,CAAA;AAE5D,MAAM,wBAAwB,GAAG,CAAC,IAAc,EAAE,GAAQ,EAAE,EAAE;IACjE,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,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc,EAAE;QACxB,GAAG,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,kBAAkB,EAAE;KACxD,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAChB,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,CAAA;QAChB,UAAU,GAAG,IAAI,CAAA;IACrB,CAAC,CAAC,CAAA;IAEF,OAAO,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS,CAAA;AACnD,CAAC,CAAA;AAbY,QAAA,wBAAwB,4BAapC;AAEY,QAAA,EAAE,GAAG,gCAAwB,CAAA;AAC1C,kBAAe,UAAE,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { API, FileInfo } from "jscodeshift";
|
|
2
|
+
export declare const name: string;
|
|
3
|
+
export declare const description = "remove deprecated `name` property from DataSource options";
|
|
4
|
+
export declare const datasourceName: (file: FileInfo, api: API) => string | undefined;
|
|
5
|
+
export declare const fn: (file: FileInfo, api: API) => string | undefined;
|
|
6
|
+
export default fn;
|
|
@@ -0,0 +1,46 @@
|
|
|
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.datasourceName = exports.description = exports.name = void 0;
|
|
7
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
+
const ast_helpers_1 = require("../ast-helpers");
|
|
9
|
+
exports.name = node_path_1.default.basename(__filename, node_path_1.default.extname(__filename));
|
|
10
|
+
exports.description = "remove deprecated `name` property from DataSource options";
|
|
11
|
+
const propertyNames = new Set(["name"]);
|
|
12
|
+
const datasourceName = (file, api) => {
|
|
13
|
+
const j = api.jscodeshift;
|
|
14
|
+
const root = j(file.source);
|
|
15
|
+
let hasChanges = false;
|
|
16
|
+
const removeNameFromObject = (arg) => {
|
|
17
|
+
if (arg?.type !== "ObjectExpression")
|
|
18
|
+
return;
|
|
19
|
+
if ((0, ast_helpers_1.removeObjectProperties)(arg, propertyNames)) {
|
|
20
|
+
hasChanges = true;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
// new DataSource({ name: ... })
|
|
24
|
+
root.find(j.NewExpression, {
|
|
25
|
+
callee: { type: "Identifier", name: "DataSource" },
|
|
26
|
+
}).forEach((path) => {
|
|
27
|
+
removeNameFromObject(path.node.arguments[0]);
|
|
28
|
+
});
|
|
29
|
+
// new Connection({ name: ... })
|
|
30
|
+
root.find(j.NewExpression, {
|
|
31
|
+
callee: { type: "Identifier", name: "Connection" },
|
|
32
|
+
}).forEach((path) => {
|
|
33
|
+
removeNameFromObject(path.node.arguments[0]);
|
|
34
|
+
});
|
|
35
|
+
// createConnection({ name: ... })
|
|
36
|
+
root.find(j.CallExpression, {
|
|
37
|
+
callee: { type: "Identifier", name: "createConnection" },
|
|
38
|
+
}).forEach((path) => {
|
|
39
|
+
removeNameFromObject(path.node.arguments[0]);
|
|
40
|
+
});
|
|
41
|
+
return hasChanges ? root.toSource() : undefined;
|
|
42
|
+
};
|
|
43
|
+
exports.datasourceName = datasourceName;
|
|
44
|
+
exports.fn = exports.datasourceName;
|
|
45
|
+
exports.default = exports.fn;
|
|
46
|
+
//# sourceMappingURL=datasource-name.js.map
|
|
@@ -0,0 +1 @@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AE,YAAY,EAAE;KACrD,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAChB,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAA;IAChD,CAAC,CAAC,CAAA;IAEF,kCAAkC;IAClC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc,EAAE;QACxB,MAAM,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,kBAAkB,EAAE;KAC3D,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAChB,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAA;IAChD,CAAC,CAAC,CAAA;IAEF,OAAO,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS,CAAA;AACnD,CAAC,CAAA;AAnCY,QAAA,cAAc,kBAmC1B;AAEY,QAAA,EAAE,GAAG,sBAAc,CAAA;AAChC,kBAAe,UAAE,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { API, FileInfo } from "jscodeshift";
|
|
2
|
+
export declare const name: string;
|
|
3
|
+
export declare const description = "rename and remove deprecated SAP HANA connection options";
|
|
4
|
+
export declare const datasourceSap: (file: FileInfo, api: API) => string | undefined;
|
|
5
|
+
export declare const fn: (file: FileInfo, api: API) => string | undefined;
|
|
6
|
+
export default fn;
|