Skip to content

Commit

Permalink
Merge pull request #128 from unfoldingWord/release-v3.0.0
Browse files Browse the repository at this point in the history
Merge Release v3.0.0 into develop
  • Loading branch information
PhotoNomad0 authored Jul 29, 2020
2 parents 601b39a + 91c59d7 commit 0736045
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
6 changes: 4 additions & 2 deletions __tests__/tnArticleHelpers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ describe('Tests for tnArticleHelpers.getMissingResources()', function() {
const sourcePath = path.join(importsPath, 'en_tn');
const expectedCalls = [];
const callLog = [];
fs.writeJsonSync(path.join(resourcesPath, 'en', 'translationHelps/translationAcademy', 'v1', 'manifest.json'), {}); // make dummy manifest for tA

// when
const {otQuery, ntQuery} = await tnArticleHelpers.getMissingResources(sourcePath, resourcesPath, mockGetMissingOriginalResource, callLog);
const {otQuery, ntQuery} = await tnArticleHelpers.getMissingResources(sourcePath, resourcesPath, mockGetMissingOriginalResource, callLog, 'en');

// then
validateCallLog(callLog, expectedCalls);
Expand Down Expand Up @@ -64,9 +65,10 @@ describe('Tests for tnArticleHelpers.getMissingResources()', function() {
const callLog = [];
const expectedNtQuery = '0.10';
const expectedOtQuery = '2.1.9';
fs.writeJsonSync(path.join(resourcesPath, 'en', 'translationHelps/translationAcademy', 'v1', 'manifest.json'), {}); // make dummy manifest for tA

// when
const {otQuery, ntQuery} = await tnArticleHelpers.getMissingResources(sourcePath, resourcesPath, mockGetMissingOriginalResource, callLog);
const {otQuery, ntQuery} = await tnArticleHelpers.getMissingResources(sourcePath, resourcesPath, mockGetMissingOriginalResource, callLog, 'en');

// then
validateCallLog(callLog, expectedCalls);
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tc-source-content-updater",
"version": "0.8.0",
"version": "0.8.1",
"description": "Module that updates source content for the desktop application translationCore.",
"main": "lib/index.js",
"display": "library",
Expand Down
20 changes: 17 additions & 3 deletions src/helpers/translationHelps/tnArticleHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,16 @@ import {
import {makeSureResourceUnzipped} from '../unzipFileHelpers';

/**
* search to see if we need to get any missing original language dependencies
* search to see if we need to get any missing resources needed for tN processing
* @param {String} sourcePath - Path to the extracted files that came from the zip file from the catalog
* e.g. /Users/mannycolon/translationCore/resources/imports/en_tn_v16/en_tn
* @param {String} resourcesPath Path to resources folder
* @param {Function} getMissingOriginalResource - function called to fetch missing resources
* @param {Array} downloadErrors - parsed list of download errors with details such as if the download completed (vs. parsing error), error, and url
* @param {String} languageId - language ID for tA
* @return {Promise<{otQuery: string, ntQuery: string}>}
*/
export async function getMissingResources(sourcePath, resourcesPath, getMissingOriginalResource, downloadErrors) {
export async function getMissingResources(sourcePath, resourcesPath, getMissingOriginalResource, downloadErrors, languageId) {
const tsvManifest = resourcesHelpers.getResourceManifestFromYaml(sourcePath);
// array of related resources used to generated the tsv.
const tsvRelations = tsvManifest.dublin_core.relation;
Expand All @@ -57,6 +58,19 @@ export async function getMissingResources(sourcePath, resourcesPath, getMissingO
makeSureResourceUnzipped(originalBiblePath);
}
}

// make sure tA is unzipped
const tAPath = path.join(
resourcesPath,
languageId,
'translationHelps/translationAcademy'
);
const taVersionPath = resourcesHelpers.getLatestVersionInPath(tAPath);
if (taVersionPath) {
makeSureResourceUnzipped(taVersionPath);
} else {
throw new Error(`getMissingResources() - cannot find tA at ${tAPath}`);
}
return {otQuery, ntQuery};
}

Expand Down Expand Up @@ -88,7 +102,7 @@ export async function processTranslationNotes(resource, sourcePath, outputPath,
fs.removeSync(outputPath);
}

const {otQuery, ntQuery} = await getMissingResources(sourcePath, resourcesPath, getMissingOriginalResource, downloadErrors);
const {otQuery, ntQuery} = await getMissingResources(sourcePath, resourcesPath, getMissingOriginalResource, downloadErrors, resource.languageId);
console.log(`processTranslationNotes() - have needed original bibles for ${sourcePath}, starting processing`);
const tsvFiles = fs.readdirSync(sourcePath).filter((filename) => path.extname(filename) === '.tsv');
const tnErrors = [];
Expand Down

0 comments on commit 0736045

Please sign in to comment.