codeplay-common 4.11.23 → 4.11.24
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/files/buildCodeplay/codeplayBeforeBuild.js +3 -0
- package/files/buildCodeplay/ruads.cjs +101 -2
- package/files/buildCodeplay/setup-ruads.cjs +7 -1
- package/files/finalrelease +3 -0
- package/package.json +1 -1
- package/scripts/ruads-install.test.cjs +18 -0
- package/scripts/ruads-policy.test.cjs +130 -0
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// Version 8.0: restore AdMob native settings when switching back to an AdMob store.
|
|
2
|
+
// Version 7.9: remove stale AdMob native settings and SDKs for non-AdMob stores.
|
|
1
3
|
// Version 7.8: preserve original Vite build settings through the generated store wrapper.
|
|
2
4
|
// Version 7.7: migrate versioned IAP imports to the dynamic @iap Vite alias without prompting.
|
|
3
5
|
// Version 7.6: resolve VK folder versions dynamically and update through the shared server manifest.
|
|
@@ -4758,6 +4760,7 @@ async function main() {
|
|
|
4758
4760
|
ruAdsBuild.withNativeAdProvider(process.cwd(), getCurrentStoreId(), buildPlatform,
|
|
4759
4761
|
() => runNpmCommand(`npx cap sync ${buildPlatform}`));
|
|
4760
4762
|
}
|
|
4763
|
+
ruAdsBuild.syncAndroidAdmobPolicy(process.cwd(), getCurrentStoreId(), buildPlatform);
|
|
4761
4764
|
}
|
|
4762
4765
|
|
|
4763
4766
|
await main();
|
|
@@ -4,6 +4,101 @@ const { execFileSync } = require('child_process');
|
|
|
4
4
|
|
|
5
5
|
const VK_PACKAGE = 'capacitor-codeplay-rustore-ads';
|
|
6
6
|
const ADMOB_PACKAGE = 'capacitor-admob-nextgen';
|
|
7
|
+
const noAdmobStart = '// BEGIN CODEPLAY EXCLUDE ADMOB';
|
|
8
|
+
const noAdmobEnd = '// END CODEPLAY EXCLUDE ADMOB';
|
|
9
|
+
|
|
10
|
+
function removeAdmobPluginConfig(config) {
|
|
11
|
+
for (const name of Object.keys(config.plugins || {})) {
|
|
12
|
+
if (/admob/i.test(name)) delete config.plugins[name];
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// IAP shares this JSON with AdMob. Keep purchase settings but omit ad IDs from
|
|
17
|
+
// non-AdMob web bundles, without editing the app's protected source config.
|
|
18
|
+
function admobConfigPlugin(provider) {
|
|
19
|
+
return {
|
|
20
|
+
name: 'codeplay-store-admob-config',
|
|
21
|
+
enforce: 'pre',
|
|
22
|
+
transform(source, id) {
|
|
23
|
+
if (provider === 'admob' || !/(?:^|[\\/])admob-ad-configuration(?:-nextgen)?\.json$/.test(id)) return null;
|
|
24
|
+
const scrub = value => {
|
|
25
|
+
if (typeof value === 'string') return value.startsWith('ca-app-pub-') ? '' : value;
|
|
26
|
+
if (Array.isArray(value)) return value.map(scrub);
|
|
27
|
+
if (value && typeof value === 'object') return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, scrub(item)]));
|
|
28
|
+
return value;
|
|
29
|
+
};
|
|
30
|
+
const config = scrub(JSON.parse(source));
|
|
31
|
+
for (const key of ['bannerEnabled', 'interstitialEnabled', 'appOpenEnabled', 'rewardVideoEnabled', 'rewardInterstitialEnabled']) {
|
|
32
|
+
if (config.config) config.config[key] = false;
|
|
33
|
+
}
|
|
34
|
+
return { code: JSON.stringify(config), map: null };
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Run after sync as well as before builds: old app-owned entries survive cap sync.
|
|
40
|
+
// Keep ads-identifier/appset: VK and analytics use them independently of AdMob.
|
|
41
|
+
function syncAndroidAdmobPolicy(projectRoot, storeId, platform = 'android') {
|
|
42
|
+
if (platform !== 'android') return false;
|
|
43
|
+
const config = JSON.parse(fs.readFileSync(path.join(projectRoot, 'capacitor.config.json'), 'utf8'));
|
|
44
|
+
const excluded = getAdProvider(config, storeId, platform) !== 'admob';
|
|
45
|
+
let changed = false;
|
|
46
|
+
const update = (file, transform) => {
|
|
47
|
+
if (!fs.existsSync(file)) return;
|
|
48
|
+
const original = fs.readFileSync(file, 'utf8');
|
|
49
|
+
const next = transform(original);
|
|
50
|
+
if (next === original) return;
|
|
51
|
+
fs.writeFileSync(file, next);
|
|
52
|
+
changed = true;
|
|
53
|
+
};
|
|
54
|
+
update(path.join(projectRoot, 'android/app/build.gradle'), original => {
|
|
55
|
+
const newline = original.includes('\r\n') ? '\r\n' : '\n';
|
|
56
|
+
const clean = original.replace(new RegExp(`^${noAdmobStart}[\\s\\S]*?${noAdmobEnd}\\r?\\n?`, 'gm'), '');
|
|
57
|
+
if (!excluded) return clean;
|
|
58
|
+
const modules = ['play-services-ads', 'play-services-ads-lite', 'play-services-ads-base',
|
|
59
|
+
'play-services-ads-api', 'play-services-ads-fullscreen', 'play-services-ads-mobile-sdk'];
|
|
60
|
+
const block = [noAdmobStart, 'configurations.configureEach {',
|
|
61
|
+
...modules.map(name => ` exclude group: 'com.google.android.gms', module: '${name}'`),
|
|
62
|
+
" exclude group: 'com.google.ads.mediation'",
|
|
63
|
+
" exclude group: 'com.google.android.ump', module: 'user-messaging-platform'",
|
|
64
|
+
'}', noAdmobEnd, ''].join(newline);
|
|
65
|
+
return `${clean.trimEnd()}${newline}${newline}${block}`;
|
|
66
|
+
});
|
|
67
|
+
if (!excluded) {
|
|
68
|
+
const readJson = file => fs.existsSync(file) ? JSON.parse(fs.readFileSync(file, 'utf8')) : {};
|
|
69
|
+
const adSettings = readJson(path.join(projectRoot, 'src/js/Ads/admob-ad-configuration-nextgen.json'));
|
|
70
|
+
const pkg = readJson(path.join(projectRoot, 'package.json'));
|
|
71
|
+
const appId = adSettings.androidAppId || pkg.admob?.androidAppId || config.plugins?.AdMob?.APP_ID_ANDROID;
|
|
72
|
+
update(path.join(projectRoot, 'android/app/src/main/AndroidManifest.xml'), original => {
|
|
73
|
+
const newline = original.includes('\r\n') ? '\r\n' : '\n';
|
|
74
|
+
let next = original;
|
|
75
|
+
const ensureMeta = (name, value) => {
|
|
76
|
+
const escapedName = name.replace(/\./g, '\\.');
|
|
77
|
+
const existing = new RegExp(`<meta-data\\b(?=[^>]*\\bandroid:name\\s*=\\s*(['"])${escapedName}\\1)[^>]*(?:/\\s*>|>[\\s\\S]*?</meta-data\\s*>)`);
|
|
78
|
+
const tag = `<meta-data android:name="${name}" android:value="${value}" />`;
|
|
79
|
+
next = existing.test(next) ? next.replace(existing, tag)
|
|
80
|
+
: next.replace(/<application\b[^>]*>/, match => `${match}${newline} ${tag}`);
|
|
81
|
+
};
|
|
82
|
+
if (appId) ensureMeta('com.google.android.gms.ads.APPLICATION_ID', appId);
|
|
83
|
+
if (!next.includes('com.google.android.gms.ads.flag.OPTIMIZE_AD_LOADING')) {
|
|
84
|
+
ensureMeta('com.google.android.gms.ads.flag.OPTIMIZE_AD_LOADING', 'true');
|
|
85
|
+
}
|
|
86
|
+
if (adSettings.config?.isKidsApp !== true && !next.includes('com.google.android.gms.permission.AD_ID')) {
|
|
87
|
+
next = next.replace('</manifest>', ` <uses-permission android:name="com.google.android.gms.permission.AD_ID" />${newline}</manifest>`);
|
|
88
|
+
}
|
|
89
|
+
return next;
|
|
90
|
+
});
|
|
91
|
+
return changed;
|
|
92
|
+
}
|
|
93
|
+
update(path.join(projectRoot, 'android/app/src/main/AndroidManifest.xml'), original =>
|
|
94
|
+
original.replace(/^[ \t]*<(meta-data|activity|service|provider|receiver|uses-library)\b(?=[^>]*\bandroid:name\s*=\s*(['"])(?:com\.google\.android\.gms\.ads\.|com\.google\.ads\.|com\.google\.android\.ump\.)[^'"]*\2)[^>]*(?:\/\s*>|>[\s\S]*?<\/\1\s*>)[ \t]*(?:\r?\n)?/gm, ''));
|
|
95
|
+
update(path.join(projectRoot, 'android/app/src/main/assets/capacitor.config.json'), original => {
|
|
96
|
+
const generated = JSON.parse(original);
|
|
97
|
+
removeAdmobPluginConfig(generated);
|
|
98
|
+
return JSON.stringify(generated, null, 2) + '\n';
|
|
99
|
+
});
|
|
100
|
+
return changed;
|
|
101
|
+
}
|
|
7
102
|
|
|
8
103
|
// A missing RuAds section preserves the existing provider on every store.
|
|
9
104
|
function getAdProvider(config, storeId, platform = 'android') {
|
|
@@ -103,9 +198,13 @@ function withNativeAdProvider(projectRoot, storeId, platform, action) {
|
|
|
103
198
|
config[target] = { ...config[target], includePlugins: includedPackages(config, pkg, target,
|
|
104
199
|
getAdProvider(config, storeId, target)) };
|
|
105
200
|
}
|
|
201
|
+
if (provider !== 'admob') removeAdmobPluginConfig(config);
|
|
106
202
|
fs.writeFileSync(configPath, JSON.stringify(config, null, 2) + '\n');
|
|
107
|
-
|
|
203
|
+
let result;
|
|
204
|
+
try { result = action(provider); }
|
|
108
205
|
finally { fs.writeFileSync(configPath, original); }
|
|
206
|
+
syncAndroidAdmobPolicy(projectRoot, storeId, platform);
|
|
207
|
+
return result;
|
|
109
208
|
}
|
|
110
209
|
|
|
111
|
-
module.exports = { getAdProvider, controllerPath, findLatestVkController, prepareReleaseAds, includedPackages, syncAdProviderPackages, withNativeAdProvider };
|
|
210
|
+
module.exports = { getAdProvider, controllerPath, findLatestVkController, prepareReleaseAds, includedPackages, syncAdProviderPackages, withNativeAdProvider, syncAndroidAdmobPolicy, admobConfigPlugin };
|
|
@@ -29,12 +29,18 @@ export default async (environment) => {
|
|
|
29
29
|
const alias = !selected ? aliases : Array.isArray(aliases)
|
|
30
30
|
? aliases.map(item => item.find === '@admob' ? { ...item, replacement: selected } : item)
|
|
31
31
|
: { ...aliases, '@admob': selected };
|
|
32
|
-
return { ...base, resolve: { ...base.resolve, alias }, define: { ...base.define,
|
|
32
|
+
return { ...base, plugins: [...(base.plugins || []), ruAdsBuild.admobConfigPlugin(provider)], resolve: { ...base.resolve, alias }, define: { ...base.define,
|
|
33
33
|
'import.meta.env.VITE_STORE_ID': JSON.stringify(storeId),
|
|
34
34
|
'import.meta.env.VITE_RUADS_ENABLED': JSON.stringify(provider === 'vk') } };
|
|
35
35
|
};
|
|
36
36
|
`);
|
|
37
37
|
}
|
|
38
|
+
const current = fs.readFileSync(vite, 'utf8');
|
|
39
|
+
if (current.includes('codeplayOriginalViteConfig') && !current.includes('ruAdsBuild.admobConfigPlugin(')) {
|
|
40
|
+
const updated = current.replace('return { ...base, resolve:', 'return { ...base, plugins: [...(base.plugins || []), ruAdsBuild.admobConfigPlugin(provider)], resolve:');
|
|
41
|
+
if (updated === current) throw new Error('Cannot install store AdMob config filtering in the Vite wrapper.');
|
|
42
|
+
fs.writeFileSync(vite, updated);
|
|
43
|
+
}
|
|
38
44
|
}
|
|
39
45
|
const ru = config.plugins?.RuAds;
|
|
40
46
|
if (ru?.VK_ADS_ENABLED !== true || !(ru.STORE_IDS || []).some(id => [4, 10].includes(Number(id)))) return;
|
package/files/finalrelease
CHANGED
|
@@ -1233,6 +1233,9 @@ rl.question('Enter new versionCode (press enter to keep current): ', (newVersion
|
|
|
1233
1233
|
execSync('npx cap sync android', { stdio: 'inherit',
|
|
1234
1234
|
env: { ...process.env, VITE_STORE_ID: String(id), CODEPLAY_BUILD_PLATFORM: 'android' } }));
|
|
1235
1235
|
|
|
1236
|
+
// Reapply after sync so stale settings cannot leak from another store.
|
|
1237
|
+
ruAdsBuild.syncAndroidAdmobPolicy(__dirname, id, 'android');
|
|
1238
|
+
|
|
1236
1239
|
if (!baselineProfileChecked) {
|
|
1237
1240
|
await checkBaselineProfileBeforeRelease();
|
|
1238
1241
|
baselineProfileChecked = true;
|
package/package.json
CHANGED
|
@@ -85,6 +85,10 @@ test('Vite selects one store/provider for object and array aliases', async () =>
|
|
|
85
85
|
assert.equal(config.define['import.meta.env.VITE_RUADS_ENABLED'], JSON.stringify(['4', '10'].includes(id)));
|
|
86
86
|
assert.equal(selected, ['4', '10'].includes(id) ? path.resolve(f.root, 'src/js/Ads/vk-ads-1.10/vk-ads.js') : '/fixture/admob.js');
|
|
87
87
|
assert.equal(config.define.fixture, 'true');
|
|
88
|
+
const filter = config.plugins.find(plugin => plugin.name === 'codeplay-store-admob-config');
|
|
89
|
+
assert.ok(filter);
|
|
90
|
+
const filtered = filter.transform('{"androidAppId":"ca-app-pub-fixture"}', '/src/js/Ads/admob-ad-configuration-nextgen.json');
|
|
91
|
+
assert.equal(filtered === null, !['4', '10'].includes(id));
|
|
88
92
|
}
|
|
89
93
|
f.write('capacitor.config.json', { plugins: { AdMob: { ADMOB_ENABLED: false } } });
|
|
90
94
|
process.env.VITE_STORE_ID = '1';
|
|
@@ -101,6 +105,20 @@ test('Vite selects one store/provider for object and array aliases', async () =>
|
|
|
101
105
|
}
|
|
102
106
|
});
|
|
103
107
|
|
|
108
|
+
test('existing generated Vite wrapper gains AdMob ID filtering without repeated changes', () => {
|
|
109
|
+
const f = fixture();
|
|
110
|
+
syncRuAdsSetup(f.root, { runtimeRoot });
|
|
111
|
+
const file = path.join(f.root, 'vite.config.mjs');
|
|
112
|
+
const current = fs.readFileSync(file, 'utf8');
|
|
113
|
+
const old = current.replace('plugins: [...(base.plugins || []), ruAdsBuild.admobConfigPlugin(provider)], ', '');
|
|
114
|
+
assert.notEqual(old, current);
|
|
115
|
+
fs.writeFileSync(file, old);
|
|
116
|
+
syncRuAdsSetup(f.root, { runtimeRoot });
|
|
117
|
+
assert.equal(fs.readFileSync(file, 'utf8'), current);
|
|
118
|
+
syncRuAdsSetup(f.root, { runtimeRoot });
|
|
119
|
+
assert.equal(fs.readFileSync(file, 'utf8'), current);
|
|
120
|
+
});
|
|
121
|
+
|
|
104
122
|
test('installer distributes all RuStore helpers and preserves release credentials', () => {
|
|
105
123
|
const f = fixture();
|
|
106
124
|
f.write('buildCodeplay/release-sync.config.json', { token: 'consumer-owned' });
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
const test = require('node:test');
|
|
2
|
+
const assert = require('node:assert/strict');
|
|
3
|
+
const fs = require('node:fs');
|
|
4
|
+
const path = require('node:path');
|
|
5
|
+
const { syncAndroidAdmobPolicy, withNativeAdProvider, admobConfigPlugin } = require('../files/buildCodeplay/ruads.cjs');
|
|
6
|
+
|
|
7
|
+
function fixture(enabled = true) {
|
|
8
|
+
const temp = path.resolve(__dirname, '../agent-temp');
|
|
9
|
+
fs.mkdirSync(temp, { recursive: true });
|
|
10
|
+
const root = fs.mkdtempSync(path.join(temp, 'admob-policy-'));
|
|
11
|
+
const config = {
|
|
12
|
+
plugins: { AdMob: { ADMOB_ENABLED: enabled, APP_ID_ANDROID: 'ca-app-pub-restored' },
|
|
13
|
+
RuAds: { VK_ADS_ENABLED: true, STORE_IDS: [4, 10] }, FirebaseAnalytics: {} },
|
|
14
|
+
};
|
|
15
|
+
const manifest = `<?xml version="1.0"?>
|
|
16
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
|
17
|
+
<uses-permission android:name="com.google.android.gms.permission.AD_ID" />
|
|
18
|
+
<application>
|
|
19
|
+
<meta-data android:value="ca-app-pub-example" android:name="com.google.android.gms.ads.APPLICATION_ID" />
|
|
20
|
+
<meta-data android:name='com.google.android.gms.ads.flag.OPTIMIZE_AD_LOADING' android:value='true'></meta-data>
|
|
21
|
+
<activity android:name="com.google.android.gms.ads.AdActivity"><intent-filter /></activity>
|
|
22
|
+
<provider android:name="com.google.android.gms.ads.MobileAdsInitProvider" />
|
|
23
|
+
<activity android:name="com.my.target.ads.MyTargetActivity" />
|
|
24
|
+
<meta-data android:name="firebase_analytics_collection_enabled" android:value="true" />
|
|
25
|
+
</application>
|
|
26
|
+
</manifest>
|
|
27
|
+
`;
|
|
28
|
+
const write = (name, value) => {
|
|
29
|
+
const file = path.join(root, name);
|
|
30
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
31
|
+
fs.writeFileSync(file, typeof value === 'string' ? value : JSON.stringify(value));
|
|
32
|
+
};
|
|
33
|
+
write('capacitor.config.json', config);
|
|
34
|
+
write('package.json', { dependencies: {
|
|
35
|
+
'capacitor-admob-nextgen': '1', 'capacitor-codeplay-rustore-ads': '1', '@capacitor/app': '1',
|
|
36
|
+
} });
|
|
37
|
+
write('android/app/build.gradle', "apply plugin: 'com.android.application'\n");
|
|
38
|
+
write('android/app/src/main/AndroidManifest.xml', manifest);
|
|
39
|
+
write('android/app/src/main/assets/capacitor.config.json', config);
|
|
40
|
+
return { root, write, manifest, read: name => fs.readFileSync(path.join(root, name), 'utf8') };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
for (const storeId of [4, 10]) {
|
|
44
|
+
test(`store ${storeId}: clean synced config, stale manifest and SDKs; repeat safely`, () => {
|
|
45
|
+
const f = fixture();
|
|
46
|
+
const originalConfig = f.read('capacitor.config.json');
|
|
47
|
+
assert.equal(withNativeAdProvider(f.root, storeId, 'android', provider => {
|
|
48
|
+
assert.equal(provider, 'vk');
|
|
49
|
+
const scoped = JSON.parse(f.read('capacitor.config.json'));
|
|
50
|
+
assert.equal(scoped.plugins.AdMob, undefined);
|
|
51
|
+
assert.ok(scoped.android.includePlugins.includes('capacitor-codeplay-rustore-ads'));
|
|
52
|
+
assert.ok(!scoped.android.includePlugins.includes('capacitor-admob-nextgen'));
|
|
53
|
+
// Simulate cap sync copying the scoped config and retaining old app entries.
|
|
54
|
+
f.write('android/app/src/main/assets/capacitor.config.json', scoped);
|
|
55
|
+
return 'synced';
|
|
56
|
+
}), 'synced');
|
|
57
|
+
assert.equal(f.read('capacitor.config.json'), originalConfig);
|
|
58
|
+
const manifest = f.read('android/app/src/main/AndroidManifest.xml');
|
|
59
|
+
assert.doesNotMatch(manifest, /com\.google\.android\.gms\.ads\.|ca-app-pub-/);
|
|
60
|
+
assert.match(manifest, /MyTargetActivity/);
|
|
61
|
+
assert.match(manifest, /firebase_analytics_collection_enabled/);
|
|
62
|
+
assert.match(manifest, /permission.AD_ID/);
|
|
63
|
+
const gradle = f.read('android/app/build.gradle');
|
|
64
|
+
assert.match(gradle, /module: 'play-services-ads'/);
|
|
65
|
+
assert.doesNotMatch(gradle, /module: 'play-services-ads-identifier'/);
|
|
66
|
+
assert.equal(syncAndroidAdmobPolicy(f.root, storeId), false);
|
|
67
|
+
|
|
68
|
+
// A later AdMob store must restore metadata without manually reseeding it.
|
|
69
|
+
assert.equal(syncAndroidAdmobPolicy(f.root, 1), true);
|
|
70
|
+
assert.doesNotMatch(f.read('android/app/build.gradle'), /CODEPLAY EXCLUDE ADMOB/);
|
|
71
|
+
assert.match(f.read('android/app/src/main/AndroidManifest.xml'), /ca-app-pub-restored/);
|
|
72
|
+
assert.match(f.read('android/app/src/main/AndroidManifest.xml'), /OPTIMIZE_AD_LOADING/);
|
|
73
|
+
const restored = f.read('android/app/src/main/AndroidManifest.xml');
|
|
74
|
+
assert.equal(syncAndroidAdmobPolicy(f.root, 1), false);
|
|
75
|
+
assert.equal(f.read('android/app/src/main/AndroidManifest.xml'), restored);
|
|
76
|
+
withNativeAdProvider(f.root, 1, 'android', provider => {
|
|
77
|
+
assert.equal(provider, 'admob');
|
|
78
|
+
const scoped = JSON.parse(f.read('capacitor.config.json'));
|
|
79
|
+
assert.ok(scoped.android.includePlugins.includes('capacitor-admob-nextgen'));
|
|
80
|
+
assert.ok(!scoped.android.includePlugins.includes('capacitor-codeplay-rustore-ads'));
|
|
81
|
+
assert.equal(scoped.plugins.AdMob.APP_ID_ANDROID, 'ca-app-pub-restored');
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
test('globally disabled AdMob cleans stores outside Huawei/RuStore', () => {
|
|
87
|
+
const f = fixture(false);
|
|
88
|
+
withNativeAdProvider(f.root, 3, 'android', provider => assert.equal(provider, 'none'));
|
|
89
|
+
assert.doesNotMatch(f.read('android/app/src/main/AndroidManifest.xml'), /com\.google\.android\.gms\.ads\./);
|
|
90
|
+
assert.equal(JSON.parse(f.read('android/app/src/main/assets/capacitor.config.json')).plugins.AdMob, undefined);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
test('sync failure restores root settings; Android cleanup does not affect iOS', () => {
|
|
94
|
+
const f = fixture();
|
|
95
|
+
const original = f.read('capacitor.config.json');
|
|
96
|
+
assert.throws(() => withNativeAdProvider(f.root, 10, 'android', () => { throw new Error('sync failed'); }), /sync failed/);
|
|
97
|
+
assert.equal(f.read('capacitor.config.json'), original);
|
|
98
|
+
assert.equal(syncAndroidAdmobPolicy(f.root, 10, 'ios'), false);
|
|
99
|
+
assert.equal(f.read('android/app/src/main/AndroidManifest.xml'), f.manifest);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
test('non-AdMob web bundles omit live/test IDs while preserving shared IAP configuration', () => {
|
|
103
|
+
const original = { IAP: { samsung: true }, androidAppId: 'ca-app-pub-app',
|
|
104
|
+
android: { bannerid: 'ca-app-pub-live' }, testid: { bannerid: ['ca-app-pub-test'] },
|
|
105
|
+
config: { bannerEnabled: true, interstitialEnabled: true } };
|
|
106
|
+
const source = JSON.stringify(original);
|
|
107
|
+
const id = '/src/js/Ads/admob-ad-configuration-nextgen.json';
|
|
108
|
+
for (const provider of ['vk', 'none']) {
|
|
109
|
+
const result = JSON.parse(admobConfigPlugin(provider).transform(source, id).code);
|
|
110
|
+
assert.doesNotMatch(JSON.stringify(result), /ca-app-pub-/);
|
|
111
|
+
assert.deepEqual(result.IAP, original.IAP);
|
|
112
|
+
assert.equal(result.config.bannerEnabled, false);
|
|
113
|
+
}
|
|
114
|
+
assert.equal(admobConfigPlugin('admob').transform(source, id), null);
|
|
115
|
+
assert.equal(admobConfigPlugin('vk').transform(source, '/vk-ad-configuration.json'), null);
|
|
116
|
+
assert.equal(JSON.stringify(original), source);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
test('AdMob restoration uses configured app ID and preserves child-directed AD_ID exclusion', () => {
|
|
120
|
+
const f = fixture();
|
|
121
|
+
f.write('src/js/Ads/admob-ad-configuration-nextgen.json', {
|
|
122
|
+
androidAppId: 'ca-app-pub-preferred', config: { isKidsApp: true },
|
|
123
|
+
});
|
|
124
|
+
f.write('android/app/src/main/AndroidManifest.xml', '<manifest><application></application></manifest>');
|
|
125
|
+
syncAndroidAdmobPolicy(f.root, 1);
|
|
126
|
+
const restored = f.read('android/app/src/main/AndroidManifest.xml');
|
|
127
|
+
assert.match(restored, /ca-app-pub-preferred/);
|
|
128
|
+
assert.doesNotMatch(restored, /permission.AD_ID/);
|
|
129
|
+
assert.equal(syncAndroidAdmobPolicy(f.root, 1), false);
|
|
130
|
+
});
|