Skip to content

feat(option): update 'dk list' filtering to '--where' with new advanced syntax#90

Merged
IT-WIBRC merged 1 commit intodevelopfrom
feat/list-where-filter
Oct 1, 2025
Merged

feat(option): update 'dk list' filtering to '--where' with new advanced syntax#90
IT-WIBRC merged 1 commit intodevelopfrom
feat/list-where-filter

Conversation

@IT-WIBRC
Copy link
Owner

@IT-WIBRC IT-WIBRC commented Oct 1, 2025

Description

This PR refactors the template filtering mechanism for the dk list command, replacing the deprecated --filter option with the new, more powerful --where option.

This change introduces advanced filtering capabilities, allowing users to perform more precise template lookups using a SQL-like WHERE clause syntax.

Breaking Change ⚠️

The option --filter is removed and replaced entirely by --where. Any scripts or commands using the old flag must be updated.

New Features & Enhancements

The new --where option supports advanced filtering logic:

  1. Multiple Clauses (Logical AND): Users can now pass multiple --where arguments in a single command, which are combined using AND logic. Only templates matching all clauses will be displayed.

    • Example: dk list --where pm=npm --where alias:rt
  2. Dual Syntax Support: The clause separator now accepts both the colon (:) and the equals sign (=).

    • Examples: name:vue or pm=pnpm
  3. Regular Expression (Regex) Matching: Filtering now supports full regex patterns, enclosed in forward slashes (/). This allows for precise matching like "starts with" or "contains a specific pattern."

    • Example: To find templates whose name starts with 'node': dk list --where name:/^node/
  4. Presence/Absence Checks: Special characters are supported for checking if a property is defined or empty.

    • * (Presence): Filters for templates where the property is present (not empty). Example: --where alias:*
    • ~ (Absence): Filters for templates where the property is missing or empty. Example: --where cache:~

Affected Commands

  • dk list
  • dk list <language>

Fixes # (issue)

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • New and existing feature support current supported languages
  • Any dependent changes have been merged and published in downstream modules

@IT-WIBRC IT-WIBRC added documentation Improvements or additions to documentation enhancement New feature or request feature labels Oct 1, 2025
@IT-WIBRC IT-WIBRC force-pushed the feat/list-where-filter branch from ee4e9e8 to ef9e4fd Compare October 1, 2025 05:56
@github-actions
Copy link
Contributor

github-actions bot commented Oct 1, 2025

Coverage Report for ./packages/devkit

Status Category Percentage Covered / Total
🟢 Lines 96.84% (🎯 85%) 2884 / 2978
🟢 Statements 96.84% (🎯 85%) 2884 / 2978
🟢 Functions 95.65% (🎯 90%) 132 / 138
🟢 Branches 92.5% (🎯 85%) 605 / 654
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/devkit/src/commands/list.ts 87.85% 85.71% 100% 87.85% 36-43, 47-48, 109-111
packages/devkit/src/core/template/filter.ts 100% 97.56% 100% 100%
packages/devkit/src/core/template/printer.ts 98.05% 88% 100% 98.05% 39, 42
Generated in workflow #266 for commit ea13d32 by the Vitest Coverage Report Action

@IT-WIBRC IT-WIBRC force-pushed the feat/list-where-filter branch from ef9e4fd to ea13d32 Compare October 1, 2025 05:58
@IT-WIBRC IT-WIBRC merged commit e0862aa into develop Oct 1, 2025
2 checks passed
@github-actions github-actions bot deleted the feat/list-where-filter branch October 1, 2025 05:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant