How to use tc-source-content-updater - 3 common examples

To help you get started, we’ve selected a few tc-source-content-updater examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github unfoldingWord / translationCore / src / js / helpers / ResourcesHelpers.js View on Github external
export function preserveNeededOrigLangVersions(languageId, resourceId, resourcePath) {
  let deleteOldResources = true; // by default we do not keep old versions of resources

  if (BibleHelpers.isOriginalLanguageBible(languageId, resourceId)) {
    const requiredVersions = getOtherTnsOLVersions(resourceId).sort((a, b) =>
      -ResourceAPI.compareVersions(a, b) // do inverted sort
    );
    console.log('preserveNeededOrigLangVersions: requiredVersions', requiredVersions);

    // see if we need to keep old versions of original language
    if (requiredVersions && requiredVersions.length) {
      deleteOldResources = false;
      const highestRequired = requiredVersions[0];
      const versions = ResourceAPI.listVersions(resourcePath);
      console.log('preserveNeededOrigLangVersions: versions', versions);

      for (let version of versions) {
        if (!requiredVersions.includes(version)) {
          const newerResource = ResourceAPI.compareVersions(version, highestRequired) > 0;

          if (!newerResource) { // don't delete if newer version
github unfoldingWord / translationCore / src / js / actions / SourceContentUpdatesActions.js View on Github external
import sourceContentUpdater from 'tc-source-content-updater';
import {
  getTranslate, getContext, getSelectedToolName, getProjectSaveLocation, getProjectBookId,
} from '../selectors';
// helpers
import { getLocalResourceList } from '../helpers/sourceContentUpdatesHelpers';
import { copyGroupDataToProject, updateSourceContentUpdaterManifest } from '../helpers/ResourcesHelpers';
import { getOrigLangforBook } from '../helpers/bibleHelpers';
import * as Bible from '../common/BooksOfTheBible';
import { loadBookTranslations } from './ResourcesActions';
import {
  openAlertDialog, closeAlertDialog, openOptionDialog,
} from './AlertModalActions';
import consts from './ActionTypes';
// constants
const SourceContentUpdater = new sourceContentUpdater();
const USER_RESOURCES_PATH = path.join(ospath.home(), 'translationCore/resources');

/**
 * Resets the state of the source content updates reducer.
 */
export const resetSourceContentUpdatesReducer = () => ({ type: consts.RESET_LIST_OF_SOURCE_CONTENT_TO_UPDATE });

export const updateSourceContentUpdatesReducer = () => ({ type: consts.SOURCE_CONTENT_UPDATED });

const failedAlertAndRetry = (closeSourceContentDialog, retryCallback, failAlertMessage) => ((dispatch, getState) => {
  const translate = getTranslate(getState());

  dispatch(
    openOptionDialog(
      translate(failAlertMessage),
      () => dispatch(retryCallback()),
github unfoldingWord / translationCore / scripts / resources / updateResources.js View on Github external
const updateResources = async (languages, resourcesPath) => {
  const SourceContentUpdater = new sourceContentUpdater();
  const localResourceList = updateResourcesHelpers.getLocalResourceList(resourcesPath);
  await SourceContentUpdater.getLatestResources(localResourceList)
    .then(async () => {
      await SourceContentUpdater.downloadResources(languages, resourcesPath)
      .then(resources => {
        resources.forEach(resource => {
          console.log("Updated resource '" + resource.resourceId + "' for language '" + resource.languageId + "' to v" + resource.version);
        });
      })
      .catch(err => {
        console.error(err);
      });
    });
};

tc-source-content-updater

Module that updates source content for the desktop application translationCore.

MIT
Latest version published 18 days ago

Package Health Score

64 / 100
Full package analysis