@comet/upgrade 1.53.0 → 1.55.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,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ts_morph_1 = require("ts-morph");
|
|
4
|
+
async function addDialogContentToEditDialog() {
|
|
5
|
+
const project = new ts_morph_1.Project({ tsConfigFilePath: "./admin/tsconfig.json" });
|
|
6
|
+
const sourceFiles = project.getSourceFiles("admin/src/**/*.tsx");
|
|
7
|
+
sourceFiles.forEach((sourceFile) => {
|
|
8
|
+
const importDeclarations = sourceFile.getImportDeclarations();
|
|
9
|
+
const muiImport = importDeclarations.find((importDeclaration) => importDeclaration.getModuleSpecifier().getLiteralValue() === "@mui/material");
|
|
10
|
+
if (!muiImport) {
|
|
11
|
+
sourceFile.addImportDeclaration({
|
|
12
|
+
moduleSpecifier: "@mui/material",
|
|
13
|
+
namedImports: ["DialogContent"],
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
else if (!muiImport.getNamedImports().some((namedImport) => namedImport.getName() === "DialogContent")) {
|
|
17
|
+
muiImport.addNamedImport("DialogContent");
|
|
18
|
+
}
|
|
19
|
+
const jsxElements = sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.JsxElement);
|
|
20
|
+
const elementsToReplace = [];
|
|
21
|
+
jsxElements.forEach((jsxElement) => {
|
|
22
|
+
const tagName = jsxElement.getOpeningElement().getTagNameNode().getText();
|
|
23
|
+
if (tagName !== "EditDialog")
|
|
24
|
+
return;
|
|
25
|
+
const children = jsxElement.getJsxChildren();
|
|
26
|
+
const functionAsChild = children.find((child) => ts_morph_1.Node.isJsxExpression(child) && ts_morph_1.Node.isArrowFunction(child.getExpression()));
|
|
27
|
+
if (functionAsChild && ts_morph_1.Node.isJsxExpression(functionAsChild)) {
|
|
28
|
+
const expression = functionAsChild.getExpression();
|
|
29
|
+
if (!expression || !ts_morph_1.Node.isArrowFunction(expression))
|
|
30
|
+
return;
|
|
31
|
+
const body = expression.getBody();
|
|
32
|
+
const parameters = expression.getParameters();
|
|
33
|
+
let wrappedContent;
|
|
34
|
+
if (ts_morph_1.Node.isBlock(body)) {
|
|
35
|
+
const returnStatement = body.getStatements().find((statement) => ts_morph_1.Node.isReturnStatement(statement));
|
|
36
|
+
if (!returnStatement || !ts_morph_1.Node.isReturnStatement(returnStatement))
|
|
37
|
+
return;
|
|
38
|
+
let returnedExpression = returnStatement.getExpression();
|
|
39
|
+
if (returnedExpression && ts_morph_1.Node.isParenthesizedExpression(returnedExpression)) {
|
|
40
|
+
returnedExpression = returnedExpression.getExpression();
|
|
41
|
+
}
|
|
42
|
+
if (!returnedExpression)
|
|
43
|
+
return;
|
|
44
|
+
if (ts_morph_1.Node.isJsxFragment(returnedExpression)) {
|
|
45
|
+
const fragmentChildren = returnedExpression.getChildrenOfKind(ts_morph_1.SyntaxKind.JsxElement);
|
|
46
|
+
const fragmentText = fragmentChildren.map((child) => child.getText()).join("\n");
|
|
47
|
+
wrappedContent = `(<DialogContent>\n${fragmentText}\n</DialogContent>)`;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
const innerContent = returnedExpression.getText().replace(/\n/g, "\n");
|
|
51
|
+
wrappedContent = `(<DialogContent>\n${innerContent}\n</DialogContent>)`;
|
|
52
|
+
}
|
|
53
|
+
const newFunction = `{(${parameters.map((param) => param.getText()).join(", ")}) => {
|
|
54
|
+
return ${wrappedContent};}}`;
|
|
55
|
+
elementsToReplace.push({ node: functionAsChild, newText: newFunction });
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
const openEditDialog = jsxElement.getOpeningElement().getText();
|
|
60
|
+
const closeEditDialog = jsxElement.getClosingElement().getText();
|
|
61
|
+
const childrensContent = children.map((child) => child.getText()).join("\n");
|
|
62
|
+
const newContent = `${openEditDialog}\n<DialogContent>\n${childrensContent}\n</DialogContent>\n${closeEditDialog}`;
|
|
63
|
+
elementsToReplace.push({ node: jsxElement, newText: newContent });
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
elementsToReplace.forEach(({ node, newText }) => {
|
|
67
|
+
node.replaceWithText(newText);
|
|
68
|
+
});
|
|
69
|
+
sourceFile.saveSync();
|
|
70
|
+
});
|
|
71
|
+
await project.save();
|
|
72
|
+
}
|
|
73
|
+
exports.default = addDialogContentToEditDialog;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const execute_command_util_1 = require("../util/execute-command.util");
|
|
4
|
+
async function executeMuiCodemods() {
|
|
5
|
+
await (0, execute_command_util_1.executeCommand)("npx", ["@mui/codemod@latest", "v6.0.0/list-item-button-prop", "admin/src"]);
|
|
6
|
+
await (0, execute_command_util_1.executeCommand)("npx", ["@mui/codemod@latest", "v6.0.0/styled", "admin/src"]);
|
|
7
|
+
await (0, execute_command_util_1.executeCommand)("npx", ["@mui/codemod@latest", "v6.0.0/sx-prop", "admin/src"]);
|
|
8
|
+
await (0, execute_command_util_1.executeCommand)("npx", ["@mui/codemod@latest", "v6.0.0/theme-v6", "admin/src/theme.ts"]);
|
|
9
|
+
}
|
|
10
|
+
exports.default = executeMuiCodemods;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stage = void 0;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const package_json_util_1 = require("../util/package-json.util");
|
|
6
|
+
exports.stage = "before-install";
|
|
7
|
+
const adminPackageJsonPath = "admin/package.json";
|
|
8
|
+
async function updateMuiDependencies() {
|
|
9
|
+
if (!(0, fs_1.existsSync)(adminPackageJsonPath)) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const packageJson = new package_json_util_1.PackageJson(adminPackageJsonPath);
|
|
13
|
+
packageJson.addDependency("@mui/material", "^6.0.0");
|
|
14
|
+
packageJson.addDependency("@mui/system", "^6.0.0");
|
|
15
|
+
packageJson.addDependency("@mui/utils", "^6.0.0");
|
|
16
|
+
packageJson.addDependency("@mui/icons-material", "^6.0.0");
|
|
17
|
+
packageJson.addDependency("@mui/lab", "^6.0.0-beta.10");
|
|
18
|
+
packageJson.save();
|
|
19
|
+
}
|
|
20
|
+
exports.default = updateMuiDependencies;
|
package/package.json
CHANGED
package/lib/v8/mui-upgrade.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const fs_1 = require("fs");
|
|
4
|
-
const execute_command_util_1 = require("../util/execute-command.util");
|
|
5
|
-
const update_dependency_version_util_1 = require("../util/update-dependency-version.util");
|
|
6
|
-
const adminPackageJsonPath = "admin/package.json";
|
|
7
|
-
async function updateMuiVersion() {
|
|
8
|
-
if (!(0, fs_1.existsSync)(adminPackageJsonPath)) {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
await (0, update_dependency_version_util_1.updateDependencyVersion)(adminPackageJsonPath, "@mui/material", "^6.0.0");
|
|
12
|
-
await (0, update_dependency_version_util_1.updateDependencyVersion)(adminPackageJsonPath, "@mui/system", "^6.0.0");
|
|
13
|
-
await (0, update_dependency_version_util_1.updateDependencyVersion)(adminPackageJsonPath, "@mui/utils", "^6.0.0");
|
|
14
|
-
await (0, update_dependency_version_util_1.updateDependencyVersion)(adminPackageJsonPath, "@mui/icons-material", "^6.0.0");
|
|
15
|
-
await (0, update_dependency_version_util_1.updateDependencyVersion)(adminPackageJsonPath, "@mui/lab", "^6.0.0-beta.10");
|
|
16
|
-
await (0, execute_command_util_1.executeCommand)("npm", ["install", "--prefix", "admin", "--no-audit", "--loglevel", "error"]);
|
|
17
|
-
await (0, execute_command_util_1.executeCommand)("npx", ["@mui/codemod@latest", "v6.0.0/list-item-button-prop", "admin/src"]);
|
|
18
|
-
await (0, execute_command_util_1.executeCommand)("npx", ["@mui/codemod@latest", "v6.0.0/styled", "admin/src"]);
|
|
19
|
-
await (0, execute_command_util_1.executeCommand)("npx", ["@mui/codemod@latest", "v6.0.0/sx-prop", "admin/src"]);
|
|
20
|
-
await (0, execute_command_util_1.executeCommand)("npx", ["@mui/codemod@latest", "v6.0.0/theme-v6", "admin/src/theme.ts"]);
|
|
21
|
-
}
|
|
22
|
-
exports.default = updateMuiVersion;
|