codeplay-common 1.1.61 → 1.1.62
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 +2 -2
- package/scripts/uninstall.js +20 -90
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codeplay-common",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.62",
|
|
4
4
|
"description": "Common build scripts and files",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"
|
|
6
|
+
"preinstall": "node scripts/uninstall.js"
|
|
7
7
|
},
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
package/scripts/uninstall.js
CHANGED
|
@@ -1,34 +1,16 @@
|
|
|
1
|
-
// Define file prefixes to delete
|
|
2
|
-
const filePrefixes = [
|
|
3
|
-
"add-splash-screen",
|
|
4
|
-
"setSplashAnimation",
|
|
5
|
-
"codeplayBeforeBuild",
|
|
6
|
-
"finalrelease"
|
|
7
|
-
];
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const splashXmlPath = path.join(projectRoot, "splashxml"); // Path to splashxml folder
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
1
|
const fs = require("fs");
|
|
16
2
|
const path = require("path");
|
|
17
3
|
|
|
18
4
|
const projectRoot = path.resolve(__dirname, "../../../"); // Project root
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
process.stdout.write("🚀 Uninstalling: Removing old and copied files...");
|
|
29
|
-
|
|
30
|
-
|
|
5
|
+
const buildCodeplayPath = path.join(projectRoot, "buildCodeplay"); // Path to buildCodeplay folder
|
|
6
|
+
const filePrefixes = [
|
|
7
|
+
"add-splash-screen",
|
|
8
|
+
"setSplashAnimation",
|
|
9
|
+
"codeplayBeforeBuild",
|
|
10
|
+
"finalrelease"
|
|
11
|
+
];
|
|
31
12
|
|
|
13
|
+
// Function to remove a directory and its contents
|
|
32
14
|
const removeDirectory = (dirPath) => {
|
|
33
15
|
if (fs.existsSync(dirPath)) {
|
|
34
16
|
fs.readdirSync(dirPath).forEach(file => {
|
|
@@ -44,72 +26,20 @@ const removeDirectory = (dirPath) => {
|
|
|
44
26
|
}
|
|
45
27
|
};
|
|
46
28
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
// Helper function to get base name without version
|
|
59
|
-
const getBaseName = (filename) => filename.replace(/-\d+\.\d+\.js$/, "");
|
|
60
|
-
|
|
61
|
-
// Step 1: Find all versioned files in the project directory
|
|
62
|
-
const filesInProject = fs.readdirSync(projectRoot)
|
|
63
|
-
.filter(file => file.match(/(add-splash-screen-|setSplashAnimation-|codeplayBeforeBuild-)-\d+\.\d+\.js/));
|
|
64
|
-
|
|
65
|
-
const latestVersions = {};
|
|
66
|
-
|
|
67
|
-
// Step 2: Determine the latest version for each file type
|
|
68
|
-
filesInProject.forEach(file => {
|
|
69
|
-
const baseName = getBaseName(file);
|
|
70
|
-
const version = extractVersion(file);
|
|
71
|
-
|
|
72
|
-
if (version !== null) {
|
|
73
|
-
if (!latestVersions[baseName] || version > latestVersions[baseName].version) {
|
|
74
|
-
latestVersions[baseName] = { file, version };
|
|
29
|
+
// Remove specific files from project root
|
|
30
|
+
fs.readdirSync(projectRoot).forEach(file => {
|
|
31
|
+
if (filePrefixes.some(prefix => file.startsWith(prefix))) {
|
|
32
|
+
const filePath = path.join(projectRoot, file);
|
|
33
|
+
try {
|
|
34
|
+
fs.unlinkSync(filePath);
|
|
35
|
+
process.stdout.write(`🗑️ Removed file: ${filePath}\n`);
|
|
36
|
+
} catch (error) {
|
|
37
|
+
process.stderr.write(`⚠️ Failed to remove ${filePath}: ${error.message}\n`);
|
|
75
38
|
}
|
|
76
39
|
}
|
|
77
40
|
});
|
|
78
41
|
|
|
42
|
+
// Remove all contents of buildCodeplay and delete the folder
|
|
43
|
+
removeDirectory(buildCodeplayPath);
|
|
79
44
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
// Step 1: Find all matching files in the project directory
|
|
83
|
-
const filesInProject1 = fs.readdirSync(projectRoot)
|
|
84
|
-
.filter(file => filePrefixes.some(prefix => file.startsWith(prefix)));
|
|
85
|
-
|
|
86
|
-
filesInProject1.forEach(file => {
|
|
87
|
-
const filePath = path.join(projectRoot, file);
|
|
88
|
-
try {
|
|
89
|
-
fs.unlinkSync(filePath);
|
|
90
|
-
process.stdout.write(`🗑️ Removed file: ${filePath}`);
|
|
91
|
-
} catch (error) {
|
|
92
|
-
process.stderr.write(`⚠️ Failed to remove ${filePath}: ${error.message}`);
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
// Remove files listed in commonBuildPath
|
|
101
|
-
if (fs.existsSync(commonBuildPath)) {
|
|
102
|
-
fs.readdirSync(commonBuildPath).forEach(file => {
|
|
103
|
-
const destPath = path.join(projectRoot, file);
|
|
104
|
-
if (fs.existsSync(destPath)) {
|
|
105
|
-
try {
|
|
106
|
-
fs.unlinkSync(destPath);
|
|
107
|
-
process.stdout.write(`🗑️ Removed file: ${destPath}`);
|
|
108
|
-
} catch (error) {
|
|
109
|
-
process.stderr.write(`⚠️ Failed to remove ${destPath}: ${error.message}`);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
process.stdout.write("✅ Uninstall cleanup complete!");
|
|
45
|
+
process.stdout.write("✅ Uninstall cleanup complete!\n");
|