@opentermsarchive/engine 0.15.0 → 0.17.0

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 (64) hide show
  1. package/package.json +7 -1
  2. package/src/tracker/index.js +1 -1
  3. package/.env.example +0 -3
  4. package/.eslintrc.yaml +0 -116
  5. package/.github/workflows/deploy.yml +0 -50
  6. package/.github/workflows/release.yml +0 -64
  7. package/.github/workflows/test.yml +0 -77
  8. package/CHANGELOG.md +0 -14
  9. package/CODE_OF_CONDUCT.md +0 -128
  10. package/CONTRIBUTING.md +0 -143
  11. package/MIGRATING.md +0 -42
  12. package/Vagrantfile +0 -38
  13. package/ansible.cfg +0 -13
  14. package/decision-records/0001-service-name-and-id.md +0 -73
  15. package/decision-records/0002-service-history.md +0 -212
  16. package/decision-records/0003-snapshots-database.md +0 -123
  17. package/ops/README.md +0 -280
  18. package/ops/app.yml +0 -5
  19. package/ops/infra.yml +0 -6
  20. package/ops/inventories/dev.yml +0 -7
  21. package/ops/inventories/production.yml +0 -27
  22. package/ops/roles/infra/defaults/main.yml +0 -2
  23. package/ops/roles/infra/files/.gitconfig +0 -3
  24. package/ops/roles/infra/files/mongod.conf +0 -18
  25. package/ops/roles/infra/files/ota-bot-key.private_key +0 -26
  26. package/ops/roles/infra/tasks/main.yml +0 -78
  27. package/ops/roles/infra/tasks/mongo.yml +0 -40
  28. package/ops/roles/infra/templates/ssh_config.j2 +0 -5
  29. package/ops/roles/ota/defaults/main.yml +0 -14
  30. package/ops/roles/ota/files/.env +0 -21
  31. package/ops/roles/ota/tasks/database.yml +0 -65
  32. package/ops/roles/ota/tasks/main.yml +0 -110
  33. package/ops/site.yml +0 -6
  34. package/pm2.config.cjs +0 -20
  35. package/test/fixtures/service_A.js +0 -22
  36. package/test/fixtures/service_A_terms.md +0 -10
  37. package/test/fixtures/service_A_terms_snapshot.html +0 -14
  38. package/test/fixtures/service_B.js +0 -22
  39. package/test/fixtures/service_with_declaration_history.js +0 -65
  40. package/test/fixtures/service_with_filters_history.js +0 -155
  41. package/test/fixtures/service_with_history.js +0 -188
  42. package/test/fixtures/service_with_multipage_document.js +0 -100
  43. package/test/fixtures/service_without_history.js +0 -31
  44. package/test/fixtures/services.js +0 -19
  45. package/test/fixtures/terms.pdf +0 -0
  46. package/test/fixtures/termsFromPDF.md +0 -25
  47. package/test/fixtures/termsModified.pdf +0 -0
  48. package/test/services/service_A.json +0 -9
  49. package/test/services/service_B.json +0 -9
  50. package/test/services/service_with_declaration_history.filters.js +0 -7
  51. package/test/services/service_with_declaration_history.history.json +0 -17
  52. package/test/services/service_with_declaration_history.json +0 -13
  53. package/test/services/service_with_filters_history.filters.history.js +0 -29
  54. package/test/services/service_with_filters_history.filters.js +0 -7
  55. package/test/services/service_with_filters_history.json +0 -13
  56. package/test/services/service_with_history.filters.history.js +0 -29
  57. package/test/services/service_with_history.filters.js +0 -7
  58. package/test/services/service_with_history.history.json +0 -26
  59. package/test/services/service_with_history.json +0 -17
  60. package/test/services/service_with_multipage_document.filters.js +0 -7
  61. package/test/services/service_with_multipage_document.history.json +0 -37
  62. package/test/services/service_with_multipage_document.json +0 -28
  63. package/test/services/service_without_history.filters.js +0 -7
  64. package/test/services/service_without_history.json +0 -13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentermsarchive/engine",
