diff --git a/bin/ota-track.js b/bin/ota-track.js index 77e480ac5..40745362a 100755 --- a/bin/ota-track.js +++ b/bin/ota-track.js @@ -16,6 +16,9 @@ program .option('-s, --services [serviceId...]', 'service IDs of services to track') .option('-t, --types [termsType...]', 'terms types to track') .option('-e, --extract-only', 'extract versions from existing snapshots with latest declarations and engine, without recording new snapshots') - .option('--schedule', 'track automatically at a regular interval'); + .option('--schedule', 'track automatically at a regular interval') + .option('--skipPreRun', 'skip the pre run') + .option('--skipReadBack', 'skip the read-back of snapshots') + .option('--skipSnapshots', 'skip both the writing and the read-back of the snapshots'); track(program.parse(process.argv).opts()); diff --git a/src/archivist/index.js b/src/archivist/index.js index e69ede836..ee43aaac6 100644 --- a/src/archivist/index.js +++ b/src/archivist/index.js @@ -127,13 +127,17 @@ export default class Archivist extends events.EventEmitter { this.emit('trackingCompleted', servicesIds.length, numberOfTerms, extractOnly); } - async trackTermsChanges({ terms, extractOnly = false }) { + async trackTermsChanges({ terms, extractOnly = false, skipReadBack = false, skipSnapshots = false }) { if (!extractOnly) { await this.fetchSourceDocuments(terms); - await this.recordSnapshots(terms); + if (!skipSnapshots) { + await this.recordSnapshots(terms); + } } - await this.loadSourceDocumentsFromSnapshots(terms); + if (!skipSnapshots && !skipReadBack) { + await this.loadSourceDocumentsFromSnapshots(terms); + } if (terms.sourceDocuments.filter(sourceDocument => !sourceDocument.content).length) { // If some source documents do not have associated snapshots, it is not possible to generate a fully valid version diff --git a/src/index.js b/src/index.js index 2083e1802..2f33fcf63 100644 --- a/src/index.js +++ b/src/index.js @@ -11,8 +11,8 @@ import Reporter from './reporter/index.js'; const require = createRequire(import.meta.url); -export default async function track({ services, types, extractOnly, schedule }) { - const archivist = new Archivist({ +export default async function track({ services, types, extractOnly, skipPreRun, skipSnapshots, skipReadBack, schedule }) { + const archivist = new Archivist({ recorderConfig: config.get('@opentermsarchive/engine.recorder'), fetcherConfig: config.get('@opentermsarchive/engine.fetcher'), }); @@ -39,9 +39,11 @@ export default async function track({ services, types, extractOnly, schedule }) // The result of the extraction step that generates the version from the snapshots may depend on changes to the engine or its dependencies. // The process thus starts by only performing the extraction process so that any version following such changes can be labelled (to avoid sending notifications, for example) - await archivist.track({ services, types, extractOnly: true }); + if (!skipPreRun) { + await archivist.track({ services, types, extractOnly: true, skipSnapshots }); + } - if (extractOnly) { + if (extractOnly && !skipPreRun) { return; } @@ -73,7 +75,7 @@ export default async function track({ services, types, extractOnly, schedule }) } if (!schedule) { - await archivist.track({ services, types }); + await archivist.track({ services, types, extractOnly, skipSnapshots, skipReadBack }); return; }