You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* This script fetches GitHub release notes and updates the local CHANGELOG.md file
7
+
* to ensure consistency between local documentation and published releases.
8
+
*
9
+
* Usage:
10
+
* node scripts/sync-changelog.js [--test]
11
+
*
12
+
* Options:
13
+
* --test Use hardcoded test data instead of fetching from GitHub
14
+
*
15
+
* Requirements:
16
+
* - GitHub CLI (gh) installed and authenticated OR GITHUB_TOKEN environment variable
17
+
* - Run from the repository root directory
18
+
*/
19
+
20
+
const{ execSync }=require('child_process');
21
+
constfs=require('fs');
22
+
constpath=require('path');
23
+
consthttps=require('https');
24
+
25
+
constTEST_MODE=process.argv.includes('--test');
26
+
27
+
// Test data matching the actual GitHub releases
28
+
constTEST_RELEASES=[
29
+
{
30
+
tagName: "v0.0.2",
31
+
name: "Release 0.0.2",
32
+
body: "\n- Automated VSIX build and release workflow",
33
+
createdAt: "2025-09-28T12:31:58Z",
34
+
isPrerelease: false
35
+
},
36
+
{
37
+
tagName: "v0.0.1",
38
+
name: "First draft",
39
+
body: "First rough version, not complete of course! \r\n\r\n- Only tested on windows\r\n- Use at your own risk 😄\r\n- Screenshots in the README\r\n- VS Code v1.104 or higher\r\n\r\n**Full Changelog**: https://github.com/rajbos/github-copilot-token-usage/commits/v0.0.1",
40
+
createdAt: "2025-09-26T21:55:29Z",
41
+
isPrerelease: true
42
+
}
43
+
];
44
+
45
+
asyncfunctionfetchGitHubReleases(){
46
+
if(TEST_MODE){
47
+
console.log('🧪 Using test data (--test mode)...');
48
+
returnTEST_RELEASES;
49
+
}
50
+
51
+
// Try GitHub CLI first
52
+
try{
53
+
execSync('gh --version',{stdio: 'ignore'});
54
+
console.log('📡 Fetching GitHub releases using GitHub CLI...');
55
+
constreleasesJson=execSync('gh release list --json tagName,name,body,createdAt,isPrerelease --limit 50',{encoding: 'utf8'});
56
+
returnJSON.parse(releasesJson);
57
+
}catch(error){
58
+
console.log('⚠️ GitHub CLI not available or not authenticated, falling back to GitHub API...');
59
+
}
60
+
61
+
// Fall back to GitHub API
62
+
consttoken=process.env.GITHUB_TOKEN;
63
+
if(!token){
64
+
console.error('❌ Error: GitHub CLI is not available and GITHUB_TOKEN environment variable is not set');
65
+
console.error(' Please either:');
66
+
console.error(' 1. Install and authenticate GitHub CLI: https://cli.github.com/');
67
+
console.error(' 2. Set GITHUB_TOKEN environment variable with a GitHub personal access token');
68
+
console.error(' 3. Use --test flag to test with sample data');
header='# Change Log\n\nAll notable changes to the "copilot-token-tracker" extension will be documented in this file.\n\nCheck [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.\n\n## [Unreleased]';
183
+
unreleasedSection='\n';
184
+
}
185
+
186
+
// Build new changelog content
187
+
letnewChangelog=header+unreleasedSection+'\n';
188
+
189
+
console.log('✏️ Building changelog entries from releases...');
0 commit comments