codeplay-common 2.0.5 → 2.0.7

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.
@@ -339,7 +339,7 @@ for (let scanPath of SCAN_PATHS) {
339
339
  fs.writeFileSync(ANDROID_MANIFEST_PATH, manifestContent, 'utf8');
340
340
  console.log("✅ android:requestLegacyExternalStorage=\"true\" added successfully.");
341
341
  } else {
342
- console.log("ℹ️ android:requestLegacyExternalStorage already exists in AndroidManifest.xml.");
342
+ console.log("ℹ️ android:requestLegacyExternalStorage already exists in AndroidManifest.xml.");
343
343
  }
344
344
  } else {
345
345
  console.log("✅ No Android saveToGalleryAndSaveAnyFile imports detected.");
@@ -535,7 +535,7 @@ if (fileContent.includes(oldCodeStart)) {
535
535
  fileContent = fileContent.replace(oldCodeStart, newCode);
536
536
  updated = true;
537
537
  } else if (fileContent.includes(newCode)) {
538
- console.log('ℹ️ Method already updated. No changes needed in "BridgeWebViewClient.java".');
538
+ console.log('ℹ️ Method already updated. No changes needed in "BridgeWebViewClient.java".');
539
539
  } else {
540
540
  console.error('❌ Error: Neither old nor new code found. Unexpected content.');
541
541
  process.exit(1);
@@ -558,7 +558,7 @@ if (!fileContent.includes(importToast)) {
558
558
  process.exit(1);
559
559
  }
560
560
  } else {
561
- console.log('ℹ️ Import for Toast already exists. No changes needed.');
561
+ console.log('ℹ️ Import for Toast already exists. No changes needed.');
562
562
  }
563
563
 
564
564
  // Step 3: Save if updated
@@ -566,7 +566,7 @@ if (updated) {
566
566
  fs.writeFileSync(bridgeWebViewClientFilePath, fileContent, 'utf8');
567
567
  console.log('✅ File updated successfully.');
568
568
  } else {
569
- console.log('ℹ️ No changes needed.');
569
+ console.log('ℹ️ No changes needed.');
570
570
  }
571
571
 
572
572
 
@@ -982,68 +982,80 @@ checkPlugins();
982
982
 
983
983
 
984
984
 
985
-
986
-
987
985
  // ====================================================================
988
- // AUTO-ADD esbuild.drop: ['console','debugger'] to vite.config.js
986
+ // AUTO-ADD esbuild.drop: ['console','debugger'] to vite.config.js / mjs
989
987
  // ====================================================================
990
- const checkAndupdateDropInViteConfig=()=>{
991
- const viteConfigPath = path.join(process.cwd(), "vite.config.js");
992
988
 
993
- if (fs.existsSync(viteConfigPath)) {
994
- let viteContent = fs.readFileSync(viteConfigPath, "utf8");
995
989
 
996
- // If drop already exists → skip
997
- if (/drop\s*:\s*\[.*['"]console['"].*\]/.test(viteContent)) {
998
- console.log("ℹ️ esbuild.drop already exists. Skipping.");
999
- } else {
1000
- console.log("🔧 Adding aligned esbuild.drop to vite.config.js ...");
1001
-
1002
- // If esbuild block exists
1003
- if (/esbuild\s*:\s*{/.test(viteContent)) {
1004
- viteContent = viteContent.replace(
1005
- /esbuild\s*:\s*{([\s\S]*?)(^ {0,8})}/m,
1006
- (full, inner, indent) => {
1007
- // Split & clean lines
1008
- let lines = inner
1009
- .split("\n")
1010
- .map(l => l.trim())
1011
- .filter(l => l.length > 0);
1012
-
1013
- // Fix the last property: remove extra commas then add 1 comma
1014
- if (lines.length > 0) {
1015
- lines[lines.length - 1] =
1016
- lines[lines.length - 1].replace(/,+$/, "") + ",";
1017
- }
1018
990
 
1019
- // Re-indent correctly
1020
- lines = lines.map(l => indent + " " + l);
991
+ const checkAndupdateDropInViteConfig = () => {
1021
992
 
1022
- // Insert drop at end (no comma needed because it's last)
1023
- lines.push(`${indent} drop: ['console','debugger'],`);
993
+ const possibleFiles = [
994
+ "vite.config.js",
995
+ "vite.config.mjs"
996
+ ];
1024
997
 
1025
- // Final block
1026
- return `esbuild: {\n${lines.join("\n")}\n${indent}}`;
1027
- }
1028
- );
1029
- }
998
+ // Detect existing config file
999
+ const viteConfigPath = possibleFiles
1000
+ .map(file => path.join(process.cwd(), file))
1001
+ .find(filePath => fs.existsSync(filePath));
1002
+
1003
+ if (!viteConfigPath) {
1004
+ console.warn("⚠️ No vite config found. Skipping.");
1005
+ return;
1006
+ }
1007
+
1008
+ //console.log("📄 Using:", viteConfigPath.split("/").pop());
1009
+
1010
+ let viteContent = fs.readFileSync(viteConfigPath, "utf8");
1011
+
1012
+ // Skip if already exists
1013
+ if (/drop\s*:\s*\[.*['"]console['"].*\]/.test(viteContent)) {
1014
+ console.log("ℹ️ vite.config.(m)js already Updated. Skipping...");
1015
+ return;
1016
+ }
1030
1017
 
1031
- // If esbuild block missing → add new
1032
- else {
1033
- viteContent = viteContent.replace(
1034
- /export default defineConfig\s*\(\s*{/,
1035
- m => `${m}\n esbuild: {\n drop: ['console','debugger'],\n },`
1036
- );
1018
+ console.log("🔧 Adding esbuild.drop ...");
1019
+
1020
+ // If esbuild block exists
1021
+ if (/esbuild\s*:\s*{/.test(viteContent)) {
1022
+ viteContent = viteContent.replace(
1023
+ /esbuild\s*:\s*{([\s\S]*?)(^ {0,8})}/m,
1024
+ (full, inner, indent) => {
1025
+
1026
+ let lines = inner
1027
+ .split("\n")
1028
+ .map(l => l.trim())
1029
+ .filter(Boolean);
1030
+
1031
+ // Fix last comma
1032
+ if (lines.length > 0) {
1033
+ lines[lines.length - 1] =
1034
+ lines[lines.length - 1].replace(/,+$/, "") + ",";
1035
+ }
1036
+
1037
+ // Re-indent
1038
+ lines = lines.map(l => indent + " " + l);
1039
+
1040
+ // Add drop
1041
+ lines.push(`${indent} drop: ['console','debugger'],`);
1042
+
1043
+ return `esbuild: {\n${lines.join("\n")}\n${indent}}`;
1037
1044
  }
1045
+ );
1046
+ }
1038
1047
 
1039
- // Save
1040
- fs.writeFileSync(viteConfigPath, viteContent, "utf8");
1041
- console.log("✅ Added successfully with perfect comma alignment.");
1042
- }
1043
- } else {
1044
- console.warn("⚠️ vite.config.js not found, skipping.");
1048
+ // If esbuild missing
1049
+ else {
1050
+ viteContent = viteContent.replace(
1051
+ /export default defineConfig\s*\(\s*{/,
1052
+ m => `${m}\n esbuild: {\n drop: ['console','debugger'],\n },`
1053
+ );
1045
1054
  }
1046
- }
1055
+
1056
+ fs.writeFileSync(viteConfigPath, viteContent, "utf8");
1057
+ console.log("✅ vite.config.(m)js Updated successfully.");
1058
+ };
1047
1059
 
1048
1060
  checkAndupdateDropInViteConfig();
1049
1061
 
@@ -1053,6 +1065,7 @@ checkAndupdateDropInViteConfig();
1053
1065
 
1054
1066
 
1055
1067
 
1068
+
1056
1069
  const compareVersion = (v1, v2) => {
1057
1070
  const a = v1.split(".").map(Number);
1058
1071
  const b = v2.split(".").map(Number);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeplay-common",
3
- "version": "2.0.5",
3
+ "version": "2.0.7",
4
4
  "description": "Common build scripts and files",
5
5
  "scripts": {
6
6
  "postinstall": "node scripts/sync-files.js",