@enplug/scripts 1.11.4-dev69 → 1.11.4-dev70

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,57 +17,6 @@ const HTTP_NOT_FOUND_STATUS_CODE = 404;
17
17
  const CROWDIN_PROJECT_ID = '401630';
18
18
  const CROWDIN_PROJECT_URL = `https://api.crowdin.com/api/v2/projects/${CROWDIN_PROJECT_ID}`;
19
19
  const CROWDIN_STORAGE_URL = `https://api.crowdin.com/api/v2/storages`;
20
- const CROWDIN_DIRECTORY_NOT_FOUND_ERROR_CODE = 17;
21
-
22
- async function uploadFileToCrowdin(credentials, crowdinPath, localPath) {
23
- if (!credentials || !credentials.login || !credentials.accountKey) {
24
- console.error(`${chalk.red.bold('Crowdin credentials not provided')}`);
25
- console.log(`Make sure that the ${chalk.default.yellow('dev.private.json')} file contains ${chalk.default.yellow('crowdinCredentials: { login, accountKey }')}`);
26
- throw new Error('Crowdin credentials not provided');
27
- }
28
-
29
- if (!fs.existsSync(localPath)) {
30
- console.error(`${chalk.red.bold('Local file does not exists')} ${chalk.yellow.bold(`[${localPath}]`)}`);
31
- throw new Error('Local file does not exist');
32
- }
33
-
34
- return postFileToCrowdin('update', credentials, crowdinPath, localPath).pipe(
35
- catchError(error => {
36
- if (error.response.status === HTTP_NOT_FOUND_STATUS_CODE) {
37
- return promptAddFile(crowdinPath).pipe(
38
- filter(({addFileConfirm}) => addFileConfirm === true),
39
- switchMap(() => postFileToCrowdin('add', credentials, crowdinPath, localPath))
40
- );
41
- }
42
-
43
- return throwError(error);
44
- }),
45
- tap({
46
- next: response => {
47
- if (response.data.success) {
48
- console.log(`${chalk.green.bold('Translations uploaded to Crowdin')} ${chalk.yellow.bold(`[${crowdinPath}]`)}`);
49
- } else {
50
- console.error('Unexpected result');
51
- console.log(response);
52
- }
53
- },
54
- error: error => {
55
- const crowdinError = error.response && error.response.data && error.response.data.error;
56
-
57
- if (crowdinError && crowdinError.code === CROWDIN_DIRECTORY_NOT_FOUND_ERROR_CODE) {
58
- console.error(`\n${chalk.red.bold('Directory does not exist')} ${chalk.yellow.bold(`[${crowdinPath}]`)}`);
59
- console.log('Create the directory in the Crowdin panel first.');
60
- } else if (error.response.status === HTTP_UNAUTHORIZED_STATUS_CODE) {
61
- console.error(`\n${chalk.red.bold('Provided Crowdin credentials are incorrect')}`);
62
- console.log(`Check the ${chalk.default.yellow('dev.private.json')} file.`);
63
- } else {
64
- console.error('\nUnexpected error:');
65
- console.error(error);
66
- }
67
- }
68
- })
69
- ).toPromise();
70
- }
71
20
 
72
21
  function getCrowdinCredentials() {
73
22
  try {
@@ -263,4 +212,4 @@ function promptAddFile(crowdinPath) {
263
212
  }));
264
213
  }
265
214
 
266
- module.exports = { getCrowdinCredentials, getCrowdinConfig, findCrowdinAppDirectoryId, findCrowdinAppSubFolderId, getFileIdIfExists, uploadFileToCrowdinStorage, updateCrowdinFile, addCrowdinFile, uploadFileToCrowdin, fetchFileFromCrowdin, readFakeTranslationsFile };
215
+ module.exports = { getCrowdinCredentials, getCrowdinConfig, findCrowdinAppDirectoryId, findCrowdinAppSubFolderId, getFileIdIfExists, uploadFileToCrowdinStorage, updateCrowdinFile, addCrowdinFile, fetchFileFromCrowdin, readFakeTranslationsFile };
@@ -5,7 +5,7 @@ const inquirer = require('inquirer');
5
5
  const fs = require('fs');
6
6
  const path = require('path');
7
7
 
8
- const { getCrowdinCredentials, getCrowdinConfig, findCrowdinAppDirectoryId, findCrowdinAppSubFolderId, getFileIdIfExists, uploadFileToCrowdinStorage, updateCrowdinFile, addCrowdinFile, uploadFileToCrowdin, fetchFileFromCrowdin, readFakeTranslationsFile } = require('./crowdin');
8
+ const { getCrowdinCredentials, getCrowdinConfig, findCrowdinAppDirectoryId, findCrowdinAppSubFolderId, getFileIdIfExists, uploadFileToCrowdinStorage, updateCrowdinFile, addCrowdinFile, fetchFileFromCrowdin, readFakeTranslationsFile } = require('./crowdin');
9
9
  const { checkKeys, validateTranslationFile } = require('./transloco');
10
10
  const { uploadTranslationToS3 } = require('./translation-s3');
11
11
  const getPackageJson = require('../getPackageJson');
@@ -91,8 +91,7 @@ async function syncTranslations(s3Client, bucket) {
91
91
  const storageId = await uploadFileToCrowdinStorage(credentials, config.localPath);
92
92
  if(storageId) {
93
93
  const result = await addCrowdinFile(credentials, crowdinPath, storageId.data.data.id, folderId);
94
- console.log('add result', result.data);
95
- // await updateFrakeTranslations(credentials, fileId, s3EnPath, s3Client, bucket);
94
+ await updateFrakeTranslations(credentials, result.data.data.id, s3EnPath, s3Client, bucket);
96
95
  }
97
96
  }
98
97
  } else if((crowdinPathSections[0] === 'dashboard' || crowdinPathSections[0] === 'player-web' || crowdinPathSections[0] === 'components') && appDirectoryId) {
@@ -127,11 +126,8 @@ async function syncTranslations(s3Client, bucket) {
127
126
 
128
127
  async function updateFrakeTranslations(credentials, fileId, s3EnPath, s3Client, bucket) {
129
128
  const { data: fakeTranslationUrl } = await fetchFileFromCrowdin(credentials, FAKE_IN_CONTEXT_LANGUAGE, fileId);
130
- console.log('eo data', fakeTranslationUrl);
131
129
  const s3TranslationsPath = path.parse(s3EnPath).dir;
132
- console.log('s3TranslationsPath', s3TranslationsPath);
133
130
  const s3FakeTranslationPath = path.join(s3TranslationsPath, FAKE_IN_CONTEXT_LANGUAGE_FILE);
134
- console.log('s3FakeTranslationPath', s3FakeTranslationPath);
135
131
  const fakeTranslation = await readFakeTranslationsFile(fakeTranslationUrl.data.url);
136
132
  console.log('fakeTranslation', fakeTranslation.data);
137
133
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enplug/scripts",
3
- "version": "1.11.4-dev69",
3
+ "version": "1.11.4-dev70",
4
4
  "description": "Enplug scripts",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",