codeplay-common 4.11.16 → 4.11.18
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/files/finalrelease +64 -1
- package/files/take-screen-image.js +4414 -4408
- package/package.json +1 -1
package/files/finalrelease
CHANGED
|
@@ -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
|
|
|
@@ -1196,9 +1252,10 @@ rl.question('Enter new versionCode (press enter to keep current): ', (newVersion
|
|
|
1196
1252
|
if (existsSync(oldFilePath)) {
|
|
1197
1253
|
renameSync(oldFilePath, checkFullPath);
|
|
1198
1254
|
console.log(`✅ Renamed output ${newExt.toUpperCase()} file to: ${path.basename(checkFullPath)}`);
|
|
1255
|
+
successfulStores.push({ name: storeName, versionCode: storeVersionCode });
|
|
1199
1256
|
syncReleaseToCodeplay(storeName, finalVersionName, storeVersionCode, new Date().toISOString().slice(0, 10));
|
|
1200
1257
|
} else {
|
|
1201
|
-
|
|
1258
|
+
throw new Error(`${newExt.toUpperCase()} file not found after build.`);
|
|
1202
1259
|
}
|
|
1203
1260
|
|
|
1204
1261
|
} catch (error) {
|
|
@@ -1216,6 +1273,12 @@ rl.question('Enter new versionCode (press enter to keep current): ', (newVersion
|
|
|
1216
1273
|
}
|
|
1217
1274
|
}
|
|
1218
1275
|
|
|
1276
|
+
try {
|
|
1277
|
+
archiveVersionHistory(pendingVersionHistory, finalVersionName, finalVersionCode, successfulStores);
|
|
1278
|
+
} catch (error) {
|
|
1279
|
+
console.error(`❌ Builds completed, but version history could not be archived: ${error.message}. Check Version-history.md before retrying.`);
|
|
1280
|
+
process.exitCode = 1;
|
|
1281
|
+
}
|
|
1219
1282
|
rl.close(); // Close the readline interface after all operations
|
|
1220
1283
|
});
|
|
1221
1284
|
});
|