Pārlūkot izejas kodu

rebranding script

Alex Trofimov 10 mēneši atpakaļ
vecāks
revīzija
5c43cd2f5b
2 mainītis faili ar 55 papildinājumiem un 0 dzēšanām
  1. 1 0
      README.md
  2. 54 0
      scripts/rebrand.js

+ 1 - 0
README.md

@@ -33,6 +33,7 @@ Mobile apps need to have [Nexus](https://unacms.com/view-product/nexus) UNA app
 - Edit `constants/theme.ts` to specify custom colors.
 - Edit images in `assets/images` to change app icons.
 - Edit `app.js` to change app bundle and app name.
+- Make sure to run `npx expo prebuild` after editing `app.js` file.
 
 Automate some the of the above changes by running:
 

+ 54 - 0
scripts/rebrand.js

@@ -7,6 +7,7 @@
 const fs = require("fs").promises;
 const path = require("path");
 const readline = require("readline");
+const { exec } = require("child_process");
 
 const root = process.cwd();
 const settingsPath = path.join(root, "constants", "settings.ts");
@@ -77,6 +78,59 @@ function askQuestion(query) {
 
     })();
 
+    // --------- recreate `ios` and `android` folders
+    await (async () => {
+      const answer = await askQuestion("Recreate native app folders (Y or N): ");
+      const userInput = answer.trim().toLowerCase();
+
+
+      if (userInput != 'y' && userInput != 'n' && userInput != '') {
+        console.log("❌ Answer Y or N.");
+        return;
+      }
+
+
+      if (userInput == 'y' || userInput == '') {
+        
+        // Delete android and ios folders if they exist
+        const androidPath = path.join(root, "android");
+        const iosPath = path.join(root, "ios");
+
+        try {
+          await fs.rm(androidPath, { recursive: true, force: true });
+          await fs.rm(iosPath, { recursive: true, force: true });
+          console.log("✅ Old native folders deleted");
+        } catch (err) {
+          console.error("❌ Failed to delete native folders:", err);
+        }
+
+        // Recreate native folders using expo prebuild
+        try {
+          await new Promise((resolve, reject) => {
+            console.log("Recreating...");
+            exec("npx expo prebuild", (err, stdout, stderr) => {
+              if (err) {
+                console.error("❌ Failed to run expo prebuild:", err);
+                reject(err);
+              } else {
+                console.log(stdout);
+                resolve(stdout);
+              }
+            });
+          });
+          console.log("✅ Native app folders were recreated");
+        } catch (err) {
+          console.error("❌ Error during prebuild:", err);
+        }
+        
+      }
+
+      if (userInput == 'n') {        
+        console.log("⚠️ You chose not to recreate native folders. Some changes may not take effect in native builds.");
+      }
+
+    })();
+
   } catch (err) {
     console.error("❌ An error occurred:", err);
     const userInput = answer.trim().toLowerCase();