Skip to content

Commit

Permalink
[#1021]: restructure current files into more coherent modules
Browse files Browse the repository at this point in the history
  • Loading branch information
scottaubrey committed Mar 15, 2024
1 parent 83be3b9 commit ef670ea
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 18 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions src/fetch-and-parse.ts → src/cli/fetch-and-parse.ts
Original file line number Diff line number Diff line change
@@ -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())
Expand Down
6 changes: 3 additions & 3 deletions src/generate.ts → src/cli/generate.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable no-console */
import { writeFileSync } from 'fs';
import { Step } from './docmap';
import { Step } from '../types/docmap';
import {
addNextStep,
generateAction,
Expand All @@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion src/parse.ts → src/cli/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
Url,
VersionOfRecord,
WebPage,
} from './docmap';
} from '../types/docmap';

type Steps = {
'first-step': string,
Expand Down
11 changes: 7 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/docmap-parser.ts → src/parser/docmap-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
ExpressionType,
Item,
Step,
} from './docmap';
} from '../types/docmap';

export enum ReviewType {
EvaluationSummary = 'evaluation-summary',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
generateWebContent,
generateManuscript,
generateInsight,
} from '../docmap-generator';
} from '../generators/docmap-generators';

const publisher = {
id: 'https://elifesciences.org/',
Expand Down
File renamed without changes.

0 comments on commit ef670ea

Please sign in to comment.