fix: Audit fix progress bar and overwrite confirmation UX#31
Open
fix: Audit fix progress bar and overwrite confirmation UX#31
Conversation
🔒 Security Scan Results
⏱️ SLA Breach Summary
✅ BUILD PASSED - All security checks passed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Audit fix: progress bar and overwrite confirmation UX
Summary
Fixes the issue where the overwrite confirmation prompt (“Would you like to overwrite existing file?”) did not appear on screen when the progress bar was active—it only became visible after pressing Enter. Also improves behavior for assets and entries so the user is prompted once per run instead of once per file, and adds test infrastructure and unit test coverage.
Problem
When running
audit:fixwith log level info (or when the progress bar is shown), the CLI displays a progress bar during audit. The overwrite confirmation was triggered while the progress bar was still active. The progress UI kept controlling the terminal, so the prompt line was either overwritten or not drawn until the user pressed Enter.Additionally:
writeFixContent(and thus prompt) inside the processing loop, leading to multiple prompts when fixing many assets or entries.config:set:log --level debugset, because the real logger’s debug path was used.Solution
1. Clear progress before confirmation (all modules)
Call
this.completeProgress(true)immediately before everyawait cliux.confirm(...)in modules that use the progress bar. That clears the progress bar and releases the terminal so the overwrite prompt is visible on a new line.Modules updated:
content-types.tscompleteProgress(true)before confirm inwriteFixContent()field_rules.tscompleteProgress(true)before confirm inwriteFixContent()custom-roles.tscompleteProgress(true)before confirm inwriteFixContent()assets.tscompleteProgress(true)before confirm; single prompt per run (see below)entries.tscompleteProgress(true)before confirm; single prompt per run (see below)workflows.tsfixWorkflowSchema()andwriteFixContent(..., preConfirmed)with progress cleared before any promptextensions.tsfixExtensionsScope()andwriteFixContent(..., preConfirmed)with progress cleared before any prompt2. Single overwrite prompt per run (assets, entries)
fixOverwriteConfirmedto cache the user’s choice. The overwrite prompt is shown once when the first fix is needed; subsequentwriteFixContentcalls reuse the cached value.writeFixContentis now invoked once after the asset loop instead of inside it.fixOverwriteConfirmedcaches the result of the first confirm; one prompt per run when multiple entry files are written.3. Single upfront confirm (workflows, extensions)
fixWorkflowSchema()now asks for confirmation once at the start (when there are workflows to fix and no skip flags). The result is passed through the fix loop and intowriteFixContent(newWorkflowSchema, userConfirm).writeFixContentaccepts optionalpreConfirmedand only prompts when it isundefinedand flags don’t skip; progress is cleared before that prompt.fixExtensionsScope()andwriteFixContent(fixedExtensions, preConfirmed).4. Test infrastructure and coverage
test/unit/logger-config.js, loaded by Mocha via--filebefore any test. It forces log config to non-debug so unit tests don’t depend on the user’sconfig:set:log --leveland the real Logger doesn’t take the debug path during tests.test:unitandtest:unit:reportnow pass--file test/unit/logger-config.jsto Mocha.empty_title_ct) where needed.writeStubvariable to fix TS6133 (declared but never read).Files changed
package.json– Mocha--file test/unit/logger-config.jsin test scriptssrc/modules/assets.ts– Progress before confirm; overwrite cache; singlewriteFixContentafter loopsrc/modules/content-types.ts–completeProgress(true)before confirmsrc/modules/custom-roles.ts–completeProgress(true)before confirmsrc/modules/entries.ts– Progress before confirm; overwrite cachesrc/modules/extensions.ts– Upfront confirm;writeFixContent(..., preConfirmed); progress before confirmsrc/modules/field_rules.ts–completeProgress(true)before confirmsrc/modules/workflows.ts– Upfront confirm;writeFixContent(..., preConfirmed); progress before confirmtest/unit/logger-config.js– New; forces log level for teststest/unit/base-command.test.ts– external-config and init teststest/unit/modules/assets.test.ts– Additional casestest/unit/modules/composable-studio.test.ts– Expanded coveragetest/unit/modules/content-types.test.ts– New / expanded teststest/unit/modules/custom-roles.test.ts– Expanded coveragetest/unit/modules/entries.test.ts– Expanded coveragetest/unit/modules/extensions.test.ts– Additional casestest/unit/modules/field-rules.test.ts– Expanded coveragetest/unit/modules/workflow.test.ts– Expanded coverage; removed unusedwriteStubtest/unit/mock/(e.g. empty_title_ct) for new testsTesting
pnpm test:unit(ornpm run test:unit) in the contentstack-audit package; all tests should pass.cm:stacks:audit:fixwith log level info and trigger modules that prompt (e.g. content-types, entries, assets). The overwrite prompt should appear as soon as the progress bar clears, without needing to press Enter. For assets/entries with multiple files, the prompt should appear once per run.Backward compatibility
--copy-dir,--yes,external-config.skipConfirmstill skip or influence confirmation).