From b69e665595fce49d4c6e0a29fd211509f0a98613 Mon Sep 17 00:00:00 2001 From: kobenguyent Date: Fri, 17 Jan 2025 17:44:28 +0100 Subject: [PATCH 1/4] fix: handle logging step --- lib/output.js | 25 +++++++++++++++---------- package.json | 3 ++- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/lib/output.js b/lib/output.js index fc209d043..618c3d1aa 100644 --- a/lib/output.js +++ b/lib/output.js @@ -115,17 +115,22 @@ module.exports = { } } - let stepLine = step.toCliStyled() - if (step.metaStep && outputLevel >= 1) { - // this.stepShift += 2; - stepLine = colors.dim(truncate(stepLine, this.spaceShift)) - } - if (step.comment) { - stepLine += colors.grey(step.comment.split('\n').join('\n' + ' '.repeat(4))) - } + try { + let stepLine = step.toCliStyled() + if (step.metaStep && outputLevel >= 1) { + // this.stepShift += 2; + stepLine = colors.dim(truncate(stepLine, this.spaceShift)) + } + if (step.comment) { + stepLine += colors.grey(step.comment.split('\n').join('\n' + ' '.repeat(4))) + } - const _stepLine = isMaskedData() ? maskSensitiveData(stepLine) : stepLine - print(' '.repeat(this.stepShift), truncate(_stepLine, this.spaceShift)) + const _stepLine = isMaskedData() ? maskSensitiveData(stepLine) : stepLine + print(' '.repeat(this.stepShift), truncate(_stepLine, this.spaceShift)) + } catch (e) { + // sometimes the step is just the string, so we basically print it out + print(step) + } }, /** @namespace */ diff --git a/package.json b/package.json index 45f0a6c18..2ae398a8c 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,8 @@ ".": "./lib/index.js", "./els": "./lib/els.js", "./effects": "./lib/effects.js", - "./steps": "./lib/steps.js" + "./steps": "./lib/steps.js", + "./step": "./lib/step.js" }, "types": "typings/index.d.ts", "bin": { From 9eedefc666210428b79a8f7c44193048d0c2fa75 Mon Sep 17 00:00:00 2001 From: kobenguyent <7845001+kobenguyent@users.noreply.github.com> Date: Sun, 19 Jan 2025 07:34:17 +0100 Subject: [PATCH 2/4] remove export step in package json --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index 2ae398a8c..45f0a6c18 100644 --- a/package.json +++ b/package.json @@ -33,8 +33,7 @@ ".": "./lib/index.js", "./els": "./lib/els.js", "./effects": "./lib/effects.js", - "./steps": "./lib/steps.js", - "./step": "./lib/step.js" + "./steps": "./lib/steps.js" }, "types": "typings/index.d.ts", "bin": { From 9140b901d3897962a3965fa1f4b539d15c350df9 Mon Sep 17 00:00:00 2001 From: kobenguyent <7845001+kobenguyent@users.noreply.github.com> Date: Sun, 19 Jan 2025 07:36:21 +0100 Subject: [PATCH 3/4] export step as internal API --- lib/index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/index.js b/lib/index.js index 9f6703dba..2302b0330 100644 --- a/lib/index.js +++ b/lib/index.js @@ -38,6 +38,8 @@ module.exports = { store: require('./store'), /** @type {typeof CodeceptJS.Locator} */ locator: require('./locator'), + /** @type {typeof CodeceptJS.Step} */ + Step: require('./step'), heal: require('./heal'), ai: require('./ai'), From 981ddb11e11171307815c45e570fa59db148a6fd Mon Sep 17 00:00:00 2001 From: kobenguyent Date: Mon, 20 Jan 2025 05:40:15 +0100 Subject: [PATCH 4/4] improve the step output handling --- lib/output.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/output.js b/lib/output.js index 618c3d1aa..7b1cb8fcd 100644 --- a/lib/output.js +++ b/lib/output.js @@ -1,6 +1,7 @@ const colors = require('chalk') const figures = require('figures') const { maskSensitiveData } = require('invisi-data') +const Step = require('./step') const styles = { error: colors.bgRed.white.bold, @@ -115,7 +116,7 @@ module.exports = { } } - try { + if (step instanceof Step) { let stepLine = step.toCliStyled() if (step.metaStep && outputLevel >= 1) { // this.stepShift += 2; @@ -127,9 +128,11 @@ module.exports = { const _stepLine = isMaskedData() ? maskSensitiveData(stepLine) : stepLine print(' '.repeat(this.stepShift), truncate(_stepLine, this.spaceShift)) - } catch (e) { + } else if (typeof step === 'string') { // sometimes the step is just the string, so we basically print it out print(step) + } else { + console.log(`Something went wrong with ${step}`) } },