Skip to content

Commit

Permalink
feat(versioner): add --no-commit-scopes support for single package repos
Browse files Browse the repository at this point in the history
  • Loading branch information
shellscape committed Oct 28, 2024
1 parent 98ec005 commit 2e13d29
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions packages/versioner/src/versioner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import writePackage from 'write-pkg';
import yargs from 'yargs-parser';

const argv = yargs(process.argv.slice(2));
const { dry: dryRun, publish: doPublish, push: doPush, tag: doTag } = argv;
const { commitScopes = true, dry: dryRun, publish: doPublish, push: doPush, tag: doTag } = argv;
const log = getLog({ brand: '@dot', name: '\u001b[1D/versioner' });
const parserOptions = {
noteKeywords: ['BREAKING CHANGE', 'Breaking Change']
Expand All @@ -39,7 +39,9 @@ interface RepoPackage {
}

const commitChanges = async (cwd: string, shortName: string, version: string) => {
const commitMessage = `chore(release): ${shortName} v${version}`;
const commitMessage = commitScopes
? `chore(release): ${shortName} v${version}`
: `chore(release): v${version}`;

if (dryRun) {
log.warn(chalk`{yellow Skipping Git Commit}: ${commitMessage}`);
Expand All @@ -55,7 +57,7 @@ const commitChanges = async (cwd: string, shortName: string, version: string) =>
};

const getCommits = async (shortName: string) => {
const tagPattern = `${shortName}-v*`;
const tagPattern = commitScopes ? `${shortName}-v*` : 'v*';

log.info(chalk`{blue Gathering Commits for tags:} ${tagPattern}`);

Expand All @@ -68,7 +70,8 @@ const getCommits = async (shortName: string) => {

params = ['--no-pager', 'log', `${latestTag}..HEAD`, '--format=%B%n-hash-%n%H🐒💨🙊'];
const individuals = `(([\\w-]+,)+)?${shortName}((,[\\w-]+)+)?`;
const rePlugin = new RegExp(`^[\\w\\!]+\\((${individuals}|\\*)\\)`, 'i');
const scopeExpression = commitScopes ? `\\((${individuals}|\\*)\\)` : '(.+)';
const rePlugin = new RegExp(`^[\\w\\!]+${scopeExpression}`, 'i');
let { stdout } = await execa('git', params);

if (!stdout) {
Expand Down Expand Up @@ -159,7 +162,7 @@ const push = async () => {
};

const tag = async (cwd: string, shortName: string, version: string) => {
const prefix = `${shortName}-`;
const prefix = commitScopes ? `${shortName}-` : '';
const tagName = `${prefix}v${version}`;

if (dryRun || doTag === false) {
Expand Down

0 comments on commit 2e13d29

Please sign in to comment.