Files
pdfme/packages/common/set-version.js
Kyohei Fukuda 16bec8babb [codex] Add inline markdown text format (#1461)
* feat(schemas): add inline markdown text format

* fix(common): handle missing git tags in version script

* fix(converter): align pdfjs document options with latest types

* test(generator): update pdfjs image snapshots

* test(playground): register inline markdown example

* refactor(schemas): avoid default font i18n key

* refactor(schemas): move markdown controls to prop panel end

* refactor(schemas): use checkbox for inline markdown toggle

* fix(schemas): localize multi variable text prop labels

* refactor(schemas): align inline markdown fallback control

* fix(schemas): address inline markdown review feedback

* refactor(schemas): address inline markdown review refinements

* fix(schemas): correct synthetic italic pdf skew

* test(playground): add bold italic inline markdown sample
2026-05-02 16:34:43 +09:00

45 lines
1.3 KiB
JavaScript

import fs from 'node:fs';
import path from 'node:path';
import { execFileSync } from 'node:child_process';
import { fileURLToPath } from 'node:url';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const DEFAULT_VERSION = 'x.x.x';
const updateVersion = (version) => {
const filePath = path.join(__dirname, 'src/version.ts');
let content = '';
if (!fs.existsSync(filePath)) {
content = `export const PDFME_VERSION = '${version}';\n`;
} else {
content = fs.readFileSync(filePath, 'utf8');
const versionRegex = /export const PDFME_VERSION = '.*';/;
if (versionRegex.test(content)) {
content = content.replace(versionRegex, `export const PDFME_VERSION = '${version}';`);
} else {
content += `\nexport const PDFME_VERSION = '${version}';\n`;
}
}
fs.writeFileSync(filePath, content, 'utf8');
console.log(`Replaced PDFME_VERSION with '${version}' in ${filePath}`);
};
const getLatestGitTag = () => {
try {
return execFileSync(
'git',
['for-each-ref', '--sort=-creatordate', '--format=%(refname:short)', '--count=1', 'refs/tags'],
{
encoding: 'utf8',
stdio: ['ignore', 'pipe', 'ignore'],
},
).trim();
} catch {
return '';
}
};
updateVersion(getLatestGitTag() || DEFAULT_VERSION);