@unisphere/nx 4.5.5 → 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.
|
|
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;
|
|
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,19 +3,17 @@
|
|
|
3
3
|
* Migration: Pre-cleanup Empty Directories
|
|
4
4
|
*
|
|
5
5
|
* This migration runs before the reorganize migrations to:
|
|
6
|
-
* 1.
|
|
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". Patching here covers all migrations that run after this one.
|
|
16
|
-
require('chalk').__esModule = true;
|
|
17
13
|
const devkit_1 = require("@nx/devkit");
|
|
18
14
|
const child_process_1 = require("child_process");
|
|
15
|
+
const fs_1 = require("fs");
|
|
16
|
+
const path_1 = require("path");
|
|
19
17
|
/**
|
|
20
18
|
* Check that Nx version is 22 or higher
|
|
21
19
|
*/
|
|
@@ -52,6 +50,39 @@ function resetNxCache() {
|
|
|
52
50
|
devkit_1.logger.warn(' Could not reset Nx cache (this may be fine): ' + error);
|
|
53
51
|
}
|
|
54
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
|
+
}
|
|
55
86
|
/**
|
|
56
87
|
* Clean up empty directories in unisphere folder.
|
|
57
88
|
* Also removes directories that only contain hidden files (like .DS_Store).
|
|
@@ -96,11 +127,13 @@ async function update(tree) {
|
|
|
96
127
|
devkit_1.logger.info('Pre-cleanup: Preparing for reorganization');
|
|
97
128
|
devkit_1.logger.info('========================================');
|
|
98
129
|
devkit_1.logger.info('');
|
|
99
|
-
// Step 1:
|
|
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
|
|
100
133
|
checkNxVersion(tree);
|
|
101
|
-
// Step
|
|
134
|
+
// Step 3: Reset Nx cache to ensure fresh project graph
|
|
102
135
|
resetNxCache();
|
|
103
|
-
// Step
|
|
136
|
+
// Step 4: Clean up empty directories
|
|
104
137
|
devkit_1.logger.info(' Removing empty directories...');
|
|
105
138
|
cleanupEmptyDirectories();
|
|
106
139
|
devkit_1.logger.info(' Empty directories cleaned');
|