diff --git a/README.md b/README.md index 8412f16..724647f 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,12 @@ npm exec -- zenodraft metadata validate .zenodo.json During export, OpenCite validates generated `.zenodo.json` metadata. ZIP exports include `METADATA_VALIDATION.txt` for downstream provenance checks. +Some browsers or operating systems may save the standalone Zenodo download as +`zenodo.json` even though OpenCite requests `.zenodo.json`. Rename that file to +`.zenodo.json` before adding it to a repository, or use **Download ZIP (Both +Files)**: the archive contains `CITATION.cff`, `.zenodo.json`, and the validation +report with the exact filenames. Extract the metadata files before using them. + ## GitHub Import Workflow 1. Paste a GitHub repository URL into the import field. diff --git a/src/App.jsx b/src/App.jsx index 992b93b..9f89aec 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -357,7 +357,7 @@ function canUseNativeFilePicker() { return typeof window !== 'undefined' && typeof window.showSaveFilePicker === 'function'; } -async function createMetadataZipBlob(citationPreview, zenodoPreview, validationReport) { +export async function createMetadataZipBlob(citationPreview, zenodoPreview, validationReport) { const zip = new JSZip(); zip.file(CITATION_FILENAME, citationPreview); zip.file(ZENODO_FILENAME, zenodoPreview); @@ -1435,7 +1435,7 @@ export default function App() {

- Keep the Zenodo filename as .zenodo.json for downstream tooling compatibility. The ZIP now includes METADATA_VALIDATION.txt with export checks. + Some browsers save the standalone file as zenodo.json. If that happens, rename it to .zenodo.json, or use Download ZIP (Both Files) to preserve the filename inside the archive. The ZIP includes METADATA_VALIDATION.txt with export checks.

diff --git a/tests/services/metadataZip.test.js b/tests/services/metadataZip.test.js new file mode 100644 index 0000000..e47e319 --- /dev/null +++ b/tests/services/metadataZip.test.js @@ -0,0 +1,23 @@ +import test from 'node:test'; +import assert from 'node:assert/strict'; +import JSZip from 'jszip'; +import { createServer } from 'vite'; + +test('metadata ZIP preserves the exact dotfile name and both export contents', async () => { + const vite = await createServer({ server: { middlewareMode: true }, appType: 'custom' }); + try { + const { createMetadataZipBlob } = await vite.ssrLoadModule('/src/App.jsx'); + const citation = 'cff-version: 1.2.0\n'; + const zenodo = '{"title":"OpenCite"}'; + const report = 'Validation passed'; + const blob = await createMetadataZipBlob(citation, zenodo, report); + const zip = await JSZip.loadAsync(await blob.arrayBuffer()); + + assert.deepEqual(Object.keys(zip.files).sort(), ['.zenodo.json', 'CITATION.cff', 'METADATA_VALIDATION.txt']); + assert.equal(await zip.file('.zenodo.json').async('string'), zenodo); + assert.equal(await zip.file('CITATION.cff').async('string'), citation); + assert.equal(await zip.file('METADATA_VALIDATION.txt').async('string'), report); + } finally { + await vite.close(); + } +}); \ No newline at end of file