@unisphere/nx 4.5.7 → 4.5.8
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,10 +2,9 @@
|
|
|
2
2
|
* Migration: Pre-cleanup Empty Directories
|
|
3
3
|
*
|
|
4
4
|
* This migration runs before the reorganize migrations to:
|
|
5
|
-
* 1.
|
|
6
|
-
* 2.
|
|
7
|
-
* 3.
|
|
8
|
-
* 4. Clean up any existing empty directories that might block the migration flow
|
|
5
|
+
* 1. Check Nx version is 22 or higher
|
|
6
|
+
* 2. Reset Nx cache to ensure fresh project graph
|
|
7
|
+
* 3. Clean up any existing empty directories that might block the migration flow
|
|
9
8
|
*/
|
|
10
9
|
import { Tree } from '@nx/devkit';
|
|
11
10
|
/**
|
|
@@ -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
|
|
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;;;;;;;GAOG;AAEH,OAAO,EAAE,IAAI,EAAoB,MAAM,YAAY,CAAC;AAqFpD;;GAEG;AACH,wBAA8B,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAqB9D"}
|
|
@@ -3,17 +3,14 @@
|
|
|
3
3
|
* Migration: Pre-cleanup Empty Directories
|
|
4
4
|
*
|
|
5
5
|
* This migration runs before the reorganize migrations to:
|
|
6
|
-
* 1.
|
|
7
|
-
* 2.
|
|
8
|
-
* 3.
|
|
9
|
-
* 4. Clean up any existing empty directories that might block the migration flow
|
|
6
|
+
* 1. Check Nx version is 22 or higher
|
|
7
|
+
* 2. Reset Nx cache to ensure fresh project graph
|
|
8
|
+
* 3. Clean up any existing empty directories that might block the migration flow
|
|
10
9
|
*/
|
|
11
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
11
|
exports.default = update;
|
|
13
12
|
const devkit_1 = require("@nx/devkit");
|
|
14
13
|
const child_process_1 = require("child_process");
|
|
15
|
-
const fs_1 = require("fs");
|
|
16
|
-
const path_1 = require("path");
|
|
17
14
|
/**
|
|
18
15
|
* Check that Nx version is 22 or higher
|
|
19
16
|
*/
|
|
@@ -50,39 +47,6 @@ function resetNxCache() {
|
|
|
50
47
|
devkit_1.logger.warn(' Could not reset Nx cache (this may be fine): ' + error);
|
|
51
48
|
}
|
|
52
49
|
}
|
|
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
|
-
}
|
|
86
50
|
/**
|
|
87
51
|
* Clean up empty directories in unisphere folder.
|
|
88
52
|
* Also removes directories that only contain hidden files (like .DS_Store).
|
|
@@ -127,13 +91,11 @@ async function update(tree) {
|
|
|
127
91
|
devkit_1.logger.info('Pre-cleanup: Preparing for reorganization');
|
|
128
92
|
devkit_1.logger.info('========================================');
|
|
129
93
|
devkit_1.logger.info('');
|
|
130
|
-
// Step 1:
|
|
131
|
-
removeKnownBrokenMigrations();
|
|
132
|
-
// Step 2: Check Nx version is 22 or higher
|
|
94
|
+
// Step 1: Check Nx version is 22 or higher
|
|
133
95
|
checkNxVersion(tree);
|
|
134
|
-
// Step
|
|
96
|
+
// Step 2: Reset Nx cache to ensure fresh project graph
|
|
135
97
|
resetNxCache();
|
|
136
|
-
// Step
|
|
98
|
+
// Step 3: Clean up empty directories
|
|
137
99
|
devkit_1.logger.info(' Removing empty directories...');
|
|
138
100
|
cleanupEmptyDirectories();
|
|
139
101
|
devkit_1.logger.info(' Empty directories cleaned');
|