lppedd / idea-conventional-commit

Context and template-based completion for conventional/semantic commits.
https://plugins.jetbrains.com/plugin/13389-conventional-commit
MIT License
327 stars 19 forks source link

How to define public scopes in cc_defaults.json ? #1

Closed ymind closed 4 years ago

ymind commented 4 years ago

Thank you for your good job first ! This plugin is exactly what I need, It effectively improved my work.

I have some problems at work:

  1. I want to know how to use cc_defaults.json define some public scopes.
  2. Have you considered automatically loading cc_defaults.json in the project root directory and taking effect by default ? I expect it to work like .editorconfig.

For the first question, my current config is:

{
  "fix": {
    "description": "xxx",
    "scopes": {
      "common": {
        "description": "xxx"
      },
      "config": {
        "description": "xxx"
      }
    }
  },
  "feat": {
    "description": "xxx",
    "scopes": {
      "common": {
        "description": "xxx"
      },
      "config": {
        "description": "xxx"
      }
      // ... balabala
    }
  }
  // ... balabala
}

This is not convenient, I want to define some public scopes, like:

{
  "types": {
    "fix": {
      "description": "xxx",
      "scopes": {
        "customScope": {
          "description": "xxx"
        }
        // ... balabala
      }
    },
    "feat": {
      "description": "xxx"
    }
    // ... balabala
  },
  "scopes": {
    "common": {
      "description": "xxx"
    },
    "config": {
      "description": "xxx"
    }
    // ... balabala
  }
}
lppedd commented 4 years ago

Hi! Thanks for the issue 😄

  1. Sure, we can solve that by updating the JSON file schema. I'll do that.
  2. I had considered it, but since projects layout can vary a lot, I preferred the absolute path approach. Still the file can be versioned with the project. Do you consider it a usability problem?
lppedd commented 4 years ago

Btw, have you considered a code-level approach using the Provider API? See under https://github.com/lppedd/idea-conventional-commit/tree/master/src/main/kotlin/com/github/lppedd/cc/api

Altough I haven't polished it, so the public interface might change in the future.

lppedd commented 4 years ago

@ymind The new JSON Schema would be:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "title": "Commit types and scopes",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "types"
  ],
  "properties": {
    "types": {
      "$ref": "#/definitions/types"
    },
    "commonScopes": {
      "$ref": "#/definitions/scopes"
    }
  },
  "definitions": {
    "types": {
      "additionalProperties": true,
      "patternProperties": {
        "^([a-zA-Z0-9-]+)$": {
          "$ref": "#/definitions/commitType"
        }
      }
    },
    "scopes": {
      "type": "object",
      "additionalProperties": false,
      "patternProperties": {
        "^([a-zA-Z0-9-:]+)$": {
          "$ref": "#/definitions/commitScope"
        }
      }
    },
    "commitType": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "description": {
          "type": "string"
        },
        "scopes": {
          "type": "object",
          "additionalProperties": false,
          "patternProperties": {
            "^([a-zA-Z0-9-:]+)$": {
              "$ref": "#/definitions/commitScope"
            }
          }
        }
      }
    },
    "commitScope": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "description": {
          "type": "string"
        }
      }
    }
  }
}
ymind commented 4 years ago

Hi! Thanks for the issue 😄

  1. Sure, we can solve that by updating the JSON file schema. I'll do that.
  2. I had considered it, but since projects layout can vary a lot, I preferred the absolute path approach. Still the file can be versioned with the project. Do you consider it a usability problem?

I just want to share the settings in my team so that we can follow the same rules in the same project.

If I place setting file somewhere else, I might need another way to distribute it to other teammates. That's why I got this idea.

ymind commented 4 years ago

@ymind The new JSON Schema would be:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "title": "Commit types and scopes",
  ....

it's great!

lppedd commented 4 years ago

@ymind

I just want to share the settings in my team so that we can follow the same rules in the same project.

Ok, so I'll see what I can do to make this behavior better. Need to study the IDEA project model a little more.

lppedd commented 4 years ago

@ymind almost done. What I have done

lppedd commented 4 years ago

Fixed with commits 93890558c19387f1a77571fbd2131260a255af6d de58522f0ac7197ebc1830a1b7553b4dfefe9f37

I'll create another issue soon for automatic loading of a file in base project directory.