-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcopyVersion.js
40 lines (32 loc) · 1.28 KB
/
copyVersion.js
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
const fs = require('fs');
const path = require('path');
// Pfade zu den package.json-Dateien
const mainPackagePath = path.join(__dirname, 'package.json');
const libPackagePath = path.join(__dirname, 'projects', 'ngx-ratio-image', 'package.json');
// Funktion zum Lesen und Parsen der package.json-Dateien
function readPackageJson(filePath) {
return JSON.parse(fs.readFileSync(filePath, 'utf8'));
}
// Funktion zum Schreiben der aktualisierten package.json-Dateien
function writePackageJson(filePath, data) {
fs.writeFileSync(filePath, JSON.stringify(data, null, 2), 'utf8');
}
// Funktion zur Erhöhung der Version
function incrementVersion(version) {
const versionParts = version.split('.').map(Number);
versionParts[2] += 1; // Patch-Version erhöhen
return versionParts.join('.');
}
// Hauptlogik
function copyVersions() {
// Haupt-package.json lesen und Version hochsetzen
const mainPackageJson = readPackageJson(mainPackagePath);
const newVersion = mainPackageJson.version;
// lib/package.json lesen und Version synchronisieren
const libPackageJson = readPackageJson(libPackagePath);
libPackageJson.version = newVersion;
writePackageJson(libPackagePath, libPackageJson);
console.log(`Version updated to ${newVersion} in both package.json files.`);
}
// Skript ausführen
copyVersions();