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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -1435,7 +1435,7 @@ export default function App() {
</button>
</div>
<p className="filename-note">
Keep the Zenodo filename as <strong>.zenodo.json</strong> for downstream tooling compatibility. The ZIP now includes <strong>METADATA_VALIDATION.txt</strong> with export checks.
Some browsers save the standalone file as <strong>zenodo.json</strong>. If that happens, rename it to <strong>.zenodo.json</strong>, or use <strong>Download ZIP (Both Files)</strong> to preserve the filename inside the archive. The ZIP includes <strong>METADATA_VALIDATION.txt</strong> with export checks.
</p>

<div className="preview">
Expand Down
23 changes: 23 additions & 0 deletions tests/services/metadataZip.test.js
Original file line number Diff line number Diff line change
@@ -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();
}
});
Loading