@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.
- package/README.md +12 -10
- package/dist/cli/print-guide.js +2 -2
- package/dist/cli/print-summary.js +3 -2
- package/dist/cli/print-summary.js.map +1 -1
- package/dist/cli/print-usage.js +1 -1
- package/dist/cli/print-usage.js.map +1 -1
- package/dist/cli/run-transforms.js +16 -2
- package/dist/cli/run-transforms.js.map +1 -1
- package/dist/dependencies/v1.js +22 -9
- package/dist/dependencies/v1.js.map +1 -1
- package/dist/transforms/ast-helpers.js +150 -14
- package/dist/transforms/ast-helpers.js.map +1 -1
- package/dist/transforms/todo.js +25 -2
- package/dist/transforms/todo.js.map +1 -1
- package/dist/transforms/v1/column-readonly.js +28 -13
- package/dist/transforms/v1/column-readonly.js.map +1 -1
- package/dist/transforms/v1/column-unsigned-numeric.js +6 -8
- package/dist/transforms/v1/column-unsigned-numeric.js.map +1 -1
- package/dist/transforms/v1/column-width-zerofill.js +2 -1
- package/dist/transforms/v1/column-width-zerofill.js.map +1 -1
- package/dist/transforms/v1/connection-manager.js +82 -0
- package/dist/transforms/v1/connection-manager.js.map +1 -0
- package/dist/transforms/v1/connection-options-reader.js +198 -0
- package/dist/transforms/v1/connection-options-reader.js.map +1 -0
- package/dist/transforms/v1/connection-to-datasource.js +285 -56
- package/dist/transforms/v1/connection-to-datasource.js.map +1 -1
- package/dist/transforms/v1/datasource-mongodb.js +40 -28
- package/dist/transforms/v1/datasource-mongodb.js.map +1 -1
- package/dist/transforms/v1/datasource-mssql.js +1 -3
- package/dist/transforms/v1/datasource-mssql.js.map +1 -1
- package/dist/transforms/v1/datasource-mysql-connector.js +3 -0
- package/dist/transforms/v1/datasource-mysql-connector.js.map +1 -1
- package/dist/transforms/v1/datasource-name.js +2 -0
- package/dist/transforms/v1/datasource-name.js.map +1 -1
- package/dist/transforms/v1/datasource-sap.js +21 -8
- package/dist/transforms/v1/datasource-sap.js.map +1 -1
- package/dist/transforms/v1/datasource-sqlite-options.js +48 -13
- package/dist/transforms/v1/datasource-sqlite-options.js.map +1 -1
- package/dist/transforms/v1/datasource-sqlite-type.js +28 -7
- package/dist/transforms/v1/datasource-sqlite-type.js.map +1 -1
- package/dist/transforms/v1/file-logger.js +182 -0
- package/dist/transforms/v1/file-logger.js.map +1 -0
- package/dist/transforms/v1/find-options-join.js +84 -0
- package/dist/transforms/v1/find-options-join.js.map +1 -0
- package/dist/transforms/v1/find-options-lock-modes.js +26 -21
- package/dist/transforms/v1/find-options-lock-modes.js.map +1 -1
- package/dist/transforms/v1/find-options-string-relations.js +2 -0
- package/dist/transforms/v1/find-options-string-relations.js.map +1 -1
- package/dist/transforms/v1/find-options-string-select.js +2 -0
- package/dist/transforms/v1/find-options-string-select.js.map +1 -1
- package/dist/transforms/v1/global-functions.js +92 -64
- package/dist/transforms/v1/global-functions.js.map +1 -1
- package/dist/transforms/v1/index.js +10 -2
- package/dist/transforms/v1/index.js.map +1 -1
- package/dist/transforms/v1/migrations-get-all.js +25 -9
- package/dist/transforms/v1/migrations-get-all.js.map +1 -1
- package/dist/transforms/v1/mongodb-stats.js +3 -0
- package/dist/transforms/v1/mongodb-stats.js.map +1 -1
- package/dist/transforms/v1/query-builder-native-parameters.js +2 -0
- package/dist/transforms/v1/query-builder-native-parameters.js.map +1 -1
- package/dist/transforms/v1/query-builder-on-conflict.js +2 -1
- package/dist/transforms/v1/query-builder-on-conflict.js.map +1 -1
- package/dist/transforms/v1/query-builder-or-update.js +8 -4
- package/dist/transforms/v1/query-builder-or-update.js.map +1 -1
- package/dist/transforms/v1/query-builder-print-sql.js +3 -0
- package/dist/transforms/v1/query-builder-print-sql.js.map +1 -1
- package/dist/transforms/v1/query-builder-replace-property-names.js +3 -0
- package/dist/transforms/v1/query-builder-replace-property-names.js.map +1 -1
- package/dist/transforms/v1/query-runner-loaded-tables-views.js +1 -5
- package/dist/transforms/v1/query-runner-loaded-tables-views.js.map +1 -1
- package/dist/transforms/v1/relation-count.js +75 -12
- package/dist/transforms/v1/relation-count.js.map +1 -1
- package/dist/transforms/v1/repository-abstract.js +2 -5
- package/dist/transforms/v1/repository-abstract.js.map +1 -1
- package/dist/transforms/v1/repository-exist.js +2 -0
- package/dist/transforms/v1/repository-exist.js.map +1 -1
- package/dist/transforms/v1/repository-find-by-ids.js +0 -3
- package/dist/transforms/v1/repository-find-by-ids.js.map +1 -1
- package/dist/transforms/v1/repository-find-one-by-id.js +3 -0
- package/dist/transforms/v1/repository-find-one-by-id.js.map +1 -1
- package/dist/transforms/v1/use-container.js +5 -3
- package/dist/transforms/v1/use-container.js.map +1 -1
- package/package.json +3 -1
- package/dist/cli/colors.d.ts +0 -7
- package/dist/cli/colors.js +0 -12
- package/dist/cli/colors.js.map +0 -1
- package/dist/cli/error.d.ts +0 -1
- package/dist/cli/error.js +0 -11
- package/dist/cli/error.js.map +0 -1
- package/dist/cli/list-transforms.d.ts +0 -1
- package/dist/cli/parse-args.d.ts +0 -10
- package/dist/cli/print-guide.d.ts +0 -1
- package/dist/cli/print-summary.d.ts +0 -17
- package/dist/cli/print-todos.d.ts +0 -1
- package/dist/cli/print-usage.d.ts +0 -1
- package/dist/cli/run-dependencies.d.ts +0 -6
- package/dist/cli/run-transforms.d.ts +0 -21
- package/dist/cli/run.d.ts +0 -9
- package/dist/dependencies/config.d.ts +0 -24
- package/dist/dependencies/find-package-json.d.ts +0 -5
- package/dist/dependencies/index.d.ts +0 -5
- package/dist/dependencies/upgrade.d.ts +0 -11
- package/dist/dependencies/v1.d.ts +0 -2
- package/dist/index.d.ts +0 -2
- package/dist/lib/colors.d.ts +0 -9
- package/dist/lib/error.d.ts +0 -1
- package/dist/lib/format-time.d.ts +0 -1
- package/dist/lib/highlight.d.ts +0 -1
- package/dist/lib/spinner.d.ts +0 -5
- package/dist/transforms/ast-helpers.d.ts +0 -50
- package/dist/transforms/index.d.ts +0 -7
- package/dist/transforms/resolve.d.ts +0 -1
- package/dist/transforms/scan.d.ts +0 -4
- package/dist/transforms/scan.js +0 -33
- package/dist/transforms/scan.js.map +0 -1
- package/dist/transforms/stats.d.ts +0 -11
- package/dist/transforms/todo.d.ts +0 -2
- package/dist/transforms/transformer.d.ts +0 -8
- package/dist/transforms/v1/column-readonly.d.ts +0 -6
- package/dist/transforms/v1/column-unsigned-numeric.d.ts +0 -6
- package/dist/transforms/v1/column-width-zerofill.d.ts +0 -6
- package/dist/transforms/v1/connection-to-datasource.d.ts +0 -6
- package/dist/transforms/v1/datasource-mongodb.d.ts +0 -7
- package/dist/transforms/v1/datasource-mssql-domain.d.ts +0 -7
- package/dist/transforms/v1/datasource-mssql-domain.js +0 -35
- package/dist/transforms/v1/datasource-mssql-domain.js.map +0 -1
- package/dist/transforms/v1/datasource-mssql.d.ts +0 -7
- package/dist/transforms/v1/datasource-mysql-connector.d.ts +0 -6
- package/dist/transforms/v1/datasource-name.d.ts +0 -6
- package/dist/transforms/v1/datasource-sap.d.ts +0 -6
- package/dist/transforms/v1/datasource-sqlite-options.d.ts +0 -6
- package/dist/transforms/v1/datasource-sqlite-type.d.ts +0 -6
- package/dist/transforms/v1/find-options-lock-modes.d.ts +0 -6
- package/dist/transforms/v1/find-options-string-relations.d.ts +0 -6
- package/dist/transforms/v1/find-options-string-select.d.ts +0 -6
- package/dist/transforms/v1/global-functions.d.ts +0 -7
- package/dist/transforms/v1/index.d.ts +0 -40
- package/dist/transforms/v1/migrations-get-all.d.ts +0 -7
- package/dist/transforms/v1/mongodb-stats.d.ts +0 -7
- package/dist/transforms/v1/mongodb-types.d.ts +0 -6
- package/dist/transforms/v1/query-builder-native-parameters.d.ts +0 -6
- package/dist/transforms/v1/query-builder-on-conflict.d.ts +0 -7
- package/dist/transforms/v1/query-builder-or-update.d.ts +0 -6
- package/dist/transforms/v1/query-builder-print-sql.d.ts +0 -7
- package/dist/transforms/v1/query-builder-replace-property-names.d.ts +0 -7
- package/dist/transforms/v1/query-builder-where-expression.d.ts +0 -6
- package/dist/transforms/v1/query-runner-loaded-tables-views.d.ts +0 -7
- package/dist/transforms/v1/relation-count.d.ts +0 -7
- package/dist/transforms/v1/remove-abstract-repository.d.ts +0 -5
- package/dist/transforms/v1/remove-abstract-repository.js +0 -93
- package/dist/transforms/v1/remove-abstract-repository.js.map +0 -1
- package/dist/transforms/v1/remove-connector-package.d.ts +0 -4
- package/dist/transforms/v1/remove-connector-package.js +0 -19
- package/dist/transforms/v1/remove-connector-package.js.map +0 -1
- package/dist/transforms/v1/remove-datasource-name.d.ts +0 -4
- package/dist/transforms/v1/remove-datasource-name.js +0 -56
- package/dist/transforms/v1/remove-datasource-name.js.map +0 -1
- package/dist/transforms/v1/remove-mongodb-options.d.ts +0 -5
- package/dist/transforms/v1/remove-mongodb-options.js +0 -86
- package/dist/transforms/v1/remove-mongodb-options.js.map +0 -1
- package/dist/transforms/v1/remove-relation-count.d.ts +0 -5
- package/dist/transforms/v1/remove-relation-count.js +0 -49
- package/dist/transforms/v1/remove-relation-count.js.map +0 -1
- package/dist/transforms/v1/remove-replace-property-names.d.ts +0 -5
- package/dist/transforms/v1/remove-replace-property-names.js +0 -35
- package/dist/transforms/v1/remove-replace-property-names.js.map +0 -1
- package/dist/transforms/v1/remove-sap-options.d.ts +0 -4
- package/dist/transforms/v1/remove-sap-options.js +0 -54
- package/dist/transforms/v1/remove-sap-options.js.map +0 -1
- package/dist/transforms/v1/remove-unsigned-numeric.d.ts +0 -4
- package/dist/transforms/v1/remove-unsigned-numeric.js +0 -76
- package/dist/transforms/v1/remove-unsigned-numeric.js.map +0 -1
- package/dist/transforms/v1/remove-use-container.d.ts +0 -5
- package/dist/transforms/v1/remove-use-container.js +0 -63
- package/dist/transforms/v1/remove-use-container.js.map +0 -1
- package/dist/transforms/v1/remove-width-zerofill.d.ts +0 -4
- package/dist/transforms/v1/remove-width-zerofill.js +0 -29
- package/dist/transforms/v1/remove-width-zerofill.js.map +0 -1
- package/dist/transforms/v1/rename-connection-to-datasource.d.ts +0 -4
- package/dist/transforms/v1/rename-connection-to-datasource.js +0 -111
- package/dist/transforms/v1/rename-connection-to-datasource.js.map +0 -1
- package/dist/transforms/v1/rename-exist-to-exists.d.ts +0 -4
- package/dist/transforms/v1/rename-exist-to-exists.js +0 -25
- package/dist/transforms/v1/rename-exist-to-exists.js.map +0 -1
- package/dist/transforms/v1/rename-find-by-ids.d.ts +0 -4
- package/dist/transforms/v1/rename-find-by-ids.js +0 -64
- package/dist/transforms/v1/rename-find-by-ids.js.map +0 -1
- package/dist/transforms/v1/rename-get-all-migrations.d.ts +0 -5
- package/dist/transforms/v1/rename-get-all-migrations.js +0 -32
- package/dist/transforms/v1/rename-get-all-migrations.js.map +0 -1
- package/dist/transforms/v1/rename-loaded-tables-views.d.ts +0 -5
- package/dist/transforms/v1/rename-loaded-tables-views.js +0 -48
- package/dist/transforms/v1/rename-loaded-tables-views.js.map +0 -1
- package/dist/transforms/v1/rename-or-update-overload.d.ts +0 -4
- package/dist/transforms/v1/rename-or-update-overload.js +0 -46
- package/dist/transforms/v1/rename-or-update-overload.js.map +0 -1
- package/dist/transforms/v1/rename-print-sql-to-log-query.d.ts +0 -4
- package/dist/transforms/v1/rename-print-sql-to-log-query.js +0 -25
- package/dist/transforms/v1/rename-print-sql-to-log-query.js.map +0 -1
- package/dist/transforms/v1/replace-global-functions.d.ts +0 -5
- package/dist/transforms/v1/replace-global-functions.js +0 -92
- package/dist/transforms/v1/replace-global-functions.js.map +0 -1
- package/dist/transforms/v1/replace-lock-modes.d.ts +0 -4
- package/dist/transforms/v1/replace-lock-modes.js +0 -75
- package/dist/transforms/v1/replace-lock-modes.js.map +0 -1
- package/dist/transforms/v1/replace-mongodb-stats.d.ts +0 -5
- package/dist/transforms/v1/replace-mongodb-stats.js +0 -54
- package/dist/transforms/v1/replace-mongodb-stats.js.map +0 -1
- package/dist/transforms/v1/replace-mongodb-types.d.ts +0 -4
- package/dist/transforms/v1/replace-mongodb-types.js +0 -72
- package/dist/transforms/v1/replace-mongodb-types.js.map +0 -1
- package/dist/transforms/v1/replace-mssql-domain.d.ts +0 -5
- package/dist/transforms/v1/replace-mssql-domain.js +0 -25
- package/dist/transforms/v1/replace-mssql-domain.js.map +0 -1
- package/dist/transforms/v1/replace-on-conflict.d.ts +0 -5
- package/dist/transforms/v1/replace-on-conflict.js +0 -49
- package/dist/transforms/v1/replace-on-conflict.js.map +0 -1
- package/dist/transforms/v1/replace-readonly-column.d.ts +0 -4
- package/dist/transforms/v1/replace-readonly-column.js +0 -28
- package/dist/transforms/v1/replace-readonly-column.js.map +0 -1
- package/dist/transforms/v1/replace-set-native-parameters.d.ts +0 -4
- package/dist/transforms/v1/replace-set-native-parameters.js +0 -25
- package/dist/transforms/v1/replace-set-native-parameters.js.map +0 -1
- package/dist/transforms/v1/replace-sqlite-options.d.ts +0 -4
- package/dist/transforms/v1/replace-sqlite-options.js +0 -29
- package/dist/transforms/v1/replace-sqlite-options.js.map +0 -1
- package/dist/transforms/v1/replace-sqlite-type.d.ts +0 -4
- package/dist/transforms/v1/replace-sqlite-type.js +0 -22
- package/dist/transforms/v1/replace-sqlite-type.js.map +0 -1
- package/dist/transforms/v1/replace-where-expression-type.d.ts +0 -4
- package/dist/transforms/v1/replace-where-expression-type.js +0 -41
- package/dist/transforms/v1/replace-where-expression-type.js.map +0 -1
- package/dist/transforms/v1/repository-abstract.d.ts +0 -7
- package/dist/transforms/v1/repository-exist.d.ts +0 -6
- package/dist/transforms/v1/repository-find-by-ids.d.ts +0 -6
- package/dist/transforms/v1/repository-find-one-by-id.d.ts +0 -6
- package/dist/transforms/v1/upgrade-dependencies.d.ts +0 -15
- package/dist/transforms/v1/upgrade-dependencies.js +0 -163
- package/dist/transforms/v1/upgrade-dependencies.js.map +0 -1
- package/dist/transforms/v1/use-container.d.ts +0 -7
package/README.md
CHANGED
|
@@ -26,14 +26,16 @@ npx @typeorm/codemod v1 --list
|
|
|
26
26
|
|
|
27
27
|
## Options
|
|
28
28
|
|
|
29
|
-
| Option | Short | Description
|
|
30
|
-
| -------------------- | ----- |
|
|
31
|
-
| `--dry` | `-d` | Dry run (show changes without writing)
|
|
32
|
-
| `--help` | `-h` | Show help
|
|
33
|
-
| `--ignore <pattern>` | `-i` |
|
|
34
|
-
| `--list` | `-l` | List available transforms
|
|
35
|
-
| `--transform <name>` | `-t` | Run a specific transform only
|
|
36
|
-
| `--workers <num>` | `-w` | Number of worker processes (default: CPU cores - 1)
|
|
29
|
+
| Option | Short | Description |
|
|
30
|
+
| -------------------- | ----- | --------------------------------------------------------------------- |
|
|
31
|
+
| `--dry` | `-d` | Dry run (show changes without writing) |
|
|
32
|
+
| `--help` | `-h` | Show help |
|
|
33
|
+
| `--ignore <pattern>` | `-i` | Additional glob pattern to exclude (repeatable; merged with defaults) |
|
|
34
|
+
| `--list` | `-l` | List available transforms |
|
|
35
|
+
| `--transform <name>` | `-t` | Run a specific transform only |
|
|
36
|
+
| `--workers <num>` | `-w` | Number of worker processes (default: CPU cores - 1) |
|
|
37
|
+
|
|
38
|
+
`**/*.d.ts` is always excluded — ambient type declarations describe the shapes consumers rely on, and rewriting identifiers inside them would silently corrupt published types. User-provided `--ignore` patterns are merged on top of this default.
|
|
37
39
|
|
|
38
40
|
## After running
|
|
39
41
|
|
|
@@ -54,6 +56,6 @@ Transforms that rename properties or methods (e.g. `.connection` to `.dataSource
|
|
|
54
56
|
|
|
55
57
|
## Documentation
|
|
56
58
|
|
|
57
|
-
See the full
|
|
59
|
+
See the full upgrading guide for details on all breaking changes:
|
|
58
60
|
|
|
59
|
-
- [v1](https://typeorm.io/docs/
|
|
61
|
+
- [v1](https://typeorm.io/docs/releases/1.0/upgrading-from-0.3)
|
package/dist/cli/print-guide.js
CHANGED
|
@@ -6,9 +6,9 @@ const highlight_1 = require("../lib/highlight");
|
|
|
6
6
|
const transforms_1 = require("../transforms");
|
|
7
7
|
const printGuide = (version) => {
|
|
8
8
|
console.log((0, highlight_1.highlight)(`\n${colors_1.colors.blue("Tip:")} run your project's formatter (e.g. \`prettier\`, \`eslint --fix\`) to clean up any style differences introduced by the codemod.`));
|
|
9
|
-
const guide = transforms_1.versions[version]?.
|
|
9
|
+
const guide = transforms_1.versions[version]?.upgradingGuide;
|
|
10
10
|
if (guide) {
|
|
11
|
-
console.log(`\nSee the full
|
|
11
|
+
console.log(`\nSee the full upgrading guide for details: ${colors_1.colors.blue(guide)}`);
|
|
12
12
|
}
|
|
13
13
|
};
|
|
14
14
|
exports.printGuide = printGuide;
|
|
@@ -36,8 +36,9 @@ const groupLines = (lines) => {
|
|
|
36
36
|
};
|
|
37
37
|
const printGrouped = (lines, indent, formatter = highlight_1.highlight) => {
|
|
38
38
|
for (const [line, count] of groupLines(lines)) {
|
|
39
|
-
const
|
|
40
|
-
|
|
39
|
+
const timesLabel = `(${count} times)`;
|
|
40
|
+
const countSuffix = count > 1 ? ` ${colors_1.colors.dim(timesLabel)}` : "";
|
|
41
|
+
console.log(`${indent}${formatter(line)}${countSuffix}`);
|
|
41
42
|
}
|
|
42
43
|
};
|
|
43
44
|
const printDependencyChanges = (changes, warnings, errors) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"print-summary.js","sourceRoot":"","sources":["../../src/cli/print-summary.ts"],"names":[],"mappings":";;;AAAA,0CAAsC;AACtC,oDAA+C;AAC/C,gDAA4C;AAC5C,+CAA0C;AAgB1C,MAAM,eAAe,GAAG,CAAC,IAAiB,EAAQ,EAAE;IAChD,OAAO,CAAC,GAAG,CAAC,KAAK,eAAM,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,CAAA;IAC9C,OAAO,CAAC,GAAG,CACP,wBAAwB,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,QAAQ,EAAE,CAC7E,CAAA;IACD,OAAO,CAAC,GAAG,CAAC,wBAAwB,IAAI,CAAC,EAAE,EAAE,CAAC,CAAA;IAC9C,OAAO,CAAC,GAAG,CAAC,wBAAwB,IAA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,CAAA;IACL,CAAC;AACL,CAAC,CAAA;AAlBY,QAAA,YAAY,gBAkBxB"}
|
package/dist/cli/print-usage.js
CHANGED
|
@@ -15,7 +15,7 @@ ${versionList}
|
|
|
15
15
|
${colors_1.colors.bold("Options:")}
|
|
16
16
|
${colors_1.colors.blue("--dry, -d")} Dry run ${colors_1.colors.dim("(show changes without writing)")}
|
|
17
17
|
${colors_1.colors.blue("--help, -h")} Show this help
|
|
18
|
-
${colors_1.colors.blue("--ignore, -i")} <pattern>
|
|
18
|
+
${colors_1.colors.blue("--ignore, -i")} <pattern> Additional glob pattern to exclude ${colors_1.colors.dim("(repeatable; *.d.ts is always excluded)")}
|
|
19
19
|
${colors_1.colors.blue("--list, -l")} List available transforms
|
|
20
20
|
${colors_1.colors.blue("--transform, -t")} <name> Run a specific transform only
|
|
21
21
|
${colors_1.colors.blue("--workers, -w")} <num> Number of worker processes ${colors_1.colors.dim("(default: CPU cores - 1)")}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"print-usage.js","sourceRoot":"","sources":["../../src/cli/print-usage.ts"],"names":[],"mappings":";;;AAAA,0CAAsC;AACtC,8CAAwC;AAEjC,MAAM,UAAU,GAAG,GAAS,EAAE;IACjC,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC,qBAAQ,CAAC;SACvC,GAAG,CACA,CAAC,CAAC,IAAI,EAAE,EAAE,WAAW,EAAE,CAAC,EAAE,EAAE,CACxB,KAAK,eAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,WAAW,EAAE,CACvD;SACA,IAAI,CAAC,IAAI,CAAC,CAAA;IAEf,OAAO,CAAC,GAAG,CAAC,GAAG,eAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,qBAAqB,eAAM,CAAC,IAAI,CAAC,WAAW,CAAC;;EAEnF,eAAM,CAAC,IAAI,CAAC,WAAW,CAAC;EACxB,WAAW;;EAEX,eAAM,CAAC,IA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,CAAC;;EAE7G,eAAM,CAAC,IAAI,CAAC,WAAW,CAAC;IACtB,eAAM,CAAC,GAAG,CAAC,0BAA0B,CAAC;IACtC,eAAM,CAAC,GAAG,CAAC,gCAAgC,CAAC;IAC5C,eAAM,CAAC,GAAG,CAAC,mDAAmD,CAAC;IAC/D,eAAM,CAAC,GAAG,CAAC,+DAA+D,CAAC;IAC3E,eAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,EAAE,CAAC,CAAA;AAC/C,CAAC,CAAA;AA3BY,QAAA,UAAU,cA2BtB"}
|
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.runTransforms = void 0;
|
|
3
|
+
exports.runTransforms = exports.buildIgnorePatterns = exports.DEFAULT_IGNORE_PATTERNS = void 0;
|
|
4
4
|
const Runner_1 = require("jscodeshift/src/Runner");
|
|
5
5
|
const colors_1 = require("../lib/colors");
|
|
6
6
|
const spinner_1 = require("../lib/spinner");
|
|
7
7
|
const format_time_1 = require("../lib/format-time");
|
|
8
8
|
const stats_1 = require("../transforms/stats");
|
|
9
|
+
// Patterns that should never be processed by any codemod transform.
|
|
10
|
+
// Ambient declarations (`.d.ts`) describe types consumers rely on — renaming
|
|
11
|
+
// identifiers inside them would silently corrupt published types.
|
|
12
|
+
exports.DEFAULT_IGNORE_PATTERNS = ["**/*.d.ts"];
|
|
13
|
+
/**
|
|
14
|
+
* Merges user-supplied `--ignore` patterns with the defaults. Defaults are
|
|
15
|
+
* listed first so they apply alongside any user additions.
|
|
16
|
+
*/
|
|
17
|
+
const buildIgnorePatterns = (userPatterns) => [
|
|
18
|
+
...exports.DEFAULT_IGNORE_PATTERNS,
|
|
19
|
+
...(userPatterns ?? []),
|
|
20
|
+
];
|
|
21
|
+
exports.buildIgnorePatterns = buildIgnorePatterns;
|
|
9
22
|
const runTransforms = async (options) => {
|
|
10
23
|
const { transforms, paths, dry, workers, ignore } = options;
|
|
11
24
|
const allTodos = new Map();
|
|
@@ -66,6 +79,7 @@ const runTransforms = async (options) => {
|
|
|
66
79
|
spinner.update(progressText);
|
|
67
80
|
return true;
|
|
68
81
|
});
|
|
82
|
+
const ignorePattern = (0, exports.buildIgnorePatterns)(ignore);
|
|
69
83
|
let result;
|
|
70
84
|
try {
|
|
71
85
|
result = await (0, Runner_1.run)(transform, paths, {
|
|
@@ -74,8 +88,8 @@ const runTransforms = async (options) => {
|
|
|
74
88
|
verbose: 2,
|
|
75
89
|
extensions: "ts,tsx,js,jsx",
|
|
76
90
|
parser: "tsx",
|
|
91
|
+
ignorePattern,
|
|
77
92
|
...(workers !== undefined && { cpus: workers }),
|
|
78
|
-
...(ignore !== undefined && { ignorePattern: ignore }),
|
|
79
93
|
});
|
|
80
94
|
}
|
|
81
95
|
catch (err) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-transforms.js","sourceRoot":"","sources":["../../src/cli/run-transforms.ts"],"names":[],"mappings":";;;AAAA,mDAA2D;AAC3D,0CAAsC;AACtC,4CAA8C;AAC9C,oDAA+C;AAC/C,+CAA2C;
|
|
1
|
+
{"version":3,"file":"run-transforms.js","sourceRoot":"","sources":["../../src/cli/run-transforms.ts"],"names":[],"mappings":";;;AAAA,mDAA2D;AAC3D,0CAAsC;AACtC,4CAA8C;AAC9C,oDAA+C;AAC/C,+CAA2C;AAqB3C,oEAAoE;AACpE,6EAA6E;AAC7E,kEAAkE;AACrD,QAAA,uBAAuB,GAAG,CAAC,WAAW,CAAC,CAAA;AAEpD;;;GAGG;AACI,MAAM,mBAAmB,GAAG,CAAC,YAAuB,EAAY,EAAE,CAAC;IACtE,GAAG,+BAAuB;IAC1B,GAAG,CAAC,YAAY,IAAI,EAAE,CAAC;CAC1B,CAAA;AAHY,QAAA,mBAAmB,uBAG/B;AAEM,MAAM,aAAa,GAAG,KAAK,EAC9B,OAA6B,EACL,EAAE;IAC1B,MAAM,EAAE,UAAU,EAAE,KAAK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AC3B,KAAK,EAAE,QAAQ;QACf,OAAO,EAAE,UAAU;KACtB,CAAA;AACL,CAAC,CAAA;AAlIY,QAAA,aAAa,iBAkIzB"}
|
package/dist/dependencies/v1.js
CHANGED
|
@@ -3,29 +3,42 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.config = void 0;
|
|
4
4
|
exports.config = {
|
|
5
5
|
replacements: {
|
|
6
|
-
mysql: { replacement: "mysql2", version: "^3.
|
|
7
|
-
sqlite3: { replacement: "better-sqlite3", version: "^12.
|
|
6
|
+
mysql: { replacement: "mysql2", version: "^3.22.0" },
|
|
7
|
+
sqlite3: { replacement: "better-sqlite3", version: "^12.9.0" },
|
|
8
8
|
},
|
|
9
9
|
upgrades: {
|
|
10
10
|
"@google-cloud/spanner": { minVersion: "^8.0.0", version: "^8.6.0" },
|
|
11
|
-
"
|
|
11
|
+
"@nestjs/typeorm": { minVersion: "^11.0.1", version: "^11.0.1" },
|
|
12
|
+
"better-sqlite3": { minVersion: "^12.0.0", version: "^12.9.0" },
|
|
12
13
|
ioredis: { minVersion: "^5.0.4", version: "^5.10.1" },
|
|
13
14
|
mongodb: { minVersion: "^7.0.0", version: "^7.1.1" },
|
|
14
|
-
mssql: { minVersion: "^12.0.0", version: "^12.
|
|
15
|
-
mysql2: { minVersion: "^3.15.3", version: "^3.
|
|
16
|
-
redis: { minVersion: "^5.0.0", version: "^5.
|
|
17
|
-
typeorm: { minVersion: "^1.0.0
|
|
15
|
+
mssql: { minVersion: "^12.0.0", version: "^12.3.0" },
|
|
16
|
+
mysql2: { minVersion: "^3.15.3", version: "^3.22.0" },
|
|
17
|
+
redis: { minVersion: "^5.0.0", version: "^5.12.1" },
|
|
18
|
+
typeorm: { minVersion: "^1.0.0", version: "^1.0.0" },
|
|
18
19
|
"typeorm-aurora-data-api-driver": {
|
|
19
20
|
minVersion: "^3.0.0",
|
|
20
21
|
version: "^3.0.2",
|
|
21
22
|
},
|
|
22
23
|
},
|
|
23
24
|
incompatible: {
|
|
24
|
-
"typeorm-
|
|
25
|
-
"typeorm
|
|
25
|
+
"@next-auth/typeorm-legacy-adapter": "`@next-auth/typeorm-legacy-adapter` is incompatible with TypeORM v1 — it uses the removed global `getManager()`. Migrate to `@auth/typeorm-adapter` instead.",
|
|
26
|
+
"@opentelemetry/instrumentation-typeorm": "`@opentelemetry/instrumentation-typeorm` is incompatible with TypeORM v1 — it patches `Repository.findByIds` which was removed. Check for an updated version that supports TypeORM v1.",
|
|
27
|
+
"mock-typeorm": "`mock-typeorm` is incompatible with TypeORM v1 — it mocks `getCustomRepository`, `findByIds`, `findOneById`, `printSql`, and `.connection`, all of which were removed or renamed.",
|
|
28
|
+
"opentelemetry-instrumentation-typeorm": "`opentelemetry-instrumentation-typeorm` is incompatible with TypeORM v1 — it patches `Repository.findByIds` which was removed. Use `@opentelemetry/instrumentation-typeorm` once it adds v1 support.",
|
|
29
|
+
"pg-mem": "`pg-mem` is incompatible with TypeORM v1 — it uses the removed `getConnectionManager()` API to create TypeORM connections.",
|
|
30
|
+
"typeorm-naming-strategies": "`typeorm-naming-strategies` is incompatible with TypeORM v1 — it imports `snakeCase` from the internal path `typeorm/util/StringUtils` (not part of the public API) and overrides removed interface methods (`classTableInheritanceParentColumnName`, `eagerJoinRelationAlias`). The package is unmaintained (last published 2022). Extend `DefaultNamingStrategy` and override `columnName`/`tableName`/etc. with snake_case logic, or implement `NamingStrategyInterface` directly.",
|
|
31
|
+
"typeorm-polymorphic": "`typeorm-polymorphic` is incompatible with TypeORM v1 — it uses the removed `getCustomRepository()` API.",
|
|
32
|
+
"typeorm-routing-controllers-extensions": "`typeorm-routing-controllers-extensions` is incompatible with TypeORM v1 — the IoC container system (`useContainer`) was removed. See upgrading guide.",
|
|
33
|
+
"typeorm-seeding": "`typeorm-seeding` is incompatible with TypeORM v1 — this package uses the removed `Connection` API. Migrate to a maintained alternative or inline seeding via custom scripts.",
|
|
34
|
+
"typeorm-typedi-extensions": "`typeorm-typedi-extensions` is incompatible with TypeORM v1 — the IoC container system (`useContainer`) was removed. See upgrading guide.",
|
|
26
35
|
},
|
|
27
36
|
warnings: {
|
|
28
37
|
dotenv: "`dotenv` detected — TypeORM no longer auto-loads `.env` files. Make sure your database configuration is defined explicitly using `DataSource`.",
|
|
38
|
+
"nestjs-typeorm-paginate": "`nestjs-typeorm-paginate` detected — its peer dependency `^0.3.0` excludes TypeORM v1. Check for an updated version that supports v1.",
|
|
39
|
+
"typeorm-encrypted": "`typeorm-encrypted` detected — its peer dependency `^0.3.7` excludes TypeORM v1. Check for an updated version.",
|
|
40
|
+
"typeorm-fixtures-cli": "`typeorm-fixtures-cli` detected — its peer dependency `^0.3.0` excludes TypeORM v1. Check for an updated version.",
|
|
41
|
+
"typeorm-transactional": "`typeorm-transactional` detected — it uses the deprecated `.connection` property (renamed to `.dataSource`). The deprecated getter still works in v1 but may be removed in a future version. Check for an updated release.",
|
|
29
42
|
},
|
|
30
43
|
minNodeVersion: "20.0.0",
|
|
31
44
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"v1.js","sourceRoot":"","sources":["../../src/dependencies/v1.ts"],"names":[],"mappings":";;;AAEa,QAAA,MAAM,GAAqB;IACpC,YAAY,EAAE;QACV,KAAK,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE;QACpD,OAAO,EAAE,EAAE,WAAW,EAAE,gBAAgB,EAAE,OAAO,EAAE,SAAS,EAAE;KACjE;IAED,QAAQ,EAAE;QACN,uBAAuB,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE;QACpE,gBAAgB,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE;QAC/D,OAAO,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE;QACrD,OAAO,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,E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gC,EAAE;YAC9B,UAAU,EAAE,QAAQ;YACpB,OAAO,EAAE,QAAQ;SACpB;KACJ;IAED,YAAY,EAAE;QACV,mCAAmC,EAC/B,8JAA8J;QAClK,wCAAwC,EACpC,wLAAwL;QAC5L,cAAc,EACV,mLAAmL;QACvL,uCAAuC,EACnC,sMAAsM;QAC1M,QAAQ,EACJ,4HAA4H;QAChI,2BAA2B,EACvB,udAAud;QAC3d,qBAAqB,EACjB,0GAA0G;QAC9G,wCAAwC,EACpC,wJAAwJ;QAC5J,iBAAiB,EACb,+KAA+K;QACnL,2BAA2B,EACvB,2IAA2I;KAClJ;IAED,QAAQ,EAAE;QACN,MAAM,EAAE,gJAAgJ;QACxJ,yBAAyB,EACrB,uIAAuI;QAC3I,mBAAmB,EACf,gHAAgH;QACpH,sBAAsB,EAClB,mHAAmH;QACvH,uBAAuB,EACnB,4NAA4N;KACnO;IAED,cAAc,EAAE,QAAQ;CAC3B,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.renameMemberMethod = exports.removeImportSpecifiers = exports.removeObjectProperties = exports.forEachDecoratorObjectArg = exports.forEachIdentifierParam = exports.fileImportsFrom = exports.isIdentifier = exports.setStringValue = exports.getStringValue = void 0;
|
|
3
|
+
exports.renameMemberMethod = exports.removeImportSpecifiers = exports.removeObjectProperties = exports.forEachDecoratorObjectArg = exports.expandLocalNamesForImports = exports.TYPEORM_COLUMN_DECORATORS = exports.forEachIdentifierParam = exports.getLocalNamesForImport = exports.fileImportsFrom = exports.isIdentifier = exports.setStringValue = exports.getStringValue = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Extracts a string value from a StringLiteral or Literal node.
|
|
6
6
|
* Returns null if the node is not a string literal.
|
|
@@ -30,14 +30,108 @@ exports.setStringValue = setStringValue;
|
|
|
30
30
|
const isIdentifier = (node) => node.type === "Identifier";
|
|
31
31
|
exports.isIdentifier = isIdentifier;
|
|
32
32
|
/**
|
|
33
|
-
* Checks whether the file contains an import from the given module.
|
|
33
|
+
* Checks whether the file contains an import from the given module. Matches
|
|
34
|
+
* both the exact module name (`"typeorm"`) and any sub-path (`"typeorm/..."`),
|
|
35
|
+
* and recognizes ESM `import`, TypeScript `import = require(...)`, and
|
|
36
|
+
* CommonJS `require(...)` forms so that `.js`/`.jsx` callers still pass the
|
|
37
|
+
* scope guard.
|
|
34
38
|
*/
|
|
35
39
|
const fileImportsFrom = (root, j, moduleName) => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
40
|
+
const prefix = `${moduleName}/`;
|
|
41
|
+
const matchesModule = (source) => typeof source === "string" &&
|
|
42
|
+
(source === moduleName || source.startsWith(prefix));
|
|
43
|
+
// ESM: import ... from "typeorm[/subpath]"
|
|
44
|
+
if (root
|
|
45
|
+
.find(j.ImportDeclaration)
|
|
46
|
+
.some((path) => matchesModule(path.node.source.value))) {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
// TS: import ... = require("typeorm[/subpath]")
|
|
50
|
+
if (root.find(j.TSImportEqualsDeclaration).some((path) => {
|
|
51
|
+
const ref = path.node.moduleReference;
|
|
52
|
+
return (ref.type === "TSExternalModuleReference" &&
|
|
53
|
+
matchesModule((0, exports.getStringValue)(ref.expression)));
|
|
54
|
+
})) {
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
// CommonJS: require("typeorm[/subpath]")
|
|
58
|
+
return root
|
|
59
|
+
.find(j.CallExpression, {
|
|
60
|
+
callee: { type: "Identifier", name: "require" },
|
|
61
|
+
})
|
|
62
|
+
.some((path) => {
|
|
63
|
+
const [arg] = path.node.arguments;
|
|
64
|
+
return arg !== undefined && matchesModule((0, exports.getStringValue)(arg));
|
|
65
|
+
});
|
|
39
66
|
};
|
|
40
67
|
exports.fileImportsFrom = fileImportsFrom;
|
|
68
|
+
/**
|
|
69
|
+
* Returns the set of local identifiers bound to a given named export.
|
|
70
|
+
* Handles ESM direct/aliased imports and CommonJS destructured requires:
|
|
71
|
+
*
|
|
72
|
+
* import { RelationCount } from "typeorm" → { "RelationCount" }
|
|
73
|
+
* import { RelationCount as RC } from "typeorm" → { "RC" }
|
|
74
|
+
* const { RelationCount } = require("typeorm") → { "RelationCount" }
|
|
75
|
+
* const { RelationCount: RC } = require("typeorm")→ { "RC" }
|
|
76
|
+
*/
|
|
77
|
+
const getLocalNamesForImport = (root, j, moduleName, importedName) => {
|
|
78
|
+
const localNames = new Set();
|
|
79
|
+
// ESM: `import { X [as Y] } from "moduleName"`
|
|
80
|
+
root.find(j.ImportDeclaration, {
|
|
81
|
+
source: { value: moduleName },
|
|
82
|
+
}).forEach((importPath) => {
|
|
83
|
+
for (const spec of importPath.node.specifiers ?? []) {
|
|
84
|
+
if (spec.type !== "ImportSpecifier" ||
|
|
85
|
+
spec.imported.type !== "Identifier" ||
|
|
86
|
+
spec.imported.name !== importedName) {
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
const local = spec.local ?? spec.imported;
|
|
90
|
+
if (local.type === "Identifier") {
|
|
91
|
+
localNames.add(local.name);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
// CommonJS: `const { X [: Y] } = require("moduleName")`
|
|
96
|
+
root.find(j.CallExpression, {
|
|
97
|
+
callee: { type: "Identifier", name: "require" },
|
|
98
|
+
}).forEach((callPath) => {
|
|
99
|
+
const [arg] = callPath.node.arguments;
|
|
100
|
+
if (!arg || (0, exports.getStringValue)(arg) !== moduleName)
|
|
101
|
+
return;
|
|
102
|
+
const parent = callPath.parent.node;
|
|
103
|
+
if (parent.type !== "VariableDeclarator")
|
|
104
|
+
return;
|
|
105
|
+
const id = parent.id;
|
|
106
|
+
if (id.type !== "ObjectPattern")
|
|
107
|
+
return;
|
|
108
|
+
for (const prop of id.properties) {
|
|
109
|
+
if (prop.type !== "Property" && prop.type !== "ObjectProperty") {
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
if (prop.key.type !== "Identifier" ||
|
|
113
|
+
prop.key.name !== importedName) {
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
// Extract the binding name from each destructuring variant:
|
|
117
|
+
// { X } → "X" (Identifier)
|
|
118
|
+
// { X: Y } → "Y" (Identifier alias)
|
|
119
|
+
// { X = fallback } → "X" (AssignmentPattern, shorthand)
|
|
120
|
+
// { X: Y = fallback }→ "Y" (AssignmentPattern, aliased)
|
|
121
|
+
let localName = prop.key.name;
|
|
122
|
+
if (prop.value.type === "Identifier") {
|
|
123
|
+
localName = prop.value.name;
|
|
124
|
+
}
|
|
125
|
+
else if (prop.value.type === "AssignmentPattern" &&
|
|
126
|
+
prop.value.left.type === "Identifier") {
|
|
127
|
+
localName = prop.value.left.name;
|
|
128
|
+
}
|
|
129
|
+
localNames.add(localName);
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
return localNames;
|
|
133
|
+
};
|
|
134
|
+
exports.getLocalNamesForImport = getLocalNamesForImport;
|
|
41
135
|
/**
|
|
42
136
|
* Calls `callback` for each Identifier parameter found in function-like
|
|
43
137
|
* nodes (functions, methods, arrows) and TSParameterProperty nodes.
|
|
@@ -57,22 +151,62 @@ const forEachIdentifierParam = (root, j, callback) => {
|
|
|
57
151
|
});
|
|
58
152
|
};
|
|
59
153
|
exports.forEachIdentifierParam = forEachIdentifierParam;
|
|
154
|
+
/**
|
|
155
|
+
* TypeORM column-family decorator names. Exposed so decorator-scoped
|
|
156
|
+
* transforms can narrow their match set and skip unrelated decorators like
|
|
157
|
+
* Angular's `@Input` or class-validator's `@IsDefined` without relying on a
|
|
158
|
+
* file-level `fileImportsFrom` guard.
|
|
159
|
+
*/
|
|
160
|
+
exports.TYPEORM_COLUMN_DECORATORS = new Set([
|
|
161
|
+
"Column",
|
|
162
|
+
"PrimaryColumn",
|
|
163
|
+
"PrimaryGeneratedColumn",
|
|
164
|
+
"VersionColumn",
|
|
165
|
+
"CreateDateColumn",
|
|
166
|
+
"UpdateDateColumn",
|
|
167
|
+
"DeleteDateColumn",
|
|
168
|
+
"ObjectIdColumn",
|
|
169
|
+
"ViewColumn",
|
|
170
|
+
]);
|
|
171
|
+
/**
|
|
172
|
+
* Expands a set of exported names into the local bindings each one has in
|
|
173
|
+
* the file — covers ESM aliases (`import { Column as C }`) and CJS aliases
|
|
174
|
+
* (`const { Column: C } = require(...)`). Returns a union set suitable for
|
|
175
|
+
* alias-aware identifier matching.
|
|
176
|
+
*/
|
|
177
|
+
const expandLocalNamesForImports = (root, j, moduleName, importedNames) => {
|
|
178
|
+
const expanded = new Set();
|
|
179
|
+
for (const name of importedNames) {
|
|
180
|
+
for (const local of (0, exports.getLocalNamesForImport)(root, j, moduleName, name)) {
|
|
181
|
+
expanded.add(local);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return expanded;
|
|
185
|
+
};
|
|
186
|
+
exports.expandLocalNamesForImports = expandLocalNamesForImports;
|
|
60
187
|
/**
|
|
61
188
|
* Traverses ClassProperty decorators and calls `callback` for each
|
|
62
189
|
* ObjectExpression argument found in decorator call expressions.
|
|
63
190
|
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
191
|
+
* Pass `decoratorNames` to restrict the traversal to a known set of callees
|
|
192
|
+
* (e.g. TypeORM's column decorators). Without it, every decorator-with-object
|
|
193
|
+
* on every class property is visited.
|
|
66
194
|
*/
|
|
67
|
-
const forEachDecoratorObjectArg = (root, j, callback) => {
|
|
195
|
+
const forEachDecoratorObjectArg = (root, j, callback, decoratorNames) => {
|
|
68
196
|
root.find(j.ClassProperty).forEach((path) => {
|
|
69
|
-
// ast-types omits `decorators` from ClassProperty — extend it
|
|
70
197
|
const node = path.node;
|
|
71
198
|
if (!node.decorators)
|
|
72
199
|
return;
|
|
73
200
|
for (const decorator of node.decorators) {
|
|
74
201
|
if (decorator.expression.type !== "CallExpression")
|
|
75
202
|
continue;
|
|
203
|
+
if (decoratorNames) {
|
|
204
|
+
const callee = decorator.expression.callee;
|
|
205
|
+
if (callee.type !== "Identifier" ||
|
|
206
|
+
!decoratorNames.has(callee.name)) {
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
76
210
|
for (const arg of decorator.expression.arguments) {
|
|
77
211
|
if (arg.type !== "ObjectExpression")
|
|
78
212
|
continue;
|
|
@@ -84,17 +218,19 @@ const forEachDecoratorObjectArg = (root, j, callback) => {
|
|
|
84
218
|
exports.forEachDecoratorObjectArg = forEachDecoratorObjectArg;
|
|
85
219
|
/**
|
|
86
220
|
* Removes properties matching the given key names from an ObjectExpression.
|
|
221
|
+
* Matches both identifier keys (`name`) and string-literal keys (`"name"`).
|
|
87
222
|
* Returns true if any properties were removed.
|
|
88
223
|
*/
|
|
89
224
|
const removeObjectProperties = (obj, propertyNames) => {
|
|
90
225
|
const original = obj.properties.length;
|
|
91
226
|
obj.properties = obj.properties.filter((prop) => {
|
|
92
|
-
if (
|
|
93
|
-
|
|
94
|
-
propertyNames.has(prop.key.name)) {
|
|
95
|
-
return false;
|
|
227
|
+
if (prop.type !== "Property" && prop.type !== "ObjectProperty") {
|
|
228
|
+
return true;
|
|
96
229
|
}
|
|
97
|
-
|
|
230
|
+
const keyName = prop.key.type === "Identifier"
|
|
231
|
+
? prop.key.name
|
|
232
|
+
: (0, exports.getStringValue)(prop.key);
|
|
233
|
+
return keyName === null ? true : !propertyNames.has(keyName);
|
|
98
234
|
});
|
|
99
235
|
return obj.properties.length !== original;
|
|
100
236
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast-helpers.js","sourceRoot":"","sources":["../../src/transforms/ast-helpers.ts"],"names":[],"mappings":";;;AAWA;;;GAGG;AACI,MAAM,cAAc,GAAG,CAAC,IAAa,EAAiB,EAAE;IAC3D,IAAI,IAAI,CAAC,IAAI,KAAK,eAAe,EAAE,CAAC;QAChC,OAAO,IAAI,CAAC,KAAK,CAAA;IACrB,CAAC;IAED,IAAI,IAAI,CAAC,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AAS,CAAA;QAC1C,CAAC;IACL,CAAC,CAAC,CAAA;IAEF,OAAO,OAAO,CAAA;AAClB,CAAC,CAAA;AA/BY,QAAA,sBAAsB,0BA+BlC;AAED;;;;GAIG;AACI,MAAM,kBAAkB,GAAG,CAC9B,IAAgB,EAChB,CAAc,EACd,OAAe,EACf,OAAe,EACR,EAAE;IACT,IAAI,OAAO,GAAG,KAAK,CAAA;IAEnB,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc,EAAE;QACxB,MAAM,EAAE;YACJ,IAAI,EAAE,kBAAkB;YACxB,QAAQ,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;SAC9B;KACJ,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAChB,IACI,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,kBAAkB;YAC5C,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,KAAK,YAAY,EACjD,CAAC;YACC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,GAAG,OAAO,CAAA;YACxC,OAAO,GAAG,IAAI,CAAA;QAClB,CAAC;IACL,CAAC,CAAC,CAAA;IAEF,OAAO,OAAO,CAAA;AAClB,CAAC,CAAA;AAxBY,QAAA,kBAAkB,sBAwB9B"}
|
package/dist/transforms/todo.js
CHANGED
|
@@ -1,10 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.addTodoComment = void 0;
|
|
3
|
+
exports.hasTodoComment = exports.addTodoComment = void 0;
|
|
4
|
+
const formatTodo = (message) => ` TODO(typeorm-v1): ${message}`;
|
|
5
|
+
// Prettier treats a leading `// prettier-ignore` line-comment as a directive
|
|
6
|
+
// for the statement immediately following it. Appending our comment *after*
|
|
7
|
+
// that directive places it between `prettier-ignore` and its target and
|
|
8
|
+
// silently disables the directive, so detect the pattern and insert above.
|
|
9
|
+
const isPrettierIgnore = (comment) => comment.type === "CommentLine" && comment.value.trim() === "prettier-ignore";
|
|
4
10
|
const addTodoComment = (node, message, j) => {
|
|
5
11
|
if (!node.comments)
|
|
6
12
|
node.comments = [];
|
|
7
|
-
|
|
13
|
+
const todo = j.commentLine(formatTodo(message));
|
|
14
|
+
const firstDirectiveIndex = node.comments.findIndex(isPrettierIgnore);
|
|
15
|
+
if (firstDirectiveIndex === -1) {
|
|
16
|
+
node.comments.push(todo);
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
node.comments.splice(firstDirectiveIndex, 0, todo);
|
|
20
|
+
}
|
|
8
21
|
};
|
|
9
22
|
exports.addTodoComment = addTodoComment;
|
|
23
|
+
/**
|
|
24
|
+
* Returns true when `node` already carries the `message` as a line-comment.
|
|
25
|
+
* Used to keep transforms idempotent — running the codemod twice must not
|
|
26
|
+
* stack duplicates.
|
|
27
|
+
*/
|
|
28
|
+
const hasTodoComment = (node, message) => {
|
|
29
|
+
const expected = formatTodo(message);
|
|
30
|
+
return (node.comments ?? []).some((c) => c.value === expected);
|
|
31
|
+
};
|
|
32
|
+
exports.hasTodoComment = hasTodoComment;
|
|
10
33
|
//# sourceMappingURL=todo.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"todo.js","sourceRoot":"","sources":["../../src/transforms/todo.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"todo.js","sourceRoot":"","sources":["../../src/transforms/todo.ts"],"names":[],"mappings":";;;AAEA,MAAM,UAAU,GAAG,CAAC,OAAe,EAAU,EAAE,CAAC,sBAAsB,OAAO,EAAE,CAAA;AAE/E,6EAA6E;AAC7E,4EAA4E;AAC5E,wEAAwE;AACxE,2EAA2E;AAC3E,MAAM,gBAAgB,GAAG,CAAC,OAAwC,EAAW,EAAE,CAC3E,OAAO,CAAC,IAAI,KAAK,aAAa,IAAI,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,iBAAiB,CAAA;AAEzE,MAAM,cAAc,GAAG,CAC1B,IAAU,EACV,OAAe,EACf,CAAc,EACV,EAAE;IACN,IAAI,CAAC,IAAI,CAAC,QAAQ;QAAE,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAA;IACtC,MAAM,IAAI,GAAG,CAAC,CAAC,WAAW,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAA;IAC/C,MAAM,mBAAmB,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAA;IACrE,IAAI,mBAAmB,KAAK,CAAC,CAAC,EAAE,CAAC;QAC7B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC5B,CAAC;SAAM,CAAC;QACJ,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,mBAAmB,EAAE,CAAC,EAAE,IAAI,CAAC,CAAA;IACtD,CAAC;AACL,CAAC,CAAA;AAbY,QAAA,cAAc,kBAa1B;AAED;;;;GAIG;AACI,MAAM,cAAc,GAAG,CAAC,IAAU,EAAE,OAAe,EAAW,EAAE;IACnE,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO,CAAC,CAAA;IACpC,OAAO,CAAC,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAA;AAClE,CAAC,CAAA;AAHY,QAAA,cAAc,kBAG1B"}
|
|
@@ -12,23 +12,38 @@ const columnReadonly = (file, api) => {
|
|
|
12
12
|
const j = api.jscodeshift;
|
|
13
13
|
const root = j(file.source);
|
|
14
14
|
let hasChanges = false;
|
|
15
|
+
const decoratorLocalNames = (0, ast_helpers_1.expandLocalNamesForImports)(root, j, "typeorm", ast_helpers_1.TYPEORM_COLUMN_DECORATORS);
|
|
15
16
|
(0, ast_helpers_1.forEachDecoratorObjectArg)(root, j, (obj) => {
|
|
16
17
|
for (const prop of obj.properties) {
|
|
17
|
-
if (prop.type
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
18
|
+
if (prop.type !== "ObjectProperty")
|
|
19
|
+
continue;
|
|
20
|
+
const keyName = prop.key.type === "Identifier"
|
|
21
|
+
? prop.key.name
|
|
22
|
+
: (0, ast_helpers_1.getStringValue)(prop.key);
|
|
23
|
+
if (keyName !== "readonly")
|
|
24
|
+
continue;
|
|
25
|
+
// readonly: true → update: false
|
|
26
|
+
// readonly: false → update: true
|
|
27
|
+
// readonly: <expr> → update: !<expr>
|
|
28
|
+
prop.key = j.identifier("update");
|
|
29
|
+
if (prop.value.type === "BooleanLiteral" ||
|
|
30
|
+
(prop.value.type === "Literal" &&
|
|
31
|
+
typeof prop.value.value === "boolean")) {
|
|
32
|
+
prop.value.value = !prop.value.value;
|
|
29
33
|
}
|
|
34
|
+
else if (prop.value.type === "UnaryExpression" &&
|
|
35
|
+
prop.value.operator === "!") {
|
|
36
|
+
// `readonly: !flag` → `update: flag` (strip the existing
|
|
37
|
+
// NOT rather than double-negating).
|
|
38
|
+
prop.value = prop.value.argument;
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
// `readonly: someVar` / `readonly: obj.flag` → `update: !(…)`
|
|
42
|
+
prop.value = j.unaryExpression("!", prop.value, true);
|
|
43
|
+
}
|
|
44
|
+
hasChanges = true;
|
|
30
45
|
}
|
|
31
|
-
});
|
|
46
|
+
}, decoratorLocalNames);
|
|
32
47
|
return hasChanges ? root.toSource() : undefined;
|
|
33
48
|
};
|
|
34
49
|
exports.columnReadonly = columnReadonly;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"column-readonly.js","sourceRoot":"","sources":["../../../src/transforms/v1/column-readonly.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA4B;AAE5B,
|
|
1
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