codeplay-common 4.8.6 → 4.8.7

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 CHANGED
@@ -1,2 +1,2 @@
1
- # Auto detect text files and perform LF normalization
2
- * text=auto
1
+ # Auto detect text files and perform LF normalization
2
+ * text=auto
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Merbin Joe
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Merbin Joe
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,169 +1,169 @@
1
- # codeplay-common
2
- Everything automatted in Capacitor apps, easy to maintain many apps in capacitor. It will reduce your 40% of work, with common file code.
3
-
4
-
5
- Easy add splashscreen and set animation
6
- Admob id automatically from capacitor.config.json file
7
- Make three build file for different store as per our requirement
8
- Based on store install various IAP plugins
9
- Make it to ionic project
10
-
11
- ## Platform builds and shared validation
12
-
13
- Installing or updating `codeplay-common` updates the consuming project's `package.json`
14
- to use the latest bundled pre-build script and adds these commands:
15
-
16
- - `npm run build`: Android by default, including on macOS.
17
- - `npm run build:ios`: sets `CODEPLAY_BUILD_PLATFORM=ios` and runs the same build pipeline.
18
- - `npm run build-capacitor-android`: runs the shared checks and copies the web build to Android.
19
-
20
- The pre-build script migrates direct `saveToGalleryAndSaveAnyFile` imports to
21
- `@saveGallery` and sets the Vite alias to the matching Android or iOS helper.
22
- Before changing source imports or the alias, it lists the build target, affected files,
23
- and exact replacements. Press Enter or type `y` to continue; any other answer cancels.
24
- Correct imports and alias targets continue without prompting. Missing helpers, mixed
25
- versions and query/hash imports stop with an actionable error.
26
-
27
- Source validation reuses a directory inventory and combines the gallery and editor
28
- checks in one content pass. The inventory refreshes when generated or downloaded
29
- files change the source tree.
30
-
31
- Builds also keep `agent-temp/` ignored and remove existing `buildCodeplay/` ignore entries.
32
- If `onesignal-cordova-plugin` is declared or installed, the pre-build script warns and
33
- runs `npm uninstall onesignal-cordova-plugin`. It stops if removal fails or active
34
- package imports remain. Legacy OneSignal patching and helper downloads are disabled.
35
-
36
- ## Screenshot data
37
-
38
- Shared screenshot helpers are installed into `scripts/screenshot/` and updated with
39
- the package. App-specific data is not bundled with the package.
40
- During an upgrade, cleanup removes only the two legacy helpers `frame-samples.js`
41
- and `background-decorations.js` from `scripts-screenshot/screenshot/`, preserving
42
- the folder, JSON data, and other app files.
43
-
44
- `take-screen-image.js` creates `scripts-screenshot/screenshot/` and empty
45
- `screenshot-copy.json` and `screenshot-info.json` files when needed. Existing files
46
- are preserved during initialization, package installation, and cleanup. Capture
47
- updates screenshot information; the AI text-generation workflow fills screenshot
48
- copy. `--delete` removes matching records, and screenshot runs reconcile records
49
- against the captured images (except dry runs and `--refresh-info`).
50
-
51
- ## Agent instructions
52
-
53
- Agent instructions are updated during `npm run build`, not during npm installation.
54
- The build script reads the `agents` version from
55
- `https://htmlcodeplay.com/code-play-plugin/versions.json` and downloads the matching
56
- `agents-<version>.zip` archive when the project has no agent instructions or the
57
- server version is newer.
58
-
59
- The ZIP root must contain `AGENTS.md` and `AGENTS/`. These are copied directly to
60
- the project root. The installed version is stored in `AGENTS/.codeplay-version`.
61
- Existing files with matching names are replaced; project-only files with other
62
- names inside `AGENTS/` are preserved.
63
-
64
- For example, publish `agents-1.1.zip` and add this entry to the server's
65
- `versions.json`:
66
-
67
- ```json
68
- "agents": "1.1"
69
- ```
70
-
71
- Donate to get full code including many common functions
72
- https://ko-fi.com/codeplay
73
-
74
- Version 4.6.1
75
- Added automatic IAP startup integration for Framework7 home pages.
76
- Updated minimum shared versions to IAP 4.2 and AdMob nextgen 2.5.
77
-
78
- 4.2.8
79
- baseline profile code modifications
80
-
81
- Version 4.2.3
82
- Added build warning confirmation when android.ORIENTATION is not "auto" or android.RESIZEABLE_ACTIVITY is not true.
83
-
84
- Version 4.2.2
85
- Added "bannerDisabledPages" property and its default value
86
- The admob configuration default value priority is updated
87
-
88
- Version 4.2.1
89
- Updated AdMob nextgen file validation to match admob-emi-nextgen file names.
90
-
91
- Version 4.2.0
92
- Firebase related automatic changes updated
93
-
94
- Version 4.1.9
95
- Added AdMob nextgen 1.7 validation/default support for "overlappingHeight", "bannerTypeAndroidLandscape", and "bannerTypeiOSLandscape".
96
-
97
- Version 4.1.8
98
- "consentDebug: false" is added
99
-
100
- Version 4.1.7
101
- admob configuration automatically added.
102
-
103
- Version 4.1.6
104
- "setup-baseline-profile.js" modification, duplicate validation error fixed
105
-
106
- Version 4.1.5
107
- While isTesting is true it is not validated from our new configuration admob file, now it is solved
108
-
109
- Version 4.1.4
110
- hardcoded version is removed for the admob-emi-nextgen
111
-
112
-
113
- Version 4.1.3
114
- "consentDebug": false automatically adds if not
115
-
116
- Version 4.1.2
117
- Speedup
118
-
119
- Version 4.1.1
120
- Auto admob integration updated
121
-
122
-
123
- version 4.0.9
124
- packageJson.scripts["ionic:serve"] = "cross-env NODE_ENV=development vite"; this line updated in "sync-files.js"
125
-
126
-
127
- version 4.0.8
128
- safearea plugin is checked and removed automatically
129
- Automatically added following in capacitor.config.json file
130
- "SystemBars": {
131
- "insetsHandling": "css"
132
- }
133
- patchFile() method is removed
134
-
135
-
136
-
137
-
138
- Version 4.0.6
139
- IAP related some automatic variable creation and validation
140
- Fetch from vite.config.json file
141
- 'import.meta.env.VITE_APP_UNIQUE_ID': JSON.stringify(APP_UNIQUE_ID),
142
- 'import.meta.env.VITE_ANDROID_ANALYTICS_ENABLED': JSON.stringify(ANDROID_ANALYTICS_ENABLED),
143
- 'import.meta.env.VITE_IOS_ANALYTICS_ENABLED': JSON.stringify(IOS_ANALYTICS_ENABLED),
144
- 'import.meta.env.VITE_IAP_DESIGN': JSON.stringify(IAP_DESIGN),
145
-
146
-
147
- Version 4.0.5
148
- In "files\buildCodeplay\packageidBaseModification-1.4.js" SCHEDULE_EXACT_ALARM permission added for the app unique id 2 (resume generator app)
149
-
150
-
151
- Version 4.0.4
152
- patchFile(); method is disabled, Due to "@capacitor/android:8.4.2" this update. I think it is realted to safearea issue fixed in this latest version, file in "SystemBars.java"
153
-
154
- Version 4.0.3
155
- Old admob check performs through plugin location, but not it is validated from capacitor.config.json
156
-
157
-
158
- Version: 4.0.2
159
- After check & install/download the latest version, the re-check is cancelled now
160
-
161
- Version: 4.0.1
162
- Base profile script added
163
-
164
-
165
- "version": "",
166
- Version : 4.0.0 (Previous version 3.2.19)
167
- 1) In here we are completly remove the admob-emi and use "capacitor-admob-nextgen"
168
- 2) Removed "modify-plugin-xml.js"
169
- 3)
1
+ # codeplay-common
2
+ Everything automatted in Capacitor apps, easy to maintain many apps in capacitor. It will reduce your 40% of work, with common file code.
3
+
4
+
5
+ Easy add splashscreen and set animation
6
+ Admob id automatically from capacitor.config.json file
7
+ Make three build file for different store as per our requirement
8
+ Based on store install various IAP plugins
9
+ Make it to ionic project
10
+
11
+ ## Platform builds and shared validation
12
+
13
+ Installing or updating `codeplay-common` updates the consuming project's `package.json`
14
+ to use the latest bundled pre-build script and adds these commands:
15
+
16
+ - `npm run build`: Android by default, including on macOS.
17
+ - `npm run build:ios`: sets `CODEPLAY_BUILD_PLATFORM=ios` and runs the same build pipeline.
18
+ - `npm run build-capacitor-android`: runs the shared checks and copies the web build to Android.
19
+
20
+ The pre-build script migrates direct `saveToGalleryAndSaveAnyFile` imports to
21
+ `@saveGallery` and sets the Vite alias to the matching Android or iOS helper.
22
+ Before changing source imports or the alias, it lists the build target, affected files,
23
+ and exact replacements. Press Enter or type `y` to continue; any other answer cancels.
24
+ Correct imports and alias targets continue without prompting. Missing helpers, mixed
25
+ versions and query/hash imports stop with an actionable error.
26
+
27
+ Source validation reuses a directory inventory and combines the gallery and editor
28
+ checks in one content pass. The inventory refreshes when generated or downloaded
29
+ files change the source tree.
30
+
31
+ Builds also keep `agent-temp/` ignored and remove existing `buildCodeplay/` ignore entries.
32
+ If `onesignal-cordova-plugin` is declared or installed, the pre-build script warns and
33
+ runs `npm uninstall onesignal-cordova-plugin`. It stops if removal fails or active
34
+ package imports remain. Legacy OneSignal patching and helper downloads are disabled.
35
+
36
+ ## Screenshot data
37
+
38
+ Shared screenshot helpers are installed into `scripts/screenshot/` and updated with
39
+ the package. App-specific data is not bundled with the package.
40
+ During an upgrade, cleanup removes only the two legacy helpers `frame-samples.js`
41
+ and `background-decorations.js` from `scripts-screenshot/screenshot/`, preserving
42
+ the folder, JSON data, and other app files.
43
+
44
+ `take-screen-image.js` creates `scripts-screenshot/screenshot/` and empty
45
+ `screenshot-copy.json` and `screenshot-info.json` files when needed. Existing files
46
+ are preserved during initialization, package installation, and cleanup. Capture
47
+ updates screenshot information; the AI text-generation workflow fills screenshot
48
+ copy. `--delete` removes matching records, and screenshot runs reconcile records
49
+ against the captured images (except dry runs and `--refresh-info`).
50
+
51
+ ## Agent instructions
52
+
53
+ Agent instructions are updated during `npm run build`, not during npm installation.
54
+ The build script reads the `agents` version from
55
+ `https://htmlcodeplay.com/code-play-plugin/versions.json` and downloads the matching
56
+ `agents-<version>.zip` archive when the project has no agent instructions or the
57
+ server version is newer.
58
+
59
+ The ZIP root must contain `AGENTS.md` and `AGENTS/`. These are copied directly to
60
+ the project root. The installed version is stored in `AGENTS/.codeplay-version`.
61
+ Existing files with matching names are replaced; project-only files with other
62
+ names inside `AGENTS/` are preserved.
63
+
64
+ For example, publish `agents-1.1.zip` and add this entry to the server's
65
+ `versions.json`:
66
+
67
+ ```json
68
+ "agents": "1.1"
69
+ ```
70
+
71
+ Donate to get full code including many common functions
72
+ https://ko-fi.com/codeplay
73
+
74
+ Version 4.6.1
75
+ Added automatic IAP startup integration for Framework7 home pages.
76
+ Updated minimum shared versions to IAP 4.2 and AdMob nextgen 2.5.
77
+
78
+ 4.2.8
79
+ baseline profile code modifications
80
+
81
+ Version 4.2.3
82
+ Added build warning confirmation when android.ORIENTATION is not "auto" or android.RESIZEABLE_ACTIVITY is not true.
83
+
84
+ Version 4.2.2
85
+ Added "bannerDisabledPages" property and its default value
86
+ The admob configuration default value priority is updated
87
+
88
+ Version 4.2.1
89
+ Updated AdMob nextgen file validation to match admob-emi-nextgen file names.
90
+
91
+ Version 4.2.0
92
+ Firebase related automatic changes updated
93
+
94
+ Version 4.1.9
95
+ Added AdMob nextgen 1.7 validation/default support for "overlappingHeight", "bannerTypeAndroidLandscape", and "bannerTypeiOSLandscape".
96
+
97
+ Version 4.1.8
98
+ "consentDebug: false" is added
99
+
100
+ Version 4.1.7
101
+ admob configuration automatically added.
102
+
103
+ Version 4.1.6
104
+ "setup-baseline-profile.js" modification, duplicate validation error fixed
105
+
106
+ Version 4.1.5
107
+ While isTesting is true it is not validated from our new configuration admob file, now it is solved
108
+
109
+ Version 4.1.4
110
+ hardcoded version is removed for the admob-emi-nextgen
111
+
112
+
113
+ Version 4.1.3
114
+ "consentDebug": false automatically adds if not
115
+
116
+ Version 4.1.2
117
+ Speedup
118
+
119
+ Version 4.1.1
120
+ Auto admob integration updated
121
+
122
+
123
+ version 4.0.9
124
+ packageJson.scripts["ionic:serve"] = "cross-env NODE_ENV=development vite"; this line updated in "sync-files.js"
125
+
126
+
127
+ version 4.0.8
128
+ safearea plugin is checked and removed automatically
129
+ Automatically added following in capacitor.config.json file
130
+ "SystemBars": {
131
+ "insetsHandling": "css"
132
+ }
133
+ patchFile() method is removed
134
+
135
+
136
+
137
+
138
+ Version 4.0.6
139
+ IAP related some automatic variable creation and validation
140
+ Fetch from vite.config.json file
141
+ 'import.meta.env.VITE_APP_UNIQUE_ID': JSON.stringify(APP_UNIQUE_ID),
142
+ 'import.meta.env.VITE_ANDROID_ANALYTICS_ENABLED': JSON.stringify(ANDROID_ANALYTICS_ENABLED),
143
+ 'import.meta.env.VITE_IOS_ANALYTICS_ENABLED': JSON.stringify(IOS_ANALYTICS_ENABLED),
144
+ 'import.meta.env.VITE_IAP_DESIGN': JSON.stringify(IAP_DESIGN),
145
+
146
+
147
+ Version 4.0.5
148
+ In "files\buildCodeplay\packageidBaseModification-1.4.js" SCHEDULE_EXACT_ALARM permission added for the app unique id 2 (resume generator app)
149
+
150
+
151
+ Version 4.0.4
152
+ patchFile(); method is disabled, Due to "@capacitor/android:8.4.2" this update. I think it is realted to safearea issue fixed in this latest version, file in "SystemBars.java"
153
+
154
+ Version 4.0.3
155
+ Old admob check performs through plugin location, but not it is validated from capacitor.config.json
156
+
157
+
158
+ Version: 4.0.2
159
+ After check & install/download the latest version, the re-check is cancelled now
160
+
161
+ Version: 4.0.1
162
+ Base profile script added
163
+
164
+
165
+ "version": "",
166
+ Version : 4.0.0 (Previous version 3.2.19)
167
+ 1) In here we are completly remove the admob-emi and use "capacitor-admob-nextgen"
168
+ 2) Removed "modify-plugin-xml.js"
169
+ 3)
@@ -1358,6 +1358,28 @@ const resourcesPath = path.join(process.cwd(), 'resources', 'res');
1358
1358
  const androidResPath = path.join(process.cwd(), 'android', 'app', 'src', 'main', 'res');
