From ffd8f2363645c76b4f77597778336f132b913f1f Mon Sep 17 00:00:00 2001 From: Michiel de Jong Date: Fri, 13 Sep 2024 16:43:50 +0200 Subject: [PATCH] More skip options, fixes #1103 --- bin/ota-track.js | 5 ++++- src/archivist/index.js | 10 +++++++--- src/index.js | 13 ++++++++----- 3 files changed, 19 insertions(+), 9 deletions(-) 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..0b1ffcf1d 100644 --- a/src/index.js +++ b/src/index.js @@ -11,8 +11,9 @@ 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 }) { + console.log('top level 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 +40,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 +76,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; }