codeplay-common 4.4.3 → 4.4.5

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.
@@ -16,11 +16,128 @@ import { dirname } from 'path';
16
16
  /* const path = require('path');
17
17
  const fs = require('fs'); */
18
18
 
19
- import fs from 'fs';
20
- import path from 'path';
21
-
22
- // Define a mapping between store IDs and store names
23
- /* const storeNames = {
19
+ import fs from 'fs';
20
+ import path from 'path';
21
+
22
+ const __filename = fileURLToPath(import.meta.url);
23
+ const __dirname = dirname(__filename);
24
+
25
+ function stripJavaScriptComments(content) {
26
+ let result = '';
27
+ let state = 'code';
28
+
29
+ for (let index = 0; index < content.length; index++) {
30
+ const character = content[index];
31
+ const nextCharacter = content[index + 1];
32
+
33
+ if (state === 'lineComment') {
34
+ if (character === '\n') {
35
+ result += character;
36
+ state = 'code';
37
+ } else {
38
+ result += ' ';
39
+ }
40
+ continue;
41
+ }
42
+
43
+ if (state === 'blockComment') {
44
+ if (character === '*' && nextCharacter === '/') {
45
+ result += ' ';
46
+ index++;
47
+ state = 'code';
48
+ } else {
49
+ result += character === '\n' ? '\n' : ' ';
50
+ }
51
+ continue;
52
+ }
53
+
54
+ if (state !== 'code') {
55
+ result += character;
56
+
57
+ if (character === '\\') {
58
+ if (nextCharacter !== undefined) {
59
+ result += nextCharacter;
60
+ index++;
61
+ }
62
+ } else if (
63
+ (state === 'singleQuote' && character === "'") ||
64
+ (state === 'doubleQuote' && character === '"') ||
65
+ (state === 'templateLiteral' && character === '`')
66
+ ) {
67
+ state = 'code';
68
+ }
69
+ continue;
70
+ }
71
+
72
+ if (character === '/' && nextCharacter === '/') {
73
+ result += ' ';
74
+ index++;
75
+ state = 'lineComment';
76
+ } else if (character === '/' && nextCharacter === '*') {
77
+ result += ' ';
78
+ index++;
79
+ state = 'blockComment';
80
+ } else {
81
+ result += character;
82
+
83
+ if (character === "'") state = 'singleQuote';
84
+ else if (character === '"') state = 'doubleQuote';
85
+ else if (character === '`') state = 'templateLiteral';
86
+ }
87
+ }
88
+
89
+ return result;
90
+ }
91
+
92
+ function checkProductionAdmobAlias() {
93
+ const possibleConfigFiles = ['vite.config.mjs', 'vite.config.js'];
94
+ const viteConfigPath = possibleConfigFiles
95
+ .map(configFile => resolve(__dirname, configFile))
96
+ .find(filePath => existsSync(filePath));
97
+
98
+ if (!viteConfigPath) {
99
+ console.error('❌ FINAL RELEASE BLOCKED: No vite.config.mjs or vite.config.js file found.');
100
+ process.exit(1);
101
+ }
102
+
103
+ const viteConfigContent = stripJavaScriptComments(readFileSync(viteConfigPath, 'utf8'));
104
+ const aliasPattern = /(['"])@admob\1\s*:\s*path\.resolve\(\s*__dirname\s*,\s*(['"])([^'"\r\n]+)\2\s*\)/g;
105
+ const activeAliases = [...viteConfigContent.matchAll(aliasPattern)].map(match => match[3]);
106
+ const productionAliasPattern = /^\.\/src\/js\/Ads\/admob-emi-nextgen-\d+(?:\.\d+)+\.js$/;
107
+
108
+ if (activeAliases.length === 0) {
109
+ console.error('❌ FINAL RELEASE BLOCKED: The production @admob alias is commented out or missing in the Vite config.');
110
+ console.error(" Enable: '@admob': path.resolve(__dirname, './src/js/Ads/admob-emi-nextgen-x.x.js')");
111
+ process.exit(1);
112
+ }
113
+
114
+ if (activeAliases.length > 1) {
115
+ console.error('❌ FINAL RELEASE BLOCKED: Multiple active @admob aliases were found in the Vite config.');
116
+ console.error(' Keep exactly one active production admob-emi-nextgen-x.x.js alias.');
117
+ process.exit(1);
118
+ }
119
+
120
+ const activeAlias = activeAliases[0];
121
+ if (!productionAliasPattern.test(activeAlias)) {
122
+ console.error(`❌ FINAL RELEASE BLOCKED: @admob currently points to '${activeAlias}'.`);
123
+ console.error(" It must point to './src/js/Ads/admob-emi-nextgen-x.x.js', not a test AdMob file.");
124
+ process.exit(1);
125
+ }
126
+
127
+ const productionAdmobPath = resolve(__dirname, activeAlias);
128
+ if (!existsSync(productionAdmobPath)) {
129
+ console.error(`❌ FINAL RELEASE BLOCKED: The production @admob file does not exist: ${productionAdmobPath}`);
130
+ process.exit(1);
131
+ }
132
+
133
+ console.log(`✅ Production @admob alias verified: ${activeAlias}`);
134
+ }
135
+
136
+ // This must be the first release validation so test/no-ad builds cannot proceed.
137
+ checkProductionAdmobAlias();
138
+
139
+ // Define a mapping between store IDs and store names
140
+ /* const storeNames = {
24
141
  "1": "PlayStore",
25
142
  "2": "SamsungStore",
26
143
  "7": "AmazonStore"
@@ -66,10 +183,7 @@ const _appPackageId=config.appId;
66
183
 
67
184
 
68
185
 
69
- const __filename = fileURLToPath(import.meta.url);
70
- const __dirname = dirname(__filename);
71
-
72
- function fileExists(filePath) {
186
+ function fileExists(filePath) {
73
187
  return existsSync(filePath);
74
188
  }
75
189
 
@@ -196,13 +196,41 @@ async function askIosStoreDetails() {
196
196
  }, null, 2)}\n`, 'utf8');
197
197
  }
198
198
 
199
- async function ensureEndCardBanner() {
200
- if (fs.existsSync(endCardBannerPath)) return;
201
- throw new Error(
202
- `AI end-card banner is missing. Generate it manually and save it here:\n${endCardBannerPath}\n\n`
203
- + 'Then run the video-generation command again.',
204
- );
205
- }
199
+ async function ensureEndCardBanner() {
200
+ if (fs.existsSync(endCardBannerPath)) return;
201
+ throw new Error(
202
+ `AI end-card banner is missing. Generate it manually and save it here:\n${endCardBannerPath}\n\n`
203
+ + 'Create a promotional video end-card banner for this application.\n\n'
204
+ + 'Requirements:\n'
205
+ + '- Final image size must be exactly 1672 × 941 pixels.\n'
206
+ + '- Save it as:\n'
207
+ + ` ${endCardBannerPath}\n`
208
+ + '- Inspect the current project and use the application’s actual highest-resolution app icon.\n'
209
+ + '- Do not generate, redraw, reinterpret, or replace the app icon.\n'
210
+ + '- Use the complete official black “Download on the App Store” badge.\n'
211
+ + '- Use the complete official black “Get it on Google Play” badge.\n'
212
+ + '- Download the official badges from Apple and Google if they are not available in the project.\n'
213
+ + '- Do not generate or imitate the Apple, Google Play, or application logos.\n'
214
+ + '- Keep all logos and badge text sharp, correctly proportioned, and completely visible.\n'
215
+ + '- Match the background colors and visual style to the actual app icon.\n'
216
+ + '- Create a polished, professional background related to the app’s purpose.\n'
217
+ + '- Keep the background subtle so it does not compete with the icon or download badges.\n'
218
+ + '- Use a balanced landscape composition:\n'
219
+ + ' - Large actual app icon on the left.\n'
220
+ + ' - App Store badge followed by Google Play badge on the right.\n'
221
+ + ' - Maintain comfortable margins and clear space around every element.\n'
222
+ + '- Do not add extra marketing text unless it is specifically requested.\n'
223
+ + '- Do not add watermarks, fake UI, generated symbols, or unrelated decorations.\n'
224
+ + '- Rounded corners and a subtle shadow may be applied around the app icon, but its internal artwork must remain unchanged.\n'
225
+ + '- Use image generation only for the background.\n'
226
+ + '- Composite the actual app icon and official store badges afterward.\n'
227
+ + '- Replace the specified output file if it already exists.\n'
228
+ + '- Verify the final PNG dimensions are exactly 1672 × 941.\n'
229
+ + '- Visually inspect the completed image before finishing.\n'
230
+ + '- Report the final saved path.\n\n'
231
+ + 'Then run the video-generation command again.',
232
+ );
233
+ }
206
234
 
207
235
  function findVideos(directory) {
208
236
  if (!fs.existsSync(directory)) return [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeplay-common",
3
- "version": "4.4.3",
3
+ "version": "4.4.5",
4
4
  "description": "Common build scripts and files",
5
5
  "scripts": {
6
6
  "postinstall": "node scripts/sync-files.js",