@enplug/scripts 1.11.4-dev41 → 1.11.4-dev42

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.
@@ -162,11 +162,11 @@ async function uploadFileToCrowdinStorage(credentials, crowdinPath, localPath) {
162
162
  catchError(error => {
163
163
  console('ERROR could not upload file to crowdin storage')
164
164
  return throwError(error);
165
- })
165
+ }),
166
166
  ).toPromise();
167
167
  }
168
168
 
169
- function updateCrowdinFile(credentials, storageId, fileId) {
169
+ async function updateCrowdinFile(credentials, storageId, fileId) {
170
170
  console.log('fileId', fileId);
171
171
  const url = `${CROWDIN_PROJECT_URL}/files/${fileId}`;
172
172
  const AuthStr = 'Bearer '.concat(credentials.token);
@@ -182,32 +182,30 @@ function updateCrowdinFile(credentials, storageId, fileId) {
182
182
  },
183
183
  "replaceModifiedContext": false
184
184
  }
185
- return from(axios.put(url, body, { headers: { Authorization: AuthStr } })).pipe(
186
- tap({
187
- next: response => {
188
- if (response.data) {
189
- console.log(`${chalk.green.bold('Translations uploaded to Crowdin')} ${chalk.yellow.bold(`[${crowdinPath}]`)}`);
190
- } else {
191
- console.error('Unexpected result');
192
- console.log(response);
193
- }
194
- },
195
- error: error => {
196
- const crowdinError = error.response && error.response.data && error.response.data.error;
197
-
198
- if (crowdinError && crowdinError.code === CROWDIN_DIRECTORY_NOT_FOUND_ERROR_CODE) {
199
- console.error(`\n${chalk.red.bold('Directory does not exist')} ${chalk.yellow.bold(`[${crowdinPath}]`)}`);
200
- console.log('Create the directory in the Crowdin panel first.');
201
- } else if (error.response.status === HTTP_UNAUTHORIZED_STATUS_CODE) {
202
- console.error(`\n${chalk.red.bold('Provided Crowdin credentials are incorrect')}`);
203
- console.log(`Check the ${chalk.default.yellow('dev.private.json')} file.`);
204
- } else {
205
- console.error('\nUnexpected error:');
206
- console.error(error);
207
- }
185
+ return from(axios.put(url, body, { headers: { Authorization: AuthStr } })).pipe(tap({
186
+ next: response => {
187
+ if (response.data) {
188
+ console.log(`${chalk.green.bold('Translations uploaded to Crowdin')} ${chalk.yellow.bold(`[${crowdinPath}]`)}`);
189
+ } else {
190
+ console.error('Unexpected result');
191
+ console.log(response);
208
192
  }
209
- })
210
- );
193
+ },
194
+ error: error => {
195
+ const crowdinError = error.response && error.response.data && error.response.data.error;
196
+
197
+ if (crowdinError && crowdinError.code === CROWDIN_DIRECTORY_NOT_FOUND_ERROR_CODE) {
198
+ console.error(`\n${chalk.red.bold('Directory does not exist')} ${chalk.yellow.bold(`[${crowdinPath}]`)}`);
199
+ console.log('Create the directory in the Crowdin panel first.');
200
+ } else if (error.response.status === HTTP_UNAUTHORIZED_STATUS_CODE) {
201
+ console.error(`\n${chalk.red.bold('Provided Crowdin credentials are incorrect')}`);
202
+ console.log(`Check the ${chalk.default.yellow('dev.private.json')} file.`);
203
+ } else {
204
+ console.error('\nUnexpected error:');
205
+ console.error(error);
206
+ }
207
+ }
208
+ })).toPromise();
211
209
  }
212
210
 
213
211
  function fetchFileFromCrowdin(credentials, crowdinPath, language) {
@@ -80,9 +80,10 @@ async function syncTranslations(s3Client, bucket) {
80
80
  }
81
81
  const fileId = await getFileIdIfExists(credentials, folderId, crowdinPathSections[3]); // en.json file id to update
82
82
  if(fileId) {
83
- const storageId = await uploadFileToCrowdinStorage(credentials, crowdiPath, config.localPath);
83
+ const storageId = await uploadFileToCrowdinStorage(credentials, config.localPath);
84
84
  if(fileId && storageId) {
85
- updateCrowdinFile(credentials, storageId.data.data.id, fileId);
85
+ const response = updateCrowdinFile(credentials, storageId.data.data.id, fileId);
86
+ console.log('response', response);
86
87
  }
87
88
  } else {
88
89
  //TODO add file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enplug/scripts",
3
- "version": "1.11.4-dev41",
3
+ "version": "1.11.4-dev42",
4
4
  "description": "Enplug scripts",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",