@talisdev/bibliographic-resource-parsers-lib 5.23.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,102 @@
1
+ # Bibliographic resource parsers lib
2
+
3
+ Welcome to Bibliographic resource parsers lib! This guide will walk you through setting up the development environment and getting started with contributing to the project.
4
+
5
+ ## Contributing
6
+
7
+ We follow the conventional commits specification for our PR titles. When creating a Pull Request, the title of the PR will be used as the commits will be squashed and merged in the main branch.
8
+
9
+ Therefore, it is mandatory to use conventional commit messages in the title of your PR. To enforce this, we use a GitHub action that validates the PR title conforms to the Conventional Commits conventions.
10
+
11
+ We use this standard to help us correctly version the project and generate changelogs automatically.
12
+
13
+ For more information about conventional commits, you can refer to [Conventional Commits Specification](https://www.conventionalcommits.org/).
14
+
15
+ ## Setting Up the Development Environment
16
+
17
+ ### Prerequisites
18
+
19
+ Before you begin, make sure you have the following installed:
20
+
21
+ - nvm
22
+ - Node.js - version is defined in `.nvmrc` file
23
+ - Git
24
+
25
+ ## Getting Started
26
+
27
+ ```bash
28
+ git clone git@github.com:talis/bibliographic-resource-parsers-lib.git
29
+ cd bibliographic-resource-parsers-lib
30
+ ```
31
+
32
+ You can run the following `nvm` command to install and use the required Node.js version:
33
+
34
+ ```bash
35
+ nvm install && nvm use
36
+ ```
37
+
38
+ ### Install Dependencies
39
+
40
+ ```bash
41
+ npm install
42
+ ```
43
+
44
+ ## Linting & Formatting
45
+
46
+ Code standards and formatting are enforced using [ESLint](https://eslint.org/docs/latest/) and [Prettier](https://prettier.io/docs/en/).
47
+
48
+ You can analyse your code for standards issues using:
49
+
50
+ ```bash
51
+ npm run lint
52
+ ```
53
+
54
+ You can reformat and apply automatic fixes by running:
55
+
56
+ ```bash
57
+ npm run format
58
+ ```
59
+
60
+ ## Build library
61
+
62
+ To build the library run:
63
+
64
+ ```bash
65
+ npm run build
66
+ ```
67
+
68
+ ## Running/Writing Tests
69
+
70
+ To run the tests, you can use the following command:
71
+
72
+ ```bash
73
+ npm test
74
+ ```
75
+
76
+ ### Parser Tests
77
+ Parser tests use HTML fixtures saved from real-world examples. These should be specified in the tests as URLs which will be mapped to fixtures and snapshots.
78
+
79
+ The general format of a parser test is as follows:
80
+
81
+ ```typescript
82
+ const urls = [
83
+ 'https://www.example.com',
84
+ ];
85
+
86
+ test.each(urls)('should parse %s', async url => {
87
+ const fixture = await loadFixture(__dirname, url);
88
+ const resourceData = convertToResourceData(url, fixture);
89
+
90
+ const result = yourParserUnderTest(resourceData);
91
+
92
+ await expect(result).toMatchFileSnapshot(getSnapshotPath(__dirname, url));
93
+ });
94
+ ```
95
+
96
+ If no fixture exists for a real-world example, the test will fail and prompt you to save the fixture using the command `npm run save-fixture {url} {saveDirectory}`. This will save the HTML from the URL to the specified directory. Running the test again will use the saved fixture.
97
+
98
+ The fixture should be run through the parser under test and compared against a snapshot of the expected output. If the snapshot does not exist, it will be created. If it mismatches the output, the test will fail and Vitest will prompt you to update the snapshot.
99
+
100
+
101
+
102
+