@enplug/scripts 1.11.4-dev57 → 1.11.4-dev58
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.
|
@@ -109,19 +109,19 @@ function getCrowdinConfig() {
|
|
|
109
109
|
|
|
110
110
|
async function findCrowdinAppDirectoryId(credentials, crowdinPath, appName) {
|
|
111
111
|
try {
|
|
112
|
-
if(crowdinPath.startsWith('apps')){
|
|
112
|
+
if(crowdinPath.startsWith('apps') || appName !== 'en.json') { // path is apps/{app-name}/... or dashboard/{data-connector or regions-map or uploader}/en.json
|
|
113
113
|
const url = `${CROWDIN_PROJECT_URL}/directories?filter=${appName}`;
|
|
114
114
|
const AuthStr = 'Bearer '.concat(credentials.token);
|
|
115
115
|
const resp = await axios.get(url, { headers: { Authorization: AuthStr } });
|
|
116
116
|
const directory = resp.data.data.find(d => d.data.name === appName );
|
|
117
117
|
return directory ? directory.data.id : undefined;
|
|
118
|
-
} else if(crowdinPath.startsWith('dashboard')) {
|
|
118
|
+
} else if((crowdinPath.startsWith('dashboard') || crowdinPath.startsWith('player-web') || crowdinPath.startsWith('components')) && appName === 'en.json') { //path is dashboard/en.json or player-web/en.json or components/en.json
|
|
119
119
|
const url = `${CROWDIN_PROJECT_URL}/directories?filter=dashboard`;
|
|
120
120
|
const AuthStr = 'Bearer '.concat(credentials.token);
|
|
121
121
|
const resp = await axios.get(url, { headers: { Authorization: AuthStr } });
|
|
122
122
|
const directory = resp.data.data.find(d => d.data.name === 'dashboard' && d.data.title === 'Dashboard' && d.data.path === '/dashboard');
|
|
123
123
|
return directory ? directory.data.id : undefined;
|
|
124
|
-
}
|
|
124
|
+
}
|
|
125
125
|
} catch (err) {
|
|
126
126
|
if (err.response.status === HTTP_UNAUTHORIZED_STATUS_CODE) {
|
|
127
127
|
console.error(`\n${chalk.red.bold('Provided Crowdin token is invalid')}`);
|
|
@@ -66,7 +66,7 @@ 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.error(`\n${chalk.red.bold('Directory does not exist')} ${chalk.yellow.bold(
|
|
69
|
+
console.error(`\n${chalk.red.bold('Directory does not exist')} ${chalk.yellow.bold(`${appName}`)}`);
|
|
70
70
|
console.log('Create the directory in the Crowdin panel first.');
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
@@ -92,7 +92,7 @@ async function syncTranslations(s3Client, bucket) {
|
|
|
92
92
|
addCrowdinFile(credentials, crowdinPath, storageId.data.data.id, folderId);
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
|
-
} else if(crowdinPathSections[0] === 'dashboard' && appDirectoryId) {
|
|
95
|
+
} else if((crowdinPathSections[0] === 'dashboard' || crowdinPathSections[0] === 'player-web' || crowdinPathSections[0] === 'components') && appDirectoryId) {
|
|
96
96
|
if(crowdinPathSections[1] === 'en.json') {
|
|
97
97
|
const fileId = await getFileIdIfExists(credentials, appDirectoryId, crowdinPathSections[1]); // en.json file id to update
|
|
98
98
|
if(fileId) {
|
|
@@ -101,9 +101,19 @@ async function syncTranslations(s3Client, bucket) {
|
|
|
101
101
|
updateCrowdinFile(credentials, crowdinPath, storageId.data.data.id, fileId);
|
|
102
102
|
}
|
|
103
103
|
} else {
|
|
104
|
-
console.error(`Could not upload ${chalk.yellow.bold(
|
|
104
|
+
console.error(`Could not upload ${chalk.yellow.bold(`${rowdinPathSections[1]}`)}. Only en.json supported.`);
|
|
105
105
|
}
|
|
106
|
-
}
|
|
106
|
+
} else { // data-connector, regions-map and uploader in dashboard folder
|
|
107
|
+
const folderId = await findCrowdinAppDirectoryId(credentials, crowdinPath, crowdinPathSections[1]);
|
|
108
|
+
if(folderId === undefined) {
|
|
109
|
+
console.error(`Could not find ${chalk.yellow.bold(`${folderId}`)} folder`);
|
|
110
|
+
}
|
|
111
|
+
const fileId = await getFileIdIfExists(credentials, folderId, crowdinPathSections[2]); // en.json file id to update
|
|
112
|
+
const storageId = await uploadFileToCrowdinStorage(credentials, config.localPath);
|
|
113
|
+
if(fileId && storageId) {
|
|
114
|
+
updateCrowdinFile(credentials, crowdinPath, storageId.data.data.id, fileId);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
107
117
|
}
|
|
108
118
|
// await uploadFileToCrowdin(credentials, config.crowdinPath, config.localPath);
|
|
109
119
|
// const { data: fakeTranslation } = await fetchFileFromCrowdin(credentials, config.crowdinPath, FAKE_IN_CONTEXT_LANGUAGE);
|