diff --git a/package-lock.json b/package-lock.json index 96e2a20..edb20b5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14836,7 +14836,7 @@ }, "packages/branch-utilities": { "name": "@shiftcode/branch-utilities", - "version": "5.0.1", + "version": "5.0.2-pr65.0", "license": "MIT", "engines": { "node": "^20.0.0 || ^22.0.0" @@ -14921,7 +14921,7 @@ }, "packages/publish-helper": { "name": "@shiftcode/publish-helper", - "version": "4.1.1", + "version": "4.1.2-pr65.0", "license": "MIT", "dependencies": { "conventional-changelog-angular": "^8.0.0", @@ -14932,7 +14932,7 @@ "publish-lib": "dist/publish-lib.js" }, "devDependencies": { - "@shiftcode/branch-utilities": "^5.0.1", + "@shiftcode/branch-utilities": "^5.0.2-pr65.0", "@types/yargs": "^17.0.32" }, "engines": { diff --git a/packages/branch-utilities/package.json b/packages/branch-utilities/package.json index 0d4b7c6..9112626 100644 --- a/packages/branch-utilities/package.json +++ b/packages/branch-utilities/package.json @@ -1,6 +1,6 @@ { "name": "@shiftcode/branch-utilities", - "version": "5.0.1", + "version": "5.0.2-pr65.0", "description": "Utilities for local and ci to get branch name and stage", "repository": "https://github.com/shiftcode/sc-commons-public", "license": "MIT", diff --git a/packages/branch-utilities/src/lib/base.utils.spec.ts b/packages/branch-utilities/src/lib/base.utils.spec.ts index befd57d..553d2fd 100644 --- a/packages/branch-utilities/src/lib/base.utils.spec.ts +++ b/packages/branch-utilities/src/lib/base.utils.spec.ts @@ -1,4 +1,4 @@ -import { BranchInfo, getBranchInfo, parseBranchName } from './base.utils.js' +import { BranchInfo, getBranchInfo, isProduction, isPullRequest, parseBranchName } from './base.utils.js' import { CustomGitHubContext, GithubActionEnv, GitHubContext } from './types/index.js' import { CustomScOverrideEnv } from './types/sc-override-env-var.type.js' @@ -109,4 +109,31 @@ describe('base utils', () => { expect(() => parseBranchName('feat/copilot/fix-123')).toThrow() }) }) + + describe('isProduction', () => { + test.each([ + ['main', true], + ['master', true], + ['prod', false], + ['xx1', false], + ['pr1', false], + ['pr1-main', false], + ['xx1-master', false], + ])("when '%s' it returns %s", (stageName, expected) => { + expect(isProduction(stageName)).toBe(expected) + }) + }) + + describe('isPullRequest', () => { + test.each([ + ['pr1', true], + ['pr123456', true], + ['xx1', false], + ['xx123', false], + ['main', false], + ['master', false], + ])("when '%s' it returns %s", (stageName, expected) => { + expect(isPullRequest(stageName)).toBe(expected) + }) + }) }) diff --git a/packages/branch-utilities/src/lib/base.utils.ts b/packages/branch-utilities/src/lib/base.utils.ts index c906fcb..d16872a 100644 --- a/packages/branch-utilities/src/lib/base.utils.ts +++ b/packages/branch-utilities/src/lib/base.utils.ts @@ -165,7 +165,7 @@ export function parseBranchName(branchName: string): { branchId: number; branchN * @return returns true if the stage is 'master' or 'main', false if not */ export function isProduction(stageName: string): boolean { - return REGEX_MASTER.test(stageName) ?? REGEX_MAIN.test(stageName) + return REGEX_MASTER.test(stageName) || REGEX_MAIN.test(stageName) } /** diff --git a/packages/publish-helper/package.json b/packages/publish-helper/package.json index bc50b33..a96b619 100644 --- a/packages/publish-helper/package.json +++ b/packages/publish-helper/package.json @@ -1,6 +1,6 @@ { "name": "@shiftcode/publish-helper", - "version": "4.1.1", + "version": "4.1.2-pr65.0", "description": "scripts for conventional (pre)releases", "repository": "https://github.com/shiftcode/sc-commons-public", "license": "MIT", @@ -32,7 +32,7 @@ "yargs": "^17.7.2" }, "devDependencies": { - "@shiftcode/branch-utilities": "^5.0.1", + "@shiftcode/branch-utilities": "^5.0.2-pr65.0", "@types/yargs": "^17.0.32" }, "peerDependencies": {