feat(version): sanitize package names in formatTag function#72
feat(version): sanitize package names in formatTag function#72goosewobbler merged 3 commits intomainfrom
Conversation
- Updated the formatTag function to strip the '@' prefix from scoped package names and replace '/' with '-' for tag formatting. - Enhanced unit tests to verify the correct handling of sanitized package names in various scenarios, ensuring accurate tag generation.
- Changed the tag template format from "${packageName}@v${version}" to "${packageName}-v${version}" for improved consistency in version tagging.
Release Preview — no release
Updated automatically by ReleaseKit |
Greptile SummaryThis PR fixes a latent bug where scoped npm package names (e.g.
Confidence Score: 5/5Safe to merge — the fix is focused, well-tested, and corrects a real bug with no regressions introduced. The change is minimal and surgical: two identical sanitization one-liners, three new passing tests covering the new behaviour, and a config update that follows directly from the logic change. The previously flagged single-slash No files require special attention.
|
| Filename | Overview |
|---|---|
| packages/version/src/utils/formatting.ts | Adds sanitizedPackageName local variable in both formatTag and formatTagPrefix to strip the @ prefix and replace / with - for scoped npm package names; also adds `string |
| packages/version/test/unit/utils/formatting.spec.ts | Adds three new test cases covering scoped package name sanitization in formatTag (template path, unscoped @-prefixed name, and default package-specific format path); no new tests for formatTagPrefix with scoped names. |
| releasekit.config.json | Updates tagTemplate from ${packageName}@v${version} to ${packageName}-v${version} so the sanitized package name produces well-formed tags (e.g. releasekit-version-v1.0.0 instead of the previously broken @releasekit/version@v1.0.0). |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["packageName input\n(e.g. '@releasekit/version')"] --> B{startsWith '@'?}
B -- Yes --> C["slice(1) → 'releasekit/version'"]
C --> D["replace /\\//g with '-'\n→ 'releasekit-version'"]
D --> E[sanitizedPackageName]
B -- No --> F["packageName unchanged\n(e.g. 'my-package')"]
F --> E
E --> G{template provided?}
G -- Yes --> H["template.replace\n'${packageName}' → sanitizedPackageName || ''"]
G -- No --> I{packageSpecificTags\n&& sanitizedPackageName?}
I -- Yes --> J["'sanitizedPackageName@prefixversion'\n(formatTag)\nor 'sanitizedPackageName@prefix'\n(formatTagPrefix)"]
I -- No --> K["prefixversion\nor prefix"]
Reviews (2): Last reviewed commit: "fix(version): enhance package name sanit..." | Re-trigger Greptile
- Updated the `formatTag` and `formatTagPrefix` functions to ensure that the '@' prefix is stripped and '/' is replaced with '-' for all package names, improving consistency in tag formatting. - Adjusted the handling of `packageName` to account for null values, ensuring robust tag generation.
No description provided.