@enplug/scripts 1.11.4-dev50 → 1.11.4-dev51
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.
|
@@ -126,7 +126,7 @@ async function findCrowdinAppDirectoryId(credentials, crowdinPath, appName) {
|
|
|
126
126
|
if (err.response.status === HTTP_UNAUTHORIZED_STATUS_CODE) {
|
|
127
127
|
console.error(`\n${chalk.red.bold('Provided Crowdin token is invalid')}`);
|
|
128
128
|
console.log(`Check the ${chalk.default.yellow('dev.private.json')} file.`);
|
|
129
|
-
return;
|
|
129
|
+
return throwError(err);
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
}
|
|
@@ -198,17 +198,8 @@ async function updateCrowdinFile(credentials, crowdinPath, storageId, fileId) {
|
|
|
198
198
|
},
|
|
199
199
|
error: error => {
|
|
200
200
|
const crowdinError = error.response && error.response.data && error.response.data.error;
|
|
201
|
-
|
|
202
|
-
|
|
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
|
-
}
|
|
201
|
+
console.error('\nUnexpected error:');
|
|
202
|
+
console.error(error);
|
|
212
203
|
}
|
|
213
204
|
})).toPromise();
|
|
214
205
|
}
|
|
@@ -66,8 +66,9 @@ async function syncTranslations(s3Client, bucket) {
|
|
|
66
66
|
const appName = crowdinPathSections[1];
|
|
67
67
|
const appDirectoryId = await findCrowdinAppDirectoryId(credentials, crowdinPath, appName);
|
|
68
68
|
if(appDirectoryId === undefined) {
|
|
69
|
-
console.
|
|
70
|
-
|
|
69
|
+
console.error(`\n${chalk.red.bold('Directory does not exist')} ${chalk.yellow.bold(`[${appName}]`)}`);
|
|
70
|
+
console.log('Create the directory in the Crowdin panel first.');
|
|
71
|
+
return;
|
|
71
72
|
}
|
|
72
73
|
if(crowdinPathSections[0] === 'apps' && appDirectoryId) {
|
|
73
74
|
if(crowdinPathSections.length !== 4 && crowdinPathSections[3] !== 'en.json') {
|
|
@@ -87,9 +88,18 @@ async function syncTranslations(s3Client, bucket) {
|
|
|
87
88
|
} else {
|
|
88
89
|
//TODO add file
|
|
89
90
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
} else if(crowdinPathSections[0] === 'dashboard' && appDirectoryId) {
|
|
92
|
+
if(crowdinPathSections[1] === 'en.json') {
|
|
93
|
+
const fileId = await getFileIdIfExists(credentials, appDirectoryId, crowdinPathSections[1]); // en.json file id to update
|
|
94
|
+
if(fileId) {
|
|
95
|
+
const storageId = await uploadFileToCrowdinStorage(credentials, config.localPath);
|
|
96
|
+
if(fileId && storageId) {
|
|
97
|
+
const response = await updateCrowdinFile(credentials, crowdinPath, storageId.data.data.id, fileId);
|
|
98
|
+
}
|
|
99
|
+
} else {
|
|
100
|
+
console.error(`Could not upload ${chalk.yellow.bold(`[${rowdinPathSections[1]}]`)}. Only en.json supported.`);
|
|
101
|
+
}
|
|
102
|
+
} // TODO else for data-connector, regions-map and uploader
|
|
93
103
|
}
|
|
94
104
|
// await uploadFileToCrowdin(credentials, config.crowdinPath, config.localPath);
|
|
95
105
|
// const { data: fakeTranslation } = await fetchFileFromCrowdin(credentials, config.crowdinPath, FAKE_IN_CONTEXT_LANGUAGE);
|