Fixed build issues.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "jmespath-playground",
|
||||
"version": "1.4.1",
|
||||
"version": "1.4.2",
|
||||
"description": "A React-based web application for testing JMESPath expressions against JSON data",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -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() {
|
||||
const versionModuleUrl = pathToFileURL(path.join(__dirname, 'version.mjs')).href;
|
||||
const { generateVersionFile: generate } = await import(versionModuleUrl);
|
||||
@@ -44,6 +53,26 @@ async function generateVersionFile() {
|
||||
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) {
|
||||
const contents = fs.readFileSync(versionFilePath, 'utf8');
|
||||
const versionMatch = contents.match(/export const VERSION = '([^']+)';/);
|
||||
@@ -117,8 +146,19 @@ async function main() {
|
||||
}
|
||||
|
||||
const containerTool = getContainerTool();
|
||||
const versionFilePath = await generateVersionFile();
|
||||
const { version, isRelease } = readVersionFile(versionFilePath);
|
||||
let version;
|
||||
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;
|
||||
if (values['all-arch']) {
|
||||
|
||||
Reference in New Issue
Block a user