codeplay-common 1.0.44 → 1.0.45

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.0.44",
3
+ "version": "1.0.45",
4
4
  "description": "Common build scripts and files",
5
5
  "scripts": {
6
6
 
@@ -4,49 +4,55 @@ const path = require("path");
4
4
  const projectRoot = path.resolve(__dirname, "../../../"); // Project root
5
5
  const commonBuildPath = path.join(__dirname, "../files"); // Path where files were copied from
6
6
 
7
- console.log("🚀 Uninstalling: Removing copied files...");
7
+ console.log("🚀 Uninstalling: Removing old and copied files...");
8
8
 
9
9
  // Check if commonBuildPath exists
10
10
  if (!fs.existsSync(commonBuildPath)) {
11
11
  console.warn("⚠️ Common build path does not exist, skipping removal.");
12
12
  }
13
13
 
14
- // Helper function to extract version from filename
14
+ // Helper function to extract version from file name
15
15
  const extractVersion = (filename) => {
16
16
  const match = filename.match(/-(\d+\.\d+)\.js$/);
17
17
  return match ? parseFloat(match[1]) : null;
18
18
  };
19
19
 
20
- // Helper function to get base name of versioned files
20
+ // Helper function to get base name (without version and extension)
21
21
  const getBaseName = (filename) => {
22
22
  return filename.replace(/-\d+\.\d+\.js$/, "");
23
23
  };
24
24
 
25
- // Find versioned files in the project directory
26
- const versionedFiles = fs.readdirSync(projectRoot)
27
- .filter(file => file.match(/(add-splash-screen|setSplashAnimation|codeplayBeforeBuild)-\d+\.\d+\.js/));
28
-
25
+ // Store latest versions for each file category
29
26
  const latestVersions = {};
30
27
 
31
- // Group files by their base name and track latest versions
32
- versionedFiles.forEach(file => {
33
- const baseName = getBaseName(file);
34
- const version = extractVersion(file);
28
+ // Scan project directory for versioned files
29
+ fs.readdirSync(projectRoot).forEach(file => {
30
+ if (file.match(/(add-splash-screen|setSplashAnimation|codeplayBeforeBuild)-\d+\.\d+\.js/)) {
31
+ const baseName = getBaseName(file);
32
+ const version = extractVersion(file);
35
33
 
36
- if (version !== null) {
37
- if (!latestVersions[baseName] || version > latestVersions[baseName].version) {
38
- latestVersions[baseName] = { file, version };
34
+ if (version !== null) {
35
+ // Store the latest version found
36
+ if (!latestVersions[baseName] || version > latestVersions[baseName].version) {
37
+ latestVersions[baseName] = { file, version };
38
+ }
39
39
  }
40
40
  }
41
41
  });
42
42
 
43
- // Remove older versions
44
- versionedFiles.forEach(file => {
43
+ // Remove all outdated versions
44
+ fs.readdirSync(projectRoot).forEach(file => {
45
45
  const baseName = getBaseName(file);
46
- if (latestVersions[baseName] && file !== latestVersions[baseName].file) {
46
+ const version = extractVersion(file);
47
+
48
+ if (version !== null && latestVersions[baseName] && file !== latestVersions[baseName].file) {
47
49
  const filePath = path.join(projectRoot, file);
48
- fs.unlinkSync(filePath);
49
- console.log(`🗑️ Removed old version: ${filePath}`);
50
+ try {
51
+ fs.unlinkSync(filePath);
52
+ console.log(`🗑️ Removed old version: ${filePath}`);
53
+ } catch (error) {
54
+ console.warn(`⚠️ Failed to remove ${filePath}: ${error.message}`);
55
+ }
50
56
  }
51
57
  });
52
58