intershell 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +301 -0
- package/dist/commands/ci/act.d.ts +13 -0
- package/dist/commands/ci/act.d.ts.map +1 -0
- package/dist/commands/ci/act.js +89 -0
- package/dist/commands/ci/act.js.map +1 -0
- package/dist/commands/ci/attach-affected.d.ts +12 -0
- package/dist/commands/ci/attach-affected.d.ts.map +1 -0
- package/dist/commands/ci/attach-affected.js +83 -0
- package/dist/commands/ci/attach-affected.js.map +1 -0
- package/dist/commands/ci/attach-service-ports.d.ts +10 -0
- package/dist/commands/ci/attach-service-ports.d.ts.map +1 -0
- package/dist/commands/ci/attach-service-ports.js +25 -0
- package/dist/commands/ci/attach-service-ports.js.map +1 -0
- package/dist/commands/commit-check.d.ts +13 -0
- package/dist/commands/commit-check.d.ts.map +1 -0
- package/dist/commands/commit-check.js +110 -0
- package/dist/commands/commit-check.js.map +1 -0
- package/dist/commands/commit.d.ts +16 -0
- package/dist/commands/commit.d.ts.map +1 -0
- package/dist/commands/commit.js +91 -0
- package/dist/commands/commit.js.map +1 -0
- package/dist/commands/dev/check.d.ts +13 -0
- package/dist/commands/dev/check.d.ts.map +1 -0
- package/dist/commands/dev/check.js +91 -0
- package/dist/commands/dev/check.js.map +1 -0
- package/dist/commands/dev/cleanup.d.ts +10 -0
- package/dist/commands/dev/cleanup.d.ts.map +1 -0
- package/dist/commands/dev/cleanup.js +28 -0
- package/dist/commands/dev/cleanup.js.map +1 -0
- package/dist/commands/dev/rm.d.ts +12 -0
- package/dist/commands/dev/rm.d.ts.map +1 -0
- package/dist/commands/dev/rm.js +49 -0
- package/dist/commands/dev/rm.js.map +1 -0
- package/dist/commands/dev/setup.d.ts +10 -0
- package/dist/commands/dev/setup.d.ts.map +1 -0
- package/dist/commands/dev/setup.js +40 -0
- package/dist/commands/dev/setup.js.map +1 -0
- package/dist/commands/local/cleanup.d.ts +12 -0
- package/dist/commands/local/cleanup.d.ts.map +1 -0
- package/dist/commands/local/cleanup.js +62 -0
- package/dist/commands/local/cleanup.js.map +1 -0
- package/dist/commands/local/setup.d.ts +11 -0
- package/dist/commands/local/setup.d.ts.map +1 -0
- package/dist/commands/local/setup.js +55 -0
- package/dist/commands/local/setup.js.map +1 -0
- package/dist/commands/local/vscode.d.ts +17 -0
- package/dist/commands/local/vscode.d.ts.map +1 -0
- package/dist/commands/local/vscode.js +94 -0
- package/dist/commands/local/vscode.js.map +1 -0
- package/dist/commands/update-package-json.d.ts +12 -0
- package/dist/commands/update-package-json.d.ts.map +1 -0
- package/dist/commands/update-package-json.js +82 -0
- package/dist/commands/update-package-json.js.map +1 -0
- package/dist/commands/version/apply.d.ts +16 -0
- package/dist/commands/version/apply.d.ts.map +1 -0
- package/dist/commands/version/apply.js +120 -0
- package/dist/commands/version/apply.js.map +1 -0
- package/dist/commands/version/ci.d.ts +12 -0
- package/dist/commands/version/ci.d.ts.map +1 -0
- package/dist/commands/version/ci.js +67 -0
- package/dist/commands/version/ci.js.map +1 -0
- package/dist/commands/version/prepare.d.ts +19 -0
- package/dist/commands/version/prepare.d.ts.map +1 -0
- package/dist/commands/version/prepare.js +153 -0
- package/dist/commands/version/prepare.js.map +1 -0
- package/dist/core/colorify.d.ts +21 -0
- package/dist/core/colorify.d.ts.map +1 -0
- package/dist/core/colorify.js +56 -0
- package/dist/core/colorify.js.map +1 -0
- package/dist/core/index.d.ts +4 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +3 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/types.d.ts +181 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +5 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/wrapshell.d.ts +19 -0
- package/dist/core/wrapshell.d.ts.map +1 -0
- package/dist/core/wrapshell.js +323 -0
- package/dist/core/wrapshell.js.map +1 -0
- package/dist/entities/affected/affected.d.ts +4 -0
- package/dist/entities/affected/affected.d.ts.map +1 -0
- package/dist/entities/affected/affected.js +20 -0
- package/dist/entities/affected/affected.js.map +1 -0
- package/dist/entities/affected/affected.test.d.ts +2 -0
- package/dist/entities/affected/affected.test.d.ts.map +1 -0
- package/dist/entities/affected/affected.test.js +305 -0
- package/dist/entities/affected/affected.test.js.map +1 -0
- package/dist/entities/affected/index.d.ts +2 -0
- package/dist/entities/affected/index.d.ts.map +1 -0
- package/dist/entities/affected/index.js +2 -0
- package/dist/entities/affected/index.js.map +1 -0
- package/dist/entities/branch/branch.d.ts +8 -0
- package/dist/entities/branch/branch.d.ts.map +1 -0
- package/dist/entities/branch/branch.js +74 -0
- package/dist/entities/branch/branch.js.map +1 -0
- package/dist/entities/branch/branch.test.d.ts +2 -0
- package/dist/entities/branch/branch.test.d.ts.map +1 -0
- package/dist/entities/branch/branch.test.js +316 -0
- package/dist/entities/branch/branch.test.js.map +1 -0
- package/dist/entities/branch/branch.types.d.ts +6 -0
- package/dist/entities/branch/branch.types.d.ts.map +1 -0
- package/dist/entities/branch/branch.types.js +2 -0
- package/dist/entities/branch/branch.types.js.map +1 -0
- package/dist/entities/branch/index.d.ts +3 -0
- package/dist/entities/branch/index.d.ts.map +1 -0
- package/dist/entities/branch/index.js +3 -0
- package/dist/entities/branch/index.js.map +1 -0
- package/dist/entities/commit/commit.d.ts +15 -0
- package/dist/entities/commit/commit.d.ts.map +1 -0
- package/dist/entities/commit/commit.js +196 -0
- package/dist/entities/commit/commit.js.map +1 -0
- package/dist/entities/commit/commit.test.d.ts +26 -0
- package/dist/entities/commit/commit.test.d.ts.map +1 -0
- package/dist/entities/commit/commit.test.js +550 -0
- package/dist/entities/commit/commit.test.js.map +1 -0
- package/dist/entities/commit/commit.types.d.ts +49 -0
- package/dist/entities/commit/commit.types.d.ts.map +1 -0
- package/dist/entities/commit/commit.types.js +31 -0
- package/dist/entities/commit/commit.types.js.map +1 -0
- package/dist/entities/commit/index.d.ts +3 -0
- package/dist/entities/commit/index.d.ts.map +1 -0
- package/dist/entities/commit/index.js +3 -0
- package/dist/entities/commit/index.js.map +1 -0
- package/dist/entities/commit/pr.d.ts +11 -0
- package/dist/entities/commit/pr.d.ts.map +1 -0
- package/dist/entities/commit/pr.js +201 -0
- package/dist/entities/commit/pr.js.map +1 -0
- package/dist/entities/commit/pr.test.d.ts +2 -0
- package/dist/entities/commit/pr.test.d.ts.map +1 -0
- package/dist/entities/commit/pr.test.js +782 -0
- package/dist/entities/commit/pr.test.js.map +1 -0
- package/dist/entities/compose/compose.d.ts +18 -0
- package/dist/entities/compose/compose.d.ts.map +1 -0
- package/dist/entities/compose/compose.js +197 -0
- package/dist/entities/compose/compose.js.map +1 -0
- package/dist/entities/compose/compose.test.d.ts +2 -0
- package/dist/entities/compose/compose.test.d.ts.map +1 -0
- package/dist/entities/compose/compose.test.js +406 -0
- package/dist/entities/compose/compose.test.js.map +1 -0
- package/dist/entities/compose/compose.types.d.ts +77 -0
- package/dist/entities/compose/compose.types.d.ts.map +1 -0
- package/dist/entities/compose/compose.types.js +2 -0
- package/dist/entities/compose/compose.types.js.map +1 -0
- package/dist/entities/compose/index.d.ts +3 -0
- package/dist/entities/compose/index.d.ts.map +1 -0
- package/dist/entities/compose/index.js +3 -0
- package/dist/entities/compose/index.js.map +1 -0
- package/dist/entities/entities.shell.d.ts +29 -0
- package/dist/entities/entities.shell.d.ts.map +1 -0
- package/dist/entities/entities.shell.js +27 -0
- package/dist/entities/entities.shell.js.map +1 -0
- package/dist/entities/entities.shell.test.d.ts +2 -0
- package/dist/entities/entities.shell.test.d.ts.map +1 -0
- package/dist/entities/entities.shell.test.js +23 -0
- package/dist/entities/entities.shell.test.js.map +1 -0
- package/dist/entities/index.d.ts +12 -0
- package/dist/entities/index.d.ts.map +1 -0
- package/dist/entities/index.js +12 -0
- package/dist/entities/index.js.map +1 -0
- package/dist/entities/intershell-config/intershell-config.d.ts +11 -0
- package/dist/entities/intershell-config/intershell-config.d.ts.map +1 -0
- package/dist/entities/intershell-config/intershell-config.default.d.ts +188 -0
- package/dist/entities/intershell-config/intershell-config.default.d.ts.map +1 -0
- package/dist/entities/intershell-config/intershell-config.default.js +225 -0
- package/dist/entities/intershell-config/intershell-config.default.js.map +1 -0
- package/dist/entities/intershell-config/intershell-config.js +132 -0
- package/dist/entities/intershell-config/intershell-config.js.map +1 -0
- package/dist/entities/intershell-config/intershell-config.test.d.ts +2 -0
- package/dist/entities/intershell-config/intershell-config.test.d.ts.map +1 -0
- package/dist/entities/intershell-config/intershell-config.test.js +102 -0
- package/dist/entities/intershell-config/intershell-config.test.js.map +1 -0
- package/dist/entities/intershell-config/intershell-config.types.d.ts +103 -0
- package/dist/entities/intershell-config/intershell-config.types.d.ts.map +1 -0
- package/dist/entities/intershell-config/intershell-config.types.js +2 -0
- package/dist/entities/intershell-config/intershell-config.types.js.map +1 -0
- package/dist/entities/package/index.d.ts +4 -0
- package/dist/entities/package/index.d.ts.map +1 -0
- package/dist/entities/package/index.js +4 -0
- package/dist/entities/package/index.js.map +1 -0
- package/dist/entities/package/package.d.ts +49 -0
- package/dist/entities/package/package.d.ts.map +1 -0
- package/dist/entities/package/package.js +234 -0
- package/dist/entities/package/package.js.map +1 -0
- package/dist/entities/package/package.shell.d.ts +48 -0
- package/dist/entities/package/package.shell.d.ts.map +1 -0
- package/dist/entities/package/package.shell.js +118 -0
- package/dist/entities/package/package.shell.js.map +1 -0
- package/dist/entities/package/package.test.d.ts +23 -0
- package/dist/entities/package/package.test.d.ts.map +1 -0
- package/dist/entities/package/package.test.js +637 -0
- package/dist/entities/package/package.test.js.map +1 -0
- package/dist/entities/package/package.types.d.ts +48 -0
- package/dist/entities/package/package.types.d.ts.map +1 -0
- package/dist/entities/package/package.types.js +2 -0
- package/dist/entities/package/package.types.js.map +1 -0
- package/dist/entities/package-changelog/index.d.ts +4 -0
- package/dist/entities/package-changelog/index.d.ts.map +1 -0
- package/dist/entities/package-changelog/index.js +4 -0
- package/dist/entities/package-changelog/index.js.map +1 -0
- package/dist/entities/package-changelog/package-changelog.d.ts +20 -0
- package/dist/entities/package-changelog/package-changelog.d.ts.map +1 -0
- package/dist/entities/package-changelog/package-changelog.js +59 -0
- package/dist/entities/package-changelog/package-changelog.js.map +1 -0
- package/dist/entities/package-changelog/package-changelog.types.d.ts +25 -0
- package/dist/entities/package-changelog/package-changelog.types.d.ts.map +1 -0
- package/dist/entities/package-changelog/package-changelog.types.js +2 -0
- package/dist/entities/package-changelog/package-changelog.types.js.map +1 -0
- package/dist/entities/package-changelog/template.d.ts +20 -0
- package/dist/entities/package-changelog/template.d.ts.map +1 -0
- package/dist/entities/package-changelog/template.default.d.ts +10 -0
- package/dist/entities/package-changelog/template.default.d.ts.map +1 -0
- package/dist/entities/package-changelog/template.default.js +85 -0
- package/dist/entities/package-changelog/template.default.js.map +1 -0
- package/dist/entities/package-changelog/template.js +90 -0
- package/dist/entities/package-changelog/template.js.map +1 -0
- package/dist/entities/package-commits/dependency-analyzer.d.ts +35 -0
- package/dist/entities/package-commits/dependency-analyzer.d.ts.map +1 -0
- package/dist/entities/package-commits/dependency-analyzer.js +169 -0
- package/dist/entities/package-commits/dependency-analyzer.js.map +1 -0
- package/dist/entities/package-commits/dependency-analyzer.test.d.ts +2 -0
- package/dist/entities/package-commits/dependency-analyzer.test.d.ts.map +1 -0
- package/dist/entities/package-commits/dependency-analyzer.test.js +25 -0
- package/dist/entities/package-commits/dependency-analyzer.test.js.map +1 -0
- package/dist/entities/package-commits/index.d.ts +3 -0
- package/dist/entities/package-commits/index.d.ts.map +1 -0
- package/dist/entities/package-commits/index.js +3 -0
- package/dist/entities/package-commits/index.js.map +1 -0
- package/dist/entities/package-commits/package-commits.d.ts +33 -0
- package/dist/entities/package-commits/package-commits.d.ts.map +1 -0
- package/dist/entities/package-commits/package-commits.js +149 -0
- package/dist/entities/package-commits/package-commits.js.map +1 -0
- package/dist/entities/package-commits/package-commits.test.d.ts +2 -0
- package/dist/entities/package-commits/package-commits.test.d.ts.map +1 -0
- package/dist/entities/package-commits/package-commits.test.js +40 -0
- package/dist/entities/package-commits/package-commits.test.js.map +1 -0
- package/dist/entities/package-tags/index.d.ts +2 -0
- package/dist/entities/package-tags/index.d.ts.map +1 -0
- package/dist/entities/package-tags/index.js +2 -0
- package/dist/entities/package-tags/index.js.map +1 -0
- package/dist/entities/package-tags/package-tags.d.ts +24 -0
- package/dist/entities/package-tags/package-tags.d.ts.map +1 -0
- package/dist/entities/package-tags/package-tags.js +197 -0
- package/dist/entities/package-tags/package-tags.js.map +1 -0
- package/dist/entities/package-tags/package-tags.test.d.ts +2 -0
- package/dist/entities/package-tags/package-tags.test.d.ts.map +1 -0
- package/dist/entities/package-tags/package-tags.test.js +60 -0
- package/dist/entities/package-tags/package-tags.test.js.map +1 -0
- package/dist/entities/package-version/index.d.ts +3 -0
- package/dist/entities/package-version/index.d.ts.map +1 -0
- package/dist/entities/package-version/index.js +3 -0
- package/dist/entities/package-version/index.js.map +1 -0
- package/dist/entities/package-version/package-version.d.ts +16 -0
- package/dist/entities/package-version/package-version.d.ts.map +1 -0
- package/dist/entities/package-version/package-version.js +166 -0
- package/dist/entities/package-version/package-version.js.map +1 -0
- package/dist/entities/package-version/package-version.test.d.ts +2 -0
- package/dist/entities/package-version/package-version.test.d.ts.map +1 -0
- package/dist/entities/package-version/package-version.test.js +113 -0
- package/dist/entities/package-version/package-version.test.js.map +1 -0
- package/dist/entities/package-version/package-version.types.d.ts +31 -0
- package/dist/entities/package-version/package-version.types.d.ts.map +1 -0
- package/dist/entities/package-version/package-version.types.js +2 -0
- package/dist/entities/package-version/package-version.types.js.map +1 -0
- package/dist/entities/tag/index.d.ts +3 -0
- package/dist/entities/tag/index.d.ts.map +1 -0
- package/dist/entities/tag/index.js +3 -0
- package/dist/entities/tag/index.js.map +1 -0
- package/dist/entities/tag/tag.d.ts +24 -0
- package/dist/entities/tag/tag.d.ts.map +1 -0
- package/dist/entities/tag/tag.js +168 -0
- package/dist/entities/tag/tag.js.map +1 -0
- package/dist/entities/tag/tag.test.d.ts +2 -0
- package/dist/entities/tag/tag.test.d.ts.map +1 -0
- package/dist/entities/tag/tag.test.js +638 -0
- package/dist/entities/tag/tag.test.js.map +1 -0
- package/dist/entities/tag/tag.types.d.ts +35 -0
- package/dist/entities/tag/tag.types.d.ts.map +1 -0
- package/dist/entities/tag/tag.types.js +2 -0
- package/dist/entities/tag/tag.types.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/package.json +73 -0
- package/src/commands/ci/act.ts +95 -0
- package/src/commands/ci/attach-affected.ts +93 -0
- package/src/commands/ci/attach-service-ports.ts +31 -0
- package/src/commands/commit-check.ts +124 -0
- package/src/commands/commit.ts +103 -0
- package/src/commands/dev/check.ts +117 -0
- package/src/commands/dev/cleanup.ts +34 -0
- package/src/commands/dev/rm.ts +66 -0
- package/src/commands/dev/setup.ts +48 -0
- package/src/commands/local/cleanup.ts +74 -0
- package/src/commands/local/setup.ts +68 -0
- package/src/commands/local/vscode.ts +118 -0
- package/src/commands/update-package-json.ts +104 -0
- package/src/commands/version/apply.ts +156 -0
- package/src/commands/version/ci.ts +85 -0
- package/src/commands/version/prepare.ts +217 -0
- package/src/core/colorify.ts +61 -0
- package/src/core/index.ts +3 -0
- package/src/core/types.ts +262 -0
- package/src/core/wrapshell.ts +388 -0
- package/src/entities/affected/affected.test.ts +427 -0
- package/src/entities/affected/affected.ts +22 -0
- package/src/entities/affected/index.ts +1 -0
- package/src/entities/branch/branch.test.ts +348 -0
- package/src/entities/branch/branch.ts +89 -0
- package/src/entities/branch/branch.types.ts +5 -0
- package/src/entities/branch/index.ts +2 -0
- package/src/entities/commit/commit.test.ts +769 -0
- package/src/entities/commit/commit.ts +245 -0
- package/src/entities/commit/commit.types.ts +81 -0
- package/src/entities/commit/index.ts +2 -0
- package/src/entities/commit/pr.test.ts +860 -0
- package/src/entities/commit/pr.ts +241 -0
- package/src/entities/compose/compose.test.ts +496 -0
- package/src/entities/compose/compose.ts +251 -0
- package/src/entities/compose/compose.types.ts +88 -0
- package/src/entities/compose/index.ts +2 -0
- package/src/entities/entities.shell.test.ts +35 -0
- package/src/entities/entities.shell.ts +81 -0
- package/src/entities/index.ts +11 -0
- package/src/entities/intershell-config/intershell-config.default.ts +229 -0
- package/src/entities/intershell-config/intershell-config.test.ts +117 -0
- package/src/entities/intershell-config/intershell-config.ts +143 -0
- package/src/entities/intershell-config/intershell-config.types.ts +118 -0
- package/src/entities/package/index.ts +3 -0
- package/src/entities/package/package.shell.ts +124 -0
- package/src/entities/package/package.test.ts +830 -0
- package/src/entities/package/package.ts +267 -0
- package/src/entities/package/package.types.ts +49 -0
- package/src/entities/package-changelog/index.ts +3 -0
- package/src/entities/package-changelog/package-changelog.ts +81 -0
- package/src/entities/package-changelog/package-changelog.types.ts +30 -0
- package/src/entities/package-changelog/template.default.ts +109 -0
- package/src/entities/package-changelog/template.ts +118 -0
- package/src/entities/package-commits/dependency-analyzer.test.ts +29 -0
- package/src/entities/package-commits/dependency-analyzer.ts +194 -0
- package/src/entities/package-commits/index.ts +2 -0
- package/src/entities/package-commits/package-commits.test.ts +44 -0
- package/src/entities/package-commits/package-commits.ts +191 -0
- package/src/entities/package-tags/index.ts +1 -0
- package/src/entities/package-tags/package-tags.test.ts +73 -0
- package/src/entities/package-tags/package-tags.ts +234 -0
- package/src/entities/package-version/index.ts +2 -0
- package/src/entities/package-version/package-version.test.ts +141 -0
- package/src/entities/package-version/package-version.ts +234 -0
- package/src/entities/package-version/package-version.types.ts +35 -0
- package/src/entities/tag/index.ts +2 -0
- package/src/entities/tag/tag.test.ts +844 -0
- package/src/entities/tag/tag.ts +208 -0
- package/src/entities/tag/tag.types.ts +37 -0
- package/src/index.ts +7 -0
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it, mock } from "bun:test";
|
|
2
|
+
import type { $ } from "bun";
|
|
3
|
+
import type { IConfig } from "../intershell-config/intershell-config.types";
|
|
4
|
+
import { EntityBranch } from "./branch";
|
|
5
|
+
import type { ParsedBranch } from "./branch.types";
|
|
6
|
+
|
|
7
|
+
// Mock the entitiesConfig module
|
|
8
|
+
const mockEntitiesConfig = {
|
|
9
|
+
getConfig: mock(() => ({
|
|
10
|
+
branch: {
|
|
11
|
+
defaultBranch: "main",
|
|
12
|
+
prefixes: ["feature", "bugfix", "hotfix"],
|
|
13
|
+
name: {
|
|
14
|
+
minLength: 3,
|
|
15
|
+
maxLength: 50,
|
|
16
|
+
allowedCharacters: /^[a-zA-Z0-9\-_/]+$/,
|
|
17
|
+
noConsecutiveSeparators: true,
|
|
18
|
+
noLeadingTrailingSeparators: true,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
})),
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// Mock the config module
|
|
25
|
+
mock.module("../config/config", () => ({
|
|
26
|
+
entitiesConfig: mockEntitiesConfig,
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
type BranchConfig = IConfig["branch"];
|
|
30
|
+
|
|
31
|
+
describe.skip("EntityBranch", () => {
|
|
32
|
+
let branch: InstanceType<typeof EntityBranch>;
|
|
33
|
+
let mockConfig: BranchConfig;
|
|
34
|
+
|
|
35
|
+
beforeEach(() => {
|
|
36
|
+
mockConfig = {
|
|
37
|
+
defaultBranch: "main",
|
|
38
|
+
prefixes: ["feature", "bugfix", "hotfix"],
|
|
39
|
+
name: {
|
|
40
|
+
minLength: 3,
|
|
41
|
+
maxLength: 50,
|
|
42
|
+
allowedCharacters: /^[a-zA-Z0-9\-_/]+$/,
|
|
43
|
+
noConsecutiveSeparators: true,
|
|
44
|
+
noLeadingTrailingSeparators: true,
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// Set up the mock config
|
|
49
|
+
mockEntitiesConfig.getConfig.mockReturnValue({
|
|
50
|
+
branch: mockConfig,
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
branch = new EntityBranch();
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
describe("static parseByName", () => {
|
|
57
|
+
const parseTestCases = [
|
|
58
|
+
{
|
|
59
|
+
name: "should parse branch name with prefix and name",
|
|
60
|
+
input: "feature/user-authentication",
|
|
61
|
+
expected: {
|
|
62
|
+
prefix: "feature",
|
|
63
|
+
name: "feature/user-authentication",
|
|
64
|
+
fullName: "feature/user-authentication",
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: "should parse branch name with multiple slashes",
|
|
69
|
+
input: "feature/auth/user-authentication",
|
|
70
|
+
expected: {
|
|
71
|
+
prefix: "feature",
|
|
72
|
+
name: "feature/auth/user-authentication",
|
|
73
|
+
fullName: "feature/auth/user-authentication",
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: "should parse branch name with only prefix",
|
|
78
|
+
input: "feature",
|
|
79
|
+
expected: {
|
|
80
|
+
prefix: "feature",
|
|
81
|
+
name: "feature",
|
|
82
|
+
fullName: "feature",
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: "should parse branch name with no slashes",
|
|
87
|
+
input: "main",
|
|
88
|
+
expected: {
|
|
89
|
+
prefix: undefined,
|
|
90
|
+
name: "main",
|
|
91
|
+
fullName: "main",
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
name: "should handle empty string",
|
|
96
|
+
input: "",
|
|
97
|
+
expected: {
|
|
98
|
+
prefix: undefined,
|
|
99
|
+
name: "",
|
|
100
|
+
fullName: "",
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
];
|
|
104
|
+
|
|
105
|
+
parseTestCases.forEach(({ name, input, expected }) => {
|
|
106
|
+
it(name, () => {
|
|
107
|
+
const result = new EntityBranch().parseByName(input);
|
|
108
|
+
expect(result).toEqual(expected);
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
describe("getCurrentBranch", () => {
|
|
114
|
+
// keep the trailing space to test the trim() function
|
|
115
|
+
const mockCurrentBranch = "test-branch ";
|
|
116
|
+
|
|
117
|
+
beforeEach(async () => {
|
|
118
|
+
// Import and mock entitiesShell methods directly
|
|
119
|
+
const { entitiesShell } = await import("../entities.shell");
|
|
120
|
+
|
|
121
|
+
// Mock gitBranchShowCurrent directly
|
|
122
|
+
entitiesShell.gitBranchShowCurrent = mock(
|
|
123
|
+
() =>
|
|
124
|
+
({
|
|
125
|
+
exitCode: 0,
|
|
126
|
+
text: () => mockCurrentBranch,
|
|
127
|
+
}) as unknown as $.ShellPromise,
|
|
128
|
+
);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it("should handle git command and return trimmed output", async () => {
|
|
132
|
+
const result = await branch.getCurrentBranch();
|
|
133
|
+
expect(result).toBe(mockCurrentBranch.trim());
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
describe("validate", () => {
|
|
138
|
+
describe("with string input", () => {
|
|
139
|
+
const stringInputTests = [
|
|
140
|
+
{
|
|
141
|
+
name: "should validate valid branch name",
|
|
142
|
+
input: "feature/user-auth",
|
|
143
|
+
expected: true as const,
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
name: "should validate default branch",
|
|
147
|
+
input: "main",
|
|
148
|
+
expected: true as const,
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
name: "should validate branch without prefixes when prefixes array is empty",
|
|
152
|
+
input: "any-branch-name",
|
|
153
|
+
setup: () => {
|
|
154
|
+
mockEntitiesConfig.getConfig.mockReturnValue({
|
|
155
|
+
branch: {
|
|
156
|
+
...mockConfig,
|
|
157
|
+
prefixes: [] as string[],
|
|
158
|
+
},
|
|
159
|
+
} as IConfig);
|
|
160
|
+
return new EntityBranch();
|
|
161
|
+
},
|
|
162
|
+
expected: true as const,
|
|
163
|
+
},
|
|
164
|
+
];
|
|
165
|
+
|
|
166
|
+
stringInputTests.forEach(({ name, input, setup, expected }) => {
|
|
167
|
+
it(name, () => {
|
|
168
|
+
const testBranch = setup ? setup() : branch;
|
|
169
|
+
const result = testBranch.validate(input);
|
|
170
|
+
expect(result).toBe(expected);
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
describe("with ParsedBranch input", () => {
|
|
176
|
+
const parsedBranchTests = [
|
|
177
|
+
{
|
|
178
|
+
name: "should validate valid parsed branch",
|
|
179
|
+
input: {
|
|
180
|
+
prefix: "feature",
|
|
181
|
+
name: "user-auth",
|
|
182
|
+
fullName: "feature/user-auth",
|
|
183
|
+
} as ParsedBranch,
|
|
184
|
+
expected: true as const,
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
name: "should validate default branch when parsed",
|
|
188
|
+
input: {
|
|
189
|
+
prefix: "main",
|
|
190
|
+
name: "",
|
|
191
|
+
fullName: "main",
|
|
192
|
+
} as ParsedBranch,
|
|
193
|
+
expected: true as const,
|
|
194
|
+
},
|
|
195
|
+
];
|
|
196
|
+
|
|
197
|
+
parsedBranchTests.forEach(({ name, input, expected }) => {
|
|
198
|
+
it(name, () => {
|
|
199
|
+
const result = branch.validate(input);
|
|
200
|
+
expect(result).toBe(expected);
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
describe("validation rules", () => {
|
|
206
|
+
const validationRuleTests = [
|
|
207
|
+
{
|
|
208
|
+
name: "should reject empty branch name",
|
|
209
|
+
input: "",
|
|
210
|
+
expected: "branch name is empty",
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
name: "should reject branch name shorter than minLength",
|
|
214
|
+
input: "ab",
|
|
215
|
+
expected: "branch name should be at least 3 characters long",
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
name: "should reject branch name longer than maxLength",
|
|
219
|
+
input: "a".repeat(51),
|
|
220
|
+
expected: "branch name should be max 50 characters, received: 51",
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
name: "should reject branch name with invalid characters",
|
|
224
|
+
input: "feature/user@auth",
|
|
225
|
+
expected:
|
|
226
|
+
"branch name can only contain letters, numbers, hyphens, underscores, and forward slashes",
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
name: "should reject branch name with consecutive separators",
|
|
230
|
+
input: "feature--user-auth",
|
|
231
|
+
expected: "branch name should not have consecutive separators",
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
name: "should reject branch name with leading separator",
|
|
235
|
+
input: "-feature/user-auth",
|
|
236
|
+
expected: "branch name should not start or end with separators",
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
name: "should reject branch name with trailing separator",
|
|
240
|
+
input: "feature/user-auth-",
|
|
241
|
+
expected: "branch name should not start or end with separators",
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
name: "should reject branch name without prefix when prefixes are required",
|
|
245
|
+
input: "user-auth",
|
|
246
|
+
expected: "branch name should have a prefix. valid prefixes: feature, bugfix, hotfix",
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
name: "should accept branch name with only prefix",
|
|
250
|
+
input: "feature",
|
|
251
|
+
expected: true as const,
|
|
252
|
+
},
|
|
253
|
+
];
|
|
254
|
+
|
|
255
|
+
validationRuleTests.forEach(({ name, input, expected }) => {
|
|
256
|
+
it(name, () => {
|
|
257
|
+
const result = branch.validate(input);
|
|
258
|
+
expect(result).toBe(expected);
|
|
259
|
+
});
|
|
260
|
+
});
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
describe("edge cases", () => {
|
|
264
|
+
const edgeCaseTests = [
|
|
265
|
+
{
|
|
266
|
+
name: "should handle branch names with only separators",
|
|
267
|
+
input: "---",
|
|
268
|
+
expected: "branch name should not have consecutive separators",
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
name: "should handle branch names with mixed separators",
|
|
272
|
+
input: "feature_-user",
|
|
273
|
+
expected: "branch name should not have consecutive separators",
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
name: "should handle very long branch names",
|
|
277
|
+
input: "a".repeat(100),
|
|
278
|
+
expected: "branch name should be max 50 characters, received: 100",
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
name: "should handle branch names with special characters",
|
|
282
|
+
input: "feature/user#auth",
|
|
283
|
+
expected:
|
|
284
|
+
"branch name can only contain letters, numbers, hyphens, underscores, and forward slashes",
|
|
285
|
+
},
|
|
286
|
+
];
|
|
287
|
+
|
|
288
|
+
edgeCaseTests.forEach(({ name, input, expected }) => {
|
|
289
|
+
it(name, () => {
|
|
290
|
+
const result = branch.validate(input);
|
|
291
|
+
expect(result).toBe(expected);
|
|
292
|
+
});
|
|
293
|
+
});
|
|
294
|
+
});
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
describe("constructor and configuration", () => {
|
|
298
|
+
it("should create instance with provided config", () => {
|
|
299
|
+
expect(branch).toBeInstanceOf(EntityBranch);
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
const configTests = [
|
|
303
|
+
{
|
|
304
|
+
name: "should handle config with no length restrictions",
|
|
305
|
+
setup: () => {
|
|
306
|
+
mockEntitiesConfig.getConfig.mockReturnValue({
|
|
307
|
+
branch: {
|
|
308
|
+
...mockConfig,
|
|
309
|
+
name: {
|
|
310
|
+
...mockConfig.name,
|
|
311
|
+
minLength: 0,
|
|
312
|
+
maxLength: 0,
|
|
313
|
+
},
|
|
314
|
+
},
|
|
315
|
+
} as IConfig);
|
|
316
|
+
return new EntityBranch();
|
|
317
|
+
},
|
|
318
|
+
input: "a",
|
|
319
|
+
expected: "branch name should have a prefix. valid prefixes: feature, bugfix, hotfix",
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
name: "should handle config with no character restrictions",
|
|
323
|
+
setup: () => {
|
|
324
|
+
mockEntitiesConfig.getConfig.mockReturnValue({
|
|
325
|
+
branch: {
|
|
326
|
+
...mockConfig,
|
|
327
|
+
name: {
|
|
328
|
+
...mockConfig.name,
|
|
329
|
+
allowedCharacters: /.*/,
|
|
330
|
+
},
|
|
331
|
+
},
|
|
332
|
+
} as IConfig);
|
|
333
|
+
return new EntityBranch();
|
|
334
|
+
},
|
|
335
|
+
input: "feature/user@auth",
|
|
336
|
+
expected: true as const,
|
|
337
|
+
},
|
|
338
|
+
];
|
|
339
|
+
|
|
340
|
+
configTests.forEach(({ name, setup, input, expected }) => {
|
|
341
|
+
it(name, () => {
|
|
342
|
+
const testBranch = setup();
|
|
343
|
+
const result = testBranch.validate(input);
|
|
344
|
+
expect(result).toBe(expected);
|
|
345
|
+
});
|
|
346
|
+
});
|
|
347
|
+
});
|
|
348
|
+
});
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { entitiesShell } from "../entities.shell";
|
|
2
|
+
import { entitiesConfig } from "../intershell-config/intershell-config";
|
|
3
|
+
import type { ParsedBranch } from "./branch.types";
|
|
4
|
+
|
|
5
|
+
export class EntityBranch {
|
|
6
|
+
parseByName(branchName: string): ParsedBranch {
|
|
7
|
+
const config = entitiesConfig.getConfig().branch;
|
|
8
|
+
const validPrefixes = config.prefixes;
|
|
9
|
+
|
|
10
|
+
// Split the branch name by "/" to get all parts
|
|
11
|
+
const parts = branchName.split("/");
|
|
12
|
+
|
|
13
|
+
// Find the first valid prefix in the parts
|
|
14
|
+
let foundPrefixIndex = -1;
|
|
15
|
+
let foundPrefix = "";
|
|
16
|
+
|
|
17
|
+
for (let i = 0; i < parts.length; i++) {
|
|
18
|
+
if (validPrefixes.includes(parts[i])) {
|
|
19
|
+
foundPrefixIndex = i;
|
|
20
|
+
foundPrefix = parts[i];
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// If we found a valid prefix, use everything from that point as the name
|
|
26
|
+
if (foundPrefixIndex !== -1) {
|
|
27
|
+
const nameParts = parts.slice(foundPrefixIndex);
|
|
28
|
+
return {
|
|
29
|
+
prefix: foundPrefix,
|
|
30
|
+
name: nameParts.join("/"),
|
|
31
|
+
fullName: branchName,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// If no valid prefix found, use the entire name
|
|
36
|
+
return {
|
|
37
|
+
prefix: undefined,
|
|
38
|
+
name: branchName,
|
|
39
|
+
fullName: branchName,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async getCurrentBranch(): Promise<string> {
|
|
44
|
+
const result = await entitiesShell.gitBranchShowCurrent();
|
|
45
|
+
return result.text().trim();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
validate(input: string | ParsedBranch): true | string {
|
|
49
|
+
const branch = typeof input === "string" ? this.parseByName(input) : input;
|
|
50
|
+
|
|
51
|
+
return this.mainValidator(branch);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
private mainValidator(branch: ParsedBranch): true | string {
|
|
55
|
+
const config = entitiesConfig.getConfig().branch;
|
|
56
|
+
|
|
57
|
+
if (!branch.fullName) return "branch name is empty";
|
|
58
|
+
if (config.name.minLength && branch.fullName.length < config.name.minLength)
|
|
59
|
+
return `branch name should be at least ${config.name.minLength} characters long`;
|
|
60
|
+
if (config.name.maxLength && branch.fullName.length > config.name.maxLength)
|
|
61
|
+
return `branch name should be max ${config.name.maxLength} characters, received: ${branch.fullName.length}`;
|
|
62
|
+
if (config.name.allowedCharacters && !config.name.allowedCharacters.test(branch.fullName))
|
|
63
|
+
return "branch name can only contain letters, numbers, hyphens, underscores, and forward slashes";
|
|
64
|
+
if (config.name.noConsecutiveSeparators && /[-_/]{2,}/.test(branch.fullName))
|
|
65
|
+
return "branch name should not have consecutive separators";
|
|
66
|
+
if (config.name.noLeadingTrailingSeparators && /(^[-_/]|[-_/]$)/.test(branch.fullName))
|
|
67
|
+
return "branch name should not start or end with separators";
|
|
68
|
+
|
|
69
|
+
if (branch.fullName === config.defaultBranch) {
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (config.prefixes.length === 0) {
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const prefix = branch.prefix ?? "";
|
|
78
|
+
const name = branch.name;
|
|
79
|
+
if (!prefix) {
|
|
80
|
+
return `branch name should have a prefix. valid prefixes: ${config.prefixes.join(", ")}`;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (!name) {
|
|
84
|
+
return "branch name should have a name";
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
}
|