codeplay-common 1.0.44 → 1.0.46

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