@defra/lis-species-cattle 0.4.0 → 0.5.0-lreg-519.alpha.2

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.
Files changed (2) hide show
  1. package/README.md +161 -14
  2. package/package.json +1 -5
package/README.md CHANGED
@@ -1,30 +1,177 @@
1
- # Cattle species
1
+ # lis-species-cattle
2
2
 
3
- Shared package for the cattle species.
3
+ Part of the Livestock Information Service (LIS), which lets livestock keepers, owners, agents and
4
+ delegates record and manage their animals.
4
5
 
5
- Install dependencies for this package locally with `npm install` from this directory.
6
+ `@defra/lis-species-cattle` is a shared npm package that holds the cattle species definition used by
7
+ the cattle microsites: the species identity and the list of cattle breeds and breed codes.
6
8
 
7
- ### Run Cake Files locally
9
+ It is a species package. The taxonomy packages (`lis-taxonomy-*`, for example home, move and
10
+ register) describe what a journey does. This package says which species it is for. A cattle
11
+ microsite combines the two, for example to build its path from `taxonomy.id` and `species.id`. The
12
+ package does not import any taxonomy package. The sibling [lis-species-sheep](https://github.com/DEFRA/lis-species-sheep)
13
+ package follows the same pattern for sheep.
8
14
 
9
- Cake is the build engine and orchestrates the Node package lifecycle. To run the
10
- default build locally:
15
+ Used by:
16
+
17
+ - spokes: [lis-apps-cattle-home](https://github.com/DEFRA/lis-apps-cattle-home), [lis-apps-cattle-register](https://github.com/DEFRA/lis-apps-cattle-register), [lis-apps-cattle-move](https://github.com/DEFRA/lis-apps-cattle-move), [lis-apps-cattle-death](https://github.com/DEFRA/lis-apps-cattle-death)
18
+ - fake services: [lis-fake-service](https://github.com/DEFRA/lis-fake-service) (breed-code validation and breed names)
19
+
20
+ ## Installation
11
21
 
12
22
  ```bash
13
- dotnet cake ./build.cake --target=Default --package_version=0.1.0
23
+ npm install @defra/lis-species-cattle
24
+ ```
25
+
26
+ The package has no peer dependencies.
27
+
28
+ ## Usage
29
+
30
+ The package has one entry point, `@defra/lis-species-cattle`. It exports four things.
31
+
32
+ ### `species`
33
+
34
+ The species identity: `{ id: 'cattle', label: 'Cattle', summary: '...' }`. Use `species.id` to
35
+ build microsite paths.
36
+
37
+ ```js
38
+ import { species } from '@defra/lis-species-cattle'
39
+
40
+ export const ROOT_PATH = buildMicrositePath(taxonomy.id, species.id)
41
+ ```
42
+
43
+ ### `breeds`
44
+
45
+ The canonical list of cattle breeds, as an object keyed by upper-case breed code. For example
46
+ `breeds.AA` is `'Aberdeen Angus'`. Crossbreeds have their own codes, for example `AAX` is
47
+ `'Aberdeen Angus Cross'`.
48
+
49
+ ```js
50
+ import { breeds } from '@defra/lis-species-cattle'
51
+
52
+ const items = Object.entries(breeds).map(([value, text]) => ({ value, text }))
53
+ ```
54
+
55
+ ### `getBreedName(code)`
56
+
57
+ Returns the breed name for a breed code. The code is case-insensitive. Returns `undefined` for an
58
+ unknown code.
59
+
60
+ ```js
61
+ import { getBreedName } from '@defra/lis-species-cattle'
62
+
63
+ getBreedName('aa') // 'Aberdeen Angus'
64
+ getBreedName('nope') // undefined
65
+ ```
66
+
67
+ ### `getBreedCode(name)`
68
+
69
+ Returns the breed code for a breed name. The name is case-insensitive, and apostrophes (straight,
70
+ curly or missing) are ignored. Returns `undefined` for an unknown name.
71
+
72
+ ```js
73
+ import { getBreedCode } from '@defra/lis-species-cattle'
74
+
75
+ getBreedCode('aberdeen angus') // 'AA'
76
+ getBreedCode("Blonde D'Aquitaine") // 'BA'
77
+ ```
78
+
79
+ ## Prerequisites
80
+
81
+ - Node.js 24 (see `.nvmrc`, use `nvm use`)
82
+ - To check changes against a consuming app: a local clone of [lis-dev](https://github.com/DEFRA/lis-dev) with its one-time setup done
83
+
84
+ ## Setup
85
+
86
+ ### Development
87
+
88
+ ```bash
89
+ nvm use
90
+ npm install
14
91
  ```
15
92
 
16
- ### Test Github action
93
+ ### Test
17
94
 
18
- Install `act` to run the github action locally.
95
+ There are no tools to install beyond `npm install`. Tests use [Vitest](https://vitest.dev/).
19
96
 
20
- To Install act on Linux
97
+ ## Running in development
21
98
 
22
- ```sh
23
- brew install act
99
+ This is a library, so it has no server of its own. To try a change in a consuming app without
100
+ publishing, link the local copy into the lis-dev stack:
101
+
102
+ ```bash
103
+ cd lis-dev
104
+ .bin/sideload link species/cattle # every installed copy now points at this repo
105
+ .bin/sideload up cattle-home # optional: run a consumer locally with hot reload
106
+ .bin/sideload unlink species/cattle # when done
107
+ ```
108
+
109
+ ## Running tests
110
+
111
+ ```bash
112
+ npm test # unit tests
113
+ npm run test:coverage # with coverage
114
+ npm run lint # ESLint
115
+ npm run format:check # Prettier
116
+ ```
117
+
118
+ Before releasing a change, also run the tests of each consuming repo against the linked package.
119
+
120
+ ## Pipelines
121
+
122
+ Build, versioning and publishing run in GitHub Actions (`.github/workflows`) using Cake scripts (`*.cake`):
123
+
124
+ - **Pull request to `main`**: validate (format, lint, test), Sonar analysis, version check
125
+ - **Push to a `feature/` or `hotfix/` branch**: prerelease version and tag
126
+ - **Merge to `main`**: release tag, then publish to [npm](https://www.npmjs.com/package/@defra/lis-species-cattle)
127
+
128
+ Versions come from git tags (SemVer). After a merge, wait for the publish job to finish before bumping the package in consuming repos.
129
+
130
+ ### Running the build locally
131
+
132
+ Cake is the build engine and orchestrates the Node package lifecycle. To run the default build
133
+ (install, audit, format, lint, test and pack) locally:
134
+
135
+ ```bash
136
+ dotnet cake ./build.cake --target=Default --package_version=0.1.0
24
137
  ```
25
138
 
26
- To run github action
139
+ ### Testing the GitHub Actions workflow locally
27
140
 
28
- ```sh
141
+ Install [`act`](https://github.com/nektos/act) (for example `brew install act`), then run:
142
+
143
+ ```bash
29
144
  act -W .github/workflows/prerelease.yml
30
145
  ```
146
+
147
+ ## Branching policy
148
+
149
+ The repo uses mainline development. Branch from `main` and name the branch:
150
+
151
+ - `feature/LREG-<ticket>-<short-kebab-description>`
152
+ - `hotfix/LREG-<ticket>-<short-kebab-description>`
153
+
154
+ `LREG` must be uppercase, because the GitHub ruleset rejects other branch names. Rebase onto `main`
155
+ rather than merging `main` in.
156
+
157
+ ## Contributing to this project
158
+
159
+ - Follow the [Defra software development standards](https://github.com/DEFRA/software-development-standards).
160
+ - `npm install` sets up a pre-commit hook (Husky) that runs the security audit, format check and lint.
161
+ - Open a pull request against `main` using the PR template. CI must pass and the Sonar quality gate must be green before merge.
162
+
163
+ ## Licence
164
+
165
+ THIS INFORMATION IS LICENSED UNDER THE CONDITIONS OF THE OPEN GOVERNMENT LICENCE found at:
166
+
167
+ <http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3>
168
+
169
+ The following attribution statement MUST be cited in your products and applications when using this information.
170
+
171
+ > Contains public sector information licensed under the Open Government licence v3
172
+
173
+ ### About the licence
174
+
175
+ The Open Government Licence (OGL) was developed by the Controller of His Majesty's Stationery Office (HMSO) to enable information providers in the public sector to license the use and re-use of their information under a common open licence.
176
+
177
+ It is designed to encourage use and re-use of information freely and flexibly, with only a few conditions.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defra/lis-species-cattle",
3
- "version": "0.4.0",
3
+ "version": "0.5.0-lreg-519.alpha.2",
4
4
  "description": "Cattle shared package for livestock taxonomy flows.",
5
5
  "main": "src/index.js",
6
6
  "repository": {
@@ -30,10 +30,6 @@
30
30
  },
31
31
  "author": "Defra DDTS",
32
32
  "license": "OGL-UK-3.0",
33
- "dependencies": {
34
- "convict": "6.2.5",
35
- "convict-format-with-validator": "6.2.0"
36
- },
37
33
  "devDependencies": {
38
34
  "@defra/lis-infra-eslint-config": "^0.6.0",
39
35
  "@vitest/coverage-istanbul": "^4.1.10",