codeplay-common 1.2.7 → 1.2.8
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.
|
@@ -19,7 +19,7 @@ let admobConfig;
|
|
|
19
19
|
try {
|
|
20
20
|
admobConfig = JSON.parse(fs.readFileSync(admobConfigPath, 'utf8'));
|
|
21
21
|
} catch (err) {
|
|
22
|
-
console.error("Failed to read admob-ad-configuration.json", err);
|
|
22
|
+
console.error("❌ Failed to read admob-ad-configuration.json", err);
|
|
23
23
|
process.exit(1);
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -38,7 +38,7 @@ const checkCommonFileStoreId=()=>{
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
if (!viteConfigPath) {
|
|
41
|
-
console.error('Error: No vite.config.mjs or vite.config.js file found.');
|
|
41
|
+
console.error('❌ Error: No vite.config.mjs or vite.config.js file found.');
|
|
42
42
|
process.exit(1);
|
|
43
43
|
}
|
|
44
44
|
|
|
@@ -51,7 +51,7 @@ const checkCommonFileStoreId=()=>{
|
|
|
51
51
|
const match = viteConfigContent.match(aliasPattern);
|
|
52
52
|
|
|
53
53
|
if (!match) {
|
|
54
|
-
console.error(
|
|
54
|
+
console.error(`❌ Error: @common alias not found in ${viteConfigPath}`);
|
|
55
55
|
process.exit(1);
|
|
56
56
|
}
|
|
57
57
|
|
|
@@ -60,7 +60,7 @@ const checkCommonFileStoreId=()=>{
|
|
|
60
60
|
|
|
61
61
|
// Read the common file content
|
|
62
62
|
if (!fs.existsSync(resolvedCommonPath)) {
|
|
63
|
-
console.error(
|
|
63
|
+
console.error(`❌ Error: Resolved common file does not exist: ${resolvedCommonPath}`);
|
|
64
64
|
process.exit(1);
|
|
65
65
|
}
|
|
66
66
|
|
|
@@ -69,13 +69,13 @@ const checkCommonFileStoreId=()=>{
|
|
|
69
69
|
// Check for the _storeid export line
|
|
70
70
|
const storeIdPattern = /export\s+let\s+_storeid\s*=\s*import\.meta\.env\.VITE_STORE_ID\s*\|\|\s*1\s*;/;
|
|
71
71
|
if (!storeIdPattern.test(commonFileContent)) {
|
|
72
|
-
console.error(
|
|
72
|
+
console.error(`❌ Error: _storeid value is wrong in ${commonFilePath}`);
|
|
73
73
|
process.exit(1);
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
console.log(commonFilePath,'Success - No problem found');
|
|
77
77
|
} catch (error) {
|
|
78
|
-
console.error('Error:', error);
|
|
78
|
+
console.error('❌ Error:', error);
|
|
79
79
|
process.exit(1);
|
|
80
80
|
}
|
|
81
81
|
|
|
@@ -84,13 +84,64 @@ const checkCommonFileStoreId=()=>{
|
|
|
84
84
|
const checkIsTestingInAdmob=()=>{
|
|
85
85
|
|
|
86
86
|
if (admobConfig.config && admobConfig.config.isTesting === true) {
|
|
87
|
-
console.error(
|
|
87
|
+
console.error(`❌ Problem found while generating the AAB file. Please change "isTesting: true" to "isTesting: false" in the "admob-ad-configuration.json" file.`);
|
|
88
88
|
process.exit(1); // Exit with an error code to halt the process
|
|
89
89
|
} else {
|
|
90
|
-
console.log('No problem found. "isTesting" is either already false or not defined.');
|
|
90
|
+
console.log('✅ No problem found. "isTesting" is either already false or not defined.');
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
+
const checkIsAdsDisableByReturnStatement=()=>{
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
const adsFolder = path.join('src', 'js', 'Ads');
|
|
98
|
+
const filePattern = /^admob-emi-(\d+\.)+\d+\.js$/;
|
|
99
|
+
|
|
100
|
+
// Step 1: Find the admob file
|
|
101
|
+
const files = fs.readdirSync(adsFolder);
|
|
102
|
+
const admobFile = files.find(f => filePattern.test(f));
|
|
103
|
+
|
|
104
|
+
if (!admobFile) {
|
|
105
|
+
console.log('❌ No Admob file found.');
|
|
106
|
+
process.exit(1);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const filePath = path.join(adsFolder, admobFile);
|
|
110
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
111
|
+
|
|
112
|
+
// Step 2: Extract the adsOnDeviceReady function body
|
|
113
|
+
const functionRegex = /async\s+function\s+adsOnDeviceReady\s*\([^)]*\)\s*{([\s\S]*?)^}/m;
|
|
114
|
+
const match = content.match(functionRegex);
|
|
115
|
+
|
|
116
|
+
if (!match) {
|
|
117
|
+
console.log(`❌ Function 'adsOnDeviceReady' not found in file: ${admobFile}`);
|
|
118
|
+
process.exit(1);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const body = match[1];
|
|
122
|
+
const lines = body.split('\n').map(line => line.trim());
|
|
123
|
+
|
|
124
|
+
// Step 3: Skip blank lines and comments, get the first real code line
|
|
125
|
+
let firstCodeLine = '';
|
|
126
|
+
for (const line of lines) {
|
|
127
|
+
if (line === '' || line.startsWith('//')) continue;
|
|
128
|
+
firstCodeLine = line;
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Step 4: Block if it's any of the unwanted returns
|
|
133
|
+
const badReturnPattern = /^return\s*(true|false)?\s*;?$/;
|
|
134
|
+
|
|
135
|
+
if (badReturnPattern.test(firstCodeLine)) {
|
|
136
|
+
console.log(`❌ BLOCKED in file '${admobFile}': First active line in 'adsOnDeviceReady' is '${firstCodeLine}'`);
|
|
137
|
+
process.exit(2);
|
|
138
|
+
} else {
|
|
139
|
+
console.log(`✅ Safe: No early return (true/false) found in 'adsOnDeviceReady' of file '${admobFile}'.`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
94
145
|
const addPermission_AD_ID=()=>{
|
|
95
146
|
|
|
96
147
|
const admobPluginXmlPath = path.join('node_modules', 'emi-indo-cordova-plugin-admob', 'plugin.xml');
|
|
@@ -121,21 +172,22 @@ const addPermission_AD_ID=()=>{
|
|
|
121
172
|
|
|
122
173
|
// Write the updated manifest content back to AndroidManifest.xml
|
|
123
174
|
fs.writeFileSync(androidManifestPath, manifestContent, 'utf8');
|
|
124
|
-
console.log("ad_id permission added successfully.");
|
|
175
|
+
console.log("✅ ad_id permission added successfully.");
|
|
125
176
|
} else {
|
|
126
|
-
console.log("ad_id permission already exists in AndroidManifest.xml.");
|
|
177
|
+
console.log("ℹ️ ad_id permission already exists in AndroidManifest.xml.");
|
|
127
178
|
}
|
|
128
179
|
} else {
|
|
129
|
-
console.error("AndroidManifest.xml not found at the specified path.");
|
|
180
|
+
console.error("❌ AndroidManifest.xml not found at the specified path.");
|
|
130
181
|
}
|
|
131
182
|
} else {
|
|
132
|
-
console.log("\x1b[33m%s\x1b[0m", "No admob found, so permission.AD_ID is not added");
|
|
183
|
+
console.log("\x1b[33m%s\x1b[0m", "⚠️ No admob found, so permission.AD_ID is not added");
|
|
133
184
|
}
|
|
134
185
|
}
|
|
135
186
|
|
|
136
187
|
|
|
137
188
|
checkCommonFileStoreId();
|
|
138
189
|
checkIsTestingInAdmob();
|
|
190
|
+
checkIsAdsDisableByReturnStatement()
|
|
139
191
|
|
|
140
192
|
|
|
141
193
|
let isAdmobFound = true;
|
|
@@ -144,7 +196,7 @@ addPermission_AD_ID()
|
|
|
144
196
|
|
|
145
197
|
|
|
146
198
|
const { playstore, samsung, amazon } = admobConfig.IAP;
|
|
147
|
-
console.log(
|
|
199
|
+
console.log(`ℹ️ IAP Configurations - PlayStore: ${playstore}, Samsung: ${samsung}, Amazon: ${amazon}`);
|
|
148
200
|
|
|
149
201
|
|
|
150
202
|
|
|
@@ -165,7 +217,7 @@ if (fs.existsSync(aabDirectory)) {
|
|
|
165
217
|
files.forEach(file => {
|
|
166
218
|
const filePath = path.join(aabDirectory, file);
|
|
167
219
|
fs.unlinkSync(filePath);
|
|
168
|
-
console.log(
|
|
220
|
+
console.log(`ℹ️ Deleted existing AAB file: ${file}`);
|
|
169
221
|
});
|
|
170
222
|
}
|
|
171
223
|
|
|
@@ -214,8 +266,10 @@ rl.question('Enter new versionCode (press enter to keep current): ', (newVersion
|
|
|
214
266
|
const finalVersionName = newVersionName || versionName; // Use existing if no input
|
|
215
267
|
|
|
216
268
|
// Log the final version details
|
|
217
|
-
console.log(
|
|
218
|
-
console.log(
|
|
269
|
+
console.log(`📦 Final versionCode: ${finalVersionCode}`);
|
|
270
|
+
console.log(`📝 Final versionName: ${finalVersionName}`);
|
|
271
|
+
|
|
272
|
+
|
|
219
273
|
|
|
220
274
|
// Update build.gradle with the new version details
|
|
221
275
|
let updatedGradleContent = gradleContent
|
|
@@ -228,15 +282,43 @@ rl.question('Enter new versionCode (press enter to keep current): ', (newVersion
|
|
|
228
282
|
// Add resConfigs "en" below versionName
|
|
229
283
|
updatedGradleContent = updatedGradleContent.replace(/versionName\s+"[^"]+"/, `versionName "${finalVersionName}"\n${resConfigsLine}`);
|
|
230
284
|
} else {
|
|
231
|
-
console.log('resConfigs "en" already exists in build.gradle.');
|
|
285
|
+
console.log('ℹ️ resConfigs "en" already exists in build.gradle.');
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
if (/minifyEnabled\s+false/.test(updatedGradleContent)) {
|
|
294
|
+
updatedGradleContent = updatedGradleContent.replace(/minifyEnabled\s+false/, 'minifyEnabled true');
|
|
295
|
+
console.log('Replaced minifyEnabled false with true.');
|
|
296
|
+
} else if (!/minifyEnabled\s+true/.test(updatedGradleContent)) {
|
|
297
|
+
// Only insert if minifyEnabled (true or false) is NOT present
|
|
298
|
+
if (/buildTypes\s*{[\s\S]*?release\s*{/.test(updatedGradleContent)) {
|
|
299
|
+
updatedGradleContent = updatedGradleContent.replace(
|
|
300
|
+
/(buildTypes\s*{[\s\S]*?release\s*{)/,
|
|
301
|
+
'$1\n minifyEnabled true'
|
|
302
|
+
);
|
|
303
|
+
console.log('✅ Inserted minifyEnabled true into release block.');
|
|
304
|
+
} else {
|
|
305
|
+
console.log('⚠️ Warning: buildTypes > release block not found. minifyEnabled was not added.');
|
|
306
|
+
}
|
|
307
|
+
} else {
|
|
308
|
+
console.log('ℹ️ minifyEnabled true already present. No change needed.');
|
|
232
309
|
}
|
|
233
310
|
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
|
|
234
316
|
// Write the updated gradle content back to build.gradle
|
|
235
317
|
fs.writeFileSync(gradleFilePath, updatedGradleContent, 'utf8');
|
|
236
|
-
console.log(
|
|
318
|
+
console.log(`✅ Updated build.gradle with versionCode: ${finalVersionCode}, versionName: ${finalVersionName}, resConfigs "en" and "minifyEnabled true"`);
|
|
237
319
|
|
|
238
320
|
storeIds.forEach((id) => {
|
|
239
|
-
console.log(
|
|
321
|
+
console.log(`ℹ️ Building for Store ID ${id}`);
|
|
240
322
|
|
|
241
323
|
// Set the environment variable for store ID
|
|
242
324
|
process.env.VITE_STORE_ID = id;
|
|
@@ -318,13 +400,13 @@ rl.question('Enter new versionCode (press enter to keep current): ', (newVersion
|
|
|
318
400
|
const oldFilePath = path.join(aabDirectory, "app-release-signed.aab");
|
|
319
401
|
if (fs.existsSync(oldFilePath)) {
|
|
320
402
|
fs.renameSync(oldFilePath, checkFullPath);
|
|
321
|
-
console.log(
|
|
403
|
+
console.log(`✅ Renamed output AAB file to: ${newFileName}`);
|
|
322
404
|
} else {
|
|
323
|
-
console.error("AAB file not found after build.");
|
|
405
|
+
console.error("❌ AAB file not found after build.");
|
|
324
406
|
}
|
|
325
407
|
|
|
326
408
|
} catch (error) {
|
|
327
|
-
console.error(
|
|
409
|
+
console.error(`❌ Error during build for Store ID ${id}:`, error);
|
|
328
410
|
}
|
|
329
411
|
});
|
|
330
412
|
|
|
@@ -356,7 +438,7 @@ function managePackages(store) {
|
|
|
356
438
|
const permissionRegex = new RegExp(`^\\s*<uses-permission\\s+android:name="${permission}"\\s*/?>\\s*[\r\n]?`, 'm');
|
|
357
439
|
if (permissionRegex.test(manifestContent)) {
|
|
358
440
|
manifestContent = manifestContent.replace(permissionRegex, '');
|
|
359
|
-
console.log(
|
|
441
|
+
console.log(`✅ Removed <uses-permission android:name="${permission}" /> from AndroidManifest.xml`);
|
|
360
442
|
}
|
|
361
443
|
});
|
|
362
444
|
|
|
@@ -387,14 +469,14 @@ function managePackages(store) {
|
|
|
387
469
|
try {
|
|
388
470
|
child_process.execSync(`npm uninstall cordova-plugin-samsungiap`, { stdio: 'inherit' });
|
|
389
471
|
child_process.execSync(`npm uninstall @revenuecat/purchases-capacitor`, { stdio: 'inherit' });
|
|
390
|
-
console.log(
|
|
472
|
+
console.log(`✅ Both plugins uninstalled successfully.`);
|
|
391
473
|
} catch (err) {
|
|
392
|
-
console.error("Error uninstalling plugins:", err);
|
|
474
|
+
console.error("❌ Error uninstalling plugins:", err);
|
|
393
475
|
}
|
|
394
476
|
return;
|
|
395
477
|
}
|
|
396
478
|
|
|
397
|
-
console.log(
|
|
479
|
+
console.log(`⚠️ Installing ${install} and uninstalling ${uninstall} for ${store}...`);
|
|
398
480
|
try {
|
|
399
481
|
if (install) {
|
|
400
482
|
child_process.execSync(`npm install ${install}`, { stdio: 'inherit' });
|
|
@@ -402,9 +484,9 @@ function managePackages(store) {
|
|
|
402
484
|
if (uninstall) {
|
|
403
485
|
child_process.execSync(`npm uninstall ${uninstall}`, { stdio: 'inherit' });
|
|
404
486
|
}
|
|
405
|
-
console.log(
|
|
487
|
+
console.log(`✅ ${install} installed and ${uninstall} uninstalled successfully.`);
|
|
406
488
|
} catch (err) {
|
|
407
|
-
console.error(
|
|
489
|
+
console.error(`❌ Error managing packages for ${store}:`, err);
|
|
408
490
|
}
|
|
409
491
|
}
|
|
410
492
|
|
|
@@ -413,7 +495,7 @@ function managePackages(store) {
|
|
|
413
495
|
function updateAndroidManifest(store, addPermission) {
|
|
414
496
|
try {
|
|
415
497
|
if (!fs.existsSync(androidManifestPath)) {
|
|
416
|
-
console.error("AndroidManifest.xml file not found!");
|
|
498
|
+
console.error("❌ AndroidManifest.xml file not found!");
|
|
417
499
|
return;
|
|
418
500
|
}
|
|
419
501
|
|
|
@@ -437,18 +519,18 @@ function updateAndroidManifest(store, addPermission) {
|
|
|
437
519
|
closingTag,
|
|
438
520
|
`${formattedPermission}${closingTag}`
|
|
439
521
|
);
|
|
440
|
-
console.log(
|
|
522
|
+
console.log(`✅ Added ${addPermission} before </manifest> tag.`);
|
|
441
523
|
} else {
|
|
442
|
-
console.warn(
|
|
524
|
+
console.warn(`⚠️ </manifest> tag not found. Adding ${addPermission} at the end of the file.`);
|
|
443
525
|
manifestContent += `\n${formattedPermission}`;
|
|
444
526
|
}
|
|
445
527
|
|
|
446
528
|
// Normalize line endings back to `\r\n` and write the updated content
|
|
447
529
|
manifestContent = manifestContent.replace(/\n/g, '\r\n');
|
|
448
530
|
fs.writeFileSync(androidManifestPath, manifestContent, 'utf-8');
|
|
449
|
-
console.log(
|
|
531
|
+
console.log(`✅ AndroidManifest.xml updated successfully for ${store}`);
|
|
450
532
|
} catch (err) {
|
|
451
|
-
console.error(
|
|
533
|
+
console.error(`❌ Error updating AndroidManifest.xml for ${store}:`, err);
|
|
452
534
|
}
|
|
453
535
|
}
|
|
454
536
|
|