@enplug/scripts 1.11.4-dev58 → 1.11.4-dev59

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.
@@ -238,16 +238,15 @@ async function addCrowdinFile(credentials, crowdinPath, storageId, folderId) {
238
238
  })).toPromise();
239
239
  }
240
240
 
241
- function fetchFileFromCrowdin(credentials, crowdinPath, language) {
242
- const url = `${CROWDIN_PROJECT_URL}/export-file`;
243
- const params = {
244
- 'login': credentials.login,
245
- 'account-key': credentials.accountKey,
246
- 'file': crowdinPath,
247
- 'language': language
241
+ function fetchFileFromCrowdin(credentials, language, fileId) {
242
+ const url = `${CROWDIN_PROJECT_URL}/translations/exports`;
243
+ const AuthStr = 'Bearer '.concat(credentials.token);
244
+ const body = {
245
+ "targetLanguageId": language,
246
+ "fileIds": [fileId]
248
247
  };
249
248
 
250
- return axios.get(url, { params });
249
+ return axios.post(url, body, { headers: { Authorization: AuthStr } });
251
250
  }
252
251
 
253
252
  function promptAddFile(crowdinPath) {
@@ -84,12 +84,13 @@ async function syncTranslations(s3Client, bucket) {
84
84
  if(fileId) {
85
85
  const storageId = await uploadFileToCrowdinStorage(credentials, config.localPath);
86
86
  if(fileId && storageId) {
87
- updateCrowdinFile(credentials, crowdinPath, storageId.data.data.id, fileId);
87
+ await updateCrowdinFile(credentials, crowdinPath, storageId.data.data.id, fileId);
88
88
  }
89
89
  } else {
90
90
  const storageId = await uploadFileToCrowdinStorage(credentials, config.localPath);
91
91
  if(storageId) {
92
- addCrowdinFile(credentials, crowdinPath, storageId.data.data.id, folderId);
92
+ const result = await addCrowdinFile(credentials, crowdinPath, storageId.data.data.id, folderId);
93
+ console.log('add result', result.data);
93
94
  }
94
95
  }
95
96
  } else if((crowdinPathSections[0] === 'dashboard' || crowdinPathSections[0] === 'player-web' || crowdinPathSections[0] === 'components') && appDirectoryId) {
@@ -98,7 +99,7 @@ async function syncTranslations(s3Client, bucket) {
98
99
  if(fileId) {
99
100
  const storageId = await uploadFileToCrowdinStorage(credentials, config.localPath);
100
101
  if(fileId && storageId) {
101
- updateCrowdinFile(credentials, crowdinPath, storageId.data.data.id, fileId);
102
+ await updateCrowdinFile(credentials, crowdinPath, storageId.data.data.id, fileId);
102
103
  }
103
104
  } else {
104
105
  console.error(`Could not upload ${chalk.yellow.bold(`${rowdinPathSections[1]}`)}. Only en.json supported.`);
@@ -111,15 +112,16 @@ async function syncTranslations(s3Client, bucket) {
111
112
  const fileId = await getFileIdIfExists(credentials, folderId, crowdinPathSections[2]); // en.json file id to update
112
113
  const storageId = await uploadFileToCrowdinStorage(credentials, config.localPath);
113
114
  if(fileId && storageId) {
114
- updateCrowdinFile(credentials, crowdinPath, storageId.data.data.id, fileId);
115
+ await updateCrowdinFile(credentials, crowdinPath, storageId.data.data.id, fileId);
115
116
  }
116
117
  }
117
118
  }
118
- // await uploadFileToCrowdin(credentials, config.crowdinPath, config.localPath);
119
- // const { data: fakeTranslation } = await fetchFileFromCrowdin(credentials, config.crowdinPath, FAKE_IN_CONTEXT_LANGUAGE);
120
-
121
- // const s3TranslationsPath = path.parse(s3EnPath).dir;
122
- // const s3FakeTranslationPath = path.join(s3TranslationsPath, FAKE_IN_CONTEXT_LANGUAGE_FILE);
119
+ const { data: fakeTranslation } = await fetchFileFromCrowdin(credentials, FAKE_IN_CONTEXT_LANGUAGE, fileId);
120
+ console.log('eo data', fakeTranslation);
121
+ const s3TranslationsPath = path.parse(s3EnPath).dir;
122
+ console.log('s3TranslationsPath', s3TranslationsPath);
123
+ const s3FakeTranslationPath = path.join(s3TranslationsPath, FAKE_IN_CONTEXT_LANGUAGE_FILE);
124
+ console.log('s3FakeTranslationPath', s3FakeTranslationPath);
123
125
 
124
126
  // await uploadTranslationToS3(s3Client, bucket, s3FakeTranslationPath, JSON.stringify(fakeTranslation));
125
127
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enplug/scripts",
3
- "version": "1.11.4-dev58",
3
+ "version": "1.11.4-dev59",
4
4
  "description": "Enplug scripts",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",