@comet/upgrade 1.15.0 → 1.17.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.
package/lib/index.js CHANGED
@@ -50,9 +50,15 @@ function main() {
50
50
  console.error("Missing target version! Usage: npx @comet/upgrade <version>");
51
51
  process.exit(-1);
52
52
  }
53
- const isUpgradeScript = fs_1.default.existsSync(path_1.default.join(__dirname, targetVersionArg.replace(/\.ts$/, ".js")));
53
+ const isUpgradeScript = targetVersionArg.endsWith(".ts");
54
54
  if (isUpgradeScript) {
55
- yield runUpgradeScript(targetVersionArg.replace(/\.ts$/, ".js"));
55
+ if (fs_1.default.existsSync(path_1.default.join(__dirname, targetVersionArg.replace(/\.ts$/, ".js")))) {
56
+ yield runUpgradeScript(targetVersionArg.replace(/\.ts$/, ".js"));
57
+ }
58
+ else {
59
+ console.error(`Can't find upgrade script '${targetVersionArg}'`);
60
+ process.exit(-1);
61
+ }
56
62
  return;
57
63
  }
58
64
  const targetVersion = semver_1.default.coerce(targetVersionArg, { includePrerelease: true });
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const promises_1 = require("fs/promises");
13
+ const glob_1 = require("glob");
14
+ const ts_morph_1 = require("ts-morph");
15
+ /**
16
+ * Replaces the import of `GridColDef` from `@mui/x-data-grid*` with `GridColDef` from `@comet/admin`.
17
+ */
18
+ function replaceGridColDefImport() {
19
+ var _a;
20
+ return __awaiter(this, void 0, void 0, function* () {
21
+ const files = glob_1.glob.sync(["admin/src/**/*.ts", "admin/src/**/*.tsx"]);
22
+ const project = new ts_morph_1.Project({ tsConfigFilePath: "./admin/tsconfig.json" });
23
+ for (const filePath of files) {
24
+ const fileContent = (yield (0, promises_1.readFile)(filePath)).toString();
25
+ if (!fileContent.includes("GridColDef")) {
26
+ continue;
27
+ }
28
+ const sourceFile = project.getSourceFile(filePath);
29
+ if (!sourceFile) {
30
+ throw new Error(`Can't get source file for ${filePath}`);
31
+ }
32
+ const dataGridImport = sourceFile.getImportDeclaration((declaration) => declaration.getModuleSpecifierValue().includes("@mui/x-data-grid"));
33
+ if (!dataGridImport) {
34
+ continue;
35
+ }
36
+ (_a = dataGridImport
37
+ .getNamedImports()
38
+ .find((namedImport) => namedImport.getText() === "GridColDef")) === null || _a === void 0 ? void 0 : _a.remove();
39
+ sourceFile.addImportDeclaration({
40
+ namedImports: ["GridColDef"],
41
+ moduleSpecifier: "@comet/admin",
42
+ });
43
+ sourceFile.saveSync();
44
+ }
45
+ });
46
+ }
47
+ exports.default = replaceGridColDefImport;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@comet/upgrade",
3
- "version": "1.15.0",
3
+ "version": "1.17.0",
4
4
  "description": "Upgrade scripts for Comet DXP",
5
5
  "homepage": "https://github.com/vivid-planet/comet-upgrade#readme",
6
6
  "bugs": {