3
- "version": "0.15.0",
3
+ "version": "0.17.0",
4
4
  "description": "Tracks and makes visible changes to the terms of online services",
5
5
  "homepage": "https://github.com/ambanum/OpenTermsArchive#readme",
6
6
  "bugs": {
@@ -40,6 +40,12 @@
40
40
  "posttest": "npm run lint",
41
41
  "test:debug": "npm run test -- --inspect-brk --exit"
42
42
  },
43
+ "files": [
44
+ "bin",
45
+ "config",
46
+ "scripts",
47
+ "src"
48
+ ],
43
49
  "dependencies": {
44
50
  "@accordproject/markdown-cicero": "^0.15.2",
45
51
  "@accordproject/markdown-pdf": "^0.15.2",
@@ -197,7 +197,7 @@ export default class Tracker {
197
197
  const body = `
198
198
  This document is no longer properly tracked.
199
199
 
200
- \`${message}\`
200
+ ${message}
201
201
 
202
202
  Check what's wrong by:
203
203
  - Using the [online contribution tool](${CONTRIBUTE_URL}?${urlQueryParams}).
package/.env.example DELETED
@@ -1,3 +0,0 @@
1
- SENDINBLUE_API_KEY='xkeysib-3f51c…'
2
- SMTP_PASSWORD='password'
3
- GITHUB_TOKEN=ghp_XXXXXXXXX
package/.eslintrc.yaml DELETED
@@ -1,116 +0,0 @@
1
- extends:
2
- - airbnb-base
3
- parserOptions:
4
- ecmaVersion: 2022
5
- env:
6
- node: true
7
- mocha: true
8
- es6: true
9
- plugins:
10
- - chai-friendly
11
- - import
12
- - json-format
13
- rules:
14
- arrow-parens:
15
- - error
16
- - as-needed
17
- array-bracket-spacing:
18
- - error
19
- - always
20
- - objectsInArrays: false
21
- arraysInArrays: false
22
- singleValue: false
23
- eqeqeq: 0
24
- chai-friendly/no-unused-expressions: 2
25
- comma-dangle:
26
- - error
27
- - always-multiline
28
- consistent-return: 0
29
- function-paren-newline:
30
- - error
31
- - multiline
32
- implicit-arrow-linebreak:
33
- - 'off'
34
- import/extensions:
35
- - error
36
- - always
37
- - ignorePackages: true
38
- import/prefer-default-export: 0
39
- import/order:
40
- - error
41
- - newlines-between: always
42
- alphabetize:
43
- order: asc
44
- caseInsensitive: true
45
- import/namespace:
46
- - error
47
- - allowComputed: true
48
- indent:
49
- - error
50
- - 2
51
- max-len: 0
52
- object-curly-newline:
53
- - error
54
- - multiline: true
55
- no-console: 0
56
- no-continue: 0
57
- no-param-reassign: 0
58
- no-plusplus: 0
59
- no-restricted-syntax: 0
60
- no-shadow: 0
61
- no-tabs: 0
62
- no-underscore-dangle: 0
63
- no-unused-expressions: 0
64
- no-unused-vars:
65
- - error
66
- - argsIgnorePattern: next
67
- no-use-before-define: 0
68
- padding-line-between-statements:
69
- - error
70
- - blankLine: always
71
- prev: '*'
72
- next: return
73
- - blankLine: always
74
- prev:
75
- - const
76
- - let
77
- - var
78
- next: '*'
79
- - blankLine: any
80
- prev:
81
- - const
82
- - let
83
- - var
84
- next:
85
- - const
86
- - let
87
- - var
88
- multiline-comment-style:
89
- - error
90
- - separate-lines
91
- eol-last:
92
- - error
93
- - always
94
- new-cap:
95
- - error
96
- - properties: false
97
-
98
- overrides:
99
- - files:
100
- - src/**/*test.js
101
- - scripts/declarations/validate/*.js
102
- rules:
103
- func-names: 0
104
- - files:
105
- - scripts/**/*.js
106
- - bin/**/*.js
107
- rules:
108
- func-names: 0
109
- import/no-extraneous-dependencies: 0
110
- - files:
111
- - src/**/*[iI]nterface.js
112
- rules:
113
- no-unused-vars: 0
114
- require-yield: 0
115
- class-methods-use-this: 0
116
- no-empty-function: 0
@@ -1,50 +0,0 @@
1
- name: Deploy
2
-
3
- on:
4
- push:
5
- branches: [ main ]
6
-
7
- jobs:
8
- test:
9
- uses: "ambanum/OpenTermsArchive/.github/workflows/test.yml@main"
10
-
11
- get_instances:
12
- runs-on: ubuntu-latest
13
- outputs:
14
- names: ${{ steps.get_production_instances_names.outputs.result }}
15
- steps:
16
- - uses: actions/checkout@v2
17
- - name: Get production instance names
18
- id: get_production_instances_names
19
- uses: mikefarah/yq@master
20
- with:
21
- cmd: yq 'with_entries(select(.key | test("all") | not)) | keys' ops/inventories/production.yml --output-format=json # list all group names except `all`
22
-
23
- deploy:
24
- needs: [ test, get_instances ]
25
- runs-on: ubuntu-latest
26
- strategy:
27
- fail-fast: false # deploy other instances even if one fails to deploy
28
- matrix:
29
- instance: ${{ fromJSON(needs.get_instances.outputs.names) }}
30
- steps:
31
- - uses: actions/checkout@v2
32
- - name: Get target server hostname
33
- id: get_hostname
34
- uses: mikefarah/yq@master
35
- with:
36
- cmd: yq ".${{ matrix.instance }}.hosts.* | key" ops/inventories/production.yml
37
- - name: Get target server fingerprint
38
- id: get_fingerprint
39
- uses: mikefarah/yq@master
40
- with:
41
- cmd: yq '.${{ matrix.instance }}.hosts.["${{ steps.get_hostname.outputs.result }}"].ed25519_fingerprint' ops/inventories/production.yml
42
- - name: Set up SSH
43
- uses: shimataro/ssh-key-action@v2
44
- with:
45
- key: ${{ secrets.SERVER_SSH_KEY }}
46
- known_hosts: ${{ steps.get_hostname.outputs.result }} ssh-ed25519 ${{ steps.get_fingerprint.outputs.result }}
47
- - run: echo "${{ secrets.ANSIBLE_VAULT_KEY }}" > vault.key
48
- - run: pip install --upgrade setuptools
49
- - run: pip install 'ansible ~= 2.9'
50
- - run: ansible-playbook ops/site.yml --inventory ops/inventories/production.yml --limit ${{ matrix.instance }}
@@ -1,64 +0,0 @@
1
- name: Release
2
-
3
- on:
4
- push:
5
- branches: [ packaging ]
6
-
7
- jobs:
8
- test:
9
- uses: "ambanum/OpenTermsArchive/.github/workflows/test.yml@packaging"
10
- release:
11
- needs: [ test ]
12
- runs-on: ubuntu-latest
13
- steps:
14
- - name: Checkout
15
- uses: actions/checkout@v2
16
- with:
17
- token: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }}
18
-
19
- - name: Configure Git author
20
- run: |
21
- git config --global user.name "Open Terms Archive Release Bot"
22
- git config --global user.email "release-bot@opentermsarchive.org"
23
-
24
- - name: Bump package version
25
- run: |
26
- echo "Release type obtained from the previous job: '${{ needs.test.outputs.release_type }}'"
27
- echo "NEW_VERSION=$(npm --no-git-tag-version version ${{ needs.test.outputs.release_type }})" >> $GITHUB_ENV
28
-
29
- - name: Update changelog unreleased section with new version
30
- uses: superfaceai/release-changelog-action@v2
31
- with:
32
- version: ${{ env.NEW_VERSION }}
33
- operation: release
34
-
35
- - name: Commit CHANGELOG.md and package.json changes and create tag
36
- run: |
37
- git add "package.json"
38
- git add "package-lock.json"
39
- git add "CHANGELOG.md"
40
- git commit -m "Release ${{ env.NEW_VERSION }}"
41
- git tag ${{ env.NEW_VERSION }}
42
-
43
- - name: Read version changelog
44
- uses: superfaceai/release-changelog-action@v2
45
- id: get-changelog
46
- with:
47
- version: ${{ env.NEW_VERSION }}
48
- operation: read
49
-
50
- - name: Push changes to repository
51
- run: git push origin && git push --tags
52
-
53
- - name: Create GitHub release
54
- uses: softprops/action-gh-release@v1
55
- with:
56
- tag_name: ${{ env.NEW_VERSION }}
57
- body: ${{ steps.get-changelog.outputs.changelog }}
58
- token: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }}
59
-
60
- - name: Publish version to NPM public repository
61
- uses: JS-DevTools/npm-publish@v1
62
- with:
63
- token: ${{ secrets.NPMJS_ACCESS_TOKEN }}
64
- dryRun: true
@@ -1,77 +0,0 @@
1
- name: Test
2
-
3
- on:
4
- push:
5
- branches-ignore:
6
- - main # tests will be launched by workflow_call from the deploy workflow
7
- pull_request:
8
- types: [ opened, reopened ]
9
- workflow_call:
10
- outputs:
11
- release_type:
12
- description: "The release type extracted from changelog"
13
- value: ${{ jobs.check_changelog.outputs.release_type }}
14
-
15
- jobs:
16
- check_changelog:
17
- runs-on: [ubuntu-latest]
18
- outputs:
19
- release_type: ${{ steps.set_release_type_output.outputs.release_type }}
20
- steps:
21
- - uses: actions/checkout@v2
22
- - name: Get release type in changelog
23
- run: echo "RELEASE_TYPE=$(cat CHANGELOG.md | grep -E '^## Unreleased \[(patch|minor|major)\]$' | grep -E -w -o "patch|minor|major" | tr -d '\n')" >> $GITHUB_ENV
24
- - name: Make release type available to subsequent jobs
25
- if: env.RELEASE_TYPE
26
- id: set_release_type_output
27
- run: |
28
- echo "Found release type '${{ env.RELEASE_TYPE }}'"
29
- echo "release_type=${{ env.RELEASE_TYPE }}" >> $GITHUB_OUTPUT
30
- - name: Fail and display error if no proper release type is found in changelog
31
- if: env.RELEASE_TYPE == ''
32
- run: echo "No valid release type found in changelog. The title of the 'Unreleased' section must contain one of the following tags '[patch]', '[minor]', '[major]'. For example, '## Unreleased [minor]'."; exit 1
33
-
34
-
35
- test:
36
- strategy:
37
- matrix:
38
- operating_system: [ ubuntu-latest, windows-latest, macos-latest ]
39
- fail-fast: false # run tests on other operating systems even if one fails
40
-
41
- runs-on: ${{ matrix.operating_system }}
42
-
43
- steps:
44
- - run: |
45
- git config --global core.autocrlf false
46
- - uses: actions/checkout@v2
47
- - uses: ankane/setup-mongodb@ce30d9041565cb469945895d5bde3384a254dd2e # use commit ID until action is versioned, see https://github.com/ankane/setup-mongodb/issues/2
48
- with:
49
- mongodb-version: 5.0
50
- - uses: actions/setup-node@v2
51
- with:
52
- node-version: 16
53
- - run: npm ci
54
- - run: npm test
55
-
56
- validate_declarations:
57
- strategy:
58
- matrix:
59
- operating_system: [ ubuntu-latest, windows-latest, macos-latest ]
60
- fail-fast: false # run tests on other operating systems even if one fails
61
-
62
- runs-on: ${{ matrix.operating_system }}
63
-
64
- steps:
65
- - run: |
66
- git config --global core.autocrlf false
67
- - uses: actions/checkout@v2
68
- - uses: actions/checkout@v2
69
- with:
70
- repository: OpenTermsArchive/contrib-declarations
71
- path: ./contrib-declarations
72
- - uses: actions/setup-node@v2
73
- with:
74
- node-version: 16.x
75
- - run: cd ./contrib-declarations && npm install
76
- - run: npm ci
77
- - run: ./node_modules/.bin/cross-env NODE_ENV=ci npm run declarations:validate:schema
package/CHANGELOG.md DELETED
@@ -1,14 +0,0 @@
1
- # Changelog
2
-
3
- All notable changes to this project will be documented in this file.
4
-
5
- This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) and the format is based on [Common Changelog](https://common-changelog.org).\
6
- Unlike Common Changelog, the `unreleased` section of [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) is preserved with the addition of a tag to specify which type of release should be published and to foster discussions about it inside pull requests. This tag should be one of the names mandated by SemVer, within brackets: `[patch]`, `[minor]` or `[major]`. For example: `## Unreleased [minor]`.
7
-
8
- ## Unreleased [minor]
9
-
10
- ### Added
11
-
12
- - Publish package on NPM under name `opentermsarchive`.
13
- - Export `filter`, `pageDeclaration` and `fetch` in NPM module.
14
- - Add changelog.
@@ -1,128 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- We as members, contributors, and leaders pledge to make participation in our
6
- community a harassment-free experience for everyone, regardless of age, body
7
- size, visible or invisible disability, ethnicity, sex characteristics, gender
8
- identity and expression, level of experience, education, socio-economic status,
9
- nationality, personal appearance, race, religion, or sexual identity
10
- and orientation.
11
-
12
- We pledge to act and interact in ways that contribute to an open, welcoming,
13
- diverse, inclusive, and healthy community.
14
-
15
- ## Our Standards
16
-
17
- Examples of behavior that contributes to a positive environment for our
18
- community include:
19
-
20
- * Demonstrating empathy and kindness toward other people
21
- * Being respectful of differing opinions, viewpoints, and experiences
22
- * Giving and gracefully accepting constructive feedback
23
- * Accepting responsibility and apologizing to those affected by our mistakes,
24
- and learning from the experience
25
- * Focusing on what is best not just for us as individuals, but for the
26
- overall community
27
-
28
- Examples of unacceptable behavior include:
29
-
30
- * The use of sexualized language or imagery, and sexual attention or
31
- advances of any kind
32
- * Trolling, insulting or derogatory comments, and personal or political attacks
33
- * Public or private harassment
34
- * Publishing others' private information, such as a physical or email
35
- address, without their explicit permission
36
- * Other conduct which could reasonably be considered inappropriate in a
37
- professional setting
38
-
39
- ## Enforcement Responsibilities
40
-
41
- Community leaders are responsible for clarifying and enforcing our standards of
42
- acceptable behavior and will take appropriate and fair corrective action in
43
- response to any behavior that they deem inappropriate, threatening, offensive,
44
- or harmful.
45
-
46
- Community leaders have the right and responsibility to remove, edit, or reject
47
- comments, commits, code, wiki edits, issues, and other contributions that are
48
- not aligned to this Code of Conduct, and will communicate reasons for moderation
49
- decisions when appropriate.
50
-
51
- ## Scope
52
-
53
- This Code of Conduct applies within all community spaces, and also applies when
54
- an individual is officially representing the community in public spaces.
55
- Examples of representing our community include using an official e-mail address,
56
- posting via an official social media account, or acting as an appointed
57
- representative at an online or offline event.
58
-
59
- ## Enforcement
60
-
61
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
- reported to the community leaders responsible for enforcement at
63
- moderators@opentermsarchive.org.
64
- All complaints will be reviewed and investigated promptly and fairly.
65
-
66
- All community leaders are obligated to respect the privacy and security of the
67
- reporter of any incident.
68
-
69
- ## Enforcement Guidelines
70
-
71
- Community leaders will follow these Community Impact Guidelines in determining
72
- the consequences for any action they deem in violation of this Code of Conduct:
73
-
74
- ### 1. Correction
75
-
76
- **Community Impact**: Use of inappropriate language or other behavior deemed
77
- unprofessional or unwelcome in the community.
78
-
79
- **Consequence**: A private, written warning from community leaders, providing
80
- clarity around the nature of the violation and an explanation of why the
81
- behavior was inappropriate. A public apology may be requested.
82
-
83
- ### 2. Warning
84
-
85
- **Community Impact**: A violation through a single incident or series
86
- of actions.
87
-
88
- **Consequence**: A warning with consequences for continued behavior. No
89
- interaction with the people involved, including unsolicited interaction with
90
- those enforcing the Code of Conduct, for a specified period of time. This
91
- includes avoiding interactions in community spaces as well as external channels
92
- like social media. Violating these terms may lead to a temporary or
93
- permanent ban.
94
-
95
- ### 3. Temporary Ban
96
-
97
- **Community Impact**: A serious violation of community standards, including
98
- sustained inappropriate behavior.
99
-
100
- **Consequence**: A temporary ban from any sort of interaction or public
101
- communication with the community for a specified period of time. No public or
102
- private interaction with the people involved, including unsolicited interaction
103
- with those enforcing the Code of Conduct, is allowed during this period.
104
- Violating these terms may lead to a permanent ban.
105
-
106
- ### 4. Permanent Ban
107
-
108
- **Community Impact**: Demonstrating a pattern of violation of community
109
- standards, including sustained inappropriate behavior, harassment of an
110
- individual, or aggression toward or disparagement of classes of individuals.
111
-
112
- **Consequence**: A permanent ban from any sort of public interaction within
113
- the community.
114
-
115
- ## Attribution
116
-
117
- This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
- version 2.0, available at
119
- https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120
-
121
- Community Impact Guidelines were inspired by [Mozilla's code of conduct
122
- enforcement ladder](https://github.com/mozilla/diversity).
123
-
124
- [homepage]: https://www.contributor-covenant.org
125
-
126
- For answers to common questions about this code of conduct, see the FAQ at
127
- https://www.contributor-covenant.org/faq. Translations are available at
128
- https://www.contributor-covenant.org/translations.
package/CONTRIBUTING.md DELETED
@@ -1,143 +0,0 @@
1
- First of all, thanks for taking the time to contribute! 🎉👍
2
-
3
- ## Table of Contents
4
-
5
- - [Workflow](#workflow)
6
- - [Pull requests](#pull-requests)
7
- - [Commit messages](#commit-messages)
8
- - [Continuous delivery](#continuous-delivery)
9
- - [Changelog](#changelog)
10
- - [Development](#development)
11
- - [Documentation](#documentation)
12
- - [Naming](#naming)
13
- - [Instances and repositories](#instances-and-repositories)
14
- - [Namespaces](#namespaces)
15
- - [Practices](#practices)
16
- - [Errors handling](#errors-handling)
17
-
18
- ---
19
-
20
- ## Workflow
21
-
22
- ### Pull requests
23
-
24
- We follow the [GitHub Flow](https://guides.github.com/introduction/flow/): all code contributions are submitted via a pull request towards the `main` branch.
25
-
26
- Opening a pull request means you want that code to be merged. If you want to only discuss it, send a link to your branch along with your questions through whichever communication channel you prefer.
27
-
28
- #### Peer reviews
29
-
30
- All pull requests must be reviewed by at least one person who is not their original author.
31
-
32
- To help reviewers, make sure to describe your pull request with a **clear text explanation** of your changes.
33
-
34
- ### Continuous delivery
35
-
36
- GitHub Actions is used to deploy the application on every merge to the main branch.
37
-
38
- Branch protection is active, meaning that a merge to the main branch can only take place once all tests pass in CI, and that the peer review policy has been fulfilled.
39
-
40
- ### Commit messages
41
-
42
- We strive to follow this [recommendation](https://chris.beams.io/posts/git-commit) to write our commit messages, which contains the following rules:
43
-
44
- - [Separate subject from body with a blank line](https://chris.beams.io/posts/git-commit/#separate).
45
- - [Limit the subject line to 50 characters](https://chris.beams.io/posts/git-commit/#limit-50).
46
- - [Capitalize the subject line](https://chris.beams.io/posts/git-commit/#capitalize).
47
- - [Do not end the subject line with a period](https://chris.beams.io/posts/git-commit/#end).
48
- - [Use the imperative mood in the subject line](https://chris.beams.io/posts/git-commit/#imperative).
49
- - [Wrap the body at 72 characters](https://chris.beams.io/posts/git-commit/#wrap-72).
50
- - [Use the body to explain what and why vs. how](https://chris.beams.io/posts/git-commit/#why-not-how).
51
-
52
- We add this additional rule:
53
-
54
- - Do not rely on GitHub issue reference numbers in commit messages, as we have no guarantee the host system and its autolinking will be stable in time. Make sure the context is self-explanatory. If an external reference is given, use its full URL.
55
-
56
- ### Changelog
57
-
58
- All changes to the codebase that impact users must be documented in the [`CHANGELOG.md`](./CHANGELOG.md) file. The format to use is documented in the file itself.
59
-
60
- ## Development
61
-
62
- ### Documentation
63
-
64
- #### CLI
65
-
66
- ##### docopt
67
-
68
- For command-line examples and documentation, we follow the [docopt usage patterns](http://docopt.org) syntax. Quick recap of the main points:
69
-
70
- - mandatory arguments are given between `<` and `>`;
71
- - optional elements are given between `[` and `]`;
72
- - mutually exclusive elements are given between `(` and `)` and separated by `|`.
73
-
74
- ```diff
75
- - npm start [ $service_id ] [, $service_id, ...]
76
- + npm start [service_id]...
77
- ```
78
-
79
- ##### Long options
80
-
81
- In order to improve the understandability of commands, we document all CLI options and examples with the long version of the options.
82
-
83
-
84
- ```diff
85
- - ansible-playbook -i production.yml app.yml -l france -t stop
86
- + ansible-playbook --inventory production.yml app.yml --limit france --tag stop
87
- ```
88
-
89
- ## Naming
90
-
91
- ### Instances and repositories
92
-
93
- An “instance” of Open Terms Archive is comprised of a server running Open Terms Archive and up to three repositories. An instance has a _name_ describing the scope of services it aims at tracking. This scope is defined by one or several dimensions: jurisdiction, language, industry…
94
-
95
- > For example, the `france` instance tracks documents in the French jurisdiction and French language, while the `dating` instance tracks services from the dating industry.
96
-
97
- The instance name is written in lowercase and is made of one word for each dimension it focuses on, separated by dashes.
98
-
99
- > For example, the `france-elections` instance tracks services in the French jurisdiction and French language that could impact the French electoral processes.
100
-
101
- This name is used consistently in all communication, written references, and in the inventory of instances that are managed automatically. It is also used as the base for naming the database repositories, by suffixing it with each type:
102
-
103
- - The repository containing the declarations of services to be tracked is named `$instance_name-declarations`. You can [create it from a template](https://github.com/OpenTermsArchive/template-declarations/generate).
104
- - The repository containing the snapshots of the tracked documents (unless the instance is storing them in an alternative database) is named `$instance_name-snapshots`. You can [create it from a template](https://github.com/OpenTermsArchive/template-snapshots/generate).
105
- - The repository containing the versions of the tracked documents (unless the instance is storing them in an alternative database) is named `$instance_name-versions`. You can [create it from a template](https://github.com/OpenTermsArchive/template-versions/generate).
106
-
107
- ### Namespaces
108
-
109
- We deploy identifiers for packages and namespaces across different universes: package managers, social networks, URLs… In order to unify these names across constraints, we reserve everywhere the name `opentermsarchive`, with no space, no dash, no underscore, no capital.
110
-
111
- > For example, NPM does not allow uppercase and spaces; Ansible does not allow dashes and spaces; Twitter does not allow spaces. The name `ota` is too unlikely to be available everywhere.
112
-
113
- ## Practices
114
-
115
- ### Errors handling
116
-
117
- First of all it's important to distinguish two fundamentally different kinds of errors: **operational** and **programmer** errors.
118
-
119
- - **Operational errors represent run-time problems experienced by correctly-written programs**. These are not bugs in the program. These are usually problems with something else: the system itself (e.g. out of memory), the system’s configuration (e.g. no route to a remote host), the network (e.g. socket hang-up), or a remote service (e.g. a 500 error).
120
-
121
- - **Programmer errors are bugs in the program**. These are things that can always be avoided by changing the code. They can never be handled properly, since by definition the code in question is broken (e.g. tried to read property of `undefined`, or forget to `await` an asynchronous function).
122
-
123
- So the very important distinction is that operational errors are part of the **normal operation of a program** whereas programmer errors are **bugs**.
124
-
125
- Also noteworthy, failure to handle an operational error is itself a programmer error.
126
-
127
- #### Handling operational errors
128
-
129
- There are five ways to handle operational errors:
130
- - **Deal with the failure directly**. For example, create directory if it's missing.
131
- - **Propagate the failure**. If you don’t know how to deal with the error, the simplest thing to do is to abort whatever operation you’re trying to do, clean up whatever you’ve started, and propagate the error.
132
- - **Retry the operation**. For example, try to reconnect if the connection is lost.
133
- - **Log the error — and do nothing else**. If it's a minor error and there’s nothing you can do about, and there is no reason to stop the whole process.
134
- - **Crash immediately**. If the error cannot be handled and can affect data integrity.
135
-
136
- In our case, we consider all `fetch`-related errors as expected, so as operational errors and we handle them by logging but we do not stop the whole process. We handle errors related to the `notifier` in the same way.
137
- In contrast, we consider errors from the `recorder` module as fatal, and we crash immediately.
138
-
139
- #### Handling programmer errors
140
-
141
- **The best way to handle programmer errors is to crash immediately.** Indeed, it is not recommended to attempt to recover from programmer errors — that is, allow the current operation to fail, but keep handling requests. Consider that a programmer error is a case that you didn’t think about when you wrote the original code. How can you be sure that the problem won’t affect the program itself and the data integrity?
142
-
143
- This section is highly inspired, and in part extracted, from [this error handling guide](https://console.joyent.com/node-js/production/design/errors).
package/MIGRATING.md DELETED
@@ -1,42 +0,0 @@
1
- ## 2022-03-29 Unify repository names
2
-
3
- All services declarations, snapshots and versions repo has been renamed and moved to the [OpenTermArchive organization](https://github.com/OpenTermsArchive) on github.
4
-
5
- Documentation on the new naming system can be found [here](https://github.com/ambanum/OpenTermsArchive/blob/main/CONTRIBUTING.md#instances-and-repositories-names)
6
-
7
- If you already have some of those projects locally, you can run
8
-
9
- ```
10
- mv services-all contrib-declarations
11
- mv services-dating dating-declarations
12
- mv declarations-france-elections france-elections-declarations
13
- mv declarations-france france-elections
14
- mv declarations-france-elections-experiment france-elections-experiment-declarations
15
- ```
16
-
17
- ## 2021-11-25 Externalize services declarations
18
-
19
- Services declarations are now declared in their [own repository](https://github.com/OpenTermsArchive/services-all).
20
-
21
- In order to use all the defined services locally, you now have to clone that new repository in the parent folder of the OpenTermsArchive one:
22
-
23
- ```
24
- # From your local clone of the OpenTermsArchive repository
25
- cd ..
26
- git clone git@github.com:OpenTermsArchive/contrib-declarations.git
27
- ```
28
-
29
- ## 2021-02-24 Name change
30
-
31
- `CGUs` is now called `OpenTermsArchive`.
32
-
33
- To reflect this change, if you already have this project locally, execute:
34
-
35
- ```
36
- # From your local clone of the OpenTermsArchive repository
37
- cd ..
38
- mv CGUs OpenTermsArchive
39
- cd OpenTermsArchive
40
- git remote set-url origin https://github.com/ambanum/OpenTermsArchive.git
41
- ```
42
-