@enplug/scripts 1.11.4-dev1 → 1.11.4-dev10

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.
@@ -137,28 +137,33 @@ async function findCrowdinAppDirectoryId(credentials, crowdinPath) {
137
137
  const appName = path.split('/')[1];
138
138
  const url = `${CROWDIN_PROJECT_URL}/directories?filter=${appName}`;
139
139
  const AuthStr = 'Bearer '.concat(credentials.token);
140
- const directories = await axios.get(url, { headers: { Authorization: AuthStr } });
141
- return directories.data.find(d => d.data.name === appName)?.id;
140
+ const resp = await axios.get(url, { headers: { Authorization: AuthStr } });
141
+ const directory = resp.data.data.find(d => d.data.name === appName );
142
+ return directory.data.id
142
143
  } else if(path.startsWith('dashboard')) {
143
144
  const url = `${CROWDIN_PROJECT_URL}/directories?filter=dashboard`;
144
145
  const AuthStr = 'Bearer '.concat(credentials.token);
145
- const directories = axios.get(url, { headers: { Authorization: AuthStr } });
146
- return directories.data.find(d => d.data.name === 'dashboard' && d.data.title === 'Dashboard' && d.data.path === '/dashboard')?.id;
146
+ const resp = axios.get(url, { headers: { Authorization: AuthStr } });
147
+ const directory = resp.data.data.find(d => d.data.name === 'dashboard' && d.data.title === 'Dashboard' && d.data.path === '/dashboard');
148
+ return directory.data.id;
147
149
  }
148
150
  }
149
151
 
150
152
  async function findCrowdinAppSubFolderId(credentials, directoryId, subfolderName) {
151
153
  const url = `${CROWDIN_PROJECT_URL}/directories?directoryId=${directoryId}`;
152
154
  const AuthStr = 'Bearer '.concat(credentials.token);
153
- const directories = await axios.get(url, { headers: { Authorization: AuthStr } });
154
- return directories.data.find(d => d.data.name === subfolderName)?.id;
155
+ const resp = await axios.get(url, { headers: { Authorization: AuthStr } });
156
+ const subdirectory = resp.data.data.find(d => d.data.name === subfolderName)
157
+ return subdirectory.data.id;
155
158
  }
156
159
 
157
160
  async function getFileIdIfExists(credentials, directoryId, fileName) {
158
161
  const url = `${CROWDIN_PROJECT_URL}/files?directoryId=${directoryId}`;
159
162
  const AuthStr = 'Bearer '.concat(credentials.token);
160
- const files = await axios.get(url, { headers: { Authorization: AuthStr } });
161
- return files.data.find(d => d.data.name === fileName)?.id;
163
+ const resp = await axios.get(url, { headers: { Authorization: AuthStr } });
164
+ const file = resp.data.data.find(d => d.data.name === fileName);
165
+ console.log('file found', file);
166
+ return file.data.id;
162
167
  }
163
168
 
164
169
  async function uploadFileToCrowdinStorage(credentials, crowdinPath, localPath) {
@@ -64,7 +64,7 @@ async function syncTranslations(s3Client, bucket) {
64
64
  const appDirectoryId = await findCrowdinAppDirectoryId(credentials, config.crowdinPath);
65
65
  console.log('found directoryId', appDirectoryId);
66
66
  if(config.crowdinPath.includes('apps')) {
67
- const path = crowdinPath.startsWith('/') ? crowdinPath.substr(1) : crowdinPath;
67
+ const path = config.crowdinPath.startsWith('/') ? config.crowdinPath.substr(1) : config.crowdinPath;
68
68
  const subfolderName = path.split('/')[2];
69
69
  const folderId = await findCrowdinAppSubFolderId(credentials, appDirectoryId, subfolderName);
70
70
  console.log('found folderId', folderId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enplug/scripts",
3
- "version": "1.11.4-dev1",
3
+ "version": "1.11.4-dev10",
4
4
  "description": "Enplug scripts",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",