@enplug/scripts 1.11.4-dev39 → 1.11.4-dev40
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.
|
@@ -158,14 +158,31 @@ async function uploadFileToCrowdinStorage(credentials, crowdinPath, localPath) {
|
|
|
158
158
|
console.error(`${chalk.red.bold('Local file does not exists')} ${chalk.yellow.bold(`[${localPath}]`)}`);
|
|
159
159
|
throw new Error('Local file does not exist');
|
|
160
160
|
}
|
|
161
|
-
|
|
162
|
-
// const response = await postFileToCrowdin(credentials, crowdinPath, localPath)
|
|
163
|
-
// return response
|
|
164
161
|
return postFileToCrowdin(credentials, localPath).pipe(
|
|
165
162
|
catchError(error => {
|
|
166
163
|
console('ERROR could not upload file to crowdin storage')
|
|
167
164
|
return throwError(error);
|
|
168
|
-
})
|
|
165
|
+
})
|
|
166
|
+
).toPromise();
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function updateCrowdinFile(credentials, storageId, fileId) {
|
|
170
|
+
console.log('fileId', fileId);
|
|
171
|
+
const url = `${CROWDIN_PROJECT_URL}/files/${fileId}`;
|
|
172
|
+
const AuthStr = 'Bearer '.concat(credentials.token);
|
|
173
|
+
const body = {
|
|
174
|
+
"storageId": storageId,
|
|
175
|
+
"updateOption": "keep_translations_and_approvals",
|
|
176
|
+
"importOptions": {
|
|
177
|
+
"contentSegmentation": false,
|
|
178
|
+
"customSegmentation": false
|
|
179
|
+
},
|
|
180
|
+
"exportOptions": {
|
|
181
|
+
"exportPattern": "%locale%.json"
|
|
182
|
+
},
|
|
183
|
+
"replaceModifiedContext": false
|
|
184
|
+
}
|
|
185
|
+
return axios.put(url, body, { headers: { Authorization: AuthStr } }).pipe(
|
|
169
186
|
tap({
|
|
170
187
|
next: response => {
|
|
171
188
|
if (response.data) {
|
|
@@ -190,27 +207,7 @@ async function uploadFileToCrowdinStorage(credentials, crowdinPath, localPath) {
|
|
|
190
207
|
}
|
|
191
208
|
}
|
|
192
209
|
})
|
|
193
|
-
)
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
function updateCrowdinFile(credentials, storageId, fileId) {
|
|
197
|
-
console.log('storageId', storageId);
|
|
198
|
-
console.log('fileId', fileId);
|
|
199
|
-
const url = `${CROWDIN_PROJECT_URL}/files/${fileId}`;
|
|
200
|
-
const AuthStr = 'Bearer '.concat(credentials.token);
|
|
201
|
-
const body = {
|
|
202
|
-
"storageId": storageId,
|
|
203
|
-
"updateOption": "keep_translations_and_approvals",
|
|
204
|
-
"importOptions": {
|
|
205
|
-
"contentSegmentation": false,
|
|
206
|
-
"customSegmentation": false
|
|
207
|
-
},
|
|
208
|
-
"exportOptions": {
|
|
209
|
-
"exportPattern": "%locale%.json"
|
|
210
|
-
},
|
|
211
|
-
"replaceModifiedContext": false
|
|
212
|
-
}
|
|
213
|
-
return axios.put(url, body, { headers: { Authorization: AuthStr } });
|
|
210
|
+
);
|
|
214
211
|
}
|
|
215
212
|
|
|
216
213
|
function fetchFileFromCrowdin(credentials, crowdinPath, language) {
|
|
@@ -82,8 +82,7 @@ async function syncTranslations(s3Client, bucket) {
|
|
|
82
82
|
if(fileId) {
|
|
83
83
|
const storageId = await uploadFileToCrowdinStorage(credentials, crowdiPath, config.localPath);
|
|
84
84
|
if(fileId && storageId) {
|
|
85
|
-
|
|
86
|
-
console.log('response', response.data);
|
|
85
|
+
await updateCrowdinFile(credentials, storageId.data.data.id, fileId);
|
|
87
86
|
}
|
|
88
87
|
} else {
|
|
89
88
|
//TODO add file
|