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,245 @@
|
|
|
1
|
+
import { entitiesShell } from "../entities.shell";
|
|
2
|
+
import { entitiesConfig } from "../intershell-config/intershell-config";
|
|
3
|
+
import type { IConfig } from "../intershell-config/intershell-config.types";
|
|
4
|
+
import type { CommitMessageData, ParsedCommitData } from "./commit.types";
|
|
5
|
+
import { EntityPr } from "./pr";
|
|
6
|
+
|
|
7
|
+
const conventionalCommitRegex = /^([a-z]+)(\([a-zA-Z0-9@\-,\s/]+\))?(!)?:\s(.+)/;
|
|
8
|
+
const depScopes = ["deps", "dependencies", "dep", "renovate", "dependabot"];
|
|
9
|
+
const getIsMerge = (message: string) =>
|
|
10
|
+
message.startsWith("Merge pull request") || message.startsWith("Merge branch");
|
|
11
|
+
const getIsDependency = (message: string) =>
|
|
12
|
+
message.includes("renovate[bot]") || message.includes("dependabot[bot]");
|
|
13
|
+
|
|
14
|
+
export class EntityCommit {
|
|
15
|
+
private readonly config: IConfig;
|
|
16
|
+
|
|
17
|
+
constructor(config?: IConfig) {
|
|
18
|
+
this.config = config || entitiesConfig.getConfig();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
static parseByMessage(message: string): CommitMessageData {
|
|
22
|
+
const lines = message.split("\n");
|
|
23
|
+
const subject = lines[0];
|
|
24
|
+
const bodyLines = lines.length > 1 ? lines.slice(1).filter((line) => line.trim()) : [];
|
|
25
|
+
|
|
26
|
+
const match = subject.match(conventionalCommitRegex);
|
|
27
|
+
if (!match) {
|
|
28
|
+
const type = getIsMerge(message) ? "merge" : getIsDependency(message) ? "deps" : "other";
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
subject,
|
|
32
|
+
type,
|
|
33
|
+
description: subject,
|
|
34
|
+
scopes: [],
|
|
35
|
+
bodyLines: bodyLines,
|
|
36
|
+
isBreaking: false,
|
|
37
|
+
isMerge: type === "merge",
|
|
38
|
+
isDependency: type === "deps",
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const [, type, scope, breaking, description] = match || [];
|
|
43
|
+
const scopes = scope ? scope.replace(/[()]/g, "").split(",") : [];
|
|
44
|
+
const isBreaking = breaking === "!";
|
|
45
|
+
const isMerge = getIsMerge(message);
|
|
46
|
+
const isDependency = scopes.some((s) => depScopes.includes(s)) || getIsDependency(message);
|
|
47
|
+
|
|
48
|
+
return { subject, type, scopes, description, bodyLines, isMerge, isBreaking, isDependency };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
validateCommitMessage(message: string): string[] {
|
|
52
|
+
if (!message.trim()) return ["commit message cannot be empty"];
|
|
53
|
+
const match = EntityCommit.parseByMessage(message);
|
|
54
|
+
|
|
55
|
+
const errors: string[] = [];
|
|
56
|
+
const commitConfig = this.config.commit;
|
|
57
|
+
|
|
58
|
+
if (match.isMerge) {
|
|
59
|
+
// Validate merge commit
|
|
60
|
+
if (commitConfig.conventional.isMerge?.validator) {
|
|
61
|
+
const validation = commitConfig.conventional.isMerge.validator({ message: match });
|
|
62
|
+
if (typeof validation === "string") errors.push(`isMerge: ${validation}`);
|
|
63
|
+
}
|
|
64
|
+
} else {
|
|
65
|
+
// Validate conventional commit
|
|
66
|
+
// Type validation
|
|
67
|
+
if (commitConfig.conventional.type?.list && commitConfig.conventional.type.list.length > 0) {
|
|
68
|
+
const validTypes = commitConfig.conventional.type.list.map((t) => t.type);
|
|
69
|
+
if (!validTypes.includes(match.type)) {
|
|
70
|
+
errors.push(`type: invalid type "${match.type}". valid types: ${validTypes.join(", ")}`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Scope validation
|
|
75
|
+
if (
|
|
76
|
+
commitConfig.conventional.scopes?.list &&
|
|
77
|
+
commitConfig.conventional.scopes.list.length > 0
|
|
78
|
+
) {
|
|
79
|
+
if (match.scopes && match.scopes.length > 0) {
|
|
80
|
+
const scopesList = commitConfig.conventional.scopes.list;
|
|
81
|
+
const invalidScopes = match.scopes.filter((scope) => !scopesList.includes(scope));
|
|
82
|
+
if (invalidScopes.length > 0) {
|
|
83
|
+
errors.push(
|
|
84
|
+
`scopes: invalid scope(s) "${invalidScopes.join(", ")}". valid scopes: ${scopesList.join(", ")}`,
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Description validation
|
|
91
|
+
if (commitConfig.conventional.description) {
|
|
92
|
+
const desc = match.description;
|
|
93
|
+
const minLength = commitConfig.conventional.description.minLength;
|
|
94
|
+
if (minLength !== undefined && desc.length < minLength) {
|
|
95
|
+
errors.push(`description: should be at least ${minLength} characters long`);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const maxLength = commitConfig.conventional.description.maxLength;
|
|
99
|
+
if (maxLength !== undefined && desc.length > maxLength) {
|
|
100
|
+
errors.push(`description: should be max ${maxLength} chars, received: ${desc.length}`);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (commitConfig.conventional.description.shouldNotEndWithPeriod && desc.endsWith(".")) {
|
|
104
|
+
errors.push("description: should not end with a period");
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (
|
|
108
|
+
commitConfig.conventional.description.shouldNotStartWithType &&
|
|
109
|
+
commitConfig.conventional.type?.list
|
|
110
|
+
) {
|
|
111
|
+
const firstWord = desc.split(" ")[0].toLowerCase();
|
|
112
|
+
const validTypes = commitConfig.conventional.type.list.map((t) => t.type);
|
|
113
|
+
if (validTypes.includes(firstWord)) {
|
|
114
|
+
errors.push(
|
|
115
|
+
`description: should not start with a type "${firstWord}". You're either duplicating the type or should use a different type.`,
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Body lines validation
|
|
122
|
+
if (commitConfig.conventional.bodyLines && match.bodyLines.length > 0) {
|
|
123
|
+
const minLength = commitConfig.conventional.bodyLines.minLength;
|
|
124
|
+
if (minLength !== undefined && match.bodyLines.every((line) => line.length < minLength)) {
|
|
125
|
+
errors.push(`bodyLines: should be ${minLength} characters or more`);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const maxLength = commitConfig.conventional.bodyLines.maxLength;
|
|
129
|
+
if (maxLength !== undefined && match.bodyLines.every((line) => line.length > maxLength)) {
|
|
130
|
+
errors.push(`bodyLines: should be ${maxLength} characters or less`);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Breaking change validation
|
|
135
|
+
if (match.isBreaking && commitConfig.conventional.type?.list) {
|
|
136
|
+
const breakingAllowedTypes = commitConfig.conventional.type.list
|
|
137
|
+
.filter((t) => t.breakingAllowed)
|
|
138
|
+
.map((t) => t.type);
|
|
139
|
+
if (!breakingAllowedTypes.includes(match.type)) {
|
|
140
|
+
errors.push(
|
|
141
|
+
`isBreaking: breaking change is not allowed for this type, allowed types: ${breakingAllowedTypes.join(", ")}`,
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
if (match.description.length < 10) {
|
|
145
|
+
errors.push(
|
|
146
|
+
"isBreaking: breaking change description should be at least 10 characters long",
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return errors;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
formatCommitMessage(message: CommitMessageData): string {
|
|
156
|
+
let formatted = `${message.type}`;
|
|
157
|
+
if (message.scopes && message.scopes.length > 0) formatted += `(${message.scopes.join(", ")})`;
|
|
158
|
+
formatted += `: ${message.description}`;
|
|
159
|
+
if (message.bodyLines && message.bodyLines.length > 0)
|
|
160
|
+
formatted += `\n\n${message.bodyLines.join("\n")}`;
|
|
161
|
+
if (message.isBreaking) formatted += `\n\nBREAKING CHANGE: ${message.description}`;
|
|
162
|
+
|
|
163
|
+
return formatted;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
async parseByHash(hash: string): Promise<ParsedCommitData> {
|
|
167
|
+
try {
|
|
168
|
+
const commitResult = await entitiesShell.gitShow(hash);
|
|
169
|
+
if (commitResult.exitCode !== 0)
|
|
170
|
+
throw new Error(
|
|
171
|
+
`Could not find commit ${hash}, exit code: ${commitResult.exitCode}, text: ${commitResult.text()}`,
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
const lines = commitResult.text().trim().split("\n");
|
|
175
|
+
const [commitHash, author, date, subject, ...bodyLines] = lines;
|
|
176
|
+
if (!subject) throw new Error(`No subject found for commit ${hash}`);
|
|
177
|
+
|
|
178
|
+
// Get files changed in this commit
|
|
179
|
+
const filesResult = await entitiesShell.gitShowNameOnly(hash);
|
|
180
|
+
|
|
181
|
+
const files =
|
|
182
|
+
filesResult.exitCode === 0 ? filesResult.text().trim().split("\n").filter(Boolean) : [];
|
|
183
|
+
|
|
184
|
+
const message = EntityCommit.parseByMessage(`${subject}\n${bodyLines.join("\n")}`);
|
|
185
|
+
const config = this.config || entitiesConfig.getConfig();
|
|
186
|
+
const parseByHash = this.parseByHash.bind(this);
|
|
187
|
+
|
|
188
|
+
return {
|
|
189
|
+
message,
|
|
190
|
+
info: {
|
|
191
|
+
hash: commitHash,
|
|
192
|
+
author: author || undefined,
|
|
193
|
+
date: date || undefined,
|
|
194
|
+
},
|
|
195
|
+
pr: message.isMerge
|
|
196
|
+
? await new EntityPr(config).getPRInfo(parseByHash, hash, message)
|
|
197
|
+
: undefined,
|
|
198
|
+
files,
|
|
199
|
+
};
|
|
200
|
+
} catch (error) {
|
|
201
|
+
throw new Error(
|
|
202
|
+
`Failed to parse commit ${hash}: ${error instanceof Error ? error.message : String(error)}`,
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
async getStagedFiles(): Promise<{ stagedFiles: string[] }> {
|
|
208
|
+
const status = await entitiesShell.gitStatus().text();
|
|
209
|
+
const lines = status.split("\n").filter(Boolean);
|
|
210
|
+
|
|
211
|
+
return {
|
|
212
|
+
stagedFiles: lines
|
|
213
|
+
.filter((line) => line.startsWith("A ") || line.startsWith("M "))
|
|
214
|
+
.map((line) => line.substring(3)),
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
async validateStagedFiles(files: string[]): Promise<string[]> {
|
|
219
|
+
const errors: string[] = [];
|
|
220
|
+
const stagedConfig = this.config.commit.staged || [];
|
|
221
|
+
|
|
222
|
+
// Process each file individually for proper ignore logic and error reporting
|
|
223
|
+
for (const file of files) {
|
|
224
|
+
for (const pattern of stagedConfig) {
|
|
225
|
+
const fileNameMatches = pattern.filePattern.some((p) => p.test(file));
|
|
226
|
+
if (!fileNameMatches) continue;
|
|
227
|
+
|
|
228
|
+
const stagedDiff = await entitiesShell.gitDiff(file).text();
|
|
229
|
+
const contentMatches = pattern.contentPattern?.some((p) => p.test(stagedDiff)) ?? true;
|
|
230
|
+
|
|
231
|
+
// Check if this is a new file and should be ignored
|
|
232
|
+
const isNewFile =
|
|
233
|
+
stagedDiff.includes("new file mode") || stagedDiff.includes("--- /dev/null");
|
|
234
|
+
const shouldIgnore = pattern.ignore?.mode === "create" && isNewFile;
|
|
235
|
+
const isDisabled = pattern.disabled;
|
|
236
|
+
|
|
237
|
+
if (contentMatches && !shouldIgnore && !isDisabled) {
|
|
238
|
+
errors.push(`${file}: ${pattern.description}`);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
return errors;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { ParsedBranch } from "../branch/branch.types";
|
|
2
|
+
import type { PRCategory } from "../intershell-config/intershell-config.types";
|
|
3
|
+
|
|
4
|
+
export type CommitMessageData =
|
|
5
|
+
| {
|
|
6
|
+
subject: string;
|
|
7
|
+
type: "other";
|
|
8
|
+
scopes?: string[];
|
|
9
|
+
description: string;
|
|
10
|
+
bodyLines: string[];
|
|
11
|
+
isBreaking: boolean;
|
|
12
|
+
isMerge: boolean;
|
|
13
|
+
isDependency: boolean;
|
|
14
|
+
}
|
|
15
|
+
| {
|
|
16
|
+
subject: string;
|
|
17
|
+
type: string;
|
|
18
|
+
scopes?: string[];
|
|
19
|
+
description: string;
|
|
20
|
+
bodyLines: string[];
|
|
21
|
+
isBreaking: boolean;
|
|
22
|
+
isMerge: boolean;
|
|
23
|
+
isDependency: boolean;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export interface PRStats {
|
|
27
|
+
readonly commitCount: number;
|
|
28
|
+
readonly fileCount?: number;
|
|
29
|
+
readonly linesAdded?: number;
|
|
30
|
+
readonly linesDeleted?: number;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export type PRInfo = {
|
|
34
|
+
prNumber: string;
|
|
35
|
+
prCategory: PRCategory;
|
|
36
|
+
prStats: PRStats;
|
|
37
|
+
prCommits: ParsedCommitData[];
|
|
38
|
+
prBranchName: ParsedBranch;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const prCategories: Record<PRCategory, { emoji: string; label: string }> = {
|
|
42
|
+
features: {
|
|
43
|
+
emoji: "🚀",
|
|
44
|
+
label: "Feature Releases",
|
|
45
|
+
},
|
|
46
|
+
infrastructure: {
|
|
47
|
+
emoji: "🛠️",
|
|
48
|
+
label: "Infrastructure & Tooling",
|
|
49
|
+
},
|
|
50
|
+
bugfixes: {
|
|
51
|
+
emoji: "🐛",
|
|
52
|
+
label: "Bug Fixes & Improvements",
|
|
53
|
+
},
|
|
54
|
+
refactoring: {
|
|
55
|
+
emoji: "🔄",
|
|
56
|
+
label: "Code Quality & Refactoring",
|
|
57
|
+
},
|
|
58
|
+
documentation: {
|
|
59
|
+
emoji: "📚",
|
|
60
|
+
label: "Documentation",
|
|
61
|
+
},
|
|
62
|
+
dependencies: {
|
|
63
|
+
emoji: "📦",
|
|
64
|
+
label: "Dependency Updates",
|
|
65
|
+
},
|
|
66
|
+
other: {
|
|
67
|
+
emoji: "🔄",
|
|
68
|
+
label: "Other Changes",
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export interface ParsedCommitData {
|
|
73
|
+
message: CommitMessageData;
|
|
74
|
+
info?: {
|
|
75
|
+
hash: string;
|
|
76
|
+
author?: string;
|
|
77
|
+
date?: string;
|
|
78
|
+
};
|
|
79
|
+
pr?: PRInfo;
|
|
80
|
+
files?: string[];
|
|
81
|
+
}
|