codeplay-common 4.11.17 → 4.11.19

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.
Files changed (2) hide show
  1. package/files/finalrelease +70 -3
  2. package/package.json +1 -1
@@ -23,6 +23,60 @@ import path from 'path';
23
23
  const __filename = fileURLToPath(import.meta.url);
24
24
  const __dirname = process.cwd();
25
25
 
26
+ const versionHistoryPath = join(__dirname, 'Version-history.md');
27
+ const emptyUnreleasedHistory = '## Unreleased\n\n### Release notes\n\n### Detailed changes\n';
28
+
29
+ function readPendingVersionHistory() {
30
+ if (!existsSync(versionHistoryPath)) {
31
+ writeFileSync(versionHistoryPath, `# Version History\n\n${emptyUnreleasedHistory}`, 'utf8');
32
+ }
33
+ const content = readFileSync(versionHistoryPath, 'utf8');
34
+ const unreleased = /^## Unreleased\r?\n([\s\S]*?)(?=^## |$(?![\s\S]))/m.exec(content);
35
+ if (!unreleased || (content.match(/^## Unreleased\r?$/gm) || []).length !== 1) {
36
+ throw new Error('Version-history.md must contain exactly one ## Unreleased section. Pending notes were not changed.');
37
+ }
38
+ const notes = unreleased[1].trim();
39
+ const hasNotes = notes.split(/\r?\n/).some(line =>
40
+ line.trim() && !/^#{3,}\s/.test(line.trim()));
41
+ return { content, section: unreleased[0], index: unreleased.index, notes, hasNotes };
42
+ }
43
+
44
+ function archiveVersionHistory(pending, finalVersionName, finalVersionCode, successfulStores) {
45
+ if (!pending.hasNotes || successfulStores.length === 0) {
46
+ console.log('ℹ️ Version history skipped: no pending notes or no completed builds.');
47
+ return;
48
+ }
49
+ const current = readFileSync(versionHistoryPath, 'utf8');
50
+ if (current !== pending.content) {
51
+ console.warn('⚠️ Version-history.md changed during the build; pending notes were preserved.');
52
+ return;
53
+ }
54
+ const heading = `## Version ${finalVersionName} (${finalVersionCode})`;
55
+ if (current.split(/\r?\n/).some(line => line === heading || line.startsWith(`${heading} — `))) {
56
+ console.warn('⚠️ This version already exists in Version-history.md; pending notes were preserved. Use a new version identifier to archive new changes.');
57
+ return;
58
+ }
59
+ const now = new Date();
60
+ const date = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')}`;
61
+ const stores = successfulStores.map(store => `${store.name} (${store.versionCode})`).join(', ');
62
+ const newline = current.includes('\r\n') ? '\r\n' : '\n';
63
+ const entry = `${emptyUnreleasedHistory}\n${heading} — ${date}\n\nBuilt stores: ${stores}\n\n${pending.notes}\n\n`;
64
+ const updated = current.slice(0, pending.index)
65
+ + entry.replace(/\r?\n/g, newline)
66
+ + current.slice(pending.index + pending.section.length);
67
+ // Write beside other temporary artifacts, then replace the history in one operation.
68
+ const tempDirectory = join(__dirname, 'agent-temp', 'version-history');
69
+ mkdirSync(tempDirectory, { recursive: true });
70
+ const tempPath = join(tempDirectory, `history-${process.pid}.tmp`);
71
+ try {
72
+ writeFileSync(tempPath, updated, 'utf8');
73
+ renameSync(tempPath, versionHistoryPath);
74
+ } finally {
75
+ if (existsSync(tempPath)) unlinkSync(tempPath);
76
+ }
77
+ console.log(`✅ Archived pending notes under Version ${finalVersionName} (${finalVersionCode}).`);
78
+ }
79
+
26
80
  function stripJavaScriptComments(content) {
27
81
  let result = '';
28
82
  let state = 'code';
@@ -928,6 +982,8 @@ rl.question('Enter new versionCode (press enter to keep current): ', (newVersion
928
982
  console.log(`📦 Final versionCode: ${finalVersionCode}`);
929
983
  console.log(`📝 Final versionName: ${finalVersionName}`);
930
984
 
985
+ const pendingVersionHistory = readPendingVersionHistory();
986
+ const successfulStores = [];
931
987
 
932
988
  updateIOSVersion(finalVersionCode, finalVersionName);
933
989
 
@@ -1003,8 +1059,12 @@ rl.question('Enter new versionCode (press enter to keep current): ', (newVersion
1003
1059
  // Conditionally set the new file name
1004
1060
  let newFileName;
1005
1061
  let storeName = storeNames[id];
1006
- // Amazon previously received version code 10000 for this package.
1007
- const storeVersionCode = _appPackageId === 'computer.shortcut.keys.app' && String(id) === '7'
1062
+ // These packages require the higher Amazon version-code range.
1063
+ const storeVersionCode = [
1064
+ 'computer.shortcut.keys.app',
1065
+ 'tamil.vidukathai.riddles.game',
1066
+ 'tamiljokes.vidukathai.thathuvam',
1067
+ ].includes(_appPackageId) && String(id) === '7'
1008
1068
  ? String(10000 + Number(finalVersionCode))
1009
1069
  : finalVersionCode;
1010
1070
 
@@ -1196,9 +1256,10 @@ rl.question('Enter new versionCode (press enter to keep current): ', (newVersion
1196
1256
  if (existsSync(oldFilePath)) {
1197
1257
  renameSync(oldFilePath, checkFullPath);
1198
1258
  console.log(`✅ Renamed output ${newExt.toUpperCase()} file to: ${path.basename(checkFullPath)}`);
1259
+ successfulStores.push({ name: storeName, versionCode: storeVersionCode });
1199
1260
  syncReleaseToCodeplay(storeName, finalVersionName, storeVersionCode, new Date().toISOString().slice(0, 10));
1200
1261
  } else {
1201
- console.error(`❌ ${newExt.toUpperCase()} file not found after build.`);
1262
+ throw new Error(`${newExt.toUpperCase()} file not found after build.`);
1202
1263
  }
1203
1264
 
1204
1265
  } catch (error) {
@@ -1216,6 +1277,12 @@ rl.question('Enter new versionCode (press enter to keep current): ', (newVersion
1216
1277
  }
1217
1278
  }
1218
1279
 
1280
+ try {
1281
+ archiveVersionHistory(pendingVersionHistory, finalVersionName, finalVersionCode, successfulStores);
1282
+ } catch (error) {
1283
+ console.error(`❌ Builds completed, but version history could not be archived: ${error.message}. Check Version-history.md before retrying.`);
1284
+ process.exitCode = 1;
1285
+ }
1219
1286
  rl.close(); // Close the readline interface after all operations
1220
1287
  });
1221
1288
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeplay-common",
3
- "version": "4.11.17",
3
+ "version": "4.11.19",
4
4
  "description": "Common build scripts and files",
5
5
  "scripts": {
6
6
  "postinstall": "node scripts/sync-files.js",