1359
1359
  const localNotificationsPluginPath = path.join(process.cwd(), 'node_modules', '@capacitor', 'local-notifications');
1360
1360
 
1361
+ function syncAndroidCodeOptimization() {
1362
+ if (buildPlatform !== 'android') return;
1363
+
1364
+ if (!fs.existsSync(androidAppBuildGradlePath)) {
1365
+ throw new Error(`Android app build.gradle not found: ${androidAppBuildGradlePath}`);
1366
+ }
1367
+
1368
+ const currentContent = fs.readFileSync(androidAppBuildGradlePath, 'utf8');
1369
+ const nextContent = currentContent.replace(
1370
+ /getDefaultProguardFile\(\s*(['"])proguard-android\.txt\1\s*\)/g,
1371
+ "getDefaultProguardFile('proguard-android-optimize.txt')"
1372
+ );
1373
+
1374
+ if (!/getDefaultProguardFile\(\s*(['"])proguard-android-optimize\.txt\1\s*\)/.test(nextContent)) {
1375
+ throw new Error('Android code optimisation setup failed: expected default ProGuard configuration was not found.');
1376
+ }
1377
+
1378
+ if (nextContent !== currentContent) {
1379
+ fs.writeFileSync(androidAppBuildGradlePath, nextContent, 'utf8');
1380
+ }
1381
+ }
1382
+
1361
1383
  function fileExists(filePath) {
1362
1384
  return fs.existsSync(filePath);
1363
1385
  }
@@ -4305,6 +4327,7 @@ async function main() {
4305
4327
  checkAndupdateDropInViteConfig();
4306
4328
  checkAdmobConfigurationProperty();
4307
4329
  syncAndroidAdIdPermission();
4330
+ syncAndroidCodeOptimization();
4308
4331
  }
4309
4332
 
4310
4333
  await main();
@@ -4320,6 +4343,7 @@ await main();
4320
4343
  Release Notes
4321
4344
 
4322
4345
  6.5
4346
+ Android builds use the optimisation-enabled default ProGuard rules without changing minification settings or custom keep rules.
4323
4347
  Kids ad configuration disables iOS ATT prompts and excludes Android AD_ID during builds.
4324
4348
  Non-kids apps retain tracking prompts and normal permission behavior.
4325
4349
  Ad configuration migration preserves newer local configuration versions.
@@ -1,4 +1,4 @@
1
- {
2
- "url": "https://htmlcodeplay.com/codeplay/api/v1/release/sync",
3
- "token": "b_TiY0Lu7q7Yb0Kx9djVxA6ST8k4CFiwFQNxgci7AAU"
4
- }
1
+ {
2
+ "url": "https://htmlcodeplay.com/codeplay/api/v1/release/sync",
3
+ "token": "b_TiY0Lu7q7Yb0Kx9djVxA6ST8k4CFiwFQNxgci7AAU"
4
+ }
@@ -7,7 +7,7 @@ node finalrelease "1,2,7"
7
7
 
8
8
  import { existsSync, readFileSync, readdirSync, promises, constants, writeFileSync, unlinkSync, mkdirSync, renameSync } from 'fs';
9
9
  import { join, resolve } from 'path';
10
- import { execSync, execFileSync } from 'child_process';
10
+ import { execSync, execFileSync } from 'child_process';
11
11
  import { createInterface } from 'readline';
12
12
 
13
13
  import { fileURLToPath } from 'url';
@@ -179,49 +179,49 @@ const config = JSON.parse(fs.readFileSync(configPath, 'utf8'));
179
179
 
180
180
  const _appUniqueId = config.android?.APP_UNIQUE_ID;
181
181
  const _appName=config.appName;
182
- const _appPackageId=config.appId;
183
-
184
- const releaseSyncConfigPath = join(__dirname, 'buildCodeplay', 'release-sync.config.json');
185
- let releaseSyncConfig = {};
186
- if (existsSync(releaseSyncConfigPath)) {
187
- try {
188
- releaseSyncConfig = JSON.parse(readFileSync(releaseSyncConfigPath, 'utf8'));
189
- } catch (error) {
190
- console.warn(`⚠️ Could not read ${releaseSyncConfigPath}: ${error.message}`);
191
- }
192
- }
193
- const RELEASE_SYNC_URL = process.env.CODEPLAY_RELEASE_SYNC_URL || releaseSyncConfig.url || 'https://htmlcodeplay.com/codeplay/api/v1/release/sync';
194
- const RELEASE_SYNC_TOKEN = process.env.CODEPLAY_RELEASE_SYNC_TOKEN || releaseSyncConfig.token || '';
195
- const RELEASE_PLATFORM_IDS = { PlayStore: 1, SamsungStore: 13, AmazonStore: 17, MiStore: 15, HuaweiStore: 12, OppoStore: 14, VivoStore: 16 };
196
-
197
- function syncReleaseToCodeplay(storeName, finalVersionName, finalVersionCode, releasedDate) {
198
- if (!RELEASE_SYNC_TOKEN) {
199
- console.warn(`⚠️ Codeplay release sync skipped: add a token to ${releaseSyncConfigPath}.`);
200
- return;
201
- }
202
- const payload = JSON.stringify({
203
- app_name: _appName,
204
- package_id: _appPackageId,
205
- version_name: String(finalVersionName),
206
- version_code: String(finalVersionCode),
207
- released_date: releasedDate,
208
- language_id: 0,
209
- language_name: 'Capacitor+ Framework 7',
210
- notes: 'Automated release update',
211
- status: 1,
212
- folder_name: path.basename(process.cwd()),
213
- app_unique_id: String(_appUniqueId || ''),
214
- platform_id: RELEASE_PLATFORM_IDS[storeName],
215
- });
216
- try {
217
- const response = execFileSync('curl.exe', ['-sS', '--fail-with-body', '-X', 'POST', RELEASE_SYNC_URL,
218
- '-H', 'Content-Type: application/json', '-H', `X-Release-Token: ${RELEASE_SYNC_TOKEN}`, '--data-binary', payload],
219
- { encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] });
220
- console.log(`✅ Codeplay sync (${storeName}): ${response.trim()}`);
221
- } catch (error) {
222
- console.warn(`⚠️ Codeplay sync failed for ${storeName}; continuing release builds: ${error.message}`);
223
- }
224
- }
182
+ const _appPackageId=config.appId;
183
+
184
+ const releaseSyncConfigPath = join(__dirname, 'buildCodeplay', 'release-sync.config.json');
185
+ let releaseSyncConfig = {};
186
+ if (existsSync(releaseSyncConfigPath)) {
187
+ try {
188
+ releaseSyncConfig = JSON.parse(readFileSync(releaseSyncConfigPath, 'utf8'));
189
+ } catch (error) {
190
+ console.warn(`⚠️ Could not read ${releaseSyncConfigPath}: ${error.message}`);
191
+ }
192
+ }
193
+ const RELEASE_SYNC_URL = process.env.CODEPLAY_RELEASE_SYNC_URL || releaseSyncConfig.url || 'https://htmlcodeplay.com/codeplay/api/v1/release/sync';
194
+ const RELEASE_SYNC_TOKEN = process.env.CODEPLAY_RELEASE_SYNC_TOKEN || releaseSyncConfig.token || '';
195
+ const RELEASE_PLATFORM_IDS = { PlayStore: 1, SamsungStore: 13, AmazonStore: 17, MiStore: 15, HuaweiStore: 12, OppoStore: 14, VivoStore: 16 };
196
+
197
+ function syncReleaseToCodeplay(storeName, finalVersionName, finalVersionCode, releasedDate) {
198
+ if (!RELEASE_SYNC_TOKEN) {
199
+ console.warn(`⚠️ Codeplay release sync skipped: add a token to ${releaseSyncConfigPath}.`);
200
+ return;
201
+ }
202
+ const payload = JSON.stringify({
203
+ app_name: _appName,
204
+ package_id: _appPackageId,
205
+ version_name: String(finalVersionName),
206
+ version_code: String(finalVersionCode),
207
+ released_date: releasedDate,
208
+ language_id: 0,
209
+ language_name: 'Capacitor+ Framework 7',
210
+ notes: 'Automated release update',
211
+ status: 1,
212
+ folder_name: path.basename(process.cwd()),
213
+ app_unique_id: String(_appUniqueId || ''),
214
+ platform_id: RELEASE_PLATFORM_IDS[storeName],
215
+ });
216
+ try {
217
+ const response = execFileSync('curl.exe', ['-sS', '--fail-with-body', '-X', 'POST', RELEASE_SYNC_URL,
218
+ '-H', 'Content-Type: application/json', '-H', `X-Release-Token: ${RELEASE_SYNC_TOKEN}`, '--data-binary', payload],
219
+ { encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] });
220
+ console.log(`✅ Codeplay sync (${storeName}): ${response.trim()}`);
221
+ } catch (error) {
222
+ console.warn(`⚠️ Codeplay sync failed for ${storeName}; continuing release builds: ${error.message}`);
223
+ }
224
+ }
225
225
 
226
226
  const FLOWCHART_API_APP_ID = 228;
227
227
  const FLOWCHART_SHARED_PATH = join('public', 'src', 'shared.js');
@@ -1036,11 +1036,11 @@ rl.question('Enter new versionCode (press enter to keep current): ', (newVersion
1036
1036
  const checkFullPath = join("AAB", newFileName.replace(/\.aab$/, `.${newExt}`));
1037
1037
 
1038
1038
  // Rename the output file
1039
- if (existsSync(oldFilePath)) {
1040
- renameSync(oldFilePath, checkFullPath);
1041
- console.log(`✅ Renamed output ${newExt.toUpperCase()} file to: ${path.basename(checkFullPath)}`);
1042
- syncReleaseToCodeplay(storeName, finalVersionName, finalVersionCode, new Date().toISOString().slice(0, 10));
1043
- } else {
1039
+ if (existsSync(oldFilePath)) {
1040
+ renameSync(oldFilePath, checkFullPath);
1041
+ console.log(`✅ Renamed output ${newExt.toUpperCase()} file to: ${path.basename(checkFullPath)}`);
1042
+ syncReleaseToCodeplay(storeName, finalVersionName, finalVersionCode, new Date().toISOString().slice(0, 10));
1043
+ } else {
1044
1044
  console.error(`❌ ${newExt.toUpperCase()} file not found after build.`);
1045
1045
  }
1046
1046