@talend/i18n-scripts
Advanced tools
Comparing version 2.2.1 to 2.3.0
@@ -114,2 +114,55 @@ /* eslint-disable no-param-reassign */ | ||
function getFileGenerationStatus(data, iteration) { | ||
const { project } = data; | ||
const xtm = getXTMVariables(); | ||
printRunning(`Check generated files...`); | ||
return fetch( | ||
`${xtm.apiUrl}/projects/${project.id}/files/status?fileScope=PROJECT&fileType=TARGET`, | ||
{ | ||
headers: { Authorization: `XTM-Basic ${xtm.token}` }, | ||
}, | ||
) | ||
.then(handleError) | ||
.then((res) => res.json()) | ||
.then((res) => { | ||
printInfo(JSON.stringify(res)); | ||
const status = res.some(({ status }) => status === 'IN_PROGRESS') | ||
? 'IN_PROGRESS' | ||
: 'FINISHED'; | ||
if (status === 'IN_PROGRESS') { | ||
printInfo(`Generation status: still in progress, retry in 3s`); | ||
return new Promise((resolve) => { | ||
setTimeout(() => { | ||
resolve(getFileGenerationStatus(data, iteration + 1)); | ||
}, 3000); | ||
}); | ||
} | ||
printInfo(`Generation status: ${status}`); | ||
}); | ||
} | ||
function waitForFilesGeneration(data) { | ||
return getFileGenerationStatus(data, 0); | ||
} | ||
function generateTargetFiles(data) { | ||
const { project } = data; | ||
const xtm = getXTMVariables(); | ||
const formData = new FormData(); | ||
formData.append('fileType', 'TARGET'); | ||
printRunning(`Generate target files...`); | ||
return fetch(`${xtm.apiUrl}/projects/${project.id}/files/generate`, { | ||
method: 'POST', | ||
headers: { Authorization: `XTM-Basic ${xtm.token}` }, | ||
body: formData, | ||
}) | ||
.then(handleError) | ||
.then((res) => res.json()) | ||
.then(() => waitForFilesGeneration(data)) | ||
.then(() => data); | ||
} | ||
function getFilesToDownload(data) { | ||
@@ -285,2 +338,3 @@ const { project, version } = data; | ||
downloadFiles, | ||
generateTargetFiles, | ||
getFilesToDownload, | ||
@@ -287,0 +341,0 @@ getProject, |
{ | ||
"name": "@talend/i18n-scripts", | ||
"description": "Set of scripts to ease i18n workflow", | ||
"version": "2.2.1", | ||
"version": "2.3.0", | ||
"license": "Apache-2.0", | ||
@@ -6,0 +6,0 @@ "main": "index.js", |
@@ -6,3 +6,8 @@ const fs = require('fs'); | ||
const rimraf = require('rimraf'); | ||
const { getFilesToDownload, getProject, downloadFiles } = require('../common/xtm'); | ||
const { | ||
generateTargetFiles, | ||
getFilesToDownload, | ||
getProject, | ||
downloadFiles, | ||
} = require('../common/xtm'); | ||
const error = require('../common/error'); | ||
@@ -81,2 +86,3 @@ const { printRunning, printSection, printSuccess } = require('../common/log'); | ||
.then(getFilesToDownload) | ||
.then(generateTargetFiles) | ||
.then(downloadFiles) | ||
@@ -83,0 +89,0 @@ .then(unzip) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
115306
1546
9