codeplay-common 1.0.44 → 1.0.45
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 +25 -19
package/package.json
CHANGED
package/scripts/uninstall.js
CHANGED
|
@@ -4,49 +4,55 @@ const path = require("path");
|
|
|
4
4
|
const projectRoot = path.resolve(__dirname, "../../../"); // Project root
|
|
5
5
|
const commonBuildPath = path.join(__dirname, "../files"); // Path where files were copied from
|
|
6
6
|
|
|
7
|
-
console.log("🚀 Uninstalling: Removing copied files...");
|
|
7
|
+
console.log("🚀 Uninstalling: Removing old and copied files...");
|
|
8
8
|
|
|
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
12
|
}
|
|
13
13
|
|
|
14
|
-
// Helper function to extract version from
|
|
14
|
+
// Helper function to extract version from file name
|
|
15
15
|
const extractVersion = (filename) => {
|
|
16
16
|
const match = filename.match(/-(\d+\.\d+)\.js$/);
|
|
17
17
|
return match ? parseFloat(match[1]) : null;
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
// Helper function to get base name
|
|
20
|
+
// Helper function to get base name (without version and extension)
|
|
21
21
|
const getBaseName = (filename) => {
|
|
22
22
|
return filename.replace(/-\d+\.\d+\.js$/, "");
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
//
|
|
26
|
-
const versionedFiles = fs.readdirSync(projectRoot)
|
|
27
|
-
.filter(file => file.match(/(add-splash-screen|setSplashAnimation|codeplayBeforeBuild)-\d+\.\d+\.js/));
|
|
28
|
-
|
|
25
|
+
// Store latest versions for each file category
|
|
29
26
|
const latestVersions = {};
|
|
30
27
|
|
|
31
|
-
//
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
// Scan project directory for versioned files
|
|
29
|
+
fs.readdirSync(projectRoot).forEach(file => {
|
|
30
|
+
if (file.match(/(add-splash-screen|setSplashAnimation|codeplayBeforeBuild)-\d+\.\d+\.js/)) {
|
|
31
|
+
const baseName = getBaseName(file);
|
|
32
|
+
const version = extractVersion(file);
|
|
35
33
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
latestVersions[baseName]
|
|
34
|
+
if (version !== null) {
|
|
35
|
+
// Store the latest version found
|
|
36
|
+
if (!latestVersions[baseName] || version > latestVersions[baseName].version) {
|
|
37
|
+
latestVersions[baseName] = { file, version };
|
|
38
|
+
}
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
42
|
|
|
43
|
-
// Remove
|
|
44
|
-
|
|
43
|
+
// Remove all outdated versions
|
|
44
|
+
fs.readdirSync(projectRoot).forEach(file => {
|
|
45
45
|
const baseName = getBaseName(file);
|
|
46
|
-
|
|
46
|
+
const version = extractVersion(file);
|
|
47
|
+
|
|
48
|
+
if (version !== null && latestVersions[baseName] && file !== latestVersions[baseName].file) {
|
|
47
49
|
const filePath = path.join(projectRoot, file);
|
|
48
|
-
|
|
49
|
-
|
|
50
|
+
try {
|
|
51
|
+
fs.unlinkSync(filePath);
|
|
52
|
+
console.log(`🗑️ Removed old version: ${filePath}`);
|
|
53
|
+
} catch (error) {
|
|
54
|
+
console.warn(`⚠️ Failed to remove ${filePath}: ${error.message}`);
|
|
55
|
+
}
|
|
50
56
|
}
|
|
51
57
|
});
|
|
52
58
|
|