codeplay-common 1.3.2 → 1.3.4
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/.gitattributes +2 -2
- package/LICENSE +21 -21
- package/README.md +11 -11
- package/files/buildCodeplay/add-splash-screen-1.1.js +0 -0
- package/files/buildCodeplay/{codeplayBeforeBuild-1.6.js → codeplayBeforeBuild-1.7.js} +312 -308
- package/files/buildCodeplay/modify-plugin-xml.js +36 -36
- package/files/buildCodeplay/setSplashAnimation-1.1.js +167 -167
- package/files/buildCodeplay/splashxml/codeplay_splashScreen.xml +11 -11
- package/files/finalrelease15 +575 -575
- package/files/iap-install-1.js +146 -146
- package/files/ionic.config.json +6 -6
- package/package.json +14 -14
- package/scripts/sync-files.js +78 -78
- package/scripts/uninstall.js +76 -76
|
@@ -1,308 +1,312 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const plist = require('plist');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
//Check codeplay-common latest version installed or not Start
|
|
21
|
-
const { execSync } = require('child_process');
|
|
22
|
-
|
|
23
|
-
function getInstalledVersion(packageName) {
|
|
24
|
-
try {
|
|
25
|
-
const packageJsonPath = path.join(process.cwd(), 'node_modules', packageName, 'package.json');
|
|
26
|
-
if (fs.existsSync(packageJsonPath)) {
|
|
27
|
-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
28
|
-
return packageJson.version;
|
|
29
|
-
}
|
|
30
|
-
} catch (error) {
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function getLatestVersion(packageName) {
|
|
37
|
-
try {
|
|
38
|
-
return execSync(`npm view ${packageName} version`).toString().trim();
|
|
39
|
-
} catch (error) {
|
|
40
|
-
console.error(`Failed to fetch latest version for ${packageName}`);
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function checkPackageVersion() {
|
|
46
|
-
const packageName = 'codeplay-common';
|
|
47
|
-
const installedVersion = getInstalledVersion(packageName);
|
|
48
|
-
const latestVersion = getLatestVersion(packageName);
|
|
49
|
-
|
|
50
|
-
if (!installedVersion) {
|
|
51
|
-
console.error(`${packageName} is not installed. Please install it using "npm install ${packageName}".`);
|
|
52
|
-
process.exit(1);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (installedVersion !== latestVersion) {
|
|
56
|
-
console.error(`\x1b[31m${packageName} is outdated (installed: ${installedVersion}, latest: ${latestVersion}). Please update it.\x1b[0m\n\x1b[33mUse 'npm uninstall codeplay-common ; npm i codeplay-common'\x1b[0m`);
|
|
57
|
-
process.exit(1);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
console.log(`${packageName} is up to date (version ${installedVersion}).`);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Run package version check before executing the main script
|
|
64
|
-
try {
|
|
65
|
-
checkPackageVersion();
|
|
66
|
-
} catch (error) {
|
|
67
|
-
console.error(error.message);
|
|
68
|
-
process.exit(1);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
//Check codeplay-common latest version installed or not End
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
// Run package version check before executing the main script
|
|
77
|
-
try {
|
|
78
|
-
checkPackageVersion();
|
|
79
|
-
} catch (error) {
|
|
80
|
-
console.error(error.message);
|
|
81
|
-
process.exit(1);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
// Clean up AppleDouble files (._*) created by macOS START
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
if
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
import
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
{
|
|
153
|
-
path: '/
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
const
|
|
194
|
-
const
|
|
195
|
-
const
|
|
196
|
-
const
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
function
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
fs.
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
APP_ID_ANDROID
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
plistData
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
if (!fileExists(
|
|
291
|
-
throw new Error('
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
if (fileExists(
|
|
303
|
-
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
}
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const plist = require('plist');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
//Check codeplay-common latest version installed or not Start
|
|
21
|
+
const { execSync } = require('child_process');
|
|
22
|
+
|
|
23
|
+
function getInstalledVersion(packageName) {
|
|
24
|
+
try {
|
|
25
|
+
const packageJsonPath = path.join(process.cwd(), 'node_modules', packageName, 'package.json');
|
|
26
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
27
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
28
|
+
return packageJson.version;
|
|
29
|
+
}
|
|
30
|
+
} catch (error) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function getLatestVersion(packageName) {
|
|
37
|
+
try {
|
|
38
|
+
return execSync(`npm view ${packageName} version`).toString().trim();
|
|
39
|
+
} catch (error) {
|
|
40
|
+
console.error(`Failed to fetch latest version for ${packageName}`);
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function checkPackageVersion() {
|
|
46
|
+
const packageName = 'codeplay-common';
|
|
47
|
+
const installedVersion = getInstalledVersion(packageName);
|
|
48
|
+
const latestVersion = getLatestVersion(packageName);
|
|
49
|
+
|
|
50
|
+
if (!installedVersion) {
|
|
51
|
+
console.error(`${packageName} is not installed. Please install it using "npm install ${packageName}".`);
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (installedVersion !== latestVersion) {
|
|
56
|
+
console.error(`\x1b[31m${packageName} is outdated (installed: ${installedVersion}, latest: ${latestVersion}). Please update it.\x1b[0m\n\x1b[33mUse 'npm uninstall codeplay-common ; npm i codeplay-common'\x1b[0m`);
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
console.log(`${packageName} is up to date (version ${installedVersion}).`);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Run package version check before executing the main script
|
|
64
|
+
try {
|
|
65
|
+
checkPackageVersion();
|
|
66
|
+
} catch (error) {
|
|
67
|
+
console.error(error.message);
|
|
68
|
+
process.exit(1);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
//Check codeplay-common latest version installed or not End
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
// Run package version check before executing the main script
|
|
77
|
+
try {
|
|
78
|
+
checkPackageVersion();
|
|
79
|
+
} catch (error) {
|
|
80
|
+
console.error(error.message);
|
|
81
|
+
process.exit(1);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
// Clean up AppleDouble files (._*) created by macOS START
|
|
92
|
+
if (process.platform === 'darwin') {
|
|
93
|
+
try {
|
|
94
|
+
console.log('🧹 Cleaning up AppleDouble files (._*)...');
|
|
95
|
+
execSync(`find . -name '._*' -delete`);
|
|
96
|
+
console.log('✅ AppleDouble files removed.');
|
|
97
|
+
} catch (err) {
|
|
98
|
+
console.warn('⚠️ Failed to remove AppleDouble files:', err.message);
|
|
99
|
+
}
|
|
100
|
+
} else {
|
|
101
|
+
console.log('ℹ️ Skipping AppleDouble cleanup — not a macOS machine.');
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Clean up AppleDouble files (._*) created by macOS END
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
//In routes.js file check static import START
|
|
113
|
+
|
|
114
|
+
const routesPath = path.join(process.cwd(), 'src', 'js', 'routes.js');
|
|
115
|
+
const routesContent = fs.readFileSync(routesPath, 'utf-8');
|
|
116
|
+
|
|
117
|
+
let inBlockComment = false;
|
|
118
|
+
const lines = routesContent.split('\n');
|
|
119
|
+
|
|
120
|
+
const allowedImport = `import HomePage from '../pages/home.f7';`;
|
|
121
|
+
const badImportRegex = /^[ \t]*import\s+[\w{}*,\s]*\s+from\s+['"].+\.f7['"]\s*;/;
|
|
122
|
+
const badImports = [];
|
|
123
|
+
|
|
124
|
+
lines.forEach((line, index) => {
|
|
125
|
+
const trimmed = line.trim();
|
|
126
|
+
|
|
127
|
+
// Handle block comment start and end
|
|
128
|
+
if (trimmed.startsWith('/*')) inBlockComment = true;
|
|
129
|
+
if (inBlockComment && trimmed.endsWith('*/')) {
|
|
130
|
+
inBlockComment = false;
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Skip if inside block comment or line comment
|
|
135
|
+
if (inBlockComment || trimmed.startsWith('//')) return;
|
|
136
|
+
|
|
137
|
+
// Match static .f7 import
|
|
138
|
+
if (badImportRegex.test(trimmed) && trimmed !== allowedImport) {
|
|
139
|
+
badImports.push({ line: trimmed, number: index + 1 });
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
if (badImports.length > 0) {
|
|
144
|
+
console.error('\n❌ ERROR: Detected disallowed static imports of .f7 files in routes.js\n');
|
|
145
|
+
console.error(`⚠️ Only this static import is allowed:\n ${allowedImport}\n`);
|
|
146
|
+
console.error(`🔧 Please convert other imports to async dynamic imports like this:\n`);
|
|
147
|
+
console.error(`
|
|
148
|
+
|
|
149
|
+
import HomePage from '../pages/home.f7';
|
|
150
|
+
|
|
151
|
+
const routes = [
|
|
152
|
+
{
|
|
153
|
+
path: '/',
|
|
154
|
+
component:HomePage,
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
path: '/ProfilePage/',
|
|
158
|
+
async async({ resolve }) {
|
|
159
|
+
const page = await import('../pages/profile.f7');
|
|
160
|
+
resolve({ component: page.default });
|
|
161
|
+
},
|
|
162
|
+
}]
|
|
163
|
+
`);
|
|
164
|
+
|
|
165
|
+
badImports.forEach(({ line, number }) => {
|
|
166
|
+
console.error(`${number}: ${line}`);
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
process.exit(1);
|
|
170
|
+
} else {
|
|
171
|
+
console.log('✅ routes.js passed the .f7 import check.');
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
//In routes.js file check static import END
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
const configPath = path.join(process.cwd(), 'capacitor.config.json');
|
|
194
|
+
const androidPlatformPath = path.join(process.cwd(), 'android');
|
|
195
|
+
const iosPlatformPath = path.join(process.cwd(), 'ios');
|
|
196
|
+
const pluginPath = path.join(process.cwd(), 'node_modules', 'emi-indo-cordova-plugin-admob', 'plugin.xml');
|
|
197
|
+
const infoPlistPath = path.join(process.cwd(), 'ios', 'App', 'App', 'Info.plist');
|
|
198
|
+
const resourcesPath = path.join(process.cwd(), 'resources', 'res');
|
|
199
|
+
const androidResPath = path.join(process.cwd(), 'android', 'app', 'src', 'main', 'res');
|
|
200
|
+
const localNotificationsPluginPath = path.join(process.cwd(), 'node_modules', '@capacitor', 'local-notifications');
|
|
201
|
+
|
|
202
|
+
function fileExists(filePath) {
|
|
203
|
+
return fs.existsSync(filePath);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function copyFolderSync(source, target) {
|
|
207
|
+
if (!fs.existsSync(target)) {
|
|
208
|
+
fs.mkdirSync(target, { recursive: true });
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
fs.readdirSync(source).forEach(file => {
|
|
212
|
+
const sourceFile = path.join(source, file);
|
|
213
|
+
const targetFile = path.join(target, file);
|
|
214
|
+
|
|
215
|
+
if (fs.lstatSync(sourceFile).isDirectory()) {
|
|
216
|
+
copyFolderSync(sourceFile, targetFile);
|
|
217
|
+
} else {
|
|
218
|
+
fs.copyFileSync(sourceFile, targetFile);
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function checkAndCopyResources() {
|
|
224
|
+
if (fileExists(resourcesPath)) {
|
|
225
|
+
copyFolderSync(resourcesPath, androidResPath);
|
|
226
|
+
console.log('Successfully copied resources/res to android/app/src/main/res.');
|
|
227
|
+
} else {
|
|
228
|
+
console.log('resources/res folder not found.');
|
|
229
|
+
|
|
230
|
+
if (fileExists(localNotificationsPluginPath)) {
|
|
231
|
+
throw new Error('resources/res is required for @capacitor/local-notifications. Stopping execution.');
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function getAdMobConfig() {
|
|
237
|
+
if (!fileExists(configPath)) {
|
|
238
|
+
throw new Error('capacitor.config.json not found. Ensure this is a Capacitor project.');
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
242
|
+
const admobConfig = config.plugins?.AdMob;
|
|
243
|
+
|
|
244
|
+
if (!admobConfig || !admobConfig.APP_ID_ANDROID || !admobConfig.APP_ID_IOS) {
|
|
245
|
+
throw new Error('AdMob configuration is missing in capacitor.config.json. Ensure APP_ID_ANDROID and APP_ID_IOS are defined.');
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
return {
|
|
249
|
+
APP_ID_ANDROID: admobConfig.APP_ID_ANDROID,
|
|
250
|
+
APP_ID_IOS: admobConfig.APP_ID_IOS,
|
|
251
|
+
USE_LITE_ADS: admobConfig.USE_LITE_ADS === "lite",
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function updatePluginXml(admobConfig) {
|
|
256
|
+
if (!fileExists(pluginPath)) {
|
|
257
|
+
console.error('plugin.xml not found. Ensure the plugin is installed.');
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
let pluginContent = fs.readFileSync(pluginPath, 'utf8');
|
|
262
|
+
|
|
263
|
+
pluginContent = pluginContent
|
|
264
|
+
.replace(/<preference name="APP_ID_ANDROID" default=".*?" \/>/, `<preference name="APP_ID_ANDROID" default="${admobConfig.APP_ID_ANDROID}" />`)
|
|
265
|
+
.replace(/<preference name="APP_ID_IOS" default=".*?" \/>/, `<preference name="APP_ID_IOS" default="${admobConfig.APP_ID_IOS}" />`);
|
|
266
|
+
|
|
267
|
+
fs.writeFileSync(pluginPath, pluginContent, 'utf8');
|
|
268
|
+
console.log('AdMob IDs successfully updated in plugin.xml');
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function updateInfoPlist(admobConfig) {
|
|
272
|
+
if (!fileExists(infoPlistPath)) {
|
|
273
|
+
console.error('Info.plist not found. Ensure you have built the iOS project.');
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
const plistContent = fs.readFileSync(infoPlistPath, 'utf8');
|
|
278
|
+
const plistData = plist.parse(plistContent);
|
|
279
|
+
|
|
280
|
+
plistData.GADApplicationIdentifier = admobConfig.APP_ID_IOS;
|
|
281
|
+
plistData.NSUserTrackingUsageDescription = 'This identifier will be used to deliver personalized ads to you.';
|
|
282
|
+
plistData.GADDelayAppMeasurementInit = true;
|
|
283
|
+
|
|
284
|
+
const updatedPlistContent = plist.build(plistData);
|
|
285
|
+
fs.writeFileSync(infoPlistPath, updatedPlistContent, 'utf8');
|
|
286
|
+
console.log('AdMob IDs and additional configurations successfully updated in Info.plist');
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
try {
|
|
290
|
+
if (!fileExists(configPath)) {
|
|
291
|
+
throw new Error('capacitor.config.json not found. Skipping setup.');
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
if (!fileExists(androidPlatformPath) && !fileExists(iosPlatformPath)) {
|
|
295
|
+
throw new Error('Neither Android nor iOS platforms are found. Ensure platforms are added to your Capacitor project.');
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
checkAndCopyResources();
|
|
299
|
+
|
|
300
|
+
const admobConfig = getAdMobConfig();
|
|
301
|
+
|
|
302
|
+
if (fileExists(androidPlatformPath)) {
|
|
303
|
+
updatePluginXml(admobConfig);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
if (fileExists(iosPlatformPath)) {
|
|
307
|
+
updateInfoPlist(admobConfig);
|
|
308
|
+
}
|
|
309
|
+
} catch (error) {
|
|
310
|
+
console.error(error.message);
|
|
311
|
+
process.exit(1); // Stop execution if there's a critical error
|
|
312
|
+
}
|