codeplay-common 1.0.42 → 1.0.44
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/package.json +1 -1
- package/scripts/uninstall.js +42 -13
package/package.json
CHANGED
package/scripts/uninstall.js
CHANGED
|
@@ -9,29 +9,58 @@ console.log("🚀 Uninstalling: Removing copied files...");
|
|
|
9
9
|
// Check if commonBuildPath exists
|
|
10
10
|
if (!fs.existsSync(commonBuildPath)) {
|
|
11
11
|
console.warn("⚠️ Common build path does not exist, skipping removal.");
|
|
12
|
-
process.exit(0);
|
|
13
12
|
}
|
|
14
13
|
|
|
15
|
-
//
|
|
14
|
+
// Helper function to extract version from filename
|
|
15
|
+
const extractVersion = (filename) => {
|
|
16
|
+
const match = filename.match(/-(\d+\.\d+)\.js$/);
|
|
17
|
+
return match ? parseFloat(match[1]) : null;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
// Helper function to get base name of versioned files
|
|
21
|
+
const getBaseName = (filename) => {
|
|
22
|
+
return filename.replace(/-\d+\.\d+\.js$/, "");
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// Find versioned files in the project directory
|
|
26
|
+
const versionedFiles = fs.readdirSync(projectRoot)
|
|
27
|
+
.filter(file => file.match(/(add-splash-screen|setSplashAnimation|codeplayBeforeBuild)-\d+\.\d+\.js/));
|
|
28
|
+
|
|
29
|
+
const latestVersions = {};
|
|
30
|
+
|
|
31
|
+
// Group files by their base name and track latest versions
|
|
32
|
+
versionedFiles.forEach(file => {
|
|
33
|
+
const baseName = getBaseName(file);
|
|
34
|
+
const version = extractVersion(file);
|
|
35
|
+
|
|
36
|
+
if (version !== null) {
|
|
37
|
+
if (!latestVersions[baseName] || version > latestVersions[baseName].version) {
|
|
38
|
+
latestVersions[baseName] = { file, version };
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// Remove older versions
|
|
44
|
+
versionedFiles.forEach(file => {
|
|
45
|
+
const baseName = getBaseName(file);
|
|
46
|
+
if (latestVersions[baseName] && file !== latestVersions[baseName].file) {
|
|
47
|
+
const filePath = path.join(projectRoot, file);
|
|
48
|
+
fs.unlinkSync(filePath);
|
|
49
|
+
console.log(`🗑️ Removed old version: ${filePath}`);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// Remove files listed in commonBuildPath
|
|
16
54
|
fs.readdirSync(commonBuildPath).forEach(file => {
|
|
17
55
|
const destPath = path.join(projectRoot, file);
|
|
18
56
|
|
|
19
57
|
if (fs.existsSync(destPath)) {
|
|
20
58
|
try {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (stats.isDirectory()) {
|
|
24
|
-
fs.rmSync(destPath, { recursive: true, force: true });
|
|
25
|
-
console.log(`🗑️ Removed folder: ${destPath}`);
|
|
26
|
-
} else {
|
|
27
|
-
fs.unlinkSync(destPath);
|
|
28
|
-
console.log(`🗑️ Removed file: ${destPath}`);
|
|
29
|
-
}
|
|
59
|
+
fs.unlinkSync(destPath);
|
|
60
|
+
console.log(`🗑️ Removed file: ${destPath}`);
|
|
30
61
|
} catch (error) {
|
|
31
62
|
console.warn(`⚠️ Failed to remove ${destPath}: ${error.message}`);
|
|
32
63
|
}
|
|
33
|
-
} else {
|
|
34
|
-
console.log(`✅ Already removed: ${destPath}`);
|
|
35
64
|
}
|
|
36
65
|
});
|
|
37
66
|
|