From 3e0e18ccdc9eeb183e590d525626c2554a63b708 Mon Sep 17 00:00:00 2001 From: Bruce McLean Date: Mon, 10 Jan 2022 06:55:52 -0500 Subject: [PATCH 1/5] revert Changes made in PR: https://github.com/unfoldingWord/translationCore/pull/7155/files --- src/js/actions/__tests__/MigrationActions.test.js | 4 ++-- .../__snapshots__/MigrationActions.test.js.snap | 3 ++- src/js/helpers/ResourcesHelpers.js | 10 +++++----- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/js/actions/__tests__/MigrationActions.test.js b/src/js/actions/__tests__/MigrationActions.test.js index 9c471aa555..d61550ae9f 100644 --- a/src/js/actions/__tests__/MigrationActions.test.js +++ b/src/js/actions/__tests__/MigrationActions.test.js @@ -326,10 +326,10 @@ describe('migrate tCore resources', () => { expect(fs.existsSync(path.join(USER_RESOURCES_PATH, 'grc'))).toBeFalsy(); // should remove folder }); - it('test with older version of ugnt in grc/bible - should be removed', () => { + it('test with older version of ugnt in grc/bible - should not be removed', () => { // given const expectedHelpsVers = false; - const expectedBibleVers = ['v0.2']; + const expectedBibleVers = ['v0.1', 'v0.2']; const bibleId = 'ugnt'; fs.copySync(path.join(STATIC_RESOURCES_PATH, 'el-x-koine/bibles', bibleId, 'v0.2'), path.join(USER_RESOURCES_PATH, 'grc/bibles', bibleId, 'v0.1')); const migrateResourcesFolder = MigrationActions.migrateResourcesFolder(); diff --git a/src/js/actions/__tests__/__snapshots__/MigrationActions.test.js.snap b/src/js/actions/__tests__/__snapshots__/MigrationActions.test.js.snap index fe0a8b57ba..55553e4dc9 100644 --- a/src/js/actions/__tests__/__snapshots__/MigrationActions.test.js.snap +++ b/src/js/actions/__tests__/__snapshots__/MigrationActions.test.js.snap @@ -19,8 +19,9 @@ Array [ ] `; -exports[`migrate tCore resources Test grc resource migration test with older version of ugnt in grc/bible - should be removed 1`] = ` +exports[`migrate tCore resources Test grc resource migration test with older version of ugnt in grc/bible - should not be removed 1`] = ` Array [ + "/Users/jest/mock/path/translationCore/resources/el-x-koine/bibles/ugnt/v0.1", "/Users/jest/mock/path/translationCore/resources/el-x-koine/bibles/ugnt/v0.2", "/Users/jest/mock/path/translationCore/resources/el-x-koine/translationHelps/translationWords/v8", "/Users/jest/mock/path/translationCore/resources/en/bibles/ult/v12.1", diff --git a/src/js/helpers/ResourcesHelpers.js b/src/js/helpers/ResourcesHelpers.js index 34a067428d..54101a7a1a 100644 --- a/src/js/helpers/ResourcesHelpers.js +++ b/src/js/helpers/ResourcesHelpers.js @@ -692,6 +692,8 @@ export const extractZippedResourceContent = (resourceDestinationPath, isBible) = if (fs.existsSync(contentZipPath)) { fs.removeSync(contentZipPath); } + } else { + console.info(`extractZippedResourceContent: ${contentZipPath}, Path Does not exist`); } } }; @@ -1191,7 +1193,7 @@ export function preserveNeededOrigLangVersions(languageId, resourceId, resourceP let deleteOldResources = true; // by default we do not keep old versions of resources if (BibleHelpers.isOriginalLanguageBible(languageId, resourceId)) { - const requiredVersions = getOtherTnsOLVersions(USER_RESOURCES_PATH, resourceId).sort((a, b) => + const requiredVersions = getOtherTnsOLVersions(resourcePath, resourceId).sort((a, b) => -ResourceAPI.compareVersions(a, b), // do inverted sort ); console.log('preserveNeededOrigLangVersions: requiredVersions', requiredVersions); @@ -1246,15 +1248,13 @@ export function getMissingResources() { } else if (!fs.existsSync(userResourcePath)) {// if resource isn't found in user resources folder. copyAndExtractResource(staticResourcePath, userResourcePath, languageId, resourceId, resourceType); } else { // compare resources manifest modified time + const userResourceVersionPath = ResourceAPI.getLatestVersion(userResourcePath); const staticResourceVersionPath = ResourceAPI.getLatestVersion(staticResourcePath); - const version = path.basename(staticResourceVersionPath); - const userResourceVersionPath = path.join(userResourcePath, version); - const userResourceExists = fs.existsSync(userResourceVersionPath); let isOldResource = false; const filename = 'manifest.json'; const staticResourceManifestPath = path.join(staticResourceVersionPath, filename); - if (userResourceExists) { + if (userResourceVersionPath) { const userResourceManifestPath = path.join(userResourceVersionPath, filename); if (fs.existsSync(userResourceManifestPath) && fs.existsSync(staticResourceManifestPath)) { From caebd5bb7fb70ba4300b676159d7fe8b693ecb53 Mon Sep 17 00:00:00 2001 From: Bruce McLean Date: Mon, 10 Jan 2022 08:00:03 -0500 Subject: [PATCH 2/5] update tc-source-content-updater --- package-lock.json | 14 +++++++------- package.json | 2 +- src/js/helpers/ResourcesHelpers.js | 2 -- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index cd41886014..4c163387ab 100644 --- a/package-lock.json +++ b/package-lock.json @@ -71,7 +71,7 @@ "string-punctuation-tokenizer": "^2.2.0", "sudo-prompt": "6.2.1", "tc-electron-env": "0.9.0", - "tc-source-content-updater": "^0.9.0", + "tc-source-content-updater": "0.9.1-alpha", "tc-strings": "0.1.7", "tc-tool": "4.1.0", "tc-ui-toolkit": "5.3.3", @@ -22903,9 +22903,9 @@ } }, "node_modules/tc-source-content-updater": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/tc-source-content-updater/-/tc-source-content-updater-0.9.0.tgz", - "integrity": "sha512-9SrIlTnf8WiO8QbOGGrRs+ix8iOLgW0VN1W2k/XjO3KEQe5uC3UVwpncvCOzrI6WwLYCZ6oOfU4YdwrlWkZTKQ==", + "version": "0.9.1-alpha", + "resolved": "https://registry.npmjs.org/tc-source-content-updater/-/tc-source-content-updater-0.9.1-alpha.tgz", + "integrity": "sha512-2o9sb0XhmcaysLKTkAUF08UgDud9JOxJeBUnlPfK2HwLLOs2GvPj9u+NLgI1WsZE8sR5kpAW1vuEhK6X/t8ETQ==", "dependencies": { "adm-zip": "^0.4.11", "agentkeepalive": "4.1.0", @@ -45074,9 +45074,9 @@ } }, "tc-source-content-updater": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/tc-source-content-updater/-/tc-source-content-updater-0.9.0.tgz", - "integrity": "sha512-9SrIlTnf8WiO8QbOGGrRs+ix8iOLgW0VN1W2k/XjO3KEQe5uC3UVwpncvCOzrI6WwLYCZ6oOfU4YdwrlWkZTKQ==", + "version": "0.9.1-alpha", + "resolved": "https://registry.npmjs.org/tc-source-content-updater/-/tc-source-content-updater-0.9.1-alpha.tgz", + "integrity": "sha512-2o9sb0XhmcaysLKTkAUF08UgDud9JOxJeBUnlPfK2HwLLOs2GvPj9u+NLgI1WsZE8sR5kpAW1vuEhK6X/t8ETQ==", "requires": { "adm-zip": "^0.4.11", "agentkeepalive": "4.1.0", diff --git a/package.json b/package.json index 60d3de92c4..be580f877a 100644 --- a/package.json +++ b/package.json @@ -175,7 +175,7 @@ "string-punctuation-tokenizer": "^2.2.0", "sudo-prompt": "6.2.1", "tc-electron-env": "0.9.0", - "tc-source-content-updater": "^0.9.0", + "tc-source-content-updater": "0.9.1-alpha", "tc-strings": "0.1.7", "tc-tool": "4.1.0", "tc-ui-toolkit": "5.3.3", diff --git a/src/js/helpers/ResourcesHelpers.js b/src/js/helpers/ResourcesHelpers.js index 54101a7a1a..8b32e005cb 100644 --- a/src/js/helpers/ResourcesHelpers.js +++ b/src/js/helpers/ResourcesHelpers.js @@ -692,8 +692,6 @@ export const extractZippedResourceContent = (resourceDestinationPath, isBible) = if (fs.existsSync(contentZipPath)) { fs.removeSync(contentZipPath); } - } else { - console.info(`extractZippedResourceContent: ${contentZipPath}, Path Does not exist`); } } }; From 019f45ea11d55696f78d7e0d9b1572bc2fce4da4 Mon Sep 17 00:00:00 2001 From: Bruce McLean Date: Mon, 10 Jan 2022 09:56:24 -0500 Subject: [PATCH 3/5] update tc-source-content-updater --- package-lock.json | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4c163387ab..d8a680a633 100644 --- a/package-lock.json +++ b/package-lock.json @@ -71,7 +71,7 @@ "string-punctuation-tokenizer": "^2.2.0", "sudo-prompt": "6.2.1", "tc-electron-env": "0.9.0", - "tc-source-content-updater": "0.9.1-alpha", + "tc-source-content-updater": "0.9.1-alpha.4", "tc-strings": "0.1.7", "tc-tool": "4.1.0", "tc-ui-toolkit": "5.3.3", @@ -22903,9 +22903,9 @@ } }, "node_modules/tc-source-content-updater": { - "version": "0.9.1-alpha", - "resolved": "https://registry.npmjs.org/tc-source-content-updater/-/tc-source-content-updater-0.9.1-alpha.tgz", - "integrity": "sha512-2o9sb0XhmcaysLKTkAUF08UgDud9JOxJeBUnlPfK2HwLLOs2GvPj9u+NLgI1WsZE8sR5kpAW1vuEhK6X/t8ETQ==", + "version": "0.9.1-alpha.4", + "resolved": "https://registry.npmjs.org/tc-source-content-updater/-/tc-source-content-updater-0.9.1-alpha.4.tgz", + "integrity": "sha512-o9+Jc7kRxJULGCj2DiMv7QrwKfI/EraSziT4t1HvWqYxUhfHO0MILzTan17LSoZ7nJZKt+ho2HcFFwO1TZH76A==", "dependencies": { "adm-zip": "^0.4.11", "agentkeepalive": "4.1.0", @@ -45074,9 +45074,9 @@ } }, "tc-source-content-updater": { - "version": "0.9.1-alpha", - "resolved": "https://registry.npmjs.org/tc-source-content-updater/-/tc-source-content-updater-0.9.1-alpha.tgz", - "integrity": "sha512-2o9sb0XhmcaysLKTkAUF08UgDud9JOxJeBUnlPfK2HwLLOs2GvPj9u+NLgI1WsZE8sR5kpAW1vuEhK6X/t8ETQ==", + "version": "0.9.1-alpha.4", + "resolved": "https://registry.npmjs.org/tc-source-content-updater/-/tc-source-content-updater-0.9.1-alpha.4.tgz", + "integrity": "sha512-o9+Jc7kRxJULGCj2DiMv7QrwKfI/EraSziT4t1HvWqYxUhfHO0MILzTan17LSoZ7nJZKt+ho2HcFFwO1TZH76A==", "requires": { "adm-zip": "^0.4.11", "agentkeepalive": "4.1.0", diff --git a/package.json b/package.json index be580f877a..bd28b473bc 100644 --- a/package.json +++ b/package.json @@ -175,7 +175,7 @@ "string-punctuation-tokenizer": "^2.2.0", "sudo-prompt": "6.2.1", "tc-electron-env": "0.9.0", - "tc-source-content-updater": "0.9.1-alpha", + "tc-source-content-updater": "0.9.1-alpha.4", "tc-strings": "0.1.7", "tc-tool": "4.1.0", "tc-ui-toolkit": "5.3.3", From a49ebcf8aea5a10bbd3659b1e35297b9bf23bf64 Mon Sep 17 00:00:00 2001 From: Bruce McLean Date: Mon, 10 Jan 2022 14:18:48 -0500 Subject: [PATCH 4/5] update tsv-groupdata-parser to fix crash in parsing tN with empty occurrence note. --- package-lock.json | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index d205aada65..ad96da072a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -76,7 +76,7 @@ "tc-tool": "4.1.0", "tc-ui-toolkit": "6.0.0", "truncate-utf8-bytes": "1.0.2", - "tsv-groupdata-parser": "0.10.1", + "tsv-groupdata-parser": "0.10.2", "usfm-js": "3.3.1", "uuid": "3.2.1", "word-aligner": "1.0.0", @@ -23704,9 +23704,9 @@ } }, "node_modules/tsv-groupdata-parser": { - "version": "0.10.1", - "resolved": "https://registry.npmjs.org/tsv-groupdata-parser/-/tsv-groupdata-parser-0.10.1.tgz", - "integrity": "sha512-f5OVdAqon4vsI4Ja4pyT4j8kTNBiezvByOtApwfTax4GUFZQHvEVdoETHbW1qvuHzXAeGoohIdkO4sR+qchKOg==", + "version": "0.10.2", + "resolved": "https://registry.npmjs.org/tsv-groupdata-parser/-/tsv-groupdata-parser-0.10.2.tgz", + "integrity": "sha512-rLcplT7O/ZhGPMl50YXoSguaEAPVYbjz4s3MlpjcBPM5v/IWKpuOU06GOxIeYJGveUdhhNfqKs2AqZ7+72yLvg==", "dependencies": { "fs-extra": "^7.0.1", "ospath": "^1.2.2", @@ -45686,9 +45686,9 @@ } }, "tsv-groupdata-parser": { - "version": "0.10.1", - "resolved": "https://registry.npmjs.org/tsv-groupdata-parser/-/tsv-groupdata-parser-0.10.1.tgz", - "integrity": "sha512-f5OVdAqon4vsI4Ja4pyT4j8kTNBiezvByOtApwfTax4GUFZQHvEVdoETHbW1qvuHzXAeGoohIdkO4sR+qchKOg==", + "version": "0.10.2", + "resolved": "https://registry.npmjs.org/tsv-groupdata-parser/-/tsv-groupdata-parser-0.10.2.tgz", + "integrity": "sha512-rLcplT7O/ZhGPMl50YXoSguaEAPVYbjz4s3MlpjcBPM5v/IWKpuOU06GOxIeYJGveUdhhNfqKs2AqZ7+72yLvg==", "requires": { "fs-extra": "^7.0.1", "ospath": "^1.2.2", diff --git a/package.json b/package.json index 47b85632a8..a3ffcf3e1e 100644 --- a/package.json +++ b/package.json @@ -181,7 +181,7 @@ "tc-tool": "4.1.0", "tc-ui-toolkit": "6.0.0", "truncate-utf8-bytes": "1.0.2", - "tsv-groupdata-parser": "0.10.1", + "tsv-groupdata-parser": "0.10.2", "usfm-js": "3.3.1", "uuid": "3.2.1", "word-aligner": "1.0.0", From 4580664d49e928ffdf13313cdb843f04505a86c8 Mon Sep 17 00:00:00 2001 From: Bruce McLean Date: Mon, 10 Jan 2022 15:46:51 -0500 Subject: [PATCH 5/5] fix paths for finding needed original resources --- package-lock.json | 14 +++++++------- package.json | 2 +- src/js/helpers/ResourcesHelpers.js | 13 +++++++------ 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/package-lock.json b/package-lock.json index ad96da072a..3206470e8d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -71,7 +71,7 @@ "string-punctuation-tokenizer": "^2.2.0", "sudo-prompt": "6.2.1", "tc-electron-env": "0.9.0", - "tc-source-content-updater": "0.9.1-alpha.4", + "tc-source-content-updater": "0.9.1", "tc-strings": "0.1.7", "tc-tool": "4.1.0", "tc-ui-toolkit": "6.0.0", @@ -22903,9 +22903,9 @@ } }, "node_modules/tc-source-content-updater": { - "version": "0.9.1-alpha.4", - "resolved": "https://registry.npmjs.org/tc-source-content-updater/-/tc-source-content-updater-0.9.1-alpha.4.tgz", - "integrity": "sha512-o9+Jc7kRxJULGCj2DiMv7QrwKfI/EraSziT4t1HvWqYxUhfHO0MILzTan17LSoZ7nJZKt+ho2HcFFwO1TZH76A==", + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/tc-source-content-updater/-/tc-source-content-updater-0.9.1.tgz", + "integrity": "sha512-rUc6ueKKE/LicCnhGwvJgKn1vyonNMFm/VsiVj32zq5XVgex1o8i8Tl88Z090IceSxE9dvworLiFKkEHqenilQ==", "dependencies": { "adm-zip": "^0.4.11", "agentkeepalive": "4.1.0", @@ -45074,9 +45074,9 @@ } }, "tc-source-content-updater": { - "version": "0.9.1-alpha.4", - "resolved": "https://registry.npmjs.org/tc-source-content-updater/-/tc-source-content-updater-0.9.1-alpha.4.tgz", - "integrity": "sha512-o9+Jc7kRxJULGCj2DiMv7QrwKfI/EraSziT4t1HvWqYxUhfHO0MILzTan17LSoZ7nJZKt+ho2HcFFwO1TZH76A==", + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/tc-source-content-updater/-/tc-source-content-updater-0.9.1.tgz", + "integrity": "sha512-rUc6ueKKE/LicCnhGwvJgKn1vyonNMFm/VsiVj32zq5XVgex1o8i8Tl88Z090IceSxE9dvworLiFKkEHqenilQ==", "requires": { "adm-zip": "^0.4.11", "agentkeepalive": "4.1.0", diff --git a/package.json b/package.json index a3ffcf3e1e..6926b1a6e2 100644 --- a/package.json +++ b/package.json @@ -176,7 +176,7 @@ "string-punctuation-tokenizer": "^2.2.0", "sudo-prompt": "6.2.1", "tc-electron-env": "0.9.0", - "tc-source-content-updater": "0.9.1-alpha.4", + "tc-source-content-updater": "0.9.1", "tc-strings": "0.1.7", "tc-tool": "4.1.0", "tc-ui-toolkit": "6.0.0", diff --git a/src/js/helpers/ResourcesHelpers.js b/src/js/helpers/ResourcesHelpers.js index 4afacdc946..ad23f22a3e 100644 --- a/src/js/helpers/ResourcesHelpers.js +++ b/src/js/helpers/ResourcesHelpers.js @@ -1208,16 +1208,17 @@ export function moveResourcesFromOldGrcFolder() { /** * find out which Original Language Bible versions are needed by installed tNs. Only keep the needed versions. * The other versions are deleted. - * @param languageId - * @param resourceId - * @param resourcePath + * @param {string} languageId + * @param {string} resourceId + * @param {string} resourcePath - path for versions of current resource + * @param {string} resourcesPath - base path for all resources * @return {boolean} - returns true if all old resources can be deleted */ -export function preserveNeededOrigLangVersions(languageId, resourceId, resourcePath) { +export function preserveNeededOrigLangVersions(languageId, resourceId, resourcePath, resourcesPath) { let deleteOldResources = true; // by default we do not keep old versions of resources if (BibleHelpers.isOriginalLanguageBible(languageId, resourceId)) { - const requiredVersions = getOtherTnsOLVersions(resourcePath, resourceId).sort((a, b) => + const requiredVersions = getOtherTnsOLVersions(resourcesPath, resourceId).sort((a, b) => -ResourceAPI.compareVersions(a, b), // do inverted sort ); console.log('preserveNeededOrigLangVersions: requiredVersions', requiredVersions); @@ -1310,7 +1311,7 @@ export function getMissingResources() { isOldResource = true; } - const deleteOldResources = preserveNeededOrigLangVersions(languageId, resourceId, userResourcePath); + const deleteOldResources = preserveNeededOrigLangVersions(languageId, resourceId, userResourcePath, USER_RESOURCES_PATH); if (isOldResource) { console.log(`getMissingResources() - checking ${languageId} ${resourceId} - old resource found`);