Skip to content

Commit

Permalink
refactor: adiciona log ao ktlint
Browse files Browse the repository at this point in the history
  • Loading branch information
katiacih committed Jul 31, 2023
1 parent 861553d commit a500a2e
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 22 deletions.
53 changes: 42 additions & 11 deletions dist/index.js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12838,6 +12838,39 @@ module.exports = {
}


/***/ }),

/***/ 7545:
/***/ ((module) => {


/**
* Formata saída de report via detekt
* @param {string} repotr
* @example writeOutput([{'version':'4.3','file':[{'name':'app/src/main/java/com/example/trybegenius/MainActivity.kt','error':[{'line':'89','column':'50','severity':'warning','message':'This expression contains a magic number. Consider defining it to a well named constant.','source':'detekt.MagicNumber'}]}])
* @output
version: '4.3',
Verifique os erros abaixo:
`Formatado em tabela`
}
*/

function writeReport(report) {
console.log(`Version: ${report[0].version}`)
console.log('Verifique os erros abaixo:')
if(report.length > 0 && report[0].file.length > 0) {
report[0].file.forEach((element) => {
console.log(`Arquivo: ${element.name}`)
console.table(element.error)
})
}
}

module.exports = {
writeReport
}


/***/ }),

/***/ 5984:
Expand Down Expand Up @@ -13054,15 +13087,16 @@ var __webpack_exports__ = {};
const { getDetektReport, getKtlintReport } = __nccwpck_require__(6109)
const { spawn } = __nccwpck_require__(2081)
const core = __nccwpck_require__(9943)
const { writeReport } = __nccwpck_require__(7545)

function runDetekt() {
const command = './gradlew detekt'
const childProcess = spawn(command, { shell: true })

try {
childProcess.stdout.on('data', (data) => {
core.info(`\u001b[38;5;6m[info] Saída do comando: ${data}`)
})
// childProcess.stdout.on('data', (data) => {
// core.info(`\u001b[38;5;6m[info] Saída do comando: ${data}`)
// })

childProcess.stderr.on('data', (data) => {
core.setFailed(`\u001b[38;5;6m[erro] EXEC -> Erro no comando bash: ${data}`)
Expand All @@ -13074,14 +13108,8 @@ function runDetekt() {
report = getDetektReport()
core.setOutput('Detekt', JSON.stringify(report))
core.notice(`\u001b[32;5;6m 🚀 Processo concluído verifique abaixo os erros reportados ${JSON.stringify(report)}`)
console.log(`Version: ${report[0].version}`)
console.log('Verifique os erros abaixo:')
if(report.length > 0 && report[0].file.length > 0) {
report[0].file.forEach((element) => {
console.log(`Arquivo: ${element.name}`)
console.table(element.error)
})
}

writeReport(report)

return report
})
Expand All @@ -13098,6 +13126,9 @@ function runKtlint() {
const childProcess = spawn(command, { shell: true })

try {
childProcess.stdout.on('data', (data) => {
core.info(`\u001b[38;5;6m[info] Saída do comando: ${data}`)
})
childProcess.stderr.on('data', (data) => {
core.setFailed(`\u001b[38;5;6m[erro] EXEC -> Erro no comando bash: ${data}`)
})
Expand Down
20 changes: 9 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
const { getDetektReport, getKtlintReport } = require('./src/controller/linterManager')
const { spawn } = require('child_process')
const core = require('@actions/core')
const { writeReport } = require('./src/controller/writeOutput')

function runDetekt() {
const command = './gradlew detekt'
const childProcess = spawn(command, { shell: true })

try {
childProcess.stdout.on('data', (data) => {
core.info(`\u001b[38;5;6m[info] Saída do comando: ${data}`)
})
// childProcess.stdout.on('data', (data) => {
// core.info(`\u001b[38;5;6m[info] Saída do comando: ${data}`)
// })

childProcess.stderr.on('data', (data) => {
core.setFailed(`\u001b[38;5;6m[erro] EXEC -> Erro no comando bash: ${data}`)
Expand All @@ -21,14 +22,8 @@ function runDetekt() {
report = getDetektReport()
core.setOutput('Detekt', JSON.stringify(report))
core.notice(`\u001b[32;5;6m 🚀 Processo concluído verifique abaixo os erros reportados ${JSON.stringify(report)}`)
console.log(`Version: ${report[0].version}`)
console.log('Verifique os erros abaixo:')
if(report.length > 0 && report[0].file.length > 0) {
report[0].file.forEach((element) => {
console.log(`Arquivo: ${element.name}`)
console.table(element.error)
})
}

writeReport(report)

return report
})
Expand All @@ -45,6 +40,9 @@ function runKtlint() {
const childProcess = spawn(command, { shell: true })

try {
childProcess.stdout.on('data', (data) => {
core.info(`\u001b[38;5;6m[info] Saída do comando: ${data}`)
})
childProcess.stderr.on('data', (data) => {
core.setFailed(`\u001b[38;5;6m[erro] EXEC -> Erro no comando bash: ${data}`)
})
Expand Down
26 changes: 26 additions & 0 deletions src/controller/writeOutput.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

/**
* Formata saída de report via detekt
* @param {string} repotr
* @example writeOutput([{'version':'4.3','file':[{'name':'app/src/main/java/com/example/trybegenius/MainActivity.kt','error':[{'line':'89','column':'50','severity':'warning','message':'This expression contains a magic number. Consider defining it to a well named constant.','source':'detekt.MagicNumber'}]}])
* @output
version: '4.3',
Verifique os erros abaixo:
`Formatado em tabela`
}
*/

function writeReport(report) {
console.log(`Version: ${report[0].version}`)
console.log('Verifique os erros abaixo:')
if(report.length > 0 && report[0].file.length > 0) {
report[0].file.forEach((element) => {
console.log(`Arquivo: ${element.name}`)
console.table(element.error)
})
}
}

module.exports = {
writeReport
}

0 comments on commit a500a2e

Please sign in to comment.