@comet/upgrade 1.40.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,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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@comet/upgrade",
3
- "version": "1.40.0",
3
+ "version": "1.41.0",
4
4
  "description": "Upgrade scripts for Comet DXP",
5
5
  "homepage": "https://github.com/vivid-planet/comet-upgrade#readme",
6
6
  "bugs": {