Initial commit.
This commit is contained in:
commit
b022bca449
20 changed files with 7405 additions and 0 deletions
48
changeVersion.js
Normal file
48
changeVersion.js
Normal file
|
@ -0,0 +1,48 @@
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
function changeVersion(newVersion) {
|
||||
const packageJsonPath = path.join(__dirname, 'package.json');
|
||||
|
||||
// Read the current package.json
|
||||
fs.readFile(packageJsonPath, 'utf8', (err, data) => {
|
||||
if (err) {
|
||||
console.error('Error reading package.json:', err);
|
||||
return;
|
||||
}
|
||||
|
||||
let packageJson;
|
||||
try {
|
||||
packageJson = JSON.parse(data);
|
||||
} catch (parseError) {
|
||||
console.error('Error parsing package.json:', parseError);
|
||||
return;
|
||||
}
|
||||
|
||||
// Update the version
|
||||
packageJson.version = newVersion;
|
||||
|
||||
// Write the updated package.json back to file
|
||||
fs.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2), 'utf8', (writeErr) => {
|
||||
if (writeErr) {
|
||||
console.error('Error writing package.json:', writeErr);
|
||||
return;
|
||||
}
|
||||
console.log(`Version updated to ${newVersion}`);
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
//Semver based on current date and time
|
||||
const currentDate = new Date();
|
||||
const year = currentDate.getFullYear();
|
||||
const month = String(currentDate.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(currentDate.getDate()).padStart(2, '0');
|
||||
const hours = String(currentDate.getHours()).padStart(2, '0');
|
||||
const minutes = String(currentDate.getMinutes()).padStart(2, '0');
|
||||
const seconds = String(currentDate.getSeconds()).padStart(2, '0');
|
||||
|
||||
const newVersion = `1.${year}${month}${day}.${hours}${minutes}${seconds}`;
|
||||
|
||||
changeVersion(newVersion);
|
Loading…
Add table
Add a link
Reference in a new issue