@opentermsarchive/engine 0.34.0 → 0.34.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.
- package/README.md +4 -0
- package/package.json +1 -1
- package/src/archivist/extract/index.js +1 -0
- package/src/archivist/fetcher/index.js +1 -0
- package/src/archivist/index.test.js +7 -7
- package/src/archivist/recorder/repositories/git/git.js +2 -1
- package/src/archivist/recorder/repositories/mongo/index.js +2 -0
- package/src/archivist/services/index.test.js +8 -8
package/README.md
CHANGED
|
@@ -6,6 +6,10 @@ For documentation, visit [docs.opentermsarchive.org](https://docs.opentermsarchi
|
|
|
6
6
|
|
|
7
7
|
- - -
|
|
8
8
|
|
|
9
|
+
## Contribute
|
|
10
|
+
|
|
11
|
+
To contribute to the Open Terms Archive Engine, please refer to the [contributing guidelines](CONTRIBUTING.md) before submitting pull requests. Bugs can be reported or features requested by opening an issue.
|
|
12
|
+
|
|
9
13
|
## License
|
|
10
14
|
|
|
11
15
|
The code for this software is distributed under the [European Union Public Licence (EUPL) v1.2](https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12). In short, this [means](https://choosealicense.com/licenses/eupl-1.2/) you are allowed to read, use, modify and redistribute this source code, as long as you as you credit “Open Terms Archive Contributors” and make available any change you make to it under similar conditions.
|
package/package.json
CHANGED
|
@@ -24,6 +24,7 @@ const ciceroMarkTransformer = new CiceroMarkTransformer();
|
|
|
24
24
|
/**
|
|
25
25
|
* Extract content from source document and convert it to Markdown
|
|
26
26
|
*
|
|
27
|
+
* @function extract
|
|
27
28
|
* @param {string} sourceDocument - Source document from which to extract content, see {@link ./src/archivist/services/sourceDocument.js}
|
|
28
29
|
* @returns {Promise<string>} Promise which is fulfilled once the content is extracted and converted in Markdown. The promise will resolve into a string containing the extracted content in Markdown format
|
|
29
30
|
*/
|
|
@@ -9,6 +9,7 @@ export { FetchDocumentError } from './errors.js';
|
|
|
9
9
|
/**
|
|
10
10
|
* Fetch a resource from the network, returning a promise which is fulfilled once the response is available
|
|
11
11
|
*
|
|
12
|
+
* @function fetch
|
|
12
13
|
* @param {Object} params - Fetcher parameters
|
|
13
14
|
* @param {string} params.url - URL of the resource you want to fetch
|
|
14
15
|
* @param {boolean} [params.executeClientScripts] - Enable execution of client scripts. When set to `true`, this property loads the page in a headless browser to load all assets and execute client scripts before returning its content
|
|
@@ -35,7 +35,7 @@ async function resetGitRepositories() {
|
|
|
35
35
|
describe('Archivist', function () {
|
|
36
36
|
this.timeout(10000);
|
|
37
37
|
|
|
38
|
-
const SERVICE_A_ID = '
|
|
38
|
+
const SERVICE_A_ID = 'service·A';
|
|
39
39
|
const SERVICE_A_TYPE = 'Terms of Service';
|
|
40
40
|
const SERVICE_A_EXPECTED_SNAPSHOT_FILE_PATH = `${SNAPSHOTS_PATH}/${SERVICE_A_ID}/${SERVICE_A_TYPE}.html`;
|
|
41
41
|
const SERVICE_A_EXPECTED_VERSION_FILE_PATH = `${VERSIONS_PATH}/${SERVICE_A_ID}/${SERVICE_A_TYPE}.md`;
|
|
@@ -49,7 +49,7 @@ describe('Archivist', function () {
|
|
|
49
49
|
let serviceBSnapshotExpectedContent;
|
|
50
50
|
let serviceBVersionExpectedContent;
|
|
51
51
|
|
|
52
|
-
const services = [ '
|
|
52
|
+
const services = [ 'service·A', 'Service B!' ];
|
|
53
53
|
|
|
54
54
|
before(async () => {
|
|
55
55
|
gitVersion = new Git({
|
|
@@ -61,8 +61,8 @@ describe('Archivist', function () {
|
|
|
61
61
|
});
|
|
62
62
|
await gitVersion.initialize();
|
|
63
63
|
|
|
64
|
-
serviceASnapshotExpectedContent = await fs.readFile(path.resolve(ROOT_PATH, 'test/fixtures/
|
|
65
|
-
serviceAVersionExpectedContent = await fs.readFile(path.resolve(ROOT_PATH, 'test/fixtures/
|
|
64
|
+
serviceASnapshotExpectedContent = await fs.readFile(path.resolve(ROOT_PATH, 'test/fixtures/service·A_terms_snapshot.html'), { encoding: 'utf8' });
|
|
65
|
+
serviceAVersionExpectedContent = await fs.readFile(path.resolve(ROOT_PATH, 'test/fixtures/service·A_terms.md'), { encoding: 'utf8' });
|
|
66
66
|
serviceBSnapshotExpectedContent = await fs.readFile(path.resolve(ROOT_PATH, 'test/fixtures/terms.pdf'));
|
|
67
67
|
serviceBVersionExpectedContent = await fs.readFile(path.resolve(ROOT_PATH, 'test/fixtures/termsFromPDF.md'), { encoding: 'utf8' });
|
|
68
68
|
});
|
|
@@ -166,7 +166,7 @@ describe('Archivist', function () {
|
|
|
166
166
|
|
|
167
167
|
app.services[SERVICE_A_ID].getTerms({ type: SERVICE_A_TYPE }).sourceDocuments[0].contentSelectors = 'h1';
|
|
168
168
|
|
|
169
|
-
await app.track({ services: [ '
|
|
169
|
+
await app.track({ services: [ 'service·A', 'Service B!' ], extractOnly: true });
|
|
170
170
|
|
|
171
171
|
const [reExtractedVersionCommit] = await gitVersion.log({ file: SERVICE_A_EXPECTED_VERSION_FILE_PATH });
|
|
172
172
|
|
|
@@ -282,7 +282,7 @@ describe('Archivist', function () {
|
|
|
282
282
|
let snapshot;
|
|
283
283
|
|
|
284
284
|
before(async () => {
|
|
285
|
-
terms = app.services.
|
|
285
|
+
terms = app.services.service·A.getTerms({ type: SERVICE_A_TYPE });
|
|
286
286
|
terms.fetchDate = FETCH_DATE;
|
|
287
287
|
terms.sourceDocuments.forEach(async sourceDocument => {
|
|
288
288
|
sourceDocument.content = serviceASnapshotExpectedContent;
|
|
@@ -364,7 +364,7 @@ describe('Archivist', function () {
|
|
|
364
364
|
let version;
|
|
365
365
|
|
|
366
366
|
before(async () => {
|
|
367
|
-
terms = app.services.
|
|
367
|
+
terms = app.services.service·A.getTerms({ type: SERVICE_A_TYPE });
|
|
368
368
|
terms.fetchDate = FETCH_DATE;
|
|
369
369
|
terms.sourceDocuments.forEach(async sourceDocument => {
|
|
370
370
|
sourceDocument.content = serviceASnapshotExpectedContent;
|
|
@@ -26,7 +26,8 @@ export default class Git {
|
|
|
26
26
|
.addConfig('core.autocrlf', false)
|
|
27
27
|
.addConfig('push.default', 'current')
|
|
28
28
|
.addConfig('user.name', this.author.name)
|
|
29
|
-
.addConfig('user.email', this.author.email)
|
|
29
|
+
.addConfig('user.email', this.author.email)
|
|
30
|
+
.addConfig('core.quotePath', false); // disable Git's encoding of special characters in pathnames. For example, `service·A` will be encoded as `service\302\267A` without this setting, leading to issues. See https://git-scm.com/docs/git-config#Documentation/git-config.txt-corequotePath
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
async add(filePath) {
|
|
@@ -97,8 +97,8 @@ describe('Services', () => {
|
|
|
97
97
|
result = await services.load();
|
|
98
98
|
});
|
|
99
99
|
|
|
100
|
-
describe('Service
|
|
101
|
-
await validateServiceWithoutHistory('
|
|
100
|
+
describe('Service·A', async () => {
|
|
101
|
+
await validateServiceWithoutHistory('service·A', expectedServices.service·A);
|
|
102
102
|
});
|
|
103
103
|
|
|
104
104
|
describe('Service B', async () => {
|
|
@@ -127,11 +127,11 @@ describe('Services', () => {
|
|
|
127
127
|
|
|
128
128
|
context('when specifying services to load', async () => {
|
|
129
129
|
before(async () => {
|
|
130
|
-
result = await services.load([ '
|
|
130
|
+
result = await services.load([ 'service·A', 'Service B!' ]);
|
|
131
131
|
});
|
|
132
132
|
|
|
133
133
|
it('loads only the given services', async () => {
|
|
134
|
-
expect(result).to.have.all.keys('
|
|
134
|
+
expect(result).to.have.all.keys('service·A', 'Service B!');
|
|
135
135
|
});
|
|
136
136
|
});
|
|
137
137
|
});
|
|
@@ -266,8 +266,8 @@ describe('Services', () => {
|
|
|
266
266
|
result = await services.loadWithHistory();
|
|
267
267
|
});
|
|
268
268
|
|
|
269
|
-
describe('Service
|
|
270
|
-
await validateServiceWithHistory('
|
|
269
|
+
describe('Service·A', async () => {
|
|
270
|
+
await validateServiceWithHistory('service·A', expectedServices.service·A);
|
|
271
271
|
});
|
|
272
272
|
|
|
273
273
|
describe('Service B', async () => {
|
|
@@ -296,11 +296,11 @@ describe('Services', () => {
|
|
|
296
296
|
|
|
297
297
|
context('when specifying services to load', async () => {
|
|
298
298
|
before(async () => {
|
|
299
|
-
result = await services.loadWithHistory([ '
|
|
299
|
+
result = await services.loadWithHistory([ 'service·A', 'Service B!' ]);
|
|
300
300
|
});
|
|
301
301
|
|
|
302
302
|
it('loads only the given services', async () => {
|
|
303
|
-
expect(result).to.have.all.keys('
|
|
303
|
+
expect(result).to.have.all.keys('service·A', 'Service B!');
|
|
304
304
|
});
|
|
305
305
|
});
|
|
306
306
|
});
|