Skip to content

build: Upgrade to Beemo configs. #20

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

Merged
merged 5 commits into from
Mar 3, 2022
Merged
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ node_modules/
# Configs
.babelrc
.eslintignore
.eslintrc.js
/.eslintrc.js
.flowconfig
.prettierignore
babel.config.js
Expand Down
8 changes: 8 additions & 0 deletions beemo.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// eslint-disable-next-line import/no-default-export
export default {
drivers: ['babel', 'eslint', 'jest', 'prettier', 'typescript'],
module: '@beemo/dev',
settings: {
node: true,
},
};
27 changes: 6 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,46 +10,31 @@
"main": "./index.js",
"types": "./lib/index.d.ts",
"engines": {
"node": ">=10.10.0"
"node": ">=12.20.0"
},
"repository": "https://github.com/beemojs/conventional-changelog-beemo",
"author": "Miles Johnson",
"license": "MIT",
"scripts": {
"prepare": "beemo create-config --silent",
"prepare": "beemo create-config",
"build": "beemo typescript",
"check": "yarn run type && yarn run test && yarn run lint",
"coverage": "yarn run jest --coverage",
"lint": "beemo eslint",
"jest": "beemo jest -i",
"test": "beemo jest -i",
"format": "beemo prettier",
"release": "npx np --yolo",
"type": "beemo typescript --noEmit",
"prerelease": "yarn test && yarn run build",
"pretest": "yarn run type",
"test": "yarn run jest",
"posttest": "yarn run lint"
"prerelease": "yarn run build && yarn run check"
},
"devDependencies": {
"@milesj/build-tools": "^2.17.0",
"@beemo/dev": "^1.7.8",
"@types/node": "^14.14.25",
"@types/shelljs": "^0.8.8",
"conventional-changelog-core": "^4.2.2",
"conventional-recommended-bump": "^6.1.0",
"shelljs": "^0.8.4"
},
"beemo": {
"module": "@milesj/build-tools",
"drivers": [
"babel",
"eslint",
"jest",
"prettier",
"typescript"
],
"settings": {
"node": true
}
},
"funding": {
"type": "ko-fi",
"url": "https://ko-fi.com/milesjohnson"
Expand Down
20 changes: 9 additions & 11 deletions src/checkCommitFormat.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import { COMMIT_FORMAT_PREFIX } from './constants';
import { CommitType } from './types';

export default function checkCommitFormat(
commit: string,
): { scope: string; type: CommitType } | null {
const match = commit.match(COMMIT_FORMAT_PREFIX);
export function checkCommitFormat(commit: string): { scope: string; type: CommitType } | null {
const match = commit.match(COMMIT_FORMAT_PREFIX);

if (!match) {
return null;
}
if (!match) {
return null;
}

return {
scope: match[2] || '',
type: match[1] as CommitType,
};
return {
scope: match[2] || '',
type: match[1] as CommitType,
};
}
157 changes: 79 additions & 78 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,83 +1,84 @@
import { Group } from './types';

// eslint-disable-next-line security/detect-unsafe-regex
export const COMMIT_FORMAT_PREFIX = /^(break|breaking|build|ci|cd|deps|docs|feature|fix|internal|misc|new|patch|perf|release|revert|security|style|styles|test|tests|type|types|update)(?:\(([a-zA-Z0-9\-., ]+)\))?:/u;
export const COMMIT_FORMAT_PREFIX =
// eslint-disable-next-line unicorn/no-unsafe-regex
/^(break|breaking|build|ci|cd|deps|docs|feature|fix|internal|misc|new|patch|perf|release|revert|security|style|styles|test|tests|type|types|update)(?:\(([a-zA-Z0-9\-., ]+)\))?:/u;

export const GROUPS: Group[] = [
{
bump: 'major',
emoji: '💥',
label: 'Breaking',
types: ['break', 'breaking'],
},
{
bump: 'patch',
emoji: '📦',
label: 'Dependencies',
types: ['deps'],
},
{
emoji: '📘',
label: 'Docs',
types: ['docs'],
},
{
bump: 'patch',
emoji: '🐞',
label: 'Fixes',
types: ['fix', 'patch'],
},
{
emoji: '🛠',
label: 'Internals',
types: ['ci', 'cd', 'build', 'test', 'tests', 'internal'],
},
{
bump: 'patch',
emoji: '📋',
label: 'Misc',
types: ['misc'],
},
{
bump: 'major',
emoji: '🎉',
label: 'Release',
types: ['release'],
},
{
bump: 'patch',
emoji: '↩️',
label: 'Reverts',
types: ['revert'],
},
{
bump: 'patch',
emoji: '🔑',
label: 'Security',
types: ['security'],
},
{
bump: 'patch',
emoji: '🎨',
label: 'Styles',
types: ['style', 'styles'],
},
{
bump: 'patch',
emoji: '⚡️',
label: 'Performance',
types: ['perf'],
},
{
bump: 'patch',
emoji: '⚙️',
label: 'Types',
types: ['type', 'types'],
},
{
bump: 'minor',
emoji: '🚀',
label: 'Updates',
types: ['new', 'update', 'feature'],
},
{
bump: 'major',
emoji: '💥',
label: 'Breaking',
types: ['break', 'breaking'],
},
{
bump: 'patch',
emoji: '📦',
label: 'Dependencies',
types: ['deps'],
},
{
emoji: '📘',
label: 'Docs',
types: ['docs'],
},
{
bump: 'patch',
emoji: '🐞',
label: 'Fixes',
types: ['fix', 'patch'],
},
{
emoji: '🛠',
label: 'Internals',
types: ['ci', 'cd', 'build', 'test', 'tests', 'internal'],
},
{
bump: 'patch',
emoji: '📋',
label: 'Misc',
types: ['misc'],
},
{
bump: 'major',
emoji: '🎉',
label: 'Release',
types: ['release'],
},
{
bump: 'patch',
emoji: '↩️',
label: 'Reverts',
types: ['revert'],
},
{
bump: 'patch',
emoji: '🔑',
label: 'Security',
types: ['security'],
},
{
bump: 'patch',
emoji: '🎨',
label: 'Styles',
types: ['style', 'styles'],
},
{
bump: 'patch',
emoji: '⚡️',
label: 'Performance',
types: ['perf'],
},
{
bump: 'patch',
emoji: '⚙️',
label: 'Types',
types: ['type', 'types'],
},
{
bump: 'minor',
emoji: '🚀',
label: 'Updates',
types: ['new', 'update', 'feature'],
},
];
6 changes: 3 additions & 3 deletions src/conventionalChangelog.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import parserOpts from './parserOpts';
import writerOpts from './writerOpts';
import { parserOpts } from './parserOpts';
import { writerOpts } from './writerOpts';

export default { parserOpts, writerOpts };
export const conventionalChangelog = { parserOpts, writerOpts };
12 changes: 6 additions & 6 deletions src/getTypeGroup.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { GROUPS } from './constants';
import { CommitType, Group } from './types';

export default function getTypeGroup(type: CommitType): Group {
const group = GROUPS.find((g) => g.types.includes(type));
export function getTypeGroup(type: CommitType): Group {
const group = GROUPS.find((g) => g.types.includes(type));

if (!group) {
throw new Error(`Cannot find group for type "${type}".`);
}
if (!group) {
throw new Error(`Cannot find group for type "${type}".`);
}

return group;
return group;
}
20 changes: 10 additions & 10 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
* @license https://opensource.org/licenses/MIT
*/

import checkCommitFormat from './checkCommitFormat';
import conventionalChangelog from './conventionalChangelog';
import getTypeGroup from './getTypeGroup';
import parserOpts from './parserOpts';
import recommendedBumpOpts from './recommendedBumpOpts';
import writerOpts from './writerOpts';
import { checkCommitFormat } from './checkCommitFormat';
import { conventionalChangelog } from './conventionalChangelog';
import { getTypeGroup } from './getTypeGroup';
import { parserOpts } from './parserOpts';
import { recommendedBumpOpts } from './recommendedBumpOpts';
import { writerOpts } from './writerOpts';

export { checkCommitFormat, getTypeGroup };

export * from './constants';
export * from './types';

export const config = Promise.resolve({
conventionalChangelog,
parserOpts,
recommendedBumpOpts,
writerOpts,
conventionalChangelog,
parserOpts,
recommendedBumpOpts,
writerOpts,
});
21 changes: 9 additions & 12 deletions src/parserOpts.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import { COMMIT_FORMAT_PREFIX } from './constants';
import { ParserOptions } from './types';

const options: Partial<ParserOptions> = {
headerCorrespondence: ['type', 'scope', 'message'],
// Keep in sync with checkCommitFormat
// eslint-disable-next-line security/detect-non-literal-regexp
headerPattern: new RegExp(`^${COMMIT_FORMAT_PREFIX.source} (.*)$`, 'u'),
mergeCorrespondence: ['pr', 'source'],
mergePattern: /^Merged? pull request #(\d+) from (.*)/u,
noteKeywords: 'Note',
revertCorrespondence: [],
revertPattern: /^Revert/u,
export const parserOpts: Partial<ParserOptions> = {
headerCorrespondence: ['type', 'scope', 'message'],
// Keep in sync with checkCommitFormat
headerPattern: new RegExp(`^${COMMIT_FORMAT_PREFIX.source} (.*)$`, 'u'),
mergeCorrespondence: ['pr', 'source'],
mergePattern: /^Merged? pull request #(\d+) from (.*)/u,
noteKeywords: 'Note',
revertCorrespondence: [],
revertPattern: /^Revert/u,
};

export default options;
Loading