pakstr 0.2.0 → 0.2.1

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.
@@ -23,10 +23,25 @@ function patchPermissions(androidRoot, manifest) {
23
23
  console.warn(`⚠️ Unknown permission: ${perm}`);
24
24
  continue;
25
25
  }
26
- const line = `<uses-permission android:name="${androidPermission}"/>`;
27
- if (!xml.includes(line)) {
28
- xml = xml.replace("<manifest", `<manifest\n ${line}`);
26
+ /**
27
+ * Check if permission already exists.
28
+ *
29
+ * Handles:
30
+ *
31
+ * <uses-permission android:name="android.permission.X"/>
32
+ *
33
+ * and
34
+ *
35
+ * <uses-permission android:name="android.permission.X" />
36
+ */
37
+ const exists = new RegExp(`<uses-permission[^>]+android:name="${androidPermission}"[^>]*/>`).test(xml);
38
+ if (exists) {
39
+ console.log(`✔ Permission already exists: ${androidPermission}`);
40
+ continue;
29
41
  }
42
+ const permissionLine = ` <uses-permission android:name="${androidPermission}" />`;
43
+ xml = xml.replace(/<manifest[^>]*>/, (match) => `${match}\n${permissionLine}`);
44
+ console.log(`➕ Added permission: ${androidPermission}`);
30
45
  }
31
46
  fs_1.default.writeFileSync(file, xml);
32
47
  console.log("🔐 Permissions patched");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pakstr",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "CLI for packaging Nostr web apps into Android APKs",
5
5
  "type": "commonjs",
6
6
  "main": "dist/index.js",