This commit is contained in:
otacoo
2026-01-30 05:59:56 +00:00
parent 05385f3b9d
commit ac67f762b3
2 changed files with 37 additions and 8 deletions
+2 -3
View File
@@ -1,11 +1,10 @@
{
"name": "sd-metadata-extractor",
"version": "1.1.0",
"version": "1.0.4",
"description": "Metadata extractor for AI-generated images (Stable Diffusion, NovelAI, ComfyUI, etc.)",
"main": "index.js",
"scripts": {
"version": "node update-version.js && git add -A",
"postversion": "git push && git push --tags"
"version": "node update-version.js"
},
"repository": {
"type": "git",
+35 -5
View File
@@ -1,12 +1,42 @@
// Sync version to __init__.py
/**
* Run by npm during "npm version" (patch/minor/major).
*/
const fs = require('fs');
const path = require('path');
const root = __dirname;
try {
const pkgPath = path.join(__dirname, 'package.json');
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
const pkg = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8'));
const version = pkg.version;
const versionTag = 'v' + version;
// Today's date (YYYY-MM-DD)
const today = new Date().toISOString().slice(0, 10);
// 1. CHANGELOG.md
const changelogPath = path.join(root, 'CHANGELOG.md');
let changelog = fs.readFileSync(changelogPath, 'utf8');
const newSection = `## ${versionTag}
*${today}*
-
`;
changelog = newSection + changelog;
fs.writeFileSync(changelogPath, changelog);
// 2. imgextract.html and standalone.html — replace version in footer
const versionRegex = /v\d+\.\d+\.\d+/;
for (const name of ['imgextract.html', 'standalone.html']) {
const htmlPath = path.join(root, 'static', name);
let html = fs.readFileSync(htmlPath, 'utf8');
html = html.replace(versionRegex, versionTag);
fs.writeFileSync(htmlPath, html);
}
console.log('Updated version to', versionTag, 'in CHANGELOG.md, imgextract.html, standalone.html');
} catch (err) {
console.warn('update-version.js:', err.message);
console.error('update-version.js:', err.message);
process.exit(1);
}
process.exit(0);