1 Commits
1.4.1 ... 1.4.2

Author SHA1 Message Date
ec2f2dbd57 Fixed build issues. 2026-02-02 07:23:51 +01:00
2 changed files with 43 additions and 3 deletions

View File

@@ -1,6 +1,6 @@
{ {
"name": "jmespath-playground", "name": "jmespath-playground",
"version": "1.4.1", "version": "1.4.2",
"description": "A React-based web application for testing JMESPath expressions against JSON data", "description": "A React-based web application for testing JMESPath expressions against JSON data",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {

View File

@@ -36,6 +36,15 @@ function getContainerTool() {
} }
} }
function isGitRepo() {
try {
execSync('git rev-parse --is-inside-work-tree', { stdio: 'ignore' });
return true;
} catch (error) {
return false;
}
}
async function generateVersionFile() { async function generateVersionFile() {
const versionModuleUrl = pathToFileURL(path.join(__dirname, 'version.mjs')).href; const versionModuleUrl = pathToFileURL(path.join(__dirname, 'version.mjs')).href;
const { generateVersionFile: generate } = await import(versionModuleUrl); const { generateVersionFile: generate } = await import(versionModuleUrl);
@@ -44,6 +53,26 @@ async function generateVersionFile() {
return versionFilePath; return versionFilePath;
} }
function writeVersionFile(version, isRelease) {
const versionFilePath = path.join(__dirname, '..', 'src', 'version.js');
const contents = [
`export const VERSION = '${version}';`,
`export const IS_RELEASE = ${isRelease};`,
''
].join('\n');
fs.writeFileSync(versionFilePath, contents, 'utf8');
return versionFilePath;
}
function readPackageJsonVersion() {
const packagePath = path.join(__dirname, '..', 'package.json');
const pkg = JSON.parse(fs.readFileSync(packagePath, 'utf8'));
if (!pkg.version) {
throw new Error('package.json does not contain a version');
}
return pkg.version;
}
function readVersionFile(versionFilePath) { function readVersionFile(versionFilePath) {
const contents = fs.readFileSync(versionFilePath, 'utf8'); const contents = fs.readFileSync(versionFilePath, 'utf8');
const versionMatch = contents.match(/export const VERSION = '([^']+)';/); const versionMatch = contents.match(/export const VERSION = '([^']+)';/);
@@ -117,8 +146,19 @@ async function main() {
} }
const containerTool = getContainerTool(); const containerTool = getContainerTool();
const versionFilePath = await generateVersionFile(); let version;
const { version, isRelease } = readVersionFile(versionFilePath); let isRelease;
if (isGitRepo()) {
const versionFilePath = await generateVersionFile();
const versionInfo = readVersionFile(versionFilePath);
version = versionInfo.version;
isRelease = versionInfo.isRelease;
} else {
version = readPackageJsonVersion();
isRelease = true;
writeVersionFile(version, isRelease);
}
let architectures; let architectures;
if (values['all-arch']) { if (values['all-arch']) {