@opentermsarchive/engine 0.17.1 → 0.18.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/.eslintrc.yaml ADDED
@@ -0,0 +1,116 @@
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
package/bin/.env.js CHANGED
@@ -1 +1,10 @@
1
- process.env.SUPPRESS_NO_CONFIG_WARNING = 'y';
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
@@ -9,14 +9,9 @@ import path from 'path';
9
9
  import { fileURLToPath, pathToFileURL } from 'url';
10
10
 
11
11
  import { program } from 'commander';
12
- import config from 'config';
13
12
 
14
13
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
15
14
 
16
- // Initialise configs to allow clients of this module to use it without requiring node-config in their own application.
17
- // see https://github.com/lorenwest/node-config/wiki/Sub-Module-Configuration
18
-
19
- config.util.setModuleDefaults('services', { declarationsPath: path.resolve(process.cwd(), './declarations') });
20
15
  const { version } = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url)).toString());
21
16
 
22
17
  program
package/bin/track.js CHANGED
@@ -5,22 +5,21 @@ import fs from 'fs';
5
5
  import path from 'path';
6
6
  import { fileURLToPath, pathToFileURL } from 'url';
7
7
 
8
- import config from 'config';
8
+ import { program } from 'commander';
9
9
 
10
10
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
11
11
 
12
- const defaultConfigs = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../config/default.json')));
12
+ const { description, version } = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url)).toString());
13
13
 
14
- // Initialise configs to allow clients of this module to use it without requiring node-config in their own application.
15
- // see https://github.com/lorenwest/node-config/wiki/Sub-Module-Configuration
16
- config.util.setModuleDefaults('services', { declarationsPath: path.resolve(process.cwd(), './declarations') });
17
- config.util.setModuleDefaults('fetcher', defaultConfigs.fetcher);
18
- config.util.setModuleDefaults('recorder', config.util.extendDeep({}, defaultConfigs.recorder, {
19
- versions: { storage: { git: { path: path.resolve(process.cwd(), './data/versions') } } },
20
- snapshots: { storage: { git: { path: path.resolve(process.cwd(), './data/snapshots') } } },
21
- }));
22
- config.util.setModuleDefaults('logger', defaultConfigs.logger);
23
- // we do not want any tracker when launching through this command line
24
- config.util.setModuleDefaults('tracker', {});
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');
25
22
 
26
- import(pathToFileURL(path.resolve(__dirname, '../src/main.js')));
23
+ const track = (await import(pathToFileURL(path.resolve(__dirname, '../src/index.js')))).default;
24
+
25
+ track(program.parse(process.argv).opts());
@@ -6,20 +6,12 @@ import path from 'path';
6
6
  import { fileURLToPath } from 'url';
7
7
 
8
8
  import { program } from 'commander';
9
- import config from 'config';
10
9
  import Mocha from 'mocha';
11
10
 
12
11
  const { version } = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url)).toString());
13
12
 
14
13
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
15
14
 
16
- const defaultConfigs = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../config/default.json')));
17
-
18
- // Initialise configs to allow clients of this module to use it without requiring node-config in their own application.
19
- // see https://github.com/lorenwest/node-config/wiki/Sub-Module-Configuration
20
- config.util.setModuleDefaults('services', { declarationsPath: path.resolve(process.cwd(), './declarations') });
21
- config.util.setModuleDefaults('fetcher', defaultConfigs.fetcher);
22
-
23
15
  const VALIDATE_PATH = path.resolve(__dirname, '../scripts/declarations/validate/index.mocha.js');
24
16
 
25
17
  // Mocha catches unhandled rejection from the user code and re-emits them to the process (see https://github.com/mochajs/mocha/blob/master/lib/runner.js#L198)
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "services": {
3
- "declarationsPath": "../declarations/declarations"
3
+ "declarationsPath": "./declarations"
4
4
  },
5
5
  "recorder": {
6
6
  "versions": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentermsarchive/engine",
3
- "version": "0.17.1",
3
+ "version": "0.18.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": {
@@ -24,6 +24,13 @@
24
24
  "ota-track": "./bin/track.js",
25
25
  "ota-validate-declarations": "./bin/validate-declarations.js"
26
26
  },
27
+ "files": [
28
+ "bin",
29
+ "config",
30
+ "scripts",
31
+ "src",
32
+ ".eslintrc.yaml"
33
+ ],
27
34
  "scripts": {
28
35
  "dataset:generate": "node scripts/dataset/main.js",
29
36
  "dataset:release": "node scripts/dataset/main.js --publish --remove-local-copy",
@@ -34,18 +41,12 @@
34
41
  "lint": "eslint src test scripts bin",
35
42
  "lint:fix": "npm run lint -- --fix",
36
43
  "refilter": "npm start -- --refilter-only",
37
- "start": "node --max-http-header-size=32768 src/main.js",
44
+ "start": "node --max-http-header-size=32768 bin/track.js",
38
45
  "start:scheduler": "npm start -- --schedule",
39
46
  "test": "cross-env NODE_ENV=test mocha --recursive \"./src/**/*.test.js\" \"./scripts/**/*.test.js\" --exit",
40
47
  "posttest": "npm run lint",
41
48
  "test:debug": "npm run test -- --inspect-brk --exit"
42
49
  },
43
- "files": [
44
- "bin",
45
- "config",
46
- "scripts",
47
- "src"
48
- ],
49
50
  "dependencies": {
50
51
  "@accordproject/markdown-cicero": "^0.15.2",
51
52
  "@accordproject/markdown-pdf": "^0.15.2",
@@ -28,7 +28,7 @@ const SLOW_DOCUMENT_THRESHOLD = 10 * 1000; // number of milliseconds after which
28
28
  const eslint = new ESLint({ overrideConfigFile: ESLINT_CONFIG_PATH, fix: false });
29
29
  const eslintWithFix = new ESLint({ overrideConfigFile: ESLINT_CONFIG_PATH, fix: true });
30
30
 
31
- const declarationsPath = path.resolve(ROOT_PATH, config.get('services.declarationsPath'));
31
+ const declarationsPath = path.resolve(process.cwd(), config.get('services.declarationsPath'));
32
32
  const instancePath = path.resolve(declarationsPath, '../');
33
33
 
34
34
  export default async options => {
@@ -38,7 +38,8 @@ let git;
38
38
  describe('GitRepository', () => {
39
39
  let subject;
40
40
 
41
- before(async () => {
41
+ before(async function () {
42
+ this.timeout(5000);
42
43
  git = new Git({
43
44
  path: RECORDER_PATH,
44
45
  author: {
@@ -10,7 +10,7 @@ import Service from './service.js';
10
10
 
11
11
  const fs = fsApi.promises;
12
12
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
13
- const declarationsPath = path.resolve(__dirname, '../../..', config.get('services.declarationsPath'));
13
+ const declarationsPath = path.resolve(process.cwd(), config.get('services.declarationsPath'));
14
14
 
15
15
  export const DOCUMENT_TYPES = JSON.parse(fsApi.readFileSync(path.resolve(__dirname, './documentTypes.json')));
16
16
 
package/src/main.js DELETED
@@ -1,18 +0,0 @@
1
- import fs from 'fs';
2
-
3
- import { program } from 'commander';
4
-
5
- import track from './index.js';
6
-
7
- const { name, description, version } = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url)).toString());
8
-
9
- program
10
- .name(name)
11
- .description(description)
12
- .version(version)
13
- .option('-s, --services [serviceId...]', 'service IDs of services to handle')
14
- .option('-d, --documentTypes [documentType...]', 'terms types to handle')
15
- .option('-r, --refilter-only', 'only refilter exisiting snapshots with last declarations and engine\'s updates')
16
- .option('--schedule', 'schedule automatic document tracking');
17
-
18
- track(program.parse(process.argv).opts());