codeplay-common 1.2.1 → 1.2.3

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.3",
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,33 @@ 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
+ /^finalrelease.*$/,
43
+ /^\.env\.storeid[1-3]$/,
44
+ /^modify-plugin-xml\.js$/
45
+ ];
46
+
47
+ const filesInProject = fs.readdirSync(projectRoot);
49
48
 
50
-
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
49
  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 };
50
+ if (filePatternsToRemove.some(pattern => pattern.test(file))) {
51
+ const filePath = path.join(projectRoot, file);
52
+ try {
53
+ fs.unlinkSync(filePath);
54
+ process.stdout.write(`🗑️ Removed file: ${filePath}\n`);
55
+ } catch (error) {
56
+ process.stderr.write(`⚠️ Failed to remove ${filePath}: ${error.message}\n`);
75
57
  }
76
58
  }
77
59
  });
78
60
 
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
61
  // Remove files listed in commonBuildPath
101
62
  if (fs.existsSync(commonBuildPath)) {
102
63
  fs.readdirSync(commonBuildPath).forEach(file => {
@@ -104,12 +65,12 @@ if (fs.existsSync(commonBuildPath)) {
104
65
  if (fs.existsSync(destPath)) {
105
66
  try {
106
67
  fs.unlinkSync(destPath);
107
- process.stdout.write(`🗑️ Removed file: ${destPath}`);
68
+ process.stdout.write(`🗑️ Removed file: ${destPath}\n`);
108
69
  } catch (error) {
109
- process.stderr.write(`⚠️ Failed to remove ${destPath}: ${error.message}`);
70
+ process.stderr.write(`⚠️ Failed to remove ${destPath}: ${error.message}\n`);
110
71
  }
111
72
  }
112
73
  });
113
74
  }
114
75
 
115
- process.stdout.write("✅ Uninstall cleanup complete!");
76
+ process.stdout.write("✅ Uninstall cleanup complete!\n");