release reminder or commit blocker when no version bump

443 Views Asked by At

Maybe there is some better solution for this. Problem is that sometimes I do fix quick push and when package version is same it wont publish is there any tool which can show me that I have to release package because there were some changes?

I am looking for a way to get this working.

version (A)

  • check package.json of mono-repo and read file last commit ID (usually I update it only when bumping package version)
  • find if there are any files commited after that commit id inside directory of package.
  • if YES display warning that some changes were made and package version need to be bumped before push

version (B)

  • before push some pre-push hook will check which mono-repos files were changed
  • and will display warn if its package.json version was not bumped.
1

There are 1 best solutions below

0
Ponciusz On

solved with husky pre-commit and pre-push:

"husky": {
    "hooks": {
        "pre-push": "yarn lint && yarn test && exec < /dev/tty && yarn bump"
    }
},

and yarn bump is a script with:

shelljs and prompts

const bumpPackages = (directory) => {

    if (shell.cd(`packages/${directory}`).code !== 0) {
        shell.echo('Error: Component does not exist');
        shell.exit(1);
    }

    shell.exec('npm version patch --no-git-tag-version > /dev/null');
    shell.exec('git add package.json');
    shell.echo(`${directory} -  version bumped succesfull`);
    shell.cd('../../..');
};

loop and bump:

directories.forEach((element) => {
  bumpPackages(element.value);
});

and sample directories:

module.exports = [
  { title: 'ComponentA', value: 'ComponentA' },
  { title: 'ComponentB', value: 'ComponentB' },
]