Skip to content

Commit

Permalink
feat(cli): changelog, non-conventional commits
Browse files Browse the repository at this point in the history
* cli, index, expose, pass non-cc
* cmds, additional checks for path join
* global, general type, consistent cc types
* parse, simplify semverBump, parser breakout
  • Loading branch information
cdcabrera committed Oct 13, 2022
1 parent 9c8f238 commit 416bcf2
Show file tree
Hide file tree
Showing 12 changed files with 514 additions and 91 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ or Yarn
[boolean] [default: true]
-d, --date CHANGELOG.md release date in the form of a valid date
string. Uses system new Date([your date])
[string] [default: "2022-10-11T04:24:24.472Z"]
[string] [default: "2022-10-13T12:25:39.055Z"]
-n, --non-cc Allow non-conventional commits to apply a semver weight and
appear in CHANGELOG.md under a general type description.
[boolean] [default: false]
-o, --override Use a version you define. [string]
-r, --dry-run Generate CHANGELOG.md sample output
[boolean] [default: false]
Expand Down
22 changes: 21 additions & 1 deletion bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const {
'commit-path': commitPath,
date,
'dry-run': isDryRun,
'non-cc': isAllowNonConventionalCommits,
override: overrideVersion,
'pr-path': prPath,
'remote-url': remoteUrl
Expand All @@ -33,6 +34,13 @@ const {
describe: 'CHANGELOG.md release date in the form of a valid date string. Uses system new Date([your date])',
type: 'string'
})
.option('n', {
alias: 'non-cc',
default: false,
describe:
'Allow non-conventional commits to apply a semver weight and appear in CHANGELOG.md under a general type description.',
type: 'boolean'
})
.option('o', {
alias: 'override',
describe: 'Use a version you define.',
Expand Down Expand Up @@ -63,11 +71,23 @@ const {
}).argv;

if (process.env.NODE_ENV === 'test') {
process.stdout.write(JSON.stringify({ commitPath, date, isDryRun, isCommit, overrideVersion, prPath, remoteUrl }));
process.stdout.write(
JSON.stringify({
commitPath,
date,
isAllowNonConventionalCommits,
isDryRun,
isCommit,
overrideVersion,
prPath,
remoteUrl
})
);
} else {
commitChangelog({
commitPath,
date,
isAllowNonConventionalCommits,
isDryRun,
isCommit,
overrideVersion,
Expand Down
8 changes: 4 additions & 4 deletions src/__tests__/__snapshots__/files.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ All notable changes to this project will be documented in this file.
## ¯\\_(ツ)_/¯ (2022-10-01)
### Features
* **dolor** issues/20 sit enhancements (#8) (53a123)
* **dolor** issues/20 sit enhancements (#8) (53a1234)
### Code Refactoring
* **file** lorem updates (#8) (1f1234)
* **file** lorem updates (#8) (1f12345)
### Chores
* **build** npm packages (#15) (e5c456)
* **build** npm packages (#15) (e5c456e)
### Bug Fixes
* **build** eslint, jsdoc updates (#16) (d12345)
* **build** eslint, jsdoc updates (#16) (d123453)
"
`;
Expand Down
64 changes: 64 additions & 0 deletions src/__tests__/__snapshots__/global.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,69 @@ exports[`Global should return specific properties: specific properties 1`] = `
"YELLOW": "",
},
"contextPath": "../src/__fixtures__",
"conventionalCommitType": {
"build": {
"description": "Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)",
"title": "Builds",
"value": "build",
},
"chore": {
"description": "Other changes that don't modify src or test files",
"title": "Chores",
"value": "chore",
},
"ci": {
"description": "Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)",
"title": "Continuous Integrations",
"value": "ci",
},
"docs": {
"description": "Documentation only changes",
"title": "Documentation",
"value": "docs",
},
"feat": {
"description": "A new feature",
"title": "Features",
"value": "feat",
},
"fix": {
"description": "A bug fix",
"title": "Bug Fixes",
"value": "fix",
},
"perf": {
"description": "A code change that improves performance",
"title": "Performance Improvements",
"value": "perf",
},
"refactor": {
"description": "A code change that neither fixes a bug nor adds a feature",
"title": "Code Refactoring",
"value": "refactor",
},
"revert": {
"description": "Reverts a previous commit",
"title": "Reverts",
"value": "revert",
},
"style": {
"description": "Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)",
"title": "Styles",
"value": "style",
},
"test": {
"description": "Adding missing tests or correcting existing tests",
"title": "Tests",
"value": "test",
},
},
"generalCommitType": {
"general": {
"description": "Commits without category",
"title": "General",
"value": "general",
},
},
}
`;
Loading

0 comments on commit 416bcf2

Please sign in to comment.