codeplay-common 1.1.61 → 1.1.63
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 +28 -82
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codeplay-common",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.63",
|
|
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,17 @@
|
|
|
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 commonBuildPath = path.join(__dirname, "../files"); // Source folder (files to be copied)
|
|
7
|
+
const filePrefixes = [
|
|
8
|
+
"add-splash-screen",
|
|
9
|
+
"setSplashAnimation",
|
|
10
|
+
"codeplayBeforeBuild",
|
|
11
|
+
"finalrelease"
|
|
12
|
+
];
|
|
31
13
|
|
|
14
|
+
// Function to remove a directory and its contents
|
|
32
15
|
const removeDirectory = (dirPath) => {
|
|
33
16
|
if (fs.existsSync(dirPath)) {
|
|
34
17
|
fs.readdirSync(dirPath).forEach(file => {
|
|
@@ -44,72 +27,35 @@ const removeDirectory = (dirPath) => {
|
|
|
44
27
|
}
|
|
45
28
|
};
|
|
46
29
|
|
|
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 };
|
|
30
|
+
// Remove specific files from project root
|
|
31
|
+
fs.readdirSync(projectRoot).forEach(file => {
|
|
32
|
+
if (filePrefixes.some(prefix => file.startsWith(prefix))) {
|
|
33
|
+
const filePath = path.join(projectRoot, file);
|
|
34
|
+
try {
|
|
35
|
+
fs.unlinkSync(filePath);
|
|
36
|
+
process.stdout.write(`🗑️ Removed file: ${filePath}\n`);
|
|
37
|
+
} catch (error) {
|
|
38
|
+
process.stderr.write(`⚠️ Failed to remove ${filePath}: ${error.message}\n`);
|
|
75
39
|
}
|
|
76
40
|
}
|
|
77
41
|
});
|
|
78
42
|
|
|
79
|
-
|
|
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
|
|
43
|
+
// Remove all files that were copied from commonBuildPath/files
|
|
101
44
|
if (fs.existsSync(commonBuildPath)) {
|
|
102
45
|
fs.readdirSync(commonBuildPath).forEach(file => {
|
|
103
|
-
const
|
|
104
|
-
if (fs.existsSync(
|
|
46
|
+
const projectFilePath = path.join(projectRoot, file);
|
|
47
|
+
if (fs.existsSync(projectFilePath)) {
|
|
105
48
|
try {
|
|
106
|
-
fs.unlinkSync(
|
|
107
|
-
process.stdout.write(`🗑️ Removed file: ${
|
|
49
|
+
fs.unlinkSync(projectFilePath);
|
|
50
|
+
process.stdout.write(`🗑️ Removed copied file: ${projectFilePath}\n`);
|
|
108
51
|
} catch (error) {
|
|
109
|
-
process.stderr.write(`⚠️ Failed to remove ${
|
|
52
|
+
process.stderr.write(`⚠️ Failed to remove ${projectFilePath}: ${error.message}\n`);
|
|
110
53
|
}
|
|
111
54
|
}
|
|
112
55
|
});
|
|
113
56
|
}
|
|
114
57
|
|
|
115
|
-
|
|
58
|
+
// Remove all contents of buildCodeplay and delete the folder
|
|
59
|
+
removeDirectory(buildCodeplayPath);
|
|
60
|
+
|
|
61
|
+
process.stdout.write("✅ Uninstall cleanup complete!\n");
|