arvinxx / gitmoji-commit-workflow

πŸ˜‰ Gitmoji Commit Workflow
MIT License
217 stars 27 forks source link

Fixing @gitmoji/parser-opts to allow for - and / #674

Open jebarpg opened 7 months ago

jebarpg commented 7 months ago

I use types in the form of fix-ci and ci/cd, which doesn't get picked up by the regex \w due to the - and / in-between the words I propose changing (?\w) to (?[a-zA-z-,\/]+) on this line: https://github.com/arvinxx/gitmoji-commit-workflow/blob/master/packages/parser-opts/src/index.ts#L10

so it becomes this

headerPattern: new RegExp("^(?:".concat(gitmojiCodeStr, "|(?:").concat(gitmojiUnicodeStr, ")|(?:").concat(emojiStr, "))\s(?[a-zA-z-,\/]+)(?:\((?.)\))?!?:\s(?(?:(?!#).)(?:(?!\s).))(?:\s\(?(?#\d*)\)?)?$")),

arvinxx commented 7 months ago

what's your commit for example?

jebarpg commented 7 months ago

` :green_heart: fix-ci(ci/cd): added release rules for all cz-emojis

body text here

`

jebarpg commented 7 months ago

I made the modification locally in my install of the @gitmoji/parser-opts, but this will probably not work with github action CI when it tries to install the original.

o also I have an additional template hbs file for cz-emoji, as well as organized release rules for all 75 emoji types. I think it could be useful to have them as an additional default template inside the lib assets directory where the commit and default templates are. let me know if you would like a copy of them and I'll make a PR request.

jebarpg commented 7 months ago
plugins: [
    [
      'semantic-release-gitmoji', {
        //NOTE: Chatgpt was used to help organize these. These all can be subjective.
        releaseRules: {
          major: [
            ':ambulance:', //Critical hotfix.
            ':boom:', //Introducing breaking changes.
            ':building_construction:', //Making architectural changes.
            ':heavy_minus_sign:', //Removing a dependency.
            ':wastebasket:', //Deprecate code that needs to be cleaned up.
          ],
          premajor: [
            ':rewind:', //Reverting changes.
            ':see_no_evil:', //Adding or updating a .gitignore file.
            ':tada:', //Initial commit.
          ],
          minor: [
            ':alembic:', //Experimenting new things.
            ':bulb:', //Documenting source code.
            ':camera_flash:', //Adding or updating snapshots.
            ':chart_with_upwards_trend:', //Adding analytics or tracking code.
            ':dizzy:', //Adding or updating animations and transitions.
            ':globe_with_meridians:', //Internationalization and localization.
            ':heavy_plus_sign:', //Adding a dependency.
            ':iphone:', //Working on responsive design.
            ':recycle:', //Refactoring code.
            ':seedling:', //Adding or updating seed files.
            ':sparkles:', //Introducing new features.
            ':triangular_flag_on_post:', //Adding, updating, or removing feature flags.
            ':whale:', //Work about Docker.
            ':wheel_of_dharma:', //Work about Kubernetes.
            ':white_check_mark:', //Adding tests.
            ':wrench:', //Changing configuration files.
            ':zap:', //Improving performance.
          ],
          preminor: [
            ':clown_face:', //Mocking things.
            ':egg:', //Adding an easter egg.
            ':label:', //Adding or updating types (Flow, TypeScript).
            ':ok_hand:', //Updating code due to code review changes.
          ],
          patch: [
            ':adhesive_bandage:', //Simple fix for a non-critical issue.
            ':alien:', //Updating code due to external API changes.
            ':apple:', //Fixing something on macOS.
            ':bug:', //Fixing a bug.
            ':checkered_flag:', //Fixing something on Windows.
            ':coffin:', //Remove dead code.
            ':fire:', //Removing code or files.
            ':green_apple:', //Fixing something on iOS.
            ':lipstick:', //Updating the UI and style files.
            ':lock:', //Fixing security issues.
            ':loud_sound:', //Adding logs.
            ':monocle_face:', //Data exploration/inspection.
            ':mute:', //Removing logs.
            ':package:', //Updating compiled files or packages.
            ':page_facing_up:', //Adding or updating license.
            ':pencil:', //Writing docs.
            ':penguin:', //Fixing something on Linux.
            ':poop:', //Writing bad code that needs to be improved.
            ':robot:', //Fixing something on Android.
            ':rocket:', //Deploying stuff.
            ':rotating_light:', //Removing linter warnings.
            ':test_tube:', //Add a failing test.
            ':truck:', //Moving or renaming files.
            ':twisted_rightwards_arrows:', //Merging branches.
            ':wheelchair:', //Improving accessibility.
          ],
          prepatch: [
            ':beers:', //Writing code drunkenly.
            ':busts_in_silhouette:', //Adding contributor(s).
            ':pencil2:', //Fixing typos.
            ':speech_balloon:', //Updating text and literals.
          ],
          prerelease: [
            ':arrow_down:', //Downgrading dependencies.
            ':arrow_up:', //Upgrading dependencies.
            ':bento:', //Adding or updating assets.
            ':construction:', //Work in progress.
            ':construction_worker:', //Adding CI build system.
            ':green_heart:', //Fixing CI Build.
            ':mag:', //Improving SEO.
            ':pushpin:', //Pinning dependencies to specific versions.
          ]
        },
        releaseNotes: {
          template,
          partials: { commitTemplate },
          helpers: {
            datetime: function (format = 'UTC:yyyy-mm-dd') {
              return dateFormat(new Date(), format)
            }
          },
          issueResolution: {
            template: '{baseUrl}/{owner}/{repo}/issues/{ref}',
            baseUrl: 'https://github.com',
            source: 'github.com',
            removeFromCommit: false,
            regex: /#\d+/g //example matches: #2341 or #8
          }
        }
      }
    ],
jebarpg commented 7 months ago
{{#if compareUrl}}
# [v{{nextRelease.version}}]({{compareUrl}}) ({{datetime "UTC:yyyy-mm-dd"}})
{{else}}
# v{{nextRelease.version}} ({{datetime "UTC:yyyy-mm-dd"}})
{{/if}}

{{#with commits}}
{{#if art}}
## 🎨 Improving structure / format of the code
{{#each art}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if zap}}
## ⚑️ Improving performance
{{#each zap}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if fire}}
## πŸ”₯ Removing code or files
{{#each fire}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if bug}}
## πŸ› Fixing a bug
{{#each bug}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if ambulance}}
## πŸš‘ Critical hotfix
{{#each ambulance}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if sparkles}}
## ✨ Introducing new features
{{#each sparkles}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if pencil}}
## πŸ“ Writing docs
{{#each pencil}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if rocket}}
## πŸš€ Deploying stuff
{{#each rocket}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if lipstick}}
## πŸ’„ Updating the UI and style files
{{#each lipstick}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if tada}}
## πŸŽ‰ Initial commit
{{#each tada}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if white_check_mark}}
## βœ… Adding tests
{{#each white_check_mark}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if lock}}
## πŸ”’ Fixing security issues
{{#each lock}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if apple}}
## 🍎 Fixing something on macOS
{{#each apple}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if penguin}}
## 🐧 Fixing something on Linux
{{#each penguin}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if checkered_flag}}
## 🏁 Fixing something on Windows
{{#each checkered_flag}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if robot}}
## πŸ€– Fixing something on Android
{{#each robot}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if green_apple}}
## 🍏 Fixing something on iOS
{{#each green_apple}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if bookmark}}
## πŸ”– Releasing / Version tags
{{#each bookmark}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if rotating_light}}
## 🚨 Removing linter warnings
{{#each rotating_light}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if construction}}
## 🚧 Work in progress
{{#each construction}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if green_heart}}
## πŸ’š Fixing CI Build
{{#each green_heart}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if arrow_down}}
## ⬇️ Downgrading dependencies
{{#each arrow_down}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if arrow_up}}
## ⬆️ Upgrading dependencies
{{#each arrow_up}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if pushpin}}
## πŸ“Œ Pinning dependencies to specific versions
{{#each pushpin}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if construction_worker}}
## πŸ‘· Adding CI build system
{{#each construction_worker}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if chart_with_upwards_trend}}
## πŸ“ˆ Adding analytics or tracking code
{{#each chart_with_upwards_trend}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if recycle}}
## ♻️ Refactoring code
{{#each recycle}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if whale}}
## 🐳 Work about Docker
{{#each whale}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if heavy_plus_sign}}
## βž• Adding a dependency
{{#each heavy_plus_sign}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if heavy_minus_sign}}
## βž– Removing a dependency
{{#each heavy_minus_sign}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if wrench}}
## πŸ”§ Changing configuration files
{{#each wrench}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if globe_with_meridians}}
## 🌐 Internationalization and localization
{{#each globe_with_meridians}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if pencil2}}
## ✏️ Fixing typos
{{#each pencil2}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if poop}}
## πŸ’© Writing bad code that needs to be improved
{{#each poop}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if rewind}}
## βͺ Reverting changes
{{#each rewind}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if twisted_rightwards_arrows}}
## πŸ”€ Merging branches
{{#each twisted_rightwards_arrows}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if package}}
## πŸ“¦ Updating compiled files or packages
{{#each package}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if alien}}
## πŸ‘½ Updating code due to external API changes
{{#each alien}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if truck}}
## 🚚 Moving or renaming files
{{#each truck}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if page_facing_up}}
## πŸ“„ Adding or updating license
{{#each page_facing_up}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if boom}}
## πŸ’₯ Introducing breaking changes
{{#each boom}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if bento}}
## 🍱 Adding or updating assets
{{#each bento}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if ok_hand}}
## πŸ‘Œ Updating code due to code review changes
{{#each ok_hand}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if wheelchair}}
## ♿️ Improving accessibility
{{#each wheelchair}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if bulb}}
## πŸ’‘ Documenting source code
{{#each bulb}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if beers}}
## 🍻 Writing code drunkenly
{{#each beers}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if speech_balloon}}
## πŸ’¬ Updating text and literals
{{#each speech_balloon}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if card_file_box}}
## πŸ—ƒοΈ Performing database related changes
{{#each card_file_box}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if loud_sound}}
## πŸ”Š Adding logs
{{#each loud_sound}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if mute}}
## πŸ”‡ Removing logs
{{#each mute}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if busts_in_silhouette}}
## πŸ‘₯ Adding contributor(s)
{{#each busts_in_silhouette}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if children_crossing}}
## 🚸 Improving user experience / usability
{{#each children_crossing}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if building_construction}}
## πŸ—οΈ Making architectural changes
{{#each building_construction}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if iphone}}
## πŸ“± Working on responsive design
{{#each iphone}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if clown_face}}
## 🀑 Mocking things
{{#each clown_face}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if egg}}
## πŸ₯š Adding an easter egg
{{#each egg}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if see_no_evil}}
## πŸ™ˆ Adding or updating a .gitignore file
{{#each see_no_evil}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if camera_flash}}
## πŸ“Έ Adding or updating snapshots
{{#each camera_flash}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if alembic}}
## βš—οΈ Experimenting new things
{{#each alembic}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if mag}}
## πŸ” Improving SEO
{{#each mag}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if wheel_of_dharma}}
## ☸️ Work about Kubernetes
{{#each wheel_of_dharma}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if label}}
## 🏷️ Adding or updating types (Flow, TypeScript)
{{#each label}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if seedling}}
## 🌱 Adding or updating seed files
{{#each seedling}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if triangular_flag_on_post}}
## 🚩 Adding, updating, or removing feature flags
{{#each triangular_flag_on_post}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if dizzy}}
## πŸ’« Adding or updating animations and transitions
{{#each dizzy}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if wastebasket}}
## πŸ—‘οΈ Deprecate code that needs to be cleaned up
{{#each wastebasket}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if passport_control}}
## πŸ›‚ Work on code related to authorization, roles and permissions
{{#each passport_control}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if adhesive_bandage}}
## 🩹 Simple fix for a non-critical issue
{{#each adhesive_bandage}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if monocle_face}}
## 🧐 Data exploration/inspection
{{#each monocle_face}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if coffin}}
## ⚰️ Remove dead code
{{#each coffin}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if test_tube}}
## πŸ§ͺ Add a failing test
{{#each test_tube}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if necktie}}
## πŸ‘” Add or update business logic
{{#each necktie}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if stethoscope}}
## 🩺 Add or update healthcheck
{{#each stethoscope}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if bricks}}
## 🧱 Infrastructure related changes
{{#each bricks}}
- {{> commitTemplate}}
{{/each}}
{{/if}}

{{#if technologist}}
## πŸ§‘β€πŸ’» Improve developer experience
{{#each technologist}}
- {{> commitTemplate}}
{{/each}}
{{/if}}
{{/with}}
jebarpg commented 7 months ago

you can see all the types at this url here: https://github.com/ngryman/cz-emoji/blob/master/lib/types.json

arvinxx commented 7 months ago

I think add - and / is reasonable, are you willing to make a pr for it?

jebarpg commented 7 months ago

I think add - and / is reasonable, are you willing to make a pr for it?

made the PR.

jebarpg commented 7 months ago

deleted my first pull request and made a second one with an updated example of the regex101 link. Also added the bug emoji to the beginning of my commit message

jebarpg commented 6 months ago

@arvinxx any update on this issue?