refactor(cli): reuse resolveDataDir() instead of duplicating its logic - #5190
Merged
Merged
Conversation
pedrofrxncx
enabled auto-merge (squash)
July 24, 2026 15:30
decocms Bot
pushed a commit
that referenced
this pull request
Jul 24, 2026
PR: #5190 refactor(cli): reuse resolveDataDir() instead of duplicating its logic Bump type: patch - decocms (apps/api/package.json): 4.122.15 -> 4.122.16 Deploy-Scope: server
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.
Source: reduction found while auditing
apps/api/src/cli.tsfor the backfill-assets argument-validation area (following up on #5180, which fixed --batch/--limit NaN handling). No further validation gaps found there, but this file had a real duplication.Why:
cli.tsalready defines aresolveDataDir()helper (values.home || process.env.DATA_DIR || process.env.DECOCMS_HOME || join(homedir(), "deco")) used by theauthcommand. The exact same 4-line expression was copy-pasted verbatim in two other places: theservicescommand and the default server-mode block. Three copies of the same precedence chain is a correctness risk if one is ever updated and the others aren't.Change: Replaced both duplicated blocks with calls to the existing
resolveDataDir()helper. Purely mechanical —resolveDataDir()is byte-identical to the inlined logic it replaces (verified by diff), so behavior fordeco services,deco(default server mode), anddeco authis unchanged. Net: -10 / +2 lines.How to verify:
cd apps/api && bunx tsc --noEmit(clean), and manually compareresolveDataDir()'s body against the removed blocks — they're identical.Checks run locally:
bun run fmt,bunx tsc --noEmitinapps/api(both clean). No existing test covers this file's argument-routing directly (it's the CLI entrypoint script), so this relies on the identical-logic diff as verification; full CI validates the rest.Summary by cubic
Refactor CLI to reuse
resolveDataDir()for data directory resolution in theservicescommand and default server mode. Removes duplicated precedence logic and preserves existing behavior.Written for commit 03f60be. Summary will update on new commits.