Skip to content

chore(deps): bump minimist, mkdirp and handlebars #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 13 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# gitool

Gitool helps you always have the right format for your commit message.
Following https://www.conventionalcommits.org/en/v1.0.0-beta.2/
Following https://www.conventionalcommits.org/en/v1.0.0/

## alias
any gitool command can be called with ```gitool``` or ```gt```
Expand All @@ -24,22 +24,20 @@ or ```gitool -cl=3```

## pretty print

```gitool --prettyPrint```
```gitool -p``` (groupBy type by default)
```gitool --prettyPrint --pn=ProjectName --v=1.23.2```
```gitool -p --pn=ProjectName --v=1.23.2``` (groupBy type by default)

```gitool -p groupBy='type'```
```gitool -p groupBy='type' --pn=ProjectName --v=1.23.2```

```gitool -pg='type'```
```gitool -pg='scope'```
```gitool -pg='type' --pn=ProjectName --v=1.23.2```
```gitool -pg='scope' --pn=ProjectName --v=1.23.2```

```gitool -pg='scope' --tag=3```

```gitool -pg='type' --tag=3 --filters='feat|fix'```
```gitool -pg='type' --filters='feat|fix' --pn=ProjectName --v=1.23.2```


![alt text](https://raw.githubusercontent.com/stefdelec/gitool/master/readme/commitprettier.png)

```gitool -p --tag``` output commits from last tag
```gitool -p --pn=ProjectName --v=1.23.2``` output commits from last tag

Output a file:

Expand All @@ -50,7 +48,7 @@ Output a file:

Add this in your package.json
```
"prepublish": "npm test && npm version minor && node index.js -pao=changelog.md --tag=1 && git push"
"postversion": "gitool -p --pn=ProjectName --v=1.23.2"
```
## message composer

Expand All @@ -68,12 +66,12 @@ and
## cane
shortcut for
```
git add . && git commit --amend --no-edit
git add . && git commit -m "release(changelog): Update changelog.md [CI SKIP]"
```

## force
rebase on develop or branch + push force
rebase on master or branch + push force

```gitool -force```
```gitool -force -branch=master```
```gitool -fb=master```
```gitool -force -branch=develop```
```gitool -fb=develop```
66 changes: 63 additions & 3 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,75 @@
# gitool
# Release notes
## v1.24.0 ( 2021-09-1 )

**version**: From v1.20.0 to v1.21.0
### **feat (1):**
- feat(changelog): Append commits in change log file

## **feat (3):**
## v1.22.0 ( 2021-06-19 )

### **feat (1):**
- feat(force): git rebase and push

## v1.21.0 ( 2021-02-19 )

### **feat (3):**
- feat(cane): short cut for add commit no edit
- feat(console): improve console log
- feat(readme): improve package.json bump

## v1.20.0 ( 2021-02-19 )

### **docs (15):**
- docs: changelog
- docs: changelog
- docs: changelog
- docs: changelog
- docs: changelog
- docs: changelog
- docs: changelog
- docs: changelog
- docs: changelog
- docs: changelog
- docs(readme): update readme with link to changelog
- docs: changelog
- docs(prettyPrint): update changelog pretty print
- docs(readme): improve readme and add images
- docs(readme): update readme with gitool alias (gt)

### **feat (22):**
- feat(readme): improve readme
- feat(autofetch): auto fetch tags before creating changelog
- feat(changelog): improve changelog title
- feat(changelog): changelog only on last tag
- feat(prettyPrint): can add all or not
- feat(prettyPrint): add changelog in preversion
- feat(prettyPrint): add filters to type of pretty print
- feat(prettyPrint): pretty print from tag
- feat(prettyPrint): quick changelog
- feat(readme): update readme and package.json
- feat(prettyPrint): can pass --tag and output from last tag
- feat(prettyPrint): can output a file
- feat(prettyPrint): pretty print group by type or scope
- feat(messageComposer): can add all modified file before commiting with -am
- feat(bin): commit is not executed if message and type are undefined
- feat(bin): gt is a new alias for gitool
- feat(commitChecker): version bump commit by npm is accepted
- feat: undefined
- feat(bin): add aliases for existing commands
- feat(messageComposer): add functionaly message composer
- feat(readme): create a simple README.md
- feat(bin): bin is packed

### **fix (8):**
- fix(changelog): fix change log tag title
- fix(prettyPrint): version of pretty print was incorrect
- fix(travis): fix travis test
- fix(readme): fix link to changelog
- fix(messageComposer): ex was undefined for git add .
- fix(messageComposer): remove automatic add .
- fix(commitChecker): fix default value of last
- fix(bin): bin command was not gitool


### **test (1):**
- test(travis): add travis ci

49 changes: 36 additions & 13 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ const commitMessageChercher = require('./src/commit-message-checker/commit-messa
const shortCut = require('./src/gitShortCut');
const messageComposer = require('./src/message-composer/message-composer')
const chalk = require('chalk');
const { existsSync } = require('fs');

const argv = require('yargs')
.alias('c', 'checkCommit')
.alias('o', 'output')
.alias('p', 'prettyPrint')
.alias('pn','projectName')
.alias('v','versionTag')
.alias('a', 'addAll')
.alias('m', 'messageComposer')
.alias('t', 'test')
Expand All @@ -17,7 +20,7 @@ const argv = require('yargs')
.alias('b','branch')
.argv

const { prettyPrint, write } = require('./src/commit-prettier/commit-prettier');
const { prettyPrint } = require('./src/commit-prettier/commit-prettier');
// Check Last commit

if (argv.checkCommit) {
Expand All @@ -40,35 +43,55 @@ if (argv.checkCommit) {
console.log(chalk.red('commit message is NOT valid'));
throw new Error()
}
console.log('')
}

}
if(argv.bump){
console.log(argv.bump);
}
if (argv.prettyPrint) {
if(!argv.projectName){
throw new Error('Project name is mandatory');
}

if(!argv.versionTag){
throw new Error('Version tag is mandatory');
}
console.log('Fetching tags from origin');
shortCut.ex("git fetch origin --tags");

const groupBy = argv.groupBy === 'scope' ? 'scope' : 'type';

const tags = shortCut.getTagsOrderedByDate().split('\n').reverse();

const numOftag=parseInt(argv.tag);
const tags = shortCut.getTagsOrderedByDate().split('\n').filter(t => t !== '');

const getFromTag = (tagNumber) => tags[+tagNumber];

const commitFrom = argv.tag ? getFromTag(numOftag) : shortCut.firstCommitAllTime().trim();

let title = `From ${getFromTag(numOftag)} to ${tags[0]}`;
const firstCommit = shortCut.firstCommitAllTime().trim()

const filters = argv.filters ? argv.filters.split('|') : undefined;
prettyPrint(commitFrom, groupBy, argv.output, title, filters);
const path = argv.output || './changelog.md';

const getDateOfTag = (tag) => ((shortCut.getDateTimeOfTag(tag).trim().split(' '))[0]);
const dateNow = (now = new Date()) => {
let month = now.getMonth() + 1;
month = month > 9 ? month : `0${month}`;
return `${now.getFullYear()}-${month}-${now.getDate()}`;
}

if(!existsSync(path)){
for (let i = 0; i < tags.length; i++) {
const date = getDateOfTag(getFromTag(i));
prettyPrint(i !== 0 ? getFromTag(i - 1) : firstCommit, getFromTag(i), groupBy, path, argv.projectName || 'untitled', getFromTag(i), filters, date);
}
}

prettyPrint(tags.length !== 0 ? getFromTag(tags.length - 1) : shortCut.firstCommitAllTime().trim(), 'HEAD', groupBy, path, argv.projectName || 'untitled', argv.versionTag, filters, dateNow());


if (argv.addAll) {
console.log('Adding files to previous commit');
shortCut.ex('git add .')
shortCut.ex('git commit --amend --no-edit')
shortCut.ex('git commit -m "release(changelog): Update changelog.md [CI SKIP]"')
}
}

Expand All @@ -85,11 +108,11 @@ if (argv.messageComposer) {
}

if(argv.force){
const branch=argv.branch || 'develop';
shortCut.ex(`git add . && git commit --amend --no-edit && git fetch && git pull origin ${branch} --rebase && git push origin HEAD --force`);
const branch=argv.branch || 'master';
shortCut.ex(`git add . && git commit -m "release(changelog): Update changelog.md [CI SKIP]" && git fetch && git pull origin ${branch} --rebase && git push origin HEAD --force`);
}

if(argv.cane){
shortCut.ex('git add .')
shortCut.ex('git commit --amend --no-edit')
shortCut.ex('git commit -m "release(changelog): Update changelog.md [CI SKIP]"')
}
82 changes: 21 additions & 61 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading