@opentermsarchive/engine 0.17.2 → 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/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.2",
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": {
@@ -41,7 +41,7 @@
41
41
  "lint": "eslint src test scripts bin",
42
42
  "lint:fix": "npm run lint -- --fix",
43
43
  "refilter": "npm start -- --refilter-only",
44
- "start": "node --max-http-header-size=32768 src/main.js",
44
+ "start": "node --max-http-header-size=32768 bin/track.js",
45
45
  "start:scheduler": "npm start -- --schedule",
46
46
  "test": "cross-env NODE_ENV=test mocha --recursive \"./src/**/*.test.js\" \"./scripts/**/*.test.js\" --exit",
47
47
  "posttest": "npm run lint",
@@ -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());