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,208 @@
|
|
|
1
|
+
import { entitiesShell } from "../entities.shell";
|
|
2
|
+
import { entitiesConfig } from "../intershell-config/intershell-config";
|
|
3
|
+
import type { ParsedTag, TagValidationResult } from "./tag.types";
|
|
4
|
+
|
|
5
|
+
export * from "./tag.types";
|
|
6
|
+
|
|
7
|
+
export const EntityTag = {
|
|
8
|
+
parseByName(tagName: string): ParsedTag {
|
|
9
|
+
const format = EntityTag.detectFormat(tagName);
|
|
10
|
+
const prefix = EntityTag.detectPrefix(tagName);
|
|
11
|
+
const name = tagName;
|
|
12
|
+
|
|
13
|
+
return {
|
|
14
|
+
name,
|
|
15
|
+
prefix,
|
|
16
|
+
format,
|
|
17
|
+
};
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
validate(tag: string | ParsedTag): TagValidationResult {
|
|
21
|
+
const parsedTag = typeof tag === "string" ? EntityTag.parseByName(tag) : tag;
|
|
22
|
+
const config = entitiesConfig.getConfig();
|
|
23
|
+
const errors = [];
|
|
24
|
+
|
|
25
|
+
// Name validation
|
|
26
|
+
if (config.tag.name.enabled) {
|
|
27
|
+
const name = parsedTag.name;
|
|
28
|
+
const length = name.length;
|
|
29
|
+
|
|
30
|
+
// Check length
|
|
31
|
+
if (length < config.tag.name.minLength) {
|
|
32
|
+
errors.push(`tag name should be at least ${config.tag.name.minLength} characters long`);
|
|
33
|
+
}
|
|
34
|
+
if (length > config.tag.name.maxLength) {
|
|
35
|
+
errors.push(
|
|
36
|
+
`tag name should be max ${config.tag.name.maxLength} characters, received: ${length}`,
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Check allowed characters
|
|
41
|
+
if (!config.tag.name.allowedCharacters.test(name)) {
|
|
42
|
+
errors.push(
|
|
43
|
+
`tag name contains invalid characters. allowed: ${config.tag.name.allowedCharacters.source}`,
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Check no spaces
|
|
48
|
+
if (config.tag.name.noSpaces && name.includes(" ")) {
|
|
49
|
+
errors.push("tag name should not contain spaces");
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Check no special chars
|
|
53
|
+
if (config.tag.name.noSpecialChars) {
|
|
54
|
+
const specialChars = /[!@#$%^&*()_+\-=[\]{};':"\\|,.<>/?]/;
|
|
55
|
+
if (specialChars.test(name)) {
|
|
56
|
+
errors.push("tag name should not contain special characters");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return { isValid: errors.length === 0, errors };
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
// Pure Git tag operations (no prefix knowledge)
|
|
65
|
+
async listTags(prefix: string): Promise<string[]> {
|
|
66
|
+
const result = await entitiesShell.gitTagList(prefix);
|
|
67
|
+
return result.text().trim().split("\n").filter(Boolean);
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
async getLatestTag(prefix: string): Promise<string | null> {
|
|
71
|
+
const result = await entitiesShell.gitTagLatest(prefix);
|
|
72
|
+
|
|
73
|
+
if (result.exitCode !== 0) {
|
|
74
|
+
throw new Error(`Could not get latest tag for pattern ${prefix}`);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const tag = result.text().trim();
|
|
78
|
+
return tag || null;
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
async getTagSha(tagName: string): Promise<string> {
|
|
82
|
+
const result = await entitiesShell.gitRevParse(tagName);
|
|
83
|
+
if (result.exitCode === 0) {
|
|
84
|
+
return result.text().trim();
|
|
85
|
+
}
|
|
86
|
+
throw new Error(`Tag ${tagName} not found`);
|
|
87
|
+
},
|
|
88
|
+
|
|
89
|
+
async tagExists(tagName: string): Promise<boolean> {
|
|
90
|
+
const result = await entitiesShell.gitTagExists(tagName);
|
|
91
|
+
return result.exitCode === 0 && result.text().trim() === tagName;
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
async createTag(
|
|
95
|
+
tagName: string,
|
|
96
|
+
message: string,
|
|
97
|
+
options: { force?: boolean; push?: boolean } = {},
|
|
98
|
+
): Promise<void> {
|
|
99
|
+
const { force = false, push = false } = options;
|
|
100
|
+
|
|
101
|
+
if (!force && (await EntityTag.tagExists(tagName))) {
|
|
102
|
+
throw new Error(`Tag ${tagName} already exists, use --force to override`);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Validate tag name structure
|
|
106
|
+
const validation = EntityTag.validate(tagName);
|
|
107
|
+
if (!validation.isValid) {
|
|
108
|
+
throw new Error(`Tag ${tagName} is invalid: ${validation.errors.join(", ")}`);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
try {
|
|
112
|
+
await entitiesShell.gitTag(tagName, message, { force: force ? "-f" : "" });
|
|
113
|
+
} catch (error) {
|
|
114
|
+
throw new Error(
|
|
115
|
+
`Failed to create tag ${tagName}: ${error instanceof Error ? error.message : String(error)}`,
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (push) {
|
|
120
|
+
try {
|
|
121
|
+
await entitiesShell.gitPushTag(tagName);
|
|
122
|
+
} catch (error) {
|
|
123
|
+
throw new Error(
|
|
124
|
+
`Failed to push tag ${tagName}: ${error instanceof Error ? error.message : String(error)}`,
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
|
|
130
|
+
async deleteTag(tagName: string, deleteRemote = false): Promise<void> {
|
|
131
|
+
if (!(await EntityTag.tagExists(tagName))) {
|
|
132
|
+
throw new Error(`Tag ${tagName} does not exist`);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
try {
|
|
136
|
+
await entitiesShell.gitDeleteTag(tagName);
|
|
137
|
+
} catch (error) {
|
|
138
|
+
throw new Error(
|
|
139
|
+
`Failed to delete tag ${tagName}: ${error instanceof Error ? error.message : String(error)}`,
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (deleteRemote) {
|
|
144
|
+
try {
|
|
145
|
+
await entitiesShell.gitPushTag(`:refs/tags/${tagName}`);
|
|
146
|
+
} catch (error) {
|
|
147
|
+
throw new Error(
|
|
148
|
+
`Failed to delete remote tag ${tagName}: ${error instanceof Error ? error.message : String(error)}`,
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
|
|
154
|
+
async getTagInfo(tagName: string): Promise<{ date: string; message: string }> {
|
|
155
|
+
const result = await entitiesShell.gitTagInfo(tagName);
|
|
156
|
+
|
|
157
|
+
if (result.exitCode === 0) {
|
|
158
|
+
const lines = result.text?.().trim?.().split("\n").filter(Boolean) ?? [];
|
|
159
|
+
if (lines.length >= 2) {
|
|
160
|
+
return {
|
|
161
|
+
date: lines[0],
|
|
162
|
+
message: lines[1],
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
throw new Error(`Could not get info for tag ${tagName}`);
|
|
167
|
+
},
|
|
168
|
+
|
|
169
|
+
async getBaseCommitSha(from?: string): Promise<string> {
|
|
170
|
+
if (from) {
|
|
171
|
+
// Check if it's a tag, commit hash, or branch
|
|
172
|
+
const result = await entitiesShell.gitRevParse(from);
|
|
173
|
+
if (result.exitCode !== 0) {
|
|
174
|
+
throw new Error(`Invalid reference: ${from}. Not found as tag, branch, or commit.`);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return result.text().trim();
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// Return first commit if no reference provided
|
|
181
|
+
const result = await entitiesShell.gitFirstCommit();
|
|
182
|
+
if (result.exitCode !== 0) {
|
|
183
|
+
throw new Error("Could not find first commit");
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return result.text().trim();
|
|
187
|
+
},
|
|
188
|
+
|
|
189
|
+
// Utility methods
|
|
190
|
+
detectFormat(tagName: string): "semver" | "calver" | "custom" | undefined {
|
|
191
|
+
if (!tagName) return undefined; // empty tag
|
|
192
|
+
if (/^v?\d+\.\d+\.\d+/.test(tagName)) return "semver"; // v1.0.0
|
|
193
|
+
if (/^\d{4}\.\d{2}\.\d{2}/.test(tagName)) return "calver"; // 2025.08.18
|
|
194
|
+
return "custom"; // custom-format
|
|
195
|
+
},
|
|
196
|
+
|
|
197
|
+
detectPrefix(tagName: string): string | undefined {
|
|
198
|
+
if (!tagName) return undefined; // empty tag
|
|
199
|
+
const firstPart = tagName.split(".")[0].replace(/[0-9]/g, ""); // v1.0.0 -> v
|
|
200
|
+
if (/^[a-zA-Z-]+/.test(firstPart)) return firstPart; // v1.0.0 -> v, intershell-v1.0.0 -> intershell-v
|
|
201
|
+
return undefined; // 1.0.0 -> undefined
|
|
202
|
+
},
|
|
203
|
+
|
|
204
|
+
getVersionFromTag(tagName: string): string {
|
|
205
|
+
const prefix = EntityTag.detectPrefix(tagName) || "";
|
|
206
|
+
return tagName.replace(prefix, "");
|
|
207
|
+
},
|
|
208
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
type Validator = (tag: ParsedTag) => true | string;
|
|
2
|
+
|
|
3
|
+
export interface TagConfig {
|
|
4
|
+
readonly format: {
|
|
5
|
+
readonly list: readonly string[];
|
|
6
|
+
readonly validator?: Validator;
|
|
7
|
+
};
|
|
8
|
+
readonly prefix: {
|
|
9
|
+
readonly list: readonly string[];
|
|
10
|
+
readonly validator?: Validator;
|
|
11
|
+
};
|
|
12
|
+
readonly name: {
|
|
13
|
+
readonly minLength: number;
|
|
14
|
+
readonly maxLength: number;
|
|
15
|
+
readonly allowedCharacters: RegExp;
|
|
16
|
+
readonly noSpaces: boolean;
|
|
17
|
+
readonly noSpecialChars: boolean;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface ParsedTag {
|
|
22
|
+
readonly name: string;
|
|
23
|
+
readonly prefix?: string;
|
|
24
|
+
readonly format?: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface TagValidationResult {
|
|
28
|
+
readonly isValid: boolean;
|
|
29
|
+
readonly errors: string[];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface TagRule {
|
|
33
|
+
readonly section: string;
|
|
34
|
+
readonly question: string;
|
|
35
|
+
readonly validator: Validator;
|
|
36
|
+
readonly list?: readonly string[];
|
|
37
|
+
}
|