@comet/upgrade 1.115.0 → 1.117.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/bin/index.js +1 -1
- package/lib/index.js +33 -73
- package/lib/util/execute-command.util.js +3 -6
- package/lib/util/format-code.util.js +3 -6
- package/lib/util/get-latest-package-version.js +3 -9
- package/lib/util/package-json.util.js +5 -9
- package/lib/util/update-dependency-version.util.js +5 -8
- package/lib/v4/remove-clear-types-script.js +7 -13
- package/lib/v6/rename-build-runtime.js +7 -10
- package/lib/v6/rename-job-status-enum.js +7 -10
- package/lib/v6/rename-subject-entity-decorator.js +7 -10
- package/lib/v7/add-site-preview-secret.js +26 -65
- package/lib/v7/hide-graphql-field-suggestions.js +6 -9
- package/lib/v7/import-admin-theme-types.js +7 -13
- package/lib/v7/rename-date-filter-to-date-time-filter.js +7 -10
- package/lib/v7/replace-exception-interceptor-with-exception-filter.js +8 -11
- package/lib/v7/replace-gridcoldef-import.js +7 -10
- package/lib/v7/replace-roboto-with-roboto-flex.js +11 -14
- package/lib/v7/use-graphql-scalars.js +11 -14
- package/lib/v8/admin/after-install/add-dialog-content-to-edit-dialog.js +14 -17
- package/lib/v8/admin/after-install/clipboard-helpers.js +7 -10
- package/lib/v8/admin/after-install/comet-config-provider.js +66 -69
- package/lib/v8/admin/after-install/merge-admin-theme-into-admin.js +10 -13
- package/lib/v8/admin/after-install/merge-blocks-admin-into-cms-admin.js +8 -11
- package/lib/v8/admin/after-install/mui-codemods.js +9 -12
- package/lib/v8/admin/after-install/mui-data-grid-remove-error-prop.js +6 -9
- package/lib/v8/admin/after-install/mui-grid-sort-to-gql.js +6 -9
- package/lib/v8/admin/after-install/mui-x-codemods.js +4 -7
- package/lib/v8/admin/after-install/rename-menu-components-in-admin.js +7 -10
- package/lib/v8/admin/after-install/replace-mui-button-with-comet-admin-button.js +3 -6
- package/lib/v8/admin/after-install/tooltip-1-update-import.js +5 -8
- package/lib/v8/admin/after-install/tooltip-2-remove-trigger-prop.js +6 -9
- package/lib/v8/admin/after-install/update-import-of-dialog.js +5 -8
- package/lib/v8/admin/before-install/remove-admin-theme-package.js +6 -10
- package/lib/v8/admin/before-install/remove-blocks-packages-admin.js +6 -10
- package/lib/v8/admin/before-install/remove-comet-admin-react-select-dependency.js +6 -10
- package/lib/v8/admin/before-install/remove-v8-eslint-disable-comments-admin.js +4 -8
- package/lib/v8/admin/before-install/update-graphql-admin.js +6 -10
- package/lib/v8/admin/before-install/update-mui-dependencies.js +6 -10
- package/lib/v8/admin/before-install/update-mui-x-dependencies.js +6 -10
- package/lib/v8/admin/before-install/update-react-dependencies.js +6 -10
- package/lib/v8/admin/before-install/update-swc-dependencies.js +6 -10
- package/lib/v8/admin/before-install/use-mui-date-picker-in-grid.js +10 -14
- package/lib/v8/api/after-install/merge-blocks-api-into-cms-api.js +8 -11
- package/lib/v8/api/after-install/mikro-orm-base-entity-generic.js +6 -9
- package/lib/v8/api/after-install/mikro-orm-create-request-context.js +7 -10
- package/lib/v8/api/after-install/mikro-orm-custom-type.js +6 -9
- package/lib/v8/api/after-install/mikro-orm-delete-rule.js +6 -9
- package/lib/v8/api/after-install/mikro-orm-dotenv.js +5 -8
- package/lib/v8/api/after-install/mikro-orm-imports.js +6 -9
- package/lib/v8/api/after-install/mikro-orm-ormconfig.js +5 -8
- package/lib/v8/api/after-install/move-maxSrcResolution-in-comet-config.js +7 -13
- package/lib/v8/api/after-install/replace-playground-with-graphiql.js +12 -15
- package/lib/v8/api/after-install/update-dam-configuration.js +13 -16
- package/lib/v8/api/after-install/update-graphql-format-error.js +4 -7
- package/lib/v8/api/after-install/update-s3-config.js +8 -11
- package/lib/v8/api/before-install/nest-peer-dependencies.js +6 -10
- package/lib/v8/api/before-install/remove-blocks-packages-api.js +6 -10
- package/lib/v8/api/before-install/remove-passport.js +6 -10
- package/lib/v8/api/before-install/replace-nestjs-console-with-nest-commander.js +6 -10
- package/lib/v8/api/before-install/update-class-validator.js +7 -11
- package/lib/v8/api/before-install/update-kubernetes-client-node.js +6 -10
- package/lib/v8/api/before-install/update-mikro-orm-dependencies.js +6 -10
- package/lib/v8/api/before-install/update-nest-dependencies.js +6 -10
- package/lib/v8/api/before-install/update-sentry.js +9 -13
- package/lib/v8/eslint-dev-dependencies.js +22 -26
- package/lib/v8/ignore-restricted-imports-admin.js +4 -8
- package/lib/v8/prettier-dev-dependencies.js +12 -16
- package/lib/v8/remove-react-barrel-imports-admin.js +5 -8
- package/lib/v8/remove-react-barrel-imports-site.js +5 -8
- package/lib/v8/replace-node-with-v22-in-gitlab-ci-files.js +6 -43
- package/lib/v8/replace-node-with-v22-locally.js +9 -13
- package/lib/v8/site/after-install/remove-graphql-client-from-site-preview-handlers.js +7 -10
- package/lib/v8/site/before-install/update-graphql-site.js +6 -10
- package/lib/v9/admin/after-install/tooltip-replace-variant-prop.js +13 -16
- package/lib/v9/site/before-install/update-next-dependencies.js +6 -10
- package/package.json +4 -3
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
exports.stage = "before-install";
|
|
8
|
-
async function removeBlocksPackagesAdmin() {
|
|
9
|
-
if ((0, fs_1.existsSync)("admin/package.json")) {
|
|
10
|
-
const packageJson = new package_json_util_1.PackageJson("admin/package.json");
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { PackageJson } from "../../../util/package-json.util.js";
|
|
3
|
+
export const stage = "before-install";
|
|
4
|
+
export default async function removeBlocksPackagesAdmin() {
|
|
5
|
+
if (existsSync("admin/package.json")) {
|
|
6
|
+
const packageJson = new PackageJson("admin/package.json");
|
|
11
7
|
packageJson.removeDependency("@comet/blocks-admin");
|
|
12
8
|
packageJson.save();
|
|
13
9
|
}
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const package_json_util_1 = require("../../../util/package-json.util");
|
|
7
|
-
exports.stage = "before-install";
|
|
8
|
-
async function removeCometAdminReactSelectDependency() {
|
|
9
|
-
if (!(0, fs_1.existsSync)("admin/package.json")) {
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { PackageJson } from "../../../util/package-json.util.js";
|
|
3
|
+
export const stage = "before-install";
|
|
4
|
+
export default async function removeCometAdminReactSelectDependency() {
|
|
5
|
+
if (!existsSync("admin/package.json")) {
|
|
10
6
|
return;
|
|
11
7
|
}
|
|
12
|
-
const packageJson = new
|
|
8
|
+
const packageJson = new PackageJson("admin/package.json");
|
|
13
9
|
packageJson.removeDependency("@comet/admin-react-select");
|
|
14
10
|
packageJson.save();
|
|
15
11
|
}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const ts_morph_1 = require("ts-morph");
|
|
6
|
-
exports.stage = "before-install";
|
|
7
|
-
async function removeV8EslintDisableCommentsAdmin() {
|
|
8
|
-
const project = new ts_morph_1.Project({ tsConfigFilePath: "./admin/tsconfig.json" });
|
|
1
|
+
import { Project } from "ts-morph";
|
|
2
|
+
export const stage = "before-install";
|
|
3
|
+
export default async function removeV8EslintDisableCommentsAdmin() {
|
|
4
|
+
const project = new Project({ tsConfigFilePath: "./admin/tsconfig.json" });
|
|
9
5
|
const sourceFiles = project.getSourceFiles("admin/src/**/*.tsx");
|
|
10
6
|
for (const sourceFile of sourceFiles) {
|
|
11
7
|
const imports = sourceFile.getImportDeclarations();
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const package_json_util_1 = require("../../../util/package-json.util");
|
|
7
|
-
exports.stage = "before-install";
|
|
8
|
-
async function updateGraphqlAdmin() {
|
|
9
|
-
if (!(0, fs_1.existsSync)("admin/package.json")) {
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { PackageJson } from "../../../util/package-json.util.js";
|
|
3
|
+
export const stage = "before-install";
|
|
4
|
+
export default async function updateGraphqlAdmin() {
|
|
5
|
+
if (!existsSync("admin/package.json")) {
|
|
10
6
|
return;
|
|
11
7
|
}
|
|
12
|
-
const packageJson = new
|
|
8
|
+
const packageJson = new PackageJson("admin/package.json");
|
|
13
9
|
packageJson.updateDependency("graphql", "^16.10.0");
|
|
14
10
|
packageJson.save();
|
|
15
11
|
}
|
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
exports.default = updateMuiDependencies;
|
|
5
|
-
const fs_1 = require("fs");
|
|
6
|
-
const package_json_util_1 = require("../../../util/package-json.util");
|
|
7
|
-
exports.stage = "before-install";
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { PackageJson } from "../../../util/package-json.util.js";
|
|
3
|
+
export const stage = "before-install";
|
|
8
4
|
const adminPackageJsonPath = "admin/package.json";
|
|
9
|
-
async function updateMuiDependencies() {
|
|
10
|
-
if (!
|
|
5
|
+
export default async function updateMuiDependencies() {
|
|
6
|
+
if (!existsSync(adminPackageJsonPath)) {
|
|
11
7
|
return;
|
|
12
8
|
}
|
|
13
|
-
const packageJson = new
|
|
9
|
+
const packageJson = new PackageJson(adminPackageJsonPath);
|
|
14
10
|
packageJson.updateDependency("@mui/material", "^7.0.0");
|
|
15
11
|
packageJson.updateDependency("@mui/system", "^7.0.0");
|
|
16
12
|
packageJson.updateDependency("@mui/utils", "^7.0.0");
|
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
exports.default = updateMuiXDependencies;
|
|
5
|
-
const fs_1 = require("fs");
|
|
6
|
-
const package_json_util_1 = require("../../../util/package-json.util");
|
|
7
|
-
exports.stage = "before-install";
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { PackageJson } from "../../../util/package-json.util.js";
|
|
3
|
+
export const stage = "before-install";
|
|
8
4
|
const adminPackageJsonPath = "admin/package.json";
|
|
9
|
-
async function updateMuiXDependencies() {
|
|
10
|
-
if (!
|
|
5
|
+
export default async function updateMuiXDependencies() {
|
|
6
|
+
if (!existsSync(adminPackageJsonPath)) {
|
|
11
7
|
return;
|
|
12
8
|
}
|
|
13
|
-
const packageJson = new
|
|
9
|
+
const packageJson = new PackageJson(adminPackageJsonPath);
|
|
14
10
|
packageJson.addDependency("@mui/x-data-grid", "^7.0.0");
|
|
15
11
|
packageJson.addDependency("@mui/x-data-grid-pro", "^7.0.0");
|
|
16
12
|
packageJson.save();
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const package_json_util_1 = require("../../../util/package-json.util");
|
|
7
|
-
exports.stage = "before-install";
|
|
8
|
-
async function updateReactDependencies() {
|
|
9
|
-
if (!(0, fs_1.existsSync)("admin/package.json")) {
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { PackageJson } from "../../../util/package-json.util.js";
|
|
3
|
+
export const stage = "before-install";
|
|
4
|
+
export default async function updateReactDependencies() {
|
|
5
|
+
if (!existsSync("admin/package.json")) {
|
|
10
6
|
return;
|
|
11
7
|
}
|
|
12
|
-
const packageJson = new
|
|
8
|
+
const packageJson = new PackageJson("admin/package.json");
|
|
13
9
|
packageJson.updateDependency("react", "^18.3.1");
|
|
14
10
|
packageJson.updateDependency("react-dom", "^18.3.1");
|
|
15
11
|
packageJson.updateDependency("@types/react", "^18.3.18");
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const package_json_util_1 = require("../../../util/package-json.util");
|
|
7
|
-
exports.stage = "before-install";
|
|
8
|
-
async function updateSwcDependencies() {
|
|
9
|
-
if (!(0, fs_1.existsSync)("admin/package.json")) {
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { PackageJson } from "../../../util/package-json.util.js";
|
|
3
|
+
export const stage = "before-install";
|
|
4
|
+
export default async function updateSwcDependencies() {
|
|
5
|
+
if (!existsSync("admin/package.json")) {
|
|
10
6
|
return;
|
|
11
7
|
}
|
|
12
|
-
const packageJson = new
|
|
8
|
+
const packageJson = new PackageJson("admin/package.json");
|
|
13
9
|
packageJson.updateDependency("@vitejs/plugin-react-swc", "^3.8.0");
|
|
14
10
|
packageJson.updateDependency("@swc/plugin-emotion", "^8.7.2");
|
|
15
11
|
packageJson.save();
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const node_fs_1 = require("node:fs");
|
|
6
|
-
const ts_morph_1 = require("ts-morph");
|
|
7
|
-
const package_json_util_1 = require("../../../util/package-json.util");
|
|
8
|
-
exports.stage = "before-install";
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { Project, SyntaxKind } from "ts-morph";
|
|
3
|
+
import { PackageJson } from "../../../util/package-json.util.js";
|
|
4
|
+
export const stage = "before-install";
|
|
9
5
|
/**
|
|
10
6
|
* Prepares the admin to use the MUI DatePicker in a grid by:
|
|
11
7
|
* 1. Installing dependencies:
|
|
@@ -16,23 +12,23 @@ exports.stage = "before-install";
|
|
|
16
12
|
* - Wraps app with LocalizationProvider (above MuiThemeProvider)
|
|
17
13
|
* - Configures enUS locale with internationalization note
|
|
18
14
|
*/
|
|
19
|
-
async function UseMuiDatePickerInGrid() {
|
|
20
|
-
if (!
|
|
15
|
+
export default async function UseMuiDatePickerInGrid() {
|
|
16
|
+
if (!existsSync("admin/package.json")) {
|
|
21
17
|
return;
|
|
22
18
|
}
|
|
23
|
-
const packageJson = new
|
|
19
|
+
const packageJson = new PackageJson("admin/package.json");
|
|
24
20
|
packageJson.addDependency("@mui/x-date-pickers", "^7.29.4");
|
|
25
21
|
packageJson.addDependency("date-fns", "^4.1.0");
|
|
26
22
|
packageJson.save();
|
|
27
23
|
// Set up LocalizationProvider
|
|
28
|
-
const project = new
|
|
24
|
+
const project = new Project({ tsConfigFilePath: "./admin/tsconfig.json" });
|
|
29
25
|
const appFile = project.getSourceFile("admin/src/App.tsx");
|
|
30
26
|
if (!appFile) {
|
|
31
27
|
console.error("🛑 App.tsx not found in admin/src. Skipping LocalizationProvider setup.");
|
|
32
28
|
return;
|
|
33
29
|
}
|
|
34
30
|
// Check if LocalizationProvider is already in use
|
|
35
|
-
const hasLocalizationProvider = appFile.getDescendantsOfKind(
|
|
31
|
+
const hasLocalizationProvider = appFile.getDescendantsOfKind(SyntaxKind.JsxElement).some((element) => {
|
|
36
32
|
const openingTag = element.getOpeningElement().getTagNameNode().getText();
|
|
37
33
|
return openingTag === "LocalizationProvider";
|
|
38
34
|
});
|
|
@@ -64,7 +60,7 @@ async function UseMuiDatePickerInGrid() {
|
|
|
64
60
|
});
|
|
65
61
|
}
|
|
66
62
|
// Find MuiThemeProvider and wrap its content with LocalizationProvider
|
|
67
|
-
const muiThemeProvider = appFile.getDescendantsOfKind(
|
|
63
|
+
const muiThemeProvider = appFile.getDescendantsOfKind(SyntaxKind.JsxElement).find((element) => {
|
|
68
64
|
const openingTag = element.getOpeningElement().getTagNameNode().getText();
|
|
69
65
|
return openingTag === "MuiThemeProvider" || openingTag === "ThemeProvider";
|
|
70
66
|
});
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const promises_1 = require("fs/promises");
|
|
5
|
-
const glob_1 = require("glob");
|
|
6
|
-
const ts_morph_1 = require("ts-morph");
|
|
1
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import { glob } from "glob";
|
|
3
|
+
import { Project } from "ts-morph";
|
|
7
4
|
const renamedExports = {
|
|
8
5
|
getMostSignificantPreviewImageUrlTemplate: "getMostSignificantPreviewImageUrlTemplateFromBlock",
|
|
9
6
|
getPreviewImageUrlTemplates: "getPreviewImageUrlTemplatesFromBlock",
|
|
@@ -17,9 +14,9 @@ const renamedExports = {
|
|
|
17
14
|
TraversableTransformResponseArray: "TraversableTransformBlockResponseArray",
|
|
18
15
|
typesafeMigrationPipe: "typeSafeBlockMigrationPipe",
|
|
19
16
|
};
|
|
20
|
-
async function mergeBlocksApiIntoCmsApi() {
|
|
21
|
-
const project = new
|
|
22
|
-
const files =
|
|
17
|
+
export default async function mergeBlocksApiIntoCmsApi() {
|
|
18
|
+
const project = new Project({ tsConfigFilePath: "./api/tsconfig.json" });
|
|
19
|
+
const files = glob.sync(["api/src/**/*.ts"]);
|
|
23
20
|
for (const filePath of files) {
|
|
24
21
|
const sourceFile = project.getSourceFile(filePath);
|
|
25
22
|
if (!sourceFile) {
|
|
@@ -43,10 +40,10 @@ async function mergeBlocksApiIntoCmsApi() {
|
|
|
43
40
|
});
|
|
44
41
|
}
|
|
45
42
|
await sourceFile.save();
|
|
46
|
-
let fileContent = (await
|
|
43
|
+
let fileContent = (await readFile(filePath)).toString();
|
|
47
44
|
for (const [oldExport, newExport] of importsToRename) {
|
|
48
45
|
fileContent = fileContent.replaceAll(oldExport, newExport);
|
|
49
46
|
}
|
|
50
|
-
await
|
|
47
|
+
await writeFile(filePath, fileContent);
|
|
51
48
|
}
|
|
52
49
|
}
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.default = removeGenericFromBaseEntity;
|
|
4
|
-
const promises_1 = require("fs/promises");
|
|
5
|
-
const glob_1 = require("glob");
|
|
1
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import { glob } from "glob";
|
|
6
3
|
/**
|
|
7
4
|
* BaseEntity no longer has generic type arguments.
|
|
8
5
|
* See https://mikro-orm.io/docs/upgrading-v5-to-v6#baseentity-no-longer-has-generic-type-arguments.
|
|
9
6
|
*/
|
|
10
|
-
async function removeGenericFromBaseEntity() {
|
|
11
|
-
const files =
|
|
7
|
+
export default async function removeGenericFromBaseEntity() {
|
|
8
|
+
const files = glob.sync(["api/src/**/*.entity.ts"]);
|
|
12
9
|
for (const filePath of files) {
|
|
13
|
-
let fileContent = await
|
|
10
|
+
let fileContent = await readFile(filePath, "utf-8");
|
|
14
11
|
fileContent = fileContent.replaceAll(/BaseEntity<.*>/g, "BaseEntity");
|
|
15
|
-
await
|
|
12
|
+
await writeFile(filePath, fileContent);
|
|
16
13
|
}
|
|
17
14
|
}
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.default = mikroOrmCreateRequestContext;
|
|
4
|
-
const glob_1 = require("glob");
|
|
5
|
-
const ts_morph_1 = require("ts-morph");
|
|
1
|
+
import { glob } from "glob";
|
|
2
|
+
import { Project, SyntaxKind } from "ts-morph";
|
|
6
3
|
/**
|
|
7
4
|
* Replace UseRequestContext with CreateRequestContext
|
|
8
5
|
*/
|
|
9
|
-
async function mikroOrmCreateRequestContext() {
|
|
10
|
-
const project = new
|
|
11
|
-
const files =
|
|
6
|
+
export default async function mikroOrmCreateRequestContext() {
|
|
7
|
+
const project = new Project({ tsConfigFilePath: "./api/tsconfig.json" });
|
|
8
|
+
const files = glob.sync("api/src/**/*.ts");
|
|
12
9
|
for (const filePath of files) {
|
|
13
10
|
const sourceFile = project.getSourceFile(filePath);
|
|
14
11
|
if (!sourceFile) {
|
|
@@ -23,8 +20,8 @@ async function mikroOrmCreateRequestContext() {
|
|
|
23
20
|
if (!mikroOrmCoreImport.getNamedImports().find((namedImport) => namedImport.getText() === "CreateRequestContext")) {
|
|
24
21
|
mikroOrmCoreImport.addNamedImport("CreateRequestContext");
|
|
25
22
|
}
|
|
26
|
-
sourceFile.getDescendantsOfKind(
|
|
27
|
-
const identifier = decorator.getFirstDescendantByKind(
|
|
23
|
+
sourceFile.getDescendantsOfKind(SyntaxKind.Decorator).forEach((decorator) => {
|
|
24
|
+
const identifier = decorator.getFirstDescendantByKind(SyntaxKind.Identifier);
|
|
28
25
|
if (identifier && identifier.getText() === "UseRequestContext") {
|
|
29
26
|
identifier.replaceWithText("CreateRequestContext");
|
|
30
27
|
}
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.default = replaceCustomType;
|
|
4
|
-
const promises_1 = require("fs/promises");
|
|
5
|
-
const glob_1 = require("glob");
|
|
1
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import { glob } from "glob";
|
|
6
3
|
/**
|
|
7
4
|
* Custom type has been removed in favor of just type.
|
|
8
5
|
* See https://mikro-orm.io/docs/upgrading-v5-to-v6#removed-propertyoptionscustomtype-in-favour-of-just-type.
|
|
9
6
|
*/
|
|
10
|
-
async function replaceCustomType() {
|
|
11
|
-
const files =
|
|
7
|
+
export default async function replaceCustomType() {
|
|
8
|
+
const files = glob.sync(["api/src/**/*.entity.ts"]);
|
|
12
9
|
for (const filePath of files) {
|
|
13
|
-
let fileContent = await
|
|
10
|
+
let fileContent = await readFile(filePath, "utf-8");
|
|
14
11
|
fileContent = fileContent.replaceAll("customType:", "type:");
|
|
15
|
-
await
|
|
12
|
+
await writeFile(filePath, fileContent);
|
|
16
13
|
}
|
|
17
14
|
}
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.default = renameOnDelete;
|
|
4
|
-
const promises_1 = require("fs/promises");
|
|
5
|
-
const glob_1 = require("glob");
|
|
1
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import { glob } from "glob";
|
|
6
3
|
/**
|
|
7
4
|
* onDelete has been renamed to deleteRule.
|
|
8
5
|
* See https://mikro-orm.io/docs/upgrading-v5-to-v6#renames.
|
|
9
6
|
*/
|
|
10
|
-
async function renameOnDelete() {
|
|
11
|
-
const files =
|
|
7
|
+
export default async function renameOnDelete() {
|
|
8
|
+
const files = glob.sync(["api/src/**/*.entity.ts"]);
|
|
12
9
|
for (const filePath of files) {
|
|
13
|
-
let fileContent = await
|
|
10
|
+
let fileContent = await readFile(filePath, "utf-8");
|
|
14
11
|
fileContent = fileContent.replaceAll("onDelete:", "deleteRule:");
|
|
15
|
-
await
|
|
12
|
+
await writeFile(filePath, fileContent);
|
|
16
13
|
}
|
|
17
14
|
}
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.default = addDotenvCallToConfig;
|
|
4
|
-
const fs_1 = require("fs");
|
|
5
|
-
const package_json_util_1 = require("../../../util/package-json.util");
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { PackageJson } from "../../../util/package-json.util.js";
|
|
6
3
|
/**
|
|
7
4
|
* Adds a `mikro-orm` script to package.json that calls dotenv.
|
|
8
5
|
* See https://mikro-orm.io/docs/upgrading-v5-to-v6#env-files-are-no-longer-automatically-loaded.
|
|
9
6
|
*/
|
|
10
|
-
async function addDotenvCallToConfig() {
|
|
11
|
-
if (!
|
|
7
|
+
export default async function addDotenvCallToConfig() {
|
|
8
|
+
if (!existsSync("api/package.json")) {
|
|
12
9
|
return;
|
|
13
10
|
}
|
|
14
|
-
const packageJson = new
|
|
11
|
+
const packageJson = new PackageJson("api/package.json");
|
|
15
12
|
packageJson.addScript("mikro-orm", "dotenv -e .env.secrets -e .env.local -e .env -e .env.site-configs -- mikro-orm");
|
|
16
13
|
packageJson.save();
|
|
17
14
|
}
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.default = replaceImports;
|
|
4
|
-
const promises_1 = require("fs/promises");
|
|
5
|
-
const glob_1 = require("glob");
|
|
1
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import { glob } from "glob";
|
|
6
3
|
/**
|
|
7
4
|
* Always import form `@mikro-orm/postgresql`.
|
|
8
5
|
* See https://mikro-orm.io/docs/upgrading-v5-to-v6#all-drivers-now-re-export-the-mikro-ormcore-package.
|
|
9
6
|
*/
|
|
10
|
-
async function replaceImports() {
|
|
11
|
-
const files =
|
|
7
|
+
export default async function replaceImports() {
|
|
8
|
+
const files = glob.sync(["api/src/**/*.entity.ts"]);
|
|
12
9
|
for (const filePath of files) {
|
|
13
|
-
let fileContent = await
|
|
10
|
+
let fileContent = await readFile(filePath, "utf-8");
|
|
14
11
|
fileContent = fileContent.replaceAll("@mikro-orm/core", "@mikro-orm/postgresql");
|
|
15
|
-
await
|
|
12
|
+
await writeFile(filePath, fileContent);
|
|
16
13
|
}
|
|
17
14
|
}
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = replaceCustomType;
|
|
4
|
-
const ts_morph_1 = require("ts-morph");
|
|
1
|
+
import { Project, SyntaxKind } from "ts-morph";
|
|
5
2
|
/**
|
|
6
3
|
* Wrap the config in createOrmConfig with defineConfig
|
|
7
4
|
*/
|
|
8
|
-
async function replaceCustomType() {
|
|
9
|
-
const project = new
|
|
5
|
+
export default async function replaceCustomType() {
|
|
6
|
+
const project = new Project({ tsConfigFilePath: "./api/tsconfig.json" });
|
|
10
7
|
const sourceFile = project.getSourceFile("api/src/db/ormconfig.ts");
|
|
11
8
|
if (!sourceFile) {
|
|
12
9
|
return;
|
|
@@ -21,9 +18,9 @@ async function replaceCustomType() {
|
|
|
21
18
|
const config = sourceFile
|
|
22
19
|
.getVariableStatementOrThrow("ormConfig")
|
|
23
20
|
.getDeclarations()[0]
|
|
24
|
-
.getInitializerIfKindOrThrow(
|
|
21
|
+
.getInitializerIfKindOrThrow(SyntaxKind.CallExpression)
|
|
25
22
|
.getArguments()[0];
|
|
26
|
-
for (const propertyAssignment of config.getDescendantsOfKind(
|
|
23
|
+
for (const propertyAssignment of config.getDescendantsOfKind(SyntaxKind.PropertyAssignment)) {
|
|
27
24
|
if (propertyAssignment.getName() === "type") {
|
|
28
25
|
propertyAssignment.remove();
|
|
29
26
|
}
|
|
@@ -1,24 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.default = moveMaxSrcResolutionInCometConfig;
|
|
7
|
-
const fs_1 = require("fs");
|
|
8
|
-
const prettier_1 = __importDefault(require("prettier"));
|
|
1
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
import prettier from "prettier";
|
|
9
3
|
/**
|
|
10
4
|
* Move the maxSrcResolution property from imgproxy to dam in comet-config.json
|
|
11
5
|
*/
|
|
12
|
-
async function moveMaxSrcResolutionInCometConfig() {
|
|
6
|
+
export default async function moveMaxSrcResolutionInCometConfig() {
|
|
13
7
|
const cometConfigPath = "api/src/comet-config.json";
|
|
14
|
-
if (
|
|
15
|
-
const content =
|
|
8
|
+
if (existsSync(cometConfigPath)) {
|
|
9
|
+
const content = readFileSync(cometConfigPath, "utf-8");
|
|
16
10
|
const config = JSON.parse(content);
|
|
17
11
|
if (config.imgproxy && config.imgproxy.maxSrcResolution !== undefined) {
|
|
18
12
|
config.dam.maxSrcResolution = config.imgproxy.maxSrcResolution;
|
|
19
13
|
delete config.imgproxy.maxSrcResolution;
|
|
20
14
|
}
|
|
21
|
-
const prettierConfig = await
|
|
22
|
-
|
|
15
|
+
const prettierConfig = await prettier.resolveConfig(process.cwd());
|
|
16
|
+
writeFileSync(cometConfigPath, await prettier.format(JSON.stringify(config), { ...prettierConfig, parser: "json" }));
|
|
23
17
|
}
|
|
24
18
|
}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = default_1;
|
|
4
|
-
const ts_morph_1 = require("ts-morph");
|
|
1
|
+
import { Project, SyntaxKind } from "ts-morph";
|
|
5
2
|
/**
|
|
6
3
|
* From
|
|
7
4
|
*
|
|
@@ -20,24 +17,24 @@ const ts_morph_1 = require("ts-morph");
|
|
|
20
17
|
* }),
|
|
21
18
|
* }),
|
|
22
19
|
*/
|
|
23
|
-
function
|
|
24
|
-
const project = new
|
|
20
|
+
export default function () {
|
|
21
|
+
const project = new Project();
|
|
25
22
|
const filePath = "api/src/app.module.ts";
|
|
26
23
|
const sourceFile = project.addSourceFileAtPath(filePath);
|
|
27
24
|
for (const node of sourceFile.getDescendants()) {
|
|
28
|
-
if (node.getKind() ===
|
|
29
|
-
const callExpr = node.asKindOrThrow(
|
|
25
|
+
if (node.getKind() === SyntaxKind.CallExpression && node.getText().startsWith("GraphQLModule.forRootAsync")) {
|
|
26
|
+
const callExpr = node.asKindOrThrow(SyntaxKind.CallExpression);
|
|
30
27
|
const arg = callExpr.getArguments()[0];
|
|
31
|
-
if (arg && arg.getKind() ===
|
|
32
|
-
const obj = arg.asKindOrThrow(
|
|
28
|
+
if (arg && arg.getKind() === SyntaxKind.ObjectLiteralExpression) {
|
|
29
|
+
const obj = arg.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);
|
|
33
30
|
const useFactoryProp = obj.getProperty("useFactory");
|
|
34
|
-
if (useFactoryProp && useFactoryProp.getKind() ===
|
|
35
|
-
const useFactory = useFactoryProp.asKindOrThrow(
|
|
36
|
-
const arrowFunc = useFactory.getInitializerIfKind(
|
|
31
|
+
if (useFactoryProp && useFactoryProp.getKind() === SyntaxKind.PropertyAssignment) {
|
|
32
|
+
const useFactory = useFactoryProp.asKindOrThrow(SyntaxKind.PropertyAssignment);
|
|
33
|
+
const arrowFunc = useFactory.getInitializerIfKind(SyntaxKind.ArrowFunction);
|
|
37
34
|
if (arrowFunc) {
|
|
38
35
|
const body = arrowFunc.getBody();
|
|
39
|
-
if (body.getKind() ===
|
|
40
|
-
const retObj = body.getFirstChildByKind(
|
|
36
|
+
if (body.getKind() === SyntaxKind.ParenthesizedExpression) {
|
|
37
|
+
const retObj = body.getFirstChildByKind(SyntaxKind.ObjectLiteralExpression);
|
|
41
38
|
if (retObj) {
|
|
42
39
|
if (retObj.getProperty("graphiql")) {
|
|
43
40
|
return; // Already has graphiql property
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = updateDamConfiguration;
|
|
4
|
-
const ts_morph_1 = require("ts-morph");
|
|
1
|
+
import { Project, SyntaxKind } from "ts-morph";
|
|
5
2
|
/**
|
|
6
3
|
* Update the configuration of the DamModule and BlobStorageModule and add ImgproxyModule to app.module.ts
|
|
7
4
|
*
|
|
@@ -10,18 +7,18 @@ const ts_morph_1 = require("ts-morph");
|
|
|
10
7
|
* - Add `maxSrcResolution` to `DamModule.register`
|
|
11
8
|
* - Removes `cacheDirectory` and `imgproxyConfig` from `DamModule.register`
|
|
12
9
|
*/
|
|
13
|
-
async function updateDamConfiguration() {
|
|
14
|
-
const project = new
|
|
10
|
+
export default async function updateDamConfiguration() {
|
|
11
|
+
const project = new Project();
|
|
15
12
|
const filePath = "api/src/app.module.ts"; // Update this path to your actual file path
|
|
16
13
|
const sourceFile = project.addSourceFileAtPath(filePath);
|
|
17
14
|
// Update BlobStorageModule configuration
|
|
18
|
-
const blobStorageModuleCall = sourceFile.getDescendantsOfKind(
|
|
15
|
+
const blobStorageModuleCall = sourceFile.getDescendantsOfKind(SyntaxKind.CallExpression).find((call) => {
|
|
19
16
|
const expression = call.getExpression();
|
|
20
17
|
return expression.getText() === "BlobStorageModule.register";
|
|
21
18
|
});
|
|
22
19
|
if (blobStorageModuleCall) {
|
|
23
20
|
const args = blobStorageModuleCall.getArguments();
|
|
24
|
-
if (args.length > 0 && args[0].getKind() ===
|
|
21
|
+
if (args.length > 0 && args[0].getKind() === SyntaxKind.ObjectLiteralExpression) {
|
|
25
22
|
const objectLiteral = args[0];
|
|
26
23
|
const cacheDirectoryProperty = objectLiteral.getProperty("cacheDirectory");
|
|
27
24
|
if (!cacheDirectoryProperty) {
|
|
@@ -41,12 +38,12 @@ async function updateDamConfiguration() {
|
|
|
41
38
|
const importsArray = sourceFile
|
|
42
39
|
.getClass("AppModule")
|
|
43
40
|
?.getStaticMethod("forRoot")
|
|
44
|
-
?.getFirstDescendantByKind(
|
|
45
|
-
?.getFirstDescendantByKind(
|
|
41
|
+
?.getFirstDescendantByKind(SyntaxKind.ReturnStatement)
|
|
42
|
+
?.getFirstDescendantByKind(SyntaxKind.ObjectLiteralExpression)
|
|
46
43
|
?.getProperty("imports")
|
|
47
|
-
?.getFirstDescendantByKind(
|
|
44
|
+
?.getFirstDescendantByKind(SyntaxKind.ArrayLiteralExpression);
|
|
48
45
|
if (importsArray) {
|
|
49
|
-
const imgproxyModuleCall = sourceFile.getDescendantsOfKind(
|
|
46
|
+
const imgproxyModuleCall = sourceFile.getDescendantsOfKind(SyntaxKind.CallExpression).find((call) => {
|
|
50
47
|
const expression = call.getExpression();
|
|
51
48
|
return expression.getText() === "ImgproxyModule.register";
|
|
52
49
|
});
|
|
@@ -55,17 +52,17 @@ async function updateDamConfiguration() {
|
|
|
55
52
|
}
|
|
56
53
|
}
|
|
57
54
|
// Update DamModule configuration
|
|
58
|
-
const damModuleCall = sourceFile.getDescendantsOfKind(
|
|
55
|
+
const damModuleCall = sourceFile.getDescendantsOfKind(SyntaxKind.CallExpression).find((call) => {
|
|
59
56
|
const expression = call.getExpression();
|
|
60
57
|
return expression.getText() === "DamModule.register";
|
|
61
58
|
});
|
|
62
59
|
if (damModuleCall) {
|
|
63
60
|
const args = damModuleCall.getArguments();
|
|
64
|
-
if (args.length > 0 && args[0].getKind() ===
|
|
61
|
+
if (args.length > 0 && args[0].getKind() === SyntaxKind.ObjectLiteralExpression) {
|
|
65
62
|
const objectLiteral = args[0];
|
|
66
63
|
const damConfigProperty = objectLiteral.getProperty("damConfig");
|
|
67
|
-
if (damConfigProperty && damConfigProperty.getKind() ===
|
|
68
|
-
const damConfigObject = damConfigProperty.getInitializerIfKind(
|
|
64
|
+
if (damConfigProperty && damConfigProperty.getKind() === SyntaxKind.PropertyAssignment) {
|
|
65
|
+
const damConfigObject = damConfigProperty.getInitializerIfKind(SyntaxKind.ObjectLiteralExpression);
|
|
69
66
|
if (damConfigObject) {
|
|
70
67
|
const maxSrcResolutionProperty = damConfigObject.getProperty("maxSrcResolution");
|
|
71
68
|
if (!maxSrcResolutionProperty) {
|