npm
This commit is contained in:
+2
-3
@@ -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
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user