codeplay-common 1.2.1 → 1.2.2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeplay-common",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "Common build scripts and files",
5
5
  "scripts": {
6
6
  "postinstall": "node scripts/sync-files.js",
@@ -1,33 +1,19 @@
1
1
  // Define file prefixes to delete
2
2
  const filePrefixes = [
3
- "add-splash-screen",
4
- "setSplashAnimation",
5
- "codeplayBeforeBuild",
6
- "finalrelease"
7
- ];
8
-
9
-
10
-
11
-
12
-
13
-
3
+ "add-splash-screen",
4
+ "setSplashAnimation",
5
+ "codeplayBeforeBuild",
6
+ "finalrelease"
7
+ ];
14
8
 
15
9
  const fs = require("fs");
16
10
  const path = require("path");
17
11
 
18
12
  const projectRoot = path.resolve(__dirname, "../../../"); // Project root
19
13
  const commonBuildPath = path.join(__dirname, "../files"); // Path where files were copied from
20
-
21
-
22
-
23
-
24
14
  const splashXmlPath = path.join(projectRoot, "buildCodeplay"); // Path to splashxml folder
25
15
 
26
-
27
-
28
- process.stdout.write("🚀 Uninstalling: Removing old and copied files...");
29
-
30
-
16
+ process.stdout.write("🚀 Uninstalling: Removing old and copied files...\n");
31
17
 
32
18
  const removeDirectory = (dirPath) => {
33
19
  if (fs.existsSync(dirPath)) {
@@ -45,58 +31,30 @@ const removeDirectory = (dirPath) => {
45
31
  };
46
32
 
47
33
  removeDirectory(splashXmlPath);
34
+ removeDirectory(path.join(projectRoot, "splashxml")); // Remove old splashxml folder
48
35
 
36
+ // Step 1: Find all matching files in the project directory
37
+ const filePatternsToRemove = [
38
+ /^add-splash-screen-.*$/,
39
+ /^setSplashAnimation-.*$/,
40
+ /^codeplayBeforeBuild-.*$/,
41
+ /^modify-plugin-xml\.xml$/
42
+ ];
49
43
 
44
+ const filesInProject = fs.readdirSync(projectRoot);
50
45
 
51
-
52
- // Helper function to extract version from filename
53
- const extractVersion = (filename) => {
54
- const match = filename.match(/-(\d+\.\d+)\.js$/);
55
- return match ? parseFloat(match[1]) : null;
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
46
  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 };
47
+ if (filePatternsToRemove.some(pattern => pattern.test(file))) {
48
+ const filePath = path.join(projectRoot, file);
49
+ try {
50
+ fs.unlinkSync(filePath);
51
+ process.stdout.write(`🗑️ Removed file: ${filePath}\n`);
52
+ } catch (error) {
53
+ process.stderr.write(`⚠️ Failed to remove ${filePath}: ${error.message}\n`);
75
54
  }
76
55
  }
77
56
  });
78
57
 
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
58
  // Remove files listed in commonBuildPath
101
59
  if (fs.existsSync(commonBuildPath)) {
102
60
  fs.readdirSync(commonBuildPath).forEach(file => {
@@ -104,12 +62,12 @@ if (fs.existsSync(commonBuildPath)) {
104
62
  if (fs.existsSync(destPath)) {
105
63
  try {
106
64
  fs.unlinkSync(destPath);
107
- process.stdout.write(`🗑️ Removed file: ${destPath}`);
65
+ process.stdout.write(`🗑️ Removed file: ${destPath}\n`);
108
66
  } catch (error) {
109
- process.stderr.write(`⚠️ Failed to remove ${destPath}: ${error.message}`);
67
+ process.stderr.write(`⚠️ Failed to remove ${destPath}: ${error.message}\n`);
110
68
  }
111
69
  }
112
70
  });
113
71
  }
114
72
 
115
- process.stdout.write("✅ Uninstall cleanup complete!");
73
+ process.stdout.write("✅ Uninstall cleanup complete!\n");