diff --git a/package.json b/package.json index 5786e69..d09dd59 100644 --- a/package.json +++ b/package.json @@ -10,9 +10,9 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "scripts": { - "generate": "ts-node src/generate.ts", - "parse": "ts-node src/parse.ts", - "fetch-and-test-data-hub-docmap": "ts-node src/fetch-and-parse.ts", + "generate": "ts-node src/cli/generate.ts", + "parse": "ts-node src/cli/parse.ts", + "fetch-and-test-data-hub-docmap": "ts-node src/cli/fetch-and-parse.ts", "test": "jest", "lint": "eslint --ext .tsx,.ts src/", "prepublish": "tsc" diff --git a/src/fetch-and-parse.ts b/src/cli/fetch-and-parse.ts similarity index 86% rename from src/fetch-and-parse.ts rename to src/cli/fetch-and-parse.ts index b73bf0b..f4d4d97 100644 --- a/src/fetch-and-parse.ts +++ b/src/cli/fetch-and-parse.ts @@ -1,7 +1,7 @@ /* eslint-disable no-console */ import { exit } from 'process'; -import { DocMap } from './docmap'; -import { parsePreprintDocMap } from './docmap-parser'; +import { DocMap } from '../types/docmap'; +import { parsePreprintDocMap } from '../parser/docmap-parser'; fetch('https://data-hub-api--stg.elifesciences.org/enhanced-preprints/docmaps/v1/index') .then((data) => data.json()) diff --git a/src/generate.ts b/src/cli/generate.ts similarity index 98% rename from src/generate.ts rename to src/cli/generate.ts index fcedcbb..71f3d92 100644 --- a/src/generate.ts +++ b/src/cli/generate.ts @@ -1,6 +1,6 @@ /* eslint-disable no-console */ import { writeFileSync } from 'fs'; -import { Step } from './docmap'; +import { Step } from '../types/docmap'; import { addNextStep, generateAction, @@ -25,8 +25,8 @@ import { generateVersionOfRecordAssertion, generateVersionOfRecord, generateRepublishedAssertion, -} from './docmap-generator'; -import { parsePreprintDocMap } from './docmap-parser'; +} from '../generators/docmap-generators'; +import { parsePreprintDocMap } from '../parser/docmap-parser'; // used for outputting JSON const replacer = (key: string, value: any) => { diff --git a/src/parse.ts b/src/cli/parse.ts similarity index 89% rename from src/parse.ts rename to src/cli/parse.ts index 569b60e..fdab08f 100644 --- a/src/parse.ts +++ b/src/cli/parse.ts @@ -2,7 +2,7 @@ import { R_OK } from 'constants'; import { accessSync, readFileSync } from 'fs'; import { argv, exit } from 'process'; -import { parsePreprintDocMap } from './docmap-parser'; +import { parsePreprintDocMap } from '../parser/docmap-parser'; if (argv[2] === undefined) { console.log('Please provide a filename'); diff --git a/src/docmap-generator.ts b/src/generators/docmap-generators.ts similarity index 99% rename from src/docmap-generator.ts rename to src/generators/docmap-generators.ts index af5c32f..9db0e50 100644 --- a/src/docmap-generator.ts +++ b/src/generators/docmap-generators.ts @@ -29,7 +29,7 @@ import { Url, VersionOfRecord, WebPage, -} from './docmap'; +} from '../types/docmap'; type Steps = { 'first-step': string, diff --git a/src/index.ts b/src/index.ts index 94d0659..4bb53bb 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,9 +1,12 @@ -export * from './docmap'; -export * as parser from './docmap-parser'; -export * from './docmap-generator'; +// export types useful to use this as a library +export * from './types/docmap'; export { VersionedReviewedPreprint, ManuscriptData, ReviewType, Evaluation, -} from './docmap-parser'; +} from './parser/docmap-parser'; + +// export parser and generators +export * as parser from './parser/docmap-parser'; +export * as generators from './generators/docmap-generators'; diff --git a/src/docmap-parser.test.ts b/src/parser/docmap-parser.test.ts similarity index 99% rename from src/docmap-parser.test.ts rename to src/parser/docmap-parser.test.ts index 272db95..034fd31 100644 --- a/src/docmap-parser.test.ts +++ b/src/parser/docmap-parser.test.ts @@ -1,11 +1,11 @@ -import { DocMap } from './docmap'; +import { DocMap } from '../types/docmap'; import { parsePreprintDocMap, ManuscriptData, ReviewType, VersionedReviewedPreprint, } from './docmap-parser'; -import { fixtures } from './test-fixtures/docmapGenerators'; +import { fixtures } from '../test-fixtures/docmap-parser'; const parseDocMap = (docmap: DocMap | string): ManuscriptData => { const parsedDocMap = parsePreprintDocMap(docmap); diff --git a/src/docmap-parser.ts b/src/parser/docmap-parser.ts similarity index 99% rename from src/docmap-parser.ts rename to src/parser/docmap-parser.ts index bbe8456..d74906d 100644 --- a/src/docmap-parser.ts +++ b/src/parser/docmap-parser.ts @@ -6,7 +6,7 @@ import { ExpressionType, Item, Step, -} from './docmap'; +} from '../types/docmap'; export enum ReviewType { EvaluationSummary = 'evaluation-summary', diff --git a/src/test-fixtures/docmapGenerators.ts b/src/test-fixtures/docmap-parser.ts similarity index 99% rename from src/test-fixtures/docmapGenerators.ts rename to src/test-fixtures/docmap-parser.ts index 0c246de..a26e972 100644 --- a/src/test-fixtures/docmapGenerators.ts +++ b/src/test-fixtures/docmap-parser.ts @@ -20,7 +20,7 @@ import { generateWebContent, generateManuscript, generateInsight, -} from '../docmap-generator'; +} from '../generators/docmap-generators'; const publisher = { id: 'https://elifesciences.org/', diff --git a/src/docmap.ts b/src/types/docmap.ts similarity index 100% rename from src/docmap.ts rename to src/types/docmap.ts