@enplug/scripts 1.11.4-dev44 → 1.11.4-dev46

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.
@@ -14,9 +14,7 @@ const { catchError, switchMap, tap, filter } = require('rxjs/operators');
14
14
  const HTTP_UNAUTHORIZED_STATUS_CODE = 401;
15
15
  const HTTP_NOT_FOUND_STATUS_CODE = 404;
16
16
 
17
- // const CROWDIN_PROJECT_ID = 'enplug';
18
17
  const CROWDIN_PROJECT_ID = '401630';
19
- // const CROWDIN_PROJECT_URL = `https://api.crowdin.com/api/project/${CROWDIN_PROJECT_ID}`;
20
18
  const CROWDIN_PROJECT_URL = `https://api.crowdin.com/api/v2/projects/${CROWDIN_PROJECT_ID}`;
21
19
  const CROWDIN_STORAGE_URL = `https://api.crowdin.com/api/v2/storages`;
22
20
  const CROWDIN_DIRECTORY_NOT_FOUND_ERROR_CODE = 17;
@@ -113,9 +111,13 @@ async function findCrowdinAppDirectoryId(credentials, crowdinPath, appName) {
113
111
  if(crowdinPath.startsWith('apps')){
114
112
  const url = `${CROWDIN_PROJECT_URL}/directories?filter=${appName}`;
115
113
  const AuthStr = 'Bearer '.concat(credentials.token);
116
- const resp = await axios.get(url, { headers: { Authorization: AuthStr } });
117
- const directory = resp.data.data.find(d => d.data.name === appName );
118
- return directory ? directory.data.id : undefined;
114
+ try {
115
+ const resp = await axios.get(url, { headers: { Authorization: AuthStr } });
116
+ const directory = resp.data.data.find(d => d.data.name === appName );
117
+ return directory ? directory.data.id : undefined;
118
+ } catch (err) {
119
+ console.log('ERROR', err);
120
+ }
119
121
  } else if(crowdinPath.startsWith('dashboard')) {
120
122
  const url = `${CROWDIN_PROJECT_URL}/directories?filter=dashboard`;
121
123
  const AuthStr = 'Bearer '.concat(credentials.token);
@@ -167,7 +169,6 @@ async function uploadFileToCrowdinStorage(credentials, localPath) {
167
169
  }
168
170
 
169
171
  async function updateCrowdinFile(credentials, crowdinPath, storageId, fileId) {
170
- console.log('fileId', fileId);
171
172
  const url = `${CROWDIN_PROJECT_URL}/files/${fileId}`;
172
173
  const AuthStr = 'Bearer '.concat(credentials.token);
173
174
  const body = {
@@ -61,10 +61,10 @@ async function syncTranslations(s3Client, bucket) {
61
61
  await uploadTranslationToS3(s3Client, bucket, s3EnPath, enTranslation);
62
62
 
63
63
  if (isProduction) {
64
- const crowdiPath = config.crowdinPath.startsWith('/') ? config.crowdinPath.substr(1) : config.crowdinPath;
65
- const crowdinPathSections = crowdiPath.split('/');
64
+ const crowdinPath = config.crowdinPath.startsWith('/') ? config.crowdinPath.substr(1) : config.crowdinPath;
65
+ const crowdinPathSections = crowdinPath.split('/');
66
66
  const appName = crowdinPathSections[1];
67
- const appDirectoryId = await findCrowdinAppDirectoryId(credentials, crowdiPath, appName);
67
+ const appDirectoryId = await findCrowdinAppDirectoryId(credentials, crowdinPath, appName);
68
68
  if(appDirectoryId === undefined) {
69
69
  console(`ERROR could not find app ${chalk.yellow.bold(`[${appName}]`)} directory`)
70
70
  return throwError(error);
@@ -83,7 +83,6 @@ async function syncTranslations(s3Client, bucket) {
83
83
  const storageId = await uploadFileToCrowdinStorage(credentials, config.localPath);
84
84
  if(fileId && storageId) {
85
85
  const response = await updateCrowdinFile(credentials, crowdinPath, storageId.data.data.id, fileId);
86
- console.log('response', response);
87
86
  }
88
87
  } else {
89
88
  //TODO add file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enplug/scripts",
3
- "version": "1.11.4-dev44",
3
+ "version": "1.11.4-dev46",
4
4
  "description": "Enplug scripts",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",