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,117 @@
|
|
|
1
|
+
import { describe, expect, mock, test } from "bun:test";
|
|
2
|
+
|
|
3
|
+
describe("Config", () => {
|
|
4
|
+
// Common mock setup for dependencies
|
|
5
|
+
const setupMocks = async () => {
|
|
6
|
+
// Mock EntityPackage methods
|
|
7
|
+
const { EntityPackage } = await import("../package");
|
|
8
|
+
EntityPackage.prototype.readJson = mock(() => ({
|
|
9
|
+
name: "test-package",
|
|
10
|
+
version: "1.0.0",
|
|
11
|
+
}));
|
|
12
|
+
|
|
13
|
+
return { EntityPackage };
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
test.skip("should have default commit configuration", async () => {
|
|
17
|
+
await setupMocks();
|
|
18
|
+
const { entitiesConfig } = await import("./intershell-config");
|
|
19
|
+
const config = entitiesConfig.getConfig();
|
|
20
|
+
|
|
21
|
+
expect(config.commit.conventional.type?.list).toBeDefined();
|
|
22
|
+
expect(config.commit.conventional.type?.list?.length).toBeGreaterThan(0);
|
|
23
|
+
expect(config.commit.staged).toBeDefined();
|
|
24
|
+
expect(config.commit.staged?.length).toBeGreaterThan(0);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test.skip("should have default branch configuration", async () => {
|
|
28
|
+
await setupMocks();
|
|
29
|
+
const { entitiesConfig } = await import("./intershell-config");
|
|
30
|
+
const config = entitiesConfig.getConfig();
|
|
31
|
+
|
|
32
|
+
expect(config.branch.defaultBranch).toBe("main");
|
|
33
|
+
expect(config.branch.prefixes).toEqual([
|
|
34
|
+
"feature",
|
|
35
|
+
"fix",
|
|
36
|
+
"hotfix",
|
|
37
|
+
"release",
|
|
38
|
+
"docs",
|
|
39
|
+
"refactor",
|
|
40
|
+
"ci",
|
|
41
|
+
"chore",
|
|
42
|
+
"wip",
|
|
43
|
+
"renovate",
|
|
44
|
+
]);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test.skip("should have default tag configuration", async () => {
|
|
48
|
+
await setupMocks();
|
|
49
|
+
const { entitiesConfig } = await import("./intershell-config");
|
|
50
|
+
const config = entitiesConfig.getConfig();
|
|
51
|
+
|
|
52
|
+
expect(config.tag.name.enabled).toBe(true);
|
|
53
|
+
expect(config.tag.name.minLength).toBe(1);
|
|
54
|
+
expect(config.tag.name.maxLength).toBe(100);
|
|
55
|
+
expect(config.tag.name.noSpaces).toBe(true);
|
|
56
|
+
expect(config.tag.name.noSpecialChars).toBe(false);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test.skip("should merge custom commit configuration", async () => {
|
|
60
|
+
await setupMocks();
|
|
61
|
+
const { entitiesConfig } = await import("./intershell-config");
|
|
62
|
+
|
|
63
|
+
// Mock custom config as a JSON string (as expected by PackageJson interface)
|
|
64
|
+
const customConfig = {
|
|
65
|
+
commit: {
|
|
66
|
+
conventional: {
|
|
67
|
+
type: {
|
|
68
|
+
list: [
|
|
69
|
+
{
|
|
70
|
+
type: "feat",
|
|
71
|
+
label: "Features",
|
|
72
|
+
description: "A new feature",
|
|
73
|
+
category: "features" as const,
|
|
74
|
+
emoji: "🚀",
|
|
75
|
+
badgeColor: "00D4AA",
|
|
76
|
+
breakingAllowed: true,
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
// Mock EntityPackage to return custom config
|
|
85
|
+
const { EntityPackage } = await import("../package");
|
|
86
|
+
EntityPackage.prototype.readJson = mock(() => ({
|
|
87
|
+
name: "test-package",
|
|
88
|
+
version: "1.0.0",
|
|
89
|
+
intershell: {
|
|
90
|
+
config: JSON.stringify(customConfig),
|
|
91
|
+
},
|
|
92
|
+
}));
|
|
93
|
+
|
|
94
|
+
const config = entitiesConfig.getConfig();
|
|
95
|
+
expect(config.commit.conventional.type?.list?.[0]?.type).toBe("feat");
|
|
96
|
+
expect(config.commit.conventional.type?.list?.[0]?.emoji).toBe("🚀");
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
test("should validate branch name regex pattern", async () => {
|
|
100
|
+
await setupMocks();
|
|
101
|
+
const { entitiesConfig } = await import("./intershell-config");
|
|
102
|
+
const config = entitiesConfig.getConfig();
|
|
103
|
+
const allowedCharacters = config.branch.name.allowedCharacters;
|
|
104
|
+
|
|
105
|
+
expect(allowedCharacters).toBeInstanceOf(RegExp);
|
|
106
|
+
|
|
107
|
+
// Test valid characters
|
|
108
|
+
expect(allowedCharacters.test("feature-branch")).toBe(true);
|
|
109
|
+
expect(allowedCharacters.test("fix_bug_123")).toBe(true);
|
|
110
|
+
expect(allowedCharacters.test("docs/update-readme")).toBe(true);
|
|
111
|
+
|
|
112
|
+
// Test invalid characters
|
|
113
|
+
expect(allowedCharacters.test("feature branch")).toBe(false); // space
|
|
114
|
+
expect(allowedCharacters.test("fix@bug")).toBe(false); // @ symbol
|
|
115
|
+
expect(allowedCharacters.test("docs#update")).toBe(false); // # symbol
|
|
116
|
+
});
|
|
117
|
+
});
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { defaultConfig } from "./intershell-config.default";
|
|
4
|
+
import type { CustomConfigJson, IConfig } from "./intershell-config.types";
|
|
5
|
+
|
|
6
|
+
class Config {
|
|
7
|
+
private config: IConfig;
|
|
8
|
+
|
|
9
|
+
constructor(customConfig?: CustomConfigJson) {
|
|
10
|
+
if (customConfig) {
|
|
11
|
+
this.config = this.mergeConfig(customConfig);
|
|
12
|
+
} else {
|
|
13
|
+
this.config = this.mergeConfig({});
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
getConfig(): IConfig {
|
|
18
|
+
return this.config;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
private mergeConfig(config: CustomConfigJson): IConfig {
|
|
22
|
+
// Load packages for commit scopes if not provided
|
|
23
|
+
let commitScopes: string[] = [];
|
|
24
|
+
if (!config.commit?.conventional?.scopes?.list) {
|
|
25
|
+
try {
|
|
26
|
+
// This is a synchronous operation that reads from the filesystem
|
|
27
|
+
// We'll populate it with available packages
|
|
28
|
+
commitScopes = this.getAvailablePackages();
|
|
29
|
+
} catch {
|
|
30
|
+
commitScopes = [];
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
...defaultConfig,
|
|
36
|
+
commit: {
|
|
37
|
+
...defaultConfig.commit,
|
|
38
|
+
...config.commit,
|
|
39
|
+
conventional: {
|
|
40
|
+
...defaultConfig.commit.conventional,
|
|
41
|
+
...config.commit?.conventional,
|
|
42
|
+
type: {
|
|
43
|
+
...defaultConfig.commit.conventional.type,
|
|
44
|
+
...config.commit?.conventional?.type,
|
|
45
|
+
},
|
|
46
|
+
scopes: {
|
|
47
|
+
...defaultConfig.commit.conventional.scopes,
|
|
48
|
+
...config.commit?.conventional?.scopes,
|
|
49
|
+
list: config.commit?.conventional?.scopes?.list || commitScopes,
|
|
50
|
+
},
|
|
51
|
+
description: {
|
|
52
|
+
...defaultConfig.commit.conventional.description,
|
|
53
|
+
...config.commit?.conventional?.description,
|
|
54
|
+
},
|
|
55
|
+
bodyLines: {
|
|
56
|
+
...defaultConfig.commit.conventional.bodyLines,
|
|
57
|
+
...config.commit?.conventional?.bodyLines,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
staged: config.commit?.staged || defaultConfig.commit.staged,
|
|
61
|
+
} as IConfig["commit"],
|
|
62
|
+
branch: {
|
|
63
|
+
...defaultConfig.branch,
|
|
64
|
+
...config.branch,
|
|
65
|
+
} as IConfig["branch"],
|
|
66
|
+
package: {
|
|
67
|
+
...defaultConfig.package,
|
|
68
|
+
...config.package,
|
|
69
|
+
} as IConfig["package"],
|
|
70
|
+
tag: {
|
|
71
|
+
...defaultConfig.tag,
|
|
72
|
+
...config.tag,
|
|
73
|
+
name: {
|
|
74
|
+
...defaultConfig.tag.name,
|
|
75
|
+
...config.tag?.name,
|
|
76
|
+
},
|
|
77
|
+
} as IConfig["tag"],
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
private getAvailablePackages(): string[] {
|
|
82
|
+
const packages: string[] = ["root"];
|
|
83
|
+
|
|
84
|
+
try {
|
|
85
|
+
// Get workspace root
|
|
86
|
+
const workspaceRoot = process.cwd();
|
|
87
|
+
|
|
88
|
+
// Check for apps directory
|
|
89
|
+
const appsPath = join(workspaceRoot, "apps");
|
|
90
|
+
if (existsSync(appsPath)) {
|
|
91
|
+
const apps = readdirSync(appsPath, { withFileTypes: true })
|
|
92
|
+
.filter((dirent) => dirent.isDirectory())
|
|
93
|
+
.map((dirent) => dirent.name);
|
|
94
|
+
packages.push(...apps);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Check for packages directory
|
|
98
|
+
const packagesPath = join(workspaceRoot, "packages");
|
|
99
|
+
if (existsSync(packagesPath)) {
|
|
100
|
+
const pkgs = readdirSync(packagesPath, { withFileTypes: true })
|
|
101
|
+
.filter((dirent) => dirent.isDirectory())
|
|
102
|
+
.map((dirent) => `@repo/${dirent.name}`);
|
|
103
|
+
packages.push(...pkgs);
|
|
104
|
+
}
|
|
105
|
+
} catch {
|
|
106
|
+
// If we can't read directories, just return basic packages
|
|
107
|
+
packages.push("admin", "api", "storefront", "ui", "utils");
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return packages;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function getCustomConfig(): CustomConfigJson | undefined {
|
|
115
|
+
let customConfig: CustomConfigJson | undefined;
|
|
116
|
+
try {
|
|
117
|
+
// Read root package.json directly
|
|
118
|
+
const rootPackageJsonPath = join(process.cwd(), "package.json");
|
|
119
|
+
const rootPackageJsonContent = readFileSync(rootPackageJsonPath, "utf-8");
|
|
120
|
+
const rootPackageJson = JSON.parse(rootPackageJsonContent);
|
|
121
|
+
|
|
122
|
+
const configFilePath = rootPackageJson.intershell?.config;
|
|
123
|
+
if (!configFilePath) throw new Error();
|
|
124
|
+
|
|
125
|
+
const config = readFileSync(configFilePath, "utf-8");
|
|
126
|
+
customConfig = JSON.parse(config) as CustomConfigJson;
|
|
127
|
+
} catch {
|
|
128
|
+
customConfig = undefined;
|
|
129
|
+
}
|
|
130
|
+
return customConfig;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Lazy initialization to allow mocking in tests
|
|
134
|
+
let _entitiesConfig: Config | undefined;
|
|
135
|
+
|
|
136
|
+
function getEntitiesConfig(): Config {
|
|
137
|
+
if (!_entitiesConfig) {
|
|
138
|
+
_entitiesConfig = new Config(getCustomConfig());
|
|
139
|
+
}
|
|
140
|
+
return _entitiesConfig;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export const entitiesConfig = getEntitiesConfig();
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
export type PRCategory =
|
|
2
|
+
| "features"
|
|
3
|
+
| "bugfixes"
|
|
4
|
+
| "dependencies"
|
|
5
|
+
| "infrastructure"
|
|
6
|
+
| "documentation"
|
|
7
|
+
| "refactoring"
|
|
8
|
+
| "other";
|
|
9
|
+
|
|
10
|
+
type Validator = (commit: unknown) => true | string;
|
|
11
|
+
|
|
12
|
+
export interface CommitConfig {
|
|
13
|
+
conventional: {
|
|
14
|
+
type?: {
|
|
15
|
+
list?: CommitTypeDefinition[];
|
|
16
|
+
validator?: Validator;
|
|
17
|
+
};
|
|
18
|
+
scopes?: {
|
|
19
|
+
list?: string[];
|
|
20
|
+
validator?: Validator;
|
|
21
|
+
};
|
|
22
|
+
description?: {
|
|
23
|
+
minLength?: number;
|
|
24
|
+
maxLength?: number;
|
|
25
|
+
shouldNotEndWithPeriod?: boolean;
|
|
26
|
+
shouldNotStartWithType?: boolean;
|
|
27
|
+
validator?: Validator;
|
|
28
|
+
};
|
|
29
|
+
bodyLines?: {
|
|
30
|
+
minLength?: number;
|
|
31
|
+
maxLength?: number;
|
|
32
|
+
validator?: Validator;
|
|
33
|
+
};
|
|
34
|
+
isBreaking?: {
|
|
35
|
+
validator?: Validator;
|
|
36
|
+
};
|
|
37
|
+
isMerge?: {
|
|
38
|
+
validator?: Validator;
|
|
39
|
+
};
|
|
40
|
+
isDependency?: {
|
|
41
|
+
validator?: Validator;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
staged?: StagedConfig;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface CommitTypeDefinition {
|
|
48
|
+
readonly type: string;
|
|
49
|
+
readonly label: string;
|
|
50
|
+
readonly description: string;
|
|
51
|
+
readonly category: PRCategory;
|
|
52
|
+
readonly emoji: string;
|
|
53
|
+
readonly badgeColor: string;
|
|
54
|
+
readonly breakingAllowed: boolean;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export type StagedConfig = {
|
|
58
|
+
filePattern: RegExp[];
|
|
59
|
+
contentPattern?: RegExp[];
|
|
60
|
+
description: string;
|
|
61
|
+
disabled?: boolean;
|
|
62
|
+
ignore?: {
|
|
63
|
+
mode: "create" | "update";
|
|
64
|
+
};
|
|
65
|
+
}[];
|
|
66
|
+
|
|
67
|
+
interface BranchConfig {
|
|
68
|
+
readonly defaultBranch: string;
|
|
69
|
+
readonly prefixes: string[];
|
|
70
|
+
readonly name: {
|
|
71
|
+
readonly minLength: number;
|
|
72
|
+
readonly maxLength: number;
|
|
73
|
+
readonly allowedCharacters: RegExp;
|
|
74
|
+
readonly noConsecutiveSeparators: boolean;
|
|
75
|
+
readonly noLeadingTrailingSeparators: boolean;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
interface PackageValidationConfig {
|
|
80
|
+
readonly selectiveVersioning: {
|
|
81
|
+
readonly enabled: boolean;
|
|
82
|
+
readonly description: string;
|
|
83
|
+
};
|
|
84
|
+
readonly semanticVersioning: {
|
|
85
|
+
readonly enabled: boolean;
|
|
86
|
+
readonly description: string;
|
|
87
|
+
};
|
|
88
|
+
readonly description: {
|
|
89
|
+
readonly enabled: boolean;
|
|
90
|
+
readonly description: string;
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
interface TagValidationConfig {
|
|
95
|
+
readonly name: {
|
|
96
|
+
readonly enabled: boolean;
|
|
97
|
+
readonly description: string;
|
|
98
|
+
readonly minLength: number;
|
|
99
|
+
readonly maxLength: number;
|
|
100
|
+
readonly allowedCharacters: RegExp;
|
|
101
|
+
readonly noSpaces: boolean;
|
|
102
|
+
readonly noSpecialChars: boolean;
|
|
103
|
+
readonly validator?: Validator;
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export interface IConfig {
|
|
108
|
+
readonly commit: CommitConfig;
|
|
109
|
+
readonly branch: BranchConfig;
|
|
110
|
+
readonly package: PackageValidationConfig;
|
|
111
|
+
readonly tag: TagValidationConfig;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
type DeepPartial<T> = {
|
|
115
|
+
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export type CustomConfigJson = DeepPartial<IConfig>;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { file, write } from "bun";
|
|
3
|
+
import { entitiesShell } from "../entities.shell";
|
|
4
|
+
import type { PackageJson } from "./package.types";
|
|
5
|
+
|
|
6
|
+
export const packagesShell = {
|
|
7
|
+
/**
|
|
8
|
+
* Reads a JSON file synchronously
|
|
9
|
+
*/
|
|
10
|
+
readJsonFile: (filePath: string): PackageJson => {
|
|
11
|
+
try {
|
|
12
|
+
const json = readFileSync(filePath, "utf8");
|
|
13
|
+
return JSON.parse(json);
|
|
14
|
+
} catch (error) {
|
|
15
|
+
throw new Error(`Failed to read JSON file ${filePath}: ${error}`);
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Writes JSON data to a file
|
|
21
|
+
*/
|
|
22
|
+
writeJsonFile: async (filePath: string, data: PackageJson): Promise<void> => {
|
|
23
|
+
await write(filePath, JSON.stringify(data, null, 2));
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Reads a changelog file
|
|
28
|
+
*/
|
|
29
|
+
readChangelogFile: (filePath: string): string => {
|
|
30
|
+
try {
|
|
31
|
+
const changelog = readFileSync(filePath, "utf8");
|
|
32
|
+
return changelog || "";
|
|
33
|
+
} catch {
|
|
34
|
+
return "";
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Writes content to a changelog file
|
|
40
|
+
*/
|
|
41
|
+
writeChangelogFile: async (filePath: string, content: string): Promise<void> => {
|
|
42
|
+
try {
|
|
43
|
+
await file(filePath).exists();
|
|
44
|
+
} catch {
|
|
45
|
+
await entitiesShell.touch(filePath);
|
|
46
|
+
}
|
|
47
|
+
await write(filePath, content);
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Checks if a file exists
|
|
52
|
+
*/
|
|
53
|
+
fileExists: async (filePath: string): Promise<boolean> => {
|
|
54
|
+
try {
|
|
55
|
+
await file(filePath).exists();
|
|
56
|
+
return true;
|
|
57
|
+
} catch {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Reads directory contents
|
|
64
|
+
*/
|
|
65
|
+
readDirectory: async (dirPath: string): Promise<string[]> => {
|
|
66
|
+
const fs = await import("node:fs/promises");
|
|
67
|
+
const entries = await fs.readdir(dirPath, { withFileTypes: true });
|
|
68
|
+
return entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Checks if a file can be accessed
|
|
73
|
+
*/
|
|
74
|
+
canAccessFile: async (filePath: string): Promise<boolean> => {
|
|
75
|
+
const fs = await import("node:fs/promises");
|
|
76
|
+
try {
|
|
77
|
+
await fs.access(filePath);
|
|
78
|
+
return true;
|
|
79
|
+
} catch {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Reads a file as text
|
|
86
|
+
*/
|
|
87
|
+
readFileAsText: async (filePath: string): Promise<string> => {
|
|
88
|
+
const fs = await import("node:fs/promises");
|
|
89
|
+
return await fs.readFile(filePath, "utf-8");
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Reads a file as text synchronously
|
|
94
|
+
*/
|
|
95
|
+
readFileAsTextSync: (filePath: string): string => {
|
|
96
|
+
return readFileSync(filePath, "utf8");
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Writes content to a file as text
|
|
101
|
+
*/
|
|
102
|
+
writeFileAsText: async (filePath: string, content: string): Promise<void> => {
|
|
103
|
+
await write(filePath, content);
|
|
104
|
+
},
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Gets the workspace root directory
|
|
108
|
+
*/
|
|
109
|
+
getWorkspaceRoot: async (): Promise<string> => {
|
|
110
|
+
const fs = await import("node:fs/promises");
|
|
111
|
+
const path = await import("node:path");
|
|
112
|
+
|
|
113
|
+
let workspaceRoot = process.cwd();
|
|
114
|
+
while (workspaceRoot !== path.dirname(workspaceRoot)) {
|
|
115
|
+
try {
|
|
116
|
+
await fs.access(path.join(workspaceRoot, "package.json"));
|
|
117
|
+
break; // Found package.json, this is the workspace root
|
|
118
|
+
} catch {
|
|
119
|
+
workspaceRoot = path.dirname(workspaceRoot);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return workspaceRoot;
|
|
123
|
+
},
|
|
124
|
+
};
|