@enplug/scripts 1.11.4-dev24 → 1.11.4-dev26

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.
@@ -112,26 +112,26 @@ function generateFormData(crowdinPath, localPath) {
112
112
  // const reader = new FileReader();
113
113
  const formData = new FormData();
114
114
  console.log('localPath', localPath);
115
- // const file = await fs.readFile(localPath);
116
- // console.log('file', file);
115
+ const file = fs.readFile(localPath);
116
+ console.log('file', file);
117
117
  // formData.append('update_option', 'update_without_changes'); // Previous translations should remain valid
118
118
  // formData.append('json', '');
119
- formData.append('file', fs.readFile(localPath), 'en.json');
119
+ formData.append('file', file, 'en.json');
120
120
  // formData.append(`export_patterns[${crowdinPath}]`, '%locale%.json');
121
121
  return formData;
122
122
  }
123
123
 
124
- function postFileToCrowdin(credentials, crowdinPath, localPath) {
124
+ function postFileToCrowdin(credentials, crowdinPath, localPath) {
125
125
  const AuthStr = 'Bearer '.concat(credentials.token);
126
126
  const formData = generateFormData(crowdinPath, localPath);
127
127
 
128
128
  const url = `${CROWDIN_STORAGE_URL}`;
129
-
130
- return from(axios.post(url, formData, { headers: {
129
+ console.log('formData', formData);
130
+ return axios.post(url, formData, { headers: {
131
131
  "Authorization": AuthStr,
132
132
  "Content-Type": "application/json",
133
133
  "Crowdin-API-FileName": "en.json"
134
- } }));
134
+ } });
135
135
  }
136
136
 
137
137
  async function findCrowdinAppDirectoryId(credentials, crowdinPath) {
@@ -174,42 +174,44 @@ async function uploadFileToCrowdinStorage(credentials, crowdinPath, localPath) {
174
174
  throw new Error('Local file does not exist');
175
175
  }
176
176
 
177
- return postFileToCrowdin(credentials, crowdinPath, localPath).pipe(
178
- 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(credentials, crowdinPath, localPath))
183
- // );
184
- // }
185
- console('ERROR could not upload file to crowdin storage')
186
- return throwError(error);
187
- }),
188
- tap({
189
- next: response => {
190
- if (response.data) {
191
- console.log(`${chalk.green.bold('Translations uploaded to Crowdin')} ${chalk.yellow.bold(`[${crowdinPath}]`)}`);
192
- } else {
193
- console.error('Unexpected result');
194
- console.log(response);
195
- }
196
- },
197
- error: error => {
198
- const crowdinError = error.response && error.response.data && error.response.data.error;
177
+ const response = await postFileToCrowdin(credentials, crowdinPath, localPath)
178
+ return response
179
+ // return postFileToCrowdin(credentials, crowdinPath, localPath).pipe(
180
+ // catchError(error => {
181
+ // // if (error.response.status === HTTP_NOT_FOUND_STATUS_CODE) {
182
+ // // return promptAddFile(crowdinPath).pipe(
183
+ // // filter(({addFileConfirm}) => addFileConfirm === true),
184
+ // // switchMap(() => postFileToCrowdin(credentials, crowdinPath, localPath))
185
+ // // );
186
+ // // }
187
+ // console('ERROR could not upload file to crowdin storage')
188
+ // return throwError(error);
189
+ // }),
190
+ // tap({
191
+ // next: response => {
192
+ // if (response.data) {
193
+ // console.log(`${chalk.green.bold('Translations uploaded to Crowdin')} ${chalk.yellow.bold(`[${crowdinPath}]`)}`);
194
+ // } else {
195
+ // console.error('Unexpected result');
196
+ // console.log(response);
197
+ // }
198
+ // },
199
+ // error: error => {
200
+ // const crowdinError = error.response && error.response.data && error.response.data.error;
199
201
 
200
- if (crowdinError && crowdinError.code === CROWDIN_DIRECTORY_NOT_FOUND_ERROR_CODE) {
201
- console.error(`\n${chalk.red.bold('Directory does not exist')} ${chalk.yellow.bold(`[${crowdinPath}]`)}`);
202
- console.log('Create the directory in the Crowdin panel first.');
203
- } else if (error.response.status === HTTP_UNAUTHORIZED_STATUS_CODE) {
204
- console.error(`\n${chalk.red.bold('Provided Crowdin credentials are incorrect')}`);
205
- console.log(`Check the ${chalk.default.yellow('dev.private.json')} file.`);
206
- } else {
207
- console.error('\nUnexpected error:');
208
- console.error(error);
209
- }
210
- }
211
- })
212
- ).toPromise();
202
+ // if (crowdinError && crowdinError.code === CROWDIN_DIRECTORY_NOT_FOUND_ERROR_CODE) {
203
+ // console.error(`\n${chalk.red.bold('Directory does not exist')} ${chalk.yellow.bold(`[${crowdinPath}]`)}`);
204
+ // console.log('Create the directory in the Crowdin panel first.');
205
+ // } else if (error.response.status === HTTP_UNAUTHORIZED_STATUS_CODE) {
206
+ // console.error(`\n${chalk.red.bold('Provided Crowdin credentials are incorrect')}`);
207
+ // console.log(`Check the ${chalk.default.yellow('dev.private.json')} file.`);
208
+ // } else {
209
+ // console.error('\nUnexpected error:');
210
+ // console.error(error);
211
+ // }
212
+ // }
213
+ // })
214
+ // ).toPromise();
213
215
  }
214
216
 
215
217
  function updateCrowdinFile(credentials, storageId, fileId) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enplug/scripts",
3
- "version": "1.11.4-dev24",
3
+ "version": "1.11.4-dev26",
4
4
  "description": "Enplug scripts",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",