Skip to content

Commit 3f08834

Browse files
authored
🔧 Update jats convert frontmatter default and enable v# suffixed bioRxiv dois (#78)
1 parent 402296f commit 3f08834

File tree

5 files changed

+28
-10
lines changed

5 files changed

+28
-10
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'jats-fetch': patch
3+
---
4+
5+
Enable v# suffixed bioRxiv dois
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'jats-convert': minor
3+
'jats-cli': minor
4+
---
5+
6+
Update jats convert frontmatter default

‎packages/jats-cli/src/convert.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ function makeConvertCLI(program: Command) {
77
.description('Convert JATS file to MyST mdast json')
88
.argument('[input]', 'The JATS file')
99
.addOption(
10-
new Option(
11-
'--frontmatter <frontmatter>',
12-
'Treat JATS frontmatter fields as page or project, or ignore if not specified',
13-
).choices(['page', 'project']),
10+
new Option('--frontmatter <frontmatter>', 'Treat JATS frontmatter fields as page or project')
11+
.choices(['page', 'project'])
12+
.default('project'),
1413
)
14+
.addOption(new Option('--no-frontmatter', 'Ignore JATS frontmatter'))
1515
.addOption(
1616
new Option(
1717
'--no-doi, --no-dois',

‎packages/jats-convert/src/index.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ export function jatsConvertTransform(
738738
export async function jatsConvert(
739739
session: ISession,
740740
input?: string,
741-
opts?: { frontmatter?: 'page' | 'project'; dois?: boolean; bibtex?: boolean },
741+
opts?: { frontmatter?: 'page' | 'project' | false; dois?: boolean; bibtex?: boolean },
742742
) {
743743
const logInfo: Record<string, any> = { jatsVersion: version };
744744
if (!input) {

‎packages/jats-fetch/src/biorxiv/data.ts‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,19 @@ export async function getBioRxivS3Metadata(
1717
if (!resp.ok) {
1818
throw new Error(`Bad response from ${BIORXIV_LOOKUP_URL}`);
1919
}
20-
const bioRxivMeta = (await resp.json()) as { versions: { s3Bucket: string; s3Key: string }[] };
21-
if (!bioRxivMeta.versions?.length) {
22-
throw new Error(`Bad response from ${BIORXIV_LOOKUP_URL} - no versions found for ${input}`);
20+
const bioRxivMeta = (await resp.json()) as {
21+
versions?: { s3Bucket: string; s3Key: string }[];
22+
s3Bucket?: string;
23+
s3Key?: string;
24+
};
25+
if (bioRxivMeta.s3Bucket && bioRxivMeta.s3Key) {
26+
return { bucketName: bioRxivMeta.s3Bucket, filePath: bioRxivMeta.s3Key };
2327
}
24-
const { s3Bucket, s3Key } = bioRxivMeta.versions[bioRxivMeta.versions.length - 1];
25-
return { bucketName: s3Bucket, filePath: s3Key };
28+
if (bioRxivMeta.versions?.length) {
29+
const { s3Bucket, s3Key } = bioRxivMeta.versions[bioRxivMeta.versions.length - 1];
30+
return { bucketName: s3Bucket, filePath: s3Key };
31+
}
32+
throw new Error(`Bad response from ${BIORXIV_LOOKUP_URL} - no s3 bucket info found for ${input}`);
2633
}
2734

2835
export async function downloadAndUnzipBioRxiv(

0 commit comments

Comments
 (0)