Skip to content

Commit be8860c

Browse files
committed
Add flags for computing crosswalks when updating collections
1 parent 0cdece2 commit be8860c

File tree

2 files changed

+26
-20
lines changed

2 files changed

+26
-20
lines changed

src/cli.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ program
7373
program
7474
.command('update-collection')
7575
.description("Update a collection to the latest version of each digital object in it's metadata")
76+
.option('--update-2d-ftu-crosswalks', 'Update 2D FTUs with the overall crosswalk in the release.', false)
77+
.option('--update-ref-organ-crosswalks', 'Update reference organs with the overall crosswalk in the release.', false)
7678
.argument('<digital-object-path>', 'Path to the digital object relative to DO_HOME')
7779
.action((str, _options, command) => {
7880
updateCollection(getContext(program, command, str));

src/update-collection.js

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,33 @@ export async function updateCollection(context) {
1919

2020
writeFileSync(doListing, dump({ 'digital-objects': updated }));
2121

22-
// Update all reference organ crosswalk files
23-
const ftuCrosswalk = updated.find((d) => d.startsWith('2d-ftu/asct-b-2d-models-crosswalk'));
24-
const ftuIllustrations = updated.filter((d) => d !== ftuCrosswalk && d.startsWith('2d-ftu/'));
22+
if (context.update2dFtuCrosswalk) {
23+
// Update all reference organ crosswalk files
24+
const ftuCrosswalk = updated.find((d) => d.startsWith('2d-ftu/asct-b-2d-models-crosswalk'));
25+
const ftuIllustrations = updated.filter((d) => d !== ftuCrosswalk && d.startsWith('2d-ftu/'));
2526

26-
for (const ftu of ftuIllustrations) {
27-
console.log(`Updating crosswalk for ${ftu} using ${ftuCrosswalk}`);
28-
update2dFtuCrosswalk({
29-
...context,
30-
selectedDigitalObject: getDigitalObjectInformation(resolve(context.doHome, ftu), context.purlIri),
31-
crosswalk: ftuCrosswalk,
32-
});
27+
for (const ftu of ftuIllustrations) {
28+
console.log(`Updating crosswalk for ${ftu} using ${ftuCrosswalk}`);
29+
update2dFtuCrosswalk({
30+
...context,
31+
selectedDigitalObject: getDigitalObjectInformation(resolve(context.doHome, ftu), context.purlIri),
32+
crosswalk: ftuCrosswalk,
33+
});
34+
}
3335
}
3436

35-
// Update all reference organ crosswalk files
36-
const refOrganCrosswalk = updated.find((d) => d.startsWith('ref-organ/asct-b-3d-models-crosswalk'));
37-
const refOrgans = updated.filter((d) => d !== refOrganCrosswalk && d.startsWith('ref-organ/'));
37+
if (context.updateRefOrganCrosswalk) {
38+
// Update all reference organ crosswalk files
39+
const refOrganCrosswalk = updated.find((d) => d.startsWith('ref-organ/asct-b-3d-models-crosswalk'));
40+
const refOrgans = updated.filter((d) => d !== refOrganCrosswalk && d.startsWith('ref-organ/'));
3841

39-
for (const refOrgan of refOrgans) {
40-
console.log(`Updating crosswalk for ${refOrgan} using ${refOrganCrosswalk}`);
41-
await updateRefOrganCrosswalk({
42-
...context,
43-
selectedDigitalObject: getDigitalObjectInformation(resolve(context.doHome, refOrgan), context.purlIri),
44-
crosswalk: refOrganCrosswalk,
45-
});
42+
for (const refOrgan of refOrgans) {
43+
console.log(`Updating crosswalk for ${refOrgan} using ${refOrganCrosswalk}`);
44+
await updateRefOrganCrosswalk({
45+
...context,
46+
selectedDigitalObject: getDigitalObjectInformation(resolve(context.doHome, refOrgan), context.purlIri),
47+
crosswalk: refOrganCrosswalk,
48+
});
49+
}
4650
}
4751
}

0 commit comments

Comments
 (0)