-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate-docs.mjs
More file actions
executable file
·360 lines (300 loc) · 11.4 KB
/
update-docs.mjs
File metadata and controls
executable file
·360 lines (300 loc) · 11.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
#!/usr/bin/env node
/**
* Script to automatically update documentation with versions from pom.xml and package.json
* Usage: node update-docs.mjs
*/
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
// Read package.json
const packageJsonPath = path.join(__dirname, 'src/main/web/package.json');
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
// Read pom.xml
const pomPath = path.join(__dirname, 'pom.xml');
const pomXml = fs.readFileSync(pomPath, 'utf-8');
// Read tsconfig.json
const tsconfigPath = path.join(__dirname, 'src/main/web/tsconfig.json');
const tsconfigContent = fs.readFileSync(tsconfigPath, 'utf-8');
const targetMatch = tsconfigContent.match(/"target"\s*:\s*"([^"]+)"/);
const typescriptTarget = targetMatch ? targetMatch[1] : 'ES2020';
// Extract versions from pom.xml
const extractPomVersion = (tag) => {
const regex = new RegExp(`<${tag}>([^<]+)</${tag}>`);
const match = pomXml.match(regex);
return match ? match[1] : null;
};
const extractProperty = (name) => {
const regex = new RegExp(`<${name}>([^<]+)</${name}>`);
const match = pomXml.match(regex);
return match ? match[1] : null;
};
// Backend versions
const backendVersions = {
projectVersion: extractPomVersion('version'),
javaVersion: extractProperty('java.version') || '25',
javaRelease: extractProperty('maven.compiler.release') || '25',
quarkusVersion: extractProperty('quarkus.platform.version') || '3.30.5',
mavenVersion: extractProperty('maven.version') || '3.9.11',
nodeVersion: extractProperty('node.version') || 'v24.12.0',
pnpmVersion: extractProperty('pnpm.version') || '10.27.0',
npmVersion: extractProperty('npm.version') || '11.6.2',
// Maven plugins
mavenCompilerPlugin: extractProperty('maven-compiler-plugin.version') || '3.14.1',
mavenSurefirePlugin: extractProperty('maven-surefire-plugin.version') || '3.5.4',
mavenFailsafePlugin: extractProperty('maven-failsafe-plugin.version') || '3.5.4',
frontendMavenPlugin: extractProperty('frontend-maven-plugin.version') || '2.0.0',
};
// Frontend versions from package.json
const frontendVersions = {
// Runtime dependencies
vue: packageJson.dependencies?.vue || '3.5.26',
vueuse: packageJson.dependencies?.['@vueuse/core'] || '14.1.0',
pinia: packageJson.dependencies?.pinia || '3.0.4',
chartjs: packageJson.dependencies?.['chart.js'] || '4.5.1',
floatingUi: packageJson.dependencies?.['@floating-ui/vue'] || '1.1.9',
dateFns: packageJson.dependencies?.['date-fns'] || '4.1.0',
filesize: packageJson.dependencies?.filesize || '11.0.13',
// Dev dependencies
typescript: packageJson.devDependencies?.typescript || '5.9.3',
typescriptTarget: typescriptTarget,
vite: packageJson.devDependencies?.vite || '7.3.0',
tailwind: packageJson.devDependencies?.tailwindcss || '4.1.18',
vitest: packageJson.devDependencies?.vitest || '4.0.16',
prettier: packageJson.devDependencies?.prettier || '3.7.4',
iconifyFaBrands: packageJson.devDependencies?.['@iconify-json/fa6-brands']?.replace('^', '') || '1.2.6',
iconifySimpleIcons: packageJson.devDependencies?.['@iconify-json/simple-icons']?.replace('^', '') || '1.2.65',
};
console.log('📦 Extracted Versions:');
console.log('Backend:', backendVersions);
console.log('Frontend:', frontendVersions);
// Update README.md
const updateReadme = () => {
const readmePath = path.join(__dirname, 'README.md');
let readme = fs.readFileSync(readmePath, 'utf-8');
// Update badges
readme = readme.replace(
/!\[Java\]\(https:\/\/img\.shields\.io\/badge\/Java-\d+-orange\.svg\)/,
``
);
readme = readme.replace(
/!\[Quarkus\]\(https:\/\/img\.shields\.io\/badge\/Quarkus-[\d.]+-blue\.svg\)/,
``
);
readme = readme.replace(
/!\[Vue\]\(https:\/\/img\.shields\.io\/badge\/Vue\.js-[\d.]+-green\.svg\)/,
``
);
readme = readme.replace(
/!\[TypeScript\]\(https:\/\/img\.shields\.io\/badge\/TypeScript-[\d.]+-blue\.svg\)/,
``
);
// Update Backend table
readme = readme.replace(
/(^\| \*\*Java\*\*\s+\| )\d+(\s+\|)/m,
`$1${backendVersions.javaVersion}$2`
);
readme = readme.replace(
/(^\| \*\*Quarkus\*\*\s+\| )[\d.]+(\s+\|)/m,
`$1${backendVersions.quarkusVersion}$2`
);
// Update Frontend Runtime Dependencies table
const runtimeDeps = [
['Vue.js', frontendVersions.vue],
['VueUse', frontendVersions.vueuse],
['Pinia', frontendVersions.pinia],
['Chart.js', frontendVersions.chartjs],
['Floating UI', frontendVersions.floatingUi],
['date-fns', frontendVersions.dateFns],
['filesize', frontendVersions.filesize],
];
runtimeDeps.forEach(([name, version]) => {
const escapedName = name.replace(/\./g, '\\.');
const regex = new RegExp(`(^\\| \\*\\*${escapedName}\\*\\*\\s+\\| )[\\d.]+( \\|)`, 'gm');
readme = readme.replace(regex, `$1${version}$2`);
});
// Update Frontend Build Tools table
const buildTools = [
['TypeScript', frontendVersions.typescript],
['Vite', frontendVersions.vite],
['Tailwind CSS', frontendVersions.tailwind],
['Vitest', frontendVersions.vitest],
['Prettier', frontendVersions.prettier],
];
buildTools.forEach(([name, version]) => {
const escapedName = name.replace(/\./g, '\\.');
const regex = new RegExp(`(^\\| \\*\\*${escapedName}\\*\\*\\s+\\| )[\\d.]+( \\|)`, 'gm');
readme = readme.replace(regex, `$1${version}$2`);
});
// Update Build & Deploy section
readme = readme.replace(
/\*\*Maven\*\* [\d.]+ /,
`**Maven** ${backendVersions.mavenVersion} `
);
readme = readme.replace(
/\*\*Node\.js\*\* v[\d.]+ /,
`**Node.js** ${backendVersions.nodeVersion} `
);
readme = readme.replace(
/\*\*pnpm\*\* [\d.]+ /,
`**pnpm** ${backendVersions.pnpmVersion} `
);
readme = readme.replace(
/\*\*npm\*\* [\d.]+ /,
`**npm** ${backendVersions.npmVersion} `
);
// Update version in docker tags
readme = readme.replace(
/- Current version: `[\d.]+-SNAPSHOT`/,
`- Current version: \`${backendVersions.projectVersion}\``
);
// Update Maven plugins in Build & Deploy section
readme = readme.replace(
/\*\*Maven Compiler Plugin\*\* [\d.]+/,
`**Maven Compiler Plugin** ${backendVersions.mavenCompilerPlugin}`
);
readme = readme.replace(
/\*\*Maven Surefire Plugin\*\* [\d.]+/,
`**Maven Surefire Plugin** ${backendVersions.mavenSurefirePlugin}`
);
readme = readme.replace(
/\*\*Maven Failsafe Plugin\*\* [\d.]+/,
`**Maven Failsafe Plugin** ${backendVersions.mavenFailsafePlugin}`
);
readme = readme.replace(
/\*\*Frontend Maven Plugin\*\* [\d.]+/,
`**Frontend Maven Plugin** ${backendVersions.frontendMavenPlugin}`
);
fs.writeFileSync(readmePath, readme, 'utf-8');
console.log('✅ Updated README.md');
};
// Update TESTING.md
const updateTesting = () => {
const testingPath = path.join(__dirname, 'TESTING.md');
let testing = fs.readFileSync(testingPath, 'utf-8');
// Update Frontend technologies
const techVersions = [
['Vitest', frontendVersions.vitest],
['Vue Test Utils', '2.4.6'],
['Happy DOM', '20.0.11'],
['Vite', frontendVersions.vite],
['TypeScript', frontendVersions.typescript],
['VueUse', frontendVersions.vueuse],
['Chart.js', frontendVersions.chartjs],
['Tailwind CSS', frontendVersions.tailwind],
['Iconify', '5.0.0'],
['Simple Icons', frontendVersions.iconifySimpleIcons],
['Floating UI', frontendVersions.floatingUi],
];
techVersions.forEach(([name, version]) => {
const escapedName = name.replace(/\./g, '\\.');
const regex = new RegExp(`${escapedName} \\([\\d.]+\\)`, 'g');
testing = testing.replace(regex, `${name} (${version})`);
});
// Update pnpm version
testing = testing.replace(
/\*\*pnpm\*\* [\d.]+ /,
`**pnpm** ${backendVersions.pnpmVersion} `
);
fs.writeFileSync(testingPath, testing, 'utf-8');
console.log('✅ Updated TESTING.md');
};
// Update CONTRIBUTING.md
const updateContributing = () => {
const contributingPath = path.join(__dirname, 'CONTRIBUTING.md');
let contributing = fs.readFileSync(contributingPath, 'utf-8');
// Update versions section
contributing = contributing.replace(
/- Java \d+/,
`- Java ${backendVersions.javaVersion}`
);
// Match Quarkus version with possible suffix (e.g., CR1, Final, etc.)
contributing = contributing.replace(
/- Quarkus [\d.]+[A-Za-z0-9.\-]*/,
`- Quarkus ${backendVersions.quarkusVersion}`
);
contributing = contributing.replace(
/- Node\.js v[\d.]+/,
`- Node.js ${backendVersions.nodeVersion}`
);
contributing = contributing.replace(
/- pnpm [\d.]+/,
`- pnpm ${backendVersions.pnpmVersion}`
);
contributing = contributing.replace(
/- npm [\d.]+/,
`- npm ${backendVersions.npmVersion}`
);
fs.writeFileSync(contributingPath, contributing, 'utf-8');
console.log('✅ Updated CONTRIBUTING.md');
};
// Update BUILD.md
const updateBuild = () => {
const buildPath = path.join(__dirname, 'BUILD.md');
let build = fs.readFileSync(buildPath, 'utf-8');
// Update prerequisites
build = build.replace(
/\*\*Required:\*\* Java \d+\+, Maven [\d.]+\+/,
`**Required:** Java ${backendVersions.javaVersion}+, Maven ${backendVersions.mavenVersion}+`
);
build = build.replace(
/\*\*Optional:\*\* Node\.js \d+\+ \(v[\d.]+/,
`**Optional:** Node.js 24+ (${backendVersions.nodeVersion}`
);
build = build.replace(
/pnpm [\d.]+/g,
`pnpm ${backendVersions.pnpmVersion}`
);
build = build.replace(
/npm [\d.]+/g,
`npm ${backendVersions.npmVersion}`
);
fs.writeFileSync(buildPath, build, 'utf-8');
console.log('✅ Updated BUILD.md');
};
// Update GitHub Actions workflows
const updateWorkflows = () => {
const workflowFiles = [
'.github/workflows/docker-dev-native.yml',
'.github/workflows/docker-native.yml',
];
workflowFiles.forEach((filePath) => {
const fullPath = path.join(__dirname, filePath);
if (!fs.existsSync(fullPath)) return;
let workflow = fs.readFileSync(fullPath, 'utf-8');
// Update GRAALVM_VERSION
workflow = workflow.replace(
/GRAALVM_VERSION: "\d+"/,
`GRAALVM_VERSION: "${backendVersions.javaVersion}"`
);
// Update NODE_VERSION
workflow = workflow.replace(
/NODE_VERSION: "v?[\d.]+"/,
`NODE_VERSION: "${backendVersions.nodeVersion}"`
);
// Update PNPM_VERSION
workflow = workflow.replace(
/PNPM_VERSION: "[\d.]+"/,
`PNPM_VERSION: "${backendVersions.pnpmVersion}"`
);
// Update MAVEN_VERSION
workflow = workflow.replace(
/MAVEN_VERSION: "[\d.]+"/,
`MAVEN_VERSION: "${backendVersions.mavenVersion}"`
);
fs.writeFileSync(fullPath, workflow, 'utf-8');
console.log(`✅ Updated ${filePath}`);
});
};
// Run all updates
try {
updateReadme();
updateTesting();
updateContributing();
updateBuild();
updateWorkflows();
console.log('\n✨ Documentation successfully updated with current versions!');
} catch (error) {
console.error('❌ Error updating documentation:', error);
process.exit(1);
}