codeplay-common 2.1.9 → 2.1.11
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.6.js +248 -248
- package/files/buildCodeplay/{codeplayBeforeBuild-5.0.js → codeplayBeforeBuild-5.1.js} +1210 -1198
- package/files/buildCodeplay/ios-emi-admob-modification.js +52 -52
- package/files/buildCodeplay/modify-plugin-xml.js +36 -36
- package/files/buildCodeplay/packageidBaseModification-1.3.js +270 -270
- package/files/buildCodeplay/setSplashAnimation-1.2.js +170 -170
- package/files/buildCodeplay/splashxml/codeplay_splashScreen.xml +11 -11
- package/files/finalrelease +832 -832
- package/files/iap-install-2.js +145 -145
- package/files/ionic.config.json +6 -6
- package/package.json +16 -16
- package/scripts/sync-files.js +86 -86
- package/scripts/uninstall.js +77 -77
|
@@ -1,1198 +1,1210 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const plist = require('plist');
|
|
4
|
-
|
|
5
|
-
const { readFileSync } = require("fs");
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const configPath = path.join(process.cwd(), 'capacitor.config.json');
|
|
10
|
-
|
|
11
|
-
// Expected plugin list with minimum versions
|
|
12
|
-
const requiredPlugins = [
|
|
13
|
-
{ pattern: /backbutton-(\d+\.\d+)\.js$/, minVersion: '1.6', required: true },
|
|
14
|
-
{ pattern: /common-(\d+\.\d+)\.js$/, minVersion: '5.1', required: true },
|
|
15
|
-
{ pattern: /localization_settings-(\d+\.\d+)\.js$/, minVersion: '1.1', required: true },
|
|
16
|
-
{ pattern: /localization-(\d+\.\d+)\.js$/, minVersion: '1.3', required: true },
|
|
17
|
-
{ pattern: /localNotification-(\d+\.\d+)\.js$/, minVersion: '2.2', required: true },
|
|
18
|
-
{ pattern: /localNotification_AppSettings-(\d+\.\d+)\.js$/, minVersion: '1.0', required: true },
|
|
19
|
-
{ pattern: /onesignal-(\d+\.\d+)\.js$/, minVersion: '2.2', required: true },
|
|
20
|
-
{ pattern: /saveToGalleryAndSaveAnyFile-(\d+\.\d+)(-ios)?\.js$/, minVersion: '3.0', required: true },
|
|
21
|
-
{ pattern: /Ads[\/\\]IAP-(\d+\.\d+)$/, minVersion: '2.5', isFolder: true , required: true },
|
|
22
|
-
{ pattern: /Ads[\/\\]admob-emi-(\d+\.\d+)\.js$/, minVersion: '3.3', required: true },
|
|
23
|
-
|
|
24
|
-
// New added plugins
|
|
25
|
-
{ pattern: /video-player-(\d+\.\d+)\.js$/, minVersion: '1.5', required: true },
|
|
26
|
-
{ pattern: /image-cropper-(\d+\.\d+)\.js$/, minVersion: '1.1', required: true },
|
|
27
|
-
|
|
28
|
-
// New folders
|
|
29
|
-
{ pattern: /editor-(\d+\.\d+)$/, minVersion: '1.8', isFolder: true, required: true },
|
|
30
|
-
{ pattern: /ffmpeg-(\d+\.\d+)$/, minVersion: '1.3', isFolder: true, required: true }
|
|
31
|
-
];
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
//Check codeplay-common latest version installed or not Start
|
|
39
|
-
const { execSync } = require('child_process');
|
|
40
|
-
|
|
41
|
-
function getInstalledVersion(packageName) {
|
|
42
|
-
try {
|
|
43
|
-
const packageJsonPath = path.join(process.cwd(), 'node_modules', packageName, 'package.json');
|
|
44
|
-
if (fs.existsSync(packageJsonPath)) {
|
|
45
|
-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
46
|
-
return packageJson.version;
|
|
47
|
-
}
|
|
48
|
-
} catch (error) {
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function getLatestVersion(packageName) {
|
|
55
|
-
try {
|
|
56
|
-
return execSync(`npm view ${packageName} version`).toString().trim();
|
|
57
|
-
} catch (error) {
|
|
58
|
-
console.error(`Failed to fetch latest version for ${packageName}`);
|
|
59
|
-
return null;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function checkPackageVersion() {
|
|
64
|
-
const packageName = 'codeplay-common';
|
|
65
|
-
const installedVersion = getInstalledVersion(packageName);
|
|
66
|
-
const latestVersion = getLatestVersion(packageName);
|
|
67
|
-
|
|
68
|
-
if (!installedVersion) {
|
|
69
|
-
console.error(`${packageName} is not installed. Please install it using "npm install ${packageName}".`);
|
|
70
|
-
process.exit(1);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (installedVersion !== latestVersion) {
|
|
74
|
-
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`);
|
|
75
|
-
process.exit(1);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
console.log(`${packageName} is up to date (version ${installedVersion}).`);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// Run package version check before executing the main script
|
|
82
|
-
try {
|
|
83
|
-
checkPackageVersion();
|
|
84
|
-
} catch (error) {
|
|
85
|
-
console.error(error.message);
|
|
86
|
-
process.exit(1);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
//Check codeplay-common latest version installed or not END
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const checkAppUniqueId=()=>{
|
|
97
|
-
|
|
98
|
-
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
99
|
-
|
|
100
|
-
const appUniqueId = config.android?.APP_UNIQUE_ID;
|
|
101
|
-
const RESIZEABLE_ACTIVITY = config.android?.RESIZEABLE_ACTIVITY;
|
|
102
|
-
const orientation = config.android?.ORIENTATION;
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
let logErrorMessage="";
|
|
106
|
-
|
|
107
|
-
// 1️⃣ Check if it’s missing
|
|
108
|
-
if (RESIZEABLE_ACTIVITY === undefined) {
|
|
109
|
-
logErrorMessage+='❌ Missing android.RESIZEABLE_ACTIVITY option in capacitor.config.json.\n';
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// 2️⃣ Check if it’s not boolean (true/false only)
|
|
113
|
-
else if (typeof RESIZEABLE_ACTIVITY !== 'boolean') {
|
|
114
|
-
logErrorMessage+='❌ Invalid android.RESIZEABLE_ACTIVITY value. Please use only true or false (without quotes).\n';
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
if (!orientation) {
|
|
120
|
-
logErrorMessage+='❌ Missing android.ORIENTATION option in capacitor.config.json.\n';
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
else if(orientation!="portrait" && orientation!="landscape" && orientation!="auto")
|
|
124
|
-
{
|
|
125
|
-
logErrorMessage+='❌ Spelling mistake in android.ORIENTATION option in capacitor.config.json. Please use only ["portrait" "landscape" "auto"]\n';
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
if (!appUniqueId) {
|
|
130
|
-
logErrorMessage+='❌ APP_UNIQUE_ID is missing in capacitor.config.json.';
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
else if (!Number.isInteger(appUniqueId)) {
|
|
134
|
-
logErrorMessage+='❌ APP_UNIQUE_ID must be an integer. Example: 1, 2, 3, etc.';
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
if(logErrorMessage!="")
|
|
140
|
-
{
|
|
141
|
-
console.error(logErrorMessage);
|
|
142
|
-
process.exit(1)
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
console.log(`✅ APP_UNIQUE_ID is valid: ${appUniqueId}`);
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
checkAppUniqueId();
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
//@Codemirror check and install/uninstall the packages START
|
|
159
|
-
//const fs = require("fs");
|
|
160
|
-
//const path = require("path");
|
|
161
|
-
//const { execSync } = require("child_process");
|
|
162
|
-
|
|
163
|
-
const baseDir = path.join(__dirname, "..", "src", "js");
|
|
164
|
-
|
|
165
|
-
// Step 1: Find highest versioned folder like `editor-1.6`
|
|
166
|
-
const editorDirs = fs.readdirSync(baseDir)
|
|
167
|
-
.filter(name => /^editor-\d+\.\d+$/.test(name))
|
|
168
|
-
.sort((a, b) => {
|
|
169
|
-
const getVersion = str => str.match(/(\d+)\.(\d+)/).slice(1).map(Number);
|
|
170
|
-
const [aMajor, aMinor] = getVersion(a);
|
|
171
|
-
const [bMajor, bMinor] = getVersion(b);
|
|
172
|
-
return bMajor - aMajor || bMinor - aMinor;
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
if (editorDirs.length === 0) {
|
|
176
|
-
|
|
177
|
-
console.log("@Codemirror used editor(s) are not found")
|
|
178
|
-
//console.error("❌ No editor-x.x folders found in src/js.");
|
|
179
|
-
//process.exit(1);
|
|
180
|
-
}
|
|
181
|
-
else
|
|
182
|
-
{
|
|
183
|
-
|
|
184
|
-
const latestEditorDir = editorDirs.sort((a, b) => {
|
|
185
|
-
const versionA = parseFloat(a.split('-')[1]);
|
|
186
|
-
const versionB = parseFloat(b.split('-')[1]);
|
|
187
|
-
return versionB - versionA;
|
|
188
|
-
})[0];
|
|
189
|
-
|
|
190
|
-
//const latestEditorDir = editorDirs[editorDirs.length - 1];
|
|
191
|
-
const runJsPath = path.join(baseDir, latestEditorDir, "run.js");
|
|
192
|
-
|
|
193
|
-
if (!fs.existsSync(runJsPath)) {
|
|
194
|
-
console.error(`❌ run.js not found in ${latestEditorDir}`);
|
|
195
|
-
process.exit(1);
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
// Step 2: Execute the run.js file
|
|
199
|
-
console.log(`🚀 Executing ${runJsPath}...`);
|
|
200
|
-
execSync(`node "${runJsPath}"`, { stdio: "inherit" });
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
//@Codemirror check and install/uninstall the packages END
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
// saveToGalleryAndSaveAnyFile-x.x-ios.js file check for android and return error if exists START
|
|
217
|
-
|
|
218
|
-
const os = require('os');
|
|
219
|
-
|
|
220
|
-
const saveToGalleryAndSaveFileCheck_iOS = () => {
|
|
221
|
-
|
|
222
|
-
// List of paths to scan
|
|
223
|
-
const SCAN_PATHS = [
|
|
224
|
-
path.resolve(__dirname, '../src/certificate'),
|
|
225
|
-
path.resolve(__dirname, '../src/pages'),
|
|
226
|
-
path.resolve(__dirname, '../src/js'),
|
|
227
|
-
path.resolve(__dirname, '../src/app.f7')
|
|
228
|
-
];
|
|
229
|
-
|
|
230
|
-
// Directory to exclude
|
|
231
|
-
const EXCLUDED_DIR = path.resolve(__dirname, '../src/js/Ads');
|
|
232
|
-
|
|
233
|
-
const ANDROID_MANIFEST_PATH = path.resolve(__dirname, '../android/app/src/main/AndroidManifest.xml');
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
// Match iOS-specific imports (e.g., saveToGalleryAndSaveAnyFile-2.5-ios.js) not in comments
|
|
237
|
-
const IOS_FILE_REGEX = /^(?!\s*\/\/).*['"](?:.*\/)?saveToGalleryAndSaveAnyFile-\d+(\.\d+)*-ios\.js['"]/m;
|
|
238
|
-
|
|
239
|
-
// Match Android-specific imports (e.g., saveToGalleryAndSaveAnyFile-2.5.js) not in comments
|
|
240
|
-
const ANDROID_FILE_REGEX = /^(?!\s*\/\/).*['"](?:.*\/)?saveToGalleryAndSaveAnyFile-\d+(\.\d+)*\.js['"]/m;
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
const ALLOWED_EXTENSIONS = ['.js', '.f7'];
|
|
247
|
-
const isMac = os.platform() === 'darwin';
|
|
248
|
-
|
|
249
|
-
let iosImportFound = false;
|
|
250
|
-
let androidImportFound = false;
|
|
251
|
-
|
|
252
|
-
// Files to skip completely (full or partial match)
|
|
253
|
-
const SKIP_FILES = [
|
|
254
|
-
'pdf-3.11.174.min.js',
|
|
255
|
-
'pdf.worker-3.11.174.min.js'
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
const
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
console.
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
if (
|
|
335
|
-
console.log(
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
const
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
if (
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
//
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
const
|
|
654
|
-
const
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
APP_ID_ANDROID
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
'
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
'
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
const
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
"com.
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
}
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
}
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
}
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
});
|
|
976
|
-
|
|
977
|
-
rl
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
}
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
//
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
.
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
"
|
|
1121
|
-
"
|
|
1122
|
-
"
|
|
1123
|
-
"
|
|
1124
|
-
"
|
|
1125
|
-
"
|
|
1126
|
-
"
|
|
1127
|
-
"
|
|
1128
|
-
"
|
|
1129
|
-
"
|
|
1130
|
-
"
|
|
1131
|
-
"
|
|
1132
|
-
"
|
|
1133
|
-
"
|
|
1134
|
-
"
|
|
1135
|
-
"
|
|
1136
|
-
"
|
|
1137
|
-
"
|
|
1138
|
-
"
|
|
1139
|
-
"
|
|
1140
|
-
"
|
|
1141
|
-
"
|
|
1142
|
-
"
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const plist = require('plist');
|
|
4
|
+
|
|
5
|
+
const { readFileSync } = require("fs");
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
const configPath = path.join(process.cwd(), 'capacitor.config.json');
|
|
10
|
+
|
|
11
|
+
// Expected plugin list with minimum versions
|
|
12
|
+
const requiredPlugins = [
|
|
13
|
+
{ pattern: /backbutton-(\d+\.\d+)\.js$/, minVersion: '1.6', required: true },
|
|
14
|
+
{ pattern: /common-(\d+\.\d+)\.js$/, minVersion: '5.1', required: true },
|
|
15
|
+
{ pattern: /localization_settings-(\d+\.\d+)\.js$/, minVersion: '1.1', required: true },
|
|
16
|
+
{ pattern: /localization-(\d+\.\d+)\.js$/, minVersion: '1.3', required: true },
|
|
17
|
+
{ pattern: /localNotification-(\d+\.\d+)\.js$/, minVersion: '2.2', required: true },
|
|
18
|
+
{ pattern: /localNotification_AppSettings-(\d+\.\d+)\.js$/, minVersion: '1.0', required: true },
|
|
19
|
+
{ pattern: /onesignal-(\d+\.\d+)\.js$/, minVersion: '2.2', required: true },
|
|
20
|
+
{ pattern: /saveToGalleryAndSaveAnyFile-(\d+\.\d+)(-ios)?\.js$/, minVersion: '3.0', required: true },
|
|
21
|
+
{ pattern: /Ads[\/\\]IAP-(\d+\.\d+)$/, minVersion: '2.5', isFolder: true , required: true },
|
|
22
|
+
{ pattern: /Ads[\/\\]admob-emi-(\d+\.\d+)\.js$/, minVersion: '3.3', required: true },
|
|
23
|
+
|
|
24
|
+
// New added plugins
|
|
25
|
+
{ pattern: /video-player-(\d+\.\d+)\.js$/, minVersion: '1.5', required: true },
|
|
26
|
+
{ pattern: /image-cropper-(\d+\.\d+)\.js$/, minVersion: '1.1', required: true },
|
|
27
|
+
|
|
28
|
+
// New folders
|
|
29
|
+
{ pattern: /editor-(\d+\.\d+)$/, minVersion: '1.8', isFolder: true, required: true },
|
|
30
|
+
{ pattern: /ffmpeg-(\d+\.\d+)$/, minVersion: '1.3', isFolder: true, required: true }
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
//Check codeplay-common latest version installed or not Start
|
|
39
|
+
const { execSync } = require('child_process');
|
|
40
|
+
|
|
41
|
+
function getInstalledVersion(packageName) {
|
|
42
|
+
try {
|
|
43
|
+
const packageJsonPath = path.join(process.cwd(), 'node_modules', packageName, 'package.json');
|
|
44
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
45
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
46
|
+
return packageJson.version;
|
|
47
|
+
}
|
|
48
|
+
} catch (error) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function getLatestVersion(packageName) {
|
|
55
|
+
try {
|
|
56
|
+
return execSync(`npm view ${packageName} version`).toString().trim();
|
|
57
|
+
} catch (error) {
|
|
58
|
+
console.error(`Failed to fetch latest version for ${packageName}`);
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function checkPackageVersion() {
|
|
64
|
+
const packageName = 'codeplay-common';
|
|
65
|
+
const installedVersion = getInstalledVersion(packageName);
|
|
66
|
+
const latestVersion = getLatestVersion(packageName);
|
|
67
|
+
|
|
68
|
+
if (!installedVersion) {
|
|
69
|
+
console.error(`${packageName} is not installed. Please install it using "npm install ${packageName}".`);
|
|
70
|
+
process.exit(1);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (installedVersion !== latestVersion) {
|
|
74
|
+
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`);
|
|
75
|
+
process.exit(1);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
console.log(`${packageName} is up to date (version ${installedVersion}).`);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Run package version check before executing the main script
|
|
82
|
+
try {
|
|
83
|
+
checkPackageVersion();
|
|
84
|
+
} catch (error) {
|
|
85
|
+
console.error(error.message);
|
|
86
|
+
process.exit(1);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
//Check codeplay-common latest version installed or not END
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
const checkAppUniqueId=()=>{
|
|
97
|
+
|
|
98
|
+
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
99
|
+
|
|
100
|
+
const appUniqueId = config.android?.APP_UNIQUE_ID;
|
|
101
|
+
const RESIZEABLE_ACTIVITY = config.android?.RESIZEABLE_ACTIVITY;
|
|
102
|
+
const orientation = config.android?.ORIENTATION;
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
let logErrorMessage="";
|
|
106
|
+
|
|
107
|
+
// 1️⃣ Check if it’s missing
|
|
108
|
+
if (RESIZEABLE_ACTIVITY === undefined) {
|
|
109
|
+
logErrorMessage+='❌ Missing android.RESIZEABLE_ACTIVITY option in capacitor.config.json.\n';
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// 2️⃣ Check if it’s not boolean (true/false only)
|
|
113
|
+
else if (typeof RESIZEABLE_ACTIVITY !== 'boolean') {
|
|
114
|
+
logErrorMessage+='❌ Invalid android.RESIZEABLE_ACTIVITY value. Please use only true or false (without quotes).\n';
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
if (!orientation) {
|
|
120
|
+
logErrorMessage+='❌ Missing android.ORIENTATION option in capacitor.config.json.\n';
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
else if(orientation!="portrait" && orientation!="landscape" && orientation!="auto")
|
|
124
|
+
{
|
|
125
|
+
logErrorMessage+='❌ Spelling mistake in android.ORIENTATION option in capacitor.config.json. Please use only ["portrait" "landscape" "auto"]\n';
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
if (!appUniqueId) {
|
|
130
|
+
logErrorMessage+='❌ APP_UNIQUE_ID is missing in capacitor.config.json.';
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
else if (!Number.isInteger(appUniqueId)) {
|
|
134
|
+
logErrorMessage+='❌ APP_UNIQUE_ID must be an integer. Example: 1, 2, 3, etc.';
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
if(logErrorMessage!="")
|
|
140
|
+
{
|
|
141
|
+
console.error(logErrorMessage);
|
|
142
|
+
process.exit(1)
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
console.log(`✅ APP_UNIQUE_ID is valid: ${appUniqueId}`);
|
|
147
|
+
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
checkAppUniqueId();
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
//@Codemirror check and install/uninstall the packages START
|
|
159
|
+
//const fs = require("fs");
|
|
160
|
+
//const path = require("path");
|
|
161
|
+
//const { execSync } = require("child_process");
|
|
162
|
+
|
|
163
|
+
const baseDir = path.join(__dirname, "..", "src", "js");
|
|
164
|
+
|
|
165
|
+
// Step 1: Find highest versioned folder like `editor-1.6`
|
|
166
|
+
const editorDirs = fs.readdirSync(baseDir)
|
|
167
|
+
.filter(name => /^editor-\d+\.\d+$/.test(name))
|
|
168
|
+
.sort((a, b) => {
|
|
169
|
+
const getVersion = str => str.match(/(\d+)\.(\d+)/).slice(1).map(Number);
|
|
170
|
+
const [aMajor, aMinor] = getVersion(a);
|
|
171
|
+
const [bMajor, bMinor] = getVersion(b);
|
|
172
|
+
return bMajor - aMajor || bMinor - aMinor;
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
if (editorDirs.length === 0) {
|
|
176
|
+
|
|
177
|
+
console.log("@Codemirror used editor(s) are not found")
|
|
178
|
+
//console.error("❌ No editor-x.x folders found in src/js.");
|
|
179
|
+
//process.exit(1);
|
|
180
|
+
}
|
|
181
|
+
else
|
|
182
|
+
{
|
|
183
|
+
|
|
184
|
+
const latestEditorDir = editorDirs.sort((a, b) => {
|
|
185
|
+
const versionA = parseFloat(a.split('-')[1]);
|
|
186
|
+
const versionB = parseFloat(b.split('-')[1]);
|
|
187
|
+
return versionB - versionA;
|
|
188
|
+
})[0];
|
|
189
|
+
|
|
190
|
+
//const latestEditorDir = editorDirs[editorDirs.length - 1];
|
|
191
|
+
const runJsPath = path.join(baseDir, latestEditorDir, "run.js");
|
|
192
|
+
|
|
193
|
+
if (!fs.existsSync(runJsPath)) {
|
|
194
|
+
console.error(`❌ run.js not found in ${latestEditorDir}`);
|
|
195
|
+
process.exit(1);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// Step 2: Execute the run.js file
|
|
199
|
+
console.log(`🚀 Executing ${runJsPath}...`);
|
|
200
|
+
execSync(`node "${runJsPath}"`, { stdio: "inherit" });
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
//@Codemirror check and install/uninstall the packages END
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
// saveToGalleryAndSaveAnyFile-x.x-ios.js file check for android and return error if exists START
|
|
217
|
+
|
|
218
|
+
const os = require('os');
|
|
219
|
+
|
|
220
|
+
const saveToGalleryAndSaveFileCheck_iOS = () => {
|
|
221
|
+
|
|
222
|
+
// List of paths to scan
|
|
223
|
+
const SCAN_PATHS = [
|
|
224
|
+
path.resolve(__dirname, '../src/certificate'),
|
|
225
|
+
path.resolve(__dirname, '../src/pages'),
|
|
226
|
+
path.resolve(__dirname, '../src/js'),
|
|
227
|
+
path.resolve(__dirname, '../src/app.f7')
|
|
228
|
+
];
|
|
229
|
+
|
|
230
|
+
// Directory to exclude
|
|
231
|
+
const EXCLUDED_DIR = path.resolve(__dirname, '../src/js/Ads');
|
|
232
|
+
|
|
233
|
+
const ANDROID_MANIFEST_PATH = path.resolve(__dirname, '../android/app/src/main/AndroidManifest.xml');
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
// Match iOS-specific imports (e.g., saveToGalleryAndSaveAnyFile-2.5-ios.js) not in comments
|
|
237
|
+
const IOS_FILE_REGEX = /^(?!\s*\/\/).*['"](?:.*\/)?saveToGalleryAndSaveAnyFile-\d+(\.\d+)*-ios\.js['"]/m;
|
|
238
|
+
|
|
239
|
+
// Match Android-specific imports (e.g., saveToGalleryAndSaveAnyFile-2.5.js) not in comments
|
|
240
|
+
const ANDROID_FILE_REGEX = /^(?!\s*\/\/).*['"](?:.*\/)?saveToGalleryAndSaveAnyFile-\d+(\.\d+)*\.js['"]/m;
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
const ALLOWED_EXTENSIONS = ['.js', '.f7'];
|
|
247
|
+
const isMac = os.platform() === 'darwin';
|
|
248
|
+
|
|
249
|
+
let iosImportFound = false;
|
|
250
|
+
let androidImportFound = false;
|
|
251
|
+
|
|
252
|
+
// Files to skip completely (full or partial match)
|
|
253
|
+
const SKIP_FILES = [
|
|
254
|
+
'pdf-3.11.174.min.js',
|
|
255
|
+
'pdf.worker-3.11.174.min.js'
|
|
256
|
+
,'index.browser.js'
|
|
257
|
+
];
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
function scanDirectory(dir) {
|
|
261
|
+
|
|
262
|
+
/*
|
|
263
|
+
//######################### DO NOT DELETE THIS - START [Appid base validation] #####################################
|
|
264
|
+
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
265
|
+
const appUniqueId = config.android?.APP_UNIQUE_ID;
|
|
266
|
+
if (appUniqueId == "206") return;
|
|
267
|
+
//######################### DO NOT DELETE THIS - END [Appid base validation] #####################################
|
|
268
|
+
*/
|
|
269
|
+
|
|
270
|
+
const stat = fs.statSync(dir);
|
|
271
|
+
|
|
272
|
+
if (stat.isFile()) {
|
|
273
|
+
|
|
274
|
+
// 🔥 Skip files in SKIP_FILES array
|
|
275
|
+
const baseName = path.basename(dir);
|
|
276
|
+
if (SKIP_FILES.includes(baseName)) {
|
|
277
|
+
// Just skip silently
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// Only scan allowed file extensions
|
|
282
|
+
if (ALLOWED_EXTENSIONS.some(ext => dir.endsWith(ext))) {
|
|
283
|
+
process.stdout.write(`\r🔍 Scanning: ${dir} `);
|
|
284
|
+
|
|
285
|
+
const content = fs.readFileSync(dir, 'utf8');
|
|
286
|
+
|
|
287
|
+
if (IOS_FILE_REGEX.test(content)) {
|
|
288
|
+
iosImportFound = true;
|
|
289
|
+
if (!isMac) {
|
|
290
|
+
console.error(`\n❌ ERROR: iOS-specific import detected in: ${dir}`);
|
|
291
|
+
console.error(`🚫 STOPPED: This file should not be imported in Android/Windows/Linux builds.\n`);
|
|
292
|
+
process.exit(1);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
else if (ANDROID_FILE_REGEX.test(content) && !content.includes('-ios.js')) {
|
|
296
|
+
androidImportFound = true;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
else if (stat.isDirectory()) {
|
|
301
|
+
if (dir === EXCLUDED_DIR || path.basename(dir) === 'node_modules') return;
|
|
302
|
+
|
|
303
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
304
|
+
for (let entry of entries) {
|
|
305
|
+
scanDirectory(path.join(dir, entry.name));
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
// Run scan on all specified paths
|
|
312
|
+
for (let scanPath of SCAN_PATHS) {
|
|
313
|
+
if (fs.existsSync(scanPath)) {
|
|
314
|
+
scanDirectory(scanPath);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
/* // Check src folder
|
|
321
|
+
if (!fs.existsSync(ROOT_DIR)) {
|
|
322
|
+
console.warn(`⚠️ Warning: 'src' directory not found at: ${ROOT_DIR}`);
|
|
323
|
+
return;
|
|
324
|
+
} */
|
|
325
|
+
|
|
326
|
+
//scanDirectory(ROOT_DIR);
|
|
327
|
+
|
|
328
|
+
// iOS Checks
|
|
329
|
+
if (isMac && !iosImportFound) {
|
|
330
|
+
console.warn(`⚠️ WARNING: You're on macOS but no iOS version (saveToGalleryAndSaveAnyFile-x.x-ios.js) found.`);
|
|
331
|
+
process.exit(1);
|
|
332
|
+
} else if (isMac && iosImportFound) {
|
|
333
|
+
console.log('✅ iOS version detected for macOS build.');
|
|
334
|
+
} else if (!iosImportFound) {
|
|
335
|
+
console.log('✅ No iOS-specific imports detected for non-macOS.');
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
// Android Checks
|
|
339
|
+
if (androidImportFound) {
|
|
340
|
+
console.log("📱 Android version of saveToGalleryAndSaveAnyFile detected. Checking AndroidManifest.xml...");
|
|
341
|
+
|
|
342
|
+
if (!fs.existsSync(ANDROID_MANIFEST_PATH)) {
|
|
343
|
+
console.error("❌ AndroidManifest.xml not found. Cannot add requestLegacyExternalStorage attribute.");
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
let manifestContent = fs.readFileSync(ANDROID_MANIFEST_PATH, 'utf8');
|
|
348
|
+
|
|
349
|
+
if (!manifestContent.includes('android:requestLegacyExternalStorage="true"')) {
|
|
350
|
+
console.log("Adding android:requestLegacyExternalStorage=\"true\" to <application> tag...");
|
|
351
|
+
|
|
352
|
+
manifestContent = manifestContent.replace(
|
|
353
|
+
/<application([^>]*)>/,
|
|
354
|
+
(match, attrs) => {
|
|
355
|
+
if (attrs.includes('android:requestLegacyExternalStorage')) return match;
|
|
356
|
+
return `<application${attrs} android:requestLegacyExternalStorage="true">`;
|
|
357
|
+
}
|
|
358
|
+
);
|
|
359
|
+
|
|
360
|
+
fs.writeFileSync(ANDROID_MANIFEST_PATH, manifestContent, 'utf8');
|
|
361
|
+
console.log("✅ android:requestLegacyExternalStorage=\"true\" added successfully.");
|
|
362
|
+
} else {
|
|
363
|
+
console.log("ℹ️ android:requestLegacyExternalStorage already exists in AndroidManifest.xml.");
|
|
364
|
+
}
|
|
365
|
+
} else {
|
|
366
|
+
console.log("✅ No Android saveToGalleryAndSaveAnyFile imports detected.");
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
saveToGalleryAndSaveFileCheck_iOS();
|
|
371
|
+
// saveToGalleryAndSaveAnyFile-x.x-ios.js file check for android and return error if exists END
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
/*
|
|
386
|
+
// Clean up AppleDouble files (._*) created by macOS START
|
|
387
|
+
if (process.platform === 'darwin') {
|
|
388
|
+
try {
|
|
389
|
+
console.log('🧹 Cleaning up AppleDouble files (._*)...');
|
|
390
|
+
execSync(`find . -name '._*' -delete`);
|
|
391
|
+
console.log('✅ AppleDouble files removed.');
|
|
392
|
+
} catch (err) {
|
|
393
|
+
console.warn('⚠️ Failed to remove AppleDouble files:', err.message);
|
|
394
|
+
}
|
|
395
|
+
} else {
|
|
396
|
+
console.log('ℹ️ Skipping AppleDouble cleanup — not a macOS machine.');
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
// Clean up AppleDouble files (._*) created by macOS END
|
|
400
|
+
*/
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
//In routes.js file check static import START
|
|
408
|
+
|
|
409
|
+
const routesPath = path.join(process.cwd(), 'src', 'js', 'routes.js');
|
|
410
|
+
const routesContent = fs.readFileSync(routesPath, 'utf-8');
|
|
411
|
+
|
|
412
|
+
let inBlockComment = false;
|
|
413
|
+
const lines = routesContent.split('\n');
|
|
414
|
+
|
|
415
|
+
const allowedImport = `import HomePage from '../pages/home.f7';`;
|
|
416
|
+
const badImportRegex = /^[ \t]*import\s+[\w{}*,\s]*\s+from\s+['"].+\.f7['"]\s*;/;
|
|
417
|
+
const badImports = [];
|
|
418
|
+
|
|
419
|
+
lines.forEach((line, index) => {
|
|
420
|
+
const trimmed = line.trim();
|
|
421
|
+
|
|
422
|
+
// Handle block comment start and end
|
|
423
|
+
if (trimmed.startsWith('/*')) inBlockComment = true;
|
|
424
|
+
if (inBlockComment && trimmed.endsWith('*/')) {
|
|
425
|
+
inBlockComment = false;
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
// Skip if inside block comment or line comment
|
|
430
|
+
if (inBlockComment || trimmed.startsWith('//')) return;
|
|
431
|
+
|
|
432
|
+
// Match static .f7 import
|
|
433
|
+
if (badImportRegex.test(trimmed) && trimmed !== allowedImport) {
|
|
434
|
+
badImports.push({ line: trimmed, number: index + 1 });
|
|
435
|
+
}
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
if (badImports.length > 0) {
|
|
439
|
+
console.error('\n❌ ERROR: Detected disallowed static imports of .f7 files in routes.js\n');
|
|
440
|
+
console.error(`⚠️ Only this static import is allowed:\n ${allowedImport}\n`);
|
|
441
|
+
console.error(`🔧 Please convert other imports to async dynamic imports like this:\n`);
|
|
442
|
+
console.error(`
|
|
443
|
+
|
|
444
|
+
import HomePage from '../pages/home.f7';
|
|
445
|
+
|
|
446
|
+
const routes = [
|
|
447
|
+
{
|
|
448
|
+
path: '/',
|
|
449
|
+
component:HomePage,
|
|
450
|
+
},
|
|
451
|
+
{
|
|
452
|
+
path: '/ProfilePage/',
|
|
453
|
+
async async({ resolve }) {
|
|
454
|
+
const page = await import('../pages/profile.f7');
|
|
455
|
+
resolve({ component: page.default });
|
|
456
|
+
},
|
|
457
|
+
}]
|
|
458
|
+
`);
|
|
459
|
+
|
|
460
|
+
badImports.forEach(({ line, number }) => {
|
|
461
|
+
console.error(`${number}: ${line}`);
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
process.exit(1);
|
|
465
|
+
} else {
|
|
466
|
+
console.log('✅ routes.js passed the .f7 import check.');
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
//In routes.js file check static import END
|
|
470
|
+
|
|
471
|
+
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
// Check and change the "BridgeWebViewClient.java" file START
|
|
484
|
+
/*
|
|
485
|
+
For crash issue due to low memory problem, we need to modify the onRenderProcessGone method in BridgeWebViewClient.java.
|
|
486
|
+
*/
|
|
487
|
+
|
|
488
|
+
|
|
489
|
+
const bridgeWebViewClientFilePath = path.join(process.cwd(), 'node_modules', '@capacitor/android/capacitor/src/main/java/com/getcapacitor', 'BridgeWebViewClient.java');
|
|
490
|
+
|
|
491
|
+
// Read the file
|
|
492
|
+
if (!fs.existsSync(bridgeWebViewClientFilePath)) {
|
|
493
|
+
console.error('❌ Error: BridgeWebViewClient.java not found.');
|
|
494
|
+
process.exit(1);
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
let fileContent = fs.readFileSync(bridgeWebViewClientFilePath, 'utf8');
|
|
498
|
+
|
|
499
|
+
// Define old and new code
|
|
500
|
+
const oldCodeStart = `@Override
|
|
501
|
+
public boolean onRenderProcessGone(WebView view, RenderProcessGoneDetail detail) {
|
|
502
|
+
super.onRenderProcessGone(view, detail);
|
|
503
|
+
boolean result = false;
|
|
504
|
+
|
|
505
|
+
List<WebViewListener> webViewListeners = bridge.getWebViewListeners();
|
|
506
|
+
if (webViewListeners != null) {
|
|
507
|
+
for (WebViewListener listener : bridge.getWebViewListeners()) {
|
|
508
|
+
result = listener.onRenderProcessGone(view, detail) || result;
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
return result;
|
|
513
|
+
}`;
|
|
514
|
+
|
|
515
|
+
const newCode = `@Override
|
|
516
|
+
public boolean onRenderProcessGone(WebView view, RenderProcessGoneDetail detail) {
|
|
517
|
+
super.onRenderProcessGone(view, detail);
|
|
518
|
+
|
|
519
|
+
boolean result = false;
|
|
520
|
+
|
|
521
|
+
List<WebViewListener> webViewListeners = bridge.getWebViewListeners();
|
|
522
|
+
if (webViewListeners != null) {
|
|
523
|
+
for (WebViewListener listener : bridge.getWebViewListeners()) {
|
|
524
|
+
result = listener.onRenderProcessGone(view, detail) || result;
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
if (!result) {
|
|
529
|
+
// If no one handled it, handle it ourselves!
|
|
530
|
+
|
|
531
|
+
/*if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
532
|
+
if (detail.didCrash()) {
|
|
533
|
+
//Log.e("CapacitorWebView", "WebView crashed internally!");
|
|
534
|
+
} else {
|
|
535
|
+
//Log.w("CapacitorWebView", "WebView was killed by system (low memory) internally!");
|
|
536
|
+
}
|
|
537
|
+
}*/
|
|
538
|
+
|
|
539
|
+
view.post(() -> {
|
|
540
|
+
Toast.makeText(view.getContext(), "Reloading due to low memory issue", Toast.LENGTH_SHORT).show();
|
|
541
|
+
});
|
|
542
|
+
|
|
543
|
+
view.reload(); // Safely reload WebView
|
|
544
|
+
|
|
545
|
+
return true; // We handled it
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
return result;
|
|
549
|
+
}`;
|
|
550
|
+
|
|
551
|
+
// Step 1: Update method if needed
|
|
552
|
+
let updated = false;
|
|
553
|
+
|
|
554
|
+
if (fileContent.includes(oldCodeStart)) {
|
|
555
|
+
console.log('✅ Found old onRenderProcessGone method. Replacing it...');
|
|
556
|
+
fileContent = fileContent.replace(oldCodeStart, newCode);
|
|
557
|
+
updated = true;
|
|
558
|
+
} else if (fileContent.includes(newCode)) {
|
|
559
|
+
console.log('ℹ️ Method already updated. No changes needed in "BridgeWebViewClient.java".');
|
|
560
|
+
} else {
|
|
561
|
+
console.error('❌ Error: Neither old nor new code found. Unexpected content.');
|
|
562
|
+
process.exit(1);
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
// Step 2: Check and add import if missing
|
|
566
|
+
const importToast = 'import android.widget.Toast;';
|
|
567
|
+
if (!fileContent.includes(importToast)) {
|
|
568
|
+
console.log('✅ Adding missing import for Toast...');
|
|
569
|
+
const importRegex = /import\s+[^;]+;/g;
|
|
570
|
+
const matches = [...fileContent.matchAll(importRegex)];
|
|
571
|
+
|
|
572
|
+
if (matches.length > 0) {
|
|
573
|
+
const lastImport = matches[matches.length - 1];
|
|
574
|
+
const insertPosition = lastImport.index + lastImport[0].length;
|
|
575
|
+
fileContent = fileContent.slice(0, insertPosition) + `\n${importToast}` + fileContent.slice(insertPosition);
|
|
576
|
+
updated = true;
|
|
577
|
+
} else {
|
|
578
|
+
console.error('❌ Error: No import section found in file.');
|
|
579
|
+
process.exit(1);
|
|
580
|
+
}
|
|
581
|
+
} else {
|
|
582
|
+
console.log('ℹ️ Import for Toast already exists. No changes needed.');
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
// Step 3: Save if updated
|
|
586
|
+
if (updated) {
|
|
587
|
+
fs.writeFileSync(bridgeWebViewClientFilePath, fileContent, 'utf8');
|
|
588
|
+
console.log('✅ File updated successfully.');
|
|
589
|
+
} else {
|
|
590
|
+
console.log('ℹ️ No changes needed.');
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
|
|
594
|
+
|
|
595
|
+
|
|
596
|
+
// Check and change the "BridgeWebViewClient.java" file END
|
|
597
|
+
|
|
598
|
+
|
|
599
|
+
|
|
600
|
+
|
|
601
|
+
|
|
602
|
+
|
|
603
|
+
|
|
604
|
+
|
|
605
|
+
/*
|
|
606
|
+
// To resolve the kotlin version issue, we need to update the kotlin version in the build.gradle file START
|
|
607
|
+
|
|
608
|
+
// Build the path dynamically like you requested
|
|
609
|
+
const gradlePath = path.join(
|
|
610
|
+
process.cwd(),
|
|
611
|
+
'android',
|
|
612
|
+
'build.gradle'
|
|
613
|
+
);
|
|
614
|
+
|
|
615
|
+
// Read the existing build.gradle
|
|
616
|
+
let gradleContent = fs.readFileSync(gradlePath, 'utf8');
|
|
617
|
+
|
|
618
|
+
// Add `ext.kotlin_version` if it's not already there
|
|
619
|
+
if (!gradleContent.includes('ext.kotlin_version')) {
|
|
620
|
+
gradleContent = gradleContent.replace(
|
|
621
|
+
/buildscript\s*{/,
|
|
622
|
+
`buildscript {\n ext.kotlin_version = '2.1.0'`
|
|
623
|
+
);
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
// Add Kotlin classpath if it's not already there
|
|
627
|
+
if (!gradleContent.includes('org.jetbrains.kotlin:kotlin-gradle-plugin')) {
|
|
628
|
+
gradleContent = gradleContent.replace(
|
|
629
|
+
/dependencies\s*{([\s\S]*?)classpath 'com.android.tools.build:gradle:8.7.2'/,
|
|
630
|
+
`dependencies {\n classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version")\n$1classpath 'com.android.tools.build:gradle:8.7.2'`
|
|
631
|
+
);
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
// Write back the modified content
|
|
635
|
+
fs.writeFileSync(gradlePath, gradleContent, 'utf8');
|
|
636
|
+
|
|
637
|
+
console.log('✅ Kotlin version updated in build.gradle.');
|
|
638
|
+
|
|
639
|
+
// To resolve the kotlin version issue, we need to update the kotlin version in the build.gradle file END
|
|
640
|
+
*/
|
|
641
|
+
|
|
642
|
+
|
|
643
|
+
|
|
644
|
+
|
|
645
|
+
|
|
646
|
+
|
|
647
|
+
|
|
648
|
+
|
|
649
|
+
let _admobConfig;
|
|
650
|
+
|
|
651
|
+
|
|
652
|
+
|
|
653
|
+
const androidPlatformPath = path.join(process.cwd(), 'android');
|
|
654
|
+
const iosPlatformPath = path.join(process.cwd(), 'ios');
|
|
655
|
+
const pluginPath = path.join(process.cwd(), 'node_modules', 'emi-indo-cordova-plugin-admob', 'plugin.xml');
|
|
656
|
+
const infoPlistPath = path.join(process.cwd(), 'ios', 'App', 'App', 'Info.plist');
|
|
657
|
+
const resourcesPath = path.join(process.cwd(), 'resources', 'res');
|
|
658
|
+
const androidResPath = path.join(process.cwd(), 'android', 'app', 'src', 'main', 'res');
|
|
659
|
+
const localNotificationsPluginPath = path.join(process.cwd(), 'node_modules', '@capacitor', 'local-notifications');
|
|
660
|
+
|
|
661
|
+
function fileExists(filePath) {
|
|
662
|
+
return fs.existsSync(filePath);
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
function copyFolderSync(source, target) {
|
|
666
|
+
if (!fs.existsSync(target)) {
|
|
667
|
+
fs.mkdirSync(target, { recursive: true });
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
fs.readdirSync(source).forEach(file => {
|
|
671
|
+
const sourceFile = path.join(source, file);
|
|
672
|
+
const targetFile = path.join(target, file);
|
|
673
|
+
|
|
674
|
+
if (fs.lstatSync(sourceFile).isDirectory()) {
|
|
675
|
+
copyFolderSync(sourceFile, targetFile);
|
|
676
|
+
} else {
|
|
677
|
+
fs.copyFileSync(sourceFile, targetFile);
|
|
678
|
+
}
|
|
679
|
+
});
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
function checkAndCopyResources() {
|
|
683
|
+
if (fileExists(resourcesPath)) {
|
|
684
|
+
copyFolderSync(resourcesPath, androidResPath);
|
|
685
|
+
console.log('✅ Successfully copied resources/res to android/app/src/main/res.');
|
|
686
|
+
} else {
|
|
687
|
+
console.log('resources/res folder not found.');
|
|
688
|
+
|
|
689
|
+
if (fileExists(localNotificationsPluginPath)) {
|
|
690
|
+
throw new Error('❌ resources/res is required for @capacitor/local-notifications. Stopping execution.');
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
|
|
696
|
+
|
|
697
|
+
|
|
698
|
+
|
|
699
|
+
|
|
700
|
+
|
|
701
|
+
|
|
702
|
+
function getAdMobConfig() {
|
|
703
|
+
if (!fileExists(configPath)) {
|
|
704
|
+
throw new Error('❌ capacitor.config.json not found. Ensure this is a Capacitor project.');
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
708
|
+
const admobConfig = config.plugins?.AdMob;
|
|
709
|
+
|
|
710
|
+
if (!admobConfig) {
|
|
711
|
+
throw new Error('❌ AdMob configuration is missing in capacitor.config.json.');
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
// Default to true if ADMOB_ENABLED is not specified
|
|
715
|
+
const isEnabled = admobConfig.ADMOB_ENABLED !== false;
|
|
716
|
+
|
|
717
|
+
if (!isEnabled) {
|
|
718
|
+
return { ADMOB_ENABLED: false }; // Skip further validation
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
if (!admobConfig.APP_ID_ANDROID || !admobConfig.APP_ID_IOS) {
|
|
722
|
+
throw new Error(' ❌ AdMob configuration is incomplete. Ensure APP_ID_ANDROID and APP_ID_IOS are defined.');
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
return {
|
|
726
|
+
ADMOB_ENABLED: true,
|
|
727
|
+
APP_ID_ANDROID: admobConfig.APP_ID_ANDROID,
|
|
728
|
+
APP_ID_IOS: admobConfig.APP_ID_IOS,
|
|
729
|
+
USE_LITE_ADS: admobConfig.USE_LITE_ADS === "lite",
|
|
730
|
+
};
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
function validateAndroidBuildOptions() {
|
|
734
|
+
|
|
735
|
+
|
|
736
|
+
if (!fileExists(configPath)) {
|
|
737
|
+
console.log('❌ capacitor.config.json not found. Ensure this is a Capacitor project.');
|
|
738
|
+
process.exit(1);
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
742
|
+
|
|
743
|
+
const targetAppId=config.appId
|
|
744
|
+
|
|
745
|
+
const buildOptions = config.android?.buildOptions;
|
|
746
|
+
|
|
747
|
+
if (!buildOptions) {
|
|
748
|
+
console.log('❌ Missing android.buildOptions in capacitor.config.json.');
|
|
749
|
+
process.exit(1);
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
const requiredProps = [
|
|
753
|
+
'keystorePath',
|
|
754
|
+
'keystorePassword',
|
|
755
|
+
'keystoreAlias',
|
|
756
|
+
'keystoreAliasPassword',
|
|
757
|
+
'releaseType',
|
|
758
|
+
'signingType'
|
|
759
|
+
];
|
|
760
|
+
|
|
761
|
+
const missing = requiredProps.filter(prop => !buildOptions[prop]);
|
|
762
|
+
|
|
763
|
+
if (missing.length > 0) {
|
|
764
|
+
console.log('❌ Missing properties android.buildOptions in capacitor.config.json.');
|
|
765
|
+
process.exit(1);
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
|
|
769
|
+
const keystorePath=buildOptions.keystorePath
|
|
770
|
+
const keyFileName = path.basename(keystorePath);
|
|
771
|
+
|
|
772
|
+
|
|
773
|
+
|
|
774
|
+
const keystoreMap = {
|
|
775
|
+
"gameskey.jks": [
|
|
776
|
+
"com.cube.blaster",
|
|
777
|
+
],
|
|
778
|
+
"htmleditorkeystoke.jks": [
|
|
779
|
+
"com.HTML.AngularJS.Codeplay",
|
|
780
|
+
"com.html.codeplay.pro",
|
|
781
|
+
"com.bootstrap.code.play",
|
|
782
|
+
"com.kids.learning.master",
|
|
783
|
+
"com.Simple.Barcode.Scanner"
|
|
784
|
+
]
|
|
785
|
+
};
|
|
786
|
+
|
|
787
|
+
// find which keystore is required for the given targetAppId
|
|
788
|
+
let requiredKey = "newappskey.jks"; // default
|
|
789
|
+
for (const [keyFile, appIds] of Object.entries(keystoreMap)) {
|
|
790
|
+
if (appIds.includes(targetAppId)) {
|
|
791
|
+
requiredKey = keyFile;
|
|
792
|
+
break;
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
// validate
|
|
797
|
+
if (keyFileName !== requiredKey) {
|
|
798
|
+
console.log(`❌ The keystore path is mismatched. Expected ${requiredKey} for ${targetAppId}, but got ${keyFileName}`);
|
|
799
|
+
process.exit(1);
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
|
|
803
|
+
|
|
804
|
+
|
|
805
|
+
|
|
806
|
+
// optionally return them
|
|
807
|
+
//return buildOptions;
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
function updatePluginXml(admobConfig) {
|
|
811
|
+
if (!fileExists(pluginPath)) {
|
|
812
|
+
console.error(' ❌ plugin.xml not found. Ensure the plugin is installed.');
|
|
813
|
+
return;
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
let pluginContent = fs.readFileSync(pluginPath, 'utf8');
|
|
817
|
+
|
|
818
|
+
pluginContent = pluginContent
|
|
819
|
+
.replace(/<preference name="APP_ID_ANDROID" default=".*?" \/>/, `<preference name="APP_ID_ANDROID" default="${admobConfig.APP_ID_ANDROID}" />`)
|
|
820
|
+
.replace(/<preference name="APP_ID_IOS" default=".*?" \/>/, `<preference name="APP_ID_IOS" default="${admobConfig.APP_ID_IOS}" />`);
|
|
821
|
+
|
|
822
|
+
fs.writeFileSync(pluginPath, pluginContent, 'utf8');
|
|
823
|
+
console.log('✅ AdMob IDs successfully updated in plugin.xml');
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
function updateInfoPlist(admobConfig) {
|
|
827
|
+
if (!fileExists(infoPlistPath)) {
|
|
828
|
+
console.error(' ❌ Info.plist not found. Ensure you have built the iOS project.');
|
|
829
|
+
return;
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
const plistContent = fs.readFileSync(infoPlistPath, 'utf8');
|
|
833
|
+
const plistData = plist.parse(plistContent);
|
|
834
|
+
|
|
835
|
+
plistData.GADApplicationIdentifier = admobConfig.APP_ID_IOS;
|
|
836
|
+
plistData.NSUserTrackingUsageDescription = 'This identifier will be used to deliver personalized ads to you.';
|
|
837
|
+
plistData.GADDelayAppMeasurementInit = true;
|
|
838
|
+
|
|
839
|
+
const updatedPlistContent = plist.build(plistData);
|
|
840
|
+
fs.writeFileSync(infoPlistPath, updatedPlistContent, 'utf8');
|
|
841
|
+
console.log('AdMob IDs and additional configurations successfully updated in Info.plist');
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
|
|
845
|
+
try {
|
|
846
|
+
if (!fileExists(configPath)) {
|
|
847
|
+
throw new Error(' ❌ capacitor.config.json not found. Skipping setup.');
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
if (!fileExists(androidPlatformPath) && !fileExists(iosPlatformPath)) {
|
|
851
|
+
throw new Error('Neither Android nor iOS platforms are found. Ensure platforms are added to your Capacitor project.');
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
checkAndCopyResources();
|
|
855
|
+
|
|
856
|
+
|
|
857
|
+
|
|
858
|
+
_admobConfig = getAdMobConfig();
|
|
859
|
+
|
|
860
|
+
|
|
861
|
+
|
|
862
|
+
|
|
863
|
+
|
|
864
|
+
// Proceed only if ADMOB_ENABLED is true
|
|
865
|
+
if (_admobConfig.ADMOB_ENABLED) {
|
|
866
|
+
if (fileExists(androidPlatformPath)) {
|
|
867
|
+
updatePluginXml(_admobConfig);
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
if (fileExists(iosPlatformPath)) {
|
|
871
|
+
updateInfoPlist(_admobConfig);
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
|
|
876
|
+
} catch (error) {
|
|
877
|
+
console.error(error.message);
|
|
878
|
+
process.exit(1); // Stop execution if there's a critical error
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
|
|
882
|
+
|
|
883
|
+
validateAndroidBuildOptions();
|
|
884
|
+
|
|
885
|
+
|
|
886
|
+
|
|
887
|
+
|
|
888
|
+
|
|
889
|
+
|
|
890
|
+
// Check all the codeplays plugins version START
|
|
891
|
+
|
|
892
|
+
|
|
893
|
+
const readline = require('readline');
|
|
894
|
+
|
|
895
|
+
|
|
896
|
+
//const srcDir = path.join(__dirname, 'src');
|
|
897
|
+
const srcDir = path.join(process.cwd(), 'src');
|
|
898
|
+
let outdatedPlugins = [];
|
|
899
|
+
|
|
900
|
+
function parseVersion(ver) {
|
|
901
|
+
return ver.split('.').map(n => parseInt(n, 10));
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
function compareVersions(v1, v2) {
|
|
905
|
+
const [a1, b1] = parseVersion(v1);
|
|
906
|
+
const [a2, b2] = parseVersion(v2);
|
|
907
|
+
if (a1 !== a2) return a1 - a2;
|
|
908
|
+
return b1 - b2;
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
function walkSync(dir, filelist = []) {
|
|
912
|
+
fs.readdirSync(dir).forEach(file => {
|
|
913
|
+
const fullPath = path.join(dir, file);
|
|
914
|
+
const stat = fs.statSync(fullPath);
|
|
915
|
+
if (stat.isDirectory()) {
|
|
916
|
+
walkSync(fullPath, filelist);
|
|
917
|
+
} else {
|
|
918
|
+
filelist.push(fullPath);
|
|
919
|
+
}
|
|
920
|
+
});
|
|
921
|
+
return filelist;
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
function checkPlugins() {
|
|
925
|
+
const files = walkSync(srcDir);
|
|
926
|
+
|
|
927
|
+
for (const plugin of requiredPlugins) {
|
|
928
|
+
if (plugin.isFolder) {
|
|
929
|
+
|
|
930
|
+
let baseFolder = path.join(srcDir,'js', 'Ads'); // <- use known folder name
|
|
931
|
+
|
|
932
|
+
if (fs.existsSync(baseFolder)) {
|
|
933
|
+
const subDirs = fs.readdirSync(baseFolder)
|
|
934
|
+
.map(name => path.join(baseFolder, name))
|
|
935
|
+
.filter(p => fs.statSync(p).isDirectory());
|
|
936
|
+
|
|
937
|
+
for (const dir of subDirs) {
|
|
938
|
+
const relativePath = path.relative(srcDir, dir).replace(/\\/g, '/'); // e.g. Ads/IAP-2.0
|
|
939
|
+
const match = plugin.pattern.exec(relativePath);
|
|
940
|
+
if (match) {
|
|
941
|
+
const currentVersion = match[1];
|
|
942
|
+
if (compareVersions(currentVersion, plugin.minVersion) < 0) {
|
|
943
|
+
outdatedPlugins.push({
|
|
944
|
+
name: relativePath,
|
|
945
|
+
currentVersion,
|
|
946
|
+
requiredVersion: plugin.minVersion
|
|
947
|
+
});
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
continue;
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
const matchedFile = files.find(file => plugin.pattern.test(file));
|
|
956
|
+
if (matchedFile) {
|
|
957
|
+
const match = plugin.pattern.exec(matchedFile);
|
|
958
|
+
if (match) {
|
|
959
|
+
const currentVersion = match[1];
|
|
960
|
+
if (compareVersions(currentVersion, plugin.minVersion) < 0) {
|
|
961
|
+
outdatedPlugins.push({
|
|
962
|
+
name: path.relative(__dirname, matchedFile),
|
|
963
|
+
currentVersion,
|
|
964
|
+
requiredVersion: plugin.minVersion
|
|
965
|
+
});
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
if (outdatedPlugins.length > 0) {
|
|
972
|
+
console.log('\n❗ The following plugins are outdated:');
|
|
973
|
+
outdatedPlugins.forEach(p => {
|
|
974
|
+
console.log(` ❌ - ${p.name} (Current: ${p.currentVersion}, Required: ${p.requiredVersion})`);
|
|
975
|
+
});
|
|
976
|
+
|
|
977
|
+
const rl = readline.createInterface({
|
|
978
|
+
input: process.stdin,
|
|
979
|
+
output: process.stdout
|
|
980
|
+
});
|
|
981
|
+
|
|
982
|
+
rl.question('\nAre you sure you want to continue without updating these plugins? (y/n): ', answer => {
|
|
983
|
+
if (answer.toLowerCase() !== 'y') {
|
|
984
|
+
console.log('\n❌ Build cancelled due to outdated plugins.');
|
|
985
|
+
process.exit(1);
|
|
986
|
+
} else {
|
|
987
|
+
console.log('\n✅ Continuing build...');
|
|
988
|
+
rl.close();
|
|
989
|
+
}
|
|
990
|
+
});
|
|
991
|
+
} else {
|
|
992
|
+
console.log('✅ All plugin versions are up to date.');
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
// Run the validation
|
|
997
|
+
checkPlugins();
|
|
998
|
+
|
|
999
|
+
|
|
1000
|
+
|
|
1001
|
+
|
|
1002
|
+
// Check all the codeplays plugins version START
|
|
1003
|
+
|
|
1004
|
+
|
|
1005
|
+
|
|
1006
|
+
|
|
1007
|
+
// ====================================================================
|
|
1008
|
+
// AUTO-ADD esbuild.drop: ['console','debugger'] to vite.config.js / mjs
|
|
1009
|
+
// ====================================================================
|
|
1010
|
+
|
|
1011
|
+
|
|
1012
|
+
|
|
1013
|
+
const checkAndupdateDropInViteConfig = () => {
|
|
1014
|
+
|
|
1015
|
+
const possibleFiles = [
|
|
1016
|
+
"vite.config.js",
|
|
1017
|
+
"vite.config.mjs"
|
|
1018
|
+
];
|
|
1019
|
+
|
|
1020
|
+
// Detect existing config file
|
|
1021
|
+
const viteConfigPath = possibleFiles
|
|
1022
|
+
.map(file => path.join(process.cwd(), file))
|
|
1023
|
+
.find(filePath => fs.existsSync(filePath));
|
|
1024
|
+
|
|
1025
|
+
if (!viteConfigPath) {
|
|
1026
|
+
console.warn("⚠️ No vite config found. Skipping.");
|
|
1027
|
+
return;
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
//console.log("📄 Using:", viteConfigPath.split("/").pop());
|
|
1031
|
+
|
|
1032
|
+
let viteContent = fs.readFileSync(viteConfigPath, "utf8");
|
|
1033
|
+
|
|
1034
|
+
// Skip if already exists
|
|
1035
|
+
if (/drop\s*:\s*\[.*['"]console['"].*\]/.test(viteContent)) {
|
|
1036
|
+
console.log("ℹ️ vite.config.(m)js already Updated. Skipping...");
|
|
1037
|
+
return;
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
console.log("🔧 Adding esbuild.drop ...");
|
|
1041
|
+
|
|
1042
|
+
// If esbuild block exists
|
|
1043
|
+
if (/esbuild\s*:\s*{/.test(viteContent)) {
|
|
1044
|
+
viteContent = viteContent.replace(
|
|
1045
|
+
/esbuild\s*:\s*{([\s\S]*?)(^ {0,8})}/m,
|
|
1046
|
+
(full, inner, indent) => {
|
|
1047
|
+
|
|
1048
|
+
let lines = inner
|
|
1049
|
+
.split("\n")
|
|
1050
|
+
.map(l => l.trim())
|
|
1051
|
+
.filter(Boolean);
|
|
1052
|
+
|
|
1053
|
+
// Fix last comma
|
|
1054
|
+
if (lines.length > 0) {
|
|
1055
|
+
lines[lines.length - 1] =
|
|
1056
|
+
lines[lines.length - 1].replace(/,+$/, "") + ",";
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
// Re-indent
|
|
1060
|
+
lines = lines.map(l => indent + " " + l);
|
|
1061
|
+
|
|
1062
|
+
// Add drop
|
|
1063
|
+
lines.push(`${indent} drop: ['console','debugger'],`);
|
|
1064
|
+
|
|
1065
|
+
return `esbuild: {\n${lines.join("\n")}\n${indent}}`;
|
|
1066
|
+
}
|
|
1067
|
+
);
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
// If esbuild missing
|
|
1071
|
+
else {
|
|
1072
|
+
viteContent = viteContent.replace(
|
|
1073
|
+
/export default defineConfig\s*\(\s*{/,
|
|
1074
|
+
m => `${m}\n esbuild: {\n drop: ['console','debugger'],\n },`
|
|
1075
|
+
);
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
fs.writeFileSync(viteConfigPath, viteContent, "utf8");
|
|
1079
|
+
console.log("✅ vite.config.(m)js Updated successfully.");
|
|
1080
|
+
};
|
|
1081
|
+
|
|
1082
|
+
checkAndupdateDropInViteConfig();
|
|
1083
|
+
|
|
1084
|
+
|
|
1085
|
+
|
|
1086
|
+
|
|
1087
|
+
|
|
1088
|
+
|
|
1089
|
+
|
|
1090
|
+
|
|
1091
|
+
const compareVersion = (v1, v2) => {
|
|
1092
|
+
const a = v1.split(".").map(Number);
|
|
1093
|
+
const b = v2.split(".").map(Number);
|
|
1094
|
+
|
|
1095
|
+
for (let i = 0; i < Math.max(a.length, b.length); i++) {
|
|
1096
|
+
const num1 = a[i] || 0;
|
|
1097
|
+
const num2 = b[i] || 0;
|
|
1098
|
+
if (num1 > num2) return 1;
|
|
1099
|
+
if (num1 < num2) return -1;
|
|
1100
|
+
}
|
|
1101
|
+
return 0;
|
|
1102
|
+
};
|
|
1103
|
+
|
|
1104
|
+
|
|
1105
|
+
|
|
1106
|
+
|
|
1107
|
+
const admobConfigPath = path.join('src', 'js','Ads', 'admob-ad-configuration.json');
|
|
1108
|
+
|
|
1109
|
+
const checkAdmobConfigurationProperty=()=>{
|
|
1110
|
+
|
|
1111
|
+
|
|
1112
|
+
if (!_admobConfig.ADMOB_ENABLED)
|
|
1113
|
+
{
|
|
1114
|
+
console.log("ℹ️ Admob is not enabled so 'admob-ad-configuration.json' checking is skipping...");
|
|
1115
|
+
return;
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
|
|
1119
|
+
const REQUIRED_CONFIG_KEYS = [
|
|
1120
|
+
"isKidsApp",
|
|
1121
|
+
"isTesting",
|
|
1122
|
+
"isConsoleLogEnabled",
|
|
1123
|
+
"bannerEnabled",
|
|
1124
|
+
"interstitialEnabled",
|
|
1125
|
+
"appOpenEnabled",
|
|
1126
|
+
"rewardVideoEnabled",
|
|
1127
|
+
"rewardInterstitialEnabled",
|
|
1128
|
+
"collapsibleEnabled",
|
|
1129
|
+
"isLandScape",
|
|
1130
|
+
"overlappingHeight",
|
|
1131
|
+
"isOverlappingEnable",
|
|
1132
|
+
"bannerTypeAndroid",
|
|
1133
|
+
"bannerTypeiOS",
|
|
1134
|
+
"bannerTopSpaceColor",
|
|
1135
|
+
"interstitialLoadScreenTextColor",
|
|
1136
|
+
"interstitialLoadScreenBackgroundColor",
|
|
1137
|
+
"beforeBannerSpace",
|
|
1138
|
+
"whenShow",
|
|
1139
|
+
"minimumClick",
|
|
1140
|
+
"interstitialTimeOut",
|
|
1141
|
+
"interstitialFirstTimeOut",
|
|
1142
|
+
"appOpenAdsTimeOut",
|
|
1143
|
+
"maxRetryCount",
|
|
1144
|
+
"retrySecondsAr",
|
|
1145
|
+
"appOpenPerSession",
|
|
1146
|
+
"interstitialPerSession",
|
|
1147
|
+
"appOpenFirstTimeOut"
|
|
1148
|
+
];
|
|
1149
|
+
|
|
1150
|
+
|
|
1151
|
+
|
|
1152
|
+
|
|
1153
|
+
|
|
1154
|
+
let admobConfigInJson;
|
|
1155
|
+
|
|
1156
|
+
try {
|
|
1157
|
+
admobConfigInJson = JSON.parse(readFileSync(admobConfigPath, "utf8"));
|
|
1158
|
+
} catch (err) {
|
|
1159
|
+
console.error("❌ Failed to read admob-ad-configuration.json", err);
|
|
1160
|
+
process.exit(1);
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
// ✅ Validate config object exists
|
|
1164
|
+
if (!admobConfigInJson.config) {
|
|
1165
|
+
console.error('❌ "config" object is missing in admob-ad-configuration.json');
|
|
1166
|
+
process.exit(1);
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
|
|
1170
|
+
const admobConfigMinVersion="1.4"
|
|
1171
|
+
|
|
1172
|
+
if (compareVersion(admobConfigInJson.VERSION, admobConfigMinVersion) < 0) {
|
|
1173
|
+
console.error(`❌ Please use at-least version ${admobConfigMinVersion} in "src/js/Ads/admob-ad-configuration.json"`);
|
|
1174
|
+
process.exit(1);
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1177
|
+
|
|
1178
|
+
const config = admobConfigInJson.config;
|
|
1179
|
+
|
|
1180
|
+
// ✅ Find missing properties
|
|
1181
|
+
const missingKeys = REQUIRED_CONFIG_KEYS.filter(
|
|
1182
|
+
key => !(key in config)
|
|
1183
|
+
);
|
|
1184
|
+
|
|
1185
|
+
|
|
1186
|
+
|
|
1187
|
+
if (missingKeys.length > 0) {
|
|
1188
|
+
console.error("❌ Missing required configuration keys. Please check it in 'src/js/Ads/admob-ad-configuration.json'");
|
|
1189
|
+
|
|
1190
|
+
missingKeys.forEach(k => console.error(" - " + k));
|
|
1191
|
+
process.exit(1);
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
|
|
1195
|
+
console.log('✅ All keys exist. in "admob-ad-configuration.json file" Configuration looks good.');
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
|
|
1199
|
+
checkAdmobConfigurationProperty()
|
|
1200
|
+
|
|
1201
|
+
|
|
1202
|
+
|
|
1203
|
+
|
|
1204
|
+
/*
|
|
1205
|
+
Release Notes
|
|
1206
|
+
|
|
1207
|
+
5.1
|
|
1208
|
+
Kotlin version update is commented. Previously admob is not worked if not update the kotlin version to higher version
|
|
1209
|
+
|
|
1210
|
+
*/
|