Skip to content
Open
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ When preparing a release:

OpenCite automatically includes GitHub release and source-tree identifiers in `CITATION.cff` when a version and repository URL are present.

Generated `CITATION.cff` files start with a `# Generated with OpenCite (https://imageomics.github.io/OpenCite/) version <x.y.z>` comment. `.zenodo.json` is unchanged because JSON does not support comments.

## Grants Autofill

The Grants field includes one-click suggestions for:
Expand Down
3 changes: 3 additions & 0 deletions src/services/appVersion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import pkg from '../../package.json' with { type: 'json' };

export const APP_VERSION = pkg.version;
3 changes: 3 additions & 0 deletions src/services/citation.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { APP_VERSION } from './appVersion.js';

export function quoteYAML(value) {
return String(value ?? '')
.replace(/\\/g, '\\\\')
Expand Down Expand Up @@ -183,6 +185,7 @@ export function toCitationCff(metadata) {
: 'If you find this work helpful in your research, please cite it.';

return [
`# Generated with OpenCite (https://imageomics.github.io/OpenCite/) version ${APP_VERSION}`,
'abstract: >-',
indentBlock(abstractText),
'authors:',
Expand Down
25 changes: 25 additions & 0 deletions tests/services/appVersion.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import test from 'node:test';
import { APP_VERSION } from '../../src/services/appVersion.js';
import { toCitationCff } from '../../src/services/citation.js';

const pkg = JSON.parse(readFileSync(new URL('../../package.json', import.meta.url), 'utf8'));

test('APP_VERSION is loaded from package.json', () => {
assert.equal(APP_VERSION, pkg.version);
});

test('CITATION.cff starts with the OpenCite generation comment', () => {
const cff = toCitationCff({
title: 'T',
authors: [],
keywords: [],
version: '1.0.0',
license: 'MIT',
});
assert.equal(
cff.split('\n')[0],
`# Generated with OpenCite (https://imageomics.github.io/OpenCite/) version ${pkg.version}`,
);
});
Loading