@comet/upgrade 1.83.0 → 1.85.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,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const ts_morph_1 = require("ts-morph");
4
+ async function replaceMuiButtonWithCometAdminButton() {
5
+ const project = new ts_morph_1.Project({ tsConfigFilePath: "./admin/tsconfig.json" });
6
+ const sourceFiles = project.getSourceFiles("admin/src/**/*.{ts,tsx}");
7
+ for (const sourceFile of sourceFiles) {
8
+ let changed = false;
9
+ const importDeclarations = sourceFile.getImportDeclarations();
10
+ const cometAdminImport = importDeclarations.find((id) => id.getModuleSpecifierValue() === "@comet/admin");
11
+ for (const importDecl of importDeclarations) {
12
+ if (importDecl.getModuleSpecifierValue() === "@mui/material") {
13
+ const namedImports = importDecl.getNamedImports();
14
+ const buttonImport = namedImports.find((ni) => ni.getName() === "Button");
15
+ if (buttonImport) {
16
+ // Remove Button from @mui/material import
17
+ buttonImport.remove();
18
+ changed = true;
19
+ // If no named imports left, remove the whole import
20
+ if (importDecl.getNamedImports().length === 0) {
21
+ importDecl.remove();
22
+ }
23
+ }
24
+ }
25
+ }
26
+ // Add Button import from @comet/admin if it was removed
27
+ if (changed) {
28
+ // Check if already imported from @comet/admin
29
+ if (cometAdminImport) {
30
+ // Add Button if not already present
31
+ if (!cometAdminImport.getNamedImports().some((ni) => ni.getName() === "Button")) {
32
+ cometAdminImport.addNamedImport("Button");
33
+ }
34
+ }
35
+ else {
36
+ sourceFile.addImportDeclaration({
37
+ moduleSpecifier: "@comet/admin",
38
+ namedImports: ["Button"],
39
+ });
40
+ }
41
+ }
42
+ if (changed) {
43
+ await sourceFile.save();
44
+ }
45
+ }
46
+ await project.save();
47
+ }
48
+ exports.default = replaceMuiButtonWithCometAdminButton;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@comet/upgrade",
3
- "version": "1.83.0",
3
+ "version": "1.85.0",
4
4
  "description": "Upgrade scripts for Comet DXP",
5
5
  "homepage": "https://github.com/vivid-planet/comet-upgrade#readme",
6
6
  "bugs": {