@opentermsarchive/engine 0.18.2 → 0.19.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.
- package/README.md +12 -12
- package/bin/env.js +11 -0
- package/bin/{lint-declarations.js → ota-lint.js} +4 -11
- package/bin/ota-track.js +21 -0
- package/bin/{validate-declarations.js → ota-validate.js} +6 -10
- package/bin/ota.js +16 -0
- package/config/production.json +0 -3
- package/package.json +5 -7
- package/scripts/declarations/validate/index.mocha.js +1 -1
- package/src/archivist/fetcher/env.js +1 -0
- package/src/archivist/fetcher/exports.js +1 -1
- package/src/index.js +1 -1
- package/bin/.env.js +0 -10
- package/bin/track.js +0 -25
package/README.md
CHANGED
|
@@ -150,17 +150,17 @@ This quick example aimed at letting you try the engine quickly. Most likely, you
|
|
|
150
150
|
|
|
151
151
|
### CLI
|
|
152
152
|
|
|
153
|
-
Once the engine module is installed as a dependency within another module, the following
|
|
153
|
+
Once the engine module is installed as a dependency within another module, the `ota` command with the following subcommands is available.
|
|
154
154
|
|
|
155
155
|
In these commands:
|
|
156
156
|
|
|
157
157
|
- **`<service_id>`** is the case sensitive name of the service declaration file without the extension. For example, for `Twitter.json`, the service ID is `Twitter`.
|
|
158
158
|
- **`<terms_type>`** is the property name used under the `documents` property in the declaration to declare a terms. For example, in the getting started declaration, the terms type declared is `Privacy Policy`.
|
|
159
159
|
|
|
160
|
-
#### `ota
|
|
160
|
+
#### `ota track`
|
|
161
161
|
|
|
162
162
|
```sh
|
|
163
|
-
npx ota
|
|
163
|
+
npx ota track
|
|
164
164
|
```
|
|
165
165
|
|
|
166
166
|
[Track](#tracking-documents) the current terms of services according to provided declarations.
|
|
@@ -172,31 +172,31 @@ The declarations, snapshots and versions paths are defined in the [configuration
|
|
|
172
172
|
##### Recap of available options
|
|
173
173
|
|
|
174
174
|
```sh
|
|
175
|
-
npx ota
|
|
175
|
+
npx ota track --help
|
|
176
176
|
```
|
|
177
177
|
|
|
178
178
|
##### Track terms of specific services
|
|
179
179
|
|
|
180
180
|
```sh
|
|
181
|
-
npx ota
|
|
181
|
+
npx ota track --services "<service_id>" ["<service_id>"...]
|
|
182
182
|
```
|
|
183
183
|
|
|
184
184
|
##### Track specific terms of specific services
|
|
185
185
|
|
|
186
186
|
```sh
|
|
187
|
-
npx ota
|
|
187
|
+
npx ota track --services "<service_id>" ["<service_id>"...] --termsTypes "<terms_type>" ["<terms_type>"...]
|
|
188
188
|
```
|
|
189
189
|
|
|
190
190
|
##### Track documents four times a day
|
|
191
191
|
|
|
192
192
|
```sh
|
|
193
|
-
npx ota
|
|
193
|
+
npx ota track --schedule
|
|
194
194
|
```
|
|
195
195
|
|
|
196
|
-
#### `ota
|
|
196
|
+
#### `ota validate`
|
|
197
197
|
|
|
198
198
|
```sh
|
|
199
|
-
npx ota
|
|
199
|
+
npx ota validate [--services <service_id>...] [--termsTypes <terms_type>...]
|
|
200
200
|
```
|
|
201
201
|
|
|
202
202
|
Check that all declarations allow recording a snapshot and a version properly.
|
|
@@ -206,7 +206,7 @@ If one or several `<service_id>` are provided, check only those services.
|
|
|
206
206
|
##### Validate schema only
|
|
207
207
|
|
|
208
208
|
```sh
|
|
209
|
-
npx ota
|
|
209
|
+
npx ota validate --schema-only [--services <service_id>...] [--termsTypes <terms_type>...]
|
|
210
210
|
```
|
|
211
211
|
|
|
212
212
|
Check that all declarations are readable by the engine.
|
|
@@ -215,10 +215,10 @@ Allows for a much faster check of declarations, but does not check that the docu
|
|
|
215
215
|
|
|
216
216
|
If one or several `<service_id>` are provided, check only those services.
|
|
217
217
|
|
|
218
|
-
#### `ota
|
|
218
|
+
#### `ota lint`
|
|
219
219
|
|
|
220
220
|
```sh
|
|
221
|
-
npx ota
|
|
221
|
+
npx ota lint [--services <service_id>...]
|
|
222
222
|
```
|
|
223
223
|
|
|
224
224
|
Normalise the format of declarations.
|
package/bin/env.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { fileURLToPath } from 'url';
|
|
3
|
+
|
|
4
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
5
|
+
|
|
6
|
+
process.env.SUPPRESS_NO_CONFIG_WARNING = 'y'; // Caller don't get "no config files" warnings if it does define configuration files
|
|
7
|
+
|
|
8
|
+
const OTA_CONFIG_DIR = path.resolve(`${__dirname}./../config/`);
|
|
9
|
+
const PROCESS_CONFIG_DIR = path.resolve(`${process.cwd()}/config/`);
|
|
10
|
+
|
|
11
|
+
process.env.NODE_CONFIG_DIR = OTA_CONFIG_DIR + path.delimiter + PROCESS_CONFIG_DIR; // Ensure OTA config is loaded and loaded before caller config
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
#! /usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// more difficult to achieve using an eslint based command directly defined in the package.json.
|
|
4
|
-
// It also ensures that the same version of eslint is used in the OpenTermsArchive core and declarations repositories.
|
|
5
|
-
import './.env.js'; // Workaround to ensure `SUPPRESS_NO_CONFIG_WARNING` is set before config is imported
|
|
2
|
+
import './env.js';
|
|
6
3
|
|
|
7
|
-
import fs from 'fs';
|
|
8
4
|
import path from 'path';
|
|
9
5
|
import { fileURLToPath, pathToFileURL } from 'url';
|
|
10
6
|
|
|
@@ -12,15 +8,12 @@ import { program } from 'commander';
|
|
|
12
8
|
|
|
13
9
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
14
10
|
|
|
15
|
-
const { version } = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url)).toString());
|
|
16
|
-
|
|
17
11
|
program
|
|
18
|
-
.name('ota
|
|
12
|
+
.name('ota lint')
|
|
19
13
|
.description('Check format and stylistic errors in declarations and auto fix them')
|
|
20
|
-
.
|
|
21
|
-
.option('-s, --services [serviceId...]', 'service IDs of services to handle')
|
|
14
|
+
.option('-s, --services [serviceId...]', 'service IDs of services to lint')
|
|
22
15
|
.option('-m, --modified', 'to only lint modified services already commited to git');
|
|
23
16
|
|
|
24
|
-
const lintDeclarations = (await import(pathToFileURL(path.resolve(__dirname, '../scripts/declarations/lint/index.js')))).default;
|
|
17
|
+
const lintDeclarations = (await import(pathToFileURL(path.resolve(__dirname, '../scripts/declarations/lint/index.js')))).default; // load asynchronously to ensure env.js is loaded before
|
|
25
18
|
|
|
26
19
|
lintDeclarations(program.parse().opts());
|
package/bin/ota-track.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#! /usr/bin/env node
|
|
2
|
+
import './env.js';
|
|
3
|
+
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { fileURLToPath, pathToFileURL } from 'url';
|
|
6
|
+
|
|
7
|
+
import { program } from 'commander';
|
|
8
|
+
|
|
9
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
10
|
+
|
|
11
|
+
const track = (await import(pathToFileURL(path.resolve(__dirname, '../src/index.js')))).default; // load asynchronously to ensure env.js is loaded before
|
|
12
|
+
|
|
13
|
+
program
|
|
14
|
+
.name('ota track')
|
|
15
|
+
.description('Retrieve declared documents, record snapshots, extract versions and publish the resulting records')
|
|
16
|
+
.option('-s, --services [serviceId...]', 'service IDs of services to track')
|
|
17
|
+
.option('-t, --termsType [termsType...]', 'terms types to track')
|
|
18
|
+
.option('-r, --refilter-only', 'refilter existing snapshots with latest declarations and engine, without recording new snapshots')
|
|
19
|
+
.option('--schedule', 'schedule automatic document tracking');
|
|
20
|
+
|
|
21
|
+
track(program.parse(process.argv).opts());
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
#! /usr/bin/env node
|
|
2
|
-
import '
|
|
2
|
+
import './env.js';
|
|
3
3
|
|
|
4
|
-
import fs from 'fs';
|
|
5
4
|
import path from 'path';
|
|
6
5
|
import { fileURLToPath } from 'url';
|
|
7
6
|
|
|
8
7
|
import { program } from 'commander';
|
|
9
8
|
import Mocha from 'mocha';
|
|
10
9
|
|
|
11
|
-
const { version } = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url)).toString());
|
|
12
|
-
|
|
13
10
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
14
11
|
|
|
15
12
|
const VALIDATE_PATH = path.resolve(__dirname, '../scripts/declarations/validate/index.mocha.js');
|
|
@@ -21,13 +18,12 @@ process.on('unhandledRejection', reason => {
|
|
|
21
18
|
});
|
|
22
19
|
|
|
23
20
|
program
|
|
24
|
-
.name('ota
|
|
21
|
+
.name('ota validate')
|
|
25
22
|
.description('Run a series of tests to check the validity of document declarations')
|
|
26
|
-
.
|
|
27
|
-
.option('-
|
|
28
|
-
.option('-
|
|
29
|
-
.option('-
|
|
30
|
-
.option('-so, --schema-only', 'only refilter exisiting snapshots with last declarations and engine\'s updates');
|
|
23
|
+
.option('-s, --services [serviceId...]', 'service IDs of services to validate')
|
|
24
|
+
.option('-t, --termsTypes [termsType...]', 'terms types to validate')
|
|
25
|
+
.option('-m, --modified', 'target only services modified in the current git branch')
|
|
26
|
+
.option('-o, --schema-only', 'much faster check of declarations, but does not check that the documents are actually accessible');
|
|
31
27
|
|
|
32
28
|
const mocha = new Mocha({
|
|
33
29
|
delay: true, // as the validation script performs an asynchronous load before running the tests, the execution of the tests are delayed until run() is called
|
package/bin/ota.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#! /usr/bin/env node
|
|
2
|
+
import './env.js';
|
|
3
|
+
|
|
4
|
+
import fs from 'fs';
|
|
5
|
+
|
|
6
|
+
import { program } from 'commander';
|
|
7
|
+
|
|
8
|
+
const { description, version } = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url)).toString());
|
|
9
|
+
|
|
10
|
+
program
|
|
11
|
+
.description(description)
|
|
12
|
+
.version(version)
|
|
13
|
+
.command('track', 'Track the current terms of services according to provided declarations')
|
|
14
|
+
.command('validate', 'Run a series of tests to check the validity of document declarations')
|
|
15
|
+
.command('lint', 'Check format and stylistic errors in declarations and auto fix them')
|
|
16
|
+
.parse(process.argv);
|
package/config/production.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentermsarchive/engine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.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": {
|
|
@@ -20,9 +20,7 @@
|
|
|
20
20
|
"./page-declaration": "./src/archivist/services/pageDeclaration.js"
|
|
21
21
|
},
|
|
22
22
|
"bin": {
|
|
23
|
-
"ota
|
|
24
|
-
"ota-track": "./bin/track.js",
|
|
25
|
-
"ota-validate-declarations": "./bin/validate-declarations.js"
|
|
23
|
+
"ota": "./bin/ota.js"
|
|
26
24
|
},
|
|
27
25
|
"files": [
|
|
28
26
|
"bin",
|
|
@@ -35,13 +33,13 @@
|
|
|
35
33
|
"dataset:generate": "node scripts/dataset/main.js",
|
|
36
34
|
"dataset:release": "node scripts/dataset/main.js --publish --remove-local-copy",
|
|
37
35
|
"dataset:scheduler": "npm run dataset:release -- --schedule",
|
|
38
|
-
"declarations:lint": "node
|
|
39
|
-
"declarations:validate": "node
|
|
36
|
+
"declarations:lint": "node bin/ota.js lint",
|
|
37
|
+
"declarations:validate": "node bin/ota.js validate",
|
|
40
38
|
"declarations:validate:schema": "npm run declarations:validate -- --schema-only",
|
|
41
39
|
"lint": "eslint src test scripts bin",
|
|
42
40
|
"lint:fix": "npm run lint -- --fix",
|
|
43
41
|
"refilter": "npm start -- --refilter-only",
|
|
44
|
-
"start": "node --max-http-header-size=32768 bin/
|
|
42
|
+
"start": "node --max-http-header-size=32768 bin/ota.js track",
|
|
45
43
|
"start:scheduler": "npm start -- --schedule",
|
|
46
44
|
"test": "cross-env NODE_ENV=test mocha --recursive \"./src/**/*.test.js\" \"./scripts/**/*.test.js\" --exit",
|
|
47
45
|
"posttest": "npm run lint",
|
|
@@ -34,7 +34,7 @@ const instancePath = path.resolve(declarationsPath, '../');
|
|
|
34
34
|
export default async options => {
|
|
35
35
|
const schemaOnly = options.schemaOnly || false;
|
|
36
36
|
let servicesToValidate = options.services || [];
|
|
37
|
-
const documentTypes = options.
|
|
37
|
+
const documentTypes = options.termsTypes || [];
|
|
38
38
|
let servicesDocumentTypes = {};
|
|
39
39
|
|
|
40
40
|
const serviceDeclarations = await services.loadWithHistory(servicesToValidate);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
process.env.SUPPRESS_NO_CONFIG_WARNING = 'y'; // Caller don't get "no config files" warnings if it does define configuration files
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import '
|
|
1
|
+
import './env.js'; // Workaround to ensure `SUPPRESS_NO_CONFIG_WARNING` is set before config is imported
|
|
2
2
|
|
|
3
3
|
import fs from 'fs';
|
|
4
4
|
import path from 'path';
|
package/src/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import logger from './logger/index.js';
|
|
|
6
6
|
import Notifier from './notifier/index.js';
|
|
7
7
|
import Tracker from './tracker/index.js';
|
|
8
8
|
|
|
9
|
-
export default async function track({ services = [], documentTypes, refilterOnly, schedule }) {
|
|
9
|
+
export default async function track({ services = [], termsType: documentTypes, refilterOnly, schedule }) {
|
|
10
10
|
const archivist = new Archivist({ recorderConfig: config.get('recorder') });
|
|
11
11
|
|
|
12
12
|
archivist.attach(logger);
|
package/bin/.env.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import { fileURLToPath } from 'url';
|
|
3
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
4
|
-
|
|
5
|
-
process.env.SUPPRESS_NO_CONFIG_WARNING = 'y'; // Caller don't get "no config files" warnings if it does define configuration files
|
|
6
|
-
|
|
7
|
-
const OTA_CONFIG_DIR = path.resolve(__dirname + "./../config/");
|
|
8
|
-
const PROCESS_CONFIG_DIR = path.resolve(process.cwd() + "/config/");
|
|
9
|
-
|
|
10
|
-
process.env["NODE_CONFIG_DIR"] = OTA_CONFIG_DIR + path.delimiter + PROCESS_CONFIG_DIR; // Ensure OTA config is loaded and loaded before caller config
|
package/bin/track.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
#! /usr/bin/env node
|
|
2
|
-
import './.env.js'; // Workaround to ensure `SUPPRESS_NO_CONFIG_WARNING` is set before config is imported
|
|
3
|
-
|
|
4
|
-
import fs from 'fs';
|
|
5
|
-
import path from 'path';
|
|
6
|
-
import { fileURLToPath, pathToFileURL } from 'url';
|
|
7
|
-
|
|
8
|
-
import { program } from 'commander';
|
|
9
|
-
|
|
10
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
11
|
-
|
|
12
|
-
const { description, version } = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url)).toString());
|
|
13
|
-
|
|
14
|
-
program
|
|
15
|
-
.name('ota-track')
|
|
16
|
-
.description(description)
|
|
17
|
-
.version(version)
|
|
18
|
-
.option('-s, --services [serviceId...]', 'service IDs of services to handle')
|
|
19
|
-
.option('-d, --documentTypes [documentType...]', 'terms types to handle')
|
|
20
|
-
.option('-r, --refilter-only', 'only refilter exisiting snapshots with last declarations and engine\'s updates')
|
|
21
|
-
.option('--schedule', 'schedule automatic document tracking');
|
|
22
|
-
|
|
23
|
-
const track = (await import(pathToFileURL(path.resolve(__dirname, '../src/index.js')))).default;
|
|
24
|
-
|
|
25
|
-
track(program.parse(process.argv).opts());
|