@unisphere/nx 4.5.6 → 4.5.7

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.
@@ -2,7 +2,7 @@
2
2
  * Migration: Pre-cleanup Empty Directories
3
3
  *
4
4
  * This migration runs before the reorganize migrations to:
5
- * 1. Hook Module._load to patch chalk for tslib >=2.8 compatibility (covers all subsequent migrations regardless of resolution path)
5
+ * 1. Remove known-broken third-party migrations from migrations.json
6
6
  * 2. Check Nx version is 22 or higher
7
7
  * 3. Reset Nx cache to ensure fresh project graph
8
8
  * 4. Clean up any existing empty directories that might block the migration flow
@@ -1 +1 @@
1
- {"version":3,"file":"pre-cleanup-empty-directories.d.ts","sourceRoot":"","sources":["../../../src/migrations/3-0-0/pre-cleanup-empty-directories.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAgBH,OAAO,EAAE,IAAI,EAAoB,MAAM,YAAY,CAAC;AAqFpD;;GAEG;AACH,wBAA8B,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAqB9D"}
1
+ {"version":3,"file":"pre-cleanup-empty-directories.d.ts","sourceRoot":"","sources":["../../../src/migrations/3-0-0/pre-cleanup-empty-directories.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,IAAI,EAAoB,MAAM,YAAY,CAAC;AA2HpD;;GAEG;AACH,wBAA8B,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAwB9D"}
@@ -3,28 +3,17 @@
3
3
  * Migration: Pre-cleanup Empty Directories
4
4
  *
5
5
  * This migration runs before the reorganize migrations to:
6
- * 1. Hook Module._load to patch chalk for tslib >=2.8 compatibility (covers all subsequent migrations regardless of resolution path)
6
+ * 1. Remove known-broken third-party migrations from migrations.json
7
7
  * 2. Check Nx version is 22 or higher
8
8
  * 3. Reset Nx cache to ensure fresh project graph
9
9
  * 4. Clean up any existing empty directories that might block the migration flow
10
10
  */
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.default = update;
13
- // Global workaround: tslib >=2.8 __importStar no longer sets __esModule on CJS modules,
14
- // causing chalk (used by @nx/workspace, @nx/jest, etc.) to crash with "Cannot read
15
- // properties of undefined". Hook Module._load to patch every chalk require regardless
16
- // of resolution path (nested node_modules, different packages, etc.).
17
- const Module = require('module');
18
- const originalLoad = Module._load;
19
- Module._load = function (request, parent, isMain) {
20
- const result = originalLoad.apply(this, arguments);
21
- if (request === 'chalk' && result && typeof result === 'object') {
22
- result.__esModule = true;
23
- }
24
- return result;
25
- };
26
13
  const devkit_1 = require("@nx/devkit");
27
14
  const child_process_1 = require("child_process");
15
+ const fs_1 = require("fs");
16
+ const path_1 = require("path");
28
17
  /**
29
18
  * Check that Nx version is 22 or higher
30
19
  */
@@ -61,6 +50,39 @@ function resetNxCache() {
61
50
  devkit_1.logger.warn(' Could not reset Nx cache (this may be fine): ' + error);
62
51
  }
63
52
  }
53
+ /**
54
+ * Remove known-broken third-party migrations from migrations.json.
55
+ * These migrations crash due to chalk/tslib >=2.8 incompatibility and cannot
56
+ * be fixed from our side. They are low-value (e.g., renaming deprecated Jest
57
+ * matcher aliases) and safe to skip.
58
+ */
59
+ const BROKEN_MIGRATIONS = [
60
+ 'replace-removed-matcher-aliases-v22-3',
61
+ ];
62
+ function removeKnownBrokenMigrations() {
63
+ const migrationsPath = (0, path_1.join)(process.cwd(), 'migrations.json');
64
+ if (!(0, fs_1.existsSync)(migrationsPath))
65
+ return;
66
+ try {
67
+ const content = (0, fs_1.readFileSync)(migrationsPath, 'utf-8');
68
+ const migrations = JSON.parse(content);
69
+ if (!migrations.migrations)
70
+ return;
71
+ const original = Object.keys(migrations.migrations);
72
+ for (const name of BROKEN_MIGRATIONS) {
73
+ if (migrations.migrations[name]) {
74
+ delete migrations.migrations[name];
75
+ devkit_1.logger.info(` Removed known-broken migration: ${name}`);
76
+ }
77
+ }
78
+ if (Object.keys(migrations.migrations).length < original.length) {
79
+ (0, fs_1.writeFileSync)(migrationsPath, JSON.stringify(migrations, null, 2) + '\n');
80
+ }
81
+ }
82
+ catch (error) {
83
+ devkit_1.logger.warn(' Could not process migrations.json: ' + error);
84
+ }
85
+ }
64
86
  /**
65
87
  * Clean up empty directories in unisphere folder.
66
88
  * Also removes directories that only contain hidden files (like .DS_Store).
@@ -105,11 +127,13 @@ async function update(tree) {
105
127
  devkit_1.logger.info('Pre-cleanup: Preparing for reorganization');
106
128
  devkit_1.logger.info('========================================');
107
129
  devkit_1.logger.info('');
108
- // Step 1: Check Nx version is 22 or higher
130
+ // Step 1: Remove known-broken migrations that crash due to chalk/tslib incompatibility
131
+ removeKnownBrokenMigrations();
132
+ // Step 2: Check Nx version is 22 or higher
109
133
  checkNxVersion(tree);
110
- // Step 2: Reset Nx cache to ensure fresh project graph
134
+ // Step 3: Reset Nx cache to ensure fresh project graph
111
135
  resetNxCache();
112
- // Step 3: Clean up empty directories
136
+ // Step 4: Clean up empty directories
113
137
  devkit_1.logger.info(' Removing empty directories...');
114
138
  cleanupEmptyDirectories();
115
139
  devkit_1.logger.info(' Empty directories cleaned');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unisphere/nx",
3
- "version": "4.5.6",
3
+ "version": "4.5.7",
4
4
  "private": false,
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",