@comet/upgrade 1.39.0 → 1.41.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.
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const promises_1 = require("fs/promises");
|
|
4
|
+
const format_code_util_1 = require("../util/format-code.util");
|
|
5
|
+
/**
|
|
6
|
+
* Replaces the old ExceptionInterceptor with the new ExceptionFilter
|
|
7
|
+
*/
|
|
8
|
+
async function replaceExceptionInterceptorWithExceptionFilter() {
|
|
9
|
+
const filePath = "api/src/main.ts";
|
|
10
|
+
let fileContent = (await (0, promises_1.readFile)(filePath)).toString();
|
|
11
|
+
if (!fileContent.includes("ExceptionInterceptor")) {
|
|
12
|
+
console.log("ExceptionInterceptor not found in main.ts. Make sure that you use the new ExceptionFilter.");
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
fileContent = fileContent.replace("app.useGlobalInterceptors(new ExceptionInterceptor(config.debug));", "app.useGlobalFilters(new ExceptionFilter(config.debug));");
|
|
16
|
+
fileContent = fileContent.replace("ExceptionInterceptor", "ExceptionFilter");
|
|
17
|
+
await (0, promises_1.writeFile)(filePath, await (0, format_code_util_1.formatCode)(fileContent, filePath));
|
|
18
|
+
}
|
|
19
|
+
exports.default = replaceExceptionInterceptorWithExceptionFilter;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const glob_1 = require("glob");
|
|
4
|
+
const ts_morph_1 = require("ts-morph");
|
|
5
|
+
async function updateImportOfDialog() {
|
|
6
|
+
const project = new ts_morph_1.Project({ tsConfigFilePath: "./admin/tsconfig.json" });
|
|
7
|
+
const files = glob_1.glob.sync(["admin/src/**/*.tsx"]);
|
|
8
|
+
for (const filePath of files) {
|
|
9
|
+
const sourceFile = project.getSourceFile(filePath);
|
|
10
|
+
if (!sourceFile) {
|
|
11
|
+
throw new Error(`Can't get source file for ${filePath}`);
|
|
12
|
+
}
|
|
13
|
+
const adminImport = sourceFile.getImportDeclaration((declaration) => declaration.getModuleSpecifierValue().includes("@comet/admin"));
|
|
14
|
+
const adminImports = adminImport?.getNamedImports().map((namedImport) => namedImport.getText());
|
|
15
|
+
if (adminImports) {
|
|
16
|
+
if (adminImports.includes("Dialog")) {
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const muiImport = sourceFile.getImportDeclaration((declaration) => declaration.getModuleSpecifierValue() === "@mui/material");
|
|
21
|
+
if (!muiImport)
|
|
22
|
+
continue;
|
|
23
|
+
const namedImports = muiImport.getNamedImports();
|
|
24
|
+
const dialogImport = namedImports.find((namedImport) => namedImport.getText() === "Dialog");
|
|
25
|
+
if (dialogImport) {
|
|
26
|
+
dialogImport.remove();
|
|
27
|
+
}
|
|
28
|
+
if (muiImport.getNamedImports().length === 0) {
|
|
29
|
+
muiImport.remove();
|
|
30
|
+
}
|
|
31
|
+
if (adminImport) {
|
|
32
|
+
adminImport.addNamedImports(["Dialog"]);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
sourceFile.addImportDeclaration({
|
|
36
|
+
namedImports: ["Dialog"],
|
|
37
|
+
moduleSpecifier: "@comet/admin",
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
await sourceFile.save();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.default = updateImportOfDialog;
|