Skip to content

Instantly share code, notes, and snippets.

@azu
Created March 7, 2020 05:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save azu/b50961d65985db114c05634cd43362f3 to your computer and use it in GitHub Desktop.
Save azu/b50961d65985db114c05634cd43362f3 to your computer and use it in GitHub Desktop.
Support custom "getNextVersion" in configuration proposal for ship.js

Is your feature request related to a problem? Please describe. Currently, It seems that ship.js support only conventional commits to get Next version.

I want to custom the logic of getNextVersion. For example, I want to implement label based version management:

Calculate Next version from labels If these includes only Version: patch, next version is patch If these includes Version: patch and Version: minor, next version is minor If any one is Version: major label, next version is major

Describe the solution you'd like

Add new lifecyle hook like updateVersion before shouldPrepare

module.exports = {
    updateVersion: async ({revisionRange,
                     currentVersion,
                     dir}) => {
       // user defined logic
       const nextVersion = await calculateNextVersion();
       return { nextVersion } 
    }
};

Describe alternatives you've considered

  • Add { versionStrategy: "conventional-commits" | customFunction }
    • it looks like mergeStrategy

Additional context

Customization for updateVersion logic may be used for independent mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment