You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:fix with 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:
Assets and entries could call writeFixContent (and thus prompt) inside the processing loop, leading to multiple prompts when fixing many assets or entries.
Unit tests could fail or behave inconsistently when the user had config:set:log --level debug set, because the real logger’s debug path was used.
Solution
1. Clear progress before confirmation (all modules)
Call this.completeProgress(true)immediately before every await 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:
Module
File(s)
Change
content-types
content-types.ts
completeProgress(true) before confirm in writeFixContent()
global-fields
(uses ContentType)
Covered by content-types fix
field_rules
field_rules.ts
completeProgress(true) before confirm in writeFixContent()
custom-roles
custom-roles.ts
completeProgress(true) before confirm in writeFixContent()
assets
assets.ts
completeProgress(true) before confirm; single prompt per run (see below)
entries
entries.ts
completeProgress(true) before confirm; single prompt per run (see below)
workflows
workflows.ts
Upfront confirm in fixWorkflowSchema() and writeFixContent(..., preConfirmed) with progress cleared before any prompt
extensions
extensions.ts
Upfront confirm in fixExtensionsScope() and writeFixContent(..., preConfirmed) with progress cleared before any prompt
2. Single overwrite prompt per run (assets, entries)
Assets: Introduced fixOverwriteConfirmed to cache the user’s choice. The overwrite prompt is shown once when the first fix is needed; subsequent writeFixContent calls reuse the cached value. writeFixContent is now invoked once after the asset loop instead of inside it.
Entries: Same pattern: fixOverwriteConfirmed caches the result of the first confirm; one prompt per run when multiple entry files are written.
3. Single upfront confirm (workflows, extensions)
Workflows: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 into writeFixContent(newWorkflowSchema, userConfirm). writeFixContent accepts optional preConfirmed and only prompts when it is undefined and flags don’t skip; progress is cleared before that prompt.
Extensions: Same pattern in fixExtensionsScope() and writeFixContent(fixedExtensions, preConfirmed).
4. Test infrastructure and coverage
Logger config: Added test/unit/logger-config.js, loaded by Mocha via --file before any test. It forces log config to non-debug so unit tests don’t depend on the user’s config:set:log --level and the real Logger doesn’t take the debug path during tests.
package.json:test:unit and test:unit:report now pass --file test/unit/logger-config.js to Mocha.
Unit tests: Expanded tests for base-command (external-config), assets, composable-studio, content-types, custom-roles, entries, extensions, field-rules, and workflows. Added mock data (e.g. empty_title_ct) where needed.
Workflow test: Removed unused writeStub variable to fix TS6133 (declared but never read).
Files changed
package.json – Mocha --file test/unit/logger-config.js in test scripts
src/modules/assets.ts – Progress before confirm; overwrite cache; single writeFixContent after loop
src/modules/content-types.ts – completeProgress(true) before confirm
src/modules/custom-roles.ts – completeProgress(true) before confirm
src/modules/entries.ts – Progress before confirm; overwrite cache
src/modules/extensions.ts – Upfront confirm; writeFixContent(..., preConfirmed); progress before confirm
src/modules/field_rules.ts – completeProgress(true) before confirm
src/modules/workflows.ts – Upfront confirm; writeFixContent(..., preConfirmed); progress before confirm
test/unit/logger-config.js – New; forces log level for tests
test/unit/base-command.test.ts – external-config and init tests
Mock data under test/unit/mock/ (e.g. empty_title_ct) for new tests
Testing
Run pnpm test:unit (or npm run test:unit) in the contentstack-audit package; all tests should pass.
Manually: run cm:stacks:audit:fix with 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
No change to when the overwrite prompt is shown (same flags: --copy-dir, --yes, external-config.skipConfirm still skip or influence confirmation).
No change to what gets written or to fix logic; only the order of progress completion and prompt display, and the number of prompts for assets/entries/workflows/extensions.
ℹ️ Note: Only vulnerabilities with available fixes (upgrades or patches) are counted toward thresholds.
Check Type
Count (with fixes)
Without fixes
Threshold
Result
🔴 Critical Severity
0
0
10
✅ Passed
🟠 High Severity
0
0
25
✅ Passed
🟡 Medium Severity
0
0
500
✅ Passed
🔵 Low Severity
0
0
1000
✅ Passed
⏱️ SLA Breach Summary
✅ No SLA breaches detected. All vulnerabilities are within acceptable time thresholds.
Severity
Breaches (with fixes)
Breaches (no fixes)
SLA Threshold (with/no fixes)
Status
🔴 Critical
0
0
15 / 30 days
✅ Passed
🟠 High
0
0
30 / 120 days
✅ Passed
🟡 Medium
0
0
90 / 365 days
✅ Passed
🔵 Low
0
0
180 / 365 days
✅ Passed
✅ 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
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).