expo-iap 2.4.0 â 2.4.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.
- package/package.json +1 -1
- package/plugin/build/withIAP.js +19 -4
- package/plugin/src/withIAP.ts +29 -10
package/package.json
CHANGED
package/plugin/build/withIAP.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const config_plugins_1 = require("expo/config-plugins");
|
|
4
4
|
const pkg = require('../../package.json');
|
|
5
|
+
// Global flag to prevent duplicate logs
|
|
6
|
+
let hasLoggedPluginExecution = false;
|
|
5
7
|
const addLineToGradle = (content, anchor, lineToAdd, offset = 1) => {
|
|
6
8
|
const lines = content.split('\n');
|
|
7
9
|
const index = lines.findIndex((line) => line.match(anchor));
|
|
@@ -19,11 +21,18 @@ const modifyAppBuildGradle = (gradle) => {
|
|
|
19
21
|
// Add billing library dependencies to app-level build.gradle
|
|
20
22
|
const billingDep = ` implementation "com.android.billingclient:billing-ktx:7.0.0"`;
|
|
21
23
|
const gmsDep = ` implementation "com.google.android.gms:play-services-base:18.1.0"`;
|
|
24
|
+
let hasAddedDependency = false;
|
|
22
25
|
if (!modified.includes(billingDep)) {
|
|
23
26
|
modified = addLineToGradle(modified, /dependencies\s*{/, billingDep);
|
|
27
|
+
hasAddedDependency = true;
|
|
24
28
|
}
|
|
25
29
|
if (!modified.includes(gmsDep)) {
|
|
26
30
|
modified = addLineToGradle(modified, /dependencies\s*{/, gmsDep, 1);
|
|
31
|
+
hasAddedDependency = true;
|
|
32
|
+
}
|
|
33
|
+
// Log only once and only if we actually added dependencies
|
|
34
|
+
if (hasAddedDependency && !hasLoggedPluginExecution) {
|
|
35
|
+
console.log('đ ī¸ expo-iap: Added billing dependencies to build.gradle');
|
|
27
36
|
}
|
|
28
37
|
return modified;
|
|
29
38
|
};
|
|
@@ -43,10 +52,14 @@ const withIAPAndroid = (config) => {
|
|
|
43
52
|
const alreadyExists = permissions.some((p) => p.$['android:name'] === 'com.android.vending.BILLING');
|
|
44
53
|
if (!alreadyExists) {
|
|
45
54
|
permissions.push(billingPerm);
|
|
46
|
-
|
|
55
|
+
if (!hasLoggedPluginExecution) {
|
|
56
|
+
console.log('â
Added com.android.vending.BILLING to AndroidManifest.xml');
|
|
57
|
+
}
|
|
47
58
|
}
|
|
48
59
|
else {
|
|
49
|
-
|
|
60
|
+
if (!hasLoggedPluginExecution) {
|
|
61
|
+
console.log('âšī¸ com.android.vending.BILLING already exists in AndroidManifest.xml');
|
|
62
|
+
}
|
|
50
63
|
}
|
|
51
64
|
return config;
|
|
52
65
|
});
|
|
@@ -54,8 +67,10 @@ const withIAPAndroid = (config) => {
|
|
|
54
67
|
};
|
|
55
68
|
const withIAP = (config, _props) => {
|
|
56
69
|
try {
|
|
57
|
-
|
|
58
|
-
|
|
70
|
+
const result = withIAPAndroid(config);
|
|
71
|
+
// Set flag after first execution to prevent duplicate logs
|
|
72
|
+
hasLoggedPluginExecution = true;
|
|
73
|
+
return result;
|
|
59
74
|
}
|
|
60
75
|
catch (error) {
|
|
61
76
|
config_plugins_1.WarningAggregator.addWarningAndroid('expo-iap', `expo-iap plugin encountered an error: ${error}`);
|
package/plugin/src/withIAP.ts
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
|
+
ConfigPlugin,
|
|
3
|
+
createRunOncePlugin,
|
|
2
4
|
WarningAggregator,
|
|
3
5
|
withAndroidManifest,
|
|
4
6
|
withAppBuildGradle,
|
|
5
|
-
ConfigPlugin,
|
|
6
|
-
createRunOncePlugin,
|
|
7
7
|
} from 'expo/config-plugins';
|
|
8
8
|
|
|
9
9
|
const pkg = require('../../package.json');
|
|
10
10
|
|
|
11
|
+
// Global flag to prevent duplicate logs
|
|
12
|
+
let hasLoggedPluginExecution = false;
|
|
13
|
+
|
|
11
14
|
const addLineToGradle = (
|
|
12
15
|
content: string,
|
|
13
16
|
anchor: RegExp | string,
|
|
@@ -33,11 +36,21 @@ const modifyAppBuildGradle = (gradle: string): string => {
|
|
|
33
36
|
// Add billing library dependencies to app-level build.gradle
|
|
34
37
|
const billingDep = ` implementation "com.android.billingclient:billing-ktx:7.0.0"`;
|
|
35
38
|
const gmsDep = ` implementation "com.google.android.gms:play-services-base:18.1.0"`;
|
|
39
|
+
|
|
40
|
+
let hasAddedDependency = false;
|
|
41
|
+
|
|
36
42
|
if (!modified.includes(billingDep)) {
|
|
37
43
|
modified = addLineToGradle(modified, /dependencies\s*{/, billingDep);
|
|
44
|
+
hasAddedDependency = true;
|
|
38
45
|
}
|
|
39
46
|
if (!modified.includes(gmsDep)) {
|
|
40
47
|
modified = addLineToGradle(modified, /dependencies\s*{/, gmsDep, 1);
|
|
48
|
+
hasAddedDependency = true;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Log only once and only if we actually added dependencies
|
|
52
|
+
if (hasAddedDependency && !hasLoggedPluginExecution) {
|
|
53
|
+
console.log('đ ī¸ expo-iap: Added billing dependencies to build.gradle');
|
|
41
54
|
}
|
|
42
55
|
|
|
43
56
|
return modified;
|
|
@@ -66,13 +79,17 @@ const withIAPAndroid: ConfigPlugin = (config) => {
|
|
|
66
79
|
);
|
|
67
80
|
if (!alreadyExists) {
|
|
68
81
|
permissions.push(billingPerm);
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
82
|
+
if (!hasLoggedPluginExecution) {
|
|
83
|
+
console.log(
|
|
84
|
+
'â
Added com.android.vending.BILLING to AndroidManifest.xml',
|
|
85
|
+
);
|
|
86
|
+
}
|
|
72
87
|
} else {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
88
|
+
if (!hasLoggedPluginExecution) {
|
|
89
|
+
console.log(
|
|
90
|
+
'âšī¸ com.android.vending.BILLING already exists in AndroidManifest.xml',
|
|
91
|
+
);
|
|
92
|
+
}
|
|
76
93
|
}
|
|
77
94
|
|
|
78
95
|
return config;
|
|
@@ -83,8 +100,10 @@ const withIAPAndroid: ConfigPlugin = (config) => {
|
|
|
83
100
|
|
|
84
101
|
const withIAP: ConfigPlugin = (config, _props) => {
|
|
85
102
|
try {
|
|
86
|
-
|
|
87
|
-
|
|
103
|
+
const result = withIAPAndroid(config);
|
|
104
|
+
// Set flag after first execution to prevent duplicate logs
|
|
105
|
+
hasLoggedPluginExecution = true;
|
|
106
|
+
return result;
|
|
88
107
|
} catch (error) {
|
|
89
108
|
WarningAggregator.addWarningAndroid(
|
|
90
109
|
'expo-iap',
|