Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
VITE_SHOW_SAMPLE_DATA= "true"

[build]
command = "sed -i \"s|DICOM_WEB_API_KEY|${DICOM_WEB_API_KEY}|g; s|DICOM_WEB_ADDRESS|${DICOM_WEB_ADDRESS}|g\" netlify.toml && npm run build"
# The version shown in the About box comes from `git describe`, which needs tags
# and enough history to count from them. Netlify clones neither by default.
command = "{ git fetch --tags --unshallow || git fetch --tags; } 2>/dev/null; sed -i \"s|DICOM_WEB_API_KEY|${DICOM_WEB_API_KEY}|g; s|DICOM_WEB_ADDRESS|${DICOM_WEB_ADDRESS}|g\" netlify.toml && npm run build"

[dev]
targetPort = 8080
23 changes: 22 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ function resolvePath(...args: string[]) {
return normalizePath(path.resolve(...args));
}

const PLACEHOLDER_VERSION = '0.0.0';

function getPackageInfo() {
const mainPkgPath = path.resolve(__dirname, 'package.json');
const mainPkg = JSON.parse(fs.readFileSync(mainPkgPath, 'utf-8'));
Expand All @@ -48,13 +50,32 @@ function getPackageInfo() {

return {
versions: {
volview: mainPkg.version,
volview: getVolViewVersion(mainPkg.version),
'vtk.js': vtkJsPkg.version,
'itk-wasm': itkWasmPkg.version,
},
};
}

// package.json carries the placeholder 0.0.0 on main; the release workflow
// stamps the real version from the pushed tag before it builds. Builds that
// skip that step (Netlify, local dev) fall back to describing the tag directly.
function getVolViewVersion(pkgVersion: string) {
if (pkgVersion !== PLACEHOLDER_VERSION) return pkgVersion;
return getGitDescribe() ?? pkgVersion;
}

function getGitDescribe() {
try {
const described = execSync('git describe --tags --always')
.toString()
.trim();
return described.replace(/^v/, '');
} catch {
return undefined;
}
}

function getGitShortSha() {
try {
return execSync('git rev-parse --short HEAD').toString().trim();
Expand Down
Loading