codeplay-common 1.0.19 → 1.0.21

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,10 +1,11 @@
1
1
  {
2
2
  "name": "codeplay-common",
3
- "version": "1.0.19",
3
+ "version": "1.0.21",
4
4
  "description": "Common build scripts and files",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
- "postinstall": "node scripts/sync-files.js"
7
+ "postinstall": "node scripts/sync-files.js",
8
+ "preuninstall": "node scripts/remove-files.js"
8
9
  },
9
10
  "repository": {
10
11
  "type": "git",
@@ -0,0 +1,38 @@
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+
4
+ const projectRoot = path.resolve(__dirname, "../../../"); // Project root
5
+ const commonBuildPath = path.join(__dirname, "../files"); // Path where files were copied from
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
+ process.exit(0);
13
+ }
14
+
15
+ // Read the common build folder and remove copied files
16
+ fs.readdirSync(commonBuildPath).forEach(file => {
17
+ const destPath = path.join(projectRoot, file);
18
+
19
+ if (fs.existsSync(destPath)) {
20
+ try {
21
+ const stats = fs.statSync(destPath);
22
+
23
+ if (stats.isDirectory()) {
24
+ fs.rmSync(destPath, { recursive: true, force: true });
25
+ console.log(`🗑️ Removed folder: ${destPath}`);
26
+ } else {
27
+ fs.unlinkSync(destPath);
28
+ console.log(`🗑️ Removed file: ${destPath}`);
29
+ }
30
+ } catch (error) {
31
+ console.warn(`⚠️ Failed to remove ${destPath}: ${error.message}`);
32
+ }
33
+ } else {
34
+ console.log(`✅ Already removed: ${destPath}`);
35
+ }
36
+ });
37
+
38
+ console.log("✅ Uninstall cleanup complete!");