@enplug/scripts 1.11.4-dev11 → 1.11.4-dev13

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.
@@ -118,7 +118,7 @@ function generateFormData(crowdinPath, localPath) {
118
118
  return formData;
119
119
  }
120
120
 
121
- function postFileToCrowdin(operation, credentials, crowdinPath, localPath) {
121
+ function postFileToCrowdin(credentials, crowdinPath, localPath) {
122
122
  const AuthStr = 'Bearer '.concat(credentials.token);
123
123
  const formData = generateFormData(crowdinPath, localPath);
124
124
 
@@ -158,11 +158,9 @@ async function findCrowdinAppSubFolderId(credentials, directoryId, subfolderName
158
158
  }
159
159
 
160
160
  async function getFileIdIfExists(credentials, directoryId, fileName) {
161
- console.log('fileName', fileName);
162
161
  const url = `${CROWDIN_PROJECT_URL}/files?directoryId=${directoryId}`;
163
162
  const AuthStr = 'Bearer '.concat(credentials.token);
164
163
  const resp = await axios.get(url, { headers: { Authorization: AuthStr } });
165
- console.log('resp', resp);
166
164
  const file = resp.data.data.find(d => d.data.name === fileName);
167
165
  console.log('file found', file);
168
166
  return file.data.id;
@@ -174,20 +172,21 @@ async function uploadFileToCrowdinStorage(credentials, crowdinPath, localPath) {
174
172
  throw new Error('Local file does not exist');
175
173
  }
176
174
 
177
- return postFileToCrowdin('update', credentials, crowdinPath, localPath).pipe(
175
+ return postFileToCrowdin(credentials, crowdinPath, localPath).pipe(
178
176
  catchError(error => {
179
- if (error.response.status === HTTP_NOT_FOUND_STATUS_CODE) {
180
- return promptAddFile(crowdinPath).pipe(
181
- filter(({addFileConfirm}) => addFileConfirm === true),
182
- switchMap(() => postFileToCrowdin('add', credentials, crowdinPath, localPath))
183
- );
184
- }
185
-
177
+ // if (error.response.status === HTTP_NOT_FOUND_STATUS_CODE) {
178
+ // return promptAddFile(crowdinPath).pipe(
179
+ // filter(({addFileConfirm}) => addFileConfirm === true),
180
+ // switchMap(() => postFileToCrowdin(credentials, crowdinPath, localPath))
181
+ // );
182
+ // }
183
+ console('ERROR could not upload file to crowdin storage')
186
184
  return throwError(error);
187
185
  }),
188
186
  tap({
189
187
  next: response => {
190
188
  if (response.data) {
189
+ console.log('response.data', response.data);
191
190
  console.log(`${chalk.green.bold('Translations uploaded to Crowdin')} ${chalk.yellow.bold(`[${crowdinPath}]`)}`);
192
191
  } else {
193
192
  console.error('Unexpected result');
@@ -62,17 +62,16 @@ async function syncTranslations(s3Client, bucket) {
62
62
 
63
63
  if (isProduction) {
64
64
  const appDirectoryId = await findCrowdinAppDirectoryId(credentials, config.crowdinPath);
65
- console.log('found directoryId', appDirectoryId);
66
65
  if(config.crowdinPath.includes('apps')) {
67
66
  const path = config.crowdinPath.startsWith('/') ? config.crowdinPath.substr(1) : config.crowdinPath;
68
67
  const subfolderName = path.split('/')[2];
69
68
  const folderId = await findCrowdinAppSubFolderId(credentials, appDirectoryId, subfolderName);
70
- console.log('found folderId', folderId);
71
- const fileId = await getFileIdIfExists(credentials, appDirectoryId, path.split('/')[3]);
69
+ const fileId = await getFileIdIfExists(credentials, folderId, path.split('/')[3]);
72
70
  console.log('found fileId', fileId);
73
71
  const storageId = await uploadFileToCrowdinStorage(credentials, config.crowdinPath, config.localPath)
72
+ console.log('storageId', storageId);
74
73
  if(fileId) {
75
- await updateCrowdinFile(credentials, storageId, fileId);
74
+ await updateCrowdinFile(credentials, storageId.data.id, fileId);
76
75
  }
77
76
  } else {
78
77
  // TODO Update dashboard transtlations file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enplug/scripts",
3
- "version": "1.11.4-dev11",
3
+ "version": "1.11.4-dev13",
4
4
  "description": "Enplug scripts",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",