@comet/upgrade 1.36.0 → 1.37.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,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const ts_morph_1 = require("ts-morph");
4
+ async function removeMuiDataGridErrorProp() {
5
+ console.log("Remove error prop from DataGrid and DataGridPro components");
6
+ const project = new ts_morph_1.Project({ tsConfigFilePath: "./admin/tsconfig.json" });
7
+ const sourceFiles = project.getSourceFiles("admin/src/**/*.tsx");
8
+ sourceFiles.forEach((sourceFile) => {
9
+ const importDeclarations = sourceFile.getImportDeclarations();
10
+ const dataGridImports = importDeclarations.filter((importDeclaration) => {
11
+ const moduleSpecifier = importDeclaration.getModuleSpecifier().getLiteralValue();
12
+ return moduleSpecifier === "@mui/x-data-grid" || moduleSpecifier === "@mui/x-data-grid-pro";
13
+ });
14
+ if (dataGridImports.length > 0) {
15
+ const jsxElements = sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.JsxSelfClosingElement);
16
+ jsxElements.forEach((jsxElement) => {
17
+ const tagName = jsxElement.getTagNameNode().getText();
18
+ if (tagName.includes("DataGrid") || tagName.includes("DataGridPro")) {
19
+ const errorProp = jsxElement.getAttributes().find((attribute) => {
20
+ if (attribute.getKind() === ts_morph_1.SyntaxKind.JsxAttribute) {
21
+ const jsxAttribute = attribute.asKind(ts_morph_1.SyntaxKind.JsxAttribute);
22
+ return jsxAttribute && jsxAttribute.getNameNode().getText() === "error";
23
+ }
24
+ });
25
+ if (errorProp) {
26
+ console.log(`✅ Removed error prop on ${tagName} at line: ${errorProp.getStartLineNumber()} in `, sourceFile.getFilePath());
27
+ errorProp.replaceWithText(`/*
28
+ @comet/upgrade
29
+ TODO: DataGrid's error prop got removed in @mui/x-data-grid(-pro) > v5.
30
+
31
+ Recommended usage of errors is using parents ErrorBoundary: https://mui.com/x/migration/migration-data-grid-v5/#removed-props.
32
+
33
+ \`\`\`
34
+ if (error) {
35
+ throw error
36
+ }
37
+ \`\`\`
38
+ */`);
39
+ }
40
+ }
41
+ });
42
+ sourceFile.save();
43
+ }
44
+ });
45
+ }
46
+ exports.default = removeMuiDataGridErrorProp;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@comet/upgrade",
3
- "version": "1.36.0",
3
+ "version": "1.37.0",
4
4
  "description": "Upgrade scripts for Comet DXP",
5
5
  "homepage": "https://github.com/vivid-planet/comet-upgrade#readme",
6
6
  "bugs": {