From 9cff9152d80b1652bb1e33e936fac7eb3c049e1f Mon Sep 17 00:00:00 2001 From: beanbean9339 Date: Sun, 8 Nov 2026 16:12:10 -0500 Subject: [PATCH 1/3] feat: add OpenCite version comment to generated CITATION.cff (#85) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- README.md | 2 ++ src/appVersion.js | 2 ++ src/services/citation.js | 3 +++ tests/services/appVersion.test.js | 21 +++++++++++++++++++++ 4 files changed, 28 insertions(+) create mode 100644 src/appVersion.js create mode 100644 tests/services/appVersion.test.js diff --git a/README.md b/README.md index 6f4c607..b1504fd 100644 --- a/README.md +++ b/README.md @@ -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 version ` comment. `.zenodo.json` is unchanged because JSON does not support comments. + ## Grants Autofill The Grants field includes one-click suggestions for: diff --git a/src/appVersion.js b/src/appVersion.js new file mode 100644 index 0000000..3136155 --- /dev/null +++ b/src/appVersion.js @@ -0,0 +1,2 @@ +// Keep in sync with package.json "version" (enforced by tests/services/appVersion.test.js). +export const APP_VERSION = '1.0.0'; diff --git a/src/services/citation.js b/src/services/citation.js index aa5b3d0..7368cc0 100644 --- a/src/services/citation.js +++ b/src/services/citation.js @@ -1,3 +1,5 @@ +import { APP_VERSION } from '../appVersion.js'; + export function quoteYAML(value) { return String(value ?? '') .replace(/\\/g, '\\\\') @@ -183,6 +185,7 @@ export function toCitationCff(metadata) { : 'If you find this work helpful in your research, please cite it.'; return [ + `# Generated with OpenCite version ${APP_VERSION}`, 'abstract: >-', indentBlock(abstractText), 'authors:', diff --git a/tests/services/appVersion.test.js b/tests/services/appVersion.test.js new file mode 100644 index 0000000..5a90272 --- /dev/null +++ b/tests/services/appVersion.test.js @@ -0,0 +1,21 @@ +import assert from 'node:assert/strict'; +import { readFileSync } from 'node:fs'; +import test from 'node:test'; +import { APP_VERSION } from '../../src/appVersion.js'; +import { toCitationCff } from '../../src/services/citation.js'; + +test('APP_VERSION matches package.json', () => { + const pkg = JSON.parse(readFileSync(new URL('../../package.json', import.meta.url), 'utf8')); + 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 version ${APP_VERSION}`); +}); From 3ede23014cbb8b644b550b6e88afdf0b8a62f9fb Mon Sep 17 00:00:00 2001 From: beanbean9339 Date: Sun, 8 Nov 2026 16:14:44 -0500 Subject: [PATCH 2/3] refactor: load OpenCite version from package.json (#85) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/appVersion.js | 5 +++-- tests/services/appVersion.test.js | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/appVersion.js b/src/appVersion.js index 3136155..d98f744 100644 --- a/src/appVersion.js +++ b/src/appVersion.js @@ -1,2 +1,3 @@ -// Keep in sync with package.json "version" (enforced by tests/services/appVersion.test.js). -export const APP_VERSION = '1.0.0'; +import pkg from '../package.json' with { type: 'json' }; + +export const APP_VERSION = pkg.version; diff --git a/tests/services/appVersion.test.js b/tests/services/appVersion.test.js index 5a90272..3c63652 100644 --- a/tests/services/appVersion.test.js +++ b/tests/services/appVersion.test.js @@ -4,7 +4,7 @@ import test from 'node:test'; import { APP_VERSION } from '../../src/appVersion.js'; import { toCitationCff } from '../../src/services/citation.js'; -test('APP_VERSION matches package.json', () => { +test('APP_VERSION is loaded from package.json', () => { const pkg = JSON.parse(readFileSync(new URL('../../package.json', import.meta.url), 'utf8')); assert.equal(APP_VERSION, pkg.version); }); From 68d955d20a17b2fd751ed2bdd5c9d0bb2b57373e Mon Sep 17 00:00:00 2001 From: beanbean9339 Date: Mon, 9 Nov 2026 11:11:45 -0500 Subject: [PATCH 3/3] feat: update CITATION.cff generation comment to include OpenCite URL and refactor appVersion import paths --- README.md | 2 +- src/appVersion.js | 3 --- src/services/appVersion.js | 3 +++ src/services/citation.js | 4 ++-- tests/services/appVersion.test.js | 10 +++++++--- 5 files changed, 13 insertions(+), 9 deletions(-) delete mode 100644 src/appVersion.js create mode 100644 src/services/appVersion.js diff --git a/README.md b/README.md index b1504fd..50d1829 100644 --- a/README.md +++ b/README.md @@ -174,7 +174,7 @@ 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 version ` comment. `.zenodo.json` is unchanged because JSON does not support comments. +Generated `CITATION.cff` files start with a `# Generated with OpenCite (https://imageomics.github.io/OpenCite/) version ` comment. `.zenodo.json` is unchanged because JSON does not support comments. ## Grants Autofill diff --git a/src/appVersion.js b/src/appVersion.js deleted file mode 100644 index d98f744..0000000 --- a/src/appVersion.js +++ /dev/null @@ -1,3 +0,0 @@ -import pkg from '../package.json' with { type: 'json' }; - -export const APP_VERSION = pkg.version; diff --git a/src/services/appVersion.js b/src/services/appVersion.js new file mode 100644 index 0000000..f62929c --- /dev/null +++ b/src/services/appVersion.js @@ -0,0 +1,3 @@ +import pkg from '../../package.json' with { type: 'json' }; + +export const APP_VERSION = pkg.version; diff --git a/src/services/citation.js b/src/services/citation.js index 7368cc0..daac826 100644 --- a/src/services/citation.js +++ b/src/services/citation.js @@ -1,4 +1,4 @@ -import { APP_VERSION } from '../appVersion.js'; +import { APP_VERSION } from './appVersion.js'; export function quoteYAML(value) { return String(value ?? '') @@ -185,7 +185,7 @@ export function toCitationCff(metadata) { : 'If you find this work helpful in your research, please cite it.'; return [ - `# Generated with OpenCite version ${APP_VERSION}`, + `# Generated with OpenCite (https://imageomics.github.io/OpenCite/) version ${APP_VERSION}`, 'abstract: >-', indentBlock(abstractText), 'authors:', diff --git a/tests/services/appVersion.test.js b/tests/services/appVersion.test.js index 3c63652..1655fd1 100644 --- a/tests/services/appVersion.test.js +++ b/tests/services/appVersion.test.js @@ -1,11 +1,12 @@ import assert from 'node:assert/strict'; import { readFileSync } from 'node:fs'; import test from 'node:test'; -import { APP_VERSION } from '../../src/appVersion.js'; +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', () => { - const pkg = JSON.parse(readFileSync(new URL('../../package.json', import.meta.url), 'utf8')); assert.equal(APP_VERSION, pkg.version); }); @@ -17,5 +18,8 @@ test('CITATION.cff starts with the OpenCite generation comment', () => { version: '1.0.0', license: 'MIT', }); - assert.equal(cff.split('\n')[0], `# Generated with OpenCite version ${APP_VERSION}`); + assert.equal( + cff.split('\n')[0], + `# Generated with OpenCite (https://imageomics.github.io/OpenCite/) version ${pkg.version}`, + ); });