@comet/upgrade 1.33.0 → 1.35.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/lib/util/package-json.util.js +4 -0
- package/lib/v8/mikro-orm-base-entity-generic.js +17 -0
- package/lib/v8/mikro-orm-custom-type.js +17 -0
- package/lib/v8/mikro-orm-delete-rule.js +17 -0
- package/lib/v8/mikro-orm-dotenv.js +17 -0
- package/lib/v8/mikro-orm-imports.js +17 -0
- package/lib/v8/mikro-orm-ormconfig.js +25 -0
- package/lib/v8/update-nest-dependencies.js +0 -2
- package/package.json +1 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const promises_1 = require("fs/promises");
|
|
4
|
+
const glob_1 = require("glob");
|
|
5
|
+
/**
|
|
6
|
+
* BaseEntity no longer has generic type arguments.
|
|
7
|
+
* See https://mikro-orm.io/docs/upgrading-v5-to-v6#baseentity-no-longer-has-generic-type-arguments.
|
|
8
|
+
*/
|
|
9
|
+
async function removeGenericFromBaseEntity() {
|
|
10
|
+
const files = glob_1.glob.sync(["api/src/**/*.entity.ts"]);
|
|
11
|
+
for (const filePath of files) {
|
|
12
|
+
let fileContent = await (0, promises_1.readFile)(filePath, "utf-8");
|
|
13
|
+
fileContent = fileContent.replaceAll(/BaseEntity<.*>/g, "BaseEntity");
|
|
14
|
+
await (0, promises_1.writeFile)(filePath, fileContent);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.default = removeGenericFromBaseEntity;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const promises_1 = require("fs/promises");
|
|
4
|
+
const glob_1 = require("glob");
|
|
5
|
+
/**
|
|
6
|
+
* Custom type has been removed in favor of just type.
|
|
7
|
+
* See https://mikro-orm.io/docs/upgrading-v5-to-v6#removed-propertyoptionscustomtype-in-favour-of-just-type.
|
|
8
|
+
*/
|
|
9
|
+
async function replaceCustomType() {
|
|
10
|
+
const files = glob_1.glob.sync(["api/src/**/*.entity.ts"]);
|
|
11
|
+
for (const filePath of files) {
|
|
12
|
+
let fileContent = await (0, promises_1.readFile)(filePath, "utf-8");
|
|
13
|
+
fileContent = fileContent.replaceAll("customType:", "type:");
|
|
14
|
+
await (0, promises_1.writeFile)(filePath, fileContent);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.default = replaceCustomType;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const promises_1 = require("fs/promises");
|
|
4
|
+
const glob_1 = require("glob");
|
|
5
|
+
/**
|
|
6
|
+
* onDelete has been renamed to deleteRule.
|
|
7
|
+
* See https://mikro-orm.io/docs/upgrading-v5-to-v6#renames.
|
|
8
|
+
*/
|
|
9
|
+
async function renameOnDelete() {
|
|
10
|
+
const files = glob_1.glob.sync(["api/src/**/*.entity.ts"]);
|
|
11
|
+
for (const filePath of files) {
|
|
12
|
+
let fileContent = await (0, promises_1.readFile)(filePath, "utf-8");
|
|
13
|
+
fileContent = fileContent.replaceAll("onDelete:", "deleteRule:");
|
|
14
|
+
await (0, promises_1.writeFile)(filePath, fileContent);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.default = renameOnDelete;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const fs_1 = require("fs");
|
|
4
|
+
const package_json_util_1 = require("../util/package-json.util");
|
|
5
|
+
/**
|
|
6
|
+
* Adds a `mikro-orm` script to package.json that calls dotenv.
|
|
7
|
+
* See https://mikro-orm.io/docs/upgrading-v5-to-v6#env-files-are-no-longer-automatically-loaded.
|
|
8
|
+
*/
|
|
9
|
+
async function addDotenvCallToConfig() {
|
|
10
|
+
if (!(0, fs_1.existsSync)("api/package.json")) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const packageJson = new package_json_util_1.PackageJson("api/package.json");
|
|
14
|
+
packageJson.addScript("mikro-orm", "dotenv -e .env.secrets -e .env.local -e .env -e .env.site-configs -- mikro-orm");
|
|
15
|
+
packageJson.save();
|
|
16
|
+
}
|
|
17
|
+
exports.default = addDotenvCallToConfig;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const promises_1 = require("fs/promises");
|
|
4
|
+
const glob_1 = require("glob");
|
|
5
|
+
/**
|
|
6
|
+
* Always import form `@mikro-orm/postgresql`.
|
|
7
|
+
* See https://mikro-orm.io/docs/upgrading-v5-to-v6#all-drivers-now-re-export-the-mikro-ormcore-package.
|
|
8
|
+
*/
|
|
9
|
+
async function replaceImports() {
|
|
10
|
+
const files = glob_1.glob.sync(["api/src/**/*.entity.ts"]);
|
|
11
|
+
for (const filePath of files) {
|
|
12
|
+
let fileContent = await (0, promises_1.readFile)(filePath, "utf-8");
|
|
13
|
+
fileContent = fileContent.replaceAll("@mikro-orm/core", "@mikro-orm/postgresql");
|
|
14
|
+
await (0, promises_1.writeFile)(filePath, fileContent);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.default = replaceImports;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ts_morph_1 = require("ts-morph");
|
|
4
|
+
/**
|
|
5
|
+
* Wrap the config in createOrmConfig with defineConfig
|
|
6
|
+
*/
|
|
7
|
+
async function replaceCustomType() {
|
|
8
|
+
const project = new ts_morph_1.Project({ tsConfigFilePath: "./api/tsconfig.json" });
|
|
9
|
+
const sourceFile = project.getSourceFile("api/src/db/ormconfig.ts");
|
|
10
|
+
if (!sourceFile) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
sourceFile.addImportDeclaration({
|
|
14
|
+
namedImports: ["defineConfig"],
|
|
15
|
+
moduleSpecifier: "@mikro-orm/postgresql",
|
|
16
|
+
});
|
|
17
|
+
const config = sourceFile
|
|
18
|
+
.getVariableStatementOrThrow("ormConfig")
|
|
19
|
+
.getDeclarations()[0]
|
|
20
|
+
.getInitializerIfKindOrThrow(ts_morph_1.SyntaxKind.CallExpression)
|
|
21
|
+
.getArguments()[0];
|
|
22
|
+
config.replaceWithText(`defineConfig(${config.getText()})`);
|
|
23
|
+
await sourceFile.save();
|
|
24
|
+
}
|
|
25
|
+
exports.default = replaceCustomType;
|
|
@@ -16,8 +16,6 @@ async function updateNestDependencies() {
|
|
|
16
16
|
packageJson.updateDependency("@nestjs/common", "^10.0.0");
|
|
17
17
|
packageJson.updateDependency("@nestjs/core", "^10.0.0");
|
|
18
18
|
packageJson.updateDependency("@nestjs/graphql", "^12.0.0");
|
|
19
|
-
// TODO remove when https://github.com/vivid-planet/comet/pull/2809 has been merged
|
|
20
|
-
packageJson.updateDependency("@nestjs/passport", "^10.0.0");
|
|
21
19
|
packageJson.updateDependency("@nestjs/platform-express", "^10.0.0");
|
|
22
20
|
packageJson.updateDependency("graphql", "^16.6.0");
|
|
23
21
|
packageJson.updateDependency("nestjs-console", "^9.0.0");
|