File size: 1,691 Bytes
51bdde0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env node

/**
 * Script to update version numbers in HTML files from package.json
 * Run this script whenever you need to sync HTML versions with package.json
 */

import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

// Read version from package.json
const packageJson = JSON.parse(
  fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf8')
);
const version = packageJson.version;

// HTML files to update
const htmlFiles = [
  'index.html',
  'about.html',
  'contact.html',
  'faq.html',
  'privacy.html',
  'terms.html',
  'src/pages/add-stamps.html',
  'src/pages/bookmark.html',
  'src/pages/json-to-pdf.html',
  'src/pages/pdf-multi-tool.html',
  'src/pages/pdf-to-json.html',
  'src/pages/table-of-contents.html',
];

console.log(`Updating version to ${version} in HTML files...`);

let updatedCount = 0;

htmlFiles.forEach((file) => {
  const filePath = path.join(__dirname, '..', file);
  
  if (!fs.existsSync(filePath)) {
    console.log(`⚠️  Skipping ${file} (not found)`);
    return;
  }

  let content = fs.readFileSync(filePath, 'utf8');
  
  // Replace version in <span id="app-version">X.X.X</span>
  const regex = /(<span id="app-version">)[^<]+(<\/span>)/g;
  const newContent = content.replace(regex, `$1${version}$2`);
  
  if (content !== newContent) {
    fs.writeFileSync(filePath, newContent, 'utf8');
    console.log(`✓ Updated ${file}`);
    updatedCount++;
  } else {
    console.log(`- ${file} (already up to date)`);
  }
});

console.log(`\nDone! Updated ${updatedCount} file(s) to version ${version}`);