@talend/i18n-scripts
Advanced tools
Comparing version 2.1.0 to 2.2.0
@@ -40,3 +40,3 @@ /* eslint-disable no-param-reassign */ | ||
if (res.status < 200 || res.status >= 300) { | ||
return res.json().then(payload => { | ||
return res.json().then((payload) => { | ||
error(payload.reason); | ||
@@ -60,4 +60,4 @@ }); | ||
.then(handleError) | ||
.then(res => res.json()) | ||
.then(projects => { | ||
.then((res) => res.json()) | ||
.then((projects) => { | ||
// page is empty, the project hasn't been found with this status | ||
@@ -77,3 +77,3 @@ if (!projects.length) { | ||
}) | ||
.then(project => (data.project = project)); | ||
.then((project) => (data.project = project)); | ||
} | ||
@@ -87,3 +87,3 @@ | ||
return getProjectsWithStatus(status); | ||
} | ||
}; | ||
} | ||
@@ -112,4 +112,4 @@ return getProjectsWithStatus('NOT_STARTED') | ||
.then(handleError) | ||
.then(res => res.json()) | ||
.then(res => console.table(res.jobs)) | ||
.then((res) => res.json()) | ||
.then((res) => console.table(res.jobs)) | ||
.then(() => printSuccess(`Project has been updated with ${filePath}`)) | ||
@@ -132,3 +132,3 @@ .then(() => data); | ||
.then(handleError) | ||
.then(res => res.json()) | ||
.then((res) => res.json()) | ||
.then(({ jobs }) => { | ||
@@ -160,7 +160,7 @@ const filteredJobs = jobs.filter(({ fileName }) => fileName.startsWith(`${version}/`)); | ||
.then(handleError) | ||
.then(res => { | ||
.then((res) => { | ||
const fileStream = fs.createWriteStream(filePath); | ||
return new Promise((resolve, reject) => { | ||
res.body.pipe(fileStream); | ||
res.body.on('error', err => { | ||
res.body.on('error', (err) => { | ||
reject(err); | ||
@@ -202,8 +202,8 @@ }); | ||
return fetch(`${xtm.apiUrl}/projects/templates?customerIds=${xtm.customerId}&scope=ALL`, { | ||
headers: { Authorization: `XTM-Basic ${xtm.token}` } | ||
headers: { Authorization: `XTM-Basic ${xtm.token}` }, | ||
}) | ||
.then(handleError) | ||
.then(res => res.json()) | ||
.then(templates => templates.find(template => template.name === projectName)) | ||
.then(template => { | ||
.then((res) => res.json()) | ||
.then((templates) => templates.find((template) => template.name === projectName)) | ||
.then((template) => { | ||
if (template) { | ||
@@ -227,3 +227,3 @@ printSuccess('Template found'); | ||
return getProjectTemplate(data) | ||
.then(template => { | ||
.then((template) => { | ||
const formData = new FormData(); | ||
@@ -236,6 +236,18 @@ formData.append('customerId', xtm.customerId); | ||
formData.append('description', projectName); | ||
formData.append("callbacks.jobFinishedCallback", "https://i18n-dev.talendforge.org/babili/xtm/job.php"); | ||
formData.append("callbacks.projectFinishedCallback", "https://i18n-dev.talendforge.org/babili/xtm/project.php"); | ||
formData.append("callbacks.analysisFinishedCallback", "https://i18n-dev.talendforge.org/babili/xtm/analysis.php"); | ||
formData.append("callbacks.workflowTransitionCallback", "https://i18n-dev.talendforge.org/babili/xtm/workflow.php"); | ||
formData.append( | ||
'callbacks.jobFinishedCallback', | ||
'https://i18n-dev.talendforge.org/babili/xtm/job.php', | ||
); | ||
formData.append( | ||
'callbacks.projectFinishedCallback', | ||
'https://i18n-dev.talendforge.org/babili/xtm/project.php', | ||
); | ||
formData.append( | ||
'callbacks.analysisFinishedCallback', | ||
'https://i18n-dev.talendforge.org/babili/xtm/analysis.php', | ||
); | ||
formData.append( | ||
'callbacks.workflowTransitionCallback', | ||
'https://i18n-dev.talendforge.org/babili/xtm/workflow.php', | ||
); | ||
@@ -249,4 +261,4 @@ return fetch(`${xtm.apiUrl}/projects/`, { | ||
.then(handleError) | ||
.then(res => res.json()) | ||
.then(project => { | ||
.then((res) => res.json()) | ||
.then((project) => { | ||
printSuccess(`Project has been created`); | ||
@@ -261,4 +273,23 @@ console.table(omit(project, 'jobs')); | ||
function reactivateProject(data) { | ||
const { project } = data; | ||
const xtm = getXTMVariables(); | ||
return fetch(`${xtm.apiUrl}/projects/${project.id}/activate`, { | ||
method: 'POST', | ||
headers: { Authorization: `XTM-Basic ${xtm.token}`, 'Content-Type': 'application/json' }, | ||
}) | ||
.then(handleError) | ||
.then((res) => res.json()) | ||
.then(({ success }) => { | ||
if (!success) { | ||
console.table(project); | ||
error('Reactivation of archived project failed'); | ||
} | ||
}); | ||
} | ||
module.exports = { | ||
createProject, | ||
reactivateProject, | ||
downloadFiles, | ||
@@ -265,0 +296,0 @@ getFilesToDownload, |
{ | ||
"name": "@talend/i18n-scripts", | ||
"description": "Set of scripts to ease i18n workflow", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"license": "Apache-2.0", | ||
@@ -6,0 +6,0 @@ "main": "index.js", |
const path = require('path'); | ||
const { createProject, getProject, uploadFile } = require('../common/xtm'); | ||
const { createProject, getProject, uploadFile, reactivateProject } = require('../common/xtm'); | ||
const error = require('../common/error'); | ||
@@ -14,2 +14,7 @@ const { getVersion } = require('../common/version'); | ||
.then(() => { | ||
if (data.project && ['AUTO_ARCHIVED', 'ARCHIVED'].includes(data.project.activity)) { | ||
return reactivateProject(data); | ||
} | ||
}) | ||
.then(() => { | ||
if (data.project) { | ||
@@ -20,3 +25,3 @@ return uploadFile(data); | ||
}) | ||
.catch(e => { | ||
.catch((e) => { | ||
error(e.message); | ||
@@ -23,0 +28,0 @@ }); |
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
113812
1492
7