codeplay-common 4.7.0 → 4.7.2

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.
@@ -1270,6 +1270,7 @@ const androidAppBuildGradlePath = path.join(process.cwd(), 'android', 'app', 'bu
1270
1270
  const AMAZON_WINDOW_EXTENSIONS_DEPENDENCY = 'implementation "androidx.window.extensions.core:core:1.0.0"';
1271
1271
  const AMAZON_WINDOW_EXTENSIONS_DEPENDENCY_PATTERN = /^[ \t]*implementation\s+["']androidx\.window\.extensions\.core:core:[^"']+["'][ \t]*(?:\r?\n)?/gm;
1272
1272
  const infoPlistPath = path.join(process.cwd(), 'ios', 'App', 'App', 'Info.plist');
1273
+ const iosSceneDelegatePath = path.join(process.cwd(), 'ios', 'App', 'App', 'SceneDelegate.swift');
1273
1274
  const resourcesPath = path.join(process.cwd(), 'resources', 'res');
1274
1275
  const androidResPath = path.join(process.cwd(), 'android', 'app', 'src', 'main', 'res');
1275
1276
  const localNotificationsPluginPath = path.join(process.cwd(), 'node_modules', '@capacitor', 'local-notifications');
@@ -1593,6 +1594,62 @@ function updateInfoPlist(admobConfig) {
1593
1594
  console.log('AdMob IDs and additional configurations successfully updated in Info.plist');
1594
1595
  }
1595
1596
 
1597
+ function updateIOSSceneDelegateForATT() {
1598
+ if (!fileExists(iosSceneDelegatePath)) {
1599
+ console.warn('SceneDelegate.swift not found. Skipping the iOS ATT scene update.');
1600
+ return;
1601
+ }
1602
+
1603
+ let content = fs.readFileSync(iosSceneDelegatePath, 'utf8');
1604
+ if (content.includes('ATTrackingManager.requestTrackingAuthorization')) return;
1605
+
1606
+ const newline = content.includes('\r\n') ? '\r\n' : '\n';
1607
+ const sceneClass = /class SceneDelegate\s*:\s*[^\{]+\{/;
1608
+ if (!sceneClass.test(content) || !/import UIKit\r?\n/.test(content) || !content.trimEnd().endsWith('}')) {
1609
+ console.warn('SceneDelegate.swift has an unexpected structure. Skipping the iOS ATT scene update.');
1610
+ return;
1611
+ }
1612
+
1613
+ if (!content.includes('import AppTrackingTransparency')) {
1614
+ content = content.replace(/import UIKit\r?\n/, (match) => `${match}import AppTrackingTransparency${newline}`);
1615
+ }
1616
+
1617
+ if (!content.includes('isTrackingAuthorizationRequestScheduled')) {
1618
+ content = content.replace(sceneClass, (match) =>
1619
+ `${match}${newline} private var isTrackingAuthorizationRequestScheduled = false`
1620
+ );
1621
+ }
1622
+
1623
+ const requestBody = [
1624
+ ' if ATTrackingManager.trackingAuthorizationStatus == .notDetermined &&',
1625
+ ' !isTrackingAuthorizationRequestScheduled {',
1626
+ ' isTrackingAuthorizationRequestScheduled = true',
1627
+ '',
1628
+ ' DispatchQueue.main.asyncAfter(deadline: .now() + 1) { [weak self] in',
1629
+ ' self?.isTrackingAuthorizationRequestScheduled = false',
1630
+ '',
1631
+ ' guard UIApplication.shared.applicationState == .active,',
1632
+ ' ATTrackingManager.trackingAuthorizationStatus == .notDetermined else { return }',
1633
+ '',
1634
+ ' ATTrackingManager.requestTrackingAuthorization { _ in }',
1635
+ ' }',
1636
+ ' }',
1637
+ ].join(newline);
1638
+
1639
+ const activeSceneMethod = /func sceneDidBecomeActive\s*\(\s*_ scene:\s*UIScene\s*\)\s*\{/;
1640
+ if (activeSceneMethod.test(content)) {
1641
+ content = content.replace(activeSceneMethod, (match) => `${match}${newline}${requestBody}`);
1642
+ } else {
1643
+ const classEnd = content.lastIndexOf('}');
1644
+ content = `${content.slice(0, classEnd).trimEnd()}${newline}${newline}` +
1645
+ ` func sceneDidBecomeActive(_ scene: UIScene) {${newline}${requestBody}${newline} }${newline}` +
1646
+ content.slice(classEnd);
1647
+ }
1648
+
1649
+ fs.writeFileSync(iosSceneDelegatePath, content, 'utf8');
1650
+ console.log('iOS SceneDelegate updated to request ATT when the app becomes active.');
1651
+ }
1652
+
1596
1653
 
1597
1654
  try {
1598
1655
  if (!fileExists(configPath)) {
@@ -1622,6 +1679,7 @@ try {
1622
1679
 
1623
1680
  if (fileExists(iosPlatformPath)) {
1624
1681
  updateInfoPlist(_admobConfig);
1682
+ updateIOSSceneDelegateForATT();
1625
1683
  }
1626
1684
  }
1627
1685
 
@@ -0,0 +1,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 } from 'child_process';
10
+ import { execSync, execFileSync } from 'child_process';
11
11
  import { createInterface } from 'readline';
12
12
 
13
13
  import { fileURLToPath } from 'url';
@@ -181,6 +181,48 @@ const _appUniqueId = config.android?.APP_UNIQUE_ID;
181
181
  const _appName=config.appName;
182
182
  const _appPackageId=config.appId;
183
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
+
184
226
  const FLOWCHART_API_APP_ID = 228;
185
227
  const FLOWCHART_SHARED_PATH = join('public', 'src', 'shared.js');
186
228
  const FLOWCHART_PLAY_API_BASE = 'https://htmlcodeplay.com/appfiles/128FlowChart';
@@ -997,6 +1039,7 @@ rl.question('Enter new versionCode (press enter to keep current): ', (newVersion
997
1039
  if (existsSync(oldFilePath)) {
998
1040
  renameSync(oldFilePath, checkFullPath);
999
1041
  console.log(`✅ Renamed output ${newExt.toUpperCase()} file to: ${path.basename(checkFullPath)}`);
1042
+ syncReleaseToCodeplay(storeName, finalVersionName, finalVersionCode, new Date().toISOString().slice(0, 10));
1000
1043
  } else {
1001
1044
  console.error(`❌ ${newExt.toUpperCase()} file not found after build.`);
1002
1045
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeplay-common",
3
- "version": "4.7.0",
3
+ "version": "4.7.2",
4
4
  "description": "Common build scripts and files",
5
5
  "scripts": {
6
6
  "postinstall": "node scripts/sync-files.js",