codeplay-common 1.0.41 → 1.0.43

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,9 +1,9 @@
1
1
  {
2
2
  "name": "codeplay-common",
3
- "version": "1.0.41",
3
+ "version": "1.0.43",
4
4
  "description": "Common build scripts and files",
5
5
  "scripts": {
6
- "postinstall": "node scripts/sync-files.js",
6
+
7
7
  "preinstall": "node scripts/uninstall.js"
8
8
  },
9
9
  "repository": {
@@ -12,6 +12,29 @@ if (!fs.existsSync(commonBuildPath)) {
12
12
  process.exit(0);
13
13
  }
14
14
 
15
+ // Helper function to extract version from file name
16
+ const extractVersion = (filename) => {
17
+ const match = filename.match(/-(\d+\.\d+)\.js$/);
18
+ return match ? parseFloat(match[1]) : null;
19
+ };
20
+
21
+ // Collect files that match versioned patterns
22
+ const versionedFilesMap = {};
23
+
24
+ // Scan project directory for versioned files
25
+ fs.readdirSync(projectRoot).forEach(file => {
26
+ if (file.match(/(add-splash-screen|setSplashAnimation|codeplayBeforeBuild)-\d+\.\d+\.js/)) {
27
+ const baseName = file.split('-')[0];
28
+ const version = extractVersion(file);
29
+
30
+ if (version !== null) {
31
+ if (!versionedFilesMap[baseName] || version > versionedFilesMap[baseName].version) {
32
+ versionedFilesMap[baseName] = { file, version };
33
+ }
34
+ }
35
+ }
36
+ });
37
+
15
38
  // Read the common build folder and remove copied files
16
39
  fs.readdirSync(commonBuildPath).forEach(file => {
17
40
  const destPath = path.join(projectRoot, file);
@@ -35,4 +58,18 @@ fs.readdirSync(commonBuildPath).forEach(file => {
35
58
  }
36
59
  });
37
60
 
61
+ // Remove older versions of versioned files
62
+ Object.keys(versionedFilesMap).forEach(baseName => {
63
+ fs.readdirSync(projectRoot).forEach(file => {
64
+ if (file.startsWith(baseName) && file.match(/-\d+\.\d+\.js$/)) {
65
+ const version = extractVersion(file);
66
+ if (version !== null && version < versionedFilesMap[baseName].version) {
67
+ const filePath = path.join(projectRoot, file);
68
+ fs.unlinkSync(filePath);
69
+ console.log(`🗑️ Removed old version: ${filePath}`);
70
+ }
71
+ }
72
+ });
73
+ });
74
+
38
75
  console.log("✅ Uninstall cleanup complete